Build dynamic iOS SDK.

- Places most ObjC code into webrtc/sdk/objc instead.
- New gyp targets to build, strip and export symbols for dylib.
- Removes old script used to generate dylib.

BUG=

Review URL: https://codereview.webrtc.org/1903663002

Cr-Commit-Position: refs/heads/master@{#12524}
This commit is contained in:
tkchin
2016-04-27 01:54:20 -07:00
committed by Commit bot
parent 06f7e49438
commit 9eeb6240c9
174 changed files with 1000 additions and 2122 deletions

View File

@ -0,0 +1,73 @@
/*
* Copyright 2015 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
#import <Foundation/Foundation.h>
#include <vector>
#include "webrtc/base/gunit.h"
#import "NSString+StdString.h"
#import "RTCConfiguration+Private.h"
#import "WebRTC/RTCConfiguration.h"
#import "WebRTC/RTCIceServer.h"
@interface RTCConfigurationTest : NSObject
- (void)testConversionToNativeConfiguration;
@end
@implementation RTCConfigurationTest
- (void)testConversionToNativeConfiguration {
NSArray *urlStrings = @[ @"stun:stun1.example.net" ];
RTCIceServer *server = [[RTCIceServer alloc] initWithURLStrings:urlStrings];
RTCConfiguration *config = [[RTCConfiguration alloc] init];
config.iceServers = @[ server ];
config.iceTransportPolicy = RTCIceTransportPolicyRelay;
config.bundlePolicy = RTCBundlePolicyMaxBundle;
config.rtcpMuxPolicy = RTCRtcpMuxPolicyNegotiate;
config.tcpCandidatePolicy = RTCTcpCandidatePolicyDisabled;
const int maxPackets = 60;
const int timeout = 1;
const int interval = 2;
config.audioJitterBufferMaxPackets = maxPackets;
config.iceConnectionReceivingTimeout = timeout;
config.iceBackupCandidatePairPingInterval = interval;
webrtc::PeerConnectionInterface::RTCConfiguration nativeConfig =
config.nativeConfiguration;
EXPECT_EQ(1u, nativeConfig.servers.size());
webrtc::PeerConnectionInterface::IceServer nativeServer =
nativeConfig.servers.front();
EXPECT_EQ(1u, nativeServer.urls.size());
EXPECT_EQ("stun:stun1.example.net", nativeServer.urls.front());
EXPECT_EQ(webrtc::PeerConnectionInterface::kRelay, nativeConfig.type);
EXPECT_EQ(webrtc::PeerConnectionInterface::kBundlePolicyMaxBundle,
nativeConfig.bundle_policy);
EXPECT_EQ(webrtc::PeerConnectionInterface::kRtcpMuxPolicyNegotiate,
nativeConfig.rtcp_mux_policy);
EXPECT_EQ(webrtc::PeerConnectionInterface::kTcpCandidatePolicyDisabled,
nativeConfig.tcp_candidate_policy);
EXPECT_EQ(maxPackets, nativeConfig.audio_jitter_buffer_max_packets);
EXPECT_EQ(timeout, nativeConfig.ice_connection_receiving_timeout);
EXPECT_EQ(interval, nativeConfig.ice_backup_candidate_pair_ping_interval);
}
@end
TEST(RTCConfigurationTest, NativeConfigurationConversionTest) {
@autoreleasepool {
RTCConfigurationTest *test = [[RTCConfigurationTest alloc] init];
[test testConversionToNativeConfiguration];
}
}

View File

@ -0,0 +1,59 @@
/*
* Copyright 2015 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
#import <Foundation/Foundation.h>
#include "webrtc/base/gunit.h"
#import "NSString+StdString.h"
#import "RTCDataChannelConfiguration+Private.h"
#import "WebRTC/RTCDataChannelConfiguration.h"
@interface RTCDataChannelConfigurationTest : NSObject
- (void)testConversionToNativeDataChannelInit;
@end
@implementation RTCDataChannelConfigurationTest
- (void)testConversionToNativeDataChannelInit {
BOOL isOrdered = NO;
int maxPacketLifeTime = 5;
int maxRetransmits = 4;
BOOL isNegotiated = YES;
int channelId = 4;
NSString *protocol = @"protocol";
RTCDataChannelConfiguration *dataChannelConfig =
[[RTCDataChannelConfiguration alloc] init];
dataChannelConfig.isOrdered = isOrdered;
dataChannelConfig.maxPacketLifeTime = maxPacketLifeTime;
dataChannelConfig.maxRetransmits = maxRetransmits;
dataChannelConfig.isNegotiated = isNegotiated;
dataChannelConfig.channelId = channelId;
dataChannelConfig.protocol = protocol;
webrtc::DataChannelInit nativeInit = dataChannelConfig.nativeDataChannelInit;
EXPECT_EQ(isOrdered, nativeInit.ordered);
EXPECT_EQ(maxPacketLifeTime, nativeInit.maxRetransmitTime);
EXPECT_EQ(maxRetransmits, nativeInit.maxRetransmits);
EXPECT_EQ(isNegotiated, nativeInit.negotiated);
EXPECT_EQ(channelId, nativeInit.id);
EXPECT_EQ(protocol.stdString, nativeInit.protocol);
}
@end
TEST(RTCDataChannelConfiguration, NativeDataChannelInitConversionTest) {
@autoreleasepool {
RTCDataChannelConfigurationTest *test =
[[RTCDataChannelConfigurationTest alloc] init];
[test testConversionToNativeDataChannelInit];
}
}

View File

@ -0,0 +1,74 @@
/*
* Copyright 2015 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
#import <Foundation/Foundation.h>
#include "webrtc/base/gunit.h"
#import "NSString+StdString.h"
#import "RTCIceCandidate+Private.h"
#import "WebRTC/RTCIceCandidate.h"
@interface RTCIceCandidateTest : NSObject
- (void)testCandidate;
- (void)testInitFromNativeCandidate;
@end
@implementation RTCIceCandidateTest
- (void)testCandidate {
NSString *sdp = @"candidate:4025901590 1 udp 2122265343 "
"fdff:2642:12a6:fe38:c001:beda:fcf9:51aa "
"59052 typ host generation 0";
RTCIceCandidate *candidate = [[RTCIceCandidate alloc] initWithSdp:sdp
sdpMLineIndex:0
sdpMid:@"audio"];
rtc::scoped_ptr<webrtc::IceCandidateInterface> nativeCandidate =
candidate.nativeCandidate;
EXPECT_EQ("audio", nativeCandidate->sdp_mid());
EXPECT_EQ(0, nativeCandidate->sdp_mline_index());
std::string sdpString;
nativeCandidate->ToString(&sdpString);
EXPECT_EQ(sdp.stdString, sdpString);
}
- (void)testInitFromNativeCandidate {
std::string sdp("candidate:4025901590 1 udp 2122265343 "
"fdff:2642:12a6:fe38:c001:beda:fcf9:51aa "
"59052 typ host generation 0");
webrtc::IceCandidateInterface *nativeCandidate =
webrtc::CreateIceCandidate("audio", 0, sdp, nullptr);
RTCIceCandidate *iceCandidate =
[[RTCIceCandidate alloc] initWithNativeCandidate:nativeCandidate];
EXPECT_TRUE([@"audio" isEqualToString:iceCandidate.sdpMid]);
EXPECT_EQ(0, iceCandidate.sdpMLineIndex);
EXPECT_EQ(sdp, iceCandidate.sdp.stdString);
}
@end
TEST(RTCIceCandidateTest, CandidateTest) {
@autoreleasepool {
RTCIceCandidateTest *test = [[RTCIceCandidateTest alloc] init];
[test testCandidate];
}
}
TEST(RTCIceCandidateTest, InitFromCandidateTest) {
@autoreleasepool {
RTCIceCandidateTest *test = [[RTCIceCandidateTest alloc] init];
[test testInitFromNativeCandidate];
}
}

View File

@ -0,0 +1,108 @@
/*
* Copyright 2015 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
#import <Foundation/Foundation.h>
#include <vector>
#include "webrtc/base/gunit.h"
#import "NSString+StdString.h"
#import "RTCIceServer+Private.h"
#import "WebRTC/RTCIceServer.h"
@interface RTCIceServerTest : NSObject
- (void)testOneURLServer;
- (void)testTwoURLServer;
- (void)testPasswordCredential;
- (void)testInitFromNativeServer;
@end
@implementation RTCIceServerTest
- (void)testOneURLServer {
RTCIceServer *server = [[RTCIceServer alloc] initWithURLStrings:@[
@"stun:stun1.example.net" ]];
webrtc::PeerConnectionInterface::IceServer iceStruct = server.nativeServer;
EXPECT_EQ(1u, iceStruct.urls.size());
EXPECT_EQ("stun:stun1.example.net", iceStruct.urls.front());
EXPECT_EQ("", iceStruct.username);
EXPECT_EQ("", iceStruct.password);
}
- (void)testTwoURLServer {
RTCIceServer *server = [[RTCIceServer alloc] initWithURLStrings:@[
@"turn1:turn1.example.net", @"turn2:turn2.example.net" ]];
webrtc::PeerConnectionInterface::IceServer iceStruct = server.nativeServer;
EXPECT_EQ(2u, iceStruct.urls.size());
EXPECT_EQ("turn1:turn1.example.net", iceStruct.urls.front());
EXPECT_EQ("turn2:turn2.example.net", iceStruct.urls.back());
EXPECT_EQ("", iceStruct.username);
EXPECT_EQ("", iceStruct.password);
}
- (void)testPasswordCredential {
RTCIceServer *server = [[RTCIceServer alloc]
initWithURLStrings:@[ @"turn1:turn1.example.net" ]
username:@"username"
credential:@"credential"];
webrtc::PeerConnectionInterface::IceServer iceStruct = server.nativeServer;
EXPECT_EQ(1u, iceStruct.urls.size());
EXPECT_EQ("turn1:turn1.example.net", iceStruct.urls.front());
EXPECT_EQ("username", iceStruct.username);
EXPECT_EQ("credential", iceStruct.password);
}
- (void)testInitFromNativeServer {
webrtc::PeerConnectionInterface::IceServer nativeServer;
nativeServer.username = "username";
nativeServer.password = "password";
nativeServer.urls.push_back("stun:stun.example.net");
RTCIceServer *iceServer =
[[RTCIceServer alloc] initWithNativeServer:nativeServer];
EXPECT_EQ(1u, iceServer.urlStrings.count);
EXPECT_EQ("stun:stun.example.net",
[NSString stdStringForString:iceServer.urlStrings.firstObject]);
EXPECT_EQ("username", [NSString stdStringForString:iceServer.username]);
EXPECT_EQ("password", [NSString stdStringForString:iceServer.credential]);
}
@end
TEST(RTCIceServerTest, OneURLTest) {
@autoreleasepool {
RTCIceServerTest *test = [[RTCIceServerTest alloc] init];
[test testOneURLServer];
}
}
TEST(RTCIceServerTest, TwoURLTest) {
@autoreleasepool {
RTCIceServerTest *test = [[RTCIceServerTest alloc] init];
[test testTwoURLServer];
}
}
TEST(RTCIceServerTest, PasswordCredentialTest) {
@autoreleasepool {
RTCIceServerTest *test = [[RTCIceServerTest alloc] init];
[test testPasswordCredential];
}
}
TEST(RTCIceServerTest, InitFromNativeServerTest) {
@autoreleasepool {
RTCIceServerTest *test = [[RTCIceServerTest alloc] init];
[test testInitFromNativeServer];
}
}

View File

@ -0,0 +1,66 @@
/*
* Copyright 2015 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
#import <Foundation/Foundation.h>
#include "webrtc/base/gunit.h"
#import "NSString+StdString.h"
#import "RTCMediaConstraints+Private.h"
#import "WebRTC/RTCMediaConstraints.h"
@interface RTCMediaConstraintsTest : NSObject
- (void)testMediaConstraints;
@end
@implementation RTCMediaConstraintsTest
- (void)testMediaConstraints {
NSDictionary *mandatory = @{@"key1": @"value1", @"key2": @"value2"};
NSDictionary *optional = @{@"key3": @"value3", @"key4": @"value4"};
RTCMediaConstraints *constraints = [[RTCMediaConstraints alloc]
initWithMandatoryConstraints:mandatory
optionalConstraints:optional];
rtc::scoped_ptr<webrtc::MediaConstraints> nativeConstraints =
[constraints nativeConstraints];
webrtc::MediaConstraintsInterface::Constraints nativeMandatory =
nativeConstraints->GetMandatory();
[self expectConstraints:mandatory inNativeConstraints:nativeMandatory];
webrtc::MediaConstraintsInterface::Constraints nativeOptional =
nativeConstraints->GetOptional();
[self expectConstraints:optional inNativeConstraints:nativeOptional];
}
- (void)expectConstraints:(NSDictionary *)constraints
inNativeConstraints:
(webrtc::MediaConstraintsInterface::Constraints)nativeConstraints {
EXPECT_EQ(constraints.count, nativeConstraints.size());
for (NSString *key in constraints) {
NSString *value = [constraints objectForKey:key];
std::string nativeValue;
bool found = nativeConstraints.FindFirst(key.stdString, &nativeValue);
EXPECT_TRUE(found);
EXPECT_EQ(value.stdString, nativeValue);
}
}
@end
TEST(RTCMediaConstraintsTest, MediaConstraintsTest) {
@autoreleasepool {
RTCMediaConstraintsTest *test = [[RTCMediaConstraintsTest alloc] init];
[test testMediaConstraints];
}
}

View File

@ -0,0 +1,144 @@
/*
* Copyright 2015 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
#import <Foundation/Foundation.h>
#include "webrtc/base/gunit.h"
#import "NSString+StdString.h"
#import "RTCSessionDescription+Private.h"
#import "WebRTC/RTCSessionDescription.h"
@interface RTCSessionDescriptionTest : NSObject
- (void)testSessionDescriptionConversion;
- (void)testInitFromNativeSessionDescription;
@end
@implementation RTCSessionDescriptionTest
/**
* Test conversion of an Objective-C RTCSessionDescription to a native
* SessionDescriptionInterface (based on the types and SDP strings being equal).
*/
- (void)testSessionDescriptionConversion {
RTCSessionDescription *description =
[[RTCSessionDescription alloc] initWithType:RTCSdpTypeAnswer
sdp:[self sdp]];
webrtc::SessionDescriptionInterface *nativeDescription =
description.nativeDescription;
EXPECT_EQ(RTCSdpTypeAnswer,
[RTCSessionDescription typeForStdString:nativeDescription->type()]);
std::string sdp;
nativeDescription->ToString(&sdp);
EXPECT_EQ([self sdp].stdString, sdp);
}
- (void)testInitFromNativeSessionDescription {
webrtc::SessionDescriptionInterface *nativeDescription;
nativeDescription = webrtc::CreateSessionDescription(
webrtc::SessionDescriptionInterface::kAnswer,
[self sdp].stdString,
nullptr);
RTCSessionDescription *description =
[[RTCSessionDescription alloc] initWithNativeDescription:
nativeDescription];
EXPECT_EQ(webrtc::SessionDescriptionInterface::kAnswer,
[RTCSessionDescription stdStringForType:description.type]);
EXPECT_TRUE([[self sdp] isEqualToString:description.sdp]);
}
- (NSString *)sdp {
return @"v=0\r\n"
"o=- 5319989746393411314 2 IN IP4 127.0.0.1\r\n"
"s=-\r\n"
"t=0 0\r\n"
"a=group:BUNDLE audio video\r\n"
"a=msid-semantic: WMS ARDAMS\r\n"
"m=audio 9 UDP/TLS/RTP/SAVPF 111 103 9 0 8 126\r\n"
"c=IN IP4 0.0.0.0\r\n"
"a=rtcp:9 IN IP4 0.0.0.0\r\n"
"a=ice-ufrag:f3o+0HG7l9nwIWFY\r\n"
"a=ice-pwd:VDctmJNCptR2TB7+meDpw7w5\r\n"
"a=fingerprint:sha-256 A9:D5:8D:A8:69:22:39:60:92:AD:94:1A:22:2D:5E:"
"A5:4A:A9:18:C2:35:5D:46:5E:59:BD:1C:AF:38:9F:E6:E1\r\n"
"a=setup:active\r\n"
"a=mid:audio\r\n"
"a=extmap:1 urn:ietf:params:rtp-hdrext:ssrc-audio-level\r\n"
"a=extmap:3 http://www.webrtc.org/experiments/rtp-hdrext/"
"abs-send-time\r\n"
"a=sendrecv\r\n"
"a=rtcp-mux\r\n"
"a=rtpmap:111 opus/48000/2\r\n"
"a=fmtp:111 minptime=10;useinbandfec=1\r\n"
"a=rtpmap:103 ISAC/16000\r\n"
"a=rtpmap:9 G722/8000\r\n"
"a=rtpmap:0 PCMU/8000\r\n"
"a=rtpmap:8 PCMA/8000\r\n"
"a=rtpmap:126 telephone-event/8000\r\n"
"a=maxptime:60\r\n"
"a=ssrc:1504474588 cname:V+FdIC5AJpxLhdYQ\r\n"
"a=ssrc:1504474588 msid:ARDAMS ARDAMSa0\r\n"
"a=ssrc:1504474588 mslabel:ARDAMS\r\n"
"a=ssrc:1504474588 label:ARDAMSa0\r\n"
"m=video 9 UDP/TLS/RTP/SAVPF 100 116 117 96\r\n"
"c=IN IP4 0.0.0.0\r\n"
"a=rtcp:9 IN IP4 0.0.0.0\r\n"
"a=ice-ufrag:f3o+0HG7l9nwIWFY\r\n"
"a=ice-pwd:VDctmJNCptR2TB7+meDpw7w5\r\n"
"a=fingerprint:sha-256 A9:D5:8D:A8:69:22:39:60:92:AD:94:1A:22:2D:5E:"
"A5:4A:A9:18:C2:35:5D:46:5E:59:BD:1C:AF:38:9F:E6:E1\r\n"
"a=setup:active\r\n"
"a=mid:video\r\n"
"a=extmap:2 urn:ietf:params:rtp-hdrext:toffset\r\n"
"a=extmap:3 http://www.webrtc.org/experiments/rtp-hdrext/"
"abs-send-time\r\n"
"a=extmap:4 urn:3gpp:video-orientation\r\n"
"a=sendrecv\r\n"
"a=rtcp-mux\r\n"
"a=rtpmap:100 VP8/90000\r\n"
"a=rtcp-fb:100 ccm fir\r\n"
"a=rtcp-fb:100 nack\r\n"
"a=rtcp-fb:100 nack pli\r\n"
"a=rtcp-fb:100 goog-remb\r\n"
"a=rtpmap:116 red/90000\r\n"
"a=rtpmap:117 ulpfec/90000\r\n"
"a=rtpmap:96 rtx/90000\r\n"
"a=fmtp:96 apt=100\r\n"
"a=ssrc-group:FID 498297514 1644357692\r\n"
"a=ssrc:498297514 cname:V+FdIC5AJpxLhdYQ\r\n"
"a=ssrc:498297514 msid:ARDAMS ARDAMSv0\r\n"
"a=ssrc:498297514 mslabel:ARDAMS\r\n"
"a=ssrc:498297514 label:ARDAMSv0\r\n"
"a=ssrc:1644357692 cname:V+FdIC5AJpxLhdYQ\r\n"
"a=ssrc:1644357692 msid:ARDAMS ARDAMSv0\r\n"
"a=ssrc:1644357692 mslabel:ARDAMS\r\n"
"a=ssrc:1644357692 label:ARDAMSv0\r\n";
}
@end
TEST(RTCSessionDescriptionTest, SessionDescriptionConversionTest) {
@autoreleasepool {
RTCSessionDescriptionTest *test = [[RTCSessionDescriptionTest alloc] init];
[test testSessionDescriptionConversion];
}
}
TEST(RTCSessionDescriptionTest, InitFromSessionDescriptionTest) {
@autoreleasepool {
RTCSessionDescriptionTest *test = [[RTCSessionDescriptionTest alloc] init];
[test testInitFromNativeSessionDescription];
}
}