ARDSettingsStore.m 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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_key";
  13. static NSString *const kVideoDisabledDefaultKey = @"rtc_video_disabled_key";
  14. static NSString *const kBitrateKey = @"rtc_max_bitrate_key";
  15. NS_ASSUME_NONNULL_BEGIN
  16. @interface ARDSettingsStore () {
  17. NSUserDefaults *_storage;
  18. }
  19. @property(nonatomic, strong, readonly) NSUserDefaults *storage;
  20. @end
  21. @implementation ARDSettingsStore
  22. - (NSUserDefaults *)storage {
  23. if (!_storage) {
  24. _storage = [NSUserDefaults standardUserDefaults];
  25. }
  26. return _storage;
  27. }
  28. - (NSString *)videoResolution {
  29. return [self.storage objectForKey:kVideoResolutionKey];
  30. }
  31. - (void)setVideoResolution:(NSString *)resolution {
  32. [self.storage setObject:resolution forKey:kVideoResolutionKey];
  33. [self.storage synchronize];
  34. }
  35. - (NSString *)videoCodec {
  36. return [self.storage objectForKey:kVideoCodecKey];
  37. }
  38. - (void)setVideoCodec:(NSString *)videoCodec {
  39. [self.storage setObject:videoCodec forKey:kVideoCodecKey];
  40. [self.storage synchronize];
  41. }
  42. - (BOOL)videoDisabledDefault {
  43. return [self.storage boolForKey:kVideoDisabledDefaultKey];
  44. }
  45. - (void)setVideoDisabledDefault:(BOOL)videoDisabledDefault {
  46. [self.storage setBool:videoDisabledDefault forKey:kVideoDisabledDefaultKey];
  47. [self.storage synchronize];
  48. }
  49. - (nullable NSNumber *)maxBitrate {
  50. return [self.storage objectForKey:kBitrateKey];
  51. }
  52. - (void)setMaxBitrate:(nullable NSNumber *)value {
  53. [self.storage setObject:value forKey:kBitrateKey];
  54. [self.storage synchronize];
  55. }
  56. @end
  57. NS_ASSUME_NONNULL_END