blob: a972a20e4ea898964b1ebe0222a8d2c440bbbfad [file] [log] [blame]
tkchin@webrtc.orgacca6752014-05-30 22:26:06 +00001/*
Donald E Curtisa8736442015-08-05 15:48:13 -07002 * Copyright 2014 The WebRTC Project Authors. All rights reserved.
tkchin@webrtc.orgacca6752014-05-30 22:26:06 +00003 *
Donald E Curtisa8736442015-08-05 15:48:13 -07004 * 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
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
tkchin@webrtc.orgacca6752014-05-30 22:26:06 +00009 */
10
11#import "APPRTCViewController.h"
12
13#import <AVFoundation/AVFoundation.h>
tkchin9eeb6242016-04-27 01:54:20 -070014
Anders Carlsson7bca8ca2018-08-30 09:30:29 +020015#import <WebRTC/RTCMTLNSVideoView.h>
16#import <WebRTC/RTCNSGLVideoView.h>
17#import <WebRTC/RTCVideoTrack.h>
hjon79858f82016-03-13 22:08:26 -070018
tkchin@webrtc.org87776a82014-12-09 19:32:35 +000019#import "ARDAppClient.h"
sakalc522e752017-04-05 12:17:48 -070020#import "ARDCaptureController.h"
sakalc4adacf2017-03-28 01:22:48 -070021#import "ARDSettingsModel.h"
tkchin@webrtc.orgacca6752014-05-30 22:26:06 +000022
denicija647915f2016-10-20 01:46:41 -070023static NSUInteger const kContentWidth = 900;
24static NSUInteger const kRoomFieldWidth = 200;
25static NSUInteger const kActionItemHeight = 30;
26static NSUInteger const kBottomViewHeight = 200;
tkchin@webrtc.orgacca6752014-05-30 22:26:06 +000027
28@class APPRTCMainView;
29@protocol APPRTCMainViewDelegate
30
31- (void)appRTCMainView:(APPRTCMainView*)mainView
denicija647915f2016-10-20 01:46:41 -070032 didEnterRoomId:(NSString*)roomId
33 loopback:(BOOL)isLoopback;
tkchin@webrtc.orgacca6752014-05-30 22:26:06 +000034
35@end
36
37@interface APPRTCMainView : NSView
38
39@property(nonatomic, weak) id<APPRTCMainViewDelegate> delegate;
denicija124a6fc2017-03-31 02:47:29 -070040@property(nonatomic, readonly) NSView<RTCVideoRenderer>* localVideoView;
41@property(nonatomic, readonly) NSView<RTCVideoRenderer>* remoteVideoView;
Jiawei Ou4aeb35b2018-11-09 13:55:45 -080042@property(nonatomic, readonly) NSTextView* logView;
tkchin@webrtc.orgacca6752014-05-30 22:26:06 +000043
44- (void)displayLogMessage:(NSString*)message;
45
46@end
47
48@interface APPRTCMainView () <NSTextFieldDelegate, RTCNSGLVideoViewDelegate>
49@end
50@implementation APPRTCMainView {
51 NSScrollView* _scrollView;
denicija647915f2016-10-20 01:46:41 -070052 NSView* _actionItemsView;
53 NSButton* _connectButton;
54 NSButton* _loopbackButton;
tkchin@webrtc.orgacca6752014-05-30 22:26:06 +000055 NSTextField* _roomField;
tkchin@webrtc.orgacca6752014-05-30 22:26:06 +000056 CGSize _localVideoSize;
57 CGSize _remoteVideoSize;
58}
59
tkchin2ddfdba2016-08-07 21:37:45 -070060@synthesize delegate = _delegate;
61@synthesize localVideoView = _localVideoView;
62@synthesize remoteVideoView = _remoteVideoView;
Jiawei Ou4aeb35b2018-11-09 13:55:45 -080063@synthesize logView = _logView;
denicija647915f2016-10-20 01:46:41 -070064
65- (void)displayLogMessage:(NSString *)message {
adam.fedor8c6afef2017-06-13 05:25:33 -070066 dispatch_async(dispatch_get_main_queue(), ^{
Jiawei Ou4aeb35b2018-11-09 13:55:45 -080067 self.logView.string = [NSString stringWithFormat:@"%@%@\n", self.logView.string, message];
68 NSRange range = NSMakeRange(self.logView.string.length, 0);
69 [self.logView scrollRangeToVisible:range];
adam.fedor8c6afef2017-06-13 05:25:33 -070070 });
tkchin@webrtc.orgacca6752014-05-30 22:26:06 +000071}
72
denicija647915f2016-10-20 01:46:41 -070073#pragma mark - Private
74
tkchin@webrtc.orgacca6752014-05-30 22:26:06 +000075- (instancetype)initWithFrame:(NSRect)frame {
76 if (self = [super initWithFrame:frame]) {
77 [self setupViews];
78 }
79 return self;
80}
81
denicija647915f2016-10-20 01:46:41 -070082+ (BOOL)requiresConstraintBasedLayout {
83 return YES;
84}
85
tkchin@webrtc.orgacca6752014-05-30 22:26:06 +000086- (void)updateConstraints {
87 NSParameterAssert(
denicija647915f2016-10-20 01:46:41 -070088 _roomField != nil &&
89 _scrollView != nil &&
90 _remoteVideoView != nil &&
91 _localVideoView != nil &&
92 _actionItemsView!= nil &&
93 _connectButton != nil &&
94 _loopbackButton != nil);
95
tkchin@webrtc.orgacca6752014-05-30 22:26:06 +000096 [self removeConstraints:[self constraints]];
97 NSDictionary* viewsDictionary =
denicija647915f2016-10-20 01:46:41 -070098 NSDictionaryOfVariableBindings(_roomField,
tkchin@webrtc.orgacca6752014-05-30 22:26:06 +000099 _scrollView,
kthelgason314bc5f2016-08-31 10:23:27 -0700100 _remoteVideoView,
denicija647915f2016-10-20 01:46:41 -0700101 _localVideoView,
102 _actionItemsView,
103 _connectButton,
104 _loopbackButton);
tkchin@webrtc.orgacca6752014-05-30 22:26:06 +0000105
106 NSSize remoteViewSize = [self remoteVideoViewSize];
107 NSDictionary* metrics = @{
tkchin@webrtc.orgacca6752014-05-30 22:26:06 +0000108 @"remoteViewWidth" : @(remoteViewSize.width),
109 @"remoteViewHeight" : @(remoteViewSize.height),
denicija647915f2016-10-20 01:46:41 -0700110 @"kBottomViewHeight" : @(kBottomViewHeight),
111 @"localViewHeight" : @(remoteViewSize.height / 3),
112 @"localViewWidth" : @(remoteViewSize.width / 3),
113 @"kRoomFieldWidth" : @(kRoomFieldWidth),
114 @"kActionItemHeight" : @(kActionItemHeight)
tkchin@webrtc.orgacca6752014-05-30 22:26:06 +0000115 };
116 // Declare this separately to avoid compiler warning about splitting string
117 // within an NSArray expression.
denicija647915f2016-10-20 01:46:41 -0700118 NSString* verticalConstraintLeft =
119 @"V:|-[_remoteVideoView(remoteViewHeight)]-[_scrollView(kBottomViewHeight)]-|";
120 NSString* verticalConstraintRight =
121 @"V:|-[_remoteVideoView(remoteViewHeight)]-[_actionItemsView(kBottomViewHeight)]-|";
tkchin@webrtc.orgacca6752014-05-30 22:26:06 +0000122 NSArray* constraintFormats = @[
denicija647915f2016-10-20 01:46:41 -0700123 verticalConstraintLeft,
124 verticalConstraintRight,
125 @"H:|-[_remoteVideoView(remoteViewWidth)]-|",
126 @"V:|-[_localVideoView(localViewHeight)]",
127 @"H:|-[_localVideoView(localViewWidth)]",
128 @"H:|-[_scrollView(==_actionItemsView)]-[_actionItemsView]-|"
tkchin@webrtc.orgacca6752014-05-30 22:26:06 +0000129 ];
denicija647915f2016-10-20 01:46:41 -0700130
131 NSArray* actionItemsConstraints = @[
132 @"H:|-[_roomField(kRoomFieldWidth)]-[_loopbackButton(kRoomFieldWidth)]",
133 @"H:|-[_connectButton(kRoomFieldWidth)]",
134 @"V:|-[_roomField(kActionItemHeight)]-[_connectButton(kActionItemHeight)]",
135 @"V:|-[_loopbackButton(kActionItemHeight)]",
136 ];
137
138 [APPRTCMainView addConstraints:constraintFormats
139 toView:self
140 viewsDictionary:viewsDictionary
141 metrics:metrics];
142 [APPRTCMainView addConstraints:actionItemsConstraints
143 toView:_actionItemsView
144 viewsDictionary:viewsDictionary
145 metrics:metrics];
tkchin@webrtc.orgacca6752014-05-30 22:26:06 +0000146 [super updateConstraints];
147}
148
denicija647915f2016-10-20 01:46:41 -0700149#pragma mark - Constraints helper
150
151+ (void)addConstraints:(NSArray*)constraints toView:(NSView*)view
152 viewsDictionary:(NSDictionary*)viewsDictionary
153 metrics:(NSDictionary*)metrics {
154 for (NSString* constraintFormat in constraints) {
155 NSArray* constraints =
156 [NSLayoutConstraint constraintsWithVisualFormat:constraintFormat
157 options:0
158 metrics:metrics
159 views:viewsDictionary];
160 for (NSLayoutConstraint* constraint in constraints) {
161 [view addConstraint:constraint];
162 }
163 }
tkchin@webrtc.orgacca6752014-05-30 22:26:06 +0000164}
165
denicija647915f2016-10-20 01:46:41 -0700166#pragma mark - Control actions
tkchin@webrtc.orgacca6752014-05-30 22:26:06 +0000167
denicija647915f2016-10-20 01:46:41 -0700168- (void)startCall:(id)sender {
169 NSString* roomString = _roomField.stringValue;
170 // Generate room id for loopback options.
171 if (_loopbackButton.intValue && [roomString isEqualToString:@""]) {
172 roomString = [NSUUID UUID].UUIDString;
173 roomString = [roomString stringByReplacingOccurrencesOfString:@"-" withString:@""];
tkchin@webrtc.orgacca6752014-05-30 22:26:06 +0000174 }
denicija647915f2016-10-20 01:46:41 -0700175 [self.delegate appRTCMainView:self
176 didEnterRoomId:roomString
177 loopback:_loopbackButton.intValue];
denicija124a6fc2017-03-31 02:47:29 -0700178 [self setNeedsUpdateConstraints:YES];
tkchin@webrtc.orgacca6752014-05-30 22:26:06 +0000179}
180
181#pragma mark - RTCNSGLVideoViewDelegate
182
183- (void)videoView:(RTCNSGLVideoView*)videoView
184 didChangeVideoSize:(NSSize)size {
185 if (videoView == _remoteVideoView) {
186 _remoteVideoSize = size;
187 } else if (videoView == _localVideoView) {
188 _localVideoSize = size;
189 } else {
190 return;
191 }
denicija647915f2016-10-20 01:46:41 -0700192
tkchin@webrtc.orgacca6752014-05-30 22:26:06 +0000193 [self setNeedsUpdateConstraints:YES];
194}
195
196#pragma mark - Private
197
198- (void)setupViews {
199 NSParameterAssert([[self subviews] count] == 0);
200
tkchin@webrtc.orgacca6752014-05-30 22:26:06 +0000201 _logView = [[NSTextView alloc] initWithFrame:NSZeroRect];
denicija647915f2016-10-20 01:46:41 -0700202 [_logView setMinSize:NSMakeSize(0, kBottomViewHeight)];
tkchin@webrtc.orgacca6752014-05-30 22:26:06 +0000203 [_logView setMaxSize:NSMakeSize(FLT_MAX, FLT_MAX)];
204 [_logView setVerticallyResizable:YES];
205 [_logView setAutoresizingMask:NSViewWidthSizable];
206 NSTextContainer* textContainer = [_logView textContainer];
207 NSSize containerSize = NSMakeSize(kContentWidth, FLT_MAX);
208 [textContainer setContainerSize:containerSize];
209 [textContainer setWidthTracksTextView:YES];
210 [_logView setEditable:NO];
211
denicija647915f2016-10-20 01:46:41 -0700212 [self setupActionItemsView];
213
tkchin@webrtc.orgacca6752014-05-30 22:26:06 +0000214 _scrollView = [[NSScrollView alloc] initWithFrame:NSZeroRect];
215 [_scrollView setTranslatesAutoresizingMaskIntoConstraints:NO];
216 [_scrollView setHasVerticalScroller:YES];
217 [_scrollView setDocumentView:_logView];
218 [self addSubview:_scrollView];
219
denicija124a6fc2017-03-31 02:47:29 -0700220// NOTE (daniela): Ignoring Clang diagonstic here.
221// We're performing run time check to make sure class is available on runtime.
222// If not we're providing sensible default.
223#pragma clang diagnostic push
224#pragma clang diagnostic ignored "-Wpartial-availability"
adam.fedor42742a52017-06-12 07:32:02 -0700225 if ([RTCMTLNSVideoView class] && [RTCMTLNSVideoView isMetalAvailable]) {
denicija124a6fc2017-03-31 02:47:29 -0700226 _remoteVideoView = [[RTCMTLNSVideoView alloc] initWithFrame:NSZeroRect];
227 _localVideoView = [[RTCMTLNSVideoView alloc] initWithFrame:NSZeroRect];
adam.fedor42742a52017-06-12 07:32:02 -0700228 }
229#pragma clang diagnostic pop
230 if (_remoteVideoView == nil) {
denicija124a6fc2017-03-31 02:47:29 -0700231 NSOpenGLPixelFormatAttribute attributes[] = {
232 NSOpenGLPFADoubleBuffer,
233 NSOpenGLPFADepthSize, 24,
234 NSOpenGLPFAOpenGLProfile,
235 NSOpenGLProfileVersion3_2Core,
236 0
237 };
238 NSOpenGLPixelFormat* pixelFormat =
239 [[NSOpenGLPixelFormat alloc] initWithAttributes:attributes];
240
241 RTCNSGLVideoView* remote =
242 [[RTCNSGLVideoView alloc] initWithFrame:NSZeroRect pixelFormat:pixelFormat];
243 remote.delegate = self;
244 _remoteVideoView = remote;
245
246 RTCNSGLVideoView* local =
247 [[RTCNSGLVideoView alloc] initWithFrame:NSZeroRect pixelFormat:pixelFormat];
248 local.delegate = self;
249 _localVideoView = local;
250 }
denicija124a6fc2017-03-31 02:47:29 -0700251
252 [_remoteVideoView setTranslatesAutoresizingMaskIntoConstraints:NO];
253 [self addSubview:_remoteVideoView];
kthelgason314bc5f2016-08-31 10:23:27 -0700254 [_localVideoView setTranslatesAutoresizingMaskIntoConstraints:NO];
kthelgason314bc5f2016-08-31 10:23:27 -0700255 [self addSubview:_localVideoView];
tkchin@webrtc.orgacca6752014-05-30 22:26:06 +0000256}
257
denicija647915f2016-10-20 01:46:41 -0700258- (void)setupActionItemsView {
259 _actionItemsView = [[NSView alloc] initWithFrame:NSZeroRect];
260 [_actionItemsView setTranslatesAutoresizingMaskIntoConstraints:NO];
261 [self addSubview:_actionItemsView];
262
263 _roomField = [[NSTextField alloc] initWithFrame:NSZeroRect];
264 [_roomField setTranslatesAutoresizingMaskIntoConstraints:NO];
magjeda445b9b2017-02-20 07:56:53 -0800265 [[_roomField cell] setPlaceholderString: @"Enter AppRTC room id"];
denicija647915f2016-10-20 01:46:41 -0700266 [_actionItemsView addSubview:_roomField];
267 [_roomField setEditable:YES];
268
269 _connectButton = [[NSButton alloc] initWithFrame:NSZeroRect];
270 [_connectButton setTranslatesAutoresizingMaskIntoConstraints:NO];
271 _connectButton.title = @"Start call";
272 _connectButton.bezelStyle = NSRoundedBezelStyle;
273 _connectButton.target = self;
274 _connectButton.action = @selector(startCall:);
275 [_actionItemsView addSubview:_connectButton];
276
277 _loopbackButton = [[NSButton alloc] initWithFrame:NSZeroRect];
278 [_loopbackButton setTranslatesAutoresizingMaskIntoConstraints:NO];
279 _loopbackButton.title = @"Loopback";
280 [_loopbackButton setButtonType:NSSwitchButton];
281 [_actionItemsView addSubview:_loopbackButton];
282}
283
tkchin@webrtc.orgacca6752014-05-30 22:26:06 +0000284- (NSSize)remoteVideoViewSize {
denicija647915f2016-10-20 01:46:41 -0700285 if (!_remoteVideoView.bounds.size.width) {
286 return NSMakeSize(kContentWidth, 0);
287 }
288 NSInteger width = MAX(_remoteVideoView.bounds.size.width, kContentWidth);
kthelgason314bc5f2016-08-31 10:23:27 -0700289 NSInteger height = (width/16) * 9;
290 return NSMakeSize(width, height);
tkchin@webrtc.orgacca6752014-05-30 22:26:06 +0000291}
292
293@end
294
295@interface APPRTCViewController ()
tkchin@webrtc.org87776a82014-12-09 19:32:35 +0000296 <ARDAppClientDelegate, APPRTCMainViewDelegate>
tkchin@webrtc.orgacca6752014-05-30 22:26:06 +0000297@property(nonatomic, readonly) APPRTCMainView* mainView;
298@end
299
300@implementation APPRTCViewController {
tkchin@webrtc.org87776a82014-12-09 19:32:35 +0000301 ARDAppClient* _client;
tkchin@webrtc.org81257442014-11-04 23:06:15 +0000302 RTCVideoTrack* _localVideoTrack;
303 RTCVideoTrack* _remoteVideoTrack;
sakalc522e752017-04-05 12:17:48 -0700304 ARDCaptureController* _captureController;
tkchin@webrtc.orgacca6752014-05-30 22:26:06 +0000305}
306
tkchin@webrtc.orgacca6752014-05-30 22:26:06 +0000307- (void)dealloc {
308 [self disconnect];
309}
310
denicija647915f2016-10-20 01:46:41 -0700311- (void)viewDidAppear {
312 [super viewDidAppear];
313 [self displayUsageInstructions];
314}
315
tkchin@webrtc.orgacca6752014-05-30 22:26:06 +0000316- (void)loadView {
317 APPRTCMainView* view = [[APPRTCMainView alloc] initWithFrame:NSZeroRect];
318 [view setTranslatesAutoresizingMaskIntoConstraints:NO];
319 view.delegate = self;
320 self.view = view;
321}
322
323- (void)windowWillClose:(NSNotification*)notification {
324 [self disconnect];
325}
326
denicija647915f2016-10-20 01:46:41 -0700327#pragma mark - Usage
328
329- (void)displayUsageInstructions {
330 [self.mainView displayLogMessage:
331 @"To start call:\n"
332 @"• Enter AppRTC room id (not neccessary for loopback)\n"
333 @"• Start call"];
334}
335
tkchin@webrtc.org87776a82014-12-09 19:32:35 +0000336#pragma mark - ARDAppClientDelegate
tkchin@webrtc.orgacca6752014-05-30 22:26:06 +0000337
tkchin@webrtc.org87776a82014-12-09 19:32:35 +0000338- (void)appClient:(ARDAppClient *)client
339 didChangeState:(ARDAppClientState)state {
340 switch (state) {
341 case kARDAppClientStateConnected:
denicija647915f2016-10-20 01:46:41 -0700342 [self.mainView displayLogMessage:@"Client connected."];
tkchin@webrtc.org87776a82014-12-09 19:32:35 +0000343 break;
344 case kARDAppClientStateConnecting:
denicija647915f2016-10-20 01:46:41 -0700345 [self.mainView displayLogMessage:@"Client connecting."];
tkchin@webrtc.org87776a82014-12-09 19:32:35 +0000346 break;
347 case kARDAppClientStateDisconnected:
denicija647915f2016-10-20 01:46:41 -0700348 [self.mainView displayLogMessage:@"Client disconnected."];
tkchin@webrtc.org87776a82014-12-09 19:32:35 +0000349 [self resetUI];
350 _client = nil;
351 break;
352 }
353}
354
355- (void)appClient:(ARDAppClient *)client
hjon79858f82016-03-13 22:08:26 -0700356 didChangeConnectionState:(RTCIceConnectionState)state {
tkchin@webrtc.org3a63a3c2015-01-06 07:21:34 +0000357}
358
sakalc522e752017-04-05 12:17:48 -0700359- (void)appClient:(ARDAppClient*)client
360 didCreateLocalCapturer:(RTCCameraVideoCapturer*)localCapturer {
361 _captureController =
362 [[ARDCaptureController alloc] initWithCapturer:localCapturer
363 settings:[[ARDSettingsModel alloc] init]];
364 [_captureController startCapture];
365}
366
tkchin@webrtc.org3a63a3c2015-01-06 07:21:34 +0000367- (void)appClient:(ARDAppClient *)client
tkchin@webrtc.org87776a82014-12-09 19:32:35 +0000368 didReceiveLocalVideoTrack:(RTCVideoTrack *)localVideoTrack {
tkchin@webrtc.org81257442014-11-04 23:06:15 +0000369 _localVideoTrack = localVideoTrack;
kthelgason314bc5f2016-08-31 10:23:27 -0700370 [_localVideoTrack addRenderer:self.mainView.localVideoView];
tkchin@webrtc.orgacca6752014-05-30 22:26:06 +0000371}
372
tkchin@webrtc.org87776a82014-12-09 19:32:35 +0000373- (void)appClient:(ARDAppClient *)client
374 didReceiveRemoteVideoTrack:(RTCVideoTrack *)remoteVideoTrack {
tkchin@webrtc.org81257442014-11-04 23:06:15 +0000375 _remoteVideoTrack = remoteVideoTrack;
376 [_remoteVideoTrack addRenderer:self.mainView.remoteVideoView];
tkchin@webrtc.orgacca6752014-05-30 22:26:06 +0000377}
378
tkchin@webrtc.org87776a82014-12-09 19:32:35 +0000379- (void)appClient:(ARDAppClient *)client
380 didError:(NSError *)error {
381 [self showAlertWithMessage:[NSString stringWithFormat:@"%@", error]];
tkchin@webrtc.orgacca6752014-05-30 22:26:06 +0000382 [self disconnect];
383}
384
Zeke Chind3325802015-08-14 11:00:02 -0700385- (void)appClient:(ARDAppClient *)client
386 didGetStats:(NSArray *)stats {
387}
388
tkchin@webrtc.orgacca6752014-05-30 22:26:06 +0000389#pragma mark - APPRTCMainViewDelegate
390
391- (void)appRTCMainView:(APPRTCMainView*)mainView
denicija647915f2016-10-20 01:46:41 -0700392 didEnterRoomId:(NSString*)roomId
393 loopback:(BOOL)isLoopback {
394
395 if ([roomId isEqualToString:@""]) {
396 [self.mainView displayLogMessage:@"Missing room id"];
397 return;
398 }
399
sakalc522e752017-04-05 12:17:48 -0700400 [self disconnect];
sakalc4adacf2017-03-28 01:22:48 -0700401 ARDAppClient* client = [[ARDAppClient alloc] initWithDelegate:self];
tkchinab1293a2016-08-30 12:35:05 -0700402 [client connectToRoomWithId:roomId
sakalc4adacf2017-03-28 01:22:48 -0700403 settings:[[ARDSettingsModel alloc] init] // Use default settings.
Anders Carlssone1500582017-06-15 16:05:13 +0200404 isLoopback:isLoopback];
tkchin@webrtc.org87776a82014-12-09 19:32:35 +0000405 _client = client;
tkchin@webrtc.orgacca6752014-05-30 22:26:06 +0000406}
407
408#pragma mark - Private
409
410- (APPRTCMainView*)mainView {
411 return (APPRTCMainView*)self.view;
412}
413
414- (void)showAlertWithMessage:(NSString*)message {
adam.fedor8c6afef2017-06-13 05:25:33 -0700415 dispatch_async(dispatch_get_main_queue(), ^{
416 NSAlert* alert = [[NSAlert alloc] init];
417 [alert setMessageText:message];
418 [alert runModal];
419 });
tkchin@webrtc.orgacca6752014-05-30 22:26:06 +0000420}
421
tkchin@webrtc.org87776a82014-12-09 19:32:35 +0000422- (void)resetUI {
tkchin@webrtc.org81257442014-11-04 23:06:15 +0000423 [_remoteVideoTrack removeRenderer:self.mainView.remoteVideoView];
kthelgason314bc5f2016-08-31 10:23:27 -0700424 [_localVideoTrack removeRenderer:self.mainView.localVideoView];
tkchin@webrtc.org81257442014-11-04 23:06:15 +0000425 _remoteVideoTrack = nil;
kthelgason314bc5f2016-08-31 10:23:27 -0700426 _localVideoTrack = nil;
tkchin@webrtc.org81257442014-11-04 23:06:15 +0000427 [self.mainView.remoteVideoView renderFrame:nil];
kthelgason314bc5f2016-08-31 10:23:27 -0700428 [self.mainView.localVideoView renderFrame:nil];
tkchin@webrtc.org87776a82014-12-09 19:32:35 +0000429}
430
431- (void)disconnect {
432 [self resetUI];
sakalc522e752017-04-05 12:17:48 -0700433 [_captureController stopCapture];
434 _captureController = nil;
tkchin@webrtc.org87776a82014-12-09 19:32:35 +0000435 [_client disconnect];
tkchin@webrtc.orgacca6752014-05-30 22:26:06 +0000436}
437
438@end