diff --git a/media/webrtc/signaling/src/sipcc/core/gsm/gsm_sdp.c b/media/webrtc/signaling/src/sipcc/core/gsm/gsm_sdp.c index c68b6385d7c..86ed01f07cb 100644 --- a/media/webrtc/signaling/src/sipcc/core/gsm/gsm_sdp.c +++ b/media/webrtc/signaling/src/sipcc/core/gsm/gsm_sdp.c @@ -2855,17 +2855,24 @@ gsmsdp_negotiate_codec (fsmdef_dcb_t *dcb_p, cc_sdp_t *sdp_p, } if (media->type == SDP_MEDIA_AUDIO) { - ptime = sdp_attr_get_simple_u32(sdp_p->dest_sdp, - SDP_ATTR_PTIME, level, 0, 1); - if (ptime != 0) { - media->packetization_period = (uint16_t) ptime; - } + if (media->payload == RTP_ILBC) { media->mode = (uint16_t)sdp_attr_get_fmtp_mode_for_payload_type (sdp_p->dest_sdp, level, 0, media->remote_dynamic_payload_type_value); } if (media->payload == RTP_OPUS) { + u16 a_inst; + if (!sdp_attr_rtpmap_payload_valid(sdp_p->dest_sdp, level, 0, &a_inst, + remote_dynamic_payload_type_value) || + sdp_attr_get_rtpmap_clockrate(sdp_p->dest_sdp, level, 0, a_inst) != RTPMAP_OPUS_CLOCKRATE || + sdp_attr_get_rtpmap_num_chan(sdp_p->dest_sdp, level, 0, a_inst) != 2) { + /* Be conservative in what we accept: any + implementation that does not use a 48 kHz + clockrate or 2 channels is broken. */ + explicit_reject = TRUE; + continue; // keep looking + } maxptime = sdp_attr_get_simple_u32(sdp_p->dest_sdp, SDP_ATTR_MAXPTIME, level, 0, 1); @@ -2887,6 +2894,11 @@ gsmsdp_negotiate_codec (fsmdef_dcb_t *dcb_p, cc_sdp_t *sdp_p, sdp_attr_get_fmtp_cbr (sdp_p->dest_sdp, level, 0, 1, &cbr); } + ptime = sdp_attr_get_simple_u32(sdp_p->dest_sdp, + SDP_ATTR_PTIME, level, 0, 1); + if (ptime != 0) { + media->packetization_period = (uint16_t) ptime; + } GSM_DEBUG(DEB_L_C_F_PREFIX"codec= %d\n", DEB_L_C_F_PREFIX_ARGS(GSM, dcb_p->line, dcb_p->call_id, fname),