Jon Hjelle | 67e83d6 | 2016-01-06 12:05:22 -0800 | [diff] [blame] | 1 | /* |
Henrik Kjellander | 15583c1 | 2016-02-10 10:53:12 +0100 | [diff] [blame] | 2 | * libjingle |
| 3 | * Copyright 2015 Google Inc. |
Jon Hjelle | 67e83d6 | 2016-01-06 12:05:22 -0800 | [diff] [blame] | 4 | * |
Henrik Kjellander | 15583c1 | 2016-02-10 10:53:12 +0100 | [diff] [blame] | 5 | * Redistribution and use in source and binary forms, with or without |
| 6 | * modification, are permitted provided that the following conditions are met: |
| 7 | * |
| 8 | * 1. Redistributions of source code must retain the above copyright notice, |
| 9 | * this list of conditions and the following disclaimer. |
| 10 | * 2. Redistributions in binary form must reproduce the above copyright notice, |
| 11 | * this list of conditions and the following disclaimer in the documentation |
| 12 | * and/or other materials provided with the distribution. |
| 13 | * 3. The name of the author may not be used to endorse or promote products |
| 14 | * derived from this software without specific prior written permission. |
| 15 | * |
| 16 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED |
| 17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF |
| 18 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO |
| 19 | * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 20 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
| 21 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; |
| 22 | * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, |
| 23 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR |
| 24 | * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF |
| 25 | * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
Jon Hjelle | 67e83d6 | 2016-01-06 12:05:22 -0800 | [diff] [blame] | 26 | */ |
| 27 | |
| 28 | #import <Foundation/Foundation.h> |
| 29 | |
| 30 | #include "webrtc/base/gunit.h" |
| 31 | |
| 32 | #import "webrtc/api/objc/RTCSessionDescription.h" |
| 33 | #import "webrtc/api/objc/RTCSessionDescription+Private.h" |
| 34 | #import "webrtc/base/objc/NSString+StdString.h" |
| 35 | |
| 36 | @interface RTCSessionDescriptionTest : NSObject |
| 37 | - (void)testSessionDescriptionConversion; |
| 38 | - (void)testInitFromNativeSessionDescription; |
| 39 | @end |
| 40 | |
| 41 | @implementation RTCSessionDescriptionTest |
| 42 | |
| 43 | /** |
| 44 | * Test conversion of an Objective-C RTCSessionDescription to a native |
| 45 | * SessionDescriptionInterface (based on the types and SDP strings being equal). |
| 46 | */ |
| 47 | - (void)testSessionDescriptionConversion { |
| 48 | RTCSessionDescription *description = |
| 49 | [[RTCSessionDescription alloc] initWithType:RTCSdpTypeAnswer |
| 50 | sdp:[self sdp]]; |
| 51 | |
| 52 | webrtc::SessionDescriptionInterface *nativeDescription = |
| 53 | description.nativeDescription; |
| 54 | |
| 55 | EXPECT_EQ(RTCSdpTypeAnswer, |
| 56 | [RTCSessionDescription typeForString:nativeDescription->type()]); |
| 57 | |
| 58 | std::string sdp; |
| 59 | nativeDescription->ToString(&sdp); |
| 60 | EXPECT_EQ([self sdp].stdString, sdp); |
| 61 | } |
| 62 | |
| 63 | - (void)testInitFromNativeSessionDescription { |
| 64 | webrtc::SessionDescriptionInterface *nativeDescription; |
| 65 | |
| 66 | nativeDescription = webrtc::CreateSessionDescription( |
| 67 | webrtc::SessionDescriptionInterface::kAnswer, |
| 68 | [self sdp].stdString, |
| 69 | nullptr); |
| 70 | |
| 71 | RTCSessionDescription *description = |
| 72 | [[RTCSessionDescription alloc] initWithNativeDescription: |
| 73 | nativeDescription]; |
| 74 | EXPECT_EQ(webrtc::SessionDescriptionInterface::kAnswer, |
| 75 | [RTCSessionDescription stringForType:description.type]); |
| 76 | EXPECT_TRUE([[self sdp] isEqualToString:description.sdp]); |
| 77 | } |
| 78 | |
| 79 | - (NSString *)sdp { |
| 80 | return @"v=0\r\n" |
| 81 | "o=- 5319989746393411314 2 IN IP4 127.0.0.1\r\n" |
| 82 | "s=-\r\n" |
| 83 | "t=0 0\r\n" |
| 84 | "a=group:BUNDLE audio video\r\n" |
| 85 | "a=msid-semantic: WMS ARDAMS\r\n" |
| 86 | "m=audio 9 UDP/TLS/RTP/SAVPF 111 103 9 0 8 126\r\n" |
| 87 | "c=IN IP4 0.0.0.0\r\n" |
| 88 | "a=rtcp:9 IN IP4 0.0.0.0\r\n" |
| 89 | "a=ice-ufrag:f3o+0HG7l9nwIWFY\r\n" |
| 90 | "a=ice-pwd:VDctmJNCptR2TB7+meDpw7w5\r\n" |
| 91 | "a=fingerprint:sha-256 A9:D5:8D:A8:69:22:39:60:92:AD:94:1A:22:2D:5E:" |
| 92 | "A5:4A:A9:18:C2:35:5D:46:5E:59:BD:1C:AF:38:9F:E6:E1\r\n" |
| 93 | "a=setup:active\r\n" |
| 94 | "a=mid:audio\r\n" |
| 95 | "a=extmap:1 urn:ietf:params:rtp-hdrext:ssrc-audio-level\r\n" |
| 96 | "a=extmap:3 http://www.webrtc.org/experiments/rtp-hdrext/" |
| 97 | "abs-send-time\r\n" |
| 98 | "a=sendrecv\r\n" |
| 99 | "a=rtcp-mux\r\n" |
| 100 | "a=rtpmap:111 opus/48000/2\r\n" |
| 101 | "a=fmtp:111 minptime=10; useinbandfec=1\r\n" |
| 102 | "a=rtpmap:103 ISAC/16000\r\n" |
| 103 | "a=rtpmap:9 G722/8000\r\n" |
| 104 | "a=rtpmap:0 PCMU/8000\r\n" |
| 105 | "a=rtpmap:8 PCMA/8000\r\n" |
| 106 | "a=rtpmap:126 telephone-event/8000\r\n" |
| 107 | "a=maxptime:60\r\n" |
| 108 | "a=ssrc:1504474588 cname:V+FdIC5AJpxLhdYQ\r\n" |
| 109 | "a=ssrc:1504474588 msid:ARDAMS ARDAMSa0\r\n" |
| 110 | "a=ssrc:1504474588 mslabel:ARDAMS\r\n" |
| 111 | "a=ssrc:1504474588 label:ARDAMSa0\r\n" |
| 112 | "m=video 9 UDP/TLS/RTP/SAVPF 100 116 117 96\r\n" |
| 113 | "c=IN IP4 0.0.0.0\r\n" |
| 114 | "a=rtcp:9 IN IP4 0.0.0.0\r\n" |
| 115 | "a=ice-ufrag:f3o+0HG7l9nwIWFY\r\n" |
| 116 | "a=ice-pwd:VDctmJNCptR2TB7+meDpw7w5\r\n" |
| 117 | "a=fingerprint:sha-256 A9:D5:8D:A8:69:22:39:60:92:AD:94:1A:22:2D:5E:" |
| 118 | "A5:4A:A9:18:C2:35:5D:46:5E:59:BD:1C:AF:38:9F:E6:E1\r\n" |
| 119 | "a=setup:active\r\n" |
| 120 | "a=mid:video\r\n" |
| 121 | "a=extmap:2 urn:ietf:params:rtp-hdrext:toffset\r\n" |
| 122 | "a=extmap:3 http://www.webrtc.org/experiments/rtp-hdrext/" |
| 123 | "abs-send-time\r\n" |
| 124 | "a=extmap:4 urn:3gpp:video-orientation\r\n" |
| 125 | "a=sendrecv\r\n" |
| 126 | "a=rtcp-mux\r\n" |
| 127 | "a=rtpmap:100 VP8/90000\r\n" |
| 128 | "a=rtcp-fb:100 ccm fir\r\n" |
| 129 | "a=rtcp-fb:100 nack\r\n" |
| 130 | "a=rtcp-fb:100 nack pli\r\n" |
| 131 | "a=rtcp-fb:100 goog-remb\r\n" |
| 132 | "a=rtpmap:116 red/90000\r\n" |
| 133 | "a=rtpmap:117 ulpfec/90000\r\n" |
| 134 | "a=rtpmap:96 rtx/90000\r\n" |
| 135 | "a=fmtp:96 apt=100\r\n" |
| 136 | "a=ssrc-group:FID 498297514 1644357692\r\n" |
| 137 | "a=ssrc:498297514 cname:V+FdIC5AJpxLhdYQ\r\n" |
| 138 | "a=ssrc:498297514 msid:ARDAMS ARDAMSv0\r\n" |
| 139 | "a=ssrc:498297514 mslabel:ARDAMS\r\n" |
| 140 | "a=ssrc:498297514 label:ARDAMSv0\r\n" |
| 141 | "a=ssrc:1644357692 cname:V+FdIC5AJpxLhdYQ\r\n" |
| 142 | "a=ssrc:1644357692 msid:ARDAMS ARDAMSv0\r\n" |
| 143 | "a=ssrc:1644357692 mslabel:ARDAMS\r\n" |
| 144 | "a=ssrc:1644357692 label:ARDAMSv0\r\n"; |
| 145 | } |
| 146 | |
| 147 | @end |
| 148 | |
| 149 | TEST(RTCSessionDescriptionTest, SessionDescriptionConversionTest) { |
| 150 | @autoreleasepool { |
| 151 | RTCSessionDescriptionTest *test = [[RTCSessionDescriptionTest alloc] init]; |
| 152 | [test testSessionDescriptionConversion]; |
| 153 | } |
| 154 | } |
| 155 | |
| 156 | TEST(RTCSessionDescriptionTest, InitFromSessionDescriptionTest) { |
| 157 | @autoreleasepool { |
| 158 | RTCSessionDescriptionTest *test = [[RTCSessionDescriptionTest alloc] init]; |
| 159 | [test testInitFromNativeSessionDescription]; |
| 160 | } |
| 161 | } |