rt_MediaSessionMgr.cxx 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373
  1. /*Copyright (C) 2013 Doubango Telecom <http://www.doubango.org>
  2. *
  3. * This file is part of Open Source Doubango Framework.
  4. *
  5. * DOUBANGO is free software: you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation, either version 3 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * DOUBANGO is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with DOUBANGO.
  17. */
  18. #include "rt_MediaSessionMgr.h"
  19. #include "rt_Enums.h"
  20. #include "rt_String.h"
  21. #include "MediaSessionMgr.h"
  22. using namespace doubango_rt::BackEnd;
  23. using namespace Platform;
  24. using namespace std;
  25. rtCodec::rtCodec(struct tmedia_codec_s* pCodec)
  26. {
  27. m_pCodec = new Codec(pCodec);
  28. }
  29. rtCodec::~rtCodec()
  30. {
  31. rtSafeDelete(m_pCodec);
  32. }
  33. enum class rt_twrap_media_type_t rtCodec::getMediaType()
  34. {
  35. return (rt_twrap_media_type_t)m_pCodec->getMediaType();
  36. }
  37. Platform::String^ rtCodec::getName()
  38. {
  39. return rtString::toString(m_pCodec->getName());
  40. }
  41. Platform::String^ rtCodec::getDescription()
  42. {
  43. return rtString::toString(m_pCodec->getDescription());
  44. }
  45. Platform::String^ rtCodec::getNegFormat()
  46. {
  47. return rtString::toString(m_pCodec->getNegFormat());
  48. }
  49. int rtCodec::getAudioSamplingRate()
  50. {
  51. return m_pCodec->getAudioSamplingRate();
  52. }
  53. int rtCodec::getAudioChannels()
  54. {
  55. return m_pCodec->getAudioChannels();
  56. }
  57. int rtCodec::getAudioPTime()
  58. {
  59. return m_pCodec->getAudioPTime();
  60. }
  61. rtMediaSessionMgr::rtMediaSessionMgr(struct tmedia_session_mgr_s* pWrappedMgr)
  62. {
  63. m_pMediaSessionMgr = new MediaSessionMgr(pWrappedMgr);
  64. }
  65. rtMediaSessionMgr::~rtMediaSessionMgr()
  66. {
  67. rtSafeDelete(m_pMediaSessionMgr);
  68. }
  69. bool rtMediaSessionMgr::sessionSetInt32(rt_twrap_media_type_t media, Platform::String^ key, int32 value)
  70. {
  71. return m_pMediaSessionMgr->sessionSetInt32((twrap_media_type_t)media, rtString::toUtf8(key).data(), value);
  72. }
  73. int32 rtMediaSessionMgr::sessionGetInt32(rt_twrap_media_type_t media, Platform::String^ key)
  74. {
  75. return m_pMediaSessionMgr->sessionGetInt32((twrap_media_type_t)media, rtString::toUtf8(key).data());
  76. }
  77. bool rtMediaSessionMgr::consumerSetInt32(rt_twrap_media_type_t media, Platform::String^ key, int32 value)
  78. {
  79. return m_pMediaSessionMgr->consumerSetInt32((twrap_media_type_t)media, rtString::toUtf8(key).data(), value);
  80. }
  81. bool rtMediaSessionMgr::consumerSetInt64(rt_twrap_media_type_t media, Platform::String^ key, int64 value)
  82. {
  83. return m_pMediaSessionMgr->consumerSetInt64((twrap_media_type_t)media, rtString::toUtf8(key).data(), value);
  84. }
  85. bool rtMediaSessionMgr::producerSetInt32(rt_twrap_media_type_t media, Platform::String^ key, int32 value)
  86. {
  87. return m_pMediaSessionMgr->producerSetInt32((twrap_media_type_t)media, rtString::toUtf8(key).data(), value);
  88. }
  89. bool rtMediaSessionMgr::producerSetInt64(rt_twrap_media_type_t media, Platform::String^ key, int64 value)
  90. {
  91. return m_pMediaSessionMgr->producerSetInt64((twrap_media_type_t)media, rtString::toUtf8(key).data(), value);
  92. }
  93. rtCodec^ rtMediaSessionMgr::producerGetCodec(rt_twrap_media_type_t media)
  94. {
  95. Codec* c = m_pMediaSessionMgr->producerGetCodec((twrap_media_type_t)media);
  96. if(c) {
  97. rtCodec^ codec = ref new rtCodec(const_cast<struct tmedia_codec_s*>(c->getWrappedCodec()));
  98. rtSafeDelete(c);
  99. return codec;
  100. }
  101. return nullptr;
  102. }
  103. unsigned int rtMediaSessionMgr::registerAudioPluginFromFile(Platform::String^ path)
  104. {
  105. return MediaSessionMgr::registerAudioPluginFromFile(rtString::toUtf8(path).data());
  106. }
  107. uint64 rtMediaSessionMgr::getSessionId(rt_twrap_media_type_t media)
  108. {
  109. return m_pMediaSessionMgr->getSessionId((twrap_media_type_t)media);
  110. }
  111. bool rtMediaSessionMgr::defaultsSetProfile(rt_tmedia_profile_t profile)
  112. {
  113. return MediaSessionMgr::defaultsSetProfile((tmedia_profile_t) profile);
  114. }
  115. rt_tmedia_profile_t rtMediaSessionMgr::defaultsGetProfile()
  116. {
  117. return (rt_tmedia_profile_t)MediaSessionMgr::defaultsGetProfile();
  118. }
  119. bool rtMediaSessionMgr::defaultsSetPrefVideoSize(enum class rt_tmedia_pref_video_size_t pref_video_size)
  120. {
  121. return MediaSessionMgr::defaultsSetPrefVideoSize((tmedia_pref_video_size_t) pref_video_size);
  122. }
  123. bool rtMediaSessionMgr::defaultsSetJbMargin(uint32 jb_margin_ms)
  124. {
  125. return MediaSessionMgr::defaultsSetJbMargin(jb_margin_ms);
  126. }
  127. bool rtMediaSessionMgr::defaultsSetJbMaxLateRate(uint32 jb_late_rate_percent)
  128. {
  129. return MediaSessionMgr::defaultsSetJbMaxLateRate(jb_late_rate_percent);
  130. }
  131. bool rtMediaSessionMgr::defaultsSetEchoTail(uint32 echo_tail)
  132. {
  133. return MediaSessionMgr::defaultsSetEchoTail(echo_tail);
  134. }
  135. uint32 rtMediaSessionMgr::defaultsGetEchoTail()
  136. {
  137. return MediaSessionMgr::defaultsGetEchoTail();
  138. }
  139. bool rtMediaSessionMgr::defaultsSetEchoSkew(uint32 echo_skew)
  140. {
  141. return MediaSessionMgr::defaultsSetEchoSkew(echo_skew);
  142. }
  143. bool rtMediaSessionMgr::defaultsSetEchoSuppEnabled(bool echo_supp_enabled)
  144. {
  145. return MediaSessionMgr::defaultsSetEchoSuppEnabled(echo_supp_enabled);
  146. }
  147. bool rtMediaSessionMgr::defaultsGetEchoSuppEnabled()
  148. {
  149. return MediaSessionMgr::defaultsGetEchoSuppEnabled();
  150. }
  151. bool rtMediaSessionMgr::defaultsSetAgcEnabled(bool agc_enabled)
  152. {
  153. return MediaSessionMgr::defaultsSetAgcEnabled(agc_enabled);
  154. }
  155. bool rtMediaSessionMgr::defaultsGetAgcEnabled()
  156. {
  157. return MediaSessionMgr::defaultsGetAgcEnabled();
  158. }
  159. bool rtMediaSessionMgr::defaultsSetAgcLevel(float agc_level)
  160. {
  161. return MediaSessionMgr::defaultsSetAgcLevel(agc_level);
  162. }
  163. float rtMediaSessionMgr::defaultsGetAgcLevel()
  164. {
  165. return MediaSessionMgr::defaultsGetAgcLevel();
  166. }
  167. bool rtMediaSessionMgr::defaultsSetVadEnabled(bool vad_enabled)
  168. {
  169. return MediaSessionMgr::defaultsSetVadEnabled(vad_enabled);
  170. }
  171. bool rtMediaSessionMgr::defaultsGetGetVadEnabled()
  172. {
  173. return MediaSessionMgr::defaultsGetGetVadEnabled();
  174. }
  175. bool rtMediaSessionMgr::defaultsSetNoiseSuppEnabled(bool noise_supp_enabled)
  176. {
  177. return MediaSessionMgr::defaultsSetNoiseSuppEnabled(noise_supp_enabled);
  178. }
  179. bool rtMediaSessionMgr::defaultsGetNoiseSuppEnabled()
  180. {
  181. return MediaSessionMgr::defaultsGetNoiseSuppEnabled();
  182. }
  183. bool rtMediaSessionMgr::defaultsSetNoiseSuppLevel(int32 noise_supp_level)
  184. {
  185. return MediaSessionMgr::defaultsSetNoiseSuppLevel(noise_supp_level);
  186. }
  187. int32 rtMediaSessionMgr::defaultsGetNoiseSuppLevel()
  188. {
  189. return MediaSessionMgr::defaultsGetNoiseSuppLevel();
  190. }
  191. bool rtMediaSessionMgr::defaultsSet100relEnabled(bool _100rel_enabled)
  192. {
  193. return MediaSessionMgr::defaultsSet100relEnabled(_100rel_enabled);
  194. }
  195. bool rtMediaSessionMgr::defaultsGet100relEnabled()
  196. {
  197. return MediaSessionMgr::defaultsGet100relEnabled();
  198. }
  199. bool rtMediaSessionMgr::defaultsSetScreenSize(int32 sx, int32 sy)
  200. {
  201. return MediaSessionMgr::defaultsSetScreenSize(sx, sy);
  202. }
  203. bool rtMediaSessionMgr::defaultsSetAudioGain(int32 producer_gain, int32 consumer_gain)
  204. {
  205. return MediaSessionMgr::defaultsSetAudioGain(producer_gain, consumer_gain);
  206. }
  207. bool rtMediaSessionMgr::defaultsSetRtpPortRange(uint16 range_start, uint16 range_stop)
  208. {
  209. return MediaSessionMgr::defaultsSetRtpPortRange(range_start, range_stop);
  210. }
  211. bool rtMediaSessionMgr::defaultsSetRtpSymetricEnabled(bool enabled)
  212. {
  213. return MediaSessionMgr::defaultsSetRtpSymetricEnabled(enabled);
  214. }
  215. bool rtMediaSessionMgr::defaultsSetMediaType(enum class rt_twrap_media_type_t media_type)
  216. {
  217. return MediaSessionMgr::defaultsSetMediaType((twrap_media_type_t) media_type);
  218. }
  219. bool rtMediaSessionMgr::defaultsSetVolume(int32 volume)
  220. {
  221. return MediaSessionMgr::defaultsSetVolume(volume);
  222. }
  223. int32 rtMediaSessionMgr::defaultsGetVolume()
  224. {
  225. return MediaSessionMgr::defaultsGetVolume();
  226. }
  227. bool rtMediaSessionMgr::defaultsSetInviteSessionTimers(int32 timeout, Platform::String^ refresher)
  228. {
  229. return MediaSessionMgr::defaultsSetInviteSessionTimers(timeout, rtString::toUtf8(refresher).data());
  230. }
  231. bool rtMediaSessionMgr::defaultsSetSRtpMode(enum class rt_tmedia_srtp_mode_t mode)
  232. {
  233. return MediaSessionMgr::defaultsSetSRtpMode((tmedia_srtp_mode_t) mode);
  234. }
  235. enum class rt_tmedia_srtp_mode_t rtMediaSessionMgr::defaultsGetSRtpMode()
  236. {
  237. return (rt_tmedia_srtp_mode_t)MediaSessionMgr::defaultsGetSRtpMode();
  238. }
  239. bool rtMediaSessionMgr::defaultsSetSRtpType(enum class rt_tmedia_srtp_type_t srtp_type)
  240. {
  241. return MediaSessionMgr::defaultsSetSRtpType((tmedia_srtp_type_t) srtp_type);
  242. }
  243. enum class rt_tmedia_srtp_type_t rtMediaSessionMgr::defaultsGetSRtpType()
  244. {
  245. return (rt_tmedia_srtp_type_t)MediaSessionMgr::defaultsGetSRtpType();
  246. }
  247. bool rtMediaSessionMgr::defaultsSetRtcpEnabled(bool enabled)
  248. {
  249. return MediaSessionMgr::defaultsSetRtcpEnabled(enabled);
  250. }
  251. bool rtMediaSessionMgr::defaultsGetRtcpEnabled()
  252. {
  253. return MediaSessionMgr::defaultsGetRtcpEnabled();
  254. }
  255. bool rtMediaSessionMgr::defaultsSetRtcpMuxEnabled(bool enabled)
  256. {
  257. return MediaSessionMgr::defaultsSetRtcpMuxEnabled(enabled);
  258. }
  259. bool rtMediaSessionMgr::defaultsGetRtcpMuxEnabled()
  260. {
  261. return MediaSessionMgr::defaultsGetRtcpMuxEnabled();
  262. }
  263. bool rtMediaSessionMgr::defaultsSetIceEnabled(bool ice_enabled)
  264. {
  265. return MediaSessionMgr::defaultsSetIceEnabled(ice_enabled);
  266. }
  267. bool rtMediaSessionMgr::defaultsSetByPassEncoding(bool enabled)
  268. {
  269. return MediaSessionMgr::defaultsSetByPassEncoding(enabled);
  270. }
  271. bool rtMediaSessionMgr::defaultsGetByPassEncoding()
  272. {
  273. return MediaSessionMgr::defaultsGetByPassEncoding();
  274. }
  275. bool rtMediaSessionMgr::defaultsSetByPassDecoding(bool enabled)
  276. {
  277. return MediaSessionMgr::defaultsSetByPassDecoding(enabled);
  278. }
  279. bool rtMediaSessionMgr::defaultsGetByPassDecoding()
  280. {
  281. return MediaSessionMgr::defaultsGetByPassDecoding();
  282. }
  283. bool rtMediaSessionMgr::defaultsSetVideoJbEnabled(bool enabled)
  284. {
  285. return MediaSessionMgr::defaultsSetVideoJbEnabled(enabled);
  286. }
  287. bool rtMediaSessionMgr::defaultsGetVideoJbEnabled()
  288. {
  289. return MediaSessionMgr::defaultsGetVideoJbEnabled();
  290. }
  291. bool rtMediaSessionMgr::defaultsSetRtpBuffSize(unsigned buffSize)
  292. {
  293. return MediaSessionMgr::defaultsSetRtpBuffSize(buffSize);
  294. }
  295. unsigned rtMediaSessionMgr::defaultsGetRtpBuffSize()
  296. {
  297. return MediaSessionMgr::defaultsGetRtpBuffSize();
  298. }
  299. bool rtMediaSessionMgr::defaultsSetAvpfTail(unsigned tail_min, unsigned tail_max)
  300. {
  301. return MediaSessionMgr::defaultsSetAvpfTail(tail_min, tail_max);
  302. }