You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Getting notification and we call the methods "connectToRoom"
as soon as user accept the call then application crash with above details.
Code
import UIKit
import TwilioVideo
classVideoChatVC:UIViewController{varroom:Room?varcamera:CameraSource?varlocalVideoTrack:LocalVideoTrack?varlocalAudioTrack:LocalAudioTrack?varremoteParticipant:RemoteParticipant?@IBOutlet weak varremoteView:VideoView!@IBOutlet weak varpreviewView:VideoView!func connectToRoom(){self.showHUD(message:NSLocalizedString("Connecting...", comment:""))InvictusAPI.get(path:"chat?room=\(self.roomName)"){(code, object)in
if let data = object as?[String:String],let token =data["token"]{self.accessToken = token
self.connect()self.hideHUD()}//self.reportEndCall() Do not remove this code it's for handle Video call using APNS}}func connect(){// Preparing the connect options with the access token that we fetched (or hardcoded).letconnectOptions=ConnectOptions(token: accessToken){(builder)in
builder.roomName =self.roomName
}// Connect to the Room using the options we provided.
room =TwilioVideoSDK.connect(options: connectOptions, delegate:self)logMessage(messageText:"Attempting to connect to room \(String(describing:self.roomName))")UIApplication.shared.isIdleTimerDisabled = true
}func prepareLocalMedia(){// Create an audio track.
if (localAudioTrack ==nil){
localAudioTrack =LocalAudioTrack(options:nil, enabled: true, name:"Microphone")
if (localAudioTrack ==nil){logMessage(messageText:"Failed to create audio track")}}// Create a video track which captures from the camera.
if (localVideoTrack ==nil){startPreview()}GCD.main(closure:{
if let localAudio =self.localAudioTrack {self.room?.localParticipant?.publishAudioTrack(localAudio)//self.room?.localParticipant?.addAudioTrack(localAudio)}})
if let localVideo =self.localVideoTrack {self.room?.localParticipant?.publishVideoTrack(localVideo)//self.room?.localParticipant?.addVideoTrack(localVideo)//self.previewView.updateVideoSize(self.previewView.videoDimensions, orientation: .up)}}// MARK:- Privatefunc startPreview(){
if PlatformUtils.isSimulator {return}letfrontCamera=CameraSource.captureDevice(position:.front)letbackCamera=CameraSource.captureDevice(position:.back)
if (frontCamera !=nil || backCamera !=nil){letoptions=CameraSourceOptions{(builder)in
if #available(iOS 13.0,*){
builder.orientationTracker =UserInterfaceTracker(scene:UIApplication.shared.keyWindow!.windowScene!)}}// Preview our local camera track in the local video preview view.
camera =CameraSource(options: options, delegate:self)
localVideoTrack =LocalVideoTrack(source: camera!, enabled: true, name:"Camera")// Add renderer to video track for local preview
localVideoTrack!.addRenderer(self.previewView)logMessage(messageText:"Video track created")
if (frontCamera !=nil && backCamera !=nil){// We will flip camera on tap.lettap=UITapGestureRecognizer(target:self, action: #selector(VideoChatVC.flipCamera))self.previewView.addGestureRecognizer(tap)}
camera!.startCapture(device: frontCamera !=nil ? frontCamera! : backCamera!){(captureDevice, videoFormat, error)in
if let error = error {self.logMessage(messageText:"Capture failed with error.\ncode = \((error asNSError).code) error = \(error.localizedDescription)")}else{self.previewView.shouldMirror =(captureDevice.position ==.front)}}}else{self.logMessage(messageText:"No front or back capture device found!")}}func disconnect(){self.room?.disconnect()self.localAudioTrack?.isEnabled = false
self.localVideoTrack?.isEnabled = false
// TODO - For Audio..//TVIAudioController.shared().stopAudio()self.camera?.stopCapture()self.cleanupRemoteParticipant()logMessage(messageText:"Attempting to disconnect from room \(room?.name ??"")")}func renderRemoteParticipant(participant :RemoteParticipant)->Bool{// This example renders the first subscribed RemoteVideoTrack from the RemoteParticipant.letvideoPublications= participant.remoteVideoTracks
for publication in videoPublications {
if let subscribedVideoTrack = publication.remoteTrack,
publication.isTrackSubscribed {
subscribedVideoTrack.addRenderer(self.remoteView!)self.remoteParticipant = participant
return true
}}return false
}func renderRemoteParticipants(participants :Array<RemoteParticipant>){
for participant in participants {// Find the first renderable track.
if participant.remoteVideoTracks.count >0,renderRemoteParticipant(participant: participant){
break
}}}func cleanupRemoteParticipant(){
if self.remoteParticipant !=nil{self.remoteView?.removeFromSuperview()self.remoteView =nilself.remoteParticipant =nilself.room =nil}}func logMessage(messageText:String){print(messageText)}@IBActionfunc answer(){self.leftButtonView.removeFromSuperview()self.rightButtonView.removeFromSuperview()self.centerButton.autolayout.pinLeft().pinRight()self.previewView.isHidden = false
GCD.main{// Prepare local media which we will share with Room Participants.self.prepareLocalMedia()}}}// MARK:- RoomDelegateextensionVideoChatVC:RoomDelegate{func roomDidConnect(room:Room){logMessage(messageText:"Connected to room \(room.name) as \(room.localParticipant?.identity ??"")")// This example only renders 1 RemoteVideoTrack at a time. Listen for all events to decide which track to render.
for remoteParticipant in room.remoteParticipants {
remoteParticipant.delegate =self}}func roomDidDisconnect(room:Room, error:Error?){logMessage(messageText:"Disconnected from room \(room.name), error = \(String(describing: error))")self.cleanupRemoteParticipant()self.room =nil}func roomDidFailToConnect(room:Room, error:Error){logMessage(messageText:"Failed to connect to room with error = \(String(describing: error))")self.room =nil}func roomIsReconnecting(room:Room, error:Error){logMessage(messageText:"Reconnecting to room \(room.name), error = \(String(describing: error))")}func roomDidReconnect(room:Room){logMessage(messageText:"Reconnected to room \(room.name)")}func participantDidConnect(room:Room, participant:RemoteParticipant){// Listen for events from all Participants to decide which RemoteVideoTrack to render.
participant.delegate =selflogMessage(messageText:"Participant \(participant.identity) connected with \(participant.remoteAudioTracks.count) audio and \(participant.remoteVideoTracks.count) video tracks")}func participantDidDisconnect(room:Room, participant:RemoteParticipant){logMessage(messageText:"Room \(room.name), Participant \(participant.identity) disconnected")// Nothing to do in this example. Subscription events are used to add/remove renderers.}}// MARK:- RemoteParticipantDelegateextensionVideoChatVC:RemoteParticipantDelegate{func remoteParticipantDidPublishVideoTrack(participant:RemoteParticipant, publication:RemoteVideoTrackPublication){// Remote Participant has offered to share the video Track.logMessage(messageText:"Participant \(participant.identity) published \(publication.trackName) video track")}func remoteParticipantDidUnpublishVideoTrack(participant:RemoteParticipant, publication:RemoteVideoTrackPublication){// Remote Participant has stopped sharing the video Track.logMessage(messageText:"Participant \(participant.identity) unpublished \(publication.trackName) video track")}func remoteParticipantDidPublishAudioTrack(participant:RemoteParticipant, publication:RemoteAudioTrackPublication){// Remote Participant has offered to share the audio Track.logMessage(messageText:"Participant \(participant.identity) published \(publication.trackName) audio track")}func remoteParticipantDidUnpublishAudioTrack(participant:RemoteParticipant, publication:RemoteAudioTrackPublication){// Remote Participant has stopped sharing the audio Track.logMessage(messageText:"Participant \(participant.identity) unpublished \(publication.trackName) audio track")}func didSubscribeToVideoTrack(videoTrack:RemoteVideoTrack, publication:RemoteVideoTrackPublication, participant:RemoteParticipant){// The LocalParticipant is subscribed to the RemoteParticipant's video Track. Frames will begin to arrive now.logMessage(messageText:"Subscribed to \(publication.trackName) video track for Participant \(participant.identity)")
if (self.remoteParticipant ==nil){
_ =renderRemoteParticipant(participant: participant)}}func didUnsubscribeFromVideoTrack(videoTrack:RemoteVideoTrack, publication:RemoteVideoTrackPublication, participant:RemoteParticipant){// We are unsubscribed from the remote Participant's video Track. We will no longer receive the// remote Participant's video.logMessage(messageText:"Unsubscribed from \(publication.trackName) video track for Participant \(participant.identity)")
if self.remoteParticipant == participant {cleanupRemoteParticipant()// Find another Participant video to render, if possible.
if var remainingParticipants = room?.remoteParticipants,let index = remainingParticipants.firstIndex(of: participant){
remainingParticipants.remove(at: index)renderRemoteParticipants(participants: remainingParticipants)}}}func didSubscribeToAudioTrack(audioTrack:RemoteAudioTrack, publication:RemoteAudioTrackPublication, participant:RemoteParticipant){// We are subscribed to the remote Participant's audio Track. We will start receiving the// remote Participant's audio now.logMessage(messageText:"Subscribed to \(publication.trackName) audio track for Participant \(participant.identity)")}func didUnsubscribeFromAudioTrack(audioTrack:RemoteAudioTrack, publication:RemoteAudioTrackPublication, participant:RemoteParticipant){// We are unsubscribed from the remote Participant's audio Track. We will no longer receive the// remote Participant's audio.logMessage(messageText:"Unsubscribed from \(publication.trackName) audio track for Participant \(participant.identity)")}func remoteParticipantDidEnableVideoTrack(participant:RemoteParticipant, publication:RemoteVideoTrackPublication){logMessage(messageText:"Participant \(participant.identity) enabled \(publication.trackName) video track")}func remoteParticipantDidDisableVideoTrack(participant:RemoteParticipant, publication:RemoteVideoTrackPublication){logMessage(messageText:"Participant \(participant.identity) disabled \(publication.trackName) video track")}func remoteParticipantDidEnableAudioTrack(participant:RemoteParticipant, publication:RemoteAudioTrackPublication){logMessage(messageText:"Participant \(participant.identity) enabled \(publication.trackName) audio track")}func remoteParticipantDidDisableAudioTrack(participant:RemoteParticipant, publication:RemoteAudioTrackPublication){logMessage(messageText:"Participant \(participant.identity) disabled \(publication.trackName) audio track")}func didFailToSubscribeToAudioTrack(publication:RemoteAudioTrackPublication, error:Error, participant:RemoteParticipant){logMessage(messageText:"FailedToSubscribe \(publication.trackName) audio track, error = \(String(describing: error))")}func didFailToSubscribeToVideoTrack(publication:RemoteVideoTrackPublication, error:Error, participant:RemoteParticipant){logMessage(messageText:"FailedToSubscribe \(publication.trackName) video track, error = \(String(describing: error))")}}// MARK:- VideoViewDelegateextensionVideoChatVC:VideoViewDelegate{func videoViewDimensionsDidChange(view:VideoView, dimensions:CMVideoDimensions){self.view.setNeedsLayout()}}// MARK:- CameraSourceDelegateextensionVideoChatVC:CameraSourceDelegate{func cameraSourceDidFail(source:CameraSource, error:Error){logMessage(messageText:"Camera source failed with error: \(error.localizedDescription)")}}
Expected Behavior
Call should connect and able to join the Room.
Reproduces How Often
Happen every time.
Versions
All relevant version information for the issue.
Video iOS SDK
pod 'TwilioVideo', '~> 4.6'
Xcode
Xcode 13.0
iOS Version
iOS 15.1
iOS Device
iPhone 12
The text was updated successfully, but these errors were encountered:
Description
I am getting crash when subscribing the Remote Participates. Please find the below crash log for more details.
Steps to Reproduce
as soon as user accept the call then application crash with above details.
Code
Expected Behavior
Call should connect and able to join the Room.
Reproduces How Often
Happen every time.
Versions
All relevant version information for the issue.
Video iOS SDK
pod 'TwilioVideo', '~> 4.6'
Xcode
Xcode 13.0
iOS Version
iOS 15.1
iOS Device
iPhone 12
The text was updated successfully, but these errors were encountered: