MediaSessionMgr.h 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248
  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. #ifndef TINYWRAP_MEDIA_SESSIONMGR_H
  23. #define TINYWRAP_MEDIA_SESSIONMGR_H
  24. #include "tinyWRAP_config.h"
  25. #include "tinymedia.h"
  26. #include "Common.h"
  27. class ProxyPlugin;
  28. class MediaSessionMgr;
  29. class TINYWRAP_API QoS
  30. {
  31. friend class MediaSessionMgr;
  32. public:
  33. #if !defined(SWIG)
  34. QoS(float qavg, float q1 = -1.f, float q2 = -1.f, float q3 = -1.f, float q4 = -1.f, float q5 = -1.f);
  35. #endif
  36. virtual ~QoS();
  37. float getQavg() {
  38. return m_Qqvg;
  39. }
  40. float getQ1() {
  41. return m_Qn[0];
  42. }
  43. float getQ2() {
  44. return m_Qn[1];
  45. }
  46. float getQ3() {
  47. return m_Qn[2];
  48. }
  49. float getQ4() {
  50. return m_Qn[3];
  51. }
  52. float getQ5() {
  53. return m_Qn[4];
  54. }
  55. unsigned getVideoInWidth() {
  56. return m_VideoInWidth;
  57. }
  58. unsigned getVideoOutWidth() {
  59. return m_VideoOutWidth;
  60. }
  61. unsigned getVideoInHeight() {
  62. return m_VideoInHeight;
  63. }
  64. unsigned getVideoOutHeight() {
  65. return m_VideoOutHeight;
  66. }
  67. unsigned getBandwidthDownKbps() {
  68. return m_BandwidthDownKbps;
  69. }
  70. unsigned getBandwidthUpKbps() {
  71. return m_BandwidthUpKbps;
  72. }
  73. unsigned getVideoInAvgFps() {
  74. return m_VideoInAvgFps;
  75. }
  76. unsigned getVideoDecAvgTime() { // In millis
  77. return m_VideoDecAvgTime;
  78. }
  79. unsigned getVideoEncAvgTime() { // In millis
  80. return m_VideoEncAvgTime;
  81. }
  82. private:
  83. float m_Qqvg;
  84. float m_Qn[5];
  85. unsigned m_VideoInWidth;
  86. unsigned m_VideoOutWidth;
  87. unsigned m_VideoInHeight;
  88. unsigned m_VideoOutHeight;
  89. unsigned m_BandwidthDownKbps;
  90. unsigned m_BandwidthUpKbps;
  91. unsigned m_VideoInAvgFps;
  92. unsigned m_VideoDecAvgTime;
  93. unsigned m_VideoEncAvgTime;
  94. };
  95. class TINYWRAP_API Codec
  96. {
  97. public:
  98. #if !defined(SWIG)
  99. Codec(const struct tmedia_codec_s* pWrappedCodec);
  100. #endif
  101. virtual ~Codec();
  102. public:
  103. #if !defined(SWIG)
  104. const struct tmedia_codec_s* getWrappedCodec() {
  105. return m_pWrappedCodec;
  106. }
  107. inline bool isOpened() {
  108. return (m_pWrappedCodec && (m_pWrappedCodec->opened == tsk_true));
  109. }
  110. #endif
  111. twrap_media_type_t getMediaType();
  112. const char* getName();
  113. const char* getDescription();
  114. const char* getNegFormat();
  115. int getAudioSamplingRate();
  116. int getAudioChannels();
  117. int getAudioPTime();
  118. private:
  119. struct tmedia_codec_s* m_pWrappedCodec;
  120. };
  121. class TINYWRAP_API MediaSessionMgr
  122. {
  123. public:
  124. #if !defined(SWIG)
  125. MediaSessionMgr(tmedia_session_mgr_t* pWrappedMgr);
  126. #endif
  127. virtual ~MediaSessionMgr();
  128. public:
  129. bool sessionSetInt32(twrap_media_type_t media, const char* key, int32_t value);
  130. int32_t sessionGetInt32(twrap_media_type_t media, const char* key);
  131. QoS* sessionGetQoS(twrap_media_type_t media);
  132. bool consumerSetInt32(twrap_media_type_t media, const char* key, int32_t value);
  133. bool consumerSetInt64(twrap_media_type_t media, const char* key, int64_t value);
  134. bool producerSetInt32(twrap_media_type_t media, const char* key, int32_t value);
  135. bool producerSetInt64(twrap_media_type_t media, const char* key, int64_t value);
  136. Codec* producerGetCodec(twrap_media_type_t media);
  137. #if !defined(SWIG)
  138. const ProxyPlugin* findProxyPlugin(twrap_media_type_t media, bool consumer)const;
  139. #endif
  140. const ProxyPlugin* findProxyPluginConsumer(twrap_media_type_t media)const {
  141. return this->findProxyPlugin(media, true);
  142. }
  143. const ProxyPlugin* findProxyPluginProducer(twrap_media_type_t media)const {
  144. return this->findProxyPlugin(media, false);
  145. }
  146. static unsigned int registerAudioPluginFromFile(const char* path);
  147. uint64_t getSessionId(twrap_media_type_t media)const;
  148. #if !defined(SWIG)
  149. inline const tmedia_session_mgr_t* getWrappedMgr()const {
  150. return m_pWrappedMgr;
  151. }
  152. #endif
  153. // Defaults
  154. static bool defaultsSetProfile(tmedia_profile_t profile);
  155. static tmedia_profile_t defaultsGetProfile();
  156. static bool defaultsSetBandwidthLevel(tmedia_bandwidth_level_t bl); // @deprecated
  157. static tmedia_bandwidth_level_t defaultsGetBandwidthLevel(); // @deprecated
  158. static bool defaultsSetCongestionCtrlEnabled(bool enabled);
  159. static bool defaultsSetVideoMotionRank(int32_t video_motion_rank);
  160. static bool defaultsSetVideoFps(int32_t video_fps);
  161. static bool defaultsSetBandwidthVideoUploadMax(int32_t bw_video_up_max_kbps);
  162. static bool defaultsSetBandwidthVideoDownloadMax(int32_t bw_video_down_max_kbps);
  163. static bool defaultsSetPrefVideoSize(tmedia_pref_video_size_t pref_video_size);
  164. static bool defaultsSetPrefVideoSizeOutRange(tmedia_pref_video_size_t min, tmedia_pref_video_size_t max);
  165. static bool defaultsSetAdaptativeVideoSizeOutEnabled(bool enabled);
  166. static bool defaultsSetJbMargin(uint32_t jb_margin_ms);
  167. static bool defaultsSetJbMaxLateRate(uint32_t jb_late_rate_percent);
  168. static bool defaultsSetEchoTail(uint32_t echo_tail);
  169. static uint32_t defaultsGetEchoTail();
  170. static bool defaultsSetEchoSkew(uint32_t echo_skew);
  171. static bool defaultsSetEchoSuppEnabled(bool echo_supp_enabled);
  172. static bool defaultsGetEchoSuppEnabled();
  173. static bool defaultsSetAgcEnabled(bool agc_enabled);
  174. static bool defaultsGetAgcEnabled();
  175. static bool defaultsSetAgcLevel(float agc_level);
  176. static float defaultsGetAgcLevel();
  177. static bool defaultsSetVadEnabled(bool vad_enabled);
  178. static bool defaultsGetGetVadEnabled();
  179. static bool defaultsSetNoiseSuppEnabled(bool noise_supp_enabled);
  180. static bool defaultsGetNoiseSuppEnabled();
  181. static bool defaultsSetNoiseSuppLevel(int32_t noise_supp_level);
  182. static int32_t defaultsGetNoiseSuppLevel();
  183. static bool defaultsSetConditionalRingingEnabled(bool _cond_ringing_enabled);
  184. static bool defaultsGetConditionalRingingEnabled();
  185. static bool defaultsSet100relEnabled(bool _100rel_enabled);
  186. static bool defaultsGet100relEnabled();
  187. static bool defaultsSetScreenSize(int32_t sx, int32_t sy);
  188. static bool defaultsSetAudioGain(int32_t producer_gain, int32_t consumer_gain);
  189. static bool defaultsSetAudioPtime(int32_t ptime);
  190. static bool defaultsSetAudioChannels(int32_t channel_playback, int32_t channel_record);
  191. static bool defaultsSetRtpPortRange(uint16_t range_start, uint16_t range_stop);
  192. static bool defaultsSetRtpSymetricEnabled(bool enabled);
  193. static bool defaultsSetMediaType(twrap_media_type_t media_type);
  194. static bool defaultsSetVolume(int32_t volume);
  195. static int32_t defaultsGetVolume();
  196. static bool defaultsSetInviteSessionTimers(int32_t timeout, const char* refresher);
  197. static bool defaultsSetSRtpMode(tmedia_srtp_mode_t mode);
  198. static tmedia_srtp_mode_t defaultsGetSRtpMode();
  199. static bool defaultsSetSRtpType(tmedia_srtp_type_t srtp_type);
  200. static tmedia_srtp_type_t defaultsGetSRtpType();
  201. static bool defaultsSetRtcpEnabled(bool enabled);
  202. static bool defaultsGetRtcpEnabled();
  203. static bool defaultsSetRtcpMuxEnabled(bool enabled);
  204. static bool defaultsGetRtcpMuxEnabled();
  205. static bool defaultsSetStunEnabled(bool stun_enabled);
  206. static bool defaultsSetIceStunEnabled(bool icestun_enabled);
  207. static bool defaultsSetIceTurnEnabled(bool iceturn_enabled);
  208. static bool defaultsSetStunServer(const char* server_ip, uint16_t server_port);
  209. static bool defaultsSetStunCred(const char* username, const char* password);
  210. static bool defaultsSetIceEnabled(bool ice_enabled);
  211. static bool defaultsSetByPassEncoding(bool enabled);
  212. static bool defaultsGetByPassEncoding();
  213. static bool defaultsSetByPassDecoding(bool enabled);
  214. static bool defaultsGetByPassDecoding();
  215. static bool defaultsSetVideoJbEnabled(bool enabled);
  216. static bool defaultsGetVideoJbEnabled();
  217. static bool defaultsSetVideoZeroArtifactsEnabled(bool enabled);
  218. static bool defaultsGetVideoZeroArtifactsEnabled();
  219. static bool defaultsSetRtpBuffSize(unsigned buffSize);
  220. static unsigned defaultsGetRtpBuffSize();
  221. static bool defaultsSetAvpfTail(unsigned tail_min, unsigned tail_max);
  222. static bool defaultsSetAvpfMode(enum tmedia_mode_e mode);
  223. static bool defaultsSetOpusMaxCaptureRate(uint32_t opus_maxcapturerate);
  224. static bool defaultsSetOpusMaxPlaybackRate(uint32_t opus_maxplaybackrate);
  225. static bool defaultsSetMaxFds(int32_t max_fds);
  226. private:
  227. tmedia_session_mgr_t* m_pWrappedMgr;
  228. };
  229. #endif /* TINYWRAP_MEDIA_SESSIONMGR_H */