Pass settings model to ARDAppClient instead of individual settings.

Moves settings model and related classes to code common for both iOS
and Mac.

BUG=webrtc:7177,webrtc:6494

Review-Url: https://codereview.webrtc.org/2770113004
Cr-Commit-Position: refs/heads/master@{#17408}
diff --git a/webrtc/examples/objc/AppRTCMobile/ios/ARDSettingsModel+Private.h b/webrtc/examples/objc/AppRTCMobile/ios/ARDSettingsModel+Private.h
deleted file mode 100644
index eba99d7..0000000
--- a/webrtc/examples/objc/AppRTCMobile/ios/ARDSettingsModel+Private.h
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- *  Copyright 2016 The WebRTC Project Authors. All rights reserved.
- *
- *  Use of this source code is governed by a BSD-style license
- *  that can be found in the LICENSE file in the root of the source
- *  tree. An additional intellectual property rights grant can be found
- *  in the file PATENTS.  All contributing project authors may
- *  be found in the AUTHORS file in the root of the source tree.
- */
-
-#import <Foundation/Foundation.h>
-#import "ARDSettingsModel.h"
-
-@class ARDSettingsStore;
-
-NS_ASSUME_NONNULL_BEGIN
-@interface ARDSettingsModel ()
-- (ARDSettingsStore *)settingsStore;
-- (nullable NSString *)currentVideoResolutionWidthFromStore;
-- (nullable NSString *)currentVideoResolutionHeightFromStore;
-@end
-NS_ASSUME_NONNULL_END
diff --git a/webrtc/examples/objc/AppRTCMobile/ios/ARDSettingsModel.h b/webrtc/examples/objc/AppRTCMobile/ios/ARDSettingsModel.h
deleted file mode 100644
index 0eb7b31..0000000
--- a/webrtc/examples/objc/AppRTCMobile/ios/ARDSettingsModel.h
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
- *  Copyright 2016 The WebRTC Project Authors. All rights reserved.
- *
- *  Use of this source code is governed by a BSD-style license
- *  that can be found in the LICENSE file in the root of the source
- *  tree. An additional intellectual property rights grant can be found
- *  in the file PATENTS.  All contributing project authors may
- *  be found in the AUTHORS file in the root of the source tree.
- */
-
-#import <Foundation/Foundation.h>
-
-NS_ASSUME_NONNULL_BEGIN
-/**
- * Model class for user defined settings.
- *
- * Currently used for streaming media constraints and bitrate only.
- * In future audio media constraints support can be added as well.
- * Offers list of avaliable video resolutions that can construct streaming media constraint.
- * Exposes methods for reading and storing media constraints from persistent store.
- * Also translates current user defined media constraint into RTCMediaConstraints
- * dictionary.
- */
-@interface ARDSettingsModel : NSObject
-
-/**
- * Returns array of available capture resoultions.
- *
- * The capture resolutions are represented as strings in the following format
- * [width]x[height]
- */
-- (NSArray<NSString *> *)availableVideoResoultionsMediaConstraints;
-
-/**
- * Returns current video resolution media constraint string.
- * If no constraint is in store, default value of 640x480 is returned.
- * When defaulting to value, the default is saved in store for consistency reasons.
- */
-- (NSString *)currentVideoResoultionConstraintFromStore;
-
-/**
- * Stores the provided video resolution media constraint string into the store.
- *
- * If the provided constraint is no part of the available video resolutions
- * the store operation will not be executed and NO will be returned.
- * @param constraint the string to be stored.
- * @return YES/NO depending on success.
- */
-- (BOOL)storeVideoResoultionConstraint:(NSString *)constraint;
-
-/**
- * Returns array of available video codecs.
- */
-- (NSArray<NSString *> *)availableVideoCodecs;
-
-/**
- * Returns current video codec setting from store if present.
- */
-- (NSString *)currentVideoCodecSettingFromStore;
-
-/**
- * Stores the provided video codec setting into the store.
- *
- * If the provided constraint is not part of the available video codecs
- * the store operation will not be executed and NO will be returned.
- * @param video codec settings the string to be stored.
- * @return YES/NO depending on success.
- */
-- (BOOL)storeVideoCodecSetting:(NSString *)videoCodec;
-
-/**
- * Converts the current media constraints from store into dictionary with RTCMediaConstraints
- * values.
- *
- * @return NSDictionary with RTC width and height parameters
- */
-- (nullable NSDictionary *)currentMediaConstraintFromStoreAsRTCDictionary;
-
-/**
- * Returns current max bitrate setting from store if present.
- */
-- (nullable NSNumber *)currentMaxBitrateSettingFromStore;
-
-/**
- * Stores the provided bitrate value into the store.
- *
- * @param bitrate NSNumber representation of the max bitrate value.
- */
-- (void)storeMaxBitrateSetting:(nullable NSNumber *)bitrate;
-
-@end
-NS_ASSUME_NONNULL_END
diff --git a/webrtc/examples/objc/AppRTCMobile/ios/ARDSettingsModel.m b/webrtc/examples/objc/AppRTCMobile/ios/ARDSettingsModel.m
deleted file mode 100644
index 7514689..0000000
--- a/webrtc/examples/objc/AppRTCMobile/ios/ARDSettingsModel.m
+++ /dev/null
@@ -1,141 +0,0 @@
-/*
- *  Copyright 2016 The WebRTC Project Authors. All rights reserved.
- *
- *  Use of this source code is governed by a BSD-style license
- *  that can be found in the LICENSE file in the root of the source
- *  tree. An additional intellectual property rights grant can be found
- *  in the file PATENTS.  All contributing project authors may
- *  be found in the AUTHORS file in the root of the source tree.
- */
-
-#import "ARDSettingsModel+Private.h"
-#import "ARDSettingsStore.h"
-#import "WebRTC/RTCMediaConstraints.h"
-
-NS_ASSUME_NONNULL_BEGIN
-static NSArray<NSString *> *videoResolutionsStaticValues() {
-  return @[ @"640x480", @"960x540", @"1280x720" ];
-}
-
-static NSArray<NSString *> *videoCodecsStaticValues() {
-  return @[ @"H264", @"VP8", @"VP9" ];
-}
-
-@interface ARDSettingsModel () {
-  ARDSettingsStore *_settingsStore;
-}
-@end
-
-@implementation ARDSettingsModel
-
-- (NSArray<NSString *> *)availableVideoResoultionsMediaConstraints {
-  return videoResolutionsStaticValues();
-}
-
-- (NSString *)currentVideoResoultionConstraintFromStore {
-  NSString *constraint = [[self settingsStore] videoResolutionConstraints];
-  if (!constraint) {
-    constraint = [self defaultVideoResolutionMediaConstraint];
-    // To ensure consistency add the default to the store.
-    [[self settingsStore] setVideoResolutionConstraints:constraint];
-  }
-  return constraint;
-}
-
-- (BOOL)storeVideoResoultionConstraint:(NSString *)constraint {
-  if (![[self availableVideoResoultionsMediaConstraints] containsObject:constraint]) {
-    return NO;
-  }
-  [[self settingsStore] setVideoResolutionConstraints:constraint];
-  return YES;
-}
-
-- (NSArray<NSString *> *)availableVideoCodecs {
-  return videoCodecsStaticValues();
-}
-
-- (NSString *)currentVideoCodecSettingFromStore {
-  NSString *videoCodec = [[self settingsStore] videoCodec];
-  if (!videoCodec) {
-    videoCodec = [self defaultVideoCodecSetting];
-    [[self settingsStore] setVideoCodec:videoCodec];
-  }
-  return videoCodec;
-}
-
-- (BOOL)storeVideoCodecSetting:(NSString *)videoCodec {
-  if (![[self availableVideoCodecs] containsObject:videoCodec]) {
-    return NO;
-  }
-  [[self settingsStore] setVideoCodec:videoCodec];
-  return YES;
-}
-
-- (nullable NSNumber *)currentMaxBitrateSettingFromStore {
-  return [[self settingsStore] maxBitrate];
-}
-
-- (void)storeMaxBitrateSetting:(nullable NSNumber *)bitrate {
-  [[self settingsStore] setMaxBitrate:bitrate];
-}
-
-#pragma mark - Testable
-
-- (ARDSettingsStore *)settingsStore {
-  if (!_settingsStore) {
-    _settingsStore = [[ARDSettingsStore alloc] init];
-  }
-  return _settingsStore;
-}
-
-- (nullable NSString *)currentVideoResolutionWidthFromStore {
-  NSString *mediaConstraintFromStore = [self currentVideoResoultionConstraintFromStore];
-
-  return [self videoResolutionComponentAtIndex:0 inConstraintsString:mediaConstraintFromStore];
-}
-
-- (nullable NSString *)currentVideoResolutionHeightFromStore {
-  NSString *mediaConstraintFromStore = [self currentVideoResoultionConstraintFromStore];
-  return [self videoResolutionComponentAtIndex:1 inConstraintsString:mediaConstraintFromStore];
-}
-
-#pragma mark -
-
-- (NSString *)defaultVideoResolutionMediaConstraint {
-  return videoResolutionsStaticValues()[0];
-}
-
-- (nullable NSString *)videoResolutionComponentAtIndex:(int)index
-                                   inConstraintsString:(NSString *)constraint {
-  if (index != 0 && index != 1) {
-    return nil;
-  }
-  NSArray *components = [constraint componentsSeparatedByString:@"x"];
-  if (components.count != 2) {
-    return nil;
-  }
-  return components[index];
-}
-
-- (NSString *)defaultVideoCodecSetting {
-  return videoCodecsStaticValues()[0];
-}
-
-#pragma mark - Conversion to RTCMediaConstraints
-
-- (nullable NSDictionary *)currentMediaConstraintFromStoreAsRTCDictionary {
-  NSDictionary *mediaConstraintsDictionary = nil;
-
-  NSString *widthConstraint = [self currentVideoResolutionWidthFromStore];
-  NSString *heightConstraint = [self currentVideoResolutionHeightFromStore];
-  if (widthConstraint && heightConstraint) {
-    mediaConstraintsDictionary = @{
-      kRTCMediaConstraintsMinWidth : widthConstraint,
-      kRTCMediaConstraintsMinHeight : heightConstraint
-    };
-  }
-  return mediaConstraintsDictionary;
-}
-
-@end
-NS_ASSUME_NONNULL_END
diff --git a/webrtc/examples/objc/AppRTCMobile/ios/ARDSettingsStore.h b/webrtc/examples/objc/AppRTCMobile/ios/ARDSettingsStore.h
deleted file mode 100644
index b82ec70..0000000
--- a/webrtc/examples/objc/AppRTCMobile/ios/ARDSettingsStore.h
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- *  Copyright 2016 The WebRTC Project Authors. All rights reserved.
- *
- *  Use of this source code is governed by a BSD-style license
- *  that can be found in the LICENSE file in the root of the source
- *  tree. An additional intellectual property rights grant can be found
- *  in the file PATENTS.  All contributing project authors may
- *  be found in the AUTHORS file in the root of the source tree.
- */
-
-#import <Foundation/Foundation.h>
-
-NS_ASSUME_NONNULL_BEGIN
-
-/**
- * Light-weight persistent store for user settings.
- *
- * It will persist between application launches and application updates.
- */
-@interface ARDSettingsStore : NSObject
-
-@property(nonatomic) NSString* videoCodec;
-
-/**
- * Returns current video resolution media constraint string stored in the store.
- */
-- (nullable NSString *)videoResolutionConstraints;
-
-/**
- * Stores the provided value as video resolution media constraint.
- * @param value the string to be stored
- */
-- (void)setVideoResolutionConstraints:(NSString *)value;
-
-/**
- * Returns current max bitrate number stored in the store.
- */
-- (nullable NSNumber *)maxBitrate;
-
-/**
- * Stores the provided value as maximum bitrate setting.
- * @param value the number to be stored
- */
-- (void)setMaxBitrate:(nullable NSNumber *)value;
-
-@end
-NS_ASSUME_NONNULL_END
diff --git a/webrtc/examples/objc/AppRTCMobile/ios/ARDSettingsStore.m b/webrtc/examples/objc/AppRTCMobile/ios/ARDSettingsStore.m
deleted file mode 100644
index c05df44..0000000
--- a/webrtc/examples/objc/AppRTCMobile/ios/ARDSettingsStore.m
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- *  Copyright 2016 The WebRTC Project Authors. All rights reserved.
- *
- *  Use of this source code is governed by a BSD-style license
- *  that can be found in the LICENSE file in the root of the source
- *  tree. An additional intellectual property rights grant can be found
- *  in the file PATENTS.  All contributing project authors may
- *  be found in the AUTHORS file in the root of the source tree.
- */
-
-#import "ARDSettingsStore.h"
-
-static NSString *const kMediaConstraintsKey = @"rtc_video_resolution_media_constraints_key";
-static NSString *const kVideoCodecKey = @"rtc_video_codec_key";
-static NSString *const kBitrateKey = @"rtc_max_bitrate_key";
-
-NS_ASSUME_NONNULL_BEGIN
-@interface ARDSettingsStore () {
-  NSUserDefaults *_storage;
-}
-@property(nonatomic, strong) NSUserDefaults *storage;
-@end
-
-@implementation ARDSettingsStore
-
-- (NSUserDefaults *)storage {
-  if (!_storage) {
-    _storage = [NSUserDefaults standardUserDefaults];
-  }
-  return _storage;
-}
-
-- (nullable NSString *)videoResolutionConstraints {
-  return [self.storage objectForKey:kMediaConstraintsKey];
-}
-
-- (void)setVideoResolutionConstraints:(NSString *)constraintsString {
-  [self.storage setObject:constraintsString forKey:kMediaConstraintsKey];
-  [self.storage synchronize];
-}
-
-- (NSString *)videoCodec {
-  return [self.storage objectForKey:kVideoCodecKey];
-}
-
-- (void)setVideoCodec:(NSString *)videoCodec {
-  [self.storage setObject:videoCodec forKey:kVideoCodecKey];
-  [self.storage synchronize];
-}
-
-- (nullable NSNumber *)maxBitrate {
-  return [self.storage objectForKey:kBitrateKey];
-}
-
-- (void)setMaxBitrate:(nullable NSNumber *)value {
-  [self.storage setObject:value forKey:kBitrateKey];
-  [self.storage synchronize];
-}
-
-@end
-NS_ASSUME_NONNULL_END
diff --git a/webrtc/examples/objc/AppRTCMobile/ios/ARDVideoCallViewController.m b/webrtc/examples/objc/AppRTCMobile/ios/ARDVideoCallViewController.m
index f58ee66..d1ae3f9 100644
--- a/webrtc/examples/objc/AppRTCMobile/ios/ARDVideoCallViewController.m
+++ b/webrtc/examples/objc/AppRTCMobile/ios/ARDVideoCallViewController.m
@@ -45,17 +45,10 @@
                    delegate:(id<ARDVideoCallViewControllerDelegate>)delegate {
   if (self = [super init]) {
     ARDSettingsModel *settingsModel = [[ARDSettingsModel alloc] init];
-    NSString* videoCodec = [settingsModel currentVideoCodecSettingFromStore];
     _delegate = delegate;
-    _client = [[ARDAppClient alloc] initWithDelegate:self
-                                    preferVideoCodec:videoCodec];
-    RTCMediaConstraints *cameraConstraints = [[RTCMediaConstraints alloc]
-        initWithMandatoryConstraints:nil
-                 optionalConstraints:[settingsModel
-                                         currentMediaConstraintFromStoreAsRTCDictionary]];
-    [_client setMaxBitrate:[settingsModel currentMaxBitrateSettingFromStore]];
-    [_client setCameraConstraints:cameraConstraints];
+    _client = [[ARDAppClient alloc] initWithDelegate:self];
     [_client connectToRoomWithId:room
+                        settings:settingsModel
                       isLoopback:isLoopback
                      isAudioOnly:isAudioOnly
                shouldMakeAecDump:shouldMakeAecDump