You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

114 lines
5.2 KiB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. /*
  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. #import <Foundation/Foundation.h>
  11. #include <vector>
  12. #include "rtc_base/gunit.h"
  13. #import "api/peerconnection/RTCConfiguration+Private.h"
  14. #import "api/peerconnection/RTCConfiguration.h"
  15. #import "api/peerconnection/RTCCryptoOptions.h"
  16. #import "api/peerconnection/RTCIceServer.h"
  17. #import "api/peerconnection/RTCMediaConstraints.h"
  18. #import "api/peerconnection/RTCPeerConnection.h"
  19. #import "api/peerconnection/RTCPeerConnectionFactory.h"
  20. #import "helpers/NSString+StdString.h"
  21. @interface RTCPeerConnectionTest : NSObject
  22. - (void)testConfigurationGetter;
  23. @end
  24. @implementation RTCPeerConnectionTest
  25. - (void)testConfigurationGetter {
  26. NSArray *urlStrings = @[ @"stun:stun1.example.net" ];
  27. RTCIceServer *server = [[RTCIceServer alloc] initWithURLStrings:urlStrings];
  28. RTCConfiguration *config = [[RTCConfiguration alloc] init];
  29. config.iceServers = @[ server ];
  30. config.iceTransportPolicy = RTCIceTransportPolicyRelay;
  31. config.bundlePolicy = RTCBundlePolicyMaxBundle;
  32. config.rtcpMuxPolicy = RTCRtcpMuxPolicyNegotiate;
  33. config.tcpCandidatePolicy = RTCTcpCandidatePolicyDisabled;
  34. config.candidateNetworkPolicy = RTCCandidateNetworkPolicyLowCost;
  35. const int maxPackets = 60;
  36. const int timeout = 1500;
  37. const int interval = 2000;
  38. config.audioJitterBufferMaxPackets = maxPackets;
  39. config.audioJitterBufferFastAccelerate = YES;
  40. config.iceConnectionReceivingTimeout = timeout;
  41. config.iceBackupCandidatePairPingInterval = interval;
  42. config.continualGatheringPolicy =
  43. RTCContinualGatheringPolicyGatherContinually;
  44. config.shouldPruneTurnPorts = YES;
  45. config.activeResetSrtpParams = YES;
  46. config.cryptoOptions = [[RTCCryptoOptions alloc] initWithSrtpEnableGcmCryptoSuites:YES
  47. srtpEnableAes128Sha1_32CryptoCipher:YES
  48. srtpEnableEncryptedRtpHeaderExtensions:NO
  49. sframeRequireFrameEncryption:NO];
  50. RTCMediaConstraints *contraints = [[RTCMediaConstraints alloc] initWithMandatoryConstraints:@{}
  51. optionalConstraints:nil];
  52. RTCPeerConnectionFactory *factory = [[RTCPeerConnectionFactory alloc] init];
  53. RTCConfiguration *newConfig;
  54. @autoreleasepool {
  55. RTCPeerConnection *peerConnection =
  56. [factory peerConnectionWithConfiguration:config constraints:contraints delegate:nil];
  57. newConfig = peerConnection.configuration;
  58. EXPECT_TRUE([peerConnection setBweMinBitrateBps:[NSNumber numberWithInt:100000]
  59. currentBitrateBps:[NSNumber numberWithInt:5000000]
  60. maxBitrateBps:[NSNumber numberWithInt:500000000]]);
  61. EXPECT_FALSE([peerConnection setBweMinBitrateBps:[NSNumber numberWithInt:2]
  62. currentBitrateBps:[NSNumber numberWithInt:1]
  63. maxBitrateBps:nil]);
  64. }
  65. EXPECT_EQ([config.iceServers count], [newConfig.iceServers count]);
  66. RTCIceServer *newServer = newConfig.iceServers[0];
  67. RTCIceServer *origServer = config.iceServers[0];
  68. std::string origUrl = origServer.urlStrings.firstObject.UTF8String;
  69. std::string url = newServer.urlStrings.firstObject.UTF8String;
  70. EXPECT_EQ(origUrl, url);
  71. EXPECT_EQ(config.iceTransportPolicy, newConfig.iceTransportPolicy);
  72. EXPECT_EQ(config.bundlePolicy, newConfig.bundlePolicy);
  73. EXPECT_EQ(config.rtcpMuxPolicy, newConfig.rtcpMuxPolicy);
  74. EXPECT_EQ(config.tcpCandidatePolicy, newConfig.tcpCandidatePolicy);
  75. EXPECT_EQ(config.candidateNetworkPolicy, newConfig.candidateNetworkPolicy);
  76. EXPECT_EQ(config.audioJitterBufferMaxPackets, newConfig.audioJitterBufferMaxPackets);
  77. EXPECT_EQ(config.audioJitterBufferFastAccelerate, newConfig.audioJitterBufferFastAccelerate);
  78. EXPECT_EQ(config.iceConnectionReceivingTimeout, newConfig.iceConnectionReceivingTimeout);
  79. EXPECT_EQ(config.iceBackupCandidatePairPingInterval,
  80. newConfig.iceBackupCandidatePairPingInterval);
  81. EXPECT_EQ(config.continualGatheringPolicy, newConfig.continualGatheringPolicy);
  82. EXPECT_EQ(config.shouldPruneTurnPorts, newConfig.shouldPruneTurnPorts);
  83. EXPECT_EQ(config.activeResetSrtpParams, newConfig.activeResetSrtpParams);
  84. EXPECT_EQ(config.cryptoOptions.srtpEnableGcmCryptoSuites,
  85. newConfig.cryptoOptions.srtpEnableGcmCryptoSuites);
  86. EXPECT_EQ(config.cryptoOptions.srtpEnableAes128Sha1_32CryptoCipher,
  87. newConfig.cryptoOptions.srtpEnableAes128Sha1_32CryptoCipher);
  88. EXPECT_EQ(config.cryptoOptions.srtpEnableEncryptedRtpHeaderExtensions,
  89. newConfig.cryptoOptions.srtpEnableEncryptedRtpHeaderExtensions);
  90. EXPECT_EQ(config.cryptoOptions.sframeRequireFrameEncryption,
  91. newConfig.cryptoOptions.sframeRequireFrameEncryption);
  92. }
  93. @end
  94. TEST(RTCPeerConnectionTest, ConfigurationGetterTest) {
  95. @autoreleasepool {
  96. RTCPeerConnectionTest *test = [[RTCPeerConnectionTest alloc] init];
  97. [test testConfigurationGetter];
  98. }
  99. }