cordova-rtc / cordova-plugin-iosrtc

Cordova iOS plugin exposing the WebRTC W3C API
MIT License
688 stars 340 forks source link

Enable/Disable track from Receiver/Sender is broken in case of use with Janus Videoroom #734

Closed RSATom closed 2 years ago

RSATom commented 2 years ago

Versions affected

Description

If try disable tracks gotten from receivers list on official Janus Videoroom demo I get following error in XCode debug console:

HelloVideoroom[383:7666] iosrtcPlugin#MediaStreamTrack_setEnabled() | ERROR: pluginMediaStreamTrack with id=janusa0 does not exist

Steps to reproduce

feeds.forEach(remoteFeed => {
        if(remoteFeed) {
                let peerConnection = remoteFeed.webrtcStuff.pc;
                if (peerConnection) {
                        const receivers = peerConnection.getReceivers();
                        receivers.forEach((receiver) => {
                                receiver.track.enabled = false;
                        })
                }
        }
})

Expected results

Track should be switched to disabled state

Actual results

Above error message

Investigation results

The problem is here: https://github.com/cordova-rtc/cordova-plugin-iosrtc/blob/239b8335a15a72d8847e083979b4479ad0d515c3/src/PluginMediaStreamTrack.swift#L22 and here: https://github.com/cordova-rtc/cordova-plugin-iosrtc/blob/239b8335a15a72d8847e083979b4479ad0d515c3/src/PluginRTCPeerConnection.swift#L824

i.e. on one side iosrtc alters track id to make it unique, but on other side iosrtc returns tracks from transeivers as is without replace original track id to internal iosrtc's track id.

hthetiot commented 2 years ago

Thx @RSATom i will see what I can do. Keep posted.

hthetiot commented 2 years ago

May be this PR can fix the issue also https://github.com/cordova-rtc/cordova-plugin-iosrtc/pull/648

hthetiot commented 2 years ago

I have a one million dollars question, do they use unique Id for Media stream lines in SDP?

RSATom commented 2 years ago

@hthetiot within specific SDP - I think yes.

hthetiot commented 2 years ago

if PR QA pass, will release as part of 8.0.4