1*d9f75844SAndroid Build Coastguard Worker/* 2*d9f75844SAndroid Build Coastguard Worker * Copyright 2015 The WebRTC project authors. All Rights Reserved. 3*d9f75844SAndroid Build Coastguard Worker * 4*d9f75844SAndroid Build Coastguard Worker * Use of this source code is governed by a BSD-style license 5*d9f75844SAndroid Build Coastguard Worker * that can be found in the LICENSE file in the root of the source 6*d9f75844SAndroid Build Coastguard Worker * tree. An additional intellectual property rights grant can be found 7*d9f75844SAndroid Build Coastguard Worker * in the file PATENTS. All contributing project authors may 8*d9f75844SAndroid Build Coastguard Worker * be found in the AUTHORS file in the root of the source tree. 9*d9f75844SAndroid Build Coastguard Worker */ 10*d9f75844SAndroid Build Coastguard Worker 11*d9f75844SAndroid Build Coastguard Worker#import <Foundation/Foundation.h> 12*d9f75844SAndroid Build Coastguard Worker#import <XCTest/XCTest.h> 13*d9f75844SAndroid Build Coastguard Worker 14*d9f75844SAndroid Build Coastguard Worker#include "rtc_base/gunit.h" 15*d9f75844SAndroid Build Coastguard Worker 16*d9f75844SAndroid Build Coastguard Worker#import "api/peerconnection/RTCSessionDescription+Private.h" 17*d9f75844SAndroid Build Coastguard Worker#import "api/peerconnection/RTCSessionDescription.h" 18*d9f75844SAndroid Build Coastguard Worker#import "helpers/NSString+StdString.h" 19*d9f75844SAndroid Build Coastguard Worker 20*d9f75844SAndroid Build Coastguard Worker@interface RTCSessionDescriptionTests : XCTestCase 21*d9f75844SAndroid Build Coastguard Worker@end 22*d9f75844SAndroid Build Coastguard Worker 23*d9f75844SAndroid Build Coastguard Worker@implementation RTCSessionDescriptionTests 24*d9f75844SAndroid Build Coastguard Worker 25*d9f75844SAndroid Build Coastguard Worker/** 26*d9f75844SAndroid Build Coastguard Worker * Test conversion of an Objective-C RTC_OBJC_TYPE(RTCSessionDescription) to a native 27*d9f75844SAndroid Build Coastguard Worker * SessionDescriptionInterface (based on the types and SDP strings being equal). 28*d9f75844SAndroid Build Coastguard Worker */ 29*d9f75844SAndroid Build Coastguard Worker- (void)testSessionDescriptionConversion { 30*d9f75844SAndroid Build Coastguard Worker RTC_OBJC_TYPE(RTCSessionDescription) *description = 31*d9f75844SAndroid Build Coastguard Worker [[RTC_OBJC_TYPE(RTCSessionDescription) alloc] initWithType:RTCSdpTypeAnswer sdp:[self sdp]]; 32*d9f75844SAndroid Build Coastguard Worker 33*d9f75844SAndroid Build Coastguard Worker std::unique_ptr<webrtc::SessionDescriptionInterface> nativeDescription = 34*d9f75844SAndroid Build Coastguard Worker description.nativeDescription; 35*d9f75844SAndroid Build Coastguard Worker 36*d9f75844SAndroid Build Coastguard Worker EXPECT_EQ(RTCSdpTypeAnswer, 37*d9f75844SAndroid Build Coastguard Worker [RTC_OBJC_TYPE(RTCSessionDescription) typeForStdString:nativeDescription->type()]); 38*d9f75844SAndroid Build Coastguard Worker 39*d9f75844SAndroid Build Coastguard Worker std::string sdp; 40*d9f75844SAndroid Build Coastguard Worker nativeDescription->ToString(&sdp); 41*d9f75844SAndroid Build Coastguard Worker EXPECT_EQ([self sdp].stdString, sdp); 42*d9f75844SAndroid Build Coastguard Worker} 43*d9f75844SAndroid Build Coastguard Worker 44*d9f75844SAndroid Build Coastguard Worker- (void)testInitFromNativeSessionDescription { 45*d9f75844SAndroid Build Coastguard Worker webrtc::SessionDescriptionInterface *nativeDescription; 46*d9f75844SAndroid Build Coastguard Worker 47*d9f75844SAndroid Build Coastguard Worker nativeDescription = webrtc::CreateSessionDescription( 48*d9f75844SAndroid Build Coastguard Worker webrtc::SessionDescriptionInterface::kAnswer, 49*d9f75844SAndroid Build Coastguard Worker [self sdp].stdString, 50*d9f75844SAndroid Build Coastguard Worker nullptr); 51*d9f75844SAndroid Build Coastguard Worker 52*d9f75844SAndroid Build Coastguard Worker RTC_OBJC_TYPE(RTCSessionDescription) *description = 53*d9f75844SAndroid Build Coastguard Worker [[RTC_OBJC_TYPE(RTCSessionDescription) alloc] initWithNativeDescription:nativeDescription]; 54*d9f75844SAndroid Build Coastguard Worker EXPECT_EQ(webrtc::SessionDescriptionInterface::kAnswer, 55*d9f75844SAndroid Build Coastguard Worker [RTC_OBJC_TYPE(RTCSessionDescription) stdStringForType:description.type]); 56*d9f75844SAndroid Build Coastguard Worker EXPECT_TRUE([[self sdp] isEqualToString:description.sdp]); 57*d9f75844SAndroid Build Coastguard Worker} 58*d9f75844SAndroid Build Coastguard Worker 59*d9f75844SAndroid Build Coastguard Worker- (NSString *)sdp { 60*d9f75844SAndroid Build Coastguard Worker return @"v=0\r\n" 61*d9f75844SAndroid Build Coastguard Worker "o=- 5319989746393411314 2 IN IP4 127.0.0.1\r\n" 62*d9f75844SAndroid Build Coastguard Worker "s=-\r\n" 63*d9f75844SAndroid Build Coastguard Worker "t=0 0\r\n" 64*d9f75844SAndroid Build Coastguard Worker "a=group:BUNDLE audio video\r\n" 65*d9f75844SAndroid Build Coastguard Worker "a=msid-semantic: WMS ARDAMS\r\n" 66*d9f75844SAndroid Build Coastguard Worker "m=audio 9 UDP/TLS/RTP/SAVPF 111 103 9 0 8 126\r\n" 67*d9f75844SAndroid Build Coastguard Worker "c=IN IP4 0.0.0.0\r\n" 68*d9f75844SAndroid Build Coastguard Worker "a=rtcp:9 IN IP4 0.0.0.0\r\n" 69*d9f75844SAndroid Build Coastguard Worker "a=ice-ufrag:f3o+0HG7l9nwIWFY\r\n" 70*d9f75844SAndroid Build Coastguard Worker "a=ice-pwd:VDctmJNCptR2TB7+meDpw7w5\r\n" 71*d9f75844SAndroid Build Coastguard Worker "a=fingerprint:sha-256 A9:D5:8D:A8:69:22:39:60:92:AD:94:1A:22:2D:5E:" 72*d9f75844SAndroid Build Coastguard Worker "A5:4A:A9:18:C2:35:5D:46:5E:59:BD:1C:AF:38:9F:E6:E1\r\n" 73*d9f75844SAndroid Build Coastguard Worker "a=setup:active\r\n" 74*d9f75844SAndroid Build Coastguard Worker "a=mid:audio\r\n" 75*d9f75844SAndroid Build Coastguard Worker "a=extmap:1 urn:ietf:params:rtp-hdrext:ssrc-audio-level\r\n" 76*d9f75844SAndroid Build Coastguard Worker "a=extmap:3 http://www.webrtc.org/experiments/rtp-hdrext/" 77*d9f75844SAndroid Build Coastguard Worker "abs-send-time\r\n" 78*d9f75844SAndroid Build Coastguard Worker "a=sendrecv\r\n" 79*d9f75844SAndroid Build Coastguard Worker "a=rtcp-mux\r\n" 80*d9f75844SAndroid Build Coastguard Worker "a=rtpmap:111 opus/48000/2\r\n" 81*d9f75844SAndroid Build Coastguard Worker "a=fmtp:111 minptime=10;useinbandfec=1\r\n" 82*d9f75844SAndroid Build Coastguard Worker "a=rtpmap:103 ISAC/16000\r\n" 83*d9f75844SAndroid Build Coastguard Worker "a=rtpmap:9 G722/8000\r\n" 84*d9f75844SAndroid Build Coastguard Worker "a=rtpmap:0 PCMU/8000\r\n" 85*d9f75844SAndroid Build Coastguard Worker "a=rtpmap:8 PCMA/8000\r\n" 86*d9f75844SAndroid Build Coastguard Worker "a=rtpmap:126 telephone-event/8000\r\n" 87*d9f75844SAndroid Build Coastguard Worker "a=maxptime:60\r\n" 88*d9f75844SAndroid Build Coastguard Worker "a=ssrc:1504474588 cname:V+FdIC5AJpxLhdYQ\r\n" 89*d9f75844SAndroid Build Coastguard Worker "a=ssrc:1504474588 msid:ARDAMS ARDAMSa0\r\n" 90*d9f75844SAndroid Build Coastguard Worker "m=video 9 UDP/TLS/RTP/SAVPF 100 116 117 96\r\n" 91*d9f75844SAndroid Build Coastguard Worker "c=IN IP4 0.0.0.0\r\n" 92*d9f75844SAndroid Build Coastguard Worker "a=rtcp:9 IN IP4 0.0.0.0\r\n" 93*d9f75844SAndroid Build Coastguard Worker "a=ice-ufrag:f3o+0HG7l9nwIWFY\r\n" 94*d9f75844SAndroid Build Coastguard Worker "a=ice-pwd:VDctmJNCptR2TB7+meDpw7w5\r\n" 95*d9f75844SAndroid Build Coastguard Worker "a=fingerprint:sha-256 A9:D5:8D:A8:69:22:39:60:92:AD:94:1A:22:2D:5E:" 96*d9f75844SAndroid Build Coastguard Worker "A5:4A:A9:18:C2:35:5D:46:5E:59:BD:1C:AF:38:9F:E6:E1\r\n" 97*d9f75844SAndroid Build Coastguard Worker "a=setup:active\r\n" 98*d9f75844SAndroid Build Coastguard Worker "a=mid:video\r\n" 99*d9f75844SAndroid Build Coastguard Worker "a=extmap:2 urn:ietf:params:rtp-hdrext:toffset\r\n" 100*d9f75844SAndroid Build Coastguard Worker "a=extmap:3 http://www.webrtc.org/experiments/rtp-hdrext/" 101*d9f75844SAndroid Build Coastguard Worker "abs-send-time\r\n" 102*d9f75844SAndroid Build Coastguard Worker "a=extmap:4 urn:3gpp:video-orientation\r\n" 103*d9f75844SAndroid Build Coastguard Worker "a=sendrecv\r\n" 104*d9f75844SAndroid Build Coastguard Worker "a=rtcp-mux\r\n" 105*d9f75844SAndroid Build Coastguard Worker "a=rtpmap:100 VP8/90000\r\n" 106*d9f75844SAndroid Build Coastguard Worker "a=rtcp-fb:100 ccm fir\r\n" 107*d9f75844SAndroid Build Coastguard Worker "a=rtcp-fb:100 goog-lntf\r\n" 108*d9f75844SAndroid Build Coastguard Worker "a=rtcp-fb:100 nack\r\n" 109*d9f75844SAndroid Build Coastguard Worker "a=rtcp-fb:100 nack pli\r\n" 110*d9f75844SAndroid Build Coastguard Worker "a=rtcp-fb:100 goog-remb\r\n" 111*d9f75844SAndroid Build Coastguard Worker "a=rtpmap:116 red/90000\r\n" 112*d9f75844SAndroid Build Coastguard Worker "a=rtpmap:117 ulpfec/90000\r\n" 113*d9f75844SAndroid Build Coastguard Worker "a=rtpmap:96 rtx/90000\r\n" 114*d9f75844SAndroid Build Coastguard Worker "a=fmtp:96 apt=100\r\n" 115*d9f75844SAndroid Build Coastguard Worker "a=ssrc-group:FID 498297514 1644357692\r\n" 116*d9f75844SAndroid Build Coastguard Worker "a=ssrc:498297514 cname:V+FdIC5AJpxLhdYQ\r\n" 117*d9f75844SAndroid Build Coastguard Worker "a=ssrc:498297514 msid:ARDAMS ARDAMSv0\r\n" 118*d9f75844SAndroid Build Coastguard Worker "a=ssrc:1644357692 cname:V+FdIC5AJpxLhdYQ\r\n" 119*d9f75844SAndroid Build Coastguard Worker "a=ssrc:1644357692 msid:ARDAMS ARDAMSv0\r\n"; 120*d9f75844SAndroid Build Coastguard Worker} 121*d9f75844SAndroid Build Coastguard Worker 122*d9f75844SAndroid Build Coastguard Worker@end 123