OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2017 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2017 The WebRTC Project Authors. All rights reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
11 #import <Foundation/Foundation.h> | 11 #import <Foundation/Foundation.h> |
12 #import <XCTest/XCTest.h> | 12 #import <XCTest/XCTest.h> |
13 | 13 |
14 #import "WebRTC/RTCSessionDescription.h" | 14 #import "WebRTC/RTCSessionDescription.h" |
15 | 15 |
16 #import "ARDSDPUtils.h" | 16 #import "ARDSDPUtils.h" |
17 | 17 |
18 @interface ARDSDPUtilsTest : XCTestCase | 18 @interface ARDSDPUtilsTest : XCTestCase |
19 @end | 19 @end |
20 | 20 |
21 @implementation ARDSDPUtilsTest | 21 @implementation ARDSDPUtilsTest |
22 | 22 |
23 - (void)testPreferVideoCodecH264 { | 23 - (void)testPreferVideoCodecH264 { |
24 NSString *sdp = @("m=video 9 RTP/SAVPF 100 116 117 96 120 97\n" | 24 NSString *sdp = @("m=video 9 RTP/SAVPF 100 116 117 96 120 97\r\n" |
25 "a=rtpmap:120 H264/90000\n" | 25 "a=rtpmap:120 H264/90000\r\n" |
26 "a=rtpmap:97 H264/90000\n"); | 26 "a=rtpmap:97 H264/90000\r\n"); |
27 NSString *expectedSdp = @("m=video 9 RTP/SAVPF 120 97 100 116 117 96\n" | 27 NSString *expectedSdp = @("m=video 9 RTP/SAVPF 120 97 100 116 117 96\r\n" |
28 "a=rtpmap:120 H264/90000\n" | 28 "a=rtpmap:120 H264/90000\r\n" |
29 "a=rtpmap:97 H264/90000\n"); | 29 "a=rtpmap:97 H264/90000\r\n"); |
30 [self preferVideoCodec:@"H264" sdp:sdp expected:expectedSdp]; | 30 [self preferVideoCodec:@"H264" sdp:sdp expected:expectedSdp]; |
31 } | 31 } |
32 | 32 |
33 - (void)testPreferVideoCodecVP8 { | 33 - (void)testPreferVideoCodecVP8 { |
34 NSString *sdp = @("m=video 9 RTP/SAVPF 100 116 117 96 120 97\n" | 34 NSString *sdp = @("m=video 9 RTP/SAVPF 100 116 117 96 120 97\r\n" |
35 "a=rtpmap:116 VP8/90000\n"); | 35 "a=rtpmap:116 VP8/90000\r\n"); |
36 NSString *expectedSdp = @("m=video 9 RTP/SAVPF 116 100 117 96 120 97\n" | 36 NSString *expectedSdp = @("m=video 9 RTP/SAVPF 116 100 117 96 120 97\r\n" |
37 "a=rtpmap:116 VP8/90000\n"); | 37 "a=rtpmap:116 VP8/90000\r\n"); |
38 [self preferVideoCodec:@"VP8" sdp:sdp expected:expectedSdp]; | 38 [self preferVideoCodec:@"VP8" sdp:sdp expected:expectedSdp]; |
39 } | 39 } |
40 | 40 |
41 - (void)testNoMLine { | 41 - (void)testNoMLine { |
42 NSString *sdp = @("a=rtpmap:116 VP8/90000\n"); | 42 NSString *sdp = @("a=rtpmap:116 VP8/90000\r\n"); |
43 [self preferVideoCodec:@"VP8" sdp:sdp expected:sdp]; | 43 [self preferVideoCodec:@"VP8" sdp:sdp expected:sdp]; |
44 } | 44 } |
45 | 45 |
46 - (void)testMissingCodec { | 46 - (void)testMissingCodec { |
47 NSString *sdp = @("m=video 9 RTP/SAVPF 100 116 117 96 120 97\n" | 47 NSString *sdp = @("m=video 9 RTP/SAVPF 100 116 117 96 120 97\r\n" |
48 "a=rtpmap:116 VP8/90000\n"); | 48 "a=rtpmap:116 VP8/90000\r\n"); |
49 [self preferVideoCodec:@"foo" sdp:sdp expected:sdp]; | 49 [self preferVideoCodec:@"foo" sdp:sdp expected:sdp]; |
50 } | 50 } |
51 | 51 |
52 #pragma mark - Helpers | 52 #pragma mark - Helpers |
53 | 53 |
54 - (void)preferVideoCodec:(NSString *)codec | 54 - (void)preferVideoCodec:(NSString *)codec |
55 sdp:(NSString *)sdp | 55 sdp:(NSString *)sdp |
56 expected:(NSString *)expectedSdp{ | 56 expected:(NSString *)expectedSdp{ |
57 RTCSessionDescription* desc = | 57 RTCSessionDescription* desc = |
58 [[RTCSessionDescription alloc] initWithType:RTCSdpTypeOffer sdp:sdp]; | 58 [[RTCSessionDescription alloc] initWithType:RTCSdpTypeOffer sdp:sdp]; |
59 RTCSessionDescription *outputDesc = | 59 RTCSessionDescription *outputDesc = |
60 [ARDSDPUtils descriptionForDescription:desc | 60 [ARDSDPUtils descriptionForDescription:desc |
61 preferredVideoCodec:codec]; | 61 preferredVideoCodec:codec]; |
62 XCTAssertTrue([outputDesc.description rangeOfString:expectedSdp].location != N
SNotFound); | 62 XCTAssertTrue([outputDesc.description rangeOfString:expectedSdp].location != N
SNotFound); |
63 } | 63 } |
64 @end | 64 @end |
OLD | NEW |