Skip to content

Commit

Permalink
Moved videotrack unwrapping out of VC
Browse files Browse the repository at this point in the history
  • Loading branch information
MattGson committed Jul 23, 2017
1 parent 7a51b7d commit 4d66e28
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 11 deletions.
8 changes: 5 additions & 3 deletions RTClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import SocketRocket

protocol RTClientDelegate {

func addedStream(stream:RTCMediaStream);
func addedRemoteVideoTrack(videoTrack:RTCVideoTrack);
func didConnect();
func didDisconnect();
}
Expand Down Expand Up @@ -201,8 +201,10 @@ extension RTClient:WebRTCDelegate {
func addedStream(stream: RTCMediaStream) {

self.remoteStream = stream;
self.delegate.addedStream(stream: self.remoteStream!);

if (stream.videoTracks.count > 0) {
let remoteTrack:RTCVideoTrack = stream.videoTracks[0] as! RTCVideoTrack;
self.delegate.addedRemoteVideoTrack(videoTrack: remoteTrack);
}
}

}
12 changes: 4 additions & 8 deletions ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -72,22 +72,18 @@ class ViewController: UIViewController {

extension ViewController:RTClientDelegate {

func addedStream(stream: RTCMediaStream) {

if (stream.videoTracks.count > 0) {
let remoteTrack:RTCVideoTrack = stream.videoTracks[0] as! RTCVideoTrack;
func addedRemoteVideoTrack(videoTrack:RTCVideoTrack) {

if (self.remoteVideoTrack != nil) {
self.remoteVideoTrack?.remove(self.remoteView);
self.remoteVideoTrack = nil;
self.remoteView.renderFrame(nil);
}

self.remoteVideoTrack = remoteTrack;
self.remoteVideoTrack = videoTrack;
self.remoteVideoTrack?.add(self.remoteView);
}
}




func didConnect() {
self.setLocalPreview();
Expand Down

0 comments on commit 4d66e28

Please sign in to comment.