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.

115 lines
3.4 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 "ARDSettingsStore.h"
  11. static NSString *const kVideoResolutionKey = @"rtc_video_resolution_key";
  12. static NSString *const kVideoCodecKey = @"rtc_video_codec_info_key";
  13. static NSString *const kBitrateKey = @"rtc_max_bitrate_key";
  14. static NSString *const kAudioOnlyKey = @"rtc_audio_only_key";
  15. static NSString *const kCreateAecDumpKey = @"rtc_create_aec_dump_key";
  16. static NSString *const kUseManualAudioConfigKey = @"rtc_use_manual_audio_config_key";
  17. NS_ASSUME_NONNULL_BEGIN
  18. @interface ARDSettingsStore () {
  19. NSUserDefaults *_storage;
  20. }
  21. @property(nonatomic, strong, readonly) NSUserDefaults *storage;
  22. @end
  23. @implementation ARDSettingsStore
  24. + (void)setDefaultsForVideoResolution:(NSString *)videoResolution
  25. videoCodec:(NSData *)videoCodec
  26. bitrate:(nullable NSNumber *)bitrate
  27. audioOnly:(BOOL)audioOnly
  28. createAecDump:(BOOL)createAecDump
  29. useManualAudioConfig:(BOOL)useManualAudioConfig {
  30. NSMutableDictionary<NSString *, id> *defaultsDictionary = [@{
  31. kAudioOnlyKey : @(audioOnly),
  32. kCreateAecDumpKey : @(createAecDump),
  33. kUseManualAudioConfigKey : @(useManualAudioConfig)
  34. } mutableCopy];
  35. if (videoResolution) {
  36. defaultsDictionary[kVideoResolutionKey] = videoResolution;
  37. }
  38. if (videoCodec) {
  39. defaultsDictionary[kVideoCodecKey] = videoCodec;
  40. }
  41. if (bitrate) {
  42. defaultsDictionary[kBitrateKey] = bitrate;
  43. }
  44. [[NSUserDefaults standardUserDefaults] registerDefaults:defaultsDictionary];
  45. }
  46. - (NSUserDefaults *)storage {
  47. if (!_storage) {
  48. _storage = [NSUserDefaults standardUserDefaults];
  49. }
  50. return _storage;
  51. }
  52. - (NSString *)videoResolution {
  53. return [self.storage objectForKey:kVideoResolutionKey];
  54. }
  55. - (void)setVideoResolution:(NSString *)resolution {
  56. [self.storage setObject:resolution forKey:kVideoResolutionKey];
  57. [self.storage synchronize];
  58. }
  59. - (NSData *)videoCodec {
  60. return [self.storage objectForKey:kVideoCodecKey];
  61. }
  62. - (void)setVideoCodec:(NSData *)videoCodec {
  63. [self.storage setObject:videoCodec forKey:kVideoCodecKey];
  64. [self.storage synchronize];
  65. }
  66. - (nullable NSNumber *)maxBitrate {
  67. return [self.storage objectForKey:kBitrateKey];
  68. }
  69. - (void)setMaxBitrate:(nullable NSNumber *)value {
  70. [self.storage setObject:value forKey:kBitrateKey];
  71. [self.storage synchronize];
  72. }
  73. - (BOOL)audioOnly {
  74. return [self.storage boolForKey:kAudioOnlyKey];
  75. }
  76. - (void)setAudioOnly:(BOOL)audioOnly {
  77. [self.storage setBool:audioOnly forKey:kAudioOnlyKey];
  78. [self.storage synchronize];
  79. }
  80. - (BOOL)createAecDump {
  81. return [self.storage boolForKey:kCreateAecDumpKey];
  82. }
  83. - (void)setCreateAecDump:(BOOL)createAecDump {
  84. [self.storage setBool:createAecDump forKey:kCreateAecDumpKey];
  85. [self.storage synchronize];
  86. }
  87. - (BOOL)useManualAudioConfig {
  88. return [self.storage boolForKey:kUseManualAudioConfigKey];
  89. }
  90. - (void)setUseManualAudioConfig:(BOOL)useManualAudioConfig {
  91. [self.storage setBool:useManualAudioConfig forKey:kUseManualAudioConfigKey];
  92. [self.storage synchronize];
  93. }
  94. @end
  95. NS_ASSUME_NONNULL_END