Bug 907353 - Disable second component when rtcp-mux r=ekr
authorEthan Hugg <ethanhugg@gmail.com>
Tue, 27 Aug 2013 12:34:44 -0700
changeset 158927 cdb9d968f5573f5138dbce26a6395ff0122abbe2
parent 158926 e87c91815713a09729ef5b89fa184f0e18799cf1
child 158928 e2796e169e2834986d2c341ecca63e42de81e333
push id2961
push userlsblakk@mozilla.com
push dateMon, 28 Oct 2013 21:59:28 +0000
treeherdermozilla-beta@73ef4f13486f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersekr
bugs907353
milestone26.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 907353 - Disable second component when rtcp-mux r=ekr
media/webrtc/signaling/src/media/VcmSIPCCBinding.cpp
media/webrtc/signaling/src/sipcc/core/gsm/gsm_sdp.c
media/webrtc/signaling/src/sipcc/core/includes/config.h
media/webrtc/signaling/src/sipcc/include/vcm.h
media/webrtc/signaling/test/signaling_unittests.cpp
--- a/media/webrtc/signaling/src/media/VcmSIPCCBinding.cpp
+++ b/media/webrtc/signaling/src/media/VcmSIPCCBinding.cpp
@@ -2854,9 +2854,57 @@ int vcmOnSdpParseError(const char *peerc
   if (!NS_SUCCEEDED(rv)) {
     CSFLogError( logTag, "%s(): Could not dispatch to main thread", __FUNCTION__);
     return VCM_ERROR;
   }
 
   return 0;
 }
 
-
+/**
+ * vcmDisableRtcpComponent_m
+ *
+ * If we are doing rtcp-mux we need to disable component number 2 in the ICE
+ * layer.  Otherwise we will wait for it to connect when it is unused
+ */
+static int vcmDisableRtcpComponent_m(const char *peerconnection, int level) {
+#ifdef MOZILLA_INTERNAL_API
+  MOZ_ASSERT(NS_IsMainThread());
+#endif
+  MOZ_ASSERT(level > 0);
+
+  sipcc::PeerConnectionWrapper pc(peerconnection);
+  ENSURE_PC(pc, VCM_ERROR);
+
+  CSFLogDebug( logTag, "%s: disabling rtcp component %d", __FUNCTION__, level);
+  mozilla::RefPtr<NrIceMediaStream> stream = pc.impl()->media()->
+    ice_media_stream(level-1);
+  MOZ_ASSERT(stream);
+  if (!stream) {
+    return VCM_ERROR;
+  }
+
+  // The second component is for RTCP
+  nsresult res = stream->DisableComponent(2);
+  MOZ_ASSERT(NS_SUCCEEDED(res));
+  if (!NS_SUCCEEDED(res)) {
+    return VCM_ERROR;
+  }
+
+  return 0;
+}
+
+/**
+ * vcmDisableRtcpComponent
+ *
+ * If we are doing rtcp-mux we need to disable component number 2 in the ICE
+ * layer.  Otherwise we will wait for it to connect when it is unused
+ */
+int vcmDisableRtcpComponent(const char *peerconnection, int level) {
+  int ret;
+  mozilla::SyncRunnable::DispatchToThread(VcmSIPCCBinding::getMainThread(),
+      WrapRunnableNMRet(&vcmDisableRtcpComponent_m,
+                        peerconnection,
+                        level,
+                        &ret));
+  return ret;
+}
+
--- a/media/webrtc/signaling/src/sipcc/core/gsm/gsm_sdp.c
+++ b/media/webrtc/signaling/src/sipcc/core/gsm/gsm_sdp.c
@@ -6829,16 +6829,27 @@ gsmsdp_install_peer_ice_attributes(fsm_f
             return (CC_CAUSE_SETTING_ICE_SESSION_PARAMETERS_FAILED);
     }
 
     /* Now process all the media lines */
     GSMSDP_FOR_ALL_MEDIA(media, dcb_p) {
       if (!GSMSDP_MEDIA_ENABLED(media))
         continue;
 
+      /* If we are muxing, disable the second
+         component of the ICE stream */
+      if (media->rtcp_mux) {
+        vcm_res = vcmDisableRtcpComponent(dcb_p->peerconnection,
+          media->level);
+
+        if (vcm_res) {
+          return (CC_CAUSE_SETTING_ICE_SESSION_PARAMETERS_FAILED);
+        }
+      }
+
       sdp_res = sdp_attr_get_ice_attribute(sdp_p->dest_sdp, media->level, 0,
         SDP_ATTR_ICE_UFRAG, 1, &ufrag);
       if (sdp_res != SDP_SUCCESS)
         ufrag = NULL;
 
       sdp_res = sdp_attr_get_ice_attribute(sdp_p->dest_sdp, media->level, 0,
         SDP_ATTR_ICE_PWD, 1, &pwd);
       if (sdp_res != SDP_SUCCESS)
--- a/media/webrtc/signaling/src/sipcc/core/includes/config.h
+++ b/media/webrtc/signaling/src/sipcc/core/includes/config.h
@@ -174,17 +174,17 @@ static const unsigned char gCallWaiting 
 static const int gDeviceSecurityMode = 1;
 static const int gCcm2_sip_port = 5060;
 static const int gCcm3_sip_port = 5060;
 static const boolean gCcm1_isvalid = TRUE;
 static const int gDscpCallControl = 1;
 static const int gSpeakerEnabled = 1;
 static const char gExternalNumberMask[] = "";
 static const char gVersion[] = "0.1";
-static const boolean gRTCPMUX = FALSE;
+static const boolean gRTCPMUX = TRUE;
 static boolean gRTPSAVPF = TRUE;           /* TRUE = RTP/SAVPF , FALSE = RTP/SAVP */
 static const boolean gMAXAVBITRATE = FALSE;      /* Following six are OPUS fmtp options */
 static const boolean gMAXCODEDAUDIOBW = FALSE;
 static const boolean gUSEDTX = FALSE;
 static const boolean gSTEREO = FALSE;
 static const boolean gUSEINBANDFEC = FALSE;
 static const boolean gCBR = FALSE;
 static const boolean gMAXPTIME = FALSE;
--- a/media/webrtc/signaling/src/sipcc/include/vcm.h
+++ b/media/webrtc/signaling/src/sipcc/include/vcm.h
@@ -1030,16 +1030,24 @@ int vcmGetILBCMode();
  * vcmOnSdpParseError
  *
  * This method is called for each parsing error of SDP.  It does not necessarily
  * mean the SDP read was fatal and can be called many times for the same SDP.
  *
  */
 int vcmOnSdpParseError(const char *peercconnection, const char *message);
 
+/**
+ * vcmDisableRtcpComponent
+ *
+ * If we are doing rtcp-mux we need to disable component number 2 in the ICE
+ * layer.  Otherwise we will wait for it to connect when it is unused
+ */
+int vcmDisableRtcpComponent(const char *peerconnection, int level);
+
 //Using C++ for gips. This is the end of extern "C" above.
 #ifdef __cplusplus
 }
 #endif
 
 
 
 
--- a/media/webrtc/signaling/test/signaling_unittests.cpp
+++ b/media/webrtc/signaling/test/signaling_unittests.cpp
@@ -32,17 +32,17 @@
 #include "nricectx.h"
 #include "mozilla/SyncRunnable.h"
 
 #include "mtransport_test_utils.h"
 MtransportTestUtils *test_utils;
 nsCOMPtr<nsIThread> gThread;
 
 static int kDefaultTimeout = 5000;
-static bool fRtcpMux = false;
+static bool fRtcpMux = true;
 
 static std::string callerName = "caller";
 static std::string calleeName = "callee";
 
 namespace test {
 
 std::string indent(const std::string &s, int width = 4) {
   std::string prefix;