From 5db450d244c7ec6e7e37a0ac71f11232b6bbe82b Mon Sep 17 00:00:00 2001 From: denicija Date: Tue, 28 Mar 2017 08:27:41 -0700 Subject: [PATCH] iOS:Add loopback launch argument functionality in AppRTCMobile. It will enable us to start immediate loopback just by passing the "loopback" string, as argument when launching. Usefull for testing and command line profiling. BUG=NONE Review-Url: https://codereview.webrtc.org/2777983004 Cr-Commit-Position: refs/heads/master@{#17426} --- .../objc/AppRTCMobile/ios/ARDMainView.m | 18 ++++------- .../AppRTCMobile/ios/ARDMainViewController.m | 31 +++++++++++++++++-- 2 files changed, 35 insertions(+), 14 deletions(-) diff --git a/webrtc/examples/objc/AppRTCMobile/ios/ARDMainView.m b/webrtc/examples/objc/AppRTCMobile/ios/ARDMainView.m index fd93250adb..0308ea0cfd 100644 --- a/webrtc/examples/objc/AppRTCMobile/ios/ARDMainView.m +++ b/webrtc/examples/objc/AppRTCMobile/ios/ARDMainView.m @@ -304,19 +304,13 @@ static CGFloat const kCallControlMargin = 8; } - (void)onStartCall:(id)sender { - NSString *room = _roomText.roomText; - // If this is a loopback call, allow a generated room name. - if (!room.length && _loopbackSwitch.isOn) { - room = [[NSUUID UUID] UUIDString]; - } - room = [room stringByReplacingOccurrencesOfString:@"-" withString:@""]; [_delegate mainView:self - didInputRoom:room - isLoopback:_loopbackSwitch.isOn - isAudioOnly:_audioOnlySwitch.isOn - shouldMakeAecDump:_aecdumpSwitch.isOn - shouldUseLevelControl:_levelControlSwitch.isOn - useManualAudio:_useManualAudioSwitch.isOn]; + didInputRoom:_roomText.roomText + isLoopback:_loopbackSwitch.isOn + isAudioOnly:_audioOnlySwitch.isOn + shouldMakeAecDump:_aecdumpSwitch.isOn + shouldUseLevelControl:_levelControlSwitch.isOn + useManualAudio:_useManualAudioSwitch.isOn]; } @end diff --git a/webrtc/examples/objc/AppRTCMobile/ios/ARDMainViewController.m b/webrtc/examples/objc/AppRTCMobile/ios/ARDMainViewController.m index 593c6a27f8..75d454a44c 100644 --- a/webrtc/examples/objc/AppRTCMobile/ios/ARDMainViewController.m +++ b/webrtc/examples/objc/AppRTCMobile/ios/ARDMainViewController.m @@ -25,6 +25,9 @@ static NSString *const barButtonImageString = @"ic_settings_black_24dp.png"; +// Launch argument to be passed to indicate that the app should start loopback immediatly +static NSString *const loopbackLaunchProcessArgument = @"loopback"; + @interface ARDMainViewController () < ARDMainViewDelegate, ARDVideoCallViewControllerDelegate, @@ -37,6 +40,19 @@ static NSString *const barButtonImageString = @"ic_settings_black_24dp.png"; BOOL _useManualAudio; } +- (void)viewDidLoad { + [super viewDidLoad]; + if ([[[NSProcessInfo processInfo] arguments] containsObject:loopbackLaunchProcessArgument]) { + [self mainView:nil + didInputRoom:@"" + isLoopback:YES + isAudioOnly:NO + shouldMakeAecDump:NO + shouldUseLevelControl:NO + useManualAudio:NO]; + } +} + - (void)loadView { self.title = @"AppRTC Mobile"; _mainView = [[ARDMainView alloc] initWithFrame:CGRectZero]; @@ -66,6 +82,12 @@ static NSString *const barButtonImageString = @"ic_settings_black_24dp.png"; self.navigationItem.rightBarButtonItem = settingsButton; } ++ (NSString *)loopbackRoomString { + NSString *loopbackRoomString = + [[NSUUID UUID].UUIDString stringByReplacingOccurrencesOfString:@"-" withString:@""]; + return loopbackRoomString; +} + #pragma mark - ARDMainViewDelegate - (void)mainView:(ARDMainView *)mainView @@ -76,8 +98,13 @@ static NSString *const barButtonImageString = @"ic_settings_black_24dp.png"; shouldUseLevelControl:(BOOL)shouldUseLevelControl useManualAudio:(BOOL)useManualAudio { if (!room.length) { - [self showAlertWithMessage:@"Missing room name."]; - return; + if (isLoopback) { + // If this is a loopback call, allow a generated room name. + room = [[self class] loopbackRoomString]; + } else { + [self showAlertWithMessage:@"Missing room name."]; + return; + } } // Trim whitespaces. NSCharacterSet *whitespaceSet = [NSCharacterSet whitespaceCharacterSet];