Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,5 @@ xcuserdata
# Misc
.DS_Store
#*.lock

.idea/
17 changes: 9 additions & 8 deletions AppRTC/ARTCVideoChatViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

#import "ARTCVideoChatViewController.h"
#import <AVFoundation/AVFoundation.h>
#import "RTCI420Frame.h"

#define SERVER_HOST_URL @"https://apprtc.appspot.com"

Expand Down Expand Up @@ -37,11 +38,11 @@ - (void)viewDidLoad {
//RTCEAGLVideoViewDelegate provides notifications on video frame dimensions
[self.remoteView setDelegate:self];
[self.localView setDelegate:self];

//Getting Orientation change
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(orientationChanged:)
name:@"UIDeviceOrientationDidChangeNotification"
name:UIDeviceOrientationDidChangeNotification
object:nil];


Expand Down Expand Up @@ -70,7 +71,7 @@ - (void)viewWillAppear:(BOOL)animated {

- (void)viewWillDisappear:(BOOL)animated {
[super viewWillDisappear:animated];
[[NSNotificationCenter defaultCenter] removeObserver:self name:@"UIDeviceOrientationDidChangeNotification" object:nil];
[[NSNotificationCenter defaultCenter] removeObserver:self name:UIDeviceOrientationDidChangeNotification object:nil];
[self disconnect];
}

Expand All @@ -82,7 +83,7 @@ - (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
}

- (void)orientationChanged:(NSNotification *)notification{
- (void)orientationChanged:(NSNotification *)notification {
[self videoView:self.localView didChangeVideoSize:self.localVideoSize];
[self videoView:self.remoteView didChangeVideoSize:self.remoteVideoSize];
}
Expand Down Expand Up @@ -200,6 +201,7 @@ - (void)appClient:(ARDAppClient *)client didReceiveLocalVideoTrack:(RTCVideoTrac

- (void)appClient:(ARDAppClient *)client didReceiveRemoteVideoTrack:(RTCVideoTrack *)remoteVideoTrack {
self.remoteVideoTrack = remoteVideoTrack;

[self.remoteVideoTrack addRenderer:self.remoteView];

[UIView animateWithDuration:0.4f animations:^{
Expand Down Expand Up @@ -237,12 +239,12 @@ - (void)videoView:(RTCEAGLVideoView *)videoView didChangeVideoSize:(CGSize)size
CGRect videoRect = self.view.bounds;
if (self.remoteVideoTrack) {
videoRect = CGRectMake(0.0f, 0.0f, self.view.frame.size.width/4.0f, self.view.frame.size.height/4.0f);
if (orientation == UIDeviceOrientationLandscapeLeft || orientation == UIDeviceOrientationLandscapeRight) {
if ( orientation == UIDeviceOrientationLandscapeLeft || orientation == UIDeviceOrientationLandscapeRight ) {
videoRect = CGRectMake(0.0f, 0.0f, self.view.frame.size.height/4.0f, self.view.frame.size.width/4.0f);
}
}
CGRect videoFrame = AVMakeRectWithAspectRatioInsideRect(aspectRatio, videoRect);

//Resize the localView accordingly
[self.localViewWidthConstraint setConstant:videoFrame.size.width];
[self.localViewHeightConstraint setConstant:videoFrame.size.height];
Expand All @@ -253,7 +255,7 @@ - (void)videoView:(RTCEAGLVideoView *)videoView didChangeVideoSize:(CGSize)size
[self.localViewBottomConstraint setConstant:containerHeight/2.0f - videoFrame.size.height/2.0f]; //center
[self.localViewRightConstraint setConstant:containerWidth/2.0f - videoFrame.size.width/2.0f]; //center
}
} else if (videoView == self.remoteView) {
} else if ( videoView == self.remoteView ) {
//Resize Remote View
self.remoteVideoSize = size;
CGSize aspectRatio = CGSizeEqualToSize(size, CGSizeZero) ? defaultAspectRatio : size;
Expand All @@ -269,7 +271,6 @@ - (void)videoView:(RTCEAGLVideoView *)videoView didChangeVideoSize:(CGSize)size
[self.remoteViewBottomConstraint setConstant:containerHeight/2.0f - videoFrame.size.height/2.0f];
[self.remoteViewLeftConstraint setConstant:containerWidth/2.0f - videoFrame.size.width/2.0f]; //center
[self.remoteViewRightConstraint setConstant:containerWidth/2.0f - videoFrame.size.width/2.0f]; //center

}
[self.view layoutIfNeeded];
}];
Expand Down
25 changes: 23 additions & 2 deletions AppRTC/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="6254" systemVersion="14C109" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="bnz-jK-0BD">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="9059" systemVersion="15B42" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="bnz-jK-0BD">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="6247"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="9049"/>
<capability name="Constraints to layout margins" minToolsVersion="6.0"/>
</dependencies>
<scenes>
Expand All @@ -12,15 +12,19 @@
<tableView key="view" clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="none" rowHeight="200" sectionHeaderHeight="22" sectionFooterHeight="22" id="IFV-7L-xYh">
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<animations/>
<color key="backgroundColor" red="0.20000000000000001" green="0.20000000000000001" blue="0.20000000000000001" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<prototypes>
<tableViewCell contentMode="scaleToFill" selectionStyle="none" indentationWidth="10" reuseIdentifier="RoomInputCell" rowHeight="200" id="Heo-uc-TEk" customClass="ARTCRoomTextInputViewCell">
<rect key="frame" x="0.0" y="86" width="600" height="200"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="Heo-uc-TEk" id="6ns-Sh-XIS">
<rect key="frame" x="0.0" y="0.0" width="600" height="200"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Please enter a room name." lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="lZU-wT-4R2">
<rect key="frame" x="18" y="18" width="227" height="21"/>
<animations/>
<constraints>
<constraint firstAttribute="height" constant="21" id="gqJ-eG-fUp"/>
<constraint firstAttribute="width" constant="227" id="iY4-S4-htt"/>
Expand All @@ -31,6 +35,7 @@
</label>
<textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="Eeb-KL-uNd">
<rect key="frame" x="40" y="48" width="520" height="40"/>
<animations/>
<color key="backgroundColor" red="0.20000000000000001" green="0.20000000000000001" blue="0.20000000000000001" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstAttribute="height" constant="40" id="9ze-gS-mBa"/>
Expand All @@ -41,13 +46,15 @@
</textField>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="jtB-pv-Mwr">
<rect key="frame" x="40" y="88" width="520" height="2"/>
<animations/>
<color key="backgroundColor" red="0.25882352941176473" green="0.52156862745098043" blue="0.95686274509803926" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstAttribute="height" constant="2" id="Jev-MF-QWj"/>
</constraints>
</view>
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Room name must be 5 or more characters and include only letters and numbers." lineBreakMode="wordWrap" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="B7r-GU-GE9">
<rect key="frame" x="40" y="93" width="520" height="40"/>
<animations/>
<constraints>
<constraint firstAttribute="height" constant="40" id="hig-Mv-0iO"/>
</constraints>
Expand All @@ -57,6 +64,7 @@
</label>
<button opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="qhI-9B-9dZ">
<rect key="frame" x="40" y="147" width="100" height="40"/>
<animations/>
<color key="backgroundColor" red="0.25882352941176473" green="0.52156862745098043" blue="0.95686274509803926" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstAttribute="width" constant="100" id="aIa-9M-AvQ"/>
Expand All @@ -80,6 +88,7 @@
</connections>
</button>
</subviews>
<animations/>
<color key="backgroundColor" red="0.20000000000000001" green="0.20000000000000001" blue="0.20000000000000001" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstAttribute="trailing" secondItem="jtB-pv-Mwr" secondAttribute="trailing" constant="40" id="6vJ-Vi-soP"/>
Expand All @@ -97,6 +106,7 @@
<constraint firstItem="jtB-pv-Mwr" firstAttribute="top" secondItem="Eeb-KL-uNd" secondAttribute="bottom" id="zOa-0z-oLA"/>
</constraints>
</tableViewCellContentView>
<animations/>
<color key="backgroundColor" red="0.20000000000000001" green="0.20000000000000001" blue="0.20000000000000001" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<connections>
<outlet property="errorLabel" destination="B7r-GU-GE9" id="1NR-J3-Q6m"/>
Expand Down Expand Up @@ -135,10 +145,12 @@
<subviews>
<view contentMode="scaleAspectFit" translatesAutoresizingMaskIntoConstraints="NO" id="hBv-zP-oWI" userLabel="Remote View" customClass="RTCEAGLVideoView">
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
<animations/>
<color key="backgroundColor" red="0.40000000000000002" green="0.40000000000000002" blue="0.40000000000000002" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</view>
<view contentMode="scaleAspectFit" translatesAutoresizingMaskIntoConstraints="NO" id="pNG-Z1-33i" userLabel="Local View" customClass="RTCEAGLVideoView">
<rect key="frame" x="452" y="452" width="120" height="120"/>
<animations/>
<color key="backgroundColor" red="0.20000000000000001" green="0.20000000000000001" blue="0.20000000000000001" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstAttribute="width" constant="120" id="CeK-nw-lub"/>
Expand All @@ -150,6 +162,7 @@
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Waiting for someone to join this room: " lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="2OI-v1-phz">
<rect key="frame" x="10" y="10" width="580" height="21"/>
<animations/>
<constraints>
<constraint firstAttribute="height" constant="21" id="qyF-Ki-4dS"/>
</constraints>
Expand All @@ -159,6 +172,7 @@
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="https://apprtc.appspot.com/r/room" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="X4B-RQ-879">
<rect key="frame" x="10" y="32" width="580" height="21"/>
<animations/>
<constraints>
<constraint firstAttribute="height" constant="21" id="fbZ-rW-rtx"/>
</constraints>
Expand All @@ -167,6 +181,7 @@
<nil key="highlightedColor"/>
</label>
</subviews>
<animations/>
<color key="backgroundColor" red="0.20000000000000001" green="0.20000000000000001" blue="0.20000000000000001" alpha="0.5" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstItem="2OI-v1-phz" firstAttribute="leading" secondItem="dd3-fP-LRC" secondAttribute="leading" constant="10" id="2F2-hY-vLx"/>
Expand All @@ -183,6 +198,7 @@
<subviews>
<button opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="aRA-AT-ApW" userLabel="Audio Button">
<rect key="frame" x="0.0" y="0.0" width="40" height="40"/>
<animations/>
<color key="backgroundColor" red="0.0" green="0.0" blue="0.0" alpha="0.20000000000000001" colorSpace="custom" customColorSpace="sRGB"/>
<state key="normal" image="audioOn">
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
Expand All @@ -193,6 +209,7 @@
</button>
<button opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="76V-d2-VYt" userLabel="Video Button">
<rect key="frame" x="0.0" y="60" width="40" height="40"/>
<animations/>
<color key="backgroundColor" red="0.0" green="0.0" blue="0.0" alpha="0.20000000000000001" colorSpace="custom" customColorSpace="sRGB"/>
<state key="normal" image="videoOn">
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
Expand All @@ -203,6 +220,7 @@
</button>
<button opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="GG8-K5-Ssv" userLabel="Hangup Button">
<rect key="frame" x="0.0" y="120" width="40" height="40"/>
<animations/>
<color key="backgroundColor" red="0.0" green="0.0" blue="0.0" alpha="0.20000000000000001" colorSpace="custom" customColorSpace="sRGB"/>
<state key="normal" image="hangup">
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
Expand All @@ -212,13 +230,15 @@
</connections>
</button>
</subviews>
<animations/>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
<constraints>
<constraint firstAttribute="height" constant="160" id="JCv-a1-f3A"/>
<constraint firstAttribute="width" constant="40" id="aRx-iH-5wU"/>
</constraints>
</view>
</subviews>
<animations/>
<color key="backgroundColor" white="0.0" alpha="1" colorSpace="calibratedWhite"/>
<constraints>
<constraint firstItem="yGf-SH-nK1" firstAttribute="top" secondItem="hBv-zP-oWI" secondAttribute="bottom" id="0G3-Sw-emm"/>
Expand Down Expand Up @@ -268,6 +288,7 @@
<navigationBar key="navigationBar" contentMode="scaleToFill" barStyle="black" id="jkN-Cj-PtW">
<rect key="frame" x="0.0" y="0.0" width="320" height="44"/>
<autoresizingMask key="autoresizingMask"/>
<animations/>
<color key="barTintColor" red="0.20000000000000001" green="0.20000000000000001" blue="0.20000000000000001" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</navigationBar>
<connections>
Expand Down
Loading