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.

53 lines
2.3 KiB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. /*
  2. * Copyright 2016 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 "RTCFieldTrials.h"
  11. #include <memory>
  12. #import "base/RTCLogging.h"
  13. #include "system_wrappers/include/field_trial.h"
  14. NSString * const kRTCFieldTrialAudioSendSideBweKey = @"WebRTC-Audio-SendSideBwe";
  15. NSString * const kRTCFieldTrialAudioForceNoTWCCKey = @"WebRTC-Audio-ForceNoTWCC";
  16. NSString * const kRTCFieldTrialAudioForceABWENoTWCCKey = @"WebRTC-Audio-ABWENoTWCC";
  17. NSString * const kRTCFieldTrialSendSideBweWithOverheadKey = @"WebRTC-SendSideBwe-WithOverhead";
  18. NSString * const kRTCFieldTrialFlexFec03AdvertisedKey = @"WebRTC-FlexFEC-03-Advertised";
  19. NSString * const kRTCFieldTrialFlexFec03Key = @"WebRTC-FlexFEC-03";
  20. NSString * const kRTCFieldTrialH264HighProfileKey = @"WebRTC-H264HighProfile";
  21. NSString * const kRTCFieldTrialMinimizeResamplingOnMobileKey =
  22. @"WebRTC-Audio-MinimizeResamplingOnMobile";
  23. NSString * const kRTCFieldTrialEnabledValue = @"Enabled";
  24. static std::unique_ptr<char[]> gFieldTrialInitString;
  25. void RTCInitFieldTrialDictionary(NSDictionary<NSString *, NSString *> *fieldTrials) {
  26. if (!fieldTrials) {
  27. RTCLogWarning(@"No fieldTrials provided.");
  28. return;
  29. }
  30. // Assemble the keys and values into the field trial string.
  31. // We don't perform any extra format checking. That should be done by the underlying WebRTC calls.
  32. NSMutableString *fieldTrialInitString = [NSMutableString string];
  33. for (NSString *key in fieldTrials) {
  34. NSString *fieldTrialEntry = [NSString stringWithFormat:@"%@/%@/", key, fieldTrials[key]];
  35. [fieldTrialInitString appendString:fieldTrialEntry];
  36. }
  37. size_t len = fieldTrialInitString.length + 1;
  38. gFieldTrialInitString.reset(new char[len]);
  39. if (![fieldTrialInitString getCString:gFieldTrialInitString.get()
  40. maxLength:len
  41. encoding:NSUTF8StringEncoding]) {
  42. RTCLogError(@"Failed to convert field trial string.");
  43. return;
  44. }
  45. webrtc::field_trial::InitFieldTrialsFromString(gFieldTrialInitString.get());
  46. }