From dcc3d046e2209a455fdf1c47045146f32204219b Mon Sep 17 00:00:00 2001 From: Philipp Hancke Date: Tue, 21 Jun 2022 20:50:59 +0200 Subject: [PATCH] pc: make codec comparison for static codecs case-insensitive BUG=webrtc:14211,webrtc:14140 Change-Id: Ib51de4c8961a4cf7c71aea27a55c115613296aae Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/266371 Commit-Queue: Philipp Hancke Reviewed-by: Harald Alvestrand Cr-Commit-Position: refs/heads/main@{#37295} --- pc/webrtc_sdp.cc | 5 +++-- pc/webrtc_sdp_unittest.cc | 15 +++++++++++++++ 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/pc/webrtc_sdp.cc b/pc/webrtc_sdp.cc index 3f1c83736e..8e4552476b 100644 --- a/pc/webrtc_sdp.cc +++ b/pc/webrtc_sdp.cc @@ -26,6 +26,7 @@ #include "absl/algorithm/container.h" #include "absl/strings/ascii.h" +#include "absl/strings/match.h" #include "api/candidate.h" #include "api/crypto_params.h" #include "api/jsep_ice_candidate.h" @@ -3601,7 +3602,7 @@ bool ParseRtpmapAttribute(absl::string_view line, VideoContentDescription* video_desc = media_desc->as_video(); for (const cricket::VideoCodec& existing_codec : video_desc->codecs()) { if (!existing_codec.name.empty() && payload_type == existing_codec.id && - (encoding_name != existing_codec.name || + (!absl::EqualsIgnoreCase(encoding_name, existing_codec.name) || clock_rate != existing_codec.clockrate)) { rtc::StringBuilder description; description @@ -3633,7 +3634,7 @@ bool ParseRtpmapAttribute(absl::string_view line, AudioContentDescription* audio_desc = media_desc->as_audio(); for (const cricket::AudioCodec& existing_codec : audio_desc->codecs()) { if (!existing_codec.name.empty() && payload_type == existing_codec.id && - (encoding_name != existing_codec.name || + (!absl::EqualsIgnoreCase(encoding_name, existing_codec.name) || clock_rate != existing_codec.clockrate || channels != existing_codec.channels)) { rtc::StringBuilder description; diff --git a/pc/webrtc_sdp_unittest.cc b/pc/webrtc_sdp_unittest.cc index 306b16281c..02f990b381 100644 --- a/pc/webrtc_sdp_unittest.cc +++ b/pc/webrtc_sdp_unittest.cc @@ -4699,6 +4699,21 @@ TEST_F(WebRtcSdpTest, FmtpBeforeRtpMap) { EXPECT_TRUE(SdpDeserialize(sdp, &jdesc_output)); } +TEST_F(WebRtcSdpTest, StaticallyAssignedPayloadTypeWithDifferentCasing) { + std::string sdp = + "v=0\r\n" + "o=- 11 22 IN IP4 127.0.0.1\r\n" + "s=-\r\n" + "t=0 0\r\n" + "m=audio 49232 RTP/AVP 18\r\n" + // Casing differs from statically assigned type, this should + // still be accepted. + "a=rtpmap:18 g729/8000\r\n"; + + JsepSessionDescription jdesc_output(kDummyType); + EXPECT_TRUE(SdpDeserialize(sdp, &jdesc_output)); +} + // This tests parsing of SDP with unknown ssrc-specific attributes. TEST_F(WebRtcSdpTest, ParseIgnoreUnknownSsrcSpecificAttribute) { std::string sdp = kSdpString;