RESOLVED FIXED 174519
Difficult to correlate MediaStreamTracks without RTCRtpTransceiver MIDs
https://bugs.webkit.org/show_bug.cgi?id=174519
Summary Difficult to correlate MediaStreamTracks without RTCRtpTransceiver MIDs
Mark Roberts
Reported 2017-07-14 11:49:59 PDT
Safari 11 Tech Preview has implemented the "new" RTCRtpReceiver behavior, namely when `addTransceiver` is called, an RTCRtpReceiver is constructed with its `track` set to a MediaStreamTrack with a random ID. So the "old" way of correlating MediaStreamTracks by ID using MSID no longer works. The new approach is to use RTCRtpTransceiver MIDs, per https://blog.mozilla.org/webrtc/the-evolution-of-webrtc/ However, Safari does not update its RTCRtpTransceivers' MIDs. I guess this is blocked until Safari moves to the Unified Plan SDP format? Another approach is to use MediaStream IDs, but in order to do this unambiguously I think you'd need to ensure you have at most one MediaStreamTrack of a kind in a given MediaStream. I've included some code below that demonstrates this issue: I add two audio MediaStreamTracks to the same MediaStream and then try to identify them. (async () => { const pc1 = new RTCPeerConnection() const pc2 = new RTCPeerConnection() const stream1 = await navigator.mediaDevices.getUserMedia({ audio: true }) const stream2 = await navigator.mediaDevices.getUserMedia({ audio: true }) const [track1] = stream1.getAudioTracks() const [track2] = stream2.getAudioTracks() pc2.addTrack(track1, stream1) pc2.addTrack(track2, stream2) pc1.addTransceiver('audio') pc1.addTransceiver('audio') const offer = await pc1.createOffer() await Promise.all([ pc1.setLocalDescription(offer), pc2.setRemoteDescription(offer) ]) const trackEvents = [] pc1.ontrack = trackEvent => trackEvents.push(trackEvent) const answer = await pc2.createAnswer() await Promise.all([ pc1.setRemoteDescription(answer), pc2.setLocalDescription(answer) ]) const [, trackEvent2] = trackEvents if (trackEvent2.track.id === track2.id) { console.log('trackEvent2.track.id matches the MSID.') return } console.warn( 'trackEvent2.track.id does not match the MSID. ' + 'I need to correlate this MediaStreamTrack based on ' + 'some other criteria.') if (trackEvent2.streams[0].id === stream2.id) { console.log( 'trackEvent2.streams[0].id matches the MSID. ' + 'I might be able to correlate MediaStreamTracks this way...') } if (trackEvent2.transceiver && trackEvent2.transceiver.mid) { console.log( 'trackEvent2.transciever.mid is available. This is the ' + 'recommended way of correlating MediaStreamTracks.') return } console.warn( 'trackEvent2 may not contain enough information for me ' + 'to correlate MediaStreamTracks.') })() Expected Output: trackEvent2.track.id does not match the MSID. I need to correlate this MediaStreamTrack based on some other criteria. trackEvent2.streams[0].id matches the MSID. I might be able to correlate MediaStreamTracks this way... trackEvent2.transciever.mid is available. This is the recommended way of correlating MediaStreamTracks. Actual Output: trackEvent2.track.id does not match the MSID. I need to correlate this MediaStreamTrack based on some other criteria. trackEvent2.streams[0].id matches the MSID. I might be able to correlate MediaStreamTracks this way... trackEvent2 may not contain enough information for me to correlate MediaStreamTracks. Is there some workaround here? Any order I can depend on until MIDs are available?
Attachments
Radar WebKit Bug Importer
Comment 1 2017-07-15 08:10:52 PDT
youenn fablet
Comment 2 2018-09-20 08:55:46 PDT
This should be fixed now that unified plan is on by default in WebKit Nightlies.
Note You need to log in before you can comment on or make changes to this bug.