Bug 786152: Increment DataChannel SCTP port in a WebRTC JSEP answer r=jesup
authorEnda Mannion <emannion@gmail.com>
Fri, 28 Sep 2012 11:36:02 +0100
changeset 110669 daf391b98703475dbda9aead34a7e5ebc16c0a1c
parent 110668 59c3444a049e1eb4acbd402b46fafe76343036d5
child 110670 cbaae9a05b62629d0714a9a0912948be4ef391bf
push id93
push usernmatsakis@mozilla.com
push dateWed, 31 Oct 2012 21:26:57 +0000
reviewersjesup
bugs786152
milestone19.0a1
Bug 786152: Increment DataChannel SCTP port in a WebRTC JSEP answer r=jesup
media/webrtc/signaling/src/sipcc/core/gsm/gsm_sdp.c
--- a/media/webrtc/signaling/src/sipcc/core/gsm/gsm_sdp.c
+++ b/media/webrtc/signaling/src/sipcc/core/gsm/gsm_sdp.c
@@ -1325,30 +1325,27 @@ gsmsdp_set_media_attributes (uint32_t me
  * Add the specified SCTP media format to the SDP.
  *
  * Parameters:
  *
  * sdp_p - Pointer to the SDP the media attribute is to be added to.
  * level - The media level of the SDP where the media attribute is to be added.
  */
 static void
-gsmsdp_set_sctp_attributes (void *sdp_p, uint16_t level)
+gsmsdp_set_sctp_attributes (void *sdp_p, uint16_t level, fsmdef_media_t *media)
 {
     uint16_t a_inst;
-    int      sctp_port = 0;
-
-    config_get_value(CFGID_SCTP_PORT, &sctp_port, sizeof(sctp_port));
 
     if (sdp_add_new_attr(sdp_p, level, 0, SDP_ATTR_FMTP, &a_inst)
         != SDP_SUCCESS) {
          return;
     }
 
     /* Use SCTP port in place of fmtp payload type */
-    (void) sdp_attr_set_fmtp_payload_type(sdp_p, level, 0, a_inst, sctp_port);
+    (void) sdp_attr_set_fmtp_payload_type(sdp_p, level, 0, a_inst, media->sctp_port);
 
     sdp_attr_set_fmtp_data_channel_protocol (sdp_p, level, 0, a_inst, WEBRTC_DATA_CHANNEL_PROT);
 
     sdp_attr_set_fmtp_streams (sdp_p, level, 0, a_inst, 16);
 }
 
 /*
  * gsmsdp_set_remote_sdp
@@ -2291,17 +2288,17 @@ gsmsdp_update_local_sdp_media (fsmdef_dc
             gsmsdp_add_default_audio_formats_to_local_sdp(dcb_p, cc_sdp_p,
                                                           media);
             break;
         case SDP_MEDIA_VIDEO:
             gsmsdp_add_default_video_formats_to_local_sdp(dcb_p, cc_sdp_p,
                                                           media);
             break;
         case SDP_MEDIA_APPLICATION:
-            gsmsdp_set_sctp_attributes (sdp_p, level);
+            gsmsdp_set_sctp_attributes (sdp_p, level, media);
             break;
         default:
             GSM_ERR_MSG(GSM_L_C_F_PREFIX"SDP ERROR media %d for level %d is not"
                         " supported\n",
                         dcb_p->line, dcb_p->call_id, fname, media->level);
             break;
         }
     } else {
@@ -2328,17 +2325,17 @@ gsmsdp_update_local_sdp_media (fsmdef_dc
             gsmsdp_set_media_attributes(media->payload, sdp_p, level,
                                     (uint16_t)dynamic_payload_type);
             break;
         case SDP_MEDIA_VIDEO:
             gsmsdp_set_video_media_attributes(media->payload, cc_sdp_p, level,
                             (uint16_t)dynamic_payload_type);
             break;
         case SDP_MEDIA_APPLICATION:
-            gsmsdp_set_sctp_attributes (sdp_p, level);
+            gsmsdp_set_sctp_attributes (sdp_p, level, media);
             break;
         default:
             GSM_ERR_MSG(GSM_L_C_F_PREFIX"SDP ERROR media %d for level %d is not"
                         " supported\n",
                         dcb_p->line, dcb_p->call_id, fname, media->level);
             break;
         }
 
@@ -2425,18 +2422,18 @@ gsmsdp_update_local_sdp (fsmdef_dcb_t *d
      * Negotiate direction based on remote SDP.
      */
     direction = gsmsdp_negotiate_local_sdp_direction(dcb_p, media, local_hold);
 
     /*
      * Update Transmit SRTP transmit key if this SRTP session.
      */
     if (media->transport == SDP_TRANSPORT_RTPSAVP) {
-    gsmsdp_update_crypto_transmit_key(dcb_p, media, offer,
-                                      initial_offer, direction);
+        gsmsdp_update_crypto_transmit_key(dcb_p, media, offer,
+                                       initial_offer, direction);
     }
 
     if (offer == TRUE) {
         gsmsdp_update_local_sdp_media(dcb_p, dcb_p->sdp, FALSE, media,
                                       media->transport);
     }
 
     /*
@@ -2977,16 +2974,19 @@ gsmsdp_negotiate_datachannel_attribs(fsm
     if(media->protocol == NULL) {
         media->protocol = cpr_malloc(SDP_MAX_STRING_LEN+1);
         if (media->protocol == NULL)
         	return;
     }
     sdp_attr_get_fmtp_data_channel_protocol(sdp_p->dest_sdp, level, 0, 1, media->protocol);
 
     media->sctp_port = sdp_attr_get_fmtp_payload_type (sdp_p->dest_sdp, level, 0, 1);
+
+    /* Increment port for answer SDP */
+    media->sctp_port++;
 }
 
 /*
  * gsmsdp_add_unsupported_stream_to_local_sdp
  *
  * Description:
  *
  * Adds a rejected media line to the local SDP. If there is already a media line at
@@ -4610,22 +4610,22 @@ gsmsdp_add_media_line (fsmdef_dcb_t *dcb
             GSM_ERR_MSG(GSM_L_C_F_PREFIX"allocate rx port failed\n",
                         dcb_p->line, dcb_p->call_id, fname);
             gsmsdp_remove_media(dcb_p, media);
             return (NULL);
         }
 
         /* allocate port successful, save the port */
 
-    	media->src_port = data.open_rcv.port;
-
-    	if(media_cap->type == SDP_MEDIA_APPLICATION) {
+        media->src_port = data.open_rcv.port;
+
+        if(media_cap->type == SDP_MEDIA_APPLICATION) {
             config_get_value(CFGID_SCTP_PORT, &sctp_port, sizeof(sctp_port));
             media->sctp_port = sctp_port;
-    	}
+        }
 
         /*
          * Setup the local soruce address.
          */
         if (addr_type == CPR_IP_ADDR_IPV6) {
             gsmsdp_get_local_source_v6_address(media);
         } else if (addr_type == CPR_IP_ADDR_IPV4) {
             gsmsdp_get_local_source_v4_address(media);