blob: 35322587996d98ac6769b0655a648b19a3ad9d3a [file] [log] [blame]
jtteh4eeb5372017-04-03 15:06:37 -07001/*
2 * Copyright 2015 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
13#include <vector>
14
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020015#include "rtc_base/gunit.h"
jtteh4eeb5372017-04-03 15:06:37 -070016
Anders Carlsson7bca8ca2018-08-30 09:30:29 +020017#import "api/peerconnection/RTCConfiguration+Private.h"
18#import "api/peerconnection/RTCConfiguration.h"
Benjamin Wright8c27cca2018-10-25 10:16:44 -070019#import "api/peerconnection/RTCCryptoOptions.h"
Anders Carlsson7bca8ca2018-08-30 09:30:29 +020020#import "api/peerconnection/RTCIceServer.h"
21#import "api/peerconnection/RTCMediaConstraints.h"
22#import "api/peerconnection/RTCPeerConnection.h"
23#import "api/peerconnection/RTCPeerConnectionFactory.h"
24#import "helpers/NSString+StdString.h"
jtteh4eeb5372017-04-03 15:06:37 -070025
26@interface RTCPeerConnectionTest : NSObject
27- (void)testConfigurationGetter;
28@end
29
30@implementation RTCPeerConnectionTest
31
32- (void)testConfigurationGetter {
33 NSArray *urlStrings = @[ @"stun:stun1.example.net" ];
34 RTCIceServer *server = [[RTCIceServer alloc] initWithURLStrings:urlStrings];
35
36 RTCConfiguration *config = [[RTCConfiguration alloc] init];
37 config.iceServers = @[ server ];
38 config.iceTransportPolicy = RTCIceTransportPolicyRelay;
39 config.bundlePolicy = RTCBundlePolicyMaxBundle;
40 config.rtcpMuxPolicy = RTCRtcpMuxPolicyNegotiate;
41 config.tcpCandidatePolicy = RTCTcpCandidatePolicyDisabled;
42 config.candidateNetworkPolicy = RTCCandidateNetworkPolicyLowCost;
43 const int maxPackets = 60;
Qingsi Wangdea68892018-03-27 10:55:21 -070044 const int timeout = 1500;
45 const int interval = 2000;
jtteh4eeb5372017-04-03 15:06:37 -070046 config.audioJitterBufferMaxPackets = maxPackets;
47 config.audioJitterBufferFastAccelerate = YES;
48 config.iceConnectionReceivingTimeout = timeout;
49 config.iceBackupCandidatePairPingInterval = interval;
50 config.continualGatheringPolicy =
51 RTCContinualGatheringPolicyGatherContinually;
52 config.shouldPruneTurnPorts = YES;
Zhi Huangb57e1692018-06-12 11:41:11 -070053 config.activeResetSrtpParams = YES;
Benjamin Wright8c27cca2018-10-25 10:16:44 -070054 config.cryptoOptions = [[RTCCryptoOptions alloc] initWithSrtpEnableGcmCryptoSuites:YES
55 srtpEnableAes128Sha1_32CryptoCipher:YES
56 srtpEnableEncryptedRtpHeaderExtensions:NO
57 sframeRequireFrameEncryption:NO];
jtteh4eeb5372017-04-03 15:06:37 -070058
59 RTCMediaConstraints *contraints = [[RTCMediaConstraints alloc] initWithMandatoryConstraints:@{}
60 optionalConstraints:nil];
61 RTCPeerConnectionFactory *factory = [[RTCPeerConnectionFactory alloc] init];
jtteh4eeb5372017-04-03 15:06:37 -070062
kthelgasonc0977102017-04-24 00:57:16 -070063 RTCConfiguration *newConfig;
64 @autoreleasepool {
65 RTCPeerConnection *peerConnection =
66 [factory peerConnectionWithConfiguration:config constraints:contraints delegate:nil];
67 newConfig = peerConnection.configuration;
zstein03adb7c2017-08-09 14:29:42 -070068
zstein8b476172017-09-05 14:43:03 -070069 EXPECT_TRUE([peerConnection setBweMinBitrateBps:[NSNumber numberWithInt:100000]
70 currentBitrateBps:[NSNumber numberWithInt:5000000]
71 maxBitrateBps:[NSNumber numberWithInt:500000000]]);
72 EXPECT_FALSE([peerConnection setBweMinBitrateBps:[NSNumber numberWithInt:2]
73 currentBitrateBps:[NSNumber numberWithInt:1]
74 maxBitrateBps:nil]);
kthelgasonc0977102017-04-24 00:57:16 -070075 }
zstein03adb7c2017-08-09 14:29:42 -070076
jtteh4eeb5372017-04-03 15:06:37 -070077 EXPECT_EQ([config.iceServers count], [newConfig.iceServers count]);
78 RTCIceServer *newServer = newConfig.iceServers[0];
79 RTCIceServer *origServer = config.iceServers[0];
80 std::string origUrl = origServer.urlStrings.firstObject.UTF8String;
81 std::string url = newServer.urlStrings.firstObject.UTF8String;
82 EXPECT_EQ(origUrl, url);
83
84 EXPECT_EQ(config.iceTransportPolicy, newConfig.iceTransportPolicy);
85 EXPECT_EQ(config.bundlePolicy, newConfig.bundlePolicy);
86 EXPECT_EQ(config.rtcpMuxPolicy, newConfig.rtcpMuxPolicy);
87 EXPECT_EQ(config.tcpCandidatePolicy, newConfig.tcpCandidatePolicy);
88 EXPECT_EQ(config.candidateNetworkPolicy, newConfig.candidateNetworkPolicy);
89 EXPECT_EQ(config.audioJitterBufferMaxPackets, newConfig.audioJitterBufferMaxPackets);
90 EXPECT_EQ(config.audioJitterBufferFastAccelerate, newConfig.audioJitterBufferFastAccelerate);
91 EXPECT_EQ(config.iceConnectionReceivingTimeout, newConfig.iceConnectionReceivingTimeout);
92 EXPECT_EQ(config.iceBackupCandidatePairPingInterval,
93 newConfig.iceBackupCandidatePairPingInterval);
94 EXPECT_EQ(config.continualGatheringPolicy, newConfig.continualGatheringPolicy);
95 EXPECT_EQ(config.shouldPruneTurnPorts, newConfig.shouldPruneTurnPorts);
Zhi Huangb57e1692018-06-12 11:41:11 -070096 EXPECT_EQ(config.activeResetSrtpParams, newConfig.activeResetSrtpParams);
Benjamin Wright8c27cca2018-10-25 10:16:44 -070097 EXPECT_EQ(config.cryptoOptions.srtpEnableGcmCryptoSuites,
98 newConfig.cryptoOptions.srtpEnableGcmCryptoSuites);
99 EXPECT_EQ(config.cryptoOptions.srtpEnableAes128Sha1_32CryptoCipher,
100 newConfig.cryptoOptions.srtpEnableAes128Sha1_32CryptoCipher);
101 EXPECT_EQ(config.cryptoOptions.srtpEnableEncryptedRtpHeaderExtensions,
102 newConfig.cryptoOptions.srtpEnableEncryptedRtpHeaderExtensions);
103 EXPECT_EQ(config.cryptoOptions.sframeRequireFrameEncryption,
104 newConfig.cryptoOptions.sframeRequireFrameEncryption);
jtteh4eeb5372017-04-03 15:06:37 -0700105}
106
107@end
108
109TEST(RTCPeerConnectionTest, ConfigurationGetterTest) {
110 @autoreleasepool {
111 RTCPeerConnectionTest *test = [[RTCPeerConnectionTest alloc] init];
112 [test testConfigurationGetter];
113 }
114}