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