twilio / twilio-video-app-ios

A collaboration application built with the Twilio Video iOS SDK
Apache License 2.0
248 stars 54 forks source link

RemoteVideoTrack from TwilioVideo.js has a nil source causing dark video screen #166

Closed lipsotiko closed 3 years ago

lipsotiko commented 3 years ago

Description

Remote video tracks of participants joining a Group Room from a browser are not added to the cameraTrack in the RemoteParticipant object. This results in a dark video screen, as if the participant has their video muted.

Browser Client:

Steps to Reproduce

  1. Join a Group Room using the twilio-video-app-ios
  2. Have another person join the same room from a browser using the TwilioVideo.js SDK
  3. Observe that the video will be dark for the person that joined from a browser

Expected Behavior

I expected the video track that was published by the browser to be rendered

Versions

After some doing, I got to work by updating RemoteParticipant.swift

    func didSubscribeToVideoTrack(
        videoTrack: TwilioVideo.RemoteVideoTrack,
        publication: RemoteVideoTrackPublication,
        participant: TwilioVideo.RemoteParticipant
    ) {
        cameraTrack = RemoteVideoTrack(track: videoTrack)

        sendUpdate()
    }

    func didUnsubscribeFromVideoTrack(
        videoTrack: TwilioVideo.RemoteVideoTrack,
        publication: RemoteVideoTrackPublication,
        participant: TwilioVideo.RemoteParticipant
    ) {
        cameraTrack = nil

        sendUpdate()
    }

If this is a bug, then, perhaps the above is a valid solution; or someone can explain the purpose of screenTrack as well as guard let source = videoTrack.source else { return }

timrozum commented 3 years ago

Hi @lipsotiko,

This code is using the track name to determine if it is the camera or screen share:

        guard let source = videoTrack.source else { return }

        switch source {
        case .camera: cameraTrack = nil
        case .screen: screenTrack = nil
        }

It uses this helper at the bottom of the file:

    var source: VideoSource? { VideoSource(trackName: name) }
}

I suspect the JS app is using a track name that the iOS app does not expect. Track name can be specified when creating the track.

This iOS app repo is compatible with this react repo as far as track names are concerned: https://github.com/twilio/twilio-video-app-react

Let me know if that helps.

lipsotiko commented 3 years ago

Thank you @timrozum , that was a big help.