Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(9)

Side by Side Diff: webrtc/examples/objc/AppRTCMobile/ios/ARDMainViewController.m

Issue 2777983004: iOS:Add loopback launch argument functionality in AppRTCMobile. (Closed)
Patch Set: Use static const instead of hardcoded value Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « webrtc/examples/objc/AppRTCMobile/ios/ARDMainView.m ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2015 The WebRTC Project Authors. All rights reserved. 2 * Copyright 2015 The WebRTC Project Authors. All rights reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 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 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 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
11 #import "ARDMainViewController.h" 11 #import "ARDMainViewController.h"
12 12
13 #import <AVFoundation/AVFoundation.h> 13 #import <AVFoundation/AVFoundation.h>
14 14
15 #import "WebRTC/RTCDispatcher.h" 15 #import "WebRTC/RTCDispatcher.h"
16 #import "WebRTC/RTCLogging.h" 16 #import "WebRTC/RTCLogging.h"
17 #import "webrtc/modules/audio_device/ios/objc/RTCAudioSession.h" 17 #import "webrtc/modules/audio_device/ios/objc/RTCAudioSession.h"
18 #import "webrtc/modules/audio_device/ios/objc/RTCAudioSessionConfiguration.h" 18 #import "webrtc/modules/audio_device/ios/objc/RTCAudioSessionConfiguration.h"
19 19
20 #import "ARDAppClient.h" 20 #import "ARDAppClient.h"
21 #import "ARDMainView.h" 21 #import "ARDMainView.h"
22 #import "ARDSettingsModel.h" 22 #import "ARDSettingsModel.h"
23 #import "ARDSettingsViewController.h" 23 #import "ARDSettingsViewController.h"
24 #import "ARDVideoCallViewController.h" 24 #import "ARDVideoCallViewController.h"
25 25
26 static NSString *const barButtonImageString = @"ic_settings_black_24dp.png"; 26 static NSString *const barButtonImageString = @"ic_settings_black_24dp.png";
27 27
28 // Launch argument to be passed to indicate that the app should start loopback i mmediatly
29 static NSString *const loopbackLaunchProcessArgument = @"loopback";
30
28 @interface ARDMainViewController () < 31 @interface ARDMainViewController () <
29 ARDMainViewDelegate, 32 ARDMainViewDelegate,
30 ARDVideoCallViewControllerDelegate, 33 ARDVideoCallViewControllerDelegate,
31 RTCAudioSessionDelegate> 34 RTCAudioSessionDelegate>
32 @end 35 @end
33 36
34 @implementation ARDMainViewController { 37 @implementation ARDMainViewController {
35 ARDMainView *_mainView; 38 ARDMainView *_mainView;
36 AVAudioPlayer *_audioPlayer; 39 AVAudioPlayer *_audioPlayer;
37 BOOL _useManualAudio; 40 BOOL _useManualAudio;
38 } 41 }
39 42
43 - (void)viewDidLoad {
44 [super viewDidLoad];
45 if ([[[NSProcessInfo processInfo] arguments] containsObject:loopbackLaunchProc essArgument]) {
46 [self mainView:nil
47 didInputRoom:@""
48 isLoopback:YES
49 isAudioOnly:NO
50 shouldMakeAecDump:NO
51 shouldUseLevelControl:NO
52 useManualAudio:NO];
53 }
54 }
55
40 - (void)loadView { 56 - (void)loadView {
41 self.title = @"AppRTC Mobile"; 57 self.title = @"AppRTC Mobile";
42 _mainView = [[ARDMainView alloc] initWithFrame:CGRectZero]; 58 _mainView = [[ARDMainView alloc] initWithFrame:CGRectZero];
43 _mainView.delegate = self; 59 _mainView.delegate = self;
44 self.view = _mainView; 60 self.view = _mainView;
45 [self addSettingsBarButton]; 61 [self addSettingsBarButton];
46 62
47 RTCAudioSessionConfiguration *webRTCConfig = 63 RTCAudioSessionConfiguration *webRTCConfig =
48 [RTCAudioSessionConfiguration webRTCConfiguration]; 64 [RTCAudioSessionConfiguration webRTCConfiguration];
49 webRTCConfig.categoryOptions = webRTCConfig.categoryOptions | 65 webRTCConfig.categoryOptions = webRTCConfig.categoryOptions |
50 AVAudioSessionCategoryOptionDefaultToSpeaker; 66 AVAudioSessionCategoryOptionDefaultToSpeaker;
51 [RTCAudioSessionConfiguration setWebRTCConfiguration:webRTCConfig]; 67 [RTCAudioSessionConfiguration setWebRTCConfiguration:webRTCConfig];
52 68
53 RTCAudioSession *session = [RTCAudioSession sharedInstance]; 69 RTCAudioSession *session = [RTCAudioSession sharedInstance];
54 [session addDelegate:self]; 70 [session addDelegate:self];
55 71
56 [self configureAudioSession]; 72 [self configureAudioSession];
57 [self setupAudioPlayer]; 73 [self setupAudioPlayer];
58 } 74 }
59 75
60 - (void)addSettingsBarButton { 76 - (void)addSettingsBarButton {
61 UIBarButtonItem *settingsButton = 77 UIBarButtonItem *settingsButton =
62 [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:barButtonImageS tring] 78 [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:barButtonImageS tring]
63 style:UIBarButtonItemStylePlain 79 style:UIBarButtonItemStylePlain
64 target:self 80 target:self
65 action:@selector(showSettings:)]; 81 action:@selector(showSettings:)];
66 self.navigationItem.rightBarButtonItem = settingsButton; 82 self.navigationItem.rightBarButtonItem = settingsButton;
67 } 83 }
68 84
85 + (NSString *)loopbackRoomString {
86 NSString *loopbackRoomString =
87 [[NSUUID UUID].UUIDString stringByReplacingOccurrencesOfString:@"-" withSt ring:@""];
88 return loopbackRoomString;
89 }
90
69 #pragma mark - ARDMainViewDelegate 91 #pragma mark - ARDMainViewDelegate
70 92
71 - (void)mainView:(ARDMainView *)mainView 93 - (void)mainView:(ARDMainView *)mainView
72 didInputRoom:(NSString *)room 94 didInputRoom:(NSString *)room
73 isLoopback:(BOOL)isLoopback 95 isLoopback:(BOOL)isLoopback
74 isAudioOnly:(BOOL)isAudioOnly 96 isAudioOnly:(BOOL)isAudioOnly
75 shouldMakeAecDump:(BOOL)shouldMakeAecDump 97 shouldMakeAecDump:(BOOL)shouldMakeAecDump
76 shouldUseLevelControl:(BOOL)shouldUseLevelControl 98 shouldUseLevelControl:(BOOL)shouldUseLevelControl
77 useManualAudio:(BOOL)useManualAudio { 99 useManualAudio:(BOOL)useManualAudio {
78 if (!room.length) { 100 if (!room.length) {
79 [self showAlertWithMessage:@"Missing room name."]; 101 if (isLoopback) {
80 return; 102 // If this is a loopback call, allow a generated room name.
103 room = [[self class] loopbackRoomString];
104 } else {
105 [self showAlertWithMessage:@"Missing room name."];
106 return;
107 }
81 } 108 }
82 // Trim whitespaces. 109 // Trim whitespaces.
83 NSCharacterSet *whitespaceSet = [NSCharacterSet whitespaceCharacterSet]; 110 NSCharacterSet *whitespaceSet = [NSCharacterSet whitespaceCharacterSet];
84 NSString *trimmedRoom = [room stringByTrimmingCharactersInSet:whitespaceSet]; 111 NSString *trimmedRoom = [room stringByTrimmingCharactersInSet:whitespaceSet];
85 112
86 // Check that room name is valid. 113 // Check that room name is valid.
87 NSError *error = nil; 114 NSError *error = nil;
88 NSRegularExpressionOptions options = NSRegularExpressionCaseInsensitive; 115 NSRegularExpressionOptions options = NSRegularExpressionCaseInsensitive;
89 NSRegularExpression *regex = 116 NSRegularExpression *regex =
90 [NSRegularExpression regularExpressionWithPattern:@"\\w+" 117 [NSRegularExpression regularExpressionWithPattern:@"\\w+"
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
230 - (void)showAlertWithMessage:(NSString*)message { 257 - (void)showAlertWithMessage:(NSString*)message {
231 UIAlertView* alertView = [[UIAlertView alloc] initWithTitle:nil 258 UIAlertView* alertView = [[UIAlertView alloc] initWithTitle:nil
232 message:message 259 message:message
233 delegate:nil 260 delegate:nil
234 cancelButtonTitle:@"OK" 261 cancelButtonTitle:@"OK"
235 otherButtonTitles:nil]; 262 otherButtonTitles:nil];
236 [alertView show]; 263 [alertView show];
237 } 264 }
238 265
239 @end 266 @end
OLDNEW
« no previous file with comments | « webrtc/examples/objc/AppRTCMobile/ios/ARDMainView.m ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698