Move setting switches in AppRTCMobile to Settings screen
All setting switches except "Loopback mode" is now in the Settings
screen instead of the main screen. They are also persisted across app
launches.
Bug: webrtc:7748
Change-Id: Iafd84e5e39639770118e2503148d1bf7fb9c3d8d
Reviewed-on: https://chromium-review.googlesource.com/527034
Commit-Queue: Magnus Jedvert <magjed@webrtc.org>
Reviewed-by: Magnus Jedvert <magjed@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#18626}
diff --git a/webrtc/examples/objc/AppRTCMobile/ios/ARDMainView.h b/webrtc/examples/objc/AppRTCMobile/ios/ARDMainView.h
index 1f2497a..c6691c2 100644
--- a/webrtc/examples/objc/AppRTCMobile/ios/ARDMainView.h
+++ b/webrtc/examples/objc/AppRTCMobile/ios/ARDMainView.h
@@ -14,14 +14,7 @@
@protocol ARDMainViewDelegate <NSObject>
-- (void)mainView:(ARDMainView *)mainView
- didInputRoom:(NSString *)room
- isLoopback:(BOOL)isLoopback
- isAudioOnly:(BOOL)isAudioOnly
- shouldMakeAecDump:(BOOL)shouldMakeAecDump
- shouldUseLevelControl:(BOOL)shouldUseLevelControl
- useManualAudio:(BOOL)useManualAudio;
-
+- (void)mainView:(ARDMainView *)mainView didInputRoom:(NSString *)room isLoopback:(BOOL)isLoopback;
- (void)mainViewDidToggleAudioLoop:(ARDMainView *)mainView;
@end
diff --git a/webrtc/examples/objc/AppRTCMobile/ios/ARDMainView.m b/webrtc/examples/objc/AppRTCMobile/ios/ARDMainView.m
index 0308ea0..fcce3c3 100644
--- a/webrtc/examples/objc/AppRTCMobile/ios/ARDMainView.m
+++ b/webrtc/examples/objc/AppRTCMobile/ios/ARDMainView.m
@@ -74,16 +74,8 @@
@implementation ARDMainView {
ARDRoomTextField *_roomText;
UILabel *_callOptionsLabel;
- UISwitch *_audioOnlySwitch;
- UILabel *_audioOnlyLabel;
- UISwitch *_aecdumpSwitch;
- UILabel *_aecdumpLabel;
- UISwitch *_levelControlSwitch;
- UILabel *_levelControlLabel;
UISwitch *_loopbackSwitch;
UILabel *_loopbackLabel;
- UISwitch *_useManualAudioSwitch;
- UILabel *_useManualAudioLabel;
UIButton *_startCallButton;
UIButton *_audioLoopButton;
}
@@ -106,17 +98,6 @@
[_callOptionsLabel sizeToFit];
[self addSubview:_callOptionsLabel];
- _audioOnlySwitch = [[UISwitch alloc] initWithFrame:CGRectZero];
- [_audioOnlySwitch sizeToFit];
- [self addSubview:_audioOnlySwitch];
-
- _audioOnlyLabel = [[UILabel alloc] initWithFrame:CGRectZero];
- _audioOnlyLabel.text = @"Audio only";
- _audioOnlyLabel.font = controlFont;
- _audioOnlyLabel.textColor = controlFontColor;
- [_audioOnlyLabel sizeToFit];
- [self addSubview:_audioOnlyLabel];
-
_loopbackSwitch = [[UISwitch alloc] initWithFrame:CGRectZero];
[_loopbackSwitch sizeToFit];
[self addSubview:_loopbackSwitch];
@@ -128,40 +109,6 @@
[_loopbackLabel sizeToFit];
[self addSubview:_loopbackLabel];
- _aecdumpSwitch = [[UISwitch alloc] initWithFrame:CGRectZero];
- [_aecdumpSwitch sizeToFit];
- [self addSubview:_aecdumpSwitch];
-
- _aecdumpLabel = [[UILabel alloc] initWithFrame:CGRectZero];
- _aecdumpLabel.text = @"Create AecDump";
- _aecdumpLabel.font = controlFont;
- _aecdumpLabel.textColor = controlFontColor;
- [_aecdumpLabel sizeToFit];
- [self addSubview:_aecdumpLabel];
-
- _levelControlSwitch = [[UISwitch alloc] initWithFrame:CGRectZero];
- [_levelControlSwitch sizeToFit];
- [self addSubview:_levelControlSwitch];
-
- _levelControlLabel = [[UILabel alloc] initWithFrame:CGRectZero];
- _levelControlLabel.text = @"Use level controller";
- _levelControlLabel.font = controlFont;
- _levelControlLabel.textColor = controlFontColor;
- [_levelControlLabel sizeToFit];
- [self addSubview:_levelControlLabel];
-
- _useManualAudioSwitch = [[UISwitch alloc] initWithFrame:CGRectZero];
- [_useManualAudioSwitch sizeToFit];
- _useManualAudioSwitch.on = YES;
- [self addSubview:_useManualAudioSwitch];
-
- _useManualAudioLabel = [[UILabel alloc] initWithFrame:CGRectZero];
- _useManualAudioLabel.text = @"Use manual audio config";
- _useManualAudioLabel.font = controlFont;
- _useManualAudioLabel.textColor = controlFontColor;
- [_useManualAudioLabel sizeToFit];
- [self addSubview:_useManualAudioLabel];
-
_startCallButton = [UIButton buttonWithType:UIButtonTypeSystem];
[_startCallButton setTitle:@"Start call"
forState:UIControlStateNormal];
@@ -208,20 +155,7 @@
_callOptionsLabel.frame.size.width,
_callOptionsLabel.frame.size.height);
- CGFloat audioOnlyTop =
- CGRectGetMaxY(_callOptionsLabel.frame) + kCallControlMargin * 2;
- CGRect audioOnlyRect = CGRectMake(kCallControlMargin * 3,
- audioOnlyTop,
- _audioOnlySwitch.frame.size.width,
- _audioOnlySwitch.frame.size.height);
- _audioOnlySwitch.frame = audioOnlyRect;
- CGFloat audioOnlyLabelCenterX = CGRectGetMaxX(audioOnlyRect) +
- kCallControlMargin + _audioOnlyLabel.frame.size.width / 2;
- _audioOnlyLabel.center = CGPointMake(audioOnlyLabelCenterX,
- CGRectGetMidY(audioOnlyRect));
-
- CGFloat loopbackModeTop =
- CGRectGetMaxY(_audioOnlySwitch.frame) + kCallControlMargin;
+ CGFloat loopbackModeTop = CGRectGetMaxY(_callOptionsLabel.frame) + kCallControlMargin * 2;
CGRect loopbackModeRect = CGRectMake(kCallControlMargin * 3,
loopbackModeTop,
_loopbackSwitch.frame.size.width,
@@ -232,46 +166,7 @@
_loopbackLabel.center = CGPointMake(loopbackModeLabelCenterX,
CGRectGetMidY(loopbackModeRect));
- CGFloat aecdumpModeTop =
- CGRectGetMaxY(_loopbackSwitch.frame) + kCallControlMargin;
- CGRect aecdumpModeRect = CGRectMake(kCallControlMargin * 3,
- aecdumpModeTop,
- _aecdumpSwitch.frame.size.width,
- _aecdumpSwitch.frame.size.height);
- _aecdumpSwitch.frame = aecdumpModeRect;
- CGFloat aecdumpModeLabelCenterX = CGRectGetMaxX(aecdumpModeRect) +
- kCallControlMargin + _aecdumpLabel.frame.size.width / 2;
- _aecdumpLabel.center = CGPointMake(aecdumpModeLabelCenterX,
- CGRectGetMidY(aecdumpModeRect));
-
- CGFloat levelControlModeTop =
- CGRectGetMaxY(_aecdumpSwitch.frame) + kCallControlMargin;
- CGRect levelControlModeRect = CGRectMake(kCallControlMargin * 3,
- levelControlModeTop,
- _levelControlSwitch.frame.size.width,
- _levelControlSwitch.frame.size.height);
- _levelControlSwitch.frame = levelControlModeRect;
- CGFloat levelControlModeLabelCenterX = CGRectGetMaxX(levelControlModeRect) +
- kCallControlMargin + _levelControlLabel.frame.size.width / 2;
- _levelControlLabel.center = CGPointMake(levelControlModeLabelCenterX,
- CGRectGetMidY(levelControlModeRect));
-
- CGFloat useManualAudioTop =
- CGRectGetMaxY(_levelControlSwitch.frame) + kCallControlMargin;
- CGRect useManualAudioRect =
- CGRectMake(kCallControlMargin * 3,
- useManualAudioTop,
- _useManualAudioSwitch.frame.size.width,
- _useManualAudioSwitch.frame.size.height);
- _useManualAudioSwitch.frame = useManualAudioRect;
- CGFloat useManualAudioLabelCenterX = CGRectGetMaxX(useManualAudioRect) +
- kCallControlMargin + _useManualAudioLabel.frame.size.width / 2;
- _useManualAudioLabel.center =
- CGPointMake(useManualAudioLabelCenterX,
- CGRectGetMidY(useManualAudioRect));
-
- CGFloat audioLoopTop =
- CGRectGetMaxY(useManualAudioRect) + kCallControlMargin * 3;
+ CGFloat audioLoopTop = CGRectGetMaxY(loopbackModeRect) + kCallControlMargin * 3;
_audioLoopButton.frame = CGRectMake(kCallControlMargin,
audioLoopTop,
_audioLoopButton.frame.size.width,
@@ -304,13 +199,7 @@
}
- (void)onStartCall:(id)sender {
- [_delegate mainView:self
- didInputRoom:_roomText.roomText
- isLoopback:_loopbackSwitch.isOn
- isAudioOnly:_audioOnlySwitch.isOn
- shouldMakeAecDump:_aecdumpSwitch.isOn
- shouldUseLevelControl:_levelControlSwitch.isOn
- useManualAudio:_useManualAudioSwitch.isOn];
+ [_delegate mainView:self didInputRoom:_roomText.roomText isLoopback:_loopbackSwitch.isOn];
}
@end
diff --git a/webrtc/examples/objc/AppRTCMobile/ios/ARDMainViewController.m b/webrtc/examples/objc/AppRTCMobile/ios/ARDMainViewController.m
index 0e93aae..c57dace 100644
--- a/webrtc/examples/objc/AppRTCMobile/ios/ARDMainViewController.m
+++ b/webrtc/examples/objc/AppRTCMobile/ios/ARDMainViewController.m
@@ -44,13 +44,7 @@
- (void)viewDidLoad {
[super viewDidLoad];
if ([[[NSProcessInfo processInfo] arguments] containsObject:loopbackLaunchProcessArgument]) {
- [self mainView:nil
- didInputRoom:@""
- isLoopback:YES
- isAudioOnly:NO
- shouldMakeAecDump:NO
- shouldUseLevelControl:NO
- useManualAudio:NO];
+ [self mainView:nil didInputRoom:@"" isLoopback:YES];
}
}
@@ -91,13 +85,7 @@
#pragma mark - ARDMainViewDelegate
-- (void)mainView:(ARDMainView *)mainView
- didInputRoom:(NSString *)room
- isLoopback:(BOOL)isLoopback
- isAudioOnly:(BOOL)isAudioOnly
- shouldMakeAecDump:(BOOL)shouldMakeAecDump
- shouldUseLevelControl:(BOOL)shouldUseLevelControl
- useManualAudio:(BOOL)useManualAudio {
+- (void)mainView:(ARDMainView *)mainView didInputRoom:(NSString *)room isLoopback:(BOOL)isLoopback {
if (!room.length) {
if (isLoopback) {
// If this is a loopback call, allow a generated room name.
@@ -132,17 +120,16 @@
return;
}
+ ARDSettingsModel *settingsModel = [[ARDSettingsModel alloc] init];
+
RTCAudioSession *session = [RTCAudioSession sharedInstance];
- session.useManualAudio = useManualAudio;
+ session.useManualAudio = [settingsModel currentUseManualAudioConfigSettingFromStore];
session.isAudioEnabled = NO;
// Kick off the video call.
ARDVideoCallViewController *videoCallViewController =
[[ARDVideoCallViewController alloc] initForRoom:trimmedRoom
isLoopback:isLoopback
- isAudioOnly:isAudioOnly
- shouldMakeAecDump:shouldMakeAecDump
- shouldUseLevelControl:shouldUseLevelControl
delegate:self];
videoCallViewController.modalTransitionStyle =
UIModalTransitionStyleCrossDissolve;
diff --git a/webrtc/examples/objc/AppRTCMobile/ios/ARDSettingsViewController.m b/webrtc/examples/objc/AppRTCMobile/ios/ARDSettingsViewController.m
index 09a3d6d..fce5df7 100644
--- a/webrtc/examples/objc/AppRTCMobile/ios/ARDSettingsViewController.m
+++ b/webrtc/examples/objc/AppRTCMobile/ios/ARDSettingsViewController.m
@@ -14,11 +14,19 @@
NS_ASSUME_NONNULL_BEGIN
typedef NS_ENUM(int, ARDSettingsSections) {
- ARDSettingsSectionVideoResolution = 0,
+ ARDSettingsSectionAudioSettings = 0,
+ ARDSettingsSectionVideoResolution,
ARDSettingsSectionVideoCodec,
ARDSettingsSectionBitRate,
};
+typedef NS_ENUM(int, ARDAudioSettingsOptions) {
+ ARDAudioSettingsAudioOnly = 0,
+ ARDAudioSettingsCreateAecDump,
+ ARDAudioSettingsUseLevelController,
+ ARDAudioSettingsUseManualAudioConfig,
+};
+
@interface ARDSettingsViewController () <UITextFieldDelegate> {
ARDSettingsModel *_settingsModel;
}
@@ -46,22 +54,16 @@
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
- [self addCheckmarkInSection:ARDSettingsSectionVideoResolution
- withArray:[self videoResolutionArray]
- selecting:[_settingsModel currentVideoResolutionSettingFromStore]];
- [self addCheckmarkInSection:ARDSettingsSectionVideoCodec
- withArray:[self videoCodecArray]
- selecting:[_settingsModel currentVideoCodecSettingFromStore]];
}
#pragma mark - Data source
- (NSArray<NSString *> *)videoResolutionArray {
- return _settingsModel.availableVideoResolutions;
+ return [_settingsModel availableVideoResolutions];
}
- (NSArray<NSString *> *)videoCodecArray {
- return _settingsModel.availableVideoCodecs;
+ return [_settingsModel availableVideoCodecs];
}
#pragma mark -
@@ -74,16 +76,6 @@
self.navigationItem.leftBarButtonItem = barItem;
}
-- (void)addCheckmarkInSection:(int)section
- withArray:(NSArray<NSString*>*) array
- selecting:(NSString*)selection {
- NSUInteger indexOfSelection = [array indexOfObject:selection];
- NSIndexPath *pathToBeDecorated = [NSIndexPath indexPathForRow:indexOfSelection
- inSection:section];
- UITableViewCell *cell = [self.tableView cellForRowAtIndexPath:pathToBeDecorated];
- cell.accessoryType = UITableViewCellAccessoryCheckmark;
-}
-
#pragma mark - Dismissal of view controller
- (void)dismissModally:(id)sender {
@@ -93,11 +85,13 @@
#pragma mark - Table view data source
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
- return 3;
+ return 4;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
switch (section) {
+ case ARDSettingsSectionAudioSettings:
+ return 4;
case ARDSettingsSectionVideoResolution:
return self.videoResolutionArray.count;
case ARDSettingsSectionVideoCodec:
@@ -133,6 +127,8 @@
- (nullable NSString *)tableView:(UITableView *)tableView
titleForHeaderInSection:(NSInteger)section {
switch (section) {
+ case ARDSettingsSectionAudioSettings:
+ return @"Audio";
case ARDSettingsSectionVideoResolution:
return @"Video resolution";
case ARDSettingsSectionVideoCodec:
@@ -147,6 +143,9 @@
- (UITableViewCell *)tableView:(UITableView *)tableView
cellForRowAtIndexPath:(NSIndexPath *)indexPath {
switch (indexPath.section) {
+ case ARDSettingsSectionAudioSettings:
+ return [self audioSettingsTableViewCellForTableView:tableView atIndexPath:indexPath];
+
case ARDSettingsSectionVideoResolution:
return [self videoResolutionTableViewCellForTableView:tableView atIndexPath:indexPath];
@@ -184,7 +183,14 @@
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault
reuseIdentifier:dequeueIdentifier];
}
- cell.textLabel.text = self.videoResolutionArray[indexPath.row];
+ NSString *resolution = self.videoResolutionArray[indexPath.row];
+ cell.textLabel.text = resolution;
+ if ([resolution isEqualToString:[_settingsModel currentVideoResolutionSettingFromStore]]) {
+ cell.accessoryType = UITableViewCellAccessoryCheckmark;
+ } else {
+ cell.accessoryType = UITableViewCellAccessoryNone;
+ }
+
return cell;
}
@@ -208,7 +214,13 @@
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault
reuseIdentifier:dequeueIdentifier];
}
- cell.textLabel.text = self.videoCodecArray[indexPath.row];
+ NSString *codec = self.videoCodecArray[indexPath.row];
+ cell.textLabel.text = codec;
+ if ([codec isEqualToString:[_settingsModel currentVideoCodecSettingFromStore]]) {
+ cell.accessoryType = UITableViewCellAccessoryCheckmark;
+ } else {
+ cell.accessoryType = UITableViewCellAccessoryNone;
+ }
return cell;
}
@@ -275,5 +287,83 @@
[_settingsModel storeMaxBitrateSetting:bitrateNumber];
}
+#pragma mark - Table view delegate(Audio settings)
+
+- (UITableViewCell *)audioSettingsTableViewCellForTableView:(UITableView *)tableView
+ atIndexPath:(NSIndexPath *)indexPath {
+ NSString *dequeueIdentifier = @"ARDSettingsAudioSettingsCellIdentifier";
+ UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:dequeueIdentifier];
+ if (!cell) {
+ cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault
+ reuseIdentifier:dequeueIdentifier];
+ cell.selectionStyle = UITableViewCellSelectionStyleNone;
+ UISwitch *switchView = [[UISwitch alloc] initWithFrame:CGRectZero];
+ switchView.tag = indexPath.row;
+ [switchView addTarget:self
+ action:@selector(audioSettingSwitchChanged:)
+ forControlEvents:UIControlEventValueChanged];
+ cell.accessoryView = switchView;
+ }
+
+ cell.textLabel.text = [self labelForAudioSettingAtIndexPathRow:indexPath.row];
+ UISwitch *switchView = (UISwitch *)cell.accessoryView;
+ switchView.on = [self valueForAudioSettingAtIndexPathRow:indexPath.row];
+
+ return cell;
+}
+
+- (NSString *)labelForAudioSettingAtIndexPathRow:(NSInteger)setting {
+ switch (setting) {
+ case ARDAudioSettingsAudioOnly:
+ return @"Audio only";
+ case ARDAudioSettingsCreateAecDump:
+ return @"Create AecDump";
+ case ARDAudioSettingsUseLevelController:
+ return @"Use level controller";
+ case ARDAudioSettingsUseManualAudioConfig:
+ return @"Use manual audio config";
+ default:
+ return @"";
+ }
+}
+
+- (BOOL)valueForAudioSettingAtIndexPathRow:(NSInteger)setting {
+ switch (setting) {
+ case ARDAudioSettingsAudioOnly:
+ return [_settingsModel currentAudioOnlySettingFromStore];
+ case ARDAudioSettingsCreateAecDump:
+ return [_settingsModel currentCreateAecDumpSettingFromStore];
+ case ARDAudioSettingsUseLevelController:
+ return [_settingsModel currentUseLevelControllerSettingFromStore];
+ case ARDAudioSettingsUseManualAudioConfig:
+ return [_settingsModel currentUseManualAudioConfigSettingFromStore];
+ default:
+ return NO;
+ }
+}
+
+- (void)audioSettingSwitchChanged:(UISwitch *)sender {
+ switch (sender.tag) {
+ case ARDAudioSettingsAudioOnly: {
+ [_settingsModel storeAudioOnlySetting:sender.isOn];
+ break;
+ }
+ case ARDAudioSettingsCreateAecDump: {
+ [_settingsModel storeCreateAecDumpSetting:sender.isOn];
+ break;
+ }
+ case ARDAudioSettingsUseLevelController: {
+ [_settingsModel storeUseLevelControllerSetting:sender.isOn];
+ break;
+ }
+ case ARDAudioSettingsUseManualAudioConfig: {
+ [_settingsModel storeUseManualAudioConfigSetting:sender.isOn];
+ break;
+ }
+ default:
+ break;
+ }
+}
+
@end
NS_ASSUME_NONNULL_END
diff --git a/webrtc/examples/objc/AppRTCMobile/ios/ARDVideoCallViewController.h b/webrtc/examples/objc/AppRTCMobile/ios/ARDVideoCallViewController.h
index 3ca2dc2..bdb8747 100644
--- a/webrtc/examples/objc/AppRTCMobile/ios/ARDVideoCallViewController.h
+++ b/webrtc/examples/objc/AppRTCMobile/ios/ARDVideoCallViewController.h
@@ -23,9 +23,6 @@
- (instancetype)initForRoom:(NSString *)room
isLoopback:(BOOL)isLoopback
- isAudioOnly:(BOOL)isAudioOnly
- shouldMakeAecDump:(BOOL)shouldMakeAecDump
- shouldUseLevelControl:(BOOL)shouldUseLevelControl
delegate:(id<ARDVideoCallViewControllerDelegate>)delegate;
@end
diff --git a/webrtc/examples/objc/AppRTCMobile/ios/ARDVideoCallViewController.m b/webrtc/examples/objc/AppRTCMobile/ios/ARDVideoCallViewController.m
index fd33e01..03ce626 100644
--- a/webrtc/examples/objc/AppRTCMobile/ios/ARDVideoCallViewController.m
+++ b/webrtc/examples/objc/AppRTCMobile/ios/ARDVideoCallViewController.m
@@ -40,21 +40,13 @@
- (instancetype)initForRoom:(NSString *)room
isLoopback:(BOOL)isLoopback
- isAudioOnly:(BOOL)isAudioOnly
- shouldMakeAecDump:(BOOL)shouldMakeAecDump
- shouldUseLevelControl:(BOOL)shouldUseLevelControl
delegate:(id<ARDVideoCallViewControllerDelegate>)delegate {
if (self = [super init]) {
ARDSettingsModel *settingsModel = [[ARDSettingsModel alloc] init];
_delegate = delegate;
_client = [[ARDAppClient alloc] initWithDelegate:self];
- [_client connectToRoomWithId:room
- settings:settingsModel
- isLoopback:isLoopback
- isAudioOnly:isAudioOnly
- shouldMakeAecDump:shouldMakeAecDump
- shouldUseLevelControl:shouldUseLevelControl];
+ [_client connectToRoomWithId:room settings:settingsModel isLoopback:isLoopback];
}
return self;
}