Bug 922245 - Make SDP buffer allocation dynamic in feature message r=ehugg
authorAdam Roach [:abr] <adam@nostrum.com>
Mon, 30 Sep 2013 22:28:38 -0500
changeset 149408 3b0cd8c4e0a4ae45c9076d74f73b80abf96b6ff3
parent 149407 cc2c853d5c7635cfd50766b1bfcc608a952822bc
child 149409 111be6d857e12fc2263f8c84f5df2f7c26a2fb3e
push id25386
push useremorley@mozilla.com
push dateTue, 01 Oct 2013 09:29:22 +0000
treeherdermozilla-central@6856c45f3688 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersehugg
bugs922245
milestone27.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 922245 - Make SDP buffer allocation dynamic in feature message r=ehugg
media/webrtc/signaling/src/sipcc/core/gsm/ccapi.c
media/webrtc/signaling/src/sipcc/core/includes/ccapi.h
media/webrtc/signaling/test/signaling_unittests.cpp
--- a/media/webrtc/signaling/src/sipcc/core/gsm/ccapi.c
+++ b/media/webrtc/signaling/src/sipcc/core/gsm/ccapi.c
@@ -648,16 +648,17 @@ cc_free_msg_data (cc_msg_t *msg)
             msg_body = cc_get_msg_body_info_ptr_from_feature_data(
                                msg->msg.feature.feature_id,
                                &msg->msg.feature.data);
 
             if (msg->msg.feature.feature_id == CC_FEATURE_CALLINFO) {
                 caller_id = &msg->msg.feature.data.call_info.caller_id;
             }
         }
+        cpr_free(msg->msg.feature.sdp);
         break;
     case CC_MSG_FEATURE_ACK:
         if (msg->msg.feature_ack.data_valid) {
             msg_body = cc_get_msg_body_info_ptr_from_feature_data(
                                msg->msg.feature_ack.feature_id,
                                &msg->msg.feature_ack.data);
         }
         break;
@@ -1205,18 +1206,25 @@ static void send_message_helper(
     pmsg->feature_id = feature_id;
     pmsg->data_valid = (data == NULL) ? (FALSE) : (TRUE);
     pmsg->timecard   = timecard;
 
     if (msg_id == CC_MSG_SETLOCALDESC || msg_id == CC_MSG_SETREMOTEDESC) {
         pmsg->action = action;
     }
 
-    if (msg_id == CC_MSG_CREATEANSWER || msg_id == CC_MSG_SETLOCALDESC || msg_id == CC_MSG_SETREMOTEDESC) {
-        sstrncpy(pmsg->sdp, sdp, sizeof(pmsg->sdp));
+    if (sdp &&
+        (msg_id == CC_MSG_CREATEANSWER ||
+         msg_id == CC_MSG_SETLOCALDESC ||
+         msg_id == CC_MSG_SETREMOTEDESC)) {
+        size_t sdp_size = strlen(sdp) + 1;
+        pmsg->sdp = cpr_malloc(sdp_size);
+        sstrncpy(pmsg->sdp, sdp, sdp_size);
+    } else {
+        pmsg->sdp = NULL;
     }
 
     if (pmsg->data_valid == TRUE) {
         pmsg->data = *data;
         /*
          * For call Info feature, need to copy the caller ID
          */
         if (feature_id == CC_FEATURE_CALLINFO) {
--- a/media/webrtc/signaling/src/sipcc/core/includes/ccapi.h
+++ b/media/webrtc/signaling/src/sipcc/core/includes/ccapi.h
@@ -26,17 +26,16 @@ typedef unsigned int cc_security_e;
 typedef unsigned int cc_select_state_e;
 typedef unsigned int cc_call_type_e;
 typedef unsigned int cc_policy_e;
 typedef int cc_causes_t;
 #define  CC_CALL_OUTGOMING  CC_CALL_TYPE_OUTGOING
 #define  CC_CALL_FORWARDED  CC_CALL_TYPE_FORWARDED
 #define  CC_CALL_NONE       CC_CALL_TYPE_NONE
 #define  CC_CALL_INCOMING   CC_CALL_TYPE_INCOMING
-#define  SDP_SIZE           4096   /* must increase this */
 #define  CANDIDATE_SIZE     150
 #define  MID_SIZE           150
 
 #include "sessionConstants.h"
 
 typedef int  cc_features_t;
 typedef unsigned int softkey_events;
 typedef unsigned int cc_call_priority_e;
@@ -959,17 +958,17 @@ typedef struct cc_feature_t_ {
     cc_msgs_t            msg_id;
     cc_srcs_t            src_id;
     callid_t             call_id;
     line_t               line;
     cc_features_t        feature_id;
     cc_feature_data_t    data;
     boolean              data_valid;
     cc_jsep_action_t     action;
-    char                 sdp[SDP_SIZE];
+    char                *sdp;
     Timecard            *timecard;
 } cc_feature_t;
 
 typedef struct cc_feature_ack_t_ {
     cc_msgs_t         msg_id;
     cc_srcs_t         src_id;
     callid_t          call_id;
     line_t            line;
--- a/media/webrtc/signaling/test/signaling_unittests.cpp
+++ b/media/webrtc/signaling/test/signaling_unittests.cpp
@@ -3219,16 +3219,120 @@ TEST_F(SignalingTest, FullCallRealTrickl
                    a2_->GetPacketsReceived(0) >= 40, kDefaultTimeout * 2);
 
   a1_->CloseSendStreams();
   a2_->CloseReceiveStreams();
   ASSERT_GE(a1_->GetPacketsSent(0), 40);
   ASSERT_GE(a2_->GetPacketsReceived(0), 40);
 }
 
+TEST_F(SignalingTest, hugeSdp)
+{
+  EnsureInit();
+
+  sipcc::MediaConstraints constraints;
+  std::string offer =
+    "v=0\r\n"
+    "o=- 1109973417102828257 2 IN IP4 127.0.0.1\r\n"
+    "s=-\r\n"
+    "t=0 0\r\n"
+    "a=group:BUNDLE audio video\r\n"
+    "a=msid-semantic: WMS 1PBxet5BYh0oYodwsvNM4k6KiO2eWCX40VIP\r\n"
+    "m=audio 32952 RTP/SAVPF 111 103 104 0 8 107 106 105 13 126\r\n"
+    "c=IN IP4 128.64.32.16\r\n"
+    "a=rtcp:32952 IN IP4 128.64.32.16\r\n"
+    "a=candidate:77142221 1 udp 2113937151 192.168.137.1 54081 typ host generation 0\r\n"
+    "a=candidate:77142221 2 udp 2113937151 192.168.137.1 54081 typ host generation 0\r\n"
+    "a=candidate:983072742 1 udp 2113937151 172.22.0.56 54082 typ host generation 0\r\n"
+    "a=candidate:983072742 2 udp 2113937151 172.22.0.56 54082 typ host generation 0\r\n"
+    "a=candidate:2245074553 1 udp 1845501695 32.64.128.1 62397 typ srflx raddr 192.168.137.1 rport 54081 generation 0\r\n"
+    "a=candidate:2245074553 2 udp 1845501695 32.64.128.1 62397 typ srflx raddr 192.168.137.1 rport 54081 generation 0\r\n"
+    "a=candidate:2479353907 1 udp 1845501695 32.64.128.1 54082 typ srflx raddr 172.22.0.56 rport 54082 generation 0\r\n"
+    "a=candidate:2479353907 2 udp 1845501695 32.64.128.1 54082 typ srflx raddr 172.22.0.56 rport 54082 generation 0\r\n"
+    "a=candidate:1243276349 1 tcp 1509957375 192.168.137.1 0 typ host generation 0\r\n"
+    "a=candidate:1243276349 2 tcp 1509957375 192.168.137.1 0 typ host generation 0\r\n"
+    "a=candidate:1947960086 1 tcp 1509957375 172.22.0.56 0 typ host generation 0\r\n"
+    "a=candidate:1947960086 2 tcp 1509957375 172.22.0.56 0 typ host generation 0\r\n"
+    "a=candidate:1808221584 1 udp 33562367 128.64.32.16 32952 typ relay raddr 32.64.128.1 rport 62398 generation 0\r\n"
+    "a=candidate:1808221584 2 udp 33562367 128.64.32.16 32952 typ relay raddr 32.64.128.1 rport 62398 generation 0\r\n"
+    "a=candidate:507872740 1 udp 33562367 128.64.32.16 40975 typ relay raddr 32.64.128.1 rport 54085 generation 0\r\n"
+    "a=candidate:507872740 2 udp 33562367 128.64.32.16 40975 typ relay raddr 32.64.128.1 rport 54085 generation 0\r\n"
+    "a=ice-ufrag:xQuJwjX3V3eMA81k\r\n"
+    "a=ice-pwd:ZUiRmjS2GDhG140p73dAsSVP\r\n"
+    "a=ice-options:google-ice\r\n"
+    "a=fingerprint:sha-256 59:4A:8B:73:A7:73:53:71:88:D7:4D:58:28:0C:79:72:31:29:9B:05:37:DD:58:43:C2:D4:85:A2:B3:66:38:7A\r\n"
+    "a=extmap:1 urn:ietf:params:rtp-hdrext:ssrc-audio-level\r\n"
+    "a=sendrecv\r\n"
+    "a=mid:audio\r\n"
+    "a=rtcp-mux\r\n"
+    "a=crypto:1 AES_CM_128_HMAC_SHA1_80 inline:/U44g3ULdtapeiSg+T3n6dDLBKIjpOhb/NXAL/2b\r\n"
+    "a=rtpmap:111 opus/48000/2\r\n"
+    "a=fmtp:111 minptime=10\r\n"
+    "a=rtpmap:103 ISAC/16000\r\n"
+    "a=rtpmap:104 ISAC/32000\r\n"
+    "a=rtpmap:0 PCMU/8000\r\n"
+    "a=rtpmap:8 PCMA/8000\r\n"
+    "a=rtpmap:107 CN/48000\r\n"
+    "a=rtpmap:106 CN/32000\r\n"
+    "a=rtpmap:105 CN/16000\r\n"
+    "a=rtpmap:13 CN/8000\r\n"
+    "a=rtpmap:126 telephone-event/8000\r\n"
+    "a=maxptime:60\r\n"
+    "a=ssrc:2271517329 cname:mKDNt7SQf6pwDlIn\r\n"
+    "a=ssrc:2271517329 msid:1PBxet5BYh0oYodwsvNM4k6KiO2eWCX40VIP 1PBxet5BYh0oYodwsvNM4k6KiO2eWCX40VIPa0\r\n"
+    "a=ssrc:2271517329 mslabel:1PBxet5BYh0oYodwsvNM4k6KiO2eWCX40VIP\r\n"
+    "a=ssrc:2271517329 label:1PBxet5BYh0oYodwsvNM4k6KiO2eWCX40VIPa0\r\n"
+    "m=video 32952 RTP/SAVPF 100 116 117\r\n"
+    "c=IN IP4 128.64.32.16\r\n"
+    "a=rtcp:32952 IN IP4 128.64.32.16\r\n"
+    "a=candidate:77142221 1 udp 2113937151 192.168.137.1 54081 typ host generation 0\r\n"
+    "a=candidate:77142221 2 udp 2113937151 192.168.137.1 54081 typ host generation 0\r\n"
+    "a=candidate:983072742 1 udp 2113937151 172.22.0.56 54082 typ host generation 0\r\n"
+    "a=candidate:983072742 2 udp 2113937151 172.22.0.56 54082 typ host generation 0\r\n"
+    "a=candidate:2245074553 1 udp 1845501695 32.64.128.1 62397 typ srflx raddr 192.168.137.1 rport 54081 generation 0\r\n"
+    "a=candidate:2245074553 2 udp 1845501695 32.64.128.1 62397 typ srflx raddr 192.168.137.1 rport 54081 generation 0\r\n"
+    "a=candidate:2479353907 1 udp 1845501695 32.64.128.1 54082 typ srflx raddr 172.22.0.56 rport 54082 generation 0\r\n"
+    "a=candidate:2479353907 2 udp 1845501695 32.64.128.1 54082 typ srflx raddr 172.22.0.56 rport 54082 generation 0\r\n"
+    "a=candidate:1243276349 1 tcp 1509957375 192.168.137.1 0 typ host generation 0\r\n"
+    "a=candidate:1243276349 2 tcp 1509957375 192.168.137.1 0 typ host generation 0\r\n"
+    "a=candidate:1947960086 1 tcp 1509957375 172.22.0.56 0 typ host generation 0\r\n"
+    "a=candidate:1947960086 2 tcp 1509957375 172.22.0.56 0 typ host generation 0\r\n"
+    "a=candidate:1808221584 1 udp 33562367 128.64.32.16 32952 typ relay raddr 32.64.128.1 rport 62398 generation 0\r\n"
+    "a=candidate:1808221584 2 udp 33562367 128.64.32.16 32952 typ relay raddr 32.64.128.1 rport 62398 generation 0\r\n"
+    "a=candidate:507872740 1 udp 33562367 128.64.32.16 40975 typ relay raddr 32.64.128.1 rport 54085 generation 0\r\n"
+    "a=candidate:507872740 2 udp 33562367 128.64.32.16 40975 typ relay raddr 32.64.128.1 rport 54085 generation 0\r\n"
+    "a=ice-ufrag:xQuJwjX3V3eMA81k\r\n"
+    "a=ice-pwd:ZUiRmjS2GDhG140p73dAsSVP\r\n"
+    "a=ice-options:google-ice\r\n"
+    "a=fingerprint:sha-256 59:4A:8B:73:A7:73:53:71:88:D7:4D:58:28:0C:79:72:31:29:9B:05:37:DD:58:43:C2:D4:85:A2:B3:66:38:7A\r\n"
+    "a=extmap:2 urn:ietf:params:rtp-hdrext:toffset\r\n"
+    "a=extmap:3 http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time\r\n"
+    "a=sendrecv\r\n"
+    "a=mid:video\r\n"
+    "a=rtcp-mux\r\n"
+    "a=crypto:1 AES_CM_128_HMAC_SHA1_80 inline:/U44g3ULdtapeiSg+T3n6dDLBKIjpOhb/NXAL/2b\r\n"
+    "a=rtpmap:100 VP8/90000\r\n"
+    "a=rtcp-fb:100 ccm fir\r\n"
+    "a=rtcp-fb:100 nack\r\n"
+    "a=rtcp-fb:100 goog-remb\r\n"
+    "a=rtpmap:116 red/90000\r\n"
+    "a=rtpmap:117 ulpfec/90000\r\n"
+    "a=ssrc:54724160 cname:mKDNt7SQf6pwDlIn\r\n"
+    "a=ssrc:54724160 msid:1PBxet5BYh0oYodwsvNM4k6KiO2eWCX40VIP 1PBxet5BYh0oYodwsvNM4k6KiO2eWCX40VIPv0\r\n"
+    "a=ssrc:54724160 mslabel:1PBxet5BYh0oYodwsvNM4k6KiO2eWCX40VIP\r\n"
+    "a=ssrc:54724160 label:1PBxet5BYh0oYodwsvNM4k6KiO2eWCX40VIPv0\r\n";
+
+  a1_->CreateOffer(constraints, OFFER_AV, SHOULD_SENDRECV_AV);
+  a1_->SetLocal(TestObserver::OFFER, offer, true);
+
+  a2_->SetRemote(TestObserver::OFFER, offer, true);
+  ASSERT_GE(a2_->getRemoteDescription().length(), 4096U);
+  a2_->CreateAnswer(constraints, offer, OFFER_AV);
+}
+
 } // End namespace test.
 
 bool is_color_terminal(const char *terminal) {
   if (!terminal) {
     return false;
   }
   const char *color_terms[] = {
     "xterm",