Index: webrtc/examples/objc/AppRTCMobile/ios/ARDVideoCallViewController.m |
diff --git a/webrtc/examples/objc/AppRTCMobile/ios/ARDVideoCallViewController.m b/webrtc/examples/objc/AppRTCMobile/ios/ARDVideoCallViewController.m |
index cd42514a9f930690df6a97deb5e807427250b9ea..732e4b6511ef281db7ab763f55aa1ae7995486f5 100644 |
--- a/webrtc/examples/objc/AppRTCMobile/ios/ARDVideoCallViewController.m |
+++ b/webrtc/examples/objc/AppRTCMobile/ios/ARDVideoCallViewController.m |
@@ -13,6 +13,7 @@ |
#import "webrtc/modules/audio_device/ios/objc/RTCAudioSession.h" |
#import "ARDAppClient.h" |
+#import "ARDCaptureController.h" |
#import "ARDSettingsModel.h" |
#import "ARDVideoCallView.h" |
#import "WebRTC/RTCAVFoundationVideoSource.h" |
@@ -22,7 +23,6 @@ |
@interface ARDVideoCallViewController () <ARDAppClientDelegate, |
ARDVideoCallViewDelegate> |
-@property(nonatomic, strong) RTCVideoTrack *localVideoTrack; |
@property(nonatomic, strong) RTCVideoTrack *remoteVideoTrack; |
@property(nonatomic, readonly) ARDVideoCallView *videoCallView; |
@end |
@@ -30,12 +30,11 @@ |
@implementation ARDVideoCallViewController { |
ARDAppClient *_client; |
RTCVideoTrack *_remoteVideoTrack; |
- RTCVideoTrack *_localVideoTrack; |
+ ARDCaptureController *_captureController; |
AVAudioSessionPortOverride _portOverride; |
} |
@synthesize videoCallView = _videoCallView; |
-@synthesize localVideoTrack = _localVideoTrack; |
@synthesize remoteVideoTrack = _remoteVideoTrack; |
@synthesize delegate = _delegate; |
@@ -48,6 +47,7 @@ |
if (self = [super init]) { |
ARDSettingsModel *settingsModel = [[ARDSettingsModel alloc] init]; |
_delegate = delegate; |
+ |
_client = [[ARDAppClient alloc] initWithDelegate:self]; |
[_client connectToRoomWithId:room |
settings:settingsModel |
@@ -97,8 +97,16 @@ |
} |
- (void)appClient:(ARDAppClient *)client |
+ didCreateLocalCapturer:(RTCCameraVideoCapturer *)localCapturer { |
+ _videoCallView.localVideoView.captureSession = localCapturer.captureSession; |
+ ARDSettingsModel *settingsModel = [[ARDSettingsModel alloc] init]; |
+ _captureController = |
+ [[ARDCaptureController alloc] initWithCapturer:localCapturer settings:settingsModel]; |
+ [_captureController startCapture]; |
+} |
+ |
+- (void)appClient:(ARDAppClient *)client |
didReceiveLocalVideoTrack:(RTCVideoTrack *)localVideoTrack { |
- self.localVideoTrack = localVideoTrack; |
} |
- (void)appClient:(ARDAppClient *)client |
@@ -130,7 +138,7 @@ |
- (void)videoCallViewDidSwitchCamera:(ARDVideoCallView *)view { |
// TODO(tkchin): Rate limit this so you can't tap continously on it. |
// Probably through an animation. |
- [self switchCamera]; |
+ [_captureController switchCamera]; |
} |
- (void)videoCallViewDidChangeRoute:(ARDVideoCallView *)view { |
@@ -160,20 +168,6 @@ |
#pragma mark - Private |
-- (void)setLocalVideoTrack:(RTCVideoTrack *)localVideoTrack { |
- if (_localVideoTrack == localVideoTrack) { |
- return; |
- } |
- _localVideoTrack = nil; |
- _localVideoTrack = localVideoTrack; |
- RTCAVFoundationVideoSource *source = nil; |
- if ([localVideoTrack.source |
- isKindOfClass:[RTCAVFoundationVideoSource class]]) { |
- source = (RTCAVFoundationVideoSource*)localVideoTrack.source; |
- } |
- _videoCallView.localVideoView.captureSession = source.captureSession; |
-} |
- |
- (void)setRemoteVideoTrack:(RTCVideoTrack *)remoteVideoTrack { |
if (_remoteVideoTrack == remoteVideoTrack) { |
return; |
@@ -187,19 +181,13 @@ |
- (void)hangup { |
self.remoteVideoTrack = nil; |
- self.localVideoTrack = nil; |
+ _videoCallView.localVideoView.captureSession = nil; |
+ [_captureController stopCapture]; |
+ _captureController = nil; |
[_client disconnect]; |
[_delegate viewControllerDidFinish:self]; |
} |
-- (void)switchCamera { |
- RTCVideoSource* source = self.localVideoTrack.source; |
- if ([source isKindOfClass:[RTCAVFoundationVideoSource class]]) { |
- RTCAVFoundationVideoSource* avSource = (RTCAVFoundationVideoSource*)source; |
- avSource.useBackCamera = !avSource.useBackCamera; |
- } |
-} |
- |
- (NSString *)statusTextForState:(RTCIceConnectionState)state { |
switch (state) { |
case RTCIceConnectionStateNew: |