Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use the same MediaStreamTrack on RTCRtpSender #773

Conversation

jerry2013
Copy link
Contributor

this took me lots of time to track down.

under iosrtc, for local media tracks, the normal flow goes:

  • app calls gUM
    • iosrtc plugin sends intent/request to native side
    • webrtc does things
    • native side sends OK event to js, containing the track info
    • iosrtc plugin returns to the caller with a new MediaStreamTrack
  • app tries to add the track in the context of peer-connection/rtp-sender (new sender or replaceTrack)
    • iosrtc plugin sends intent/request to native side
    • webrtc does things
    • native side sends OK event to js
    • iosrtc plugin should directly assign the existing track to the peer-connection/rtp-sender
      • but, since the track is not yet on pc, pc.getOrCreateTrack then makes new MediaStreamTrack with the same id
      • this breaks the spec since the track from gUM is not "object reference equal" to the track linked to rtp-sender

the patch here uses a global map to maintain all "active" tracks, so that the async callback can find the existing tracks.

still, this is a quick and dirty workaround to addresses my own usage.

@hthetiot hthetiot merged commit b6b5356 into cordova-rtc:master Jun 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants