OLD | NEW |
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 "ARDVideoCallViewController.h" | 22 #import "ARDVideoCallViewController.h" |
23 | 23 |
| 24 static NSString *barButtonImageString = @"ic_settings_black_24dp.png"; |
| 25 |
24 @interface ARDMainViewController () < | 26 @interface ARDMainViewController () < |
25 ARDMainViewDelegate, | 27 ARDMainViewDelegate, |
26 ARDVideoCallViewControllerDelegate, | 28 ARDVideoCallViewControllerDelegate, |
27 RTCAudioSessionDelegate> | 29 RTCAudioSessionDelegate> |
28 @end | 30 @end |
29 | 31 |
30 @implementation ARDMainViewController { | 32 @implementation ARDMainViewController { |
31 ARDMainView *_mainView; | 33 ARDMainView *_mainView; |
32 AVAudioPlayer *_audioPlayer; | 34 AVAudioPlayer *_audioPlayer; |
33 BOOL _useManualAudio; | 35 BOOL _useManualAudio; |
34 } | 36 } |
35 | 37 |
36 - (void)loadView { | 38 - (void)loadView { |
| 39 self.title = @"AppRTC Mobile"; |
37 _mainView = [[ARDMainView alloc] initWithFrame:CGRectZero]; | 40 _mainView = [[ARDMainView alloc] initWithFrame:CGRectZero]; |
38 _mainView.delegate = self; | 41 _mainView.delegate = self; |
39 self.view = _mainView; | 42 self.view = _mainView; |
| 43 [self addSettingsBarButton]; |
40 | 44 |
41 RTCAudioSessionConfiguration *webRTCConfig = | 45 RTCAudioSessionConfiguration *webRTCConfig = |
42 [RTCAudioSessionConfiguration webRTCConfiguration]; | 46 [RTCAudioSessionConfiguration webRTCConfiguration]; |
43 webRTCConfig.categoryOptions = webRTCConfig.categoryOptions | | 47 webRTCConfig.categoryOptions = webRTCConfig.categoryOptions | |
44 AVAudioSessionCategoryOptionDefaultToSpeaker; | 48 AVAudioSessionCategoryOptionDefaultToSpeaker; |
45 [RTCAudioSessionConfiguration setWebRTCConfiguration:webRTCConfig]; | 49 [RTCAudioSessionConfiguration setWebRTCConfiguration:webRTCConfig]; |
46 | 50 |
47 RTCAudioSession *session = [RTCAudioSession sharedInstance]; | 51 RTCAudioSession *session = [RTCAudioSession sharedInstance]; |
48 [session addDelegate:self]; | 52 [session addDelegate:self]; |
49 | 53 |
50 [self configureAudioSession]; | 54 [self configureAudioSession]; |
51 [self setupAudioPlayer]; | 55 [self setupAudioPlayer]; |
52 } | 56 } |
53 | 57 |
| 58 - (void)addSettingsBarButton { |
| 59 UIBarButtonItem *settingsButton = |
| 60 [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:barButtonImageS
tring] |
| 61 style:UIBarButtonItemStylePlain |
| 62 target:self |
| 63 action:@selector(showSettings:)]; |
| 64 self.navigationItem.rightBarButtonItem = settingsButton; |
| 65 } |
| 66 |
54 #pragma mark - ARDMainViewDelegate | 67 #pragma mark - ARDMainViewDelegate |
55 | 68 |
56 - (void)mainView:(ARDMainView *)mainView | 69 - (void)mainView:(ARDMainView *)mainView |
57 didInputRoom:(NSString *)room | 70 didInputRoom:(NSString *)room |
58 isLoopback:(BOOL)isLoopback | 71 isLoopback:(BOOL)isLoopback |
59 isAudioOnly:(BOOL)isAudioOnly | 72 isAudioOnly:(BOOL)isAudioOnly |
60 shouldMakeAecDump:(BOOL)shouldMakeAecDump | 73 shouldMakeAecDump:(BOOL)shouldMakeAecDump |
61 shouldUseLevelControl:(BOOL)shouldUseLevelControl | 74 shouldUseLevelControl:(BOOL)shouldUseLevelControl |
62 useManualAudio:(BOOL)useManualAudio { | 75 useManualAudio:(BOOL)useManualAudio { |
63 if (!room.length) { | 76 if (!room.length) { |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 - (void)audioSessionDidStopPlayOrRecord:(RTCAudioSession *)session { | 161 - (void)audioSessionDidStopPlayOrRecord:(RTCAudioSession *)session { |
149 // WebRTC is done with the audio session. Restart playback. | 162 // WebRTC is done with the audio session. Restart playback. |
150 [RTCDispatcher dispatchAsyncOnType:RTCDispatcherTypeMain | 163 [RTCDispatcher dispatchAsyncOnType:RTCDispatcherTypeMain |
151 block:^{ | 164 block:^{ |
152 RTCLog(@"audioSessionDidStopPlayOrRecord"); | 165 RTCLog(@"audioSessionDidStopPlayOrRecord"); |
153 [self restartAudioPlayerIfNeeded]; | 166 [self restartAudioPlayerIfNeeded]; |
154 }]; | 167 }]; |
155 } | 168 } |
156 | 169 |
157 #pragma mark - Private | 170 #pragma mark - Private |
| 171 - (void)showSettings:(id)sender { |
| 172 } |
158 | 173 |
159 - (void)configureAudioSession { | 174 - (void)configureAudioSession { |
160 RTCAudioSessionConfiguration *configuration = | 175 RTCAudioSessionConfiguration *configuration = |
161 [[RTCAudioSessionConfiguration alloc] init]; | 176 [[RTCAudioSessionConfiguration alloc] init]; |
162 configuration.category = AVAudioSessionCategoryAmbient; | 177 configuration.category = AVAudioSessionCategoryAmbient; |
163 configuration.categoryOptions = AVAudioSessionCategoryOptionDuckOthers; | 178 configuration.categoryOptions = AVAudioSessionCategoryOptionDuckOthers; |
164 configuration.mode = AVAudioSessionModeDefault; | 179 configuration.mode = AVAudioSessionModeDefault; |
165 | 180 |
166 RTCAudioSession *session = [RTCAudioSession sharedInstance]; | 181 RTCAudioSession *session = [RTCAudioSession sharedInstance]; |
167 [session lockForConfiguration]; | 182 [session lockForConfiguration]; |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
202 - (void)showAlertWithMessage:(NSString*)message { | 217 - (void)showAlertWithMessage:(NSString*)message { |
203 UIAlertView* alertView = [[UIAlertView alloc] initWithTitle:nil | 218 UIAlertView* alertView = [[UIAlertView alloc] initWithTitle:nil |
204 message:message | 219 message:message |
205 delegate:nil | 220 delegate:nil |
206 cancelButtonTitle:@"OK" | 221 cancelButtonTitle:@"OK" |
207 otherButtonTitles:nil]; | 222 otherButtonTitles:nil]; |
208 [alertView show]; | 223 [alertView show]; |
209 } | 224 } |
210 | 225 |
211 @end | 226 @end |
OLD | NEW |