Chromium Code Reviews| Index: webrtc/examples/objc/AppRTCDemo/mac/APPRTCViewController.m |
| diff --git a/webrtc/examples/objc/AppRTCDemo/mac/APPRTCViewController.m b/webrtc/examples/objc/AppRTCDemo/mac/APPRTCViewController.m |
| index 0f4a54e88e882fd801a50439a338e774eabf4386..eaca2e9c26eb7e6833bc3f8561cbb07df8e9317c 100644 |
| --- a/webrtc/examples/objc/AppRTCDemo/mac/APPRTCViewController.m |
| +++ b/webrtc/examples/objc/AppRTCDemo/mac/APPRTCViewController.m |
| @@ -21,6 +21,7 @@ static NSUInteger const kContentWidth = 1280; |
| static NSUInteger const kContentHeight = 720; |
| static NSUInteger const kRoomFieldWidth = 80; |
| static NSUInteger const kLogViewHeight = 280; |
| +static NSUInteger const kPreviewWidth = 490; |
| @class APPRTCMainView; |
| @protocol APPRTCMainViewDelegate |
| @@ -74,14 +75,18 @@ static NSUInteger const kLogViewHeight = 280; |
| NSDictionaryOfVariableBindings(_roomLabel, |
| _roomField, |
| _scrollView, |
| - _remoteVideoView); |
| + _remoteVideoView, |
| + _localVideoView); |
| NSSize remoteViewSize = [self remoteVideoViewSize]; |
| NSDictionary* metrics = @{ |
| @"kLogViewHeight" : @(kLogViewHeight), |
| + @"kPreviewWidth" : @(kPreviewWidth), |
| @"kRoomFieldWidth" : @(kRoomFieldWidth), |
| @"remoteViewWidth" : @(remoteViewSize.width), |
| @"remoteViewHeight" : @(remoteViewSize.height), |
| + @"localViewHeight" : @(remoteViewSize.height), |
| + @"scrollViewWidth" : @(kContentWidth - kPreviewWidth), |
| }; |
| // Declare this separately to avoid compiler warning about splitting string |
| // within an NSArray expression. |
| @@ -90,10 +95,14 @@ static NSUInteger const kLogViewHeight = 280; |
| "-[_remoteVideoView(remoteViewHeight)]-|"; |
| NSArray* constraintFormats = @[ |
| verticalConstraint, |
| + @"V:[_localVideoView]-[_remoteVideoView]", |
| + @"V:[_localVideoView(kLogViewHeight)]", |
| @"|-[_roomLabel]", |
| @"|-[_roomField(kRoomFieldWidth)]", |
| - @"|-[_scrollView(remoteViewWidth)]-|", |
| + @"|-[_scrollView(scrollViewWidth)]", |
| + @"[_scrollView]-[_localVideoView]", |
| @"|-[_remoteVideoView(remoteViewWidth)]-|", |
| + @"[_localVideoView(kPreviewWidth)]-|", |
| ]; |
| for (NSString* constraintFormat in constraintFormats) { |
| NSArray* constraints = |
| @@ -190,20 +199,17 @@ static NSUInteger const kLogViewHeight = 280; |
| _remoteVideoView.delegate = self; |
| [self addSubview:_remoteVideoView]; |
| - // TODO(tkchin): create local video view. |
| - // https://code.google.com/p/webrtc/issues/detail?id=3417. |
| + _localVideoView = [[RTCNSGLVideoView alloc] initWithFrame:NSZeroRect |
| + pixelFormat:pixelFormat]; |
| + [_localVideoView setTranslatesAutoresizingMaskIntoConstraints:NO]; |
| + _localVideoView.delegate = self; |
| + [self addSubview:_localVideoView]; |
| } |
| - (NSSize)remoteVideoViewSize { |
| - if (_remoteVideoSize.width > 0 && _remoteVideoSize.height > 0) { |
| - return _remoteVideoSize; |
| - } else { |
| - return NSMakeSize(kContentWidth, kContentHeight); |
| - } |
| -} |
| - |
| -- (NSSize)localVideoViewSize { |
| - return NSZeroSize; |
| + NSInteger w = MAX(_remoteVideoSize.width, kContentWidth); |
|
tkchin_webrtc
2016/08/26 22:55:30
nits: width, height
(w / 16)
|
| + NSInteger h = (w/16) * 9; |
| + return NSMakeSize(w, h); |
| } |
| @end |
| @@ -260,6 +266,7 @@ static NSUInteger const kLogViewHeight = 280; |
| - (void)appClient:(ARDAppClient *)client |
| didReceiveLocalVideoTrack:(RTCVideoTrack *)localVideoTrack { |
| _localVideoTrack = localVideoTrack; |
| + [_localVideoTrack addRenderer:self.mainView.localVideoView]; |
| } |
| - (void)appClient:(ARDAppClient *)client |
| @@ -302,8 +309,11 @@ static NSUInteger const kLogViewHeight = 280; |
| - (void)resetUI { |
| [_remoteVideoTrack removeRenderer:self.mainView.remoteVideoView]; |
| + [_localVideoTrack removeRenderer:self.mainView.localVideoView]; |
| _remoteVideoTrack = nil; |
| + _localVideoTrack = nil; |
| [self.mainView.remoteVideoView renderFrame:nil]; |
| + [self.mainView.localVideoView renderFrame:nil]; |
| } |
| - (void)disconnect { |