diff --git a/pc/peer_connection_signaling_unittest.cc b/pc/peer_connection_signaling_unittest.cc index 8df90b7bfa..250efc8dc5 100644 --- a/pc/peer_connection_signaling_unittest.cc +++ b/pc/peer_connection_signaling_unittest.cc @@ -1051,7 +1051,7 @@ TEST_P(PeerConnectionSignalingTest, MidAttributeMaxLength) { "1C:2C:74:01:8D:50:67:23\r\n" "a=setup:actpass\r\n" // Too long mid attribute. - "a=mid:01234567890123456\r\n" + "a=mid:0123456789012345678901234567890123\r\n" "a=sendrecv\r\n" "a=msid:stream track\r\n" "a=rtcp-mux\r\n" diff --git a/pc/sdp_offer_answer.cc b/pc/sdp_offer_answer.cc index 8f5cec2f03..4332cd6df8 100644 --- a/pc/sdp_offer_answer.cc +++ b/pc/sdp_offer_answer.cc @@ -124,7 +124,8 @@ const char kSimulcastDisabled[] = "WebRTC.PeerConnection.Simulcast.Disabled"; static const int kRtcpCnameLength = 16; // The maximum length of the MID attribute. -static constexpr size_t kMidMaxSize = 16; +// TODO(bugs.webrtc.org/12517) - reduce to 16 again. +static constexpr size_t kMidMaxSize = 32; const char kDefaultStreamId[] = "default"; // NOTE: Duplicated in peer_connection.cc: @@ -446,21 +447,25 @@ bool VerifyIceUfragPwdPresent( RTCError ValidateMids(const cricket::SessionDescription& description) { std::set mids; + size_t max_length = 0; for (const cricket::ContentInfo& content : description.contents()) { if (content.name.empty()) { LOG_AND_RETURN_ERROR(RTCErrorType::INVALID_PARAMETER, "A media section is missing a MID attribute."); } + max_length = std::max(max_length, content.name.size()); if (content.name.size() > kMidMaxSize) { LOG_AND_RETURN_ERROR(RTCErrorType::INVALID_PARAMETER, "The MID attribute exceeds the maximum supported " - "length of 16 characters."); + "length of 32 characters."); } if (!mids.insert(content.name).second) { LOG_AND_RETURN_ERROR(RTCErrorType::INVALID_PARAMETER, "Duplicate a=mid value '" + content.name + "'."); } } + RTC_HISTOGRAM_COUNTS_LINEAR("WebRTC.PeerConnection.Mid.Size", max_length, 0, + 31, 32); return RTCError::OK(); }