MediaSessionMgr.cxx 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675
  1. /*
  2. * Copyright (C) 2010-2011 Mamadou Diop.
  3. *
  4. * Contact: Mamadou Diop <diopmamadou(at)doubango.org>
  5. *
  6. * This file is part of Open Source Doubango Framework.
  7. *
  8. * DOUBANGO is free software: you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation, either version 3 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * DOUBANGO is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with DOUBANGO.
  20. *
  21. */
  22. #include "MediaSessionMgr.h"
  23. //
  24. // QoS
  25. //
  26. QoS::QoS(float qavg, float q1 /*= -1.f*/, float q2 /*= -1.f*/, float q3 /*= -1.f*/, float q4 /*= -1.f*/, float q5 /*= -1.f*/)
  27. : m_Qqvg(qavg)
  28. , m_VideoInWidth(0)
  29. , m_VideoOutWidth(0)
  30. , m_VideoInHeight(0)
  31. , m_VideoOutHeight(0)
  32. , m_BandwidthDownKbps(0)
  33. , m_BandwidthUpKbps(0)
  34. , m_VideoInAvgFps(0)
  35. , m_VideoDecAvgTime(0)
  36. , m_VideoEncAvgTime(0)
  37. {
  38. m_Qn[0] = q1;
  39. m_Qn[1] = q2;
  40. m_Qn[2] = q3;
  41. m_Qn[3] = q4;
  42. m_Qn[4] = q5;
  43. }
  44. QoS::~QoS()
  45. {
  46. }
  47. //
  48. // Codec
  49. //
  50. Codec::Codec(const struct tmedia_codec_s* pWrappedCodec)
  51. {
  52. m_pWrappedCodec = (struct tmedia_codec_s*)tsk_object_ref(TSK_OBJECT(pWrappedCodec));
  53. }
  54. Codec::~Codec()
  55. {
  56. TSK_OBJECT_SAFE_FREE(m_pWrappedCodec);
  57. }
  58. twrap_media_type_t Codec::getMediaType()
  59. {
  60. if(m_pWrappedCodec) {
  61. switch(m_pWrappedCodec->type) {
  62. case tmedia_audio:
  63. return twrap_media_audio;
  64. case tmedia_video:
  65. return twrap_media_video;
  66. case tmedia_msrp:
  67. return twrap_media_msrp;
  68. default:
  69. break;
  70. }
  71. }
  72. return twrap_media_none;
  73. }
  74. const char* Codec::getName()
  75. {
  76. if(m_pWrappedCodec) {
  77. return m_pWrappedCodec->name;
  78. }
  79. return tsk_null;
  80. }
  81. const char* Codec::getDescription()
  82. {
  83. if(m_pWrappedCodec) {
  84. return m_pWrappedCodec->desc;
  85. }
  86. return tsk_null;
  87. }
  88. const char* Codec::getNegFormat()
  89. {
  90. if(m_pWrappedCodec) {
  91. return m_pWrappedCodec->neg_format ? m_pWrappedCodec->neg_format : m_pWrappedCodec->format;
  92. }
  93. return tsk_null;
  94. }
  95. int Codec::getAudioSamplingRate()
  96. {
  97. if(m_pWrappedCodec && m_pWrappedCodec->plugin) {
  98. return m_pWrappedCodec->plugin->rate;
  99. }
  100. return 0;
  101. }
  102. int Codec::getAudioChannels()
  103. {
  104. if(m_pWrappedCodec && (m_pWrappedCodec->type & tmedia_audio) && m_pWrappedCodec->plugin) {
  105. return m_pWrappedCodec->plugin->audio.channels;
  106. }
  107. return 0;
  108. }
  109. int Codec::getAudioPTime()
  110. {
  111. if(m_pWrappedCodec && (m_pWrappedCodec->type & tmedia_audio) && m_pWrappedCodec->plugin) {
  112. return m_pWrappedCodec->plugin->audio.ptime;
  113. }
  114. return 0;
  115. }
  116. //
  117. // MediaSessionMgr
  118. //
  119. MediaSessionMgr::MediaSessionMgr(tmedia_session_mgr_t* pWrappedMgr)
  120. {
  121. m_pWrappedMgr = (tmedia_session_mgr_t*)tsk_object_ref(pWrappedMgr);
  122. }
  123. MediaSessionMgr::~MediaSessionMgr()
  124. {
  125. TSK_OBJECT_SAFE_FREE(m_pWrappedMgr);
  126. }
  127. bool MediaSessionMgr::sessionSetInt32(twrap_media_type_t media, const char* key, int32_t value)
  128. {
  129. tmedia_type_t _media = twrap_get_native_media_type(media);
  130. return (tmedia_session_mgr_set(m_pWrappedMgr,
  131. TMEDIA_SESSION_SET_INT32(_media, key, value),
  132. TMEDIA_SESSION_SET_NULL()) == 0);
  133. }
  134. int32_t MediaSessionMgr::sessionGetInt32(twrap_media_type_t media, const char* key)
  135. {
  136. int32_t value = 0;
  137. tmedia_type_t _media = twrap_get_native_media_type(media);
  138. (tmedia_session_mgr_get(m_pWrappedMgr,
  139. TMEDIA_SESSION_GET_INT32(_media, key, &value),
  140. TMEDIA_SESSION_GET_NULL()));
  141. return value;
  142. }
  143. QoS* MediaSessionMgr::sessionGetQoS(twrap_media_type_t media)
  144. {
  145. tmedia_type_t _media = twrap_get_native_media_type(media);
  146. tmedia_session_t* session = tmedia_session_mgr_find(m_pWrappedMgr, _media);
  147. if (session) {
  148. QoS* pQoS = new QoS(
  149. session->qos_metrics.qvag,
  150. session->qos_metrics.q1,
  151. session->qos_metrics.q2,
  152. session->qos_metrics.q3,
  153. session->qos_metrics.q4,
  154. session->qos_metrics.q5);
  155. if (pQoS && ((_media & tmedia_video) || (_media & tmedia_bfcp_video))) {
  156. pQoS->m_VideoInWidth = session->qos_metrics.video_in_width;
  157. pQoS->m_VideoInHeight = session->qos_metrics.video_in_height;
  158. pQoS->m_VideoOutWidth = session->qos_metrics.video_out_width;
  159. pQoS->m_VideoOutHeight = session->qos_metrics.video_out_height;
  160. pQoS->m_BandwidthDownKbps = session->qos_metrics.bw_down_est_kbps;
  161. pQoS->m_BandwidthUpKbps = session->qos_metrics.bw_up_est_kbps;
  162. pQoS->m_VideoInAvgFps = session->qos_metrics.video_in_avg_fps;
  163. pQoS->m_VideoDecAvgTime = session->qos_metrics.video_dec_avg_time;
  164. pQoS->m_VideoEncAvgTime = session->qos_metrics.video_enc_avg_time;
  165. }
  166. TSK_OBJECT_SAFE_FREE(session);
  167. return pQoS;
  168. }
  169. return NULL;
  170. }
  171. bool MediaSessionMgr::consumerSetInt32(twrap_media_type_t media, const char* key, int32_t value)
  172. {
  173. tmedia_type_t _media = twrap_get_native_media_type(media);
  174. return (tmedia_session_mgr_set(m_pWrappedMgr,
  175. TMEDIA_SESSION_CONSUMER_SET_INT32(_media, key, value),
  176. TMEDIA_SESSION_SET_NULL()) == 0);
  177. }
  178. bool MediaSessionMgr::consumerSetInt64(twrap_media_type_t media, const char* key, int64_t value)
  179. {
  180. tmedia_type_t _media = twrap_get_native_media_type(media);
  181. return (tmedia_session_mgr_set(m_pWrappedMgr,
  182. TMEDIA_SESSION_CONSUMER_SET_INT64(_media, key, value),
  183. TMEDIA_SESSION_SET_NULL()) == 0);
  184. }
  185. bool MediaSessionMgr::producerSetInt32(twrap_media_type_t media, const char* key, int32_t value)
  186. {
  187. tmedia_type_t _media = twrap_get_native_media_type(media);
  188. return (tmedia_session_mgr_set(m_pWrappedMgr,
  189. TMEDIA_SESSION_PRODUCER_SET_INT32(_media, key, value),
  190. TMEDIA_SESSION_SET_NULL()) == 0);
  191. }
  192. bool MediaSessionMgr::producerSetInt64(twrap_media_type_t media, const char* key, int64_t value)
  193. {
  194. tmedia_type_t _media = twrap_get_native_media_type(media);
  195. return (tmedia_session_mgr_set(m_pWrappedMgr,
  196. TMEDIA_SESSION_PRODUCER_SET_INT64(_media, key, value),
  197. TMEDIA_SESSION_SET_NULL()) == 0);
  198. }
  199. Codec* MediaSessionMgr::producerGetCodec(twrap_media_type_t media)
  200. {
  201. tmedia_codec_t* _codec = tsk_null;
  202. tmedia_type_t _media = twrap_get_native_media_type(media);
  203. (tmedia_session_mgr_get(m_pWrappedMgr,
  204. TMEDIA_SESSION_PRODUCER_GET_POBJECT(_media, "codec", &_codec),
  205. TMEDIA_SESSION_GET_NULL()));
  206. if(_codec) {
  207. Codec* pCodec = new Codec(_codec);
  208. TSK_OBJECT_SAFE_FREE(_codec);
  209. return pCodec;
  210. }
  211. return NULL;
  212. }
  213. #include "tinydav/audio/tdav_session_audio.h"
  214. #include "tinydav/video/tdav_session_video.h"
  215. #include "ProxyPluginMgr.h"
  216. const ProxyPlugin* MediaSessionMgr::findProxyPlugin(twrap_media_type_t media, bool consumer)const
  217. {
  218. const ProxyPlugin* plugin = tsk_null;
  219. ProxyPluginMgr* manager = ProxyPluginMgr::getInstance();
  220. if(media != twrap_media_audio && media != twrap_media_video) {
  221. TSK_DEBUG_ERROR("Invalid media type");
  222. return tsk_null;
  223. }
  224. if(manager && m_pWrappedMgr) {
  225. tmedia_type_t _media = twrap_get_native_media_type(media);
  226. tmedia_session_t* session = tmedia_session_mgr_find(m_pWrappedMgr, _media);
  227. if(session) {
  228. if(session->plugin == tdav_session_audio_plugin_def_t) {
  229. if(consumer) {
  230. plugin = manager->findPlugin(TDAV_SESSION_AV(session)->consumer);
  231. }
  232. else {
  233. plugin = manager->findPlugin(TDAV_SESSION_AV(session)->producer);
  234. }
  235. }
  236. else if(session->plugin == tdav_session_video_plugin_def_t) {
  237. if(consumer) {
  238. plugin = manager->findPlugin(TDAV_SESSION_AV(session)->consumer);
  239. }
  240. else {
  241. plugin = manager->findPlugin(TDAV_SESSION_AV(session)->producer);
  242. }
  243. }
  244. else {
  245. TSK_DEBUG_ERROR("Unknown session with media type = %d", _media);
  246. }
  247. tsk_object_unref(session);
  248. }
  249. }
  250. else {
  251. TSK_DEBUG_ERROR("Invalid state");
  252. }
  253. return plugin;
  254. }
  255. // FIXME: create generic function to register any kind and number of plugin from a file
  256. unsigned int MediaSessionMgr::registerAudioPluginFromFile(const char* path)
  257. {
  258. static struct tsk_plugin_s* __plugin = tsk_null;
  259. if(__plugin) {
  260. TSK_DEBUG_ERROR("Audio plugin already registered");
  261. return 0;
  262. }
  263. if((__plugin = tsk_plugin_create(path))) {
  264. unsigned int count = 0;
  265. tsk_plugin_def_ptr_const_t plugin_def_ptr_const;
  266. if((plugin_def_ptr_const = tsk_plugin_get_def(__plugin, tsk_plugin_def_type_consumer, tsk_plugin_def_media_type_audio))) {
  267. if(tmedia_consumer_plugin_register((const tmedia_consumer_plugin_def_t*)plugin_def_ptr_const) == 0) {
  268. ++count;
  269. }
  270. }
  271. if((plugin_def_ptr_const = tsk_plugin_get_def(__plugin, tsk_plugin_def_type_producer, tsk_plugin_def_media_type_audio))) {
  272. if(tmedia_producer_plugin_register((const tmedia_producer_plugin_def_t*)plugin_def_ptr_const) == 0) {
  273. ++count;
  274. }
  275. }
  276. return count;
  277. }
  278. TSK_DEBUG_ERROR("Failed to create plugin with path=%s", path);
  279. return 0;
  280. }
  281. uint64_t MediaSessionMgr::getSessionId(twrap_media_type_t media)const
  282. {
  283. //const ProxyPlugin* plugin = tsk_null;
  284. ProxyPluginMgr* manager = ProxyPluginMgr::getInstance();
  285. uint64_t id = 0;
  286. if (media != twrap_media_audio && media != twrap_media_video) {
  287. TSK_DEBUG_ERROR("Invalid media type");
  288. return 0;
  289. }
  290. if (manager && m_pWrappedMgr) {
  291. tmedia_type_t _media = twrap_get_native_media_type(media);
  292. tmedia_session_t* session = tmedia_session_mgr_find(m_pWrappedMgr, _media);
  293. if (session) {
  294. id = session->id;
  295. }
  296. tsk_object_unref(session);
  297. }
  298. else {
  299. TSK_DEBUG_ERROR("Invalid state");
  300. }
  301. return id;
  302. }
  303. bool MediaSessionMgr::defaultsSetProfile(tmedia_profile_t profile)
  304. {
  305. return (tmedia_defaults_set_profile(profile) == 0);
  306. }
  307. tmedia_profile_t MediaSessionMgr::defaultsGetProfile()
  308. {
  309. return tmedia_defaults_get_profile();
  310. }
  311. bool MediaSessionMgr::defaultsSetBandwidthLevel(tmedia_bandwidth_level_t bl) // @deprecated
  312. {
  313. return tmedia_defaults_set_bl(bl) == 0;
  314. }
  315. tmedia_bandwidth_level_t MediaSessionMgr::defaultsGetBandwidthLevel() // @deprecated
  316. {
  317. return tmedia_defaults_get_bl();
  318. }
  319. bool MediaSessionMgr::defaultsSetCongestionCtrlEnabled(bool enabled)
  320. {
  321. return tmedia_defaults_set_congestion_ctrl_enabled(enabled ? tsk_true : tsk_false) == 0;
  322. }
  323. bool MediaSessionMgr::defaultsSetVideoMotionRank(int32_t video_motion_rank)
  324. {
  325. return (tmedia_defaults_set_video_motion_rank(video_motion_rank) == 0);
  326. }
  327. bool MediaSessionMgr::defaultsSetVideoFps(int32_t video_fps)
  328. {
  329. return (tmedia_defaults_set_video_fps(video_fps) == 0);
  330. }
  331. bool MediaSessionMgr::defaultsSetBandwidthVideoUploadMax(int32_t bw_video_up_max_kbps)
  332. {
  333. return (tmedia_defaults_set_bandwidth_video_upload_max(bw_video_up_max_kbps) == 0);
  334. }
  335. bool MediaSessionMgr::defaultsSetBandwidthVideoDownloadMax(int32_t bw_video_down_max_kbps)
  336. {
  337. return (tmedia_defaults_set_bandwidth_video_download_max(bw_video_down_max_kbps) == 0);
  338. }
  339. bool MediaSessionMgr::defaultsSetPrefVideoSize(tmedia_pref_video_size_t pref_video_size)
  340. {
  341. return tmedia_defaults_set_pref_video_size(pref_video_size) == 0;
  342. }
  343. bool MediaSessionMgr::defaultsSetPrefVideoSizeOutRange(tmedia_pref_video_size_t min, tmedia_pref_video_size_t max)
  344. {
  345. return tmedia_defaults_set_pref_video_size_range(min, max) == 0;
  346. }
  347. bool MediaSessionMgr::defaultsSetAdaptativeVideoSizeOutEnabled(bool enabled)
  348. {
  349. return tmedia_defaults_set_adapt_video_size_range_enabled(enabled ? tsk_true : tsk_false) == 0;
  350. }
  351. bool MediaSessionMgr::defaultsSetJbMargin(uint32_t jb_margin_ms)
  352. {
  353. return tmedia_defaults_set_jb_margin(jb_margin_ms) == 0;
  354. }
  355. bool MediaSessionMgr::defaultsSetJbMaxLateRate(uint32_t jb_late_rate_percent)
  356. {
  357. return tmedia_defaults_set_jb_max_late_rate(jb_late_rate_percent) == 0;
  358. }
  359. bool MediaSessionMgr::defaultsSetEchoTail(uint32_t echo_tail)
  360. {
  361. return tmedia_defaults_set_echo_tail(echo_tail) == 0;
  362. }
  363. uint32_t MediaSessionMgr::defaultsGetEchoTail()
  364. {
  365. return tmedia_defaults_get_echo_tail();
  366. }
  367. bool MediaSessionMgr::defaultsSetEchoSkew(uint32_t echo_skew)
  368. {
  369. return tmedia_defaults_set_echo_skew(echo_skew) == 0;
  370. }
  371. bool MediaSessionMgr::defaultsSetEchoSuppEnabled(bool echo_supp_enabled)
  372. {
  373. return tmedia_defaults_set_echo_supp_enabled(echo_supp_enabled ? tsk_true : tsk_false) == 0;
  374. }
  375. bool MediaSessionMgr::defaultsGetEchoSuppEnabled()
  376. {
  377. return tmedia_defaults_get_echo_supp_enabled() ? true : false;
  378. }
  379. bool MediaSessionMgr::defaultsSetAgcEnabled(bool agc_enabled)
  380. {
  381. return tmedia_defaults_set_agc_enabled(agc_enabled ? tsk_true : tsk_false) == 0;
  382. }
  383. bool MediaSessionMgr::defaultsGetAgcEnabled()
  384. {
  385. return tmedia_defaults_get_agc_enabled() ? true : false;
  386. }
  387. bool MediaSessionMgr::defaultsSetAgcLevel(float agc_level)
  388. {
  389. return tmedia_defaults_set_agc_level(agc_level) == 0;
  390. }
  391. float MediaSessionMgr::defaultsGetAgcLevel()
  392. {
  393. return tmedia_defaults_get_agc_level();
  394. }
  395. bool MediaSessionMgr::defaultsSetVadEnabled(bool vad_enabled)
  396. {
  397. return tmedia_defaults_set_vad_enabled(vad_enabled ? tsk_true : tsk_false) == 0;
  398. }
  399. bool MediaSessionMgr::defaultsGetGetVadEnabled()
  400. {
  401. return tmedia_defaults_get_vad_enabled() ? true : false;
  402. }
  403. bool MediaSessionMgr::defaultsSetNoiseSuppEnabled(bool noise_supp_enabled)
  404. {
  405. return tmedia_defaults_set_noise_supp_enabled(noise_supp_enabled ? tsk_true : tsk_false) == 0;
  406. }
  407. bool MediaSessionMgr::defaultsGetNoiseSuppEnabled()
  408. {
  409. return tmedia_defaults_get_noise_supp_enabled() ? true : false;
  410. }
  411. bool MediaSessionMgr::defaultsSetNoiseSuppLevel(int32_t noise_supp_level)
  412. {
  413. return tmedia_defaults_set_noise_supp_level(noise_supp_level) == 0;
  414. }
  415. int32_t MediaSessionMgr::defaultsGetNoiseSuppLevel()
  416. {
  417. return tmedia_defaults_get_noise_supp_level();
  418. }
  419. bool MediaSessionMgr::defaultsSetConditionalRingingEnabled(bool _cond_ringing_enabled)
  420. {
  421. return tmedia_defaults_set_conditional_ringing_enabled(_cond_ringing_enabled ? tsk_true : tsk_false) == 0;
  422. }
  423. bool MediaSessionMgr::defaultsGetConditionalRingingEnabled()
  424. {
  425. return !!tmedia_defaults_get_conditional_ringing_enabled();
  426. }
  427. bool MediaSessionMgr::defaultsSet100relEnabled(bool _100rel_enabled)
  428. {
  429. return tmedia_defaults_set_100rel_enabled(_100rel_enabled ? tsk_true : tsk_false) == 0;
  430. }
  431. bool MediaSessionMgr::defaultsGet100relEnabled()
  432. {
  433. return !!tmedia_defaults_get_100rel_enabled();
  434. }
  435. bool MediaSessionMgr::defaultsSetScreenSize(int32_t sx, int32_t sy)
  436. {
  437. return tmedia_defaults_set_screen_size(sx, sy) == 0;
  438. }
  439. bool MediaSessionMgr::defaultsSetAudioGain(int32_t producer_gain, int32_t consumer_gain)
  440. {
  441. return tmedia_defaults_set_audio_gain(producer_gain, consumer_gain) == 0;
  442. }
  443. bool MediaSessionMgr::defaultsSetAudioPtime(int32_t ptime)
  444. {
  445. return tmedia_defaults_set_audio_ptime(ptime) == 0;
  446. }
  447. bool MediaSessionMgr::defaultsSetAudioChannels(int32_t channel_playback, int32_t channel_record)
  448. {
  449. return tmedia_defaults_set_audio_channels(channel_playback, channel_record) == 0;
  450. }
  451. bool MediaSessionMgr::defaultsSetRtpPortRange(uint16_t range_start, uint16_t range_stop)
  452. {
  453. return tmedia_defaults_set_rtp_port_range(range_start, range_stop) == 0;
  454. }
  455. bool MediaSessionMgr::defaultsSetRtpSymetricEnabled(bool enabled)
  456. {
  457. return tmedia_defaults_set_rtp_symetric_enabled(enabled ? tsk_true : tsk_false) == 0;
  458. }
  459. bool MediaSessionMgr::defaultsSetMediaType(twrap_media_type_t media_type)
  460. {
  461. return (tmedia_defaults_set_media_type(twrap_get_native_media_type(media_type)) == 0);
  462. }
  463. bool MediaSessionMgr::defaultsSetVolume(int32_t volume)
  464. {
  465. return (tmedia_defaults_set_volume(volume) == 0);
  466. }
  467. int32_t MediaSessionMgr::defaultsGetVolume()
  468. {
  469. return tmedia_defaults_get_volume();
  470. }
  471. bool MediaSessionMgr::defaultsSetInviteSessionTimers(int32_t timeout, const char* refresher)
  472. {
  473. int ret = tmedia_defaults_set_inv_session_expires(timeout);
  474. ret &= tmedia_defaults_set_inv_session_refresher(refresher);
  475. return (ret == 0);
  476. }
  477. bool MediaSessionMgr::defaultsSetSRtpMode(tmedia_srtp_mode_t mode)
  478. {
  479. return (tmedia_defaults_set_srtp_mode(mode) == 0);
  480. }
  481. tmedia_srtp_mode_t MediaSessionMgr::defaultsGetSRtpMode()
  482. {
  483. return tmedia_defaults_get_srtp_mode();
  484. }
  485. bool MediaSessionMgr::defaultsSetSRtpType(tmedia_srtp_type_t srtp_type)
  486. {
  487. return (tmedia_defaults_set_srtp_type(srtp_type) == 0);
  488. }
  489. tmedia_srtp_type_t MediaSessionMgr::defaultsGetSRtpType()
  490. {
  491. return tmedia_defaults_get_srtp_type();
  492. }
  493. bool MediaSessionMgr::defaultsSetRtcpEnabled(bool enabled)
  494. {
  495. return (tmedia_defaults_set_rtcp_enabled(enabled ? tsk_true : tsk_false) == 0);
  496. }
  497. bool MediaSessionMgr::defaultsGetRtcpEnabled()
  498. {
  499. return (tmedia_defaults_get_rtcp_enabled() == tsk_true);
  500. }
  501. bool MediaSessionMgr::defaultsSetRtcpMuxEnabled(bool enabled)
  502. {
  503. return (tmedia_defaults_set_rtcpmux_enabled(enabled ? tsk_true : tsk_false) == 0);
  504. }
  505. bool MediaSessionMgr::defaultsGetRtcpMuxEnabled()
  506. {
  507. return (tmedia_defaults_get_rtcpmux_enabled() == tsk_true);
  508. }
  509. bool MediaSessionMgr::defaultsSetStunEnabled(bool stun_enabled)
  510. {
  511. return (tmedia_defaults_set_stun_enabled(stun_enabled ? tsk_true : tsk_false) == 0);
  512. }
  513. bool MediaSessionMgr::defaultsSetIceStunEnabled(bool icestun_enabled)
  514. {
  515. return (tmedia_defaults_set_icestun_enabled(icestun_enabled ? tsk_true : tsk_false) == 0);
  516. }
  517. bool MediaSessionMgr::defaultsSetIceTurnEnabled(bool iceturn_enabled)
  518. {
  519. return (tmedia_defaults_set_iceturn_enabled(iceturn_enabled ? tsk_true : tsk_false) == 0);
  520. }
  521. bool MediaSessionMgr::defaultsSetStunServer(const char* server_ip, uint16_t server_port)
  522. {
  523. return (tmedia_defaults_set_stun_server(server_ip, server_port) == 0);
  524. }
  525. bool MediaSessionMgr::defaultsSetStunCred(const char* username, const char* password)
  526. {
  527. return (tmedia_defaults_set_stun_cred(username, password) == 0);
  528. }
  529. bool MediaSessionMgr::defaultsSetIceEnabled(bool ice_enabled)
  530. {
  531. return (tmedia_defaults_set_ice_enabled(ice_enabled ? tsk_true : tsk_false) == 0);
  532. }
  533. bool MediaSessionMgr::defaultsSetByPassEncoding(bool enabled)
  534. {
  535. return (tmedia_defaults_set_bypass_encoding(enabled ? tsk_true : tsk_false) == 0);
  536. }
  537. bool MediaSessionMgr::defaultsGetByPassEncoding()
  538. {
  539. return (tmedia_defaults_get_bypass_encoding() == tsk_true);
  540. }
  541. bool MediaSessionMgr::defaultsSetByPassDecoding(bool enabled)
  542. {
  543. return (tmedia_defaults_set_bypass_decoding(enabled ? tsk_true : tsk_false) == 0);
  544. }
  545. bool MediaSessionMgr::defaultsGetByPassDecoding()
  546. {
  547. return (tmedia_defaults_get_bypass_decoding() == tsk_true);
  548. }
  549. bool MediaSessionMgr::defaultsSetVideoJbEnabled(bool enabled)
  550. {
  551. return (tmedia_defaults_set_videojb_enabled(enabled ? tsk_true : tsk_false) == 0);
  552. }
  553. bool MediaSessionMgr::defaultsGetVideoJbEnabled()
  554. {
  555. return (tmedia_defaults_get_videojb_enabled() == tsk_true);
  556. }
  557. bool MediaSessionMgr::defaultsSetVideoZeroArtifactsEnabled(bool enabled)
  558. {
  559. return (tmedia_defaults_set_video_zeroartifacts_enabled(enabled ? tsk_true : tsk_false) == 0);
  560. }
  561. bool MediaSessionMgr::defaultsGetVideoZeroArtifactsEnabled()
  562. {
  563. return (tmedia_defaults_get_video_zeroartifacts_enabled() == tsk_true);
  564. }
  565. bool MediaSessionMgr::defaultsSetRtpBuffSize(unsigned buffSize)
  566. {
  567. return (tmedia_defaults_set_rtpbuff_size(buffSize) == 0);
  568. }
  569. unsigned MediaSessionMgr::defaultsGetRtpBuffSize()
  570. {
  571. return tmedia_defaults_get_rtpbuff_size();
  572. }
  573. bool MediaSessionMgr::defaultsSetAvpfTail(unsigned tail_min, unsigned tail_max)
  574. {
  575. return (tmedia_defaults_set_avpf_tail(tail_min, tail_max) == 0);
  576. }
  577. bool MediaSessionMgr::defaultsSetAvpfMode(enum tmedia_mode_e mode)
  578. {
  579. return (tmedia_defaults_set_avpf_mode(mode) == 0);
  580. }
  581. bool MediaSessionMgr::defaultsSetOpusMaxCaptureRate(uint32_t opus_maxcapturerate)
  582. {
  583. return (tmedia_defaults_set_opus_maxcapturerate(opus_maxcapturerate) == 0);
  584. }
  585. bool MediaSessionMgr::defaultsSetOpusMaxPlaybackRate(uint32_t opus_maxplaybackrate)
  586. {
  587. return (tmedia_defaults_set_opus_maxplaybackrate(opus_maxplaybackrate) == 0);
  588. }
  589. bool MediaSessionMgr::defaultsSetMaxFds(int32_t max_fds)
  590. {
  591. return (tmedia_defaults_set_max_fds(max_fds) == 0);
  592. }