I have created RTCMTLVideoView throught Outlet.
@IBOutlet weak var otherEndVideoHolderView : RTCMTLVideoView!
And collected RTCMediaStream From the RTCPeerConnectionDelegate Delegate
func peerConnection(_ peerConnection: RTCPeerConnection, didAdd stream: RTCMediaStream) {
debugPrint("peerConnection did add stream")
if let video = stream.videoTracks.first{
self.remoteVideoTrack = video
self.delegate?.webRTCClient(self, didReceiveRemoteRender: video)
}
}
After Offer -> Answer -> and peer status to connected. Only local video is rendering. Remote video is not rendering.
I have recently worked on Webrtc and add remote stream on collectionview cell. You can use my code. If you have any other issue let me know, i will help also.
let stream = VideoCallViewController.arrRemoteStreams[indexPath.row]
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "RmoteVideoCollectionViewCell", for: indexPath) as! RmoteVideoCollectionViewCell
cell.contentView.subviews.forEach({ $0.removeFromSuperview() })
#if arch(arm64)
// Using metal (arm64 only)
let remoteRenderer = RTCMTLVideoView(frame: CGRect.init(x: 0, y: 0, width: 150, height: 150))
remoteRenderer.videoContentMode = .scaleAspectFit
#else
// Using OpenGLES for the rest
let remoteRenderer = RTCEAGLVideoView(frame: CGRect.init(x: 0, y: 0, width: 150, height: 150))
#endif
//set stream to cell
stream.videoTracks.first?.add(remoteRenderer)
//adding stream to cellview
cell.contentView.addSubview(remoteRenderer)