blob: 8ccc4388003368455171b416f37715a01b2e1f0c [file] [log] [blame]
denicijad17d5362016-11-02 02:56:09 -07001/*
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
denicija2256e042016-11-09 06:26:18 -080011#import "ARDSettingsStore.h"
denicijad17d5362016-11-02 02:56:09 -070012
sakalc522e752017-04-05 12:17:48 -070013static NSString *const kVideoResolutionKey = @"rtc_video_resolution_key";
sakal68b5df92017-03-17 09:01:59 -070014static NSString *const kVideoCodecKey = @"rtc_video_codec_key";
denicija9af2b602016-11-17 00:43:43 -080015static NSString *const kBitrateKey = @"rtc_max_bitrate_key";
Anders Carlssone1500582017-06-15 16:05:13 +020016static NSString *const kAudioOnlyKey = @"rtc_audio_only_key";
17static NSString *const kCreateAecDumpKey = @"rtc_create_aec_dump_key";
18static NSString *const kUseLevelControllerKey = @"rtc_use_level_controller_key";
19static NSString *const kUseManualAudioConfigKey = @"rtc_use_manual_audio_config_key";
denicijad17d5362016-11-02 02:56:09 -070020
21NS_ASSUME_NONNULL_BEGIN
denicija9af2b602016-11-17 00:43:43 -080022@interface ARDSettingsStore () {
23 NSUserDefaults *_storage;
24}
sakalc4adacf2017-03-28 01:22:48 -070025@property(nonatomic, strong, readonly) NSUserDefaults *storage;
denicija9af2b602016-11-17 00:43:43 -080026@end
27
denicija2256e042016-11-09 06:26:18 -080028@implementation ARDSettingsStore
denicijad17d5362016-11-02 02:56:09 -070029
Anders Carlssone1500582017-06-15 16:05:13 +020030+ (void)setDefaultsForVideoResolution:(NSString *)videoResolution
31 videoCodec:(NSString *)videoCodec
32 bitrate:(nullable NSNumber *)bitrate
33 audioOnly:(BOOL)audioOnly
34 createAecDump:(BOOL)createAecDump
35 useLevelController:(BOOL)useLevelController
36 useManualAudioConfig:(BOOL)useManualAudioConfig {
37 NSMutableDictionary<NSString *, id> *defaultsDictionary = [@{
38 kVideoResolutionKey : videoResolution,
39 kVideoCodecKey : videoCodec,
40 kAudioOnlyKey : @(audioOnly),
41 kCreateAecDumpKey : @(createAecDump),
42 kUseLevelControllerKey : @(useLevelController),
43 kUseManualAudioConfigKey : @(useManualAudioConfig)
44 } mutableCopy];
45 if (bitrate) {
46 [defaultsDictionary setObject:bitrate forKey:kBitrateKey];
47 }
48 [[NSUserDefaults standardUserDefaults] registerDefaults:defaultsDictionary];
49}
50
denicija9af2b602016-11-17 00:43:43 -080051- (NSUserDefaults *)storage {
52 if (!_storage) {
53 _storage = [NSUserDefaults standardUserDefaults];
54 }
55 return _storage;
denicijad17d5362016-11-02 02:56:09 -070056}
57
sakalc522e752017-04-05 12:17:48 -070058- (NSString *)videoResolution {
59 return [self.storage objectForKey:kVideoResolutionKey];
denicija9af2b602016-11-17 00:43:43 -080060}
61
sakalc522e752017-04-05 12:17:48 -070062- (void)setVideoResolution:(NSString *)resolution {
63 [self.storage setObject:resolution forKey:kVideoResolutionKey];
denicija9af2b602016-11-17 00:43:43 -080064 [self.storage synchronize];
65}
66
sakal68b5df92017-03-17 09:01:59 -070067- (NSString *)videoCodec {
68 return [self.storage objectForKey:kVideoCodecKey];
69}
70
71- (void)setVideoCodec:(NSString *)videoCodec {
72 [self.storage setObject:videoCodec forKey:kVideoCodecKey];
73 [self.storage synchronize];
74}
75
denicija9af2b602016-11-17 00:43:43 -080076- (nullable NSNumber *)maxBitrate {
77 return [self.storage objectForKey:kBitrateKey];
78}
79
80- (void)setMaxBitrate:(nullable NSNumber *)value {
81 [self.storage setObject:value forKey:kBitrateKey];
82 [self.storage synchronize];
denicijad17d5362016-11-02 02:56:09 -070083}
84
Anders Carlssone1500582017-06-15 16:05:13 +020085- (BOOL)audioOnly {
86 return [self.storage boolForKey:kAudioOnlyKey];
87}
88
89- (void)setAudioOnly:(BOOL)audioOnly {
90 [self.storage setBool:audioOnly forKey:kAudioOnlyKey];
91 [self.storage synchronize];
92}
93
94- (BOOL)createAecDump {
95 return [self.storage boolForKey:kCreateAecDumpKey];
96}
97
98- (void)setCreateAecDump:(BOOL)createAecDump {
99 [self.storage setBool:createAecDump forKey:kCreateAecDumpKey];
100 [self.storage synchronize];
101}
102
103- (BOOL)useLevelController {
104 return [self.storage boolForKey:kUseLevelControllerKey];
105}
106
107- (void)setUseLevelController:(BOOL)useLevelController {
108 [self.storage setBool:useLevelController forKey:kUseLevelControllerKey];
109 [self.storage synchronize];
110}
111
112- (BOOL)useManualAudioConfig {
113 return [self.storage boolForKey:kUseManualAudioConfigKey];
114}
115
116- (void)setUseManualAudioConfig:(BOOL)useManualAudioConfig {
117 [self.storage setBool:useManualAudioConfig forKey:kUseManualAudioConfigKey];
118 [self.storage synchronize];
119}
120
denicijad17d5362016-11-02 02:56:09 -0700121@end
122NS_ASSUME_NONNULL_END