media.hpp 87 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804
  1. /*
  2. * Copyright (C) 2013 Teluu Inc. (http://www.teluu.com)
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation; either version 2 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program; if not, write to the Free Software
  16. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  17. */
  18. #ifndef __PJSUA2_MEDIA_HPP__
  19. #define __PJSUA2_MEDIA_HPP__
  20. /**
  21. * @file pjsua2/media.hpp
  22. * @brief PJSUA2 media operations
  23. */
  24. #include <pjsua-lib/pjsua.h>
  25. #include <pjsua2/types.hpp>
  26. /** PJSUA2 API is inside pj namespace */
  27. namespace pj
  28. {
  29. /**
  30. * @defgroup PJSUA2_MED Media
  31. * @ingroup PJSUA2_Ref
  32. * @{
  33. */
  34. using std::string;
  35. using std::vector;
  36. /**
  37. * This structure contains all the information needed to completely describe
  38. * a media.
  39. */
  40. struct MediaFormat
  41. {
  42. /**
  43. * The format id that specifies the audio sample or video pixel format.
  44. * Some well known formats ids are declared in pjmedia_format_id
  45. * enumeration.
  46. *
  47. * @see pjmedia_format_id
  48. */
  49. pj_uint32_t id;
  50. /**
  51. * The top-most type of the media, as an information.
  52. */
  53. pjmedia_type type;
  54. public:
  55. /**
  56. * Default constructor
  57. */
  58. MediaFormat() : id(0), type(PJMEDIA_TYPE_NONE)
  59. {}
  60. };
  61. /**
  62. * This structure describe detail information about an audio media.
  63. */
  64. struct MediaFormatAudio : public MediaFormat
  65. {
  66. unsigned clockRate; /**< Audio clock rate in samples or Hz. */
  67. unsigned channelCount; /**< Number of channels. */
  68. unsigned frameTimeUsec; /**< Frame interval, in microseconds. */
  69. unsigned bitsPerSample; /**< Number of bits per sample. */
  70. pj_uint32_t avgBps; /**< Average bitrate */
  71. pj_uint32_t maxBps; /**< Maximum bitrate */
  72. /**
  73. * Construct from pjmedia_format.
  74. */
  75. void fromPj(const pjmedia_format &format);
  76. /**
  77. * Export to pjmedia_format.
  78. */
  79. pjmedia_format toPj() const;
  80. public:
  81. /**
  82. * Default constructor
  83. */
  84. MediaFormatAudio() : clockRate(0), channelCount(0), frameTimeUsec(0),
  85. bitsPerSample(0), avgBps(0), maxBps(0)
  86. {}
  87. /**
  88. * Initialization
  89. */
  90. void init(pj_uint32_t formatId, unsigned clockRate, unsigned channelCount,
  91. int frameTimeUsec, int bitsPerSample,
  92. pj_uint32_t avgBps=0, pj_uint32_t maxBps=0);
  93. };
  94. /**
  95. * This structure describe detail information about an video media.
  96. */
  97. struct MediaFormatVideo : public MediaFormat
  98. {
  99. unsigned width; /**< Video width. */
  100. unsigned height; /**< Video height. */
  101. int fpsNum; /**< Frames per second numerator. */
  102. int fpsDenum; /**< Frames per second denumerator. */
  103. pj_uint32_t avgBps; /**< Average bitrate. */
  104. pj_uint32_t maxBps; /**< Maximum bitrate. */
  105. /**
  106. * Construct from pjmedia_format.
  107. */
  108. void fromPj(const pjmedia_format &format);
  109. /**
  110. * Export to pjmedia_format.
  111. */
  112. pjmedia_format toPj() const;
  113. public:
  114. /**
  115. * Default constructor
  116. */
  117. MediaFormatVideo() : width(0), height(0), fpsNum(0),
  118. fpsDenum(1), avgBps(0), maxBps(0)
  119. {}
  120. /**
  121. * Initialization
  122. */
  123. void init(pj_uint32_t formatId, unsigned width, unsigned height,
  124. int fpsNum, int fpsDenum=1,
  125. pj_uint32_t avgBps=0, pj_uint32_t maxBps=0);
  126. };
  127. /** Array of MediaFormatAudio */
  128. typedef std::vector<MediaFormatAudio> MediaFormatAudioVector;
  129. /** Array of MediaFormatVideo */
  130. typedef std::vector<MediaFormatVideo> MediaFormatVideoVector;
  131. /**
  132. * This structure descibes information about a particular media port that
  133. * has been registered into the conference bridge.
  134. */
  135. struct ConfPortInfo
  136. {
  137. /**
  138. * Conference port number.
  139. */
  140. int portId;
  141. /**
  142. * Port name.
  143. */
  144. string name;
  145. /**
  146. * Media audio format information
  147. */
  148. MediaFormatAudio format;
  149. /**
  150. * Tx level adjustment. Value 1.0 means no adjustment, value 0 means
  151. * the port is muted, value 2.0 means the level is amplified two times.
  152. */
  153. float txLevelAdj;
  154. /**
  155. * Rx level adjustment. Value 1.0 means no adjustment, value 0 means
  156. * the port is muted, value 2.0 means the level is amplified two times.
  157. */
  158. float rxLevelAdj;
  159. /**
  160. * Array of listeners (in other words, ports where this port is
  161. * transmitting to).
  162. */
  163. IntVector listeners;
  164. public:
  165. /**
  166. * Construct from pjsua_conf_port_info.
  167. */
  168. void fromPj(const pjsua_conf_port_info &port_info);
  169. };
  170. /**
  171. * Media port, corresponds to pjmedia_port
  172. */
  173. typedef void *MediaPort;
  174. /**
  175. * Media.
  176. */
  177. class Media
  178. {
  179. public:
  180. /**
  181. * Virtual destructor.
  182. */
  183. virtual ~Media();
  184. /**
  185. * Get type of the media.
  186. *
  187. * @return The media type.
  188. */
  189. pjmedia_type getType() const;
  190. protected:
  191. /**
  192. * Constructor.
  193. */
  194. Media(pjmedia_type med_type);
  195. private:
  196. /**
  197. * Media type.
  198. */
  199. pjmedia_type type;
  200. };
  201. /**
  202. * Parameters for AudioMedia::startTransmit2() method.
  203. */
  204. struct AudioMediaTransmitParam
  205. {
  206. /**
  207. * Signal level adjustment. Value 1.0 means no level adjustment,
  208. * while value 0 means to mute the port.
  209. *
  210. * Default: 1.0
  211. */
  212. float level;
  213. public:
  214. /**
  215. * Default constructor
  216. */
  217. AudioMediaTransmitParam();
  218. };
  219. /**
  220. * Audio Media. This is a lite wrapper class for audio conference bridge port,
  221. * i.e: this class only maintains one data member, conference slot ID, and
  222. * the methods are simply proxies for conference bridge operations.
  223. *
  224. * Application can create a derived class and use registerMediaPort2()/
  225. * unregisterMediaPort() to register/unregister a media port to/from the
  226. * conference bridge.
  227. *
  228. * The library will not keep a list of AudioMedia instances, so any
  229. * AudioMedia (descendant) instances instantiated by application must be
  230. * maintained and destroyed by the application itself.
  231. *
  232. * Note that any PJSUA2 APIs that return AudioMedia instance(s) such as
  233. * Endpoint::mediaEnumPorts2() or Call::getAudioMedia() will just return
  234. * generated copy. All AudioMedia methods should work normally on this
  235. * generated copy instance.
  236. */
  237. class AudioMedia : public Media
  238. {
  239. public:
  240. /**
  241. * Get information about the specified conference port.
  242. */
  243. ConfPortInfo getPortInfo() const PJSUA2_THROW(Error);
  244. /**
  245. * Get port Id.
  246. */
  247. int getPortId() const;
  248. /**
  249. * Get information from specific port id.
  250. */
  251. static ConfPortInfo getPortInfoFromId(int port_id) PJSUA2_THROW(Error);
  252. /**
  253. * Establish unidirectional media flow to sink. This media port
  254. * will act as a source, and it may transmit to multiple destinations/sink.
  255. * And if multiple sources are transmitting to the same sink, the media
  256. * will be mixed together. Source and sink may refer to the same Media,
  257. * effectively looping the media.
  258. *
  259. * If bidirectional media flow is desired, application needs to call
  260. * this method twice, with the second one called from the opposite source
  261. * media.
  262. *
  263. * @param sink The destination Media.
  264. */
  265. void startTransmit(const AudioMedia &sink) const PJSUA2_THROW(Error);
  266. /**
  267. * Establish unidirectional media flow to sink. This media port
  268. * will act as a source, and it may transmit to multiple destinations/sink.
  269. * And if multiple sources are transmitting to the same sink, the media
  270. * will be mixed together. Source and sink may refer to the same Media,
  271. * effectively looping the media.
  272. *
  273. * Signal level from this source to the sink can be adjusted by making
  274. * it louder or quieter via the parameter param. The level adjustment
  275. * will apply to a specific connection only (i.e. only for signal
  276. * from this source to the sink), as compared to
  277. * adjustTxLevel()/adjustRxLevel() which applies to all signals from/to
  278. * this media port. The signal adjustment
  279. * will be cumulative, in this following order:
  280. * signal from this source will be adjusted with the level specified
  281. * in adjustTxLevel(), then with the level specified via this API,
  282. * and finally with the level specified to the sink's adjustRxLevel().
  283. *
  284. * If bidirectional media flow is desired, application needs to call
  285. * this method twice, with the second one called from the opposite source
  286. * media.
  287. *
  288. * @param sink The destination Media.
  289. * @param param The parameter.
  290. */
  291. void startTransmit2(const AudioMedia &sink,
  292. const AudioMediaTransmitParam &param) const
  293. PJSUA2_THROW(Error);
  294. /**
  295. * Stop media flow to destination/sink port.
  296. *
  297. * @param sink The destination media.
  298. *
  299. */
  300. void stopTransmit(const AudioMedia &sink) const PJSUA2_THROW(Error);
  301. /**
  302. * Adjust the signal level to be transmitted from the bridge to this
  303. * media port by making it louder or quieter.
  304. *
  305. * @param level Signal level adjustment. Value 1.0 means no
  306. * level adjustment, while value 0 means to mute
  307. * the port.
  308. */
  309. void adjustRxLevel(float level) PJSUA2_THROW(Error);
  310. /**
  311. * Adjust the signal level to be received from this media port (to
  312. * the bridge) by making it louder or quieter.
  313. *
  314. * @param level Signal level adjustment. Value 1.0 means no
  315. * level adjustment, while value 0 means to mute
  316. * the port.
  317. */
  318. void adjustTxLevel(float level) PJSUA2_THROW(Error);
  319. /**
  320. * Get the last received signal level.
  321. *
  322. * @return Signal level in percent.
  323. */
  324. unsigned getRxLevel() const PJSUA2_THROW(Error);
  325. /**
  326. * Get the last transmitted signal level.
  327. *
  328. * @return Signal level in percent.
  329. */
  330. unsigned getTxLevel() const PJSUA2_THROW(Error);
  331. /**
  332. * Warning: deprecated and will be removed in future release.
  333. *
  334. * Typecast from base class Media. This is useful for application written
  335. * in language that does not support downcasting such as Python.
  336. *
  337. * @param media The object to be downcasted
  338. *
  339. * @return The object as AudioMedia instance
  340. */
  341. static AudioMedia* typecastFromMedia(Media *media);
  342. /**
  343. * Default Constructor.
  344. *
  345. * Normally application will not create AudioMedia object directly,
  346. * but it instantiates an AudioMedia derived class. This is set as public
  347. * because some STL vector implementations require it.
  348. */
  349. AudioMedia();
  350. /**
  351. * Virtual Destructor.
  352. */
  353. virtual ~AudioMedia();
  354. protected:
  355. /**
  356. * Conference port Id.
  357. */
  358. int id;
  359. protected:
  360. /**
  361. * Warning: deprecated and will be removed in future release, use
  362. * registerMediaPort2() instead.
  363. *
  364. * This method needs to be called by descendants of this class to register
  365. * the media port created to the conference bridge and Endpoint's
  366. * media list.
  367. *
  368. * param port The media port to be registered to the conference bridge.
  369. *
  370. */
  371. void registerMediaPort(MediaPort port) PJSUA2_THROW(Error);
  372. /**
  373. * This method needs to be called by descendants of this class to register
  374. * the media port created to the conference bridge and Endpoint's
  375. * media list.
  376. *
  377. * param port The media port to be registered to the conference bridge.
  378. * param pool The memory pool.
  379. *
  380. */
  381. void registerMediaPort2(MediaPort port, pj_pool_t *pool)
  382. PJSUA2_THROW(Error);
  383. /**
  384. * This method needs to be called by descendants of this class to remove
  385. * the media port from the conference bridge and Endpoint's media list.
  386. * Descendant should only call this method if it has registered the media
  387. * with the previous call to registerMediaPort().
  388. */
  389. void unregisterMediaPort() PJSUA2_THROW(Error);
  390. private:
  391. /* Memory pool for deprecated registerMediaPort() */
  392. pj_caching_pool mediaCachingPool;
  393. pj_pool_t *mediaPool;
  394. };
  395. /**
  396. * Warning: deprecated, use AudioMediaVector2 instead.
  397. *
  398. * Array of Audio Media.
  399. */
  400. typedef std::vector<AudioMedia*> AudioMediaVector;
  401. /** Array of Audio Media */
  402. typedef std::vector<AudioMedia> AudioMediaVector2;
  403. /**
  404. * This structure describes a media frame.
  405. */
  406. struct MediaFrame
  407. {
  408. pjmedia_frame_type type; /**< Frame type. */
  409. ByteVector buf; /**< Frame buffer content. */
  410. unsigned size; /**< Frame size in bytes. */
  411. public:
  412. /**
  413. * Default constructor
  414. */
  415. MediaFrame()
  416. : type(PJMEDIA_FRAME_TYPE_NONE),
  417. size(0)
  418. {}
  419. };
  420. /**
  421. * Audio Media Port.
  422. */
  423. class AudioMediaPort : public AudioMedia
  424. {
  425. public:
  426. /**
  427. * Constructor.
  428. */
  429. AudioMediaPort();
  430. /**
  431. * Destructor. This will unregister the audio media port from the
  432. * conference bridge.
  433. */
  434. virtual ~AudioMediaPort();
  435. /**
  436. * Create an audio media port and register it to the conference bridge.
  437. *
  438. * @param name The port name.
  439. * @param fmt The audio format.
  440. */
  441. void createPort(const string &name, MediaFormatAudio &fmt)
  442. PJSUA2_THROW(Error);
  443. /*
  444. * Callbacks
  445. */
  446. /**
  447. * This callback is called to request a frame from this port. On input,
  448. * frame.size indicates the capacity of the frame buffer and frame.buf
  449. * will initially be an empty vector. Application can then set the frame
  450. * type and fill the vector.
  451. *
  452. * @param frame The frame.
  453. */
  454. virtual void onFrameRequested(MediaFrame &frame)
  455. { PJ_UNUSED_ARG(frame); }
  456. /**
  457. * This callback is called when this port receives a frame. The frame
  458. * content will be provided in frame.buf vector, and the frame size
  459. * can be found in either frame.size or the vector's size (both
  460. * have the same value).
  461. *
  462. * @param frame The frame.
  463. */
  464. virtual void onFrameReceived(MediaFrame &frame)
  465. { PJ_UNUSED_ARG(frame); }
  466. private:
  467. pj_pool_t *pool;
  468. pjmedia_port port;
  469. };
  470. /**
  471. * This structure contains additional info about AudioMediaPlayer.
  472. */
  473. struct AudioMediaPlayerInfo
  474. {
  475. /**
  476. * Format ID of the payload.
  477. */
  478. pjmedia_format_id formatId;
  479. /**
  480. * The number of bits per sample of the file payload. For example,
  481. * the value is 16 for PCM WAV and 8 for Alaw/Ulas WAV files.
  482. */
  483. unsigned payloadBitsPerSample;
  484. /**
  485. * The WAV payload size in bytes.
  486. */
  487. pj_uint32_t sizeBytes;
  488. /**
  489. * The WAV payload size in samples.
  490. */
  491. pj_uint32_t sizeSamples;
  492. public:
  493. /**
  494. * Default constructor
  495. */
  496. AudioMediaPlayerInfo()
  497. : formatId(PJMEDIA_FORMAT_L16),
  498. payloadBitsPerSample(0),
  499. sizeBytes(0),
  500. sizeSamples(0)
  501. {}
  502. };
  503. /**
  504. * Audio Media Player.
  505. */
  506. class AudioMediaPlayer : public AudioMedia
  507. {
  508. public:
  509. /**
  510. * Constructor.
  511. */
  512. AudioMediaPlayer();
  513. /**
  514. * Create a file player, and automatically add this
  515. * player to the conference bridge.
  516. *
  517. * @param file_name The filename to be played. Currently only
  518. * WAV files are supported, and the WAV file MUST be
  519. * formatted as 16bit PCM mono/single channel (any
  520. * clock rate is supported).
  521. * @param options Optional option flag. Application may specify
  522. * PJMEDIA_FILE_NO_LOOP to prevent playback loop.
  523. */
  524. void createPlayer(const string &file_name,
  525. unsigned options=0) PJSUA2_THROW(Error);
  526. /**
  527. * Create a file playlist media port, and automatically add the port
  528. * to the conference bridge.
  529. *
  530. * @param file_names Array of file names to be added to the play list.
  531. * Note that the files must have the same clock rate,
  532. * number of channels, and number of bits per sample.
  533. * @param label Optional label to be set for the media port.
  534. * @param options Optional option flag. Application may specify
  535. * PJMEDIA_FILE_NO_LOOP to prevent looping.
  536. */
  537. void createPlaylist(const StringVector &file_names,
  538. const string &label="",
  539. unsigned options=0) PJSUA2_THROW(Error);
  540. /**
  541. * Get additional info about the player. This operation is only valid
  542. * for player. For playlist, Error will be thrown.
  543. *
  544. * @return the info.
  545. */
  546. AudioMediaPlayerInfo getInfo() const PJSUA2_THROW(Error);
  547. /**
  548. * Get current playback position in samples. This operation is not valid
  549. * for playlist.
  550. *
  551. * @return Current playback position, in samples.
  552. */
  553. pj_uint32_t getPos() const PJSUA2_THROW(Error);
  554. /**
  555. * Set playback position in samples. This operation is not valid for
  556. * playlist.
  557. *
  558. * @param samples The desired playback position, in samples.
  559. */
  560. void setPos(pj_uint32_t samples) PJSUA2_THROW(Error);
  561. /**
  562. * Warning: deprecated and will be removed in future release.
  563. *
  564. * Typecast from base class AudioMedia. This is useful for application
  565. * written in language that does not support downcasting such as Python.
  566. *
  567. * @param media The object to be downcasted
  568. *
  569. * @return The object as AudioMediaPlayer instance
  570. */
  571. static AudioMediaPlayer* typecastFromAudioMedia(AudioMedia *media);
  572. /**
  573. * Destructor. This will unregister the player port from the conference
  574. * bridge.
  575. */
  576. virtual ~AudioMediaPlayer();
  577. public:
  578. /*
  579. * Callbacks
  580. */
  581. /* Unfortunately for pjsua2, a hard deprecation is inevitable. */
  582. #if 0 // !DEPRECATED_FOR_TICKET_2251
  583. /**
  584. * Register a callback to be called when the file player reading has
  585. * reached the end of file, or when the file reading has reached the
  586. * end of file of the last file for a playlist. If the file or playlist
  587. * is set to play repeatedly, then the callback will be called multiple
  588. * times.
  589. *
  590. * @return If the callback returns false, the playback
  591. * will stop. Note that if application destroys
  592. * the player in the callback, it must return
  593. * false here.
  594. */
  595. virtual bool onEof()
  596. { return true; }
  597. #endif
  598. /**
  599. * Register a callback to be called when the file player reading has
  600. * reached the end of file, or when the file reading has reached the
  601. * end of file of the last file for a playlist. If the file or playlist
  602. * is set to play repeatedly, then the callback will be called multiple
  603. * times.
  604. *
  605. * If application wishes to stop the playback, it can stop the media
  606. * transmission in the callback, and only after all transmissions have
  607. * been stopped, could the application safely destroy the player.
  608. */
  609. virtual void onEof2()
  610. { }
  611. private:
  612. /**
  613. * Player Id.
  614. */
  615. int playerId;
  616. /**
  617. * Low level PJMEDIA callback
  618. */
  619. static void eof_cb(pjmedia_port *port,
  620. void *usr_data);
  621. };
  622. /**
  623. * Audio Media Recorder.
  624. */
  625. class AudioMediaRecorder : public AudioMedia
  626. {
  627. public:
  628. /**
  629. * Constructor.
  630. */
  631. AudioMediaRecorder();
  632. /**
  633. * Create a file recorder, and automatically connect this recorder to
  634. * the conference bridge. The recorder currently supports recording WAV
  635. * file. The type of the recorder to use is determined by the extension of
  636. * the file (e.g. ".wav").
  637. *
  638. * @param file_name Output file name. The function will determine the
  639. * default format to be used based on the file extension.
  640. * Currently ".wav" is supported on all platforms.
  641. * @param enc_type Optionally specify the type of encoder to be used to
  642. * compress the media, if the file can support different
  643. * encodings. This value must be zero for now.
  644. * @param max_size Maximum file size. Specify zero or -1 to remove size
  645. * limitation. This value must be zero or -1 for now.
  646. * @param options Optional options, which can be used to specify the
  647. * recording file format. Supported options are
  648. * PJMEDIA_FILE_WRITE_PCM, PJMEDIA_FILE_WRITE_ALAW,
  649. * and PJMEDIA_FILE_WRITE_ULAW. Default is zero or
  650. * PJMEDIA_FILE_WRITE_PCM.
  651. */
  652. void createRecorder(const string &file_name,
  653. unsigned enc_type=0,
  654. long max_size=0,
  655. unsigned options=0) PJSUA2_THROW(Error);
  656. /**
  657. * Warning: deprecated and will be removed in future release.
  658. *
  659. * Typecast from base class AudioMedia. This is useful for application
  660. * written in language that does not support downcasting such as Python.
  661. *
  662. * @param media The object to be downcasted
  663. *
  664. * @return The object as AudioMediaRecorder instance
  665. */
  666. static AudioMediaRecorder* typecastFromAudioMedia(AudioMedia *media);
  667. /**
  668. * Destructor. This will unregister the recorder port from the conference
  669. * bridge.
  670. */
  671. virtual ~AudioMediaRecorder();
  672. private:
  673. /**
  674. * Recorder Id.
  675. */
  676. int recorderId;
  677. };
  678. /**
  679. * Tone descriptor (abstraction for pjmedia_tone_desc)
  680. */
  681. class ToneDesc : public pjmedia_tone_desc
  682. {
  683. public:
  684. ToneDesc()
  685. {
  686. pj_bzero(this, sizeof(*this));
  687. }
  688. ~ToneDesc() {}
  689. };
  690. /**
  691. * Array of tone descriptor.
  692. */
  693. typedef std::vector<ToneDesc> ToneDescVector;
  694. /**
  695. * Tone digit (abstraction for pjmedia_tone_digit)
  696. */
  697. class ToneDigit : public pjmedia_tone_digit
  698. {
  699. public:
  700. ToneDigit()
  701. {
  702. pj_bzero(this, sizeof(*this));
  703. }
  704. ~ToneDigit() {}
  705. };
  706. /**
  707. * Array of tone digits.
  708. */
  709. typedef std::vector<ToneDigit> ToneDigitVector;
  710. /**
  711. * A digit in tone digit map
  712. */
  713. struct ToneDigitMapDigit
  714. {
  715. public:
  716. string digit; /**< the digit */
  717. int freq1; /**< first frequency */
  718. int freq2; /**< second frequency */
  719. };
  720. /**
  721. * Tone digit map
  722. */
  723. typedef std::vector<ToneDigitMapDigit> ToneDigitMapVector;
  724. /**
  725. * Tone generator.
  726. */
  727. class ToneGenerator : public AudioMedia
  728. {
  729. public:
  730. /**
  731. * Constructor.
  732. */
  733. ToneGenerator();
  734. /**
  735. * Destructor. This will unregister the tone generator port from the
  736. * conference bridge.
  737. */
  738. ~ToneGenerator();
  739. /**
  740. * Create tone generator and register the port to the conference bridge.
  741. */
  742. void createToneGenerator(unsigned clock_rate = 16000,
  743. unsigned channel_count = 1) PJSUA2_THROW(Error);
  744. /**
  745. * Check if the tone generator is still busy producing some tones.
  746. * @return Non-zero if busy.
  747. */
  748. bool isBusy() const;
  749. /**
  750. * Instruct the tone generator to stop current processing.
  751. */
  752. void stop() PJSUA2_THROW(Error);
  753. /**
  754. * Rewind the playback. This will start the playback to the first
  755. * tone in the playback list.
  756. */
  757. void rewind() PJSUA2_THROW(Error);
  758. /**
  759. * Instruct the tone generator to play single or dual frequency tones
  760. * with the specified duration. The new tones will be appended to
  761. * currently playing tones, unless stop() is called before calling this
  762. * function. The playback will begin as soon as the tone generator is
  763. * connected to other media.
  764. *
  765. * @param tones Array of tones to be played.
  766. * @param loop Play the tone in a loop.
  767. */
  768. void play(const ToneDescVector &tones,
  769. bool loop=false) PJSUA2_THROW(Error);
  770. /**
  771. * Instruct the tone generator to play multiple MF digits with each of
  772. * the digits having individual ON/OFF duration. Each of the digit in the
  773. * digit array must have the corresponding descriptor in the digit map.
  774. * The new tones will be appended to currently playing tones, unless
  775. * stop() is called before calling this function. The playback will begin
  776. * as soon as the tone generator is connected to a sink media.
  777. *
  778. * @param digits Array of MF digits.
  779. * @param loop Play the tone in a loop.
  780. */
  781. void playDigits(const ToneDigitVector &digits,
  782. bool loop=false) PJSUA2_THROW(Error);
  783. /**
  784. * Get the digit-map currently used by this tone generator.
  785. *
  786. * @return The digitmap currently used by the tone generator
  787. */
  788. ToneDigitMapVector getDigitMap() const PJSUA2_THROW(Error);
  789. /**
  790. * Set digit map to be used by the tone generator.
  791. *
  792. * @param digit_map Digitmap to be used by the tone generator.
  793. */
  794. void setDigitMap(const ToneDigitMapVector &digit_map) PJSUA2_THROW(Error);
  795. private:
  796. pj_pool_t *pool;
  797. pjmedia_port *tonegen;
  798. pjmedia_tone_digit_map digitMap;
  799. };
  800. /*************************************************************************
  801. * Sound device management
  802. */
  803. /**
  804. * Audio device information structure.
  805. */
  806. struct AudioDevInfo
  807. {
  808. /**
  809. * The device ID
  810. */
  811. pjmedia_aud_dev_index id;
  812. /**
  813. * The device name
  814. */
  815. string name;
  816. /**
  817. * Maximum number of input channels supported by this device. If the
  818. * value is zero, the device does not support input operation (i.e.
  819. * it is a playback only device).
  820. */
  821. unsigned inputCount;
  822. /**
  823. * Maximum number of output channels supported by this device. If the
  824. * value is zero, the device does not support output operation (i.e.
  825. * it is an input only device).
  826. */
  827. unsigned outputCount;
  828. /**
  829. * Default sampling rate.
  830. */
  831. unsigned defaultSamplesPerSec;
  832. /**
  833. * The underlying driver name
  834. */
  835. string driver;
  836. /**
  837. * Device capabilities, as bitmask combination of pjmedia_aud_dev_cap.
  838. */
  839. unsigned caps;
  840. /**
  841. * Supported audio device routes, as bitmask combination of
  842. * pjmedia_aud_dev_route. The value may be zero if the device
  843. * does not support audio routing.
  844. */
  845. unsigned routes;
  846. /**
  847. * Array of supported extended audio formats
  848. */
  849. MediaFormatAudioVector extFmt;
  850. /**
  851. * Construct from pjmedia_aud_dev_info.
  852. */
  853. void fromPj(const pjmedia_aud_dev_info &dev_info);
  854. /**
  855. * Destructor.
  856. */
  857. ~AudioDevInfo();
  858. };
  859. /**
  860. * Warning: deprecated, use AudioDevInfoVector2 instead.
  861. *
  862. * Array of audio device info.
  863. */
  864. typedef std::vector<AudioDevInfo*> AudioDevInfoVector;
  865. /** Array of audio device info */
  866. typedef std::vector<AudioDevInfo> AudioDevInfoVector2;
  867. /**
  868. * Audio device manager.
  869. */
  870. class AudDevManager
  871. {
  872. public:
  873. /**
  874. * Get currently active capture sound devices. If sound devices has not been
  875. * created, it is possible that the function returns -1 as device IDs.
  876. *
  877. * @return Device ID of the capture device.
  878. */
  879. int getCaptureDev() const PJSUA2_THROW(Error);
  880. /**
  881. * Get the AudioMedia of the capture audio device.
  882. *
  883. * @return Audio media for the capture device.
  884. */
  885. AudioMedia &getCaptureDevMedia() PJSUA2_THROW(Error);
  886. /**
  887. * Get currently active playback sound devices. If sound devices has not
  888. * been created, it is possible that the function returns -1 as device IDs.
  889. *
  890. * @return Device ID of the playback device.
  891. */
  892. int getPlaybackDev() const PJSUA2_THROW(Error);
  893. /**
  894. * Get the AudioMedia of the speaker/playback audio device.
  895. *
  896. * @return Audio media for the speaker/playback device.
  897. */
  898. AudioMedia &getPlaybackDevMedia() PJSUA2_THROW(Error);
  899. /**
  900. * Select or change capture sound device. Application may call this
  901. * function at any time to replace current sound device. Calling this
  902. * method will not change the state of the sound device (opened/closed).
  903. *
  904. * @param capture_dev Device ID of the capture device.
  905. */
  906. void setCaptureDev(int capture_dev) const PJSUA2_THROW(Error);
  907. /**
  908. * Select or change playback sound device. Application may call this
  909. * function at any time to replace current sound device. Calling this
  910. * method will not change the state of the sound device (opened/closed).
  911. *
  912. * @param playback_dev Device ID of the playback device.
  913. */
  914. void setPlaybackDev(int playback_dev) const PJSUA2_THROW(Error);
  915. #if !DEPRECATED_FOR_TICKET_2232
  916. /**
  917. * Warning: deprecated, use enumDev2 instead. This function is not
  918. * safe in multithreaded environment.
  919. *
  920. * Enum all audio devices installed in the system. This function is not
  921. * safe in multithreaded environment.
  922. *
  923. * @return The list of audio device info.
  924. */
  925. const AudioDevInfoVector &enumDev() PJSUA2_THROW(Error);
  926. #endif
  927. /**
  928. * Enum all audio devices installed in the system.
  929. *
  930. * @return The list of audio device info.
  931. */
  932. AudioDevInfoVector2 enumDev2() const PJSUA2_THROW(Error);
  933. /**
  934. * Set pjsua to use null sound device. The null sound device only provides
  935. * the timing needed by the conference bridge, and will not interract with
  936. * any hardware.
  937. *
  938. */
  939. void setNullDev() PJSUA2_THROW(Error);
  940. /**
  941. * Disconnect the main conference bridge from any sound devices, and let
  942. * application connect the bridge to it's own sound device/master port.
  943. *
  944. * @return The port interface of the conference bridge,
  945. * so that application can connect this to it's
  946. * own sound device or master port.
  947. */
  948. MediaPort *setNoDev();
  949. /**
  950. * Set sound device mode.
  951. *
  952. * Note that this method will open the sound device, using current
  953. * active IDs set via setCaptureDev() or setPlaybackDev(), if the flag
  954. * PJSUA_SND_DEV_NO_IMMEDIATE_OPEN is not specified.
  955. *
  956. * @param mode The sound device mode, as bitmask combination
  957. * of #pjsua_snd_dev_mode
  958. *
  959. */
  960. void setSndDevMode(unsigned mode) const PJSUA2_THROW(Error);
  961. /**
  962. * Change the echo cancellation settings.
  963. *
  964. * The behavior of this function depends on whether the sound device is
  965. * currently active, and if it is, whether device or software AEC is
  966. * being used.
  967. *
  968. * If the sound device is currently active, and if the device supports AEC,
  969. * this function will forward the change request to the device and it will
  970. * be up to the device on whether support the request. If software AEC is
  971. * being used (the software EC will be used if the device does not support
  972. * AEC), this function will change the software EC settings. In all cases,
  973. * the setting will be saved for future opening of the sound device.
  974. *
  975. * If the sound device is not currently active, this will only change the
  976. * default AEC settings and the setting will be applied next time the
  977. * sound device is opened.
  978. *
  979. * @param tail_msec The tail length, in miliseconds. Set to zero to
  980. * disable AEC.
  981. * @param options Options to be passed to pjmedia_echo_create().
  982. * Normally the value should be zero.
  983. *
  984. */
  985. void setEcOptions(unsigned tail_msec, unsigned options) PJSUA2_THROW(Error);
  986. /**
  987. * Get current echo canceller tail length.
  988. *
  989. * @return The EC tail length in milliseconds,
  990. * If AEC is disabled, the value will be zero.
  991. */
  992. unsigned getEcTail() const PJSUA2_THROW(Error);
  993. /**
  994. * Check whether the sound device is currently active. The sound device
  995. * may be inactive if the application has set the auto close feature to
  996. * non-zero (the sndAutoCloseTime setting in MediaConfig), or
  997. * if null sound device or no sound device has been configured via the
  998. * setNoDev() function.
  999. */
  1000. bool sndIsActive() const;
  1001. /**
  1002. * Refresh the list of sound devices installed in the system. This method
  1003. * will only refresh the list of audio device so all active audio streams
  1004. * will be unaffected. After refreshing the device list, application MUST
  1005. * make sure to update all index references to audio devices before calling
  1006. * any method that accepts audio device index as its parameter.
  1007. *
  1008. */
  1009. void refreshDevs() PJSUA2_THROW(Error);
  1010. /**
  1011. * Get the number of sound devices installed in the system.
  1012. *
  1013. * @return The number of sound devices installed in the
  1014. * system.
  1015. *
  1016. */
  1017. unsigned getDevCount() const;
  1018. /**
  1019. * Get device information.
  1020. *
  1021. * @param id The audio device ID.
  1022. *
  1023. * @return The device information which will be filled in
  1024. * by this method once it returns successfully.
  1025. */
  1026. AudioDevInfo getDevInfo(int id) const PJSUA2_THROW(Error);
  1027. /**
  1028. * Lookup device index based on the driver and device name.
  1029. *
  1030. * @param drv_name The driver name.
  1031. * @param dev_name The device name.
  1032. *
  1033. * @return The device ID. If the device is not found,
  1034. * Error will be thrown.
  1035. */
  1036. int lookupDev(const string &drv_name,
  1037. const string &dev_name) const PJSUA2_THROW(Error);
  1038. /**
  1039. * Get string info for the specified capability.
  1040. *
  1041. * @param cap The capability ID.
  1042. *
  1043. * @return Capability name.
  1044. */
  1045. string capName(pjmedia_aud_dev_cap cap) const;
  1046. /**
  1047. * This will configure audio format capability (other than PCM) to the
  1048. * sound device being used. If sound device is currently active, the method
  1049. * will forward the setting to the sound device instance to be applied
  1050. * immediately, if it supports it.
  1051. *
  1052. * This method is only valid if the device has
  1053. * PJMEDIA_AUD_DEV_CAP_EXT_FORMAT capability in AudioDevInfo.caps flags,
  1054. * otherwise Error will be thrown.
  1055. *
  1056. * Note that in case the setting is kept for future use, it will be applied
  1057. * to any devices, even when application has changed the sound device to be
  1058. * used.
  1059. *
  1060. * @param format The audio format.
  1061. * @param keep Specify whether the setting is to be kept for
  1062. * future use.
  1063. *
  1064. */
  1065. void setExtFormat(const MediaFormatAudio &format, bool keep=true)
  1066. PJSUA2_THROW(Error);
  1067. /**
  1068. * Get the audio format capability (other than PCM) of the sound device
  1069. * being used. If sound device is currently active, the method will forward
  1070. * the request to the sound device. If sound device is currently inactive,
  1071. * and if application had previously set the setting and mark the setting
  1072. * as kept, then that setting will be returned. Otherwise, this method
  1073. * will raise error.
  1074. *
  1075. * This method is only valid if the device has
  1076. * PJMEDIA_AUD_DEV_CAP_EXT_FORMAT capability in AudioDevInfo.caps flags,
  1077. * otherwise Error will be thrown.
  1078. *
  1079. * @return The audio format.
  1080. *
  1081. */
  1082. MediaFormatAudio getExtFormat() const PJSUA2_THROW(Error);
  1083. /**
  1084. * This will configure audio input latency control or query capability to
  1085. * the sound device being used. If sound device is currently active,
  1086. * the method will forward the setting to the sound device instance to be
  1087. * applied immediately, if it supports it.
  1088. *
  1089. * This method is only valid if the device has
  1090. * PJMEDIA_AUD_DEV_CAP_INPUT_LATENCY capability in AudioDevInfo.caps flags,
  1091. * otherwise Error will be thrown.
  1092. *
  1093. * Note that in case the setting is kept for future use, it will be applied
  1094. * to any devices, even when application has changed the sound device to be
  1095. * used.
  1096. *
  1097. * @param latency_msec The input latency.
  1098. * @param keep Specify whether the setting is to be kept
  1099. * for future use.
  1100. */
  1101. void
  1102. setInputLatency(unsigned latency_msec, bool keep=true) PJSUA2_THROW(Error);
  1103. /**
  1104. * Get the audio input latency control or query capability of the sound
  1105. * device being used. If sound device is currently active, the method will
  1106. * forward the request to the sound device. If sound device is currently
  1107. * inactive, and if application had previously set the setting and mark the
  1108. * setting as kept, then that setting will be returned. Otherwise, this
  1109. * method will raise error.
  1110. *
  1111. * This method is only valid if the device has
  1112. * PJMEDIA_AUD_DEV_CAP_INPUT_LATENCY capability in AudioDevInfo.caps flags,
  1113. * otherwise Error will be thrown.
  1114. *
  1115. * @return The audio input latency.
  1116. *
  1117. */
  1118. unsigned getInputLatency() const PJSUA2_THROW(Error);
  1119. /**
  1120. * This will configure audio output latency control or query capability to
  1121. * the sound device being used. If sound device is currently active,
  1122. * the method will forward the setting to the sound device instance to be
  1123. * applied immediately, if it supports it.
  1124. *
  1125. * This method is only valid if the device has
  1126. * PJMEDIA_AUD_DEV_CAP_OUTPUT_LATENCY capability in AudioDevInfo.caps flags,
  1127. * otherwise Error will be thrown.
  1128. *
  1129. * Note that in case the setting is kept for future use, it will be applied
  1130. * to any devices, even when application has changed the sound device to be
  1131. * used.
  1132. *
  1133. * @param latency_msec The output latency.
  1134. * @param keep Specify whether the setting is to be kept
  1135. * for future use.
  1136. *
  1137. */
  1138. void
  1139. setOutputLatency(unsigned latency_msec, bool keep=true) PJSUA2_THROW(Error);
  1140. /**
  1141. * Get the audio output latency control or query capability of the sound
  1142. * device being used. If sound device is currently active, the method will
  1143. * forward the request to the sound device. If sound device is currently
  1144. * inactive, and if application had previously set the setting and mark the
  1145. * setting as kept, then that setting will be returned. Otherwise, this
  1146. * method will raise error.
  1147. *
  1148. * This method is only valid if the device has
  1149. * PJMEDIA_AUD_DEV_CAP_OUTPUT_LATENCY capability in AudioDevInfo.caps flags,
  1150. * otherwise Error will be thrown.
  1151. *
  1152. * @return The audio output latency.
  1153. *
  1154. */
  1155. unsigned getOutputLatency() const PJSUA2_THROW(Error);
  1156. /**
  1157. * This will configure audio input volume level capability to the
  1158. * sound device being used.
  1159. * If sound device is currently active, the method will forward the
  1160. * setting to the sound device instance to be applied immediately,
  1161. * if it supports it.
  1162. *
  1163. * This method is only valid if the device has
  1164. * PJMEDIA_AUD_DEV_CAP_INPUT_VOLUME_SETTING capability in AudioDevInfo.caps
  1165. * flags, otherwise Error will be thrown.
  1166. *
  1167. * Note that in case the setting is kept for future use, it will be applied
  1168. * to any devices, even when application has changed the sound device to be
  1169. * used.
  1170. *
  1171. * @param volume The input volume level, in percent.
  1172. * @param keep Specify whether the setting is to be kept for
  1173. * future use.
  1174. *
  1175. */
  1176. void setInputVolume(unsigned volume, bool keep=true) PJSUA2_THROW(Error);
  1177. /**
  1178. * Get the audio input volume level capability of the sound device being
  1179. * used. If sound device is currently active, the method will forward the
  1180. * request to the sound device. If sound device is currently inactive,
  1181. * and if application had previously set the setting and mark the setting
  1182. * as kept, then that setting will be returned. Otherwise, this method
  1183. * will raise error.
  1184. *
  1185. * This method is only valid if the device has
  1186. * PJMEDIA_AUD_DEV_CAP_INPUT_VOLUME_SETTING capability in AudioDevInfo.caps
  1187. * flags, otherwise Error will be thrown. *
  1188. * @return The audio input volume level, in percent.
  1189. *
  1190. */
  1191. unsigned getInputVolume() const PJSUA2_THROW(Error);
  1192. /**
  1193. * This will configure audio output volume level capability to the sound
  1194. * device being used. If sound device is currently active, the method will
  1195. * forward the setting to the sound device instance to be applied
  1196. * immediately, if it supports it.
  1197. *
  1198. * This method is only valid if the device has
  1199. * PJMEDIA_AUD_DEV_CAP_OUTPUT_VOLUME_SETTING capability in AudioDevInfo.caps
  1200. * flags, otherwise Error will be thrown.
  1201. *
  1202. * Note that in case the setting is kept for future use, it will be applied
  1203. * to any devices, even when application has changed the sound device to be
  1204. * used.
  1205. *
  1206. * @param volume The output volume level, in percent.
  1207. * @param keep Specify whether the setting is to be kept
  1208. * for future use.
  1209. *
  1210. */
  1211. void setOutputVolume(unsigned volume, bool keep=true) PJSUA2_THROW(Error);
  1212. /**
  1213. * Get the audio output volume level capability of the sound device being
  1214. * used. If sound device is currently active, the method will forward the
  1215. * request to the sound device. If sound device is currently inactive,
  1216. * and if application had previously set the setting and mark the setting
  1217. * as kept, then that setting will be returned. Otherwise, this method
  1218. * will raise error.
  1219. *
  1220. * This method is only valid if the device has
  1221. * PJMEDIA_AUD_DEV_CAP_OUTPUT_VOLUME_SETTING capability in AudioDevInfo.caps
  1222. * flags, otherwise Error will be thrown.
  1223. *
  1224. * @return The audio output volume level, in percent.
  1225. *
  1226. */
  1227. unsigned getOutputVolume() const PJSUA2_THROW(Error);
  1228. /**
  1229. * Get the audio input signal level capability of the sound device being
  1230. * used. If sound device is currently active, the method will forward the
  1231. * request to the sound device. If sound device is currently inactive,
  1232. * and if application had previously set the setting and mark the setting
  1233. * as kept, then that setting will be returned. Otherwise, this method
  1234. * will raise error.
  1235. *
  1236. * This method is only valid if the device has
  1237. * PJMEDIA_AUD_DEV_CAP_INPUT_SIGNAL_METER capability in AudioDevInfo.caps
  1238. * flags, otherwise Error will be thrown.
  1239. *
  1240. * @return The audio input signal level, in percent.
  1241. *
  1242. */
  1243. unsigned getInputSignal() const PJSUA2_THROW(Error);
  1244. /**
  1245. * Get the audio output signal level capability of the sound device being
  1246. * used. If sound device is currently active, the method will forward the
  1247. * request to the sound device. If sound device is currently inactive,
  1248. * and if application had previously set the setting and mark the setting
  1249. * as kept, then that setting will be returned. Otherwise, this method
  1250. * will raise error.
  1251. *
  1252. * This method is only valid if the device has
  1253. * PJMEDIA_AUD_DEV_CAP_OUTPUT_SIGNAL_METER capability in AudioDevInfo.caps
  1254. * flags, otherwise Error will be thrown.
  1255. *
  1256. * @return The audio output signal level, in percent.
  1257. *
  1258. */
  1259. unsigned getOutputSignal() const PJSUA2_THROW(Error);
  1260. /**
  1261. * This will configure audio input route capability to the sound device
  1262. * being used. If sound device is currently active, the method will
  1263. * forward the setting to the sound device instance to be applied
  1264. * immediately, if it supports it.
  1265. *
  1266. * This method is only valid if the device has
  1267. * PJMEDIA_AUD_DEV_CAP_INPUT_ROUTE capability in AudioDevInfo.caps
  1268. * flags, otherwise Error will be thrown.
  1269. *
  1270. * Note that in case the setting is kept for future use, it will be applied
  1271. * to any devices, even when application has changed the sound device to be
  1272. * used.
  1273. *
  1274. * @param route The audio input route.
  1275. * @param keep Specify whether the setting is to be kept
  1276. * for future use.
  1277. *
  1278. */
  1279. void setInputRoute(pjmedia_aud_dev_route route, bool keep=true)
  1280. PJSUA2_THROW(Error);
  1281. /**
  1282. * Get the audio input route capability of the sound device being used.
  1283. * If sound device is currently active, the method will forward the
  1284. * request to the sound device. If sound device is currently inactive,
  1285. * and if application had previously set the setting and mark the setting
  1286. * as kept, then that setting will be returned. Otherwise, this method
  1287. * will raise error.
  1288. *
  1289. * This method is only valid if the device has
  1290. * PJMEDIA_AUD_DEV_CAP_INPUT_ROUTE capability in AudioDevInfo.caps
  1291. * flags, otherwise Error will be thrown.
  1292. *
  1293. * @return The audio input route.
  1294. *
  1295. */
  1296. pjmedia_aud_dev_route getInputRoute() const PJSUA2_THROW(Error);
  1297. /**
  1298. * This will configure audio output route capability to the sound device
  1299. * being used. If sound device is currently active, the method will
  1300. * forward the setting to the sound device instance to be applied
  1301. * immediately, if it supports it.
  1302. *
  1303. * This method is only valid if the device has
  1304. * PJMEDIA_AUD_DEV_CAP_OUTPUT_ROUTE capability in AudioDevInfo.caps
  1305. * flags, otherwise Error will be thrown.
  1306. *
  1307. * Note that in case the setting is kept for future use, it will be applied
  1308. * to any devices, even when application has changed the sound device to be
  1309. * used.
  1310. *
  1311. * @param route The audio output route.
  1312. * @param keep Specify whether the setting is to be kept
  1313. * for future use.
  1314. *
  1315. */
  1316. void setOutputRoute(pjmedia_aud_dev_route route, bool keep=true)
  1317. PJSUA2_THROW(Error);
  1318. /**
  1319. * Get the audio output route capability of the sound device being used.
  1320. * If sound device is currently active, the method will forward the
  1321. * request to the sound device. If sound device is currently inactive,
  1322. * and if application had previously set the setting and mark the setting
  1323. * as kept, then that setting will be returned. Otherwise, this method
  1324. * will raise error.
  1325. *
  1326. * This method is only valid if the device has
  1327. * PJMEDIA_AUD_DEV_CAP_OUTPUT_ROUTE capability in AudioDevInfo.caps
  1328. * flags, otherwise Error will be thrown.
  1329. *
  1330. * @return The audio output route.
  1331. *
  1332. */
  1333. pjmedia_aud_dev_route getOutputRoute() const PJSUA2_THROW(Error);
  1334. /**
  1335. * This will configure audio voice activity detection capability to
  1336. * the sound device being used. If sound device is currently active,
  1337. * the method will forward the setting to the sound device instance
  1338. * to be applied immediately, if it supports it.
  1339. *
  1340. * This method is only valid if the device has PJMEDIA_AUD_DEV_CAP_VAD
  1341. * capability in AudioDevInfo.caps flags, otherwise Error will be thrown.
  1342. *
  1343. * Note that in case the setting is kept for future use, it will be applied
  1344. * to any devices, even when application has changed the sound device to be
  1345. * used.
  1346. *
  1347. * @param enable Enable/disable voice activity detection
  1348. * feature. Set true to enable.
  1349. * @param keep Specify whether the setting is to be kept for
  1350. * future use.
  1351. *
  1352. */
  1353. void setVad(bool enable, bool keep=true) PJSUA2_THROW(Error);
  1354. /**
  1355. * Get the audio voice activity detection capability of the sound device
  1356. * being used. If sound device is currently active, the method will
  1357. * forward the request to the sound device. If sound device is currently
  1358. * inactive, and if application had previously set the setting and mark
  1359. * the setting as kept, then that setting will be returned. Otherwise,
  1360. * this method will raise error.
  1361. *
  1362. * This method is only valid if the device has PJMEDIA_AUD_DEV_CAP_VAD
  1363. * capability in AudioDevInfo.caps flags, otherwise Error will be thrown.
  1364. *
  1365. * @return The audio voice activity detection feature.
  1366. *
  1367. */
  1368. bool getVad() const PJSUA2_THROW(Error);
  1369. /**
  1370. * This will configure audio comfort noise generation capability to
  1371. * the sound device being used. If sound device is currently active,
  1372. * the method will forward the setting to the sound device instance
  1373. * to be applied immediately, if it supports it.
  1374. *
  1375. * This method is only valid if the device has PJMEDIA_AUD_DEV_CAP_CNG
  1376. * capability in AudioDevInfo.caps flags, otherwise Error will be thrown.
  1377. *
  1378. * Note that in case the setting is kept for future use, it will be applied
  1379. * to any devices, even when application has changed the sound device to be
  1380. * used.
  1381. *
  1382. * @param enable Enable/disable comfort noise generation
  1383. * feature. Set true to enable.
  1384. * @param keep Specify whether the setting is to be kept for
  1385. * future use.
  1386. *
  1387. */
  1388. void setCng(bool enable, bool keep=true) PJSUA2_THROW(Error);
  1389. /**
  1390. * Get the audio comfort noise generation capability of the sound device
  1391. * being used. If sound device is currently active, the method will
  1392. * forward the request to the sound device. If sound device is currently
  1393. * inactive, and if application had previously set the setting and mark
  1394. * the setting as kept, then that setting will be returned. Otherwise,
  1395. * this method will raise error.
  1396. *
  1397. * This method is only valid if the device has PJMEDIA_AUD_DEV_CAP_CNG
  1398. * capability in AudioDevInfo.caps flags, otherwise Error will be thrown.
  1399. *
  1400. * @return The audio comfort noise generation feature.
  1401. *
  1402. */
  1403. bool getCng() const PJSUA2_THROW(Error);
  1404. /**
  1405. * This will configure audio packet loss concealment capability to
  1406. * the sound device being used. If sound device is currently active,
  1407. * the method will forward the setting to the sound device instance
  1408. * to be applied immediately, if it supports it.
  1409. *
  1410. * This method is only valid if the device has PJMEDIA_AUD_DEV_CAP_PLC
  1411. * capability in AudioDevInfo.caps flags, otherwise Error will be thrown.
  1412. *
  1413. * Note that in case the setting is kept for future use, it will be applied
  1414. * to any devices, even when application has changed the sound device to be
  1415. * used.
  1416. *
  1417. * @param enable Enable/disable packet loss concealment
  1418. * feature. Set true to enable.
  1419. * @param keep Specify whether the setting is to be kept for
  1420. * future use.
  1421. *
  1422. */
  1423. void setPlc(bool enable, bool keep=true) PJSUA2_THROW(Error);
  1424. /**
  1425. * Get the audio packet loss concealment capability of the sound device
  1426. * being used. If sound device is currently active, the method will
  1427. * forward the request to the sound device. If sound device is currently
  1428. * inactive, and if application had previously set the setting and mark
  1429. * the setting as kept, then that setting will be returned. Otherwise,
  1430. * this method will raise error.
  1431. *
  1432. * This method is only valid if the device has PJMEDIA_AUD_DEV_CAP_PLC
  1433. * capability in AudioDevInfo.caps flags, otherwise Error will be thrown.
  1434. *
  1435. * @return The audio packet loss concealment feature.
  1436. *
  1437. */
  1438. bool getPlc() const PJSUA2_THROW(Error);
  1439. private:
  1440. #if !DEPRECATED_FOR_TICKET_2232
  1441. AudioDevInfoVector audioDevList;
  1442. #endif
  1443. AudioMedia *devMedia;
  1444. /**
  1445. * Constructor.
  1446. */
  1447. AudDevManager();
  1448. /**
  1449. * Destructor.
  1450. */
  1451. ~AudDevManager();
  1452. void clearAudioDevList();
  1453. int getActiveDev(bool is_capture) const PJSUA2_THROW(Error);
  1454. friend class Endpoint;
  1455. };
  1456. /**
  1457. * Extra audio device. This class allows application to have multiple
  1458. * sound device instances active concurrently.
  1459. * Application may also use this class to improve media clock. Normally
  1460. * media clock is driven by sound device in master port, but unfortunately
  1461. * some sound devices may produce jittery clock. To improve media clock,
  1462. * application can install Null Sound Device (i.e: using
  1463. * AudDevManager::setNullDev()), which will act as a master port, and
  1464. * install the sound device as extra sound device.
  1465. *
  1466. * Note that extra sound device will not have auto-close upon idle feature.
  1467. * Also note that the extra sound device only supports mono channel.
  1468. */
  1469. class ExtraAudioDevice : public AudioMedia
  1470. {
  1471. public:
  1472. /**
  1473. * Constructor.
  1474. *
  1475. * @param playdev Playback device ID.
  1476. * @param recdev Record device ID.
  1477. */
  1478. ExtraAudioDevice(int playdev, int recdev);
  1479. /**
  1480. * Destructor.
  1481. */
  1482. virtual ~ExtraAudioDevice();
  1483. /**
  1484. * Open the audio device using format (e.g.: clock rate, bit per sample,
  1485. * samples per frame) matched to the conference bridge's format, except
  1486. * the channel count, which will be set to one (mono channel). This will
  1487. * also register the audio device port to conference bridge.
  1488. */
  1489. void open();
  1490. /**
  1491. * Close the audio device and unregister the audio device port from the
  1492. * conference bridge.
  1493. */
  1494. void close() PJSUA2_THROW(Error);
  1495. /**
  1496. * Is the extra audio device opened?
  1497. *
  1498. * @return 'true' if it is opened.
  1499. */
  1500. bool isOpened();
  1501. protected:
  1502. int playDev;
  1503. int recDev;
  1504. void *ext_snd_dev;
  1505. };
  1506. /*************************************************************************
  1507. * Video media
  1508. */
  1509. /**
  1510. * Representation of media coordinate.
  1511. */
  1512. struct MediaCoordinate
  1513. {
  1514. int x; /**< X position of the coordinate */
  1515. int y; /**< Y position of the coordinate */
  1516. };
  1517. /**
  1518. * Representation of media size.
  1519. */
  1520. struct MediaSize
  1521. {
  1522. unsigned w; /**< The width. */
  1523. unsigned h; /**< The height. */
  1524. };
  1525. /**
  1526. * This structure descibes information about a particular media port that
  1527. * has been registered into the conference bridge.
  1528. */
  1529. struct VidConfPortInfo
  1530. {
  1531. /**
  1532. * Conference port number.
  1533. */
  1534. int portId;
  1535. /**
  1536. * Port name.
  1537. */
  1538. string name;
  1539. /**
  1540. * Media audio format information
  1541. */
  1542. MediaFormatVideo format;
  1543. /**
  1544. * Array of listeners (in other words, ports where this port is
  1545. * transmitting to).
  1546. */
  1547. IntVector listeners;
  1548. /**
  1549. * Array of listeners (in other words, ports where this port is
  1550. * listening to).
  1551. */
  1552. IntVector transmitters;
  1553. public:
  1554. /**
  1555. * Construct from pjsua_conf_port_info.
  1556. */
  1557. void fromPj(const pjsua_vid_conf_port_info &port_info);
  1558. };
  1559. /**
  1560. * Parameters for VideoMedia::startTransmit() method.
  1561. */
  1562. struct VideoMediaTransmitParam
  1563. {
  1564. };
  1565. /**
  1566. * Video Media.
  1567. */
  1568. class VideoMedia : public Media
  1569. {
  1570. public:
  1571. /**
  1572. * Get information about the specified conference port.
  1573. */
  1574. VidConfPortInfo getPortInfo() const PJSUA2_THROW(Error);
  1575. /**
  1576. * Get port Id.
  1577. */
  1578. int getPortId() const;
  1579. /**
  1580. * Get information from specific port id.
  1581. */
  1582. static VidConfPortInfo getPortInfoFromId(int port_id) PJSUA2_THROW(Error);
  1583. /**
  1584. * Establish unidirectional media flow to sink. This media port
  1585. * will act as a source, and it may transmit to multiple destinations/sink.
  1586. * And if multiple sources are transmitting to the same sink, the media
  1587. * will be mixed together. Source and sink may refer to the same Media,
  1588. * effectively looping the media.
  1589. *
  1590. * If bidirectional media flow is desired, application needs to call
  1591. * this method twice, with the second one called from the opposite source
  1592. * media.
  1593. *
  1594. * @param sink The destination Media.
  1595. * @param param The parameter.
  1596. */
  1597. void startTransmit(const VideoMedia &sink,
  1598. const VideoMediaTransmitParam &param) const
  1599. PJSUA2_THROW(Error);
  1600. /**
  1601. * Stop media flow to destination/sink port.
  1602. *
  1603. * @param sink The destination media.
  1604. *
  1605. */
  1606. void stopTransmit(const VideoMedia &sink) const PJSUA2_THROW(Error);
  1607. /**
  1608. * Update or refresh port states from video port info. Some port may
  1609. * change its port info in the middle of a session, for example when
  1610. * a video stream decoder learns that incoming video size or frame rate
  1611. * has changed, video conference needs to be informed to update its
  1612. * internal states.
  1613. *
  1614. */
  1615. void update() const PJSUA2_THROW(Error);
  1616. /**
  1617. * Default Constructor.
  1618. *
  1619. * Normally application will not create VideoMedia object directly,
  1620. * but it instantiates a VideoMedia derived class. This is set as public
  1621. * because some STL vector implementations require it.
  1622. */
  1623. VideoMedia();
  1624. /**
  1625. * Virtual Destructor
  1626. */
  1627. virtual ~VideoMedia();
  1628. protected:
  1629. /**
  1630. * Conference port Id.
  1631. */
  1632. int id;
  1633. protected:
  1634. /**
  1635. * This method needs to be called by descendants of this class to register
  1636. * the media port created to the conference bridge and Endpoint's
  1637. * media list.
  1638. *
  1639. * param port The media port to be registered to the conference bridge.
  1640. * param pool The memory pool.
  1641. */
  1642. void registerMediaPort(MediaPort port, pj_pool_t *pool) PJSUA2_THROW(Error);
  1643. /**
  1644. * This method needs to be called by descendants of this class to remove
  1645. * the media port from the conference bridge and Endpoint's media list.
  1646. * Descendant should only call this method if it has registered the media
  1647. * with the previous call to registerMediaPort().
  1648. */
  1649. void unregisterMediaPort();
  1650. };
  1651. /** Array of Video Media */
  1652. typedef std::vector<VideoMedia> VideoMediaVector;
  1653. /**
  1654. * Window handle.
  1655. */
  1656. typedef struct WindowHandle {
  1657. void *window; /**< Window */
  1658. void *display; /**< Display */
  1659. } WindowHandle;
  1660. /**
  1661. * Video window handle.
  1662. */
  1663. struct VideoWindowHandle
  1664. {
  1665. /**
  1666. * The window handle type.
  1667. */
  1668. pjmedia_vid_dev_hwnd_type type;
  1669. /**
  1670. * The window handle.
  1671. */
  1672. WindowHandle handle;
  1673. };
  1674. /**
  1675. * This structure describes video window info.
  1676. */
  1677. typedef struct VideoWindowInfo
  1678. {
  1679. /**
  1680. * Flag to indicate whether this window is a native window,
  1681. * such as created by built-in preview device. If this field is
  1682. * true, only the video window handle field of this
  1683. * structure is valid.
  1684. */
  1685. bool isNative;
  1686. /**
  1687. * Video window handle.
  1688. */
  1689. VideoWindowHandle winHandle;
  1690. /**
  1691. * Renderer device ID.
  1692. */
  1693. int renderDeviceId;
  1694. /**
  1695. * Window show status. The window is hidden if false.
  1696. */
  1697. bool show;
  1698. /**
  1699. * Window position.
  1700. */
  1701. MediaCoordinate pos;
  1702. /**
  1703. * Window size.
  1704. */
  1705. MediaSize size;
  1706. } VideoWindowInfo;
  1707. /**
  1708. * Video window.
  1709. */
  1710. class VideoWindow
  1711. {
  1712. public:
  1713. /**
  1714. * Constructor
  1715. */
  1716. VideoWindow(int win_id);
  1717. /**
  1718. * Get window info.
  1719. *
  1720. * @return video window info.
  1721. */
  1722. VideoWindowInfo getInfo() const PJSUA2_THROW(Error);
  1723. /**
  1724. * Get video media or conference bridge port of the renderer of
  1725. * this video window.
  1726. *
  1727. * @return Video media of this renderer window.
  1728. */
  1729. VideoMedia getVideoMedia() PJSUA2_THROW(Error);
  1730. /**
  1731. * Show or hide window. This operation is not valid for native windows
  1732. * (VideoWindowInfo.isNative=true), on which native windowing API
  1733. * must be used instead.
  1734. *
  1735. * @param show Set to true to show the window, false to
  1736. * hide the window.
  1737. *
  1738. */
  1739. void Show(bool show) PJSUA2_THROW(Error);
  1740. /**
  1741. * Set video window position. This operation is not valid for native windows
  1742. * (VideoWindowInfo.isNative=true), on which native windowing API
  1743. * must be used instead.
  1744. *
  1745. * @param pos The window position.
  1746. *
  1747. */
  1748. void setPos(const MediaCoordinate &pos) PJSUA2_THROW(Error);
  1749. /**
  1750. * Resize window. This operation is not valid for native windows
  1751. * (VideoWindowInfo.isNative=true), on which native windowing API
  1752. * must be used instead.
  1753. *
  1754. * @param size The new window size.
  1755. *
  1756. */
  1757. void setSize(const MediaSize &size) PJSUA2_THROW(Error);
  1758. /**
  1759. * Rotate the video window. This function will change the video orientation
  1760. * and also possibly the video window size (width and height get swapped).
  1761. * This operation is not valid for native windows (VideoWindowInfo.isNative
  1762. * =true), on which native windowing API must be used instead.
  1763. *
  1764. * @param angle The rotation angle in degrees, must be
  1765. * multiple of 90.
  1766. * Specify positive value for clockwise rotation or
  1767. * negative value for counter-clockwise rotation.
  1768. */
  1769. void rotate(int angle) PJSUA2_THROW(Error);
  1770. /**
  1771. * Set output window. This operation is valid only when the underlying
  1772. * video device supports PJMEDIA_VIDEO_DEV_CAP_OUTPUT_WINDOW capability AND
  1773. * allows the output window to be changed on-the-fly, otherwise Error will
  1774. * be thrown. Currently it is only supported on Android.
  1775. *
  1776. * @param win The new output window.
  1777. */
  1778. void setWindow(const VideoWindowHandle &win) PJSUA2_THROW(Error);
  1779. /**
  1780. * Set video window full-screen. This operation is valid only when the
  1781. * underlying video device supports PJMEDIA_VID_DEV_CAP_OUTPUT_FULLSCREEN
  1782. * capability. Currently it is only supported on SDL backend.
  1783. *
  1784. * @param enabled Set to true if full screen is desired, false
  1785. * otherwise.
  1786. */
  1787. void setFullScreen(bool enabled) PJSUA2_THROW(Error);
  1788. /**
  1789. * Set video window full-screen. This operation is valid only when the
  1790. * underlying video device supports PJMEDIA_VID_DEV_CAP_OUTPUT_FULLSCREEN
  1791. * capability. Currently it is only supported on SDL backend.
  1792. *
  1793. * @param mode Fullscreen mode, see
  1794. * pjmedia_vid_dev_fullscreen_flag.
  1795. */
  1796. void setFullScreen2(pjmedia_vid_dev_fullscreen_flag mode)
  1797. PJSUA2_THROW(Error);
  1798. private:
  1799. pjsua_vid_win_id winId;
  1800. };
  1801. /**
  1802. * This structure contains parameters for VideoPreview::start()
  1803. */
  1804. struct VideoPreviewOpParam {
  1805. /**
  1806. * Device ID for the video renderer to be used for rendering the
  1807. * capture stream for preview. This parameter is ignored if native
  1808. * preview is being used.
  1809. *
  1810. * Default: PJMEDIA_VID_DEFAULT_RENDER_DEV
  1811. */
  1812. pjmedia_vid_dev_index rendId;
  1813. /**
  1814. * Show window initially.
  1815. *
  1816. * Default: PJ_TRUE.
  1817. */
  1818. bool show;
  1819. /**
  1820. * Window flags. The value is a bitmask combination of
  1821. * \a pjmedia_vid_dev_wnd_flag.
  1822. *
  1823. * Default: 0.
  1824. */
  1825. unsigned windowFlags;
  1826. /**
  1827. * Media format video. By default, this parameter is uninitialized
  1828. * and will not be used.
  1829. *
  1830. * To initialize it, use MediaFormatVideo::init().
  1831. * If left uninitialized, the capture device will be opened using
  1832. * PJMEDIA wrapper default format, e.g:
  1833. * - Android : PJMEDIA_FORMAT_I420 using the first supported size and 15fps
  1834. * - iOS : PJMEDIA_FORMAT_BGRA using size 352x288 and 15fps
  1835. * Note that when the preview is already opened, this setting will be
  1836. * ignored.
  1837. */
  1838. MediaFormatVideo format;
  1839. /**
  1840. * Optional output window to be used to display the video preview.
  1841. * This parameter will only be used if the video device supports
  1842. * PJMEDIA_VID_DEV_CAP_OUTPUT_WINDOW capability and the capability
  1843. * is not read-only.
  1844. */
  1845. VideoWindowHandle window;
  1846. public:
  1847. /**
  1848. * Default constructor initializes with default values.
  1849. */
  1850. VideoPreviewOpParam();
  1851. /**
  1852. * Convert from pjsip
  1853. */
  1854. void fromPj(const pjsua_vid_preview_param &prm);
  1855. /**
  1856. * Convert to pjsip
  1857. */
  1858. pjsua_vid_preview_param toPj() const;
  1859. };
  1860. /**
  1861. * Video Preview
  1862. */
  1863. class VideoPreview {
  1864. public:
  1865. /**
  1866. * Constructor
  1867. */
  1868. VideoPreview(int dev_id);
  1869. /**
  1870. * Determine if the specified video input device has built-in native
  1871. * preview capability. This is a convenience function that is equal to
  1872. * querying device's capability for PJMEDIA_VID_DEV_CAP_INPUT_PREVIEW
  1873. * capability.
  1874. *
  1875. * @return true if it has.
  1876. */
  1877. bool hasNative();
  1878. /**
  1879. * Start video preview window for the specified capture device.
  1880. *
  1881. * @param param Video preview parameters.
  1882. */
  1883. void start(const VideoPreviewOpParam &param) PJSUA2_THROW(Error);
  1884. /**
  1885. * Stop video preview.
  1886. */
  1887. void stop() PJSUA2_THROW(Error);
  1888. /**
  1889. * Get the preview window handle associated with the capture device,if any.
  1890. */
  1891. VideoWindow getVideoWindow();
  1892. /**
  1893. * Get video media or conference bridge port of the video capture device.
  1894. *
  1895. * @return Video media of the video capture device.
  1896. */
  1897. VideoMedia getVideoMedia() PJSUA2_THROW(Error);
  1898. private:
  1899. pjmedia_vid_dev_index devId;
  1900. pjsua_vid_win_id winId;
  1901. void updateDevId();
  1902. };
  1903. /**
  1904. * Video device information structure.
  1905. */
  1906. struct VideoDevInfo
  1907. {
  1908. /**
  1909. * The device ID
  1910. */
  1911. pjmedia_vid_dev_index id;
  1912. /**
  1913. * The device name
  1914. */
  1915. string name;
  1916. /**
  1917. * The underlying driver name
  1918. */
  1919. string driver;
  1920. /**
  1921. * The supported direction of the video device, i.e. whether it supports
  1922. * capture only, render only, or both.
  1923. */
  1924. pjmedia_dir dir;
  1925. /**
  1926. * Device capabilities, as bitmask combination of #pjmedia_vid_dev_cap
  1927. */
  1928. unsigned caps;
  1929. /**
  1930. * Array of supported video formats. Some fields in each supported video
  1931. * format may be set to zero or of "unknown" value, to indicate that the
  1932. * value is unknown or should be ignored. When these value are not set
  1933. * to zero, it indicates that the exact format combination is being used.
  1934. */
  1935. MediaFormatVideoVector fmt;
  1936. public:
  1937. /**
  1938. * Default constructor
  1939. */
  1940. VideoDevInfo() : id(-1), dir(PJMEDIA_DIR_NONE), caps(0)
  1941. {}
  1942. /**
  1943. * Construct from pjmedia_vid_dev_info.
  1944. */
  1945. void fromPj(const pjmedia_vid_dev_info &dev_info);
  1946. /**
  1947. * Destructor.
  1948. */
  1949. ~VideoDevInfo();
  1950. };
  1951. /**
  1952. * Warning: deprecated, use VideoDevInfoVector2 instead.
  1953. *
  1954. * Array of video device info.
  1955. */
  1956. typedef std::vector<VideoDevInfo*> VideoDevInfoVector;
  1957. /** Array of video device info */
  1958. typedef std::vector<VideoDevInfo> VideoDevInfoVector2;
  1959. /**
  1960. * Parameter for switching device with PJMEDIA_VID_DEV_CAP_SWITCH capability.
  1961. */
  1962. struct VideoSwitchParam
  1963. {
  1964. /**
  1965. * Target device ID to switch to. Once the switching is successful, the
  1966. * video stream will use this device and the old device will be closed.
  1967. */
  1968. pjmedia_vid_dev_index target_id;
  1969. };
  1970. /**
  1971. * Video device manager.
  1972. */
  1973. class VidDevManager {
  1974. public:
  1975. /**
  1976. * Initialize the video device subsystem. This will register all supported
  1977. * video device factories to the video device subsystem.
  1978. *
  1979. * By default, library will initialize video device subsystem automatically
  1980. * on library initialization, so application will never need to invoke this
  1981. * function. However, when PJSUA_DONT_INIT_VID_DEV_SUBSYS is set to
  1982. * non-zero, application should invoke this function before accessing
  1983. * video device.
  1984. */
  1985. void initSubsys() PJSUA2_THROW(Error);
  1986. /**
  1987. * Refresh the list of video devices installed in the system. This function
  1988. * will only refresh the list of video device so all active video streams
  1989. * will be unaffected. After refreshing the device list, application MUST
  1990. * make sure to update all index references to video devices (i.e. all
  1991. * variables of type pjmedia_vid_dev_index) before calling any function
  1992. * that accepts video device index as its parameter.
  1993. */
  1994. void refreshDevs() PJSUA2_THROW(Error);
  1995. /**
  1996. * Get the number of video devices installed in the system.
  1997. *
  1998. * @return The number of devices.
  1999. */
  2000. unsigned getDevCount();
  2001. /**
  2002. * Retrieve the video device info for the specified device index.
  2003. *
  2004. * @param dev_id The video device id
  2005. *
  2006. * @return The list of video device info
  2007. */
  2008. VideoDevInfo getDevInfo(int dev_id) const PJSUA2_THROW(Error);
  2009. #if !DEPRECATED_FOR_TICKET_2232
  2010. /**
  2011. * Warning: deprecated, use enumDev2() instead. This function is not
  2012. * safe in multithreaded environment.
  2013. *
  2014. * Enum all video devices installed in the system.
  2015. *
  2016. * @return The list of video device info
  2017. */
  2018. const VideoDevInfoVector &enumDev() PJSUA2_THROW(Error);
  2019. #endif
  2020. /**
  2021. * Enum all video devices installed in the system.
  2022. *
  2023. * @return The list of video device info
  2024. */
  2025. VideoDevInfoVector2 enumDev2() const PJSUA2_THROW(Error);
  2026. /**
  2027. * Lookup device index based on the driver and device name.
  2028. *
  2029. * @param drv_name The driver name.
  2030. * @param dev_name The device name.
  2031. *
  2032. * @return The device ID. If the device is not found,
  2033. * Error will be thrown.
  2034. */
  2035. int lookupDev(const string &drv_name,
  2036. const string &dev_name) const PJSUA2_THROW(Error);
  2037. /**
  2038. * Get string info for the specified capability.
  2039. *
  2040. * @param cap The capability ID.
  2041. *
  2042. * @return Capability name.
  2043. */
  2044. string capName(pjmedia_vid_dev_cap cap) const;
  2045. /**
  2046. * This will configure video format capability to the video device.
  2047. * If video device is currently active, the method will forward the setting
  2048. * to the video device instance to be applied immediately, if it
  2049. * supports it.
  2050. *
  2051. * This method is only valid if the device has
  2052. * PJMEDIA_VID_DEV_CAP_FORMAT capability in VideoDevInfo.caps flags,
  2053. * otherwise Error will be thrown.
  2054. *
  2055. * Note that in case the setting is kept for future use, it will be applied
  2056. * to any devices, even when application has changed the video device to be
  2057. * used.
  2058. *
  2059. * @param dev_id The video device id.
  2060. * @param format The video format.
  2061. * @param keep Specify whether the setting is to be kept for
  2062. * future use.
  2063. */
  2064. void setFormat(int dev_id,
  2065. const MediaFormatVideo &format,
  2066. bool keep) PJSUA2_THROW(Error);
  2067. /**
  2068. * Get the video format capability to the video device.
  2069. * If video device is currently active, the method will forward the request
  2070. * to the video device. If video device is currently inactive, and if
  2071. * application had previously set the setting and mark the setting as kept,
  2072. * then that setting will be returned. Otherwise, this method will
  2073. * raise error.
  2074. *
  2075. * This method is only valid if the device has
  2076. * PJMEDIA_VID_DEV_CAP_FORMAT capability in VideoDevInfo.caps flags,
  2077. * otherwise Error will be thrown.
  2078. *
  2079. * @param dev_id The video device id.
  2080. * @return keep The video format.
  2081. */
  2082. MediaFormatVideo getFormat(int dev_id) const PJSUA2_THROW(Error);
  2083. /**
  2084. * This will configure video format capability to the video device.
  2085. * If video device is currently active, the method will forward the setting
  2086. * to the video device instance to be applied immediately, if it
  2087. * supports it.
  2088. *
  2089. * This method is only valid if the device has
  2090. * PJMEDIA_VID_DEV_CAP_INPUT_SCALE capability in VideoDevInfo.caps flags,
  2091. * otherwise Error will be thrown.
  2092. *
  2093. * Note that in case the setting is kept for future use, it will be applied
  2094. * to any devices, even when application has changed the video device to be
  2095. * used.
  2096. *
  2097. * @param dev_id The video device id.
  2098. * @param scale The video scale.
  2099. * @param keep Specify whether the setting is to be kept for
  2100. * future use.
  2101. */
  2102. void setInputScale(int dev_id,
  2103. const MediaSize &scale,
  2104. bool keep) PJSUA2_THROW(Error);
  2105. /**
  2106. * Get the video input scale capability to the video device.
  2107. * If video device is currently active, the method will forward the request
  2108. * to the video device. If video device is currently inactive, and if
  2109. * application had previously set the setting and mark the setting as kept,
  2110. * then that setting will be returned. Otherwise, this method will
  2111. * raise error.
  2112. *
  2113. * This method is only valid if the device has
  2114. * PJMEDIA_VID_DEV_CAP_FORMAT capability in VideoDevInfo.caps flags,
  2115. * otherwise Error will be thrown.
  2116. *
  2117. * @param dev_id The video device id.
  2118. * @return keep The video format.
  2119. */
  2120. MediaSize getInputScale(int dev_id) const PJSUA2_THROW(Error);
  2121. /**
  2122. * This will configure fast switching to another video device.
  2123. * If video device is currently active, the method will forward the setting
  2124. * to the video device instance to be applied immediately, if it
  2125. * supports it.
  2126. *
  2127. * This method is only valid if the device has
  2128. * PJMEDIA_VID_DEV_CAP_OUTPUT_WINDOW_FLAGS capability in VideoDevInfo.caps
  2129. * flags, otherwise Error will be thrown.
  2130. *
  2131. * Note that in case the setting is kept for future use, it will be applied
  2132. * to any devices, even when application has changed the video device to be
  2133. * used.
  2134. *
  2135. * @param dev_id The video device id.
  2136. * @param flags The video window flag.
  2137. * @param keep Specify whether the setting is to be kept for
  2138. * future use.
  2139. */
  2140. void setOutputWindowFlags(int dev_id, int flags, bool keep)
  2141. PJSUA2_THROW(Error);
  2142. /**
  2143. * Get the window output flags capability to the video device.
  2144. * If video device is currently active, the method will forward the request
  2145. * to the video device. If video device is currently inactive, and if
  2146. * application had previously set the setting and mark the setting as kept,
  2147. * then that setting will be returned. Otherwise, this method will
  2148. * raise error.
  2149. *
  2150. * This method is only valid if the device has
  2151. * PJMEDIA_VID_DEV_CAP_OUTPUT_WINDOW_FLAGS capability in VideoDevInfo.caps
  2152. * flags, otherwise Error will be thrown.
  2153. *
  2154. * @param dev_id The video device id.
  2155. * @return keep The video format.
  2156. */
  2157. int getOutputWindowFlags(int dev_id) PJSUA2_THROW(Error);
  2158. /**
  2159. * This will configure fast switching to another video device.
  2160. * If video device is currently active, the method will forward the setting
  2161. * to the video device instance to be applied immediately, if it
  2162. * supports it.
  2163. *
  2164. * This method is only valid if the device has
  2165. * PJMEDIA_VID_DEV_CAP_SWITCH capability in VideoDevInfo.caps flags,
  2166. * otherwise Error will be thrown.
  2167. *
  2168. * @param dev_id The video device id.
  2169. * @param param The video switch param.
  2170. */
  2171. void switchDev(int dev_id,
  2172. const VideoSwitchParam &param) PJSUA2_THROW(Error);
  2173. /**
  2174. * Check whether the video capture device is currently active, i.e. if
  2175. * a video preview has been started or there is a video call using
  2176. * the device.
  2177. *
  2178. * @param dev_id The video device id
  2179. *
  2180. * @return True if it's active.
  2181. */
  2182. bool isCaptureActive(int dev_id) const;
  2183. /**
  2184. * This will configure video orientation of the video capture device.
  2185. * If the device is currently active (i.e. if there is a video call
  2186. * using the device or a video preview has been started), the method
  2187. * will forward the setting to the video device instance to be applied
  2188. * immediately, if it supports it.
  2189. *
  2190. * The setting will be saved for future opening of the video device,
  2191. * if the "keep" argument is set to true. If the video device is
  2192. * currently inactive, and the "keep" argument is false, this method
  2193. * will throw Error.
  2194. *
  2195. * @param dev_id The video device id
  2196. * @param orient The video orientation.
  2197. * @param keep Specify whether the setting is to be kept for
  2198. * future use.
  2199. *
  2200. */
  2201. void setCaptureOrient(pjmedia_vid_dev_index dev_id,
  2202. pjmedia_orient orient,
  2203. bool keep=true) PJSUA2_THROW(Error);
  2204. private:
  2205. #if !DEPRECATED_FOR_TICKET_2232
  2206. VideoDevInfoVector videoDevList;
  2207. #endif
  2208. void clearVideoDevList();
  2209. /**
  2210. * Constructor.
  2211. */
  2212. VidDevManager();
  2213. /**
  2214. * Destructor.
  2215. */
  2216. ~VidDevManager();
  2217. friend class Endpoint;
  2218. };
  2219. /*************************************************************************
  2220. * Codec management
  2221. */
  2222. /**
  2223. * This structure describes codec information.
  2224. */
  2225. struct CodecInfo
  2226. {
  2227. /**
  2228. * Codec unique identification.
  2229. */
  2230. string codecId;
  2231. /**
  2232. * Codec priority (integer 0-255).
  2233. */
  2234. pj_uint8_t priority;
  2235. /**
  2236. * Codec description.
  2237. */
  2238. string desc;
  2239. /**
  2240. * Construct from pjsua_codec_info.
  2241. */
  2242. void fromPj(const pjsua_codec_info &codec_info);
  2243. };
  2244. /**
  2245. * Warning: deprecated, use CodecInfoVector2 instead.
  2246. *
  2247. * Array of codec info.
  2248. */
  2249. typedef std::vector<CodecInfo*> CodecInfoVector;
  2250. /** Array of codec info */
  2251. typedef std::vector<CodecInfo> CodecInfoVector2;
  2252. /**
  2253. * Structure of codec specific parameters which contains name=value pairs.
  2254. * The codec specific parameters are to be used with SDP according to
  2255. * the standards (e.g: RFC 3555) in SDP 'a=fmtp' attribute.
  2256. */
  2257. typedef struct CodecFmtp
  2258. {
  2259. string name; /**< name */
  2260. string val; /**< value */
  2261. } CodecFmtp;
  2262. /** Array of codec fmtp */
  2263. typedef std::vector<CodecFmtp> CodecFmtpVector;
  2264. /**
  2265. * Audio codec parameters info.
  2266. */
  2267. struct CodecParamInfo
  2268. {
  2269. unsigned clockRate; /**< Sampling rate in Hz */
  2270. unsigned channelCnt; /**< Channel count. */
  2271. unsigned avgBps; /**< Average bandwidth in bits/sec */
  2272. unsigned maxBps; /**< Maximum bandwidth in bits/sec */
  2273. unsigned maxRxFrameSize; /**< Maximum frame size */
  2274. unsigned frameLen; /**< Decoder frame ptime in msec. */
  2275. unsigned frameLenDenum; /**< Decoder frame ptime denum, or
  2276. zero if ptime is integer. */
  2277. unsigned encFrameLen; /**< Encoder ptime, or zero if it's
  2278. equal to decoder ptime. */
  2279. unsigned encFrameLenDenum; /**< Encoder ptime denum, or zero
  2280. if ptime is integer. */
  2281. unsigned pcmBitsPerSample; /**< Bits/sample in the PCM side */
  2282. unsigned pt; /**< Payload type. */
  2283. pjmedia_format_id fmtId; /**< Source format, it's format of
  2284. encoder input and decoder
  2285. output. */
  2286. public:
  2287. /**
  2288. * Default constructor
  2289. */
  2290. CodecParamInfo()
  2291. : clockRate(0),
  2292. channelCnt(0),
  2293. avgBps(0),
  2294. maxBps(0),
  2295. maxRxFrameSize(0),
  2296. frameLen(0),
  2297. frameLenDenum(0),
  2298. encFrameLen(0),
  2299. encFrameLenDenum(0),
  2300. pcmBitsPerSample(0),
  2301. pt(0),
  2302. fmtId(PJMEDIA_FORMAT_L16)
  2303. {}
  2304. };
  2305. /**
  2306. * Audio codec parameters setting.
  2307. */
  2308. struct CodecParamSetting
  2309. {
  2310. unsigned frmPerPkt; /**< Number of frames per packet. */
  2311. bool vad; /**< Voice Activity Detector. */
  2312. bool cng; /**< Comfort Noise Generator. */
  2313. bool penh; /**< Perceptual Enhancement */
  2314. bool plc; /**< Packet loss concealment */
  2315. bool reserved; /**< Reserved, must be zero. */
  2316. CodecFmtpVector encFmtp; /**< Encoder's fmtp params. */
  2317. CodecFmtpVector decFmtp; /**< Decoder's fmtp params. */
  2318. unsigned packetLoss; /**< Encoder's expected pkt loss %. */
  2319. unsigned complexity; /**< Encoder complexity, 0-10(max). */
  2320. bool cbr; /**< Constant bit rate? */
  2321. };
  2322. /**
  2323. * Detailed codec attributes used in configuring an audio codec and in querying
  2324. * the capability of audio codec factories.
  2325. *
  2326. * Please note that codec parameter also contains SDP specific setting,
  2327. * setting::decFmtp and setting::encFmtp, which may need to be set
  2328. * appropriately based on the effective setting.
  2329. * See each codec documentation for more detail.
  2330. */
  2331. struct CodecParam
  2332. {
  2333. /** info */
  2334. struct CodecParamInfo info;
  2335. /** setting */
  2336. struct CodecParamSetting setting;
  2337. void fromPj(const pjmedia_codec_param &param);
  2338. pjmedia_codec_param toPj() const;
  2339. };
  2340. /**
  2341. * Opus codec parameters setting;
  2342. */
  2343. struct CodecOpusConfig
  2344. {
  2345. unsigned sample_rate; /**< Sample rate in Hz. */
  2346. unsigned channel_cnt; /**< Number of channels. */
  2347. unsigned frm_ptime; /**< Frame time in msec. */
  2348. unsigned frm_ptime_denum;/**< Frame time denumerator. */
  2349. unsigned bit_rate; /**< Encoder bit rate in bps. */
  2350. unsigned packet_loss; /**< Encoder's expected packet loss pct. */
  2351. unsigned complexity; /**< Encoder complexity, 0-10(10 is highest)*/
  2352. bool cbr; /**< Constant bit rate? */
  2353. pjmedia_codec_opus_config toPj() const;
  2354. void fromPj(const pjmedia_codec_opus_config &config);
  2355. };
  2356. /**
  2357. * Lyra codec setting;
  2358. */
  2359. struct CodecLyraConfig
  2360. {
  2361. /**
  2362. * The value represents the decoder bitrate requested by the receiver.
  2363. * Endpoints can be configured with different bitrates. For example,
  2364. * the local endpoint might be set to a bitrate of 3200, while
  2365. * the remote endpoint is set to 6000. In this scenario, the remote
  2366. * endpoint will send data at 3200 bitrate, while the local endpoint
  2367. * will send data at 6000 bitrate. Valid bitrate: 3200, 6000, 9200.
  2368. * By default it is set to PJMEDIA_CODEC_LYRA_DEFAULT_BIT_RATE.
  2369. */
  2370. unsigned bitRate;
  2371. /**
  2372. * Lyra required some additional (model) files, including
  2373. * \b lyra_config.binarypb , \b lyragan.tflite , \b quantizer.tflite and
  2374. * \b soundstream_encoder.tflite .
  2375. * This setting represents the folder containing the above files.
  2376. * The specified folder should contain these files. If an invalid folder
  2377. * is provided, the codec creation will fail.
  2378. */
  2379. string modelPath;
  2380. pjmedia_codec_lyra_config toPj() const;
  2381. void fromPj(const pjmedia_codec_lyra_config &config);
  2382. };
  2383. /**
  2384. * Detailed codec attributes used in configuring a video codec and in querying
  2385. * the capability of video codec factories.
  2386. *
  2387. * Please note that codec parameter also contains SDP specific setting,
  2388. * #decFmtp and #encFmtp, which may need to be set appropriately based on
  2389. * the effective setting. See each codec documentation for more detail.
  2390. */
  2391. struct VidCodecParam
  2392. {
  2393. pjmedia_dir dir; /**< Direction */
  2394. pjmedia_vid_packing packing; /**< Packetization strategy. */
  2395. struct
  2396. MediaFormatVideo encFmt; /**< Encoded format */
  2397. CodecFmtpVector encFmtp; /**< Encoder fmtp params */
  2398. unsigned encMtu; /**< MTU or max payload size setting*/
  2399. struct
  2400. MediaFormatVideo decFmt; /**< Decoded format */
  2401. CodecFmtpVector decFmtp; /**< Decoder fmtp params */
  2402. bool ignoreFmtp; /**< Ignore fmtp params. If set to
  2403. true, the codec will apply
  2404. format settings specified in
  2405. encFmt and decFmt only. */
  2406. public:
  2407. /**
  2408. * Default constructor
  2409. */
  2410. VidCodecParam() : dir(PJMEDIA_DIR_NONE),
  2411. packing(PJMEDIA_VID_PACKING_UNKNOWN),
  2412. encMtu(0),
  2413. ignoreFmtp(false)
  2414. {}
  2415. void fromPj(const pjmedia_vid_codec_param &param);
  2416. pjmedia_vid_codec_param toPj() const;
  2417. };
  2418. /*************************************************************************
  2419. * Media event
  2420. */
  2421. /**
  2422. * This structure describes a media format changed event.
  2423. */
  2424. struct MediaFmtChangedEvent
  2425. {
  2426. unsigned newWidth; /**< The new width. */
  2427. unsigned newHeight; /**< The new height. */
  2428. };
  2429. /**
  2430. * This structure describes an audio device error event.
  2431. */
  2432. struct AudDevErrorEvent
  2433. {
  2434. pjmedia_dir dir; /**< The direction. */
  2435. int id; /**< The audio device ID. */
  2436. pj_status_t status; /**< The status code. */
  2437. };
  2438. /**
  2439. * Media event data.
  2440. */
  2441. typedef union MediaEventData {
  2442. /**
  2443. * Media format changed event data.
  2444. */
  2445. MediaFmtChangedEvent fmtChanged;
  2446. /**
  2447. * Audio device error event data.
  2448. */
  2449. AudDevErrorEvent audDevError;
  2450. /**
  2451. * Pointer to storage to user event data, if it's outside
  2452. * this struct
  2453. */
  2454. GenericData ptr;
  2455. } MediaEventData;
  2456. /**
  2457. * This structure describes a media event. It corresponds to the
  2458. * pjmedia_event structure.
  2459. */
  2460. struct MediaEvent
  2461. {
  2462. /**
  2463. * The event type.
  2464. */
  2465. pjmedia_event_type type;
  2466. /**
  2467. * Additional data/parameters about the event. The type of data
  2468. * will be specific to the event type being reported.
  2469. */
  2470. MediaEventData data;
  2471. /**
  2472. * Pointer to original pjmedia_event. Only valid when the struct
  2473. * is converted from PJSIP's pjmedia_event.
  2474. */
  2475. void *pjMediaEvent;
  2476. public:
  2477. /**
  2478. * Default constructor
  2479. */
  2480. MediaEvent() : type(PJMEDIA_EVENT_NONE), pjMediaEvent(NULL)
  2481. {}
  2482. /**
  2483. * Convert from pjsip
  2484. */
  2485. void fromPj(const pjmedia_event &ev);
  2486. };
  2487. /**
  2488. * @} // PJSUA2_MED
  2489. */
  2490. } // namespace pj
  2491. #endif /* __PJSUA2_MEDIA_HPP__ */