From 546fe46f0c19bcde232a87c357a9d21114e3c207 Mon Sep 17 00:00:00 2001 From: bossiel Date: Wed, 26 Oct 2011 00:32:57 +0000 Subject: [PATCH] Fix issue 75, issue 79 and issue 80 --- .../bindings/_common/MediaSessionMgr.cxx | 10 ++++ .../bindings/_common/MediaSessionMgr.h | 2 + .../bindings/csharp/MediaSessionMgr.cs | 10 ++++ .../bindings/csharp/tinyWRAPPINVOKE.cs | 6 ++ .../bindings/csharp/tinyWRAP_wrap.cxx | 24 ++++++++ .../bindings/java/MediaSessionMgr.java | 8 +++ .../java/android/MediaSessionMgr.java | 8 +++ .../bindings/java/android/tinyWRAPJNI.java | 2 + .../bindings/java/android/tinyWRAP_wrap.cxx | 28 +++++++++ .../doubango/bindings/java/tinyWRAPJNI.java | 2 + .../doubango/bindings/java/tinyWRAP_wrap.cxx | 28 +++++++++ .../2.0/doubango/bindings/perl/tinyWRAP.pm | 2 + .../doubango/bindings/perl/tinyWRAP_wrap.cxx | 58 +++++++++++++++++++ .../2.0/doubango/bindings/python/tinyWRAP.py | 12 ++++ .../bindings/python/tinyWRAP_wrap.cxx | 46 +++++++++++++++ .../audio/directsound/tdav_producer_dsound.h | 1 + .../audio/directsound/tdav_consumer_dsound.c | 12 ++-- .../audio/directsound/tdav_producer_dsound.c | 32 +++++++--- .../tinyDAV/src/audio/tdav_session_audio.c | 11 ++++ .../src/audio/tdav_speex_jitterbuffer.c | 18 ++++++ .../tinyDAV/src/video/tdav_session_video.c | 11 +++- .../include/tinydshow/DSCaptureGraph.h | 3 + .../tinyDSHOW/include/tinydshow/DSDisplay.h | 1 + .../include/tinydshow/DSDisplayGraph.h | 3 + .../tinyDSHOW/include/tinydshow/DSGrabber.h | 1 + .../doubango/tinyDSHOW/src/DSCaptureGraph.cxx | 23 +++++++- .../2.0/doubango/tinyDSHOW/src/DSDisplay.cxx | 7 +++ .../doubango/tinyDSHOW/src/DSDisplayGraph.cxx | 21 ++++++- .../2.0/doubango/tinyDSHOW/src/DSGrabber.cxx | 15 +++++ .../tinyDSHOW/src/plugin/DSProducer.cxx | 42 +++++++++----- .../include/tinymedia/tmedia_defaults.h | 4 ++ .../include/tinymedia/tmedia_session.h | 4 ++ .../doubango/tinyMEDIA/src/tmedia_defaults.c | 24 ++++++++ .../doubango/tinyMEDIA/src/tmedia_session.c | 5 +- .../2.0/doubango/tinyNET/src/tnet_transport.c | 30 +++++----- .../2.0/doubango/tinyNET/src/tnet_transport.h | 3 + .../tinyNET/src/tnet_transport_poll.c | 15 +++++ .../tinyNET/src/tnet_transport_win32.c | 18 +++++- .../2.0/doubango/tinyNET/src/tnet_utils.c | 5 +- .../2.0/doubango/tinyRTP/src/trtp_manager.c | 8 +-- .../tinySIP/src/dialogs/tsip_dialog_invite.c | 3 +- 41 files changed, 510 insertions(+), 56 deletions(-) diff --git a/branches/2.0/doubango/bindings/_common/MediaSessionMgr.cxx b/branches/2.0/doubango/bindings/_common/MediaSessionMgr.cxx index 1b43801c..e541e77e 100644 --- a/branches/2.0/doubango/bindings/_common/MediaSessionMgr.cxx +++ b/branches/2.0/doubango/bindings/_common/MediaSessionMgr.cxx @@ -171,6 +171,16 @@ tmedia_bandwidth_level_t MediaSessionMgr::defaultsGetBandwidthLevel() return tmedia_defaults_get_bl(); } +bool MediaSessionMgr::defaultsSetJbMargin(uint32_t jb_margin_ms) +{ + return tmedia_defaults_set_jb_margin(jb_margin_ms) == 0; +} + +bool MediaSessionMgr::defaultsSetJbMaxLateRate(uint32_t jb_late_rate_percent) +{ + return tmedia_defaults_set_jb_max_late_rate(jb_late_rate_percent) == 0; +} + bool MediaSessionMgr::defaultsSetEchoTail(uint32_t echo_tail) { return tmedia_defaults_set_echo_tail(echo_tail) == 0; diff --git a/branches/2.0/doubango/bindings/_common/MediaSessionMgr.h b/branches/2.0/doubango/bindings/_common/MediaSessionMgr.h index 0579220a..51554526 100644 --- a/branches/2.0/doubango/bindings/_common/MediaSessionMgr.h +++ b/branches/2.0/doubango/bindings/_common/MediaSessionMgr.h @@ -60,6 +60,8 @@ public: // Defaults static bool defaultsSetBandwidthLevel(tmedia_bandwidth_level_t bl); static tmedia_bandwidth_level_t defaultsGetBandwidthLevel(); + static bool defaultsSetJbMargin(uint32_t jb_margin_ms); + static bool defaultsSetJbMaxLateRate(uint32_t jb_late_rate_percent); static bool defaultsSetEchoTail(uint32_t echo_tail); static uint32_t defaultsGetEchoTail(); static bool defaultsSetEchoSkew(uint32_t echo_skew); diff --git a/branches/2.0/doubango/bindings/csharp/MediaSessionMgr.cs b/branches/2.0/doubango/bindings/csharp/MediaSessionMgr.cs index a372b65c..b1b3072a 100644 --- a/branches/2.0/doubango/bindings/csharp/MediaSessionMgr.cs +++ b/branches/2.0/doubango/bindings/csharp/MediaSessionMgr.cs @@ -91,6 +91,16 @@ public class MediaSessionMgr : IDisposable { return ret; } + public static bool defaultsSetJbMargin(uint jb_margin_ms) { + bool ret = tinyWRAPPINVOKE.MediaSessionMgr_defaultsSetJbMargin(jb_margin_ms); + return ret; + } + + public static bool defaultsSetJbMaxLateRate(uint jb_late_rate_percent) { + bool ret = tinyWRAPPINVOKE.MediaSessionMgr_defaultsSetJbMaxLateRate(jb_late_rate_percent); + return ret; + } + public static bool defaultsSetEchoTail(uint echo_tail) { bool ret = tinyWRAPPINVOKE.MediaSessionMgr_defaultsSetEchoTail(echo_tail); return ret; diff --git a/branches/2.0/doubango/bindings/csharp/tinyWRAPPINVOKE.cs b/branches/2.0/doubango/bindings/csharp/tinyWRAPPINVOKE.cs index a4083a8a..74f3b67b 100644 --- a/branches/2.0/doubango/bindings/csharp/tinyWRAPPINVOKE.cs +++ b/branches/2.0/doubango/bindings/csharp/tinyWRAPPINVOKE.cs @@ -287,6 +287,12 @@ class tinyWRAPPINVOKE { [DllImport("tinyWRAP", EntryPoint="CSharp_MediaSessionMgr_defaultsGetBandwidthLevel")] public static extern int MediaSessionMgr_defaultsGetBandwidthLevel(); + [DllImport("tinyWRAP", EntryPoint="CSharp_MediaSessionMgr_defaultsSetJbMargin")] + public static extern bool MediaSessionMgr_defaultsSetJbMargin(uint jarg1); + + [DllImport("tinyWRAP", EntryPoint="CSharp_MediaSessionMgr_defaultsSetJbMaxLateRate")] + public static extern bool MediaSessionMgr_defaultsSetJbMaxLateRate(uint jarg1); + [DllImport("tinyWRAP", EntryPoint="CSharp_MediaSessionMgr_defaultsSetEchoTail")] public static extern bool MediaSessionMgr_defaultsSetEchoTail(uint jarg1); diff --git a/branches/2.0/doubango/bindings/csharp/tinyWRAP_wrap.cxx b/branches/2.0/doubango/bindings/csharp/tinyWRAP_wrap.cxx index ca230fd1..d700c5ab 100644 --- a/branches/2.0/doubango/bindings/csharp/tinyWRAP_wrap.cxx +++ b/branches/2.0/doubango/bindings/csharp/tinyWRAP_wrap.cxx @@ -1558,6 +1558,30 @@ SWIGEXPORT int SWIGSTDCALL CSharp_MediaSessionMgr_defaultsGetBandwidthLevel() { } +SWIGEXPORT unsigned int SWIGSTDCALL CSharp_MediaSessionMgr_defaultsSetJbMargin(unsigned int jarg1) { + unsigned int jresult ; + uint32_t arg1 ; + bool result; + + arg1 = (uint32_t)jarg1; + result = (bool)MediaSessionMgr::defaultsSetJbMargin(arg1); + jresult = result; + return jresult; +} + + +SWIGEXPORT unsigned int SWIGSTDCALL CSharp_MediaSessionMgr_defaultsSetJbMaxLateRate(unsigned int jarg1) { + unsigned int jresult ; + uint32_t arg1 ; + bool result; + + arg1 = (uint32_t)jarg1; + result = (bool)MediaSessionMgr::defaultsSetJbMaxLateRate(arg1); + jresult = result; + return jresult; +} + + SWIGEXPORT unsigned int SWIGSTDCALL CSharp_MediaSessionMgr_defaultsSetEchoTail(unsigned int jarg1) { unsigned int jresult ; uint32_t arg1 ; diff --git a/branches/2.0/doubango/bindings/java/MediaSessionMgr.java b/branches/2.0/doubango/bindings/java/MediaSessionMgr.java index e41cda19..17f95ded 100644 --- a/branches/2.0/doubango/bindings/java/MediaSessionMgr.java +++ b/branches/2.0/doubango/bindings/java/MediaSessionMgr.java @@ -75,6 +75,14 @@ public class MediaSessionMgr { return tmedia_bandwidth_level_t.swigToEnum(tinyWRAPJNI.MediaSessionMgr_defaultsGetBandwidthLevel()); } + public static boolean defaultsSetJbMargin(long jb_margin_ms) { + return tinyWRAPJNI.MediaSessionMgr_defaultsSetJbMargin(jb_margin_ms); + } + + public static boolean defaultsSetJbMaxLateRate(long jb_late_rate_percent) { + return tinyWRAPJNI.MediaSessionMgr_defaultsSetJbMaxLateRate(jb_late_rate_percent); + } + public static boolean defaultsSetEchoTail(long echo_tail) { return tinyWRAPJNI.MediaSessionMgr_defaultsSetEchoTail(echo_tail); } diff --git a/branches/2.0/doubango/bindings/java/android/MediaSessionMgr.java b/branches/2.0/doubango/bindings/java/android/MediaSessionMgr.java index e41cda19..17f95ded 100644 --- a/branches/2.0/doubango/bindings/java/android/MediaSessionMgr.java +++ b/branches/2.0/doubango/bindings/java/android/MediaSessionMgr.java @@ -75,6 +75,14 @@ public class MediaSessionMgr { return tmedia_bandwidth_level_t.swigToEnum(tinyWRAPJNI.MediaSessionMgr_defaultsGetBandwidthLevel()); } + public static boolean defaultsSetJbMargin(long jb_margin_ms) { + return tinyWRAPJNI.MediaSessionMgr_defaultsSetJbMargin(jb_margin_ms); + } + + public static boolean defaultsSetJbMaxLateRate(long jb_late_rate_percent) { + return tinyWRAPJNI.MediaSessionMgr_defaultsSetJbMaxLateRate(jb_late_rate_percent); + } + public static boolean defaultsSetEchoTail(long echo_tail) { return tinyWRAPJNI.MediaSessionMgr_defaultsSetEchoTail(echo_tail); } diff --git a/branches/2.0/doubango/bindings/java/android/tinyWRAPJNI.java b/branches/2.0/doubango/bindings/java/android/tinyWRAPJNI.java index 306a5e32..d9f34b19 100644 --- a/branches/2.0/doubango/bindings/java/android/tinyWRAPJNI.java +++ b/branches/2.0/doubango/bindings/java/android/tinyWRAPJNI.java @@ -44,6 +44,8 @@ class tinyWRAPJNI { public final static native java.math.BigInteger MediaSessionMgr_getSessionId(long jarg1, MediaSessionMgr jarg1_, int jarg2); public final static native boolean MediaSessionMgr_defaultsSetBandwidthLevel(int jarg1); public final static native int MediaSessionMgr_defaultsGetBandwidthLevel(); + public final static native boolean MediaSessionMgr_defaultsSetJbMargin(long jarg1); + public final static native boolean MediaSessionMgr_defaultsSetJbMaxLateRate(long jarg1); public final static native boolean MediaSessionMgr_defaultsSetEchoTail(long jarg1); public final static native long MediaSessionMgr_defaultsGetEchoTail(); public final static native boolean MediaSessionMgr_defaultsSetEchoSkew(long jarg1); diff --git a/branches/2.0/doubango/bindings/java/android/tinyWRAP_wrap.cxx b/branches/2.0/doubango/bindings/java/android/tinyWRAP_wrap.cxx index 09cc1f16..749d4ed8 100644 --- a/branches/2.0/doubango/bindings/java/android/tinyWRAP_wrap.cxx +++ b/branches/2.0/doubango/bindings/java/android/tinyWRAP_wrap.cxx @@ -2471,6 +2471,34 @@ SWIGEXPORT jint JNICALL Java_org_doubango_tinyWRAP_tinyWRAPJNI_MediaSessionMgr_1 } +SWIGEXPORT jboolean JNICALL Java_org_doubango_tinyWRAP_tinyWRAPJNI_MediaSessionMgr_1defaultsSetJbMargin(JNIEnv *jenv, jclass jcls, jlong jarg1) { + jboolean jresult = 0 ; + uint32_t arg1 ; + bool result; + + (void)jenv; + (void)jcls; + arg1 = (uint32_t)jarg1; + result = (bool)MediaSessionMgr::defaultsSetJbMargin(arg1); + jresult = (jboolean)result; + return jresult; +} + + +SWIGEXPORT jboolean JNICALL Java_org_doubango_tinyWRAP_tinyWRAPJNI_MediaSessionMgr_1defaultsSetJbMaxLateRate(JNIEnv *jenv, jclass jcls, jlong jarg1) { + jboolean jresult = 0 ; + uint32_t arg1 ; + bool result; + + (void)jenv; + (void)jcls; + arg1 = (uint32_t)jarg1; + result = (bool)MediaSessionMgr::defaultsSetJbMaxLateRate(arg1); + jresult = (jboolean)result; + return jresult; +} + + SWIGEXPORT jboolean JNICALL Java_org_doubango_tinyWRAP_tinyWRAPJNI_MediaSessionMgr_1defaultsSetEchoTail(JNIEnv *jenv, jclass jcls, jlong jarg1) { jboolean jresult = 0 ; uint32_t arg1 ; diff --git a/branches/2.0/doubango/bindings/java/tinyWRAPJNI.java b/branches/2.0/doubango/bindings/java/tinyWRAPJNI.java index 306a5e32..d9f34b19 100644 --- a/branches/2.0/doubango/bindings/java/tinyWRAPJNI.java +++ b/branches/2.0/doubango/bindings/java/tinyWRAPJNI.java @@ -44,6 +44,8 @@ class tinyWRAPJNI { public final static native java.math.BigInteger MediaSessionMgr_getSessionId(long jarg1, MediaSessionMgr jarg1_, int jarg2); public final static native boolean MediaSessionMgr_defaultsSetBandwidthLevel(int jarg1); public final static native int MediaSessionMgr_defaultsGetBandwidthLevel(); + public final static native boolean MediaSessionMgr_defaultsSetJbMargin(long jarg1); + public final static native boolean MediaSessionMgr_defaultsSetJbMaxLateRate(long jarg1); public final static native boolean MediaSessionMgr_defaultsSetEchoTail(long jarg1); public final static native long MediaSessionMgr_defaultsGetEchoTail(); public final static native boolean MediaSessionMgr_defaultsSetEchoSkew(long jarg1); diff --git a/branches/2.0/doubango/bindings/java/tinyWRAP_wrap.cxx b/branches/2.0/doubango/bindings/java/tinyWRAP_wrap.cxx index cfdeeaa1..21617219 100644 --- a/branches/2.0/doubango/bindings/java/tinyWRAP_wrap.cxx +++ b/branches/2.0/doubango/bindings/java/tinyWRAP_wrap.cxx @@ -2471,6 +2471,34 @@ SWIGEXPORT jint JNICALL Java_org_doubango_tinyWRAP_tinyWRAPJNI_MediaSessionMgr_1 } +SWIGEXPORT jboolean JNICALL Java_org_doubango_tinyWRAP_tinyWRAPJNI_MediaSessionMgr_1defaultsSetJbMargin(JNIEnv *jenv, jclass jcls, jlong jarg1) { + jboolean jresult = 0 ; + uint32_t arg1 ; + bool result; + + (void)jenv; + (void)jcls; + arg1 = (uint32_t)jarg1; + result = (bool)MediaSessionMgr::defaultsSetJbMargin(arg1); + jresult = (jboolean)result; + return jresult; +} + + +SWIGEXPORT jboolean JNICALL Java_org_doubango_tinyWRAP_tinyWRAPJNI_MediaSessionMgr_1defaultsSetJbMaxLateRate(JNIEnv *jenv, jclass jcls, jlong jarg1) { + jboolean jresult = 0 ; + uint32_t arg1 ; + bool result; + + (void)jenv; + (void)jcls; + arg1 = (uint32_t)jarg1; + result = (bool)MediaSessionMgr::defaultsSetJbMaxLateRate(arg1); + jresult = (jboolean)result; + return jresult; +} + + SWIGEXPORT jboolean JNICALL Java_org_doubango_tinyWRAP_tinyWRAPJNI_MediaSessionMgr_1defaultsSetEchoTail(JNIEnv *jenv, jclass jcls, jlong jarg1) { jboolean jresult = 0 ; uint32_t arg1 ; diff --git a/branches/2.0/doubango/bindings/perl/tinyWRAP.pm b/branches/2.0/doubango/bindings/perl/tinyWRAP.pm index 22860873..96b58358 100644 --- a/branches/2.0/doubango/bindings/perl/tinyWRAP.pm +++ b/branches/2.0/doubango/bindings/perl/tinyWRAP.pm @@ -201,6 +201,8 @@ sub DESTROY { *getSessionId = *tinyWRAPc::MediaSessionMgr_getSessionId; *defaultsSetBandwidthLevel = *tinyWRAPc::MediaSessionMgr_defaultsSetBandwidthLevel; *defaultsGetBandwidthLevel = *tinyWRAPc::MediaSessionMgr_defaultsGetBandwidthLevel; +*defaultsSetJbMargin = *tinyWRAPc::MediaSessionMgr_defaultsSetJbMargin; +*defaultsSetJbMaxLateRate = *tinyWRAPc::MediaSessionMgr_defaultsSetJbMaxLateRate; *defaultsSetEchoTail = *tinyWRAPc::MediaSessionMgr_defaultsSetEchoTail; *defaultsGetEchoTail = *tinyWRAPc::MediaSessionMgr_defaultsGetEchoTail; *defaultsSetEchoSkew = *tinyWRAPc::MediaSessionMgr_defaultsSetEchoSkew; diff --git a/branches/2.0/doubango/bindings/perl/tinyWRAP_wrap.cxx b/branches/2.0/doubango/bindings/perl/tinyWRAP_wrap.cxx index d7f4d971..fd4d68ed 100644 --- a/branches/2.0/doubango/bindings/perl/tinyWRAP_wrap.cxx +++ b/branches/2.0/doubango/bindings/perl/tinyWRAP_wrap.cxx @@ -3447,6 +3447,62 @@ XS(_wrap_MediaSessionMgr_defaultsGetBandwidthLevel) { } +XS(_wrap_MediaSessionMgr_defaultsSetJbMargin) { + { + uint32_t arg1 ; + unsigned int val1 ; + int ecode1 = 0 ; + int argvi = 0; + bool result; + dXSARGS; + + if ((items < 1) || (items > 1)) { + SWIG_croak("Usage: MediaSessionMgr_defaultsSetJbMargin(jb_margin_ms);"); + } + ecode1 = SWIG_AsVal_unsigned_SS_int SWIG_PERL_CALL_ARGS_2(ST(0), &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "MediaSessionMgr_defaultsSetJbMargin" "', argument " "1"" of type '" "uint32_t""'"); + } + arg1 = static_cast< uint32_t >(val1); + result = (bool)MediaSessionMgr::defaultsSetJbMargin(arg1); + ST(argvi) = SWIG_From_bool SWIG_PERL_CALL_ARGS_1(static_cast< bool >(result)); argvi++ ; + + XSRETURN(argvi); + fail: + + SWIG_croak_null(); + } +} + + +XS(_wrap_MediaSessionMgr_defaultsSetJbMaxLateRate) { + { + uint32_t arg1 ; + unsigned int val1 ; + int ecode1 = 0 ; + int argvi = 0; + bool result; + dXSARGS; + + if ((items < 1) || (items > 1)) { + SWIG_croak("Usage: MediaSessionMgr_defaultsSetJbMaxLateRate(jb_late_rate_percent);"); + } + ecode1 = SWIG_AsVal_unsigned_SS_int SWIG_PERL_CALL_ARGS_2(ST(0), &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "MediaSessionMgr_defaultsSetJbMaxLateRate" "', argument " "1"" of type '" "uint32_t""'"); + } + arg1 = static_cast< uint32_t >(val1); + result = (bool)MediaSessionMgr::defaultsSetJbMaxLateRate(arg1); + ST(argvi) = SWIG_From_bool SWIG_PERL_CALL_ARGS_1(static_cast< bool >(result)); argvi++ ; + + XSRETURN(argvi); + fail: + + SWIG_croak_null(); + } +} + + XS(_wrap_MediaSessionMgr_defaultsSetEchoTail) { { uint32_t arg1 ; @@ -21652,6 +21708,8 @@ static swig_command_info swig_commands[] = { {"tinyWRAPc::MediaSessionMgr_getSessionId", _wrap_MediaSessionMgr_getSessionId}, {"tinyWRAPc::MediaSessionMgr_defaultsSetBandwidthLevel", _wrap_MediaSessionMgr_defaultsSetBandwidthLevel}, {"tinyWRAPc::MediaSessionMgr_defaultsGetBandwidthLevel", _wrap_MediaSessionMgr_defaultsGetBandwidthLevel}, +{"tinyWRAPc::MediaSessionMgr_defaultsSetJbMargin", _wrap_MediaSessionMgr_defaultsSetJbMargin}, +{"tinyWRAPc::MediaSessionMgr_defaultsSetJbMaxLateRate", _wrap_MediaSessionMgr_defaultsSetJbMaxLateRate}, {"tinyWRAPc::MediaSessionMgr_defaultsSetEchoTail", _wrap_MediaSessionMgr_defaultsSetEchoTail}, {"tinyWRAPc::MediaSessionMgr_defaultsGetEchoTail", _wrap_MediaSessionMgr_defaultsGetEchoTail}, {"tinyWRAPc::MediaSessionMgr_defaultsSetEchoSkew", _wrap_MediaSessionMgr_defaultsSetEchoSkew}, diff --git a/branches/2.0/doubango/bindings/python/tinyWRAP.py b/branches/2.0/doubango/bindings/python/tinyWRAP.py index 07f2e99c..3396625e 100644 --- a/branches/2.0/doubango/bindings/python/tinyWRAP.py +++ b/branches/2.0/doubango/bindings/python/tinyWRAP.py @@ -158,6 +158,10 @@ class MediaSessionMgr(_object): if _newclass:defaultsSetBandwidthLevel = staticmethod(_tinyWRAP.MediaSessionMgr_defaultsSetBandwidthLevel) __swig_getmethods__["defaultsGetBandwidthLevel"] = lambda x: _tinyWRAP.MediaSessionMgr_defaultsGetBandwidthLevel if _newclass:defaultsGetBandwidthLevel = staticmethod(_tinyWRAP.MediaSessionMgr_defaultsGetBandwidthLevel) + __swig_getmethods__["defaultsSetJbMargin"] = lambda x: _tinyWRAP.MediaSessionMgr_defaultsSetJbMargin + if _newclass:defaultsSetJbMargin = staticmethod(_tinyWRAP.MediaSessionMgr_defaultsSetJbMargin) + __swig_getmethods__["defaultsSetJbMaxLateRate"] = lambda x: _tinyWRAP.MediaSessionMgr_defaultsSetJbMaxLateRate + if _newclass:defaultsSetJbMaxLateRate = staticmethod(_tinyWRAP.MediaSessionMgr_defaultsSetJbMaxLateRate) __swig_getmethods__["defaultsSetEchoTail"] = lambda x: _tinyWRAP.MediaSessionMgr_defaultsSetEchoTail if _newclass:defaultsSetEchoTail = staticmethod(_tinyWRAP.MediaSessionMgr_defaultsSetEchoTail) __swig_getmethods__["defaultsGetEchoTail"] = lambda x: _tinyWRAP.MediaSessionMgr_defaultsGetEchoTail @@ -211,6 +215,14 @@ def MediaSessionMgr_defaultsGetBandwidthLevel(): return _tinyWRAP.MediaSessionMgr_defaultsGetBandwidthLevel() MediaSessionMgr_defaultsGetBandwidthLevel = _tinyWRAP.MediaSessionMgr_defaultsGetBandwidthLevel +def MediaSessionMgr_defaultsSetJbMargin(*args): + return _tinyWRAP.MediaSessionMgr_defaultsSetJbMargin(*args) +MediaSessionMgr_defaultsSetJbMargin = _tinyWRAP.MediaSessionMgr_defaultsSetJbMargin + +def MediaSessionMgr_defaultsSetJbMaxLateRate(*args): + return _tinyWRAP.MediaSessionMgr_defaultsSetJbMaxLateRate(*args) +MediaSessionMgr_defaultsSetJbMaxLateRate = _tinyWRAP.MediaSessionMgr_defaultsSetJbMaxLateRate + def MediaSessionMgr_defaultsSetEchoTail(*args): return _tinyWRAP.MediaSessionMgr_defaultsSetEchoTail(*args) MediaSessionMgr_defaultsSetEchoTail = _tinyWRAP.MediaSessionMgr_defaultsSetEchoTail diff --git a/branches/2.0/doubango/bindings/python/tinyWRAP_wrap.cxx b/branches/2.0/doubango/bindings/python/tinyWRAP_wrap.cxx index cc4f14ae..cc7a5779 100644 --- a/branches/2.0/doubango/bindings/python/tinyWRAP_wrap.cxx +++ b/branches/2.0/doubango/bindings/python/tinyWRAP_wrap.cxx @@ -6155,6 +6155,50 @@ fail: } +SWIGINTERN PyObject *_wrap_MediaSessionMgr_defaultsSetJbMargin(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + uint32_t arg1 ; + unsigned int val1 ; + int ecode1 = 0 ; + PyObject * obj0 = 0 ; + bool result; + + if (!PyArg_ParseTuple(args,(char *)"O:MediaSessionMgr_defaultsSetJbMargin",&obj0)) SWIG_fail; + ecode1 = SWIG_AsVal_unsigned_SS_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "MediaSessionMgr_defaultsSetJbMargin" "', argument " "1"" of type '" "uint32_t""'"); + } + arg1 = static_cast< uint32_t >(val1); + result = (bool)MediaSessionMgr::defaultsSetJbMargin(arg1); + resultobj = SWIG_From_bool(static_cast< bool >(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_MediaSessionMgr_defaultsSetJbMaxLateRate(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + uint32_t arg1 ; + unsigned int val1 ; + int ecode1 = 0 ; + PyObject * obj0 = 0 ; + bool result; + + if (!PyArg_ParseTuple(args,(char *)"O:MediaSessionMgr_defaultsSetJbMaxLateRate",&obj0)) SWIG_fail; + ecode1 = SWIG_AsVal_unsigned_SS_int(obj0, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "MediaSessionMgr_defaultsSetJbMaxLateRate" "', argument " "1"" of type '" "uint32_t""'"); + } + arg1 = static_cast< uint32_t >(val1); + result = (bool)MediaSessionMgr::defaultsSetJbMaxLateRate(arg1); + resultobj = SWIG_From_bool(static_cast< bool >(result)); + return resultobj; +fail: + return NULL; +} + + SWIGINTERN PyObject *_wrap_MediaSessionMgr_defaultsSetEchoTail(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; uint32_t arg1 ; @@ -21069,6 +21113,8 @@ static PyMethodDef SwigMethods[] = { { (char *)"MediaSessionMgr_getSessionId", _wrap_MediaSessionMgr_getSessionId, METH_VARARGS, NULL}, { (char *)"MediaSessionMgr_defaultsSetBandwidthLevel", _wrap_MediaSessionMgr_defaultsSetBandwidthLevel, METH_VARARGS, NULL}, { (char *)"MediaSessionMgr_defaultsGetBandwidthLevel", _wrap_MediaSessionMgr_defaultsGetBandwidthLevel, METH_VARARGS, NULL}, + { (char *)"MediaSessionMgr_defaultsSetJbMargin", _wrap_MediaSessionMgr_defaultsSetJbMargin, METH_VARARGS, NULL}, + { (char *)"MediaSessionMgr_defaultsSetJbMaxLateRate", _wrap_MediaSessionMgr_defaultsSetJbMaxLateRate, METH_VARARGS, NULL}, { (char *)"MediaSessionMgr_defaultsSetEchoTail", _wrap_MediaSessionMgr_defaultsSetEchoTail, METH_VARARGS, NULL}, { (char *)"MediaSessionMgr_defaultsGetEchoTail", _wrap_MediaSessionMgr_defaultsGetEchoTail, METH_VARARGS, NULL}, { (char *)"MediaSessionMgr_defaultsSetEchoSkew", _wrap_MediaSessionMgr_defaultsSetEchoSkew, METH_VARARGS, NULL}, diff --git a/branches/2.0/doubango/tinyDAV/include/tinydav/audio/directsound/tdav_producer_dsound.h b/branches/2.0/doubango/tinyDAV/include/tinydav/audio/directsound/tdav_producer_dsound.h index 8b8bd59b..ed7952c3 100644 --- a/branches/2.0/doubango/tinyDAV/include/tinydav/audio/directsound/tdav_producer_dsound.h +++ b/branches/2.0/doubango/tinyDAV/include/tinydav/audio/directsound/tdav_producer_dsound.h @@ -47,6 +47,7 @@ typedef struct tdav_producer_dsound_s TDAV_DECLARE_PRODUCER_AUDIO; tsk_bool_t started; + tsk_bool_t mute; tsk_size_t bytes_per_notif; void* tid[1]; diff --git a/branches/2.0/doubango/tinyDAV/src/audio/directsound/tdav_consumer_dsound.c b/branches/2.0/doubango/tinyDAV/src/audio/directsound/tdav_consumer_dsound.c index b86edf8c..0c443697 100644 --- a/branches/2.0/doubango/tinyDAV/src/audio/directsound/tdav_consumer_dsound.c +++ b/branches/2.0/doubango/tinyDAV/src/audio/directsound/tdav_consumer_dsound.c @@ -105,12 +105,12 @@ next: /* ============ Media Consumer Interface ================= */ -int tdav_consumer_dsound_set(tmedia_consumer_t* self, const tmedia_param_t* params) +static int tdav_consumer_dsound_set(tmedia_consumer_t* self, const tmedia_param_t* params) { return tdav_consumer_audio_set(TDAV_CONSUMER_AUDIO(self), params); } -int tdav_consumer_dsound_prepare(tmedia_consumer_t* self, const tmedia_codec_t* codec) +static int tdav_consumer_dsound_prepare(tmedia_consumer_t* self, const tmedia_codec_t* codec) { HRESULT hr; HWND hWnd; @@ -186,7 +186,7 @@ int tdav_consumer_dsound_prepare(tmedia_consumer_t* self, const tmedia_codec_t* return 0; } -int tdav_consumer_dsound_start(tmedia_consumer_t* self) +static int tdav_consumer_dsound_start(tmedia_consumer_t* self) { tdav_consumer_dsound_t* dsound = (tdav_consumer_dsound_t*)self; @@ -245,7 +245,7 @@ int tdav_consumer_dsound_start(tmedia_consumer_t* self) return 0; } -int tdav_consumer_dsound_consume(tmedia_consumer_t* self, const void* buffer, tsk_size_t size, const tsk_object_t* proto_hdr) +static int tdav_consumer_dsound_consume(tmedia_consumer_t* self, const void* buffer, tsk_size_t size, const tsk_object_t* proto_hdr) { tdav_consumer_dsound_t* dsound = (tdav_consumer_dsound_t*)self; @@ -257,12 +257,12 @@ int tdav_consumer_dsound_consume(tmedia_consumer_t* self, const void* buffer, ts return tdav_consumer_audio_put(TDAV_CONSUMER_AUDIO(dsound), buffer, size, proto_hdr); } -int tdav_consumer_dsound_pause(tmedia_consumer_t* self) +static int tdav_consumer_dsound_pause(tmedia_consumer_t* self) { return 0; } -int tdav_consumer_dsound_stop(tmedia_consumer_t* self) +static int tdav_consumer_dsound_stop(tmedia_consumer_t* self) { tdav_consumer_dsound_t* dsound = (tdav_consumer_dsound_t*)self; diff --git a/branches/2.0/doubango/tinyDAV/src/audio/directsound/tdav_producer_dsound.c b/branches/2.0/doubango/tinyDAV/src/audio/directsound/tdav_producer_dsound.c index d4b91c01..51a1b066 100644 --- a/branches/2.0/doubango/tinyDAV/src/audio/directsound/tdav_producer_dsound.c +++ b/branches/2.0/doubango/tinyDAV/src/audio/directsound/tdav_producer_dsound.c @@ -98,12 +98,28 @@ next:; /* ============ Media Producer Interface ================= */ -int tdav_producer_dsound_set(tmedia_producer_t* self, const tmedia_param_t* params) -{ - return tdav_producer_audio_set(TDAV_PRODUCER_AUDIO(self), params); +static int tdav_producer_dsound_set(tmedia_producer_t* self, const tmedia_param_t* param) +{ + tdav_producer_dsound_t* dsound = (tdav_producer_dsound_t*)self; + if(param->plugin_type == tmedia_ppt_producer){ + if(param->value_type == tmedia_pvt_int32){ + if(tsk_striequals(param->key, "mute")){ + dsound->mute = (TSK_TO_INT32((uint8_t*)param->value) != 0); + if(dsound->started){ + if(dsound->mute){ + IDirectSoundCaptureBuffer_Stop(dsound->captureBuffer); + } + else{ + IDirectSoundCaptureBuffer_Start(dsound->captureBuffer, DSBPLAY_LOOPING); + } + } + return 0; + } + } + } + return tdav_producer_audio_set(TDAV_PRODUCER_AUDIO(self), param); } - -int tdav_producer_dsound_prepare(tmedia_producer_t* self, const tmedia_codec_t* codec) +static int tdav_producer_dsound_prepare(tmedia_producer_t* self, const tmedia_codec_t* codec) { HRESULT hr; @@ -155,7 +171,7 @@ int tdav_producer_dsound_prepare(tmedia_producer_t* self, const tmedia_codec_t* return 0; } -int tdav_producer_dsound_start(tmedia_producer_t* self) +static int tdav_producer_dsound_start(tmedia_producer_t* self) { tdav_producer_dsound_t* dsound = (tdav_producer_dsound_t*)self; @@ -214,12 +230,12 @@ int tdav_producer_dsound_start(tmedia_producer_t* self) return 0; } -int tdav_producer_dsound_pause(tmedia_producer_t* self) +static int tdav_producer_dsound_pause(tmedia_producer_t* self) { return 0; } -int tdav_producer_dsound_stop(tmedia_producer_t* self) +static int tdav_producer_dsound_stop(tmedia_producer_t* self) { tdav_producer_dsound_t* dsound = (tdav_producer_dsound_t*)self; diff --git a/branches/2.0/doubango/tinyDAV/src/audio/tdav_session_audio.c b/branches/2.0/doubango/tinyDAV/src/audio/tdav_session_audio.c index 497c32d5..2c607a41 100644 --- a/branches/2.0/doubango/tinyDAV/src/audio/tdav_session_audio.c +++ b/branches/2.0/doubango/tinyDAV/src/audio/tdav_session_audio.c @@ -126,6 +126,17 @@ static int tdav_session_audio_producer_enc_cb(const void* callback_data, const v tdav_session_audio_t* audio = (tdav_session_audio_t*)callback_data; + if(!audio){ + TSK_DEBUG_ERROR("Null session"); + return 0; + } + + // do nothing if session is held + // when the session is held the end user will get feedback he also has possibilities to put the consumer and producer on pause + if(TMEDIA_SESSION(audio)->lo_held){ + return 0; + } + if(audio->rtp_manager){ /* encode */ tsk_size_t out_size = 0; diff --git a/branches/2.0/doubango/tinyDAV/src/audio/tdav_speex_jitterbuffer.c b/branches/2.0/doubango/tinyDAV/src/audio/tdav_speex_jitterbuffer.c index d89af8e8..736358cd 100644 --- a/branches/2.0/doubango/tinyDAV/src/audio/tdav_speex_jitterbuffer.c +++ b/branches/2.0/doubango/tinyDAV/src/audio/tdav_speex_jitterbuffer.c @@ -31,6 +31,8 @@ #if HAVE_SPEEX_DSP && HAVE_SPEEX_JB +#include "tinymedia/tmedia_defaults.h" + #include "tsk_memory.h" #include "tsk_debug.h" @@ -43,6 +45,8 @@ static int tdav_speex_jitterbuffer_set(tmedia_jitterbuffer_t *self, const tmedia static int tdav_speex_jitterbuffer_open(tmedia_jitterbuffer_t* self, uint32_t frame_duration, uint32_t rate) { tdav_speex_jitterbuffer_t *jitterbuffer = (tdav_speex_jitterbuffer_t *)self; + spx_int32_t tmp; + if(!(jitterbuffer->state = jitter_buffer_init((int)frame_duration))){ TSK_DEBUG_ERROR("jitter_buffer_init() failed"); return -2; @@ -50,6 +54,20 @@ static int tdav_speex_jitterbuffer_open(tmedia_jitterbuffer_t* self, uint32_t fr jitterbuffer->rate = rate; jitterbuffer->frame_duration = frame_duration; + jitter_buffer_ctl(jitterbuffer->state, JITTER_BUFFER_GET_MARGIN, &tmp); + TSK_DEBUG_INFO("Default Jitter buffer margin=%d", tmp); + jitter_buffer_ctl(jitterbuffer->state, JITTER_BUFFER_GET_MAX_LATE_RATE, &tmp); + TSK_DEBUG_INFO("Default Jitter max late rate=%d", tmp); + + if((tmp = tmedia_defaults_get_jb_margin()) >= 0){ + jitter_buffer_ctl(jitterbuffer->state, JITTER_BUFFER_SET_MARGIN, &tmp); + TSK_DEBUG_INFO("New Jitter buffer margin=%d", tmp); + } + if((tmp = tmedia_defaults_get_jb_max_late_rate()) >= 0){ + jitter_buffer_ctl(jitterbuffer->state, JITTER_BUFFER_SET_MAX_LATE_RATE, &tmp); + TSK_DEBUG_INFO("New Jitter buffer max late rate=%d", tmp); + } + return 0; } diff --git a/branches/2.0/doubango/tinyDAV/src/video/tdav_session_video.c b/branches/2.0/doubango/tinyDAV/src/video/tdav_session_video.c index ad7aee48..eaff040a 100644 --- a/branches/2.0/doubango/tinyDAV/src/video/tdav_session_video.c +++ b/branches/2.0/doubango/tinyDAV/src/video/tdav_session_video.c @@ -163,7 +163,16 @@ static int tdav_session_video_producer_enc_cb(const void* callback_data, const v tsk_size_t yuv420p_size = 0; int ret = 0; - if(session && session->rtp_manager){ + if(!session){ + TSK_DEBUG_ERROR("Null session"); + return 0; + } + + if(TMEDIA_SESSION(session)->lo_held){ + return 0; + } + + if(session->rtp_manager){ /* encode */ tsk_size_t out_size = 0; tmedia_codec_t* codec = tsk_null; diff --git a/branches/2.0/doubango/tinyDSHOW/include/tinydshow/DSCaptureGraph.h b/branches/2.0/doubango/tinyDSHOW/include/tinydshow/DSCaptureGraph.h index e8593cd5..164f3307 100644 --- a/branches/2.0/doubango/tinyDSHOW/include/tinydshow/DSCaptureGraph.h +++ b/branches/2.0/doubango/tinyDSHOW/include/tinydshow/DSCaptureGraph.h @@ -57,7 +57,9 @@ public: HRESULT start(); HRESULT stop(); + HRESULT pause(); bool isRunning(); + bool isPaused(); std::string getDeviceId() const { return this->deviceId; }; @@ -101,6 +103,7 @@ private: DSCaptureFormat *captureFormat; bool running; + bool paused; std::string deviceId; }; diff --git a/branches/2.0/doubango/tinyDSHOW/include/tinydshow/DSDisplay.h b/branches/2.0/doubango/tinyDSHOW/include/tinydshow/DSDisplay.h index 580c6636..4199110b 100644 --- a/branches/2.0/doubango/tinyDSHOW/include/tinydshow/DSDisplay.h +++ b/branches/2.0/doubango/tinyDSHOW/include/tinydshow/DSDisplay.h @@ -41,6 +41,7 @@ public: virtual bool isAttached(); virtual void start(); + virtual void pause(); virtual void stop(); virtual int getWidth(); diff --git a/branches/2.0/doubango/tinyDSHOW/include/tinydshow/DSDisplayGraph.h b/branches/2.0/doubango/tinyDSHOW/include/tinydshow/DSDisplayGraph.h index 0165319e..96ba06ed 100644 --- a/branches/2.0/doubango/tinyDSHOW/include/tinydshow/DSDisplayGraph.h +++ b/branches/2.0/doubango/tinyDSHOW/include/tinydshow/DSDisplayGraph.h @@ -52,8 +52,10 @@ public: HRESULT disconnect(); HRESULT start(); + HRESULT pause(); HRESULT stop(); bool isRunning(); + bool isPaused(); IMediaEventEx *getMediaEvent() { return this->mediaEvent; }; IVideoWindow *getVideoWindow() { return this->videoWindow; }; @@ -101,6 +103,7 @@ private: bool connected; bool running; + bool paused; int fps; }; diff --git a/branches/2.0/doubango/tinyDSHOW/include/tinydshow/DSGrabber.h b/branches/2.0/doubango/tinyDSHOW/include/tinydshow/DSGrabber.h index e9d39975..fe3e58ba 100644 --- a/branches/2.0/doubango/tinyDSHOW/include/tinydshow/DSGrabber.h +++ b/branches/2.0/doubango/tinyDSHOW/include/tinydshow/DSGrabber.h @@ -53,6 +53,7 @@ public: void setCaptureDevice(const std::string &devicePath); virtual void start(); + virtual void pause(); virtual void stop(); virtual bool setCaptureParameters(int format, int f); diff --git a/branches/2.0/doubango/tinyDSHOW/src/DSCaptureGraph.cxx b/branches/2.0/doubango/tinyDSHOW/src/DSCaptureGraph.cxx index 065f1436..038edb06 100644 --- a/branches/2.0/doubango/tinyDSHOW/src/DSCaptureGraph.cxx +++ b/branches/2.0/doubango/tinyDSHOW/src/DSCaptureGraph.cxx @@ -58,6 +58,7 @@ DSCaptureGraph::DSCaptureGraph(ISampleGrabberCB* callback, HRESULT *hr) this->streamConfiguration = NULL; this->running = FALSE; + this->paused = FALSE; this->deviceId = ""; *hr = this->createCaptureGraph(); @@ -267,7 +268,9 @@ HRESULT DSCaptureGraph::start() { HRESULT hr; - if(this->running) return S_OK; + if(isRunning() && !isPaused()){ + return S_OK; + } //this->mediaController->Stop(); @@ -292,6 +295,18 @@ HRESULT DSCaptureGraph::start() return hr; } +HRESULT DSCaptureGraph::pause() +{ + HRESULT hr = S_OK; + if(isRunning()){ + hr = this->mediaController->Pause(); + if(SUCCEEDED(hr)){ + this->paused = TRUE; + } + } + return hr; +} + HRESULT DSCaptureGraph::stop() { HRESULT hr; @@ -308,6 +323,7 @@ HRESULT DSCaptureGraph::stop() TSK_DEBUG_ERROR("DSCaptureGraph::mediaController->Stop() has failed with %ld", hr); } this->running = false; + this->paused = false; return hr; } @@ -316,6 +332,11 @@ bool DSCaptureGraph::isRunning() return this->running; } +bool DSCaptureGraph::isPaused() +{ + return this->paused; +} + HRESULT DSCaptureGraph::getConnectedMediaType(AM_MEDIA_TYPE *mediaType) { #ifdef _WIN32_WCE diff --git a/branches/2.0/doubango/tinyDSHOW/src/DSDisplay.cxx b/branches/2.0/doubango/tinyDSHOW/src/DSDisplay.cxx index 1a88ef22..d7003d9d 100644 --- a/branches/2.0/doubango/tinyDSHOW/src/DSDisplay.cxx +++ b/branches/2.0/doubango/tinyDSHOW/src/DSDisplay.cxx @@ -114,11 +114,18 @@ void DSDisplay::start() { if (!this->graph->isRunning()){ this->hook(); + } + if (!this->graph->isRunning() || this->graph->isPaused()){ this->graph->start(); } this->graph->getVideoWindow()->put_Visible(OATRUE); } +void DSDisplay::pause() +{ + this->graph->pause(); +} + void DSDisplay::stop() { if (this->graph->isRunning()){ diff --git a/branches/2.0/doubango/tinyDSHOW/src/DSDisplayGraph.cxx b/branches/2.0/doubango/tinyDSHOW/src/DSDisplayGraph.cxx index e7d3800d..21cd7243 100644 --- a/branches/2.0/doubango/tinyDSHOW/src/DSDisplayGraph.cxx +++ b/branches/2.0/doubango/tinyDSHOW/src/DSDisplayGraph.cxx @@ -36,6 +36,7 @@ using namespace std; DSDisplayGraph::DSDisplayGraph(HRESULT *hr) { this->running = FALSE; + this->paused = FALSE; this->fps = 15; this->graphBuilder = NULL; @@ -168,7 +169,7 @@ HRESULT DSDisplayGraph::start() { HRESULT hr; this->running = true; - this->sourceFilter->reset(); + this->sourceFilter->reset(); hr = this->mediaController->Run(); if (!SUCCEEDED(hr)){ @@ -177,6 +178,18 @@ HRESULT DSDisplayGraph::start() return hr; } +HRESULT DSDisplayGraph::pause() +{ + HRESULT hr = S_OK; + if(isRunning() && !isPaused()){ + hr = this->mediaController->Pause(); + if(SUCCEEDED(hr)){ + this->paused = true; + } + } + return hr; +} + HRESULT DSDisplayGraph::stop() { HRESULT hr; @@ -194,6 +207,7 @@ HRESULT DSDisplayGraph::stop() } this->running = false; + this->paused = false; return hr; } @@ -203,6 +217,11 @@ bool DSDisplayGraph::isRunning() return this->running; } +bool DSDisplayGraph::isPaused() +{ + return this->paused; +} + void DSDisplayGraph::handleFrame(const void* data, int w, int h) { HRESULT hr; diff --git a/branches/2.0/doubango/tinyDSHOW/src/DSGrabber.cxx b/branches/2.0/doubango/tinyDSHOW/src/DSGrabber.cxx index 967bf145..d18bf585 100644 --- a/branches/2.0/doubango/tinyDSHOW/src/DSGrabber.cxx +++ b/branches/2.0/doubango/tinyDSHOW/src/DSGrabber.cxx @@ -86,6 +86,12 @@ void DSGrabber::setCallback(tmedia_producer_enc_cb_f callback, const void* callb void DSGrabber::start() { + if(this->graph->isPaused()){ + this->graph->start(); + this->preview->start(); + return; + } + if (!this->graph->isRunning()){ first_buffer = true; @@ -96,6 +102,15 @@ void DSGrabber::start() this->graph->start(); } } + +void DSGrabber::pause() +{ + if(this->graph && this->graph->isRunning()){ + this->graph->pause(); + this->preview->pause(); + } +} + void DSGrabber::stop() { if (this->graph->isRunning()){ diff --git a/branches/2.0/doubango/tinyDSHOW/src/plugin/DSProducer.cxx b/branches/2.0/doubango/tinyDSHOW/src/plugin/DSProducer.cxx index bfb4d048..655ae1aa 100644 --- a/branches/2.0/doubango/tinyDSHOW/src/plugin/DSProducer.cxx +++ b/branches/2.0/doubango/tinyDSHOW/src/plugin/DSProducer.cxx @@ -27,7 +27,6 @@ #include "tsk_debug.h" - #define DSPRODUCER(self) ((tdshow_producer_t*)(self)) typedef struct tdshow_producer_s @@ -38,6 +37,7 @@ typedef struct tdshow_producer_s INT64 previewHwnd; tsk_bool_t started; + tsk_bool_t mute; } tdshow_producer_t; @@ -55,30 +55,44 @@ static int tdshow_plugin_cb(const void* callback_data, const void* buffer, tsk_s /* ============ Media Producer Interface ================= */ -int tdshow_producer_set(tmedia_producer_t *self, const tmedia_param_t* param) +static int tdshow_producer_set(tmedia_producer_t *self, const tmedia_param_t* param) { int ret = 0; + tdshow_producer_t* producer = (tdshow_producer_t*)self; - if(!self || !param){ + if(!producer || !param){ TSK_DEBUG_ERROR("Invalid parameter"); return -1; } if(param->value_type == tmedia_pvt_int64){ if(tsk_striequals(param->key, "local-hwnd")){ - if(DSPRODUCER(self)->grabber && DSPRODUCER(self)->grabber->preview){ - DSPRODUCER(self)->grabber->preview->attach((INT64)*((int64_t*)param->value)); + if(DSPRODUCER(producer)->grabber && DSPRODUCER(self)->grabber->preview){ + DSPRODUCER(producer)->grabber->preview->attach((INT64)*((int64_t*)param->value)); } else{ - DSPRODUCER(self)->previewHwnd = (INT64)*((int64_t*)param->value); + DSPRODUCER(producer)->previewHwnd = (INT64)*((int64_t*)param->value); } } } - + else if(param->value_type == tmedia_pvt_int32){ + if(tsk_striequals(param->key, "mute")){ + producer->mute = (TSK_TO_INT32((uint8_t*)param->value) != 0); + if(producer->started){ + if(producer->mute){ + producer->grabber->pause(); + } + else{ + producer->grabber->start(); + } + } + } + } + return ret; } -int tdshow_producer_prepare(tmedia_producer_t* self, const tmedia_codec_t* codec) +static int tdshow_producer_prepare(tmedia_producer_t* self, const tmedia_codec_t* codec) { tdshow_producer_t* producer = (tdshow_producer_t*)self; @@ -94,7 +108,7 @@ int tdshow_producer_prepare(tmedia_producer_t* self, const tmedia_codec_t* codec return 0; } -int tdshow_producer_start(tmedia_producer_t* self) +static int tdshow_producer_start(tmedia_producer_t* self) { tdshow_producer_t* producer = (tdshow_producer_t*)self; HRESULT hr; @@ -140,14 +154,16 @@ int tdshow_producer_start(tmedia_producer_t* self) // start grabber TSK_DEBUG_INFO("Before starting DirectShow producer"); - producer->grabber->start(); + if(!producer->mute){ + producer->grabber->start(); + } producer->started = tsk_true; TSK_DEBUG_INFO("After starting DirectShow producer"); return 0; } -int tdshow_producer_pause(tmedia_producer_t* self) +static int tdshow_producer_pause(tmedia_producer_t* self) { tdshow_producer_t* producer = (tdshow_producer_t*)self; @@ -161,12 +177,12 @@ int tdshow_producer_pause(tmedia_producer_t* self) return -2; } - //producer->grabber->pause(); + producer->grabber->pause(); return 0; } -int tdshow_producer_stop(tmedia_producer_t* self) +static int tdshow_producer_stop(tmedia_producer_t* self) { tdshow_producer_t* producer = (tdshow_producer_t*)self; diff --git a/branches/2.0/doubango/tinyMEDIA/include/tinymedia/tmedia_defaults.h b/branches/2.0/doubango/tinyMEDIA/include/tinymedia/tmedia_defaults.h index c153d48a..a669e753 100644 --- a/branches/2.0/doubango/tinyMEDIA/include/tinymedia/tmedia_defaults.h +++ b/branches/2.0/doubango/tinyMEDIA/include/tinymedia/tmedia_defaults.h @@ -37,6 +37,10 @@ TINYMEDIA_API tmedia_bandwidth_level_t tmedia_defaults_get_bl(); // // Denoiser: Echo suppression, AEC, Noise redution, AGC, ... // +TINYMEDIA_API int tmedia_defaults_set_jb_margin(int32_t jb_margin_ms); +TINYMEDIA_API int32_t tmedia_defaults_get_jb_margin(); +TINYMEDIA_API int tmedia_defaults_set_jb_max_late_rate(int32_t jb_max_late_rate_percent); +TINYMEDIA_API int32_t tmedia_defaults_get_jb_max_late_rate(); TINYMEDIA_API int tmedia_defaults_set_echo_tail(uint32_t echo_tail); TINYMEDIA_API int tmedia_defaults_set_echo_skew(uint32_t echo_skew); TINYMEDIA_API uint32_t tmedia_defaults_get_echo_tail(); diff --git a/branches/2.0/doubango/tinyMEDIA/include/tinymedia/tmedia_session.h b/branches/2.0/doubango/tinyMEDIA/include/tinymedia/tmedia_session.h index f9be8a49..42b36fc7 100644 --- a/branches/2.0/doubango/tinyMEDIA/include/tinymedia/tmedia_session.h +++ b/branches/2.0/doubango/tinyMEDIA/include/tinymedia/tmedia_session.h @@ -71,6 +71,10 @@ typedef struct tmedia_session_s tsk_bool_t initialized; //! whether the session have been prepared (up to the manager to update the value) tsk_bool_t prepared; + //! whether the session is localy held + tsk_bool_t lo_held; + //! whether the session is remotely held + tsk_bool_t ro_held; //! QoS tmedia_qos_tline_t* qos; //! bandwidth level diff --git a/branches/2.0/doubango/tinyMEDIA/src/tmedia_defaults.c b/branches/2.0/doubango/tinyMEDIA/src/tmedia_defaults.c index bf1e2df6..923671f0 100644 --- a/branches/2.0/doubango/tinyMEDIA/src/tmedia_defaults.c +++ b/branches/2.0/doubango/tinyMEDIA/src/tmedia_defaults.c @@ -45,6 +45,8 @@ tmedia_bandwidth_level_t tmedia_defaults_get_bl() // // Denoiser: Echo suppression, AEC, Noise redution, AGC, ... // +static int32_t __jb_margin_ms = -1; // disable +static int32_t __jb_max_late_rate_percent = -1; // -1: disable 4: default for speex static uint32_t __echo_tail = 20; static uint32_t __echo_skew = 0; static tsk_bool_t __echo_supp_enabled; @@ -62,6 +64,28 @@ static uint16_t __rtp_port_range_start = 1024; static uint16_t __rtp_port_range_stop = 65535; static tmedia_type_t __media_type = tmedia_audio; +int tmedia_defaults_set_jb_margin(int32_t jb_margin_ms) +{ + __jb_margin_ms = jb_margin_ms; + return __jb_margin_ms; +} + +int32_t tmedia_defaults_get_jb_margin() +{ + return __jb_margin_ms; +} + +int tmedia_defaults_set_jb_max_late_rate(int32_t jb_max_late_rate_percent) +{ + __jb_max_late_rate_percent = jb_max_late_rate_percent; + return 0; +} + +int32_t tmedia_defaults_get_jb_max_late_rate() +{ + return __jb_max_late_rate_percent; +} + int tmedia_defaults_set_echo_tail(uint32_t echo_tail) { __echo_tail = echo_tail; diff --git a/branches/2.0/doubango/tinyMEDIA/src/tmedia_session.c b/branches/2.0/doubango/tinyMEDIA/src/tmedia_session.c index 7e0e3873..5a320c3d 100644 --- a/branches/2.0/doubango/tinyMEDIA/src/tmedia_session.c +++ b/branches/2.0/doubango/tinyMEDIA/src/tmedia_session.c @@ -279,6 +279,7 @@ int _tmedia_session_set_ro(tmedia_session_t* self, const tsdp_header_M_t* m) } if(!(ret = self->plugin->set_remote_offer(self, m))){ self->ro_changed = tsk_true; + self->ro_held = tsdp_header_M_is_held(m, tsk_false); } return ret; } @@ -962,8 +963,9 @@ int tmedia_session_mgr_hold(tmedia_session_mgr_t* self, tmedia_type_t type) tsk_list_foreach(item, self->sessions){ tmedia_session_t* session = TMEDIA_SESSION(item->data); if(((session->type & type) == session->type) && session->M.lo){ - if(!tsdp_header_M_hold(session->M.lo, tsk_true)){ + if(tsdp_header_M_hold(session->M.lo, tsk_true) == 0){ self->state_changed = tsk_true; + session->lo_held = tsk_true; } } } @@ -1029,6 +1031,7 @@ int tmedia_session_mgr_resume(tmedia_session_mgr_t* self, tmedia_type_t type) if(((session->type & type) == session->type) && session->M.lo){ if(!tsdp_header_M_resume(session->M.lo, tsk_true)){ self->state_changed = tsk_true; + session->lo_held = tsk_false; } } } diff --git a/branches/2.0/doubango/tinyNET/src/tnet_transport.c b/branches/2.0/doubango/tinyNET/src/tnet_transport.c index f6216b6a..83bc087c 100644 --- a/branches/2.0/doubango/tinyNET/src/tnet_transport.c +++ b/branches/2.0/doubango/tinyNET/src/tnet_transport.c @@ -282,7 +282,7 @@ tnet_fd_t tnet_transport_connectto(const tnet_transport_handle_t *handle, const */ if(TNET_SOCKET_TYPE_IS_STREAM(type)){ /* Create client socket descriptor. */ - if(status = tnet_sockfd_init(transport->local_ip, TNET_SOCKET_PORT_ANY, type, &fd)){ + if(status = tnet_sockfd_init(transport->local_host, TNET_SOCKET_PORT_ANY, type, &fd)){ TSK_DEBUG_ERROR("Failed to create new sockfd."); goto bail; } @@ -398,31 +398,28 @@ static tsk_object_t* tnet_transport_ctor(tsk_object_t * self, va_list * app) { tnet_transport_t *transport = self; if(transport){ - const char *host = va_arg(*app, const char*); - + const char *local_host = va_arg(*app, const char*); #if defined(__GNUC__) - tnet_port_t port = (uint16_t)va_arg(*app, unsigned); + tnet_port_t req_local_port = (uint16_t)va_arg(*app, unsigned); #else - tnet_port_t port = (tnet_port_t)va_arg(*app, tnet_port_t); + tnet_port_t req_local_port = (tnet_port_t)va_arg(*app, tnet_port_t); #endif - tnet_socket_type_t type = va_arg(*app, tnet_socket_type_t); const char *description = va_arg(*app, const char*); - - if(description){ - transport->description = tsk_strdup(description); - } + transport->description = tsk_strdup(description); + transport->local_host = tsk_strdup(local_host); + transport->req_local_port = req_local_port; transport->type = type; - - transport->master = tnet_socket_create(host, port, type); transport->context = tnet_transport_context_create(); - - if(TNET_SOCKET_TYPE_IS_IPV46(transport->type)){ - transport->local_ip = tsk_strdup(host); /* FQDN */ + + if((transport->master = tnet_socket_create(local_host, req_local_port, type))){ + transport->local_ip = tsk_strdup(transport->master->ip); + transport->bind_local_port = transport->master->port; } else{ - transport->local_ip = tsk_strdup(transport->master->ip); /* IP address */ + TSK_DEBUG_ERROR("Failed to create master socket"); + return tsk_null; } } return self; @@ -438,6 +435,7 @@ static tsk_object_t* tnet_transport_dtor(tsk_object_t * self) TSK_OBJECT_SAFE_FREE(transport->natt_ctx); TSK_FREE(transport->description); TSK_FREE(transport->local_ip); + TSK_FREE(transport->local_host); // tls TSK_FREE(transport->tls.ca); diff --git a/branches/2.0/doubango/tinyNET/src/tnet_transport.h b/branches/2.0/doubango/tinyNET/src/tnet_transport.h index ce853fd9..1927d2c0 100644 --- a/branches/2.0/doubango/tinyNET/src/tnet_transport.h +++ b/branches/2.0/doubango/tinyNET/src/tnet_transport.h @@ -105,6 +105,9 @@ typedef struct tnet_transport_s tnet_socket_type_t type; char* local_ip; + char* local_host; + tnet_port_t req_local_port; // user requested local port + tnet_port_t bind_local_port; // local port on which we are listening (same as master socket) tnet_nat_context_handle_t* natt_ctx; tnet_socket_t *master; diff --git a/branches/2.0/doubango/tinyNET/src/tnet_transport_poll.c b/branches/2.0/doubango/tinyNET/src/tnet_transport_poll.c index 6494b071..4a34ab76 100644 --- a/branches/2.0/doubango/tinyNET/src/tnet_transport_poll.c +++ b/branches/2.0/doubango/tinyNET/src/tnet_transport_poll.c @@ -496,6 +496,18 @@ int tnet_transport_prepare(tnet_transport_t *transport) TSK_DEBUG_ERROR("Transport already prepared."); return -2; } + + /* Prepare master */ + if(!transport->master){ + if((transport->master = tnet_socket_create(transport->local_host, transport->req_local_port, transport->type))){ + tsk_strupdate(&transport->local_ip, transport->master->ip); + transport->bind_local_port = transport->master->port; + } + else{ + TSK_DEBUG_ERROR("Failed to create master socket"); + return -3; + } + } /* set events */ context->events = TNET_POLLIN | TNET_POLLNVAL | TNET_POLLERR; @@ -569,6 +581,9 @@ int tnet_transport_unprepare(tnet_transport_t *transport) removeSocket(0, context); // safe } + // destroy master as it has been close by removeSocket() + TSK_OBJECT_SAFE_FREE(transport->master); + return 0; } diff --git a/branches/2.0/doubango/tinyNET/src/tnet_transport_win32.c b/branches/2.0/doubango/tinyNET/src/tnet_transport_win32.c index 24ab04c8..a60acb15 100644 --- a/branches/2.0/doubango/tinyNET/src/tnet_transport_win32.c +++ b/branches/2.0/doubango/tinyNET/src/tnet_transport_win32.c @@ -64,7 +64,7 @@ typedef struct transport_context_s transport_context_t; static transport_socket_t* getSocket(transport_context_t *context, tnet_fd_t fd); -static int addSocket(tnet_fd_t fd, tnet_socket_type_t type, tnet_transport_t *transport, int take_ownership, int is_client); +static int addSocket(tnet_fd_t fd, tnet_socket_type_t type, tnet_transport_t *transport, tsk_bool_t take_ownership, tsk_bool_t is_client); static int removeSocket(int index, transport_context_t *context); /* Checks if socket is connected */ @@ -342,7 +342,7 @@ static transport_socket_t* getSocket(transport_context_t *context, tnet_fd_t fd) } /*== Add new socket ==*/ -static int addSocket(tnet_fd_t fd, tnet_socket_type_t type, tnet_transport_t *transport, int take_ownership, int is_client) +static int addSocket(tnet_fd_t fd, tnet_socket_type_t type, tnet_transport_t *transport, tsk_bool_t take_ownership, tsk_bool_t is_client) { transport_context_t *context = transport?transport->context:0; @@ -448,6 +448,18 @@ int tnet_transport_prepare(tnet_transport_t *transport) TSK_DEBUG_ERROR("Transport already prepared."); return -2; } + + /* Prepare master */ + if(!transport->master){ + if((transport->master = tnet_socket_create(transport->local_host, transport->req_local_port, transport->type))){ + tsk_strupdate(&transport->local_ip, transport->master->ip); + transport->bind_local_port = transport->master->port; + } + else{ + TSK_DEBUG_ERROR("Failed to create master socket"); + return -3; + } + } /* Start listening */ if(TNET_SOCKET_TYPE_IS_STREAM(transport->master->type)){ @@ -497,6 +509,8 @@ int tnet_transport_unprepare(tnet_transport_t *transport) while(context->count){ removeSocket(0, context); // safe } + // destroy master as it has been close by removeSocket() + TSK_OBJECT_SAFE_FREE(transport->master); return 0; } diff --git a/branches/2.0/doubango/tinyNET/src/tnet_utils.c b/branches/2.0/doubango/tinyNET/src/tnet_utils.c index 5fce59d6..ddea1e0a 100644 --- a/branches/2.0/doubango/tinyNET/src/tnet_utils.c +++ b/branches/2.0/doubango/tinyNET/src/tnet_utils.c @@ -1247,9 +1247,10 @@ int tnet_sockfd_sendto(tnet_fd_t fd, const struct sockaddr *to, const void* buf, DWORD numberOfBytesSent = 0; wsaBuffer.buf = ((CHAR*)buf) + sent; wsaBuffer.len = (size-sent); - ret = WSASendTo(fd, &wsaBuffer, 1, &numberOfBytesSent, 0, to, tnet_get_sockaddr_size(to), 0, 0); + ret = WSASendTo(fd, &wsaBuffer, 1, &numberOfBytesSent, 0, to, tnet_get_sockaddr_size(to), 0, 0); // returns zero if succeed + if(ret == 0) ret = numberOfBytesSent; #else - ret = sendto(fd, (((const uint8_t*)buf)+sent), (size-sent), 0, to, tnet_get_sockaddr_size(to)); + ret = sendto(fd, (((const uint8_t*)buf)+sent), (size-sent), 0, to, tnet_get_sockaddr_size(to)); // returns number of sent bytes if succeed #endif if(ret <= 0){ goto bail; diff --git a/branches/2.0/doubango/tinyRTP/src/trtp_manager.c b/branches/2.0/doubango/tinyRTP/src/trtp_manager.c index 2e8e8d99..07ab0fb9 100644 --- a/branches/2.0/doubango/tinyRTP/src/trtp_manager.c +++ b/branches/2.0/doubango/tinyRTP/src/trtp_manager.c @@ -328,13 +328,13 @@ int trtp_manager_start(trtp_manager_t* self) return 0; } - if(!self->transport || !self->transport->master){ + if(!self->transport){ TSK_DEBUG_ERROR("RTP/RTCP manager not prepared"); return -2; } /* Flush buffers and re-enable sockets */ - { + if(self->transport->master){ char buff[2048]; // re-enable sockets @@ -409,12 +409,12 @@ int trtp_manager_send_rtp(trtp_manager_t* self, const void* data, tsk_size_t siz tsk_buffer_t* buffer; int ret = -1; - if(!self || !data || !size){ + if(!self || !self->transport || !data || !size){ TSK_DEBUG_ERROR("Invalid parameter"); return -1; } - if(!self->started){ + if(!self->started || !self->transport->master){ //--TSK_DEBUG_ERROR("RTP/RTCP manager should be started before trying to send data"); return -2; } diff --git a/branches/2.0/doubango/tinySIP/src/dialogs/tsip_dialog_invite.c b/branches/2.0/doubango/tinySIP/src/dialogs/tsip_dialog_invite.c index 19f54263..61ef85b4 100644 --- a/branches/2.0/doubango/tinySIP/src/dialogs/tsip_dialog_invite.c +++ b/branches/2.0/doubango/tinySIP/src/dialogs/tsip_dialog_invite.c @@ -527,6 +527,7 @@ int x0000_Connected_2_Connected_X_iINVITEorUPDATE(va_list *app) tsk_bool_t bodiless_invite; tmedia_type_t old_media_type = self->msession_mgr ? self->msession_mgr->type : tmedia_none; tmedia_type_t new_media_type; + static tsk_bool_t force_sdp = tsk_true; // This is a hack: many client fail to handle 200 Ok without sdp after reINVITE (e.g. hold/resume) /* process remote offer */ if((ret = tsip_dialog_invite_process_ro(self, rINVITEorUPDATE))){ @@ -555,7 +556,7 @@ int x0000_Connected_2_Connected_X_iINVITEorUPDATE(va_list *app) // send the response ret = send_RESPONSE(self, rINVITEorUPDATE, 200, "OK", - (self->msession_mgr && (bodiless_invite || self->msession_mgr->ro_changed || self->msession_mgr->state_changed || (old_media_type != new_media_type)))); + (self->msession_mgr && (force_sdp || bodiless_invite || self->msession_mgr->ro_changed || self->msession_mgr->state_changed || (old_media_type != new_media_type)))); /* session timers */ if(self->stimers.timer.timeout){