1*d9f75844SAndroid Build Coastguard Worker/* 2*d9f75844SAndroid Build Coastguard Worker * Copyright 2016 The WebRTC Project Authors. All rights reserved. 3*d9f75844SAndroid Build Coastguard Worker * 4*d9f75844SAndroid Build Coastguard Worker * Use of this source code is governed by a BSD-style license 5*d9f75844SAndroid Build Coastguard Worker * that can be found in the LICENSE file in the root of the source 6*d9f75844SAndroid Build Coastguard Worker * tree. An additional intellectual property rights grant can be found 7*d9f75844SAndroid Build Coastguard Worker * in the file PATENTS. All contributing project authors may 8*d9f75844SAndroid Build Coastguard Worker * be found in the AUTHORS file in the root of the source tree. 9*d9f75844SAndroid Build Coastguard Worker */ 10*d9f75844SAndroid Build Coastguard Worker 11*d9f75844SAndroid Build Coastguard Worker#import "ARDSettingsViewController.h" 12*d9f75844SAndroid Build Coastguard Worker#import "ARDSettingsModel.h" 13*d9f75844SAndroid Build Coastguard Worker#import "RTCVideoCodecInfo+HumanReadable.h" 14*d9f75844SAndroid Build Coastguard Worker 15*d9f75844SAndroid Build Coastguard WorkerNS_ASSUME_NONNULL_BEGIN 16*d9f75844SAndroid Build Coastguard Worker 17*d9f75844SAndroid Build Coastguard Workertypedef NS_ENUM(int, ARDSettingsSections) { 18*d9f75844SAndroid Build Coastguard Worker ARDSettingsSectionAudioSettings = 0, 19*d9f75844SAndroid Build Coastguard Worker ARDSettingsSectionVideoResolution, 20*d9f75844SAndroid Build Coastguard Worker ARDSettingsSectionVideoCodec, 21*d9f75844SAndroid Build Coastguard Worker ARDSettingsSectionBitRate, 22*d9f75844SAndroid Build Coastguard Worker}; 23*d9f75844SAndroid Build Coastguard Worker 24*d9f75844SAndroid Build Coastguard Workertypedef NS_ENUM(int, ARDAudioSettingsOptions) { 25*d9f75844SAndroid Build Coastguard Worker ARDAudioSettingsAudioOnly = 0, 26*d9f75844SAndroid Build Coastguard Worker ARDAudioSettingsCreateAecDump, 27*d9f75844SAndroid Build Coastguard Worker ARDAudioSettingsUseManualAudioConfig, 28*d9f75844SAndroid Build Coastguard Worker}; 29*d9f75844SAndroid Build Coastguard Worker 30*d9f75844SAndroid Build Coastguard Worker@interface ARDSettingsViewController () <UITextFieldDelegate> { 31*d9f75844SAndroid Build Coastguard Worker ARDSettingsModel *_settingsModel; 32*d9f75844SAndroid Build Coastguard Worker} 33*d9f75844SAndroid Build Coastguard Worker 34*d9f75844SAndroid Build Coastguard Worker@end 35*d9f75844SAndroid Build Coastguard Worker 36*d9f75844SAndroid Build Coastguard Worker@implementation ARDSettingsViewController 37*d9f75844SAndroid Build Coastguard Worker 38*d9f75844SAndroid Build Coastguard Worker- (instancetype)initWithStyle:(UITableViewStyle)style 39*d9f75844SAndroid Build Coastguard Worker settingsModel:(ARDSettingsModel *)settingsModel { 40*d9f75844SAndroid Build Coastguard Worker self = [super initWithStyle:style]; 41*d9f75844SAndroid Build Coastguard Worker if (self) { 42*d9f75844SAndroid Build Coastguard Worker _settingsModel = settingsModel; 43*d9f75844SAndroid Build Coastguard Worker } 44*d9f75844SAndroid Build Coastguard Worker return self; 45*d9f75844SAndroid Build Coastguard Worker} 46*d9f75844SAndroid Build Coastguard Worker 47*d9f75844SAndroid Build Coastguard Worker#pragma mark - View lifecycle 48*d9f75844SAndroid Build Coastguard Worker 49*d9f75844SAndroid Build Coastguard Worker- (void)viewDidLoad { 50*d9f75844SAndroid Build Coastguard Worker [super viewDidLoad]; 51*d9f75844SAndroid Build Coastguard Worker self.title = @"Settings"; 52*d9f75844SAndroid Build Coastguard Worker [self addDoneBarButton]; 53*d9f75844SAndroid Build Coastguard Worker} 54*d9f75844SAndroid Build Coastguard Worker 55*d9f75844SAndroid Build Coastguard Worker- (void)viewWillAppear:(BOOL)animated { 56*d9f75844SAndroid Build Coastguard Worker [super viewWillAppear:animated]; 57*d9f75844SAndroid Build Coastguard Worker} 58*d9f75844SAndroid Build Coastguard Worker 59*d9f75844SAndroid Build Coastguard Worker#pragma mark - Data source 60*d9f75844SAndroid Build Coastguard Worker 61*d9f75844SAndroid Build Coastguard Worker- (NSArray<NSString *> *)videoResolutionArray { 62*d9f75844SAndroid Build Coastguard Worker return [_settingsModel availableVideoResolutions]; 63*d9f75844SAndroid Build Coastguard Worker} 64*d9f75844SAndroid Build Coastguard Worker 65*d9f75844SAndroid Build Coastguard Worker- (NSArray<RTC_OBJC_TYPE(RTCVideoCodecInfo) *> *)videoCodecArray { 66*d9f75844SAndroid Build Coastguard Worker return [_settingsModel availableVideoCodecs]; 67*d9f75844SAndroid Build Coastguard Worker} 68*d9f75844SAndroid Build Coastguard Worker 69*d9f75844SAndroid Build Coastguard Worker#pragma mark - 70*d9f75844SAndroid Build Coastguard Worker 71*d9f75844SAndroid Build Coastguard Worker- (void)addDoneBarButton { 72*d9f75844SAndroid Build Coastguard Worker UIBarButtonItem *barItem = 73*d9f75844SAndroid Build Coastguard Worker [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone 74*d9f75844SAndroid Build Coastguard Worker target:self 75*d9f75844SAndroid Build Coastguard Worker action:@selector(dismissModally:)]; 76*d9f75844SAndroid Build Coastguard Worker self.navigationItem.leftBarButtonItem = barItem; 77*d9f75844SAndroid Build Coastguard Worker} 78*d9f75844SAndroid Build Coastguard Worker 79*d9f75844SAndroid Build Coastguard Worker#pragma mark - Dismissal of view controller 80*d9f75844SAndroid Build Coastguard Worker 81*d9f75844SAndroid Build Coastguard Worker- (void)dismissModally:(id)sender { 82*d9f75844SAndroid Build Coastguard Worker [self dismissViewControllerAnimated:YES completion:nil]; 83*d9f75844SAndroid Build Coastguard Worker} 84*d9f75844SAndroid Build Coastguard Worker 85*d9f75844SAndroid Build Coastguard Worker#pragma mark - Table view data source 86*d9f75844SAndroid Build Coastguard Worker 87*d9f75844SAndroid Build Coastguard Worker- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { 88*d9f75844SAndroid Build Coastguard Worker return 4; 89*d9f75844SAndroid Build Coastguard Worker} 90*d9f75844SAndroid Build Coastguard Worker 91*d9f75844SAndroid Build Coastguard Worker- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { 92*d9f75844SAndroid Build Coastguard Worker switch (section) { 93*d9f75844SAndroid Build Coastguard Worker case ARDSettingsSectionAudioSettings: 94*d9f75844SAndroid Build Coastguard Worker return 3; 95*d9f75844SAndroid Build Coastguard Worker case ARDSettingsSectionVideoResolution: 96*d9f75844SAndroid Build Coastguard Worker return self.videoResolutionArray.count; 97*d9f75844SAndroid Build Coastguard Worker case ARDSettingsSectionVideoCodec: 98*d9f75844SAndroid Build Coastguard Worker return self.videoCodecArray.count; 99*d9f75844SAndroid Build Coastguard Worker default: 100*d9f75844SAndroid Build Coastguard Worker return 1; 101*d9f75844SAndroid Build Coastguard Worker } 102*d9f75844SAndroid Build Coastguard Worker} 103*d9f75844SAndroid Build Coastguard Worker 104*d9f75844SAndroid Build Coastguard Worker#pragma mark - Table view delegate helpers 105*d9f75844SAndroid Build Coastguard Worker 106*d9f75844SAndroid Build Coastguard Worker- (void)removeAllAccessories:(UITableView *)tableView 107*d9f75844SAndroid Build Coastguard Worker inSection:(int)section 108*d9f75844SAndroid Build Coastguard Worker{ 109*d9f75844SAndroid Build Coastguard Worker for (int i = 0; i < [tableView numberOfRowsInSection:section]; i++) { 110*d9f75844SAndroid Build Coastguard Worker NSIndexPath *rowPath = [NSIndexPath indexPathForRow:i inSection:section]; 111*d9f75844SAndroid Build Coastguard Worker UITableViewCell *cell = [tableView cellForRowAtIndexPath:rowPath]; 112*d9f75844SAndroid Build Coastguard Worker cell.accessoryType = UITableViewCellAccessoryNone; 113*d9f75844SAndroid Build Coastguard Worker } 114*d9f75844SAndroid Build Coastguard Worker} 115*d9f75844SAndroid Build Coastguard Worker 116*d9f75844SAndroid Build Coastguard Worker- (void)tableView:(UITableView *)tableView 117*d9f75844SAndroid Build Coastguard WorkerupdateListSelectionAtIndexPath:(NSIndexPath *)indexPath 118*d9f75844SAndroid Build Coastguard Worker inSection:(int)section { 119*d9f75844SAndroid Build Coastguard Worker [self removeAllAccessories:tableView inSection:section]; 120*d9f75844SAndroid Build Coastguard Worker UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath]; 121*d9f75844SAndroid Build Coastguard Worker cell.accessoryType = UITableViewCellAccessoryCheckmark; 122*d9f75844SAndroid Build Coastguard Worker [tableView deselectRowAtIndexPath:indexPath animated:YES]; 123*d9f75844SAndroid Build Coastguard Worker} 124*d9f75844SAndroid Build Coastguard Worker 125*d9f75844SAndroid Build Coastguard Worker#pragma mark - Table view delegate 126*d9f75844SAndroid Build Coastguard Worker 127*d9f75844SAndroid Build Coastguard Worker- (nullable NSString *)tableView:(UITableView *)tableView 128*d9f75844SAndroid Build Coastguard Worker titleForHeaderInSection:(NSInteger)section { 129*d9f75844SAndroid Build Coastguard Worker switch (section) { 130*d9f75844SAndroid Build Coastguard Worker case ARDSettingsSectionAudioSettings: 131*d9f75844SAndroid Build Coastguard Worker return @"Audio"; 132*d9f75844SAndroid Build Coastguard Worker case ARDSettingsSectionVideoResolution: 133*d9f75844SAndroid Build Coastguard Worker return @"Video resolution"; 134*d9f75844SAndroid Build Coastguard Worker case ARDSettingsSectionVideoCodec: 135*d9f75844SAndroid Build Coastguard Worker return @"Video codec"; 136*d9f75844SAndroid Build Coastguard Worker case ARDSettingsSectionBitRate: 137*d9f75844SAndroid Build Coastguard Worker return @"Maximum bitrate"; 138*d9f75844SAndroid Build Coastguard Worker default: 139*d9f75844SAndroid Build Coastguard Worker return @""; 140*d9f75844SAndroid Build Coastguard Worker } 141*d9f75844SAndroid Build Coastguard Worker} 142*d9f75844SAndroid Build Coastguard Worker 143*d9f75844SAndroid Build Coastguard Worker- (UITableViewCell *)tableView:(UITableView *)tableView 144*d9f75844SAndroid Build Coastguard Worker cellForRowAtIndexPath:(NSIndexPath *)indexPath { 145*d9f75844SAndroid Build Coastguard Worker switch (indexPath.section) { 146*d9f75844SAndroid Build Coastguard Worker case ARDSettingsSectionAudioSettings: 147*d9f75844SAndroid Build Coastguard Worker return [self audioSettingsTableViewCellForTableView:tableView atIndexPath:indexPath]; 148*d9f75844SAndroid Build Coastguard Worker 149*d9f75844SAndroid Build Coastguard Worker case ARDSettingsSectionVideoResolution: 150*d9f75844SAndroid Build Coastguard Worker return [self videoResolutionTableViewCellForTableView:tableView atIndexPath:indexPath]; 151*d9f75844SAndroid Build Coastguard Worker 152*d9f75844SAndroid Build Coastguard Worker case ARDSettingsSectionVideoCodec: 153*d9f75844SAndroid Build Coastguard Worker return [self videoCodecTableViewCellForTableView:tableView atIndexPath:indexPath]; 154*d9f75844SAndroid Build Coastguard Worker 155*d9f75844SAndroid Build Coastguard Worker case ARDSettingsSectionBitRate: 156*d9f75844SAndroid Build Coastguard Worker return [self bitrateTableViewCellForTableView:tableView atIndexPath:indexPath]; 157*d9f75844SAndroid Build Coastguard Worker 158*d9f75844SAndroid Build Coastguard Worker default: 159*d9f75844SAndroid Build Coastguard Worker return [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault 160*d9f75844SAndroid Build Coastguard Worker reuseIdentifier:@"identifier"]; 161*d9f75844SAndroid Build Coastguard Worker } 162*d9f75844SAndroid Build Coastguard Worker} 163*d9f75844SAndroid Build Coastguard Worker 164*d9f75844SAndroid Build Coastguard Worker- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { 165*d9f75844SAndroid Build Coastguard Worker switch (indexPath.section) { 166*d9f75844SAndroid Build Coastguard Worker case ARDSettingsSectionVideoResolution: 167*d9f75844SAndroid Build Coastguard Worker [self tableView:tableView disSelectVideoResolutionAtIndex:indexPath]; 168*d9f75844SAndroid Build Coastguard Worker break; 169*d9f75844SAndroid Build Coastguard Worker 170*d9f75844SAndroid Build Coastguard Worker case ARDSettingsSectionVideoCodec: 171*d9f75844SAndroid Build Coastguard Worker [self tableView:tableView didSelectVideoCodecCellAtIndexPath:indexPath]; 172*d9f75844SAndroid Build Coastguard Worker break; 173*d9f75844SAndroid Build Coastguard Worker } 174*d9f75844SAndroid Build Coastguard Worker} 175*d9f75844SAndroid Build Coastguard Worker 176*d9f75844SAndroid Build Coastguard Worker#pragma mark - Table view delegate(Video Resolution) 177*d9f75844SAndroid Build Coastguard Worker 178*d9f75844SAndroid Build Coastguard Worker- (UITableViewCell *)videoResolutionTableViewCellForTableView:(UITableView *)tableView 179*d9f75844SAndroid Build Coastguard Worker atIndexPath:(NSIndexPath *)indexPath { 180*d9f75844SAndroid Build Coastguard Worker NSString *dequeueIdentifier = @"ARDSettingsVideoResolutionViewCellIdentifier"; 181*d9f75844SAndroid Build Coastguard Worker UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:dequeueIdentifier]; 182*d9f75844SAndroid Build Coastguard Worker if (!cell) { 183*d9f75844SAndroid Build Coastguard Worker cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault 184*d9f75844SAndroid Build Coastguard Worker reuseIdentifier:dequeueIdentifier]; 185*d9f75844SAndroid Build Coastguard Worker } 186*d9f75844SAndroid Build Coastguard Worker NSString *resolution = self.videoResolutionArray[indexPath.row]; 187*d9f75844SAndroid Build Coastguard Worker cell.textLabel.text = resolution; 188*d9f75844SAndroid Build Coastguard Worker if ([resolution isEqualToString:[_settingsModel currentVideoResolutionSettingFromStore]]) { 189*d9f75844SAndroid Build Coastguard Worker cell.accessoryType = UITableViewCellAccessoryCheckmark; 190*d9f75844SAndroid Build Coastguard Worker } else { 191*d9f75844SAndroid Build Coastguard Worker cell.accessoryType = UITableViewCellAccessoryNone; 192*d9f75844SAndroid Build Coastguard Worker } 193*d9f75844SAndroid Build Coastguard Worker 194*d9f75844SAndroid Build Coastguard Worker return cell; 195*d9f75844SAndroid Build Coastguard Worker} 196*d9f75844SAndroid Build Coastguard Worker 197*d9f75844SAndroid Build Coastguard Worker- (void)tableView:(UITableView *)tableView 198*d9f75844SAndroid Build Coastguard Worker disSelectVideoResolutionAtIndex:(NSIndexPath *)indexPath { 199*d9f75844SAndroid Build Coastguard Worker [self tableView:tableView 200*d9f75844SAndroid Build Coastguard Worker updateListSelectionAtIndexPath:indexPath 201*d9f75844SAndroid Build Coastguard Worker inSection:ARDSettingsSectionVideoResolution]; 202*d9f75844SAndroid Build Coastguard Worker 203*d9f75844SAndroid Build Coastguard Worker NSString *videoResolution = self.videoResolutionArray[indexPath.row]; 204*d9f75844SAndroid Build Coastguard Worker [_settingsModel storeVideoResolutionSetting:videoResolution]; 205*d9f75844SAndroid Build Coastguard Worker} 206*d9f75844SAndroid Build Coastguard Worker 207*d9f75844SAndroid Build Coastguard Worker#pragma mark - Table view delegate(Video Codec) 208*d9f75844SAndroid Build Coastguard Worker 209*d9f75844SAndroid Build Coastguard Worker- (UITableViewCell *)videoCodecTableViewCellForTableView:(UITableView *)tableView 210*d9f75844SAndroid Build Coastguard Worker atIndexPath:(NSIndexPath *)indexPath { 211*d9f75844SAndroid Build Coastguard Worker NSString *dequeueIdentifier = @"ARDSettingsVideoCodecCellIdentifier"; 212*d9f75844SAndroid Build Coastguard Worker UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:dequeueIdentifier]; 213*d9f75844SAndroid Build Coastguard Worker if (!cell) { 214*d9f75844SAndroid Build Coastguard Worker cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault 215*d9f75844SAndroid Build Coastguard Worker reuseIdentifier:dequeueIdentifier]; 216*d9f75844SAndroid Build Coastguard Worker } 217*d9f75844SAndroid Build Coastguard Worker RTC_OBJC_TYPE(RTCVideoCodecInfo) *codec = self.videoCodecArray[indexPath.row]; 218*d9f75844SAndroid Build Coastguard Worker cell.textLabel.text = [codec humanReadableDescription]; 219*d9f75844SAndroid Build Coastguard Worker if ([codec isEqualToCodecInfo:[_settingsModel currentVideoCodecSettingFromStore]]) { 220*d9f75844SAndroid Build Coastguard Worker cell.accessoryType = UITableViewCellAccessoryCheckmark; 221*d9f75844SAndroid Build Coastguard Worker } else { 222*d9f75844SAndroid Build Coastguard Worker cell.accessoryType = UITableViewCellAccessoryNone; 223*d9f75844SAndroid Build Coastguard Worker } 224*d9f75844SAndroid Build Coastguard Worker 225*d9f75844SAndroid Build Coastguard Worker return cell; 226*d9f75844SAndroid Build Coastguard Worker} 227*d9f75844SAndroid Build Coastguard Worker 228*d9f75844SAndroid Build Coastguard Worker- (void)tableView:(UITableView *)tableView 229*d9f75844SAndroid Build Coastguard Worker didSelectVideoCodecCellAtIndexPath:(NSIndexPath *)indexPath { 230*d9f75844SAndroid Build Coastguard Worker [self tableView:tableView 231*d9f75844SAndroid Build Coastguard Worker updateListSelectionAtIndexPath:indexPath 232*d9f75844SAndroid Build Coastguard Worker inSection:ARDSettingsSectionVideoCodec]; 233*d9f75844SAndroid Build Coastguard Worker 234*d9f75844SAndroid Build Coastguard Worker RTC_OBJC_TYPE(RTCVideoCodecInfo) *videoCodec = self.videoCodecArray[indexPath.row]; 235*d9f75844SAndroid Build Coastguard Worker [_settingsModel storeVideoCodecSetting:videoCodec]; 236*d9f75844SAndroid Build Coastguard Worker} 237*d9f75844SAndroid Build Coastguard Worker 238*d9f75844SAndroid Build Coastguard Worker#pragma mark - Table view delegate(Bitrate) 239*d9f75844SAndroid Build Coastguard Worker 240*d9f75844SAndroid Build Coastguard Worker- (UITableViewCell *)bitrateTableViewCellForTableView:(UITableView *)tableView 241*d9f75844SAndroid Build Coastguard Worker atIndexPath:(NSIndexPath *)indexPath { 242*d9f75844SAndroid Build Coastguard Worker NSString *dequeueIdentifier = @"ARDSettingsBitrateCellIdentifier"; 243*d9f75844SAndroid Build Coastguard Worker UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:dequeueIdentifier]; 244*d9f75844SAndroid Build Coastguard Worker if (!cell) { 245*d9f75844SAndroid Build Coastguard Worker cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault 246*d9f75844SAndroid Build Coastguard Worker reuseIdentifier:dequeueIdentifier]; 247*d9f75844SAndroid Build Coastguard Worker 248*d9f75844SAndroid Build Coastguard Worker UITextField *textField = [[UITextField alloc] 249*d9f75844SAndroid Build Coastguard Worker initWithFrame:CGRectMake(10, 0, cell.bounds.size.width - 20, cell.bounds.size.height)]; 250*d9f75844SAndroid Build Coastguard Worker NSString *currentMaxBitrate = [_settingsModel currentMaxBitrateSettingFromStore].stringValue; 251*d9f75844SAndroid Build Coastguard Worker textField.text = currentMaxBitrate; 252*d9f75844SAndroid Build Coastguard Worker textField.placeholder = @"Enter max bit rate (kbps)"; 253*d9f75844SAndroid Build Coastguard Worker textField.keyboardType = UIKeyboardTypeNumberPad; 254*d9f75844SAndroid Build Coastguard Worker textField.delegate = self; 255*d9f75844SAndroid Build Coastguard Worker 256*d9f75844SAndroid Build Coastguard Worker // Numerical keyboards have no return button, we need to add one manually. 257*d9f75844SAndroid Build Coastguard Worker UIToolbar *numberToolbar = 258*d9f75844SAndroid Build Coastguard Worker [[UIToolbar alloc] initWithFrame:CGRectMake(0, 0, self.view.bounds.size.width, 50)]; 259*d9f75844SAndroid Build Coastguard Worker numberToolbar.items = @[ 260*d9f75844SAndroid Build Coastguard Worker [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace 261*d9f75844SAndroid Build Coastguard Worker target:nil 262*d9f75844SAndroid Build Coastguard Worker action:nil], 263*d9f75844SAndroid Build Coastguard Worker [[UIBarButtonItem alloc] initWithTitle:@"Apply" 264*d9f75844SAndroid Build Coastguard Worker style:UIBarButtonItemStyleDone 265*d9f75844SAndroid Build Coastguard Worker target:self 266*d9f75844SAndroid Build Coastguard Worker action:@selector(numberTextFieldDidEndEditing:)] 267*d9f75844SAndroid Build Coastguard Worker ]; 268*d9f75844SAndroid Build Coastguard Worker [numberToolbar sizeToFit]; 269*d9f75844SAndroid Build Coastguard Worker 270*d9f75844SAndroid Build Coastguard Worker textField.inputAccessoryView = numberToolbar; 271*d9f75844SAndroid Build Coastguard Worker [cell addSubview:textField]; 272*d9f75844SAndroid Build Coastguard Worker } 273*d9f75844SAndroid Build Coastguard Worker return cell; 274*d9f75844SAndroid Build Coastguard Worker} 275*d9f75844SAndroid Build Coastguard Worker 276*d9f75844SAndroid Build Coastguard Worker- (void)numberTextFieldDidEndEditing:(id)sender { 277*d9f75844SAndroid Build Coastguard Worker [self.view endEditing:YES]; 278*d9f75844SAndroid Build Coastguard Worker} 279*d9f75844SAndroid Build Coastguard Worker 280*d9f75844SAndroid Build Coastguard Worker- (void)textFieldDidEndEditing:(UITextField *)textField { 281*d9f75844SAndroid Build Coastguard Worker NSNumber *bitrateNumber = nil; 282*d9f75844SAndroid Build Coastguard Worker 283*d9f75844SAndroid Build Coastguard Worker if (textField.text.length != 0) { 284*d9f75844SAndroid Build Coastguard Worker bitrateNumber = [NSNumber numberWithInteger:textField.text.intValue]; 285*d9f75844SAndroid Build Coastguard Worker } 286*d9f75844SAndroid Build Coastguard Worker 287*d9f75844SAndroid Build Coastguard Worker [_settingsModel storeMaxBitrateSetting:bitrateNumber]; 288*d9f75844SAndroid Build Coastguard Worker} 289*d9f75844SAndroid Build Coastguard Worker 290*d9f75844SAndroid Build Coastguard Worker#pragma mark - Table view delegate(Audio settings) 291*d9f75844SAndroid Build Coastguard Worker 292*d9f75844SAndroid Build Coastguard Worker- (UITableViewCell *)audioSettingsTableViewCellForTableView:(UITableView *)tableView 293*d9f75844SAndroid Build Coastguard Worker atIndexPath:(NSIndexPath *)indexPath { 294*d9f75844SAndroid Build Coastguard Worker NSString *dequeueIdentifier = @"ARDSettingsAudioSettingsCellIdentifier"; 295*d9f75844SAndroid Build Coastguard Worker UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:dequeueIdentifier]; 296*d9f75844SAndroid Build Coastguard Worker if (!cell) { 297*d9f75844SAndroid Build Coastguard Worker cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault 298*d9f75844SAndroid Build Coastguard Worker reuseIdentifier:dequeueIdentifier]; 299*d9f75844SAndroid Build Coastguard Worker cell.selectionStyle = UITableViewCellSelectionStyleNone; 300*d9f75844SAndroid Build Coastguard Worker UISwitch *switchView = [[UISwitch alloc] initWithFrame:CGRectZero]; 301*d9f75844SAndroid Build Coastguard Worker switchView.tag = indexPath.row; 302*d9f75844SAndroid Build Coastguard Worker [switchView addTarget:self 303*d9f75844SAndroid Build Coastguard Worker action:@selector(audioSettingSwitchChanged:) 304*d9f75844SAndroid Build Coastguard Worker forControlEvents:UIControlEventValueChanged]; 305*d9f75844SAndroid Build Coastguard Worker cell.accessoryView = switchView; 306*d9f75844SAndroid Build Coastguard Worker } 307*d9f75844SAndroid Build Coastguard Worker 308*d9f75844SAndroid Build Coastguard Worker cell.textLabel.text = [self labelForAudioSettingAtIndexPathRow:indexPath.row]; 309*d9f75844SAndroid Build Coastguard Worker UISwitch *switchView = (UISwitch *)cell.accessoryView; 310*d9f75844SAndroid Build Coastguard Worker switchView.on = [self valueForAudioSettingAtIndexPathRow:indexPath.row]; 311*d9f75844SAndroid Build Coastguard Worker 312*d9f75844SAndroid Build Coastguard Worker return cell; 313*d9f75844SAndroid Build Coastguard Worker} 314*d9f75844SAndroid Build Coastguard Worker 315*d9f75844SAndroid Build Coastguard Worker- (NSString *)labelForAudioSettingAtIndexPathRow:(NSInteger)setting { 316*d9f75844SAndroid Build Coastguard Worker switch (setting) { 317*d9f75844SAndroid Build Coastguard Worker case ARDAudioSettingsAudioOnly: 318*d9f75844SAndroid Build Coastguard Worker return @"Audio only"; 319*d9f75844SAndroid Build Coastguard Worker case ARDAudioSettingsCreateAecDump: 320*d9f75844SAndroid Build Coastguard Worker return @"Create AecDump"; 321*d9f75844SAndroid Build Coastguard Worker case ARDAudioSettingsUseManualAudioConfig: 322*d9f75844SAndroid Build Coastguard Worker return @"Use manual audio config"; 323*d9f75844SAndroid Build Coastguard Worker default: 324*d9f75844SAndroid Build Coastguard Worker return @""; 325*d9f75844SAndroid Build Coastguard Worker } 326*d9f75844SAndroid Build Coastguard Worker} 327*d9f75844SAndroid Build Coastguard Worker 328*d9f75844SAndroid Build Coastguard Worker- (BOOL)valueForAudioSettingAtIndexPathRow:(NSInteger)setting { 329*d9f75844SAndroid Build Coastguard Worker switch (setting) { 330*d9f75844SAndroid Build Coastguard Worker case ARDAudioSettingsAudioOnly: 331*d9f75844SAndroid Build Coastguard Worker return [_settingsModel currentAudioOnlySettingFromStore]; 332*d9f75844SAndroid Build Coastguard Worker case ARDAudioSettingsCreateAecDump: 333*d9f75844SAndroid Build Coastguard Worker return [_settingsModel currentCreateAecDumpSettingFromStore]; 334*d9f75844SAndroid Build Coastguard Worker case ARDAudioSettingsUseManualAudioConfig: 335*d9f75844SAndroid Build Coastguard Worker return [_settingsModel currentUseManualAudioConfigSettingFromStore]; 336*d9f75844SAndroid Build Coastguard Worker default: 337*d9f75844SAndroid Build Coastguard Worker return NO; 338*d9f75844SAndroid Build Coastguard Worker } 339*d9f75844SAndroid Build Coastguard Worker} 340*d9f75844SAndroid Build Coastguard Worker 341*d9f75844SAndroid Build Coastguard Worker- (void)audioSettingSwitchChanged:(UISwitch *)sender { 342*d9f75844SAndroid Build Coastguard Worker switch (sender.tag) { 343*d9f75844SAndroid Build Coastguard Worker case ARDAudioSettingsAudioOnly: { 344*d9f75844SAndroid Build Coastguard Worker [_settingsModel storeAudioOnlySetting:sender.isOn]; 345*d9f75844SAndroid Build Coastguard Worker break; 346*d9f75844SAndroid Build Coastguard Worker } 347*d9f75844SAndroid Build Coastguard Worker case ARDAudioSettingsCreateAecDump: { 348*d9f75844SAndroid Build Coastguard Worker [_settingsModel storeCreateAecDumpSetting:sender.isOn]; 349*d9f75844SAndroid Build Coastguard Worker break; 350*d9f75844SAndroid Build Coastguard Worker } 351*d9f75844SAndroid Build Coastguard Worker case ARDAudioSettingsUseManualAudioConfig: { 352*d9f75844SAndroid Build Coastguard Worker [_settingsModel storeUseManualAudioConfigSetting:sender.isOn]; 353*d9f75844SAndroid Build Coastguard Worker break; 354*d9f75844SAndroid Build Coastguard Worker } 355*d9f75844SAndroid Build Coastguard Worker default: 356*d9f75844SAndroid Build Coastguard Worker break; 357*d9f75844SAndroid Build Coastguard Worker } 358*d9f75844SAndroid Build Coastguard Worker} 359*d9f75844SAndroid Build Coastguard Worker 360*d9f75844SAndroid Build Coastguard Worker@end 361*d9f75844SAndroid Build Coastguard WorkerNS_ASSUME_NONNULL_END 362