denicija | d17d536 | 2016-11-02 02:56:09 -0700 | [diff] [blame] | 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 | |
denicija | 2256e04 | 2016-11-09 06:26:18 -0800 | [diff] [blame] | 11 | #import "ARDSettingsStore.h" |
denicija | d17d536 | 2016-11-02 02:56:09 -0700 | [diff] [blame] | 12 | |
denicija | 9af2b60 | 2016-11-17 00:43:43 -0800 | [diff] [blame] | 13 | static NSString *const kMediaConstraintsKey = @"rtc_video_resolution_media_constraints_key"; |
sakal | 68b5df9 | 2017-03-17 09:01:59 -0700 | [diff] [blame^] | 14 | static NSString *const kVideoCodecKey = @"rtc_video_codec_key"; |
denicija | 9af2b60 | 2016-11-17 00:43:43 -0800 | [diff] [blame] | 15 | static NSString *const kBitrateKey = @"rtc_max_bitrate_key"; |
denicija | d17d536 | 2016-11-02 02:56:09 -0700 | [diff] [blame] | 16 | |
| 17 | NS_ASSUME_NONNULL_BEGIN |
denicija | 9af2b60 | 2016-11-17 00:43:43 -0800 | [diff] [blame] | 18 | @interface ARDSettingsStore () { |
| 19 | NSUserDefaults *_storage; |
| 20 | } |
| 21 | @property(nonatomic, strong) NSUserDefaults *storage; |
| 22 | @end |
| 23 | |
denicija | 2256e04 | 2016-11-09 06:26:18 -0800 | [diff] [blame] | 24 | @implementation ARDSettingsStore |
denicija | d17d536 | 2016-11-02 02:56:09 -0700 | [diff] [blame] | 25 | |
denicija | 9af2b60 | 2016-11-17 00:43:43 -0800 | [diff] [blame] | 26 | - (NSUserDefaults *)storage { |
| 27 | if (!_storage) { |
| 28 | _storage = [NSUserDefaults standardUserDefaults]; |
| 29 | } |
| 30 | return _storage; |
denicija | d17d536 | 2016-11-02 02:56:09 -0700 | [diff] [blame] | 31 | } |
| 32 | |
denicija | 9af2b60 | 2016-11-17 00:43:43 -0800 | [diff] [blame] | 33 | - (nullable NSString *)videoResolutionConstraints { |
| 34 | return [self.storage objectForKey:kMediaConstraintsKey]; |
| 35 | } |
| 36 | |
| 37 | - (void)setVideoResolutionConstraints:(NSString *)constraintsString { |
| 38 | [self.storage setObject:constraintsString forKey:kMediaConstraintsKey]; |
| 39 | [self.storage synchronize]; |
| 40 | } |
| 41 | |
sakal | 68b5df9 | 2017-03-17 09:01:59 -0700 | [diff] [blame^] | 42 | - (NSString *)videoCodec { |
| 43 | return [self.storage objectForKey:kVideoCodecKey]; |
| 44 | } |
| 45 | |
| 46 | - (void)setVideoCodec:(NSString *)videoCodec { |
| 47 | [self.storage setObject:videoCodec forKey:kVideoCodecKey]; |
| 48 | [self.storage synchronize]; |
| 49 | } |
| 50 | |
denicija | 9af2b60 | 2016-11-17 00:43:43 -0800 | [diff] [blame] | 51 | - (nullable NSNumber *)maxBitrate { |
| 52 | return [self.storage objectForKey:kBitrateKey]; |
| 53 | } |
| 54 | |
| 55 | - (void)setMaxBitrate:(nullable NSNumber *)value { |
| 56 | [self.storage setObject:value forKey:kBitrateKey]; |
| 57 | [self.storage synchronize]; |
denicija | d17d536 | 2016-11-02 02:56:09 -0700 | [diff] [blame] | 58 | } |
| 59 | |
| 60 | @end |
| 61 | NS_ASSUME_NONNULL_END |