Jon Hjelle | 67e83d6 | 2016-01-06 12:05:22 -0800 | [diff] [blame] | 1 | /* |
kjellander | b24317b | 2016-02-10 07:54:43 -0800 | [diff] [blame] | 2 | * Copyright 2015 The WebRTC project authors. All Rights Reserved. |
Jon Hjelle | 67e83d6 | 2016-01-06 12:05:22 -0800 | [diff] [blame] | 3 | * |
kjellander | b24317b | 2016-02-10 07:54:43 -0800 | [diff] [blame] | 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. |
Jon Hjelle | 67e83d6 | 2016-01-06 12:05:22 -0800 | [diff] [blame] | 9 | */ |
| 10 | |
| 11 | #import <Foundation/Foundation.h> |
Byoungchan Lee | c8a6fb2 | 2022-05-13 19:59:49 +0900 | [diff] [blame] | 12 | #import <XCTest/XCTest.h> |
Jon Hjelle | 67e83d6 | 2016-01-06 12:05:22 -0800 | [diff] [blame] | 13 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 14 | #include "rtc_base/gunit.h" |
Jon Hjelle | 67e83d6 | 2016-01-06 12:05:22 -0800 | [diff] [blame] | 15 | |
Anders Carlsson | 7bca8ca | 2018-08-30 09:30:29 +0200 | [diff] [blame] | 16 | #import "api/peerconnection/RTCSessionDescription+Private.h" |
| 17 | #import "api/peerconnection/RTCSessionDescription.h" |
Artem Titov | 63ee39d | 2022-05-13 14:46:42 +0000 | [diff] [blame] | 18 | #import "helpers/NSString+StdString.h" |
Jon Hjelle | 67e83d6 | 2016-01-06 12:05:22 -0800 | [diff] [blame] | 19 | |
Byoungchan Lee | c8a6fb2 | 2022-05-13 19:59:49 +0900 | [diff] [blame] | 20 | @interface RTCSessionDescriptionTests : XCTestCase |
Jon Hjelle | 67e83d6 | 2016-01-06 12:05:22 -0800 | [diff] [blame] | 21 | @end |
| 22 | |
Byoungchan Lee | c8a6fb2 | 2022-05-13 19:59:49 +0900 | [diff] [blame] | 23 | @implementation RTCSessionDescriptionTests |
Jon Hjelle | 67e83d6 | 2016-01-06 12:05:22 -0800 | [diff] [blame] | 24 | |
| 25 | /** |
Mirko Bonadei | a81e9c8 | 2020-05-04 16:14:32 +0200 | [diff] [blame] | 26 | * Test conversion of an Objective-C RTC_OBJC_TYPE(RTCSessionDescription) to a native |
Jon Hjelle | 67e83d6 | 2016-01-06 12:05:22 -0800 | [diff] [blame] | 27 | * SessionDescriptionInterface (based on the types and SDP strings being equal). |
| 28 | */ |
| 29 | - (void)testSessionDescriptionConversion { |
Mirko Bonadei | a81e9c8 | 2020-05-04 16:14:32 +0200 | [diff] [blame] | 30 | RTC_OBJC_TYPE(RTCSessionDescription) *description = |
| 31 | [[RTC_OBJC_TYPE(RTCSessionDescription) alloc] initWithType:RTCSdpTypeAnswer sdp:[self sdp]]; |
Jon Hjelle | 67e83d6 | 2016-01-06 12:05:22 -0800 | [diff] [blame] | 32 | |
Byoungchan Lee | 3372815 | 2021-08-04 20:54:45 +0900 | [diff] [blame] | 33 | std::unique_ptr<webrtc::SessionDescriptionInterface> nativeDescription = |
Jon Hjelle | 67e83d6 | 2016-01-06 12:05:22 -0800 | [diff] [blame] | 34 | description.nativeDescription; |
| 35 | |
| 36 | EXPECT_EQ(RTCSdpTypeAnswer, |
Mirko Bonadei | a81e9c8 | 2020-05-04 16:14:32 +0200 | [diff] [blame] | 37 | [RTC_OBJC_TYPE(RTCSessionDescription) typeForStdString:nativeDescription->type()]); |
Jon Hjelle | 67e83d6 | 2016-01-06 12:05:22 -0800 | [diff] [blame] | 38 | |
| 39 | std::string sdp; |
| 40 | nativeDescription->ToString(&sdp); |
| 41 | EXPECT_EQ([self sdp].stdString, sdp); |
| 42 | } |
| 43 | |
| 44 | - (void)testInitFromNativeSessionDescription { |
| 45 | webrtc::SessionDescriptionInterface *nativeDescription; |
| 46 | |
| 47 | nativeDescription = webrtc::CreateSessionDescription( |
| 48 | webrtc::SessionDescriptionInterface::kAnswer, |
| 49 | [self sdp].stdString, |
| 50 | nullptr); |
| 51 | |
Mirko Bonadei | a81e9c8 | 2020-05-04 16:14:32 +0200 | [diff] [blame] | 52 | RTC_OBJC_TYPE(RTCSessionDescription) *description = |
| 53 | [[RTC_OBJC_TYPE(RTCSessionDescription) alloc] initWithNativeDescription:nativeDescription]; |
Jon Hjelle | 67e83d6 | 2016-01-06 12:05:22 -0800 | [diff] [blame] | 54 | EXPECT_EQ(webrtc::SessionDescriptionInterface::kAnswer, |
Mirko Bonadei | a81e9c8 | 2020-05-04 16:14:32 +0200 | [diff] [blame] | 55 | [RTC_OBJC_TYPE(RTCSessionDescription) stdStringForType:description.type]); |
Jon Hjelle | 67e83d6 | 2016-01-06 12:05:22 -0800 | [diff] [blame] | 56 | EXPECT_TRUE([[self sdp] isEqualToString:description.sdp]); |
| 57 | } |
| 58 | |
| 59 | - (NSString *)sdp { |
Elad Alon | fadb181 | 2019-05-24 13:40:02 +0200 | [diff] [blame] | 60 | return @"v=0\r\n" |
| 61 | "o=- 5319989746393411314 2 IN IP4 127.0.0.1\r\n" |
| 62 | "s=-\r\n" |
| 63 | "t=0 0\r\n" |
| 64 | "a=group:BUNDLE audio video\r\n" |
| 65 | "a=msid-semantic: WMS ARDAMS\r\n" |
| 66 | "m=audio 9 UDP/TLS/RTP/SAVPF 111 103 9 0 8 126\r\n" |
| 67 | "c=IN IP4 0.0.0.0\r\n" |
| 68 | "a=rtcp:9 IN IP4 0.0.0.0\r\n" |
| 69 | "a=ice-ufrag:f3o+0HG7l9nwIWFY\r\n" |
| 70 | "a=ice-pwd:VDctmJNCptR2TB7+meDpw7w5\r\n" |
| 71 | "a=fingerprint:sha-256 A9:D5:8D:A8:69:22:39:60:92:AD:94:1A:22:2D:5E:" |
| 72 | "A5:4A:A9:18:C2:35:5D:46:5E:59:BD:1C:AF:38:9F:E6:E1\r\n" |
| 73 | "a=setup:active\r\n" |
| 74 | "a=mid:audio\r\n" |
| 75 | "a=extmap:1 urn:ietf:params:rtp-hdrext:ssrc-audio-level\r\n" |
| 76 | "a=extmap:3 http://www.webrtc.org/experiments/rtp-hdrext/" |
| 77 | "abs-send-time\r\n" |
| 78 | "a=sendrecv\r\n" |
| 79 | "a=rtcp-mux\r\n" |
| 80 | "a=rtpmap:111 opus/48000/2\r\n" |
| 81 | "a=fmtp:111 minptime=10;useinbandfec=1\r\n" |
| 82 | "a=rtpmap:103 ISAC/16000\r\n" |
| 83 | "a=rtpmap:9 G722/8000\r\n" |
| 84 | "a=rtpmap:0 PCMU/8000\r\n" |
| 85 | "a=rtpmap:8 PCMA/8000\r\n" |
| 86 | "a=rtpmap:126 telephone-event/8000\r\n" |
| 87 | "a=maxptime:60\r\n" |
| 88 | "a=ssrc:1504474588 cname:V+FdIC5AJpxLhdYQ\r\n" |
| 89 | "a=ssrc:1504474588 msid:ARDAMS ARDAMSa0\r\n" |
Elad Alon | fadb181 | 2019-05-24 13:40:02 +0200 | [diff] [blame] | 90 | "m=video 9 UDP/TLS/RTP/SAVPF 100 116 117 96\r\n" |
| 91 | "c=IN IP4 0.0.0.0\r\n" |
| 92 | "a=rtcp:9 IN IP4 0.0.0.0\r\n" |
| 93 | "a=ice-ufrag:f3o+0HG7l9nwIWFY\r\n" |
| 94 | "a=ice-pwd:VDctmJNCptR2TB7+meDpw7w5\r\n" |
| 95 | "a=fingerprint:sha-256 A9:D5:8D:A8:69:22:39:60:92:AD:94:1A:22:2D:5E:" |
| 96 | "A5:4A:A9:18:C2:35:5D:46:5E:59:BD:1C:AF:38:9F:E6:E1\r\n" |
| 97 | "a=setup:active\r\n" |
| 98 | "a=mid:video\r\n" |
| 99 | "a=extmap:2 urn:ietf:params:rtp-hdrext:toffset\r\n" |
| 100 | "a=extmap:3 http://www.webrtc.org/experiments/rtp-hdrext/" |
| 101 | "abs-send-time\r\n" |
| 102 | "a=extmap:4 urn:3gpp:video-orientation\r\n" |
| 103 | "a=sendrecv\r\n" |
| 104 | "a=rtcp-mux\r\n" |
| 105 | "a=rtpmap:100 VP8/90000\r\n" |
| 106 | "a=rtcp-fb:100 ccm fir\r\n" |
| 107 | "a=rtcp-fb:100 goog-lntf\r\n" |
| 108 | "a=rtcp-fb:100 nack\r\n" |
| 109 | "a=rtcp-fb:100 nack pli\r\n" |
| 110 | "a=rtcp-fb:100 goog-remb\r\n" |
| 111 | "a=rtpmap:116 red/90000\r\n" |
| 112 | "a=rtpmap:117 ulpfec/90000\r\n" |
| 113 | "a=rtpmap:96 rtx/90000\r\n" |
| 114 | "a=fmtp:96 apt=100\r\n" |
| 115 | "a=ssrc-group:FID 498297514 1644357692\r\n" |
| 116 | "a=ssrc:498297514 cname:V+FdIC5AJpxLhdYQ\r\n" |
| 117 | "a=ssrc:498297514 msid:ARDAMS ARDAMSv0\r\n" |
Elad Alon | fadb181 | 2019-05-24 13:40:02 +0200 | [diff] [blame] | 118 | "a=ssrc:1644357692 cname:V+FdIC5AJpxLhdYQ\r\n" |
Harald Alvestrand | 88b8dec | 2022-04-07 09:54:51 +0000 | [diff] [blame] | 119 | "a=ssrc:1644357692 msid:ARDAMS ARDAMSv0\r\n"; |
Jon Hjelle | 67e83d6 | 2016-01-06 12:05:22 -0800 | [diff] [blame] | 120 | } |
| 121 | |
| 122 | @end |