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

Side by Side Diff: webrtc/examples/objc/AppRTCDemo/ios/ARDVideoCallViewController.m

Issue 1782363002: Fix lock behavior on RTCAudioSession. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Remove autoreleasepool bits Created 4 years, 9 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
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 "ARDVideoCallViewController.h" 11 #import "ARDVideoCallViewController.h"
12 12
13 #import "webrtc/base/objc/RTCDispatcher.h"
14 #import "webrtc/modules/audio_device/ios/objc/RTCAudioSession.h"
15
13 #import "RTCAVFoundationVideoSource.h" 16 #import "RTCAVFoundationVideoSource.h"
14 #import "RTCLogging.h" 17 #import "RTCLogging.h"
15 18
16 #import "ARDAppClient.h" 19 #import "ARDAppClient.h"
17 #import "ARDVideoCallView.h" 20 #import "ARDVideoCallView.h"
18 21
19 @interface ARDVideoCallViewController () <ARDAppClientDelegate, 22 @interface ARDVideoCallViewController () <ARDAppClientDelegate,
20 ARDVideoCallViewDelegate> 23 ARDVideoCallViewDelegate>
21 @property(nonatomic, strong) RTCVideoTrack *localVideoTrack; 24 @property(nonatomic, strong) RTCVideoTrack *localVideoTrack;
22 @property(nonatomic, strong) RTCVideoTrack *remoteVideoTrack; 25 @property(nonatomic, strong) RTCVideoTrack *remoteVideoTrack;
23 @property(nonatomic, readonly) ARDVideoCallView *videoCallView; 26 @property(nonatomic, readonly) ARDVideoCallView *videoCallView;
24 @end 27 @end
25 28
26 @implementation ARDVideoCallViewController { 29 @implementation ARDVideoCallViewController {
27 ARDAppClient *_client; 30 ARDAppClient *_client;
28 RTCVideoTrack *_remoteVideoTrack; 31 RTCVideoTrack *_remoteVideoTrack;
29 RTCVideoTrack *_localVideoTrack; 32 RTCVideoTrack *_localVideoTrack;
33 AVAudioSessionPortOverride _portOverride;
30 } 34 }
31 35
32 @synthesize videoCallView = _videoCallView; 36 @synthesize videoCallView = _videoCallView;
33 37
34 - (instancetype)initForRoom:(NSString *)room 38 - (instancetype)initForRoom:(NSString *)room
35 isLoopback:(BOOL)isLoopback 39 isLoopback:(BOOL)isLoopback
36 isAudioOnly:(BOOL)isAudioOnly { 40 isAudioOnly:(BOOL)isAudioOnly {
37 if (self = [super init]) { 41 if (self = [super init]) {
38 _client = [[ARDAppClient alloc] initWithDelegate:self]; 42 _client = [[ARDAppClient alloc] initWithDelegate:self];
39 [_client connectToRoomWithId:room 43 [_client connectToRoomWithId:room
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 - (void)videoCallViewDidHangup:(ARDVideoCallView *)view { 114 - (void)videoCallViewDidHangup:(ARDVideoCallView *)view {
111 [self hangup]; 115 [self hangup];
112 } 116 }
113 117
114 - (void)videoCallViewDidSwitchCamera:(ARDVideoCallView *)view { 118 - (void)videoCallViewDidSwitchCamera:(ARDVideoCallView *)view {
115 // TODO(tkchin): Rate limit this so you can't tap continously on it. 119 // TODO(tkchin): Rate limit this so you can't tap continously on it.
116 // Probably through an animation. 120 // Probably through an animation.
117 [self switchCamera]; 121 [self switchCamera];
118 } 122 }
119 123
124 - (void)videoCallViewDidChangeRoute:(ARDVideoCallView *)view {
125 AVAudioSessionPortOverride override = AVAudioSessionPortOverrideNone;
126 if (_portOverride == AVAudioSessionPortOverrideNone) {
127 override = AVAudioSessionPortOverrideSpeaker;
128 }
129 [RTCDispatcher dispatchAsyncOnType:RTCDispatcherTypeAudioSession
130 block:^{
131 RTCAudioSession *session = [RTCAudioSession sharedInstance];
132 [session lockForConfiguration];
133 NSError *error = nil;
134 if ([session overrideOutputAudioPort:override error:&error]) {
135 _portOverride = override;
136 } else {
137 RTCLogError(@"Error overriding output port: %@",
138 error.localizedDescription);
139 }
140 [session unlockForConfiguration];
141 }];
142 }
143
120 - (void)videoCallViewDidEnableStats:(ARDVideoCallView *)view { 144 - (void)videoCallViewDidEnableStats:(ARDVideoCallView *)view {
121 _client.shouldGetStats = YES; 145 _client.shouldGetStats = YES;
122 _videoCallView.statsView.hidden = NO; 146 _videoCallView.statsView.hidden = NO;
123 } 147 }
124 148
125 #pragma mark - Private 149 #pragma mark - Private
126 150
127 - (void)setLocalVideoTrack:(RTCVideoTrack *)localVideoTrack { 151 - (void)setLocalVideoTrack:(RTCVideoTrack *)localVideoTrack {
128 if (_localVideoTrack == localVideoTrack) { 152 if (_localVideoTrack == localVideoTrack) {
129 return; 153 return;
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 - (void)showAlertWithMessage:(NSString*)message { 211 - (void)showAlertWithMessage:(NSString*)message {
188 UIAlertView* alertView = [[UIAlertView alloc] initWithTitle:nil 212 UIAlertView* alertView = [[UIAlertView alloc] initWithTitle:nil
189 message:message 213 message:message
190 delegate:nil 214 delegate:nil
191 cancelButtonTitle:@"OK" 215 cancelButtonTitle:@"OK"
192 otherButtonTitles:nil]; 216 otherButtonTitles:nil];
193 [alertView show]; 217 [alertView show];
194 } 218 }
195 219
196 @end 220 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698