From 6644c8b7337abcf4bb91d8658a056c9bce0f8dfe Mon Sep 17 00:00:00 2001 From: kthelgason Date: Mon, 28 Aug 2017 00:48:18 -0700 Subject: [PATCH] Fix a bug in the SDP parser in AppRTCMobile. It would leave a trailing carriage return character in the payload list, causing the preferred codec to appear twice if it was at the back of the list originally. This causes problems down the line and results in that codec not being negotiated successfully. BUG=webrtc:8129 Review-Url: https://codereview.webrtc.org/3001363002 Cr-Commit-Position: refs/heads/master@{#19552} --- .../examples/objc/AppRTCMobile/ARDSDPUtils.m | 2 +- .../AppRTCMobile/tests/ARDSDPUtils_xctest.mm | 26 +++++++++---------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/webrtc/examples/objc/AppRTCMobile/ARDSDPUtils.m b/webrtc/examples/objc/AppRTCMobile/ARDSDPUtils.m index 016829eeec..a9442aac8f 100644 --- a/webrtc/examples/objc/AppRTCMobile/ARDSDPUtils.m +++ b/webrtc/examples/objc/AppRTCMobile/ARDSDPUtils.m @@ -19,7 +19,7 @@ descriptionForDescription:(RTCSessionDescription *)description preferredVideoCodec:(NSString *)codec { NSString *sdpString = description.sdp; - NSString *lineSeparator = @"\n"; + NSString *lineSeparator = @"\r\n"; NSString *mLineSeparator = @" "; // Copied from PeerConnectionClient.java. // TODO(tkchin): Move this to a shared C++ file. diff --git a/webrtc/examples/objc/AppRTCMobile/tests/ARDSDPUtils_xctest.mm b/webrtc/examples/objc/AppRTCMobile/tests/ARDSDPUtils_xctest.mm index b58048f0ca..b94f404741 100644 --- a/webrtc/examples/objc/AppRTCMobile/tests/ARDSDPUtils_xctest.mm +++ b/webrtc/examples/objc/AppRTCMobile/tests/ARDSDPUtils_xctest.mm @@ -21,31 +21,31 @@ @implementation ARDSDPUtilsTest - (void)testPreferVideoCodecH264 { - NSString *sdp = @("m=video 9 RTP/SAVPF 100 116 117 96 120 97\n" - "a=rtpmap:120 H264/90000\n" - "a=rtpmap:97 H264/90000\n"); - NSString *expectedSdp = @("m=video 9 RTP/SAVPF 120 97 100 116 117 96\n" - "a=rtpmap:120 H264/90000\n" - "a=rtpmap:97 H264/90000\n"); + NSString *sdp = @("m=video 9 RTP/SAVPF 100 116 117 96 120 97\r\n" + "a=rtpmap:120 H264/90000\r\n" + "a=rtpmap:97 H264/90000\r\n"); + NSString *expectedSdp = @("m=video 9 RTP/SAVPF 120 97 100 116 117 96\r\n" + "a=rtpmap:120 H264/90000\r\n" + "a=rtpmap:97 H264/90000\r\n"); [self preferVideoCodec:@"H264" sdp:sdp expected:expectedSdp]; } - (void)testPreferVideoCodecVP8 { - NSString *sdp = @("m=video 9 RTP/SAVPF 100 116 117 96 120 97\n" - "a=rtpmap:116 VP8/90000\n"); - NSString *expectedSdp = @("m=video 9 RTP/SAVPF 116 100 117 96 120 97\n" - "a=rtpmap:116 VP8/90000\n"); + NSString *sdp = @("m=video 9 RTP/SAVPF 100 116 117 96 120 97\r\n" + "a=rtpmap:116 VP8/90000\r\n"); + NSString *expectedSdp = @("m=video 9 RTP/SAVPF 116 100 117 96 120 97\r\n" + "a=rtpmap:116 VP8/90000\r\n"); [self preferVideoCodec:@"VP8" sdp:sdp expected:expectedSdp]; } - (void)testNoMLine { - NSString *sdp = @("a=rtpmap:116 VP8/90000\n"); + NSString *sdp = @("a=rtpmap:116 VP8/90000\r\n"); [self preferVideoCodec:@"VP8" sdp:sdp expected:sdp]; } - (void)testMissingCodec { - NSString *sdp = @("m=video 9 RTP/SAVPF 100 116 117 96 120 97\n" - "a=rtpmap:116 VP8/90000\n"); + NSString *sdp = @("m=video 9 RTP/SAVPF 100 116 117 96 120 97\r\n" + "a=rtpmap:116 VP8/90000\r\n"); [self preferVideoCodec:@"foo" sdp:sdp expected:sdp]; }