Files
platform-external-webrtc/webrtc/examples/objc/AppRTCMobile/tests/ARDSDPUtils_xctest.mm
kthelgason 6644c8b733 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}
2017-08-28 07:48:18 +00:00

65 lines
2.2 KiB
Plaintext

/*
* Copyright 2017 The WebRTC Project Authors. All rights reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
#import <Foundation/Foundation.h>
#import <XCTest/XCTest.h>
#import "WebRTC/RTCSessionDescription.h"
#import "ARDSDPUtils.h"
@interface ARDSDPUtilsTest : XCTestCase
@end
@implementation ARDSDPUtilsTest
- (void)testPreferVideoCodecH264 {
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\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\r\n");
[self preferVideoCodec:@"VP8" sdp:sdp expected:sdp];
}
- (void)testMissingCodec {
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];
}
#pragma mark - Helpers
- (void)preferVideoCodec:(NSString *)codec
sdp:(NSString *)sdp
expected:(NSString *)expectedSdp{
RTCSessionDescription* desc =
[[RTCSessionDescription alloc] initWithType:RTCSdpTypeOffer sdp:sdp];
RTCSessionDescription *outputDesc =
[ARDSDPUtils descriptionForDescription:desc
preferredVideoCodec:codec];
XCTAssertTrue([outputDesc.description rangeOfString:expectedSdp].location != NSNotFound);
}
@end