[Webkit-unassigned] [Bug 174519] New: Difficult to correlate MediaStreamTracks without RTCRtpTransceiver MIDs

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Fri Jul 14 11:49:59 PDT 2017


https://bugs.webkit.org/show_bug.cgi?id=174519

            Bug ID: 174519
           Summary: Difficult to correlate MediaStreamTracks without
                    RTCRtpTransceiver MIDs
           Product: WebKit
           Version: Safari Technology Preview
          Hardware: Unspecified
                OS: Unspecified
            Status: NEW
          Severity: Normal
          Priority: P2
         Component: WebCore JavaScript
          Assignee: webkit-unassigned at lists.webkit.org
          Reporter: mroberts at twilio.com

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?

-- 
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-unassigned/attachments/20170714/2fde06f6/attachment.html>


More information about the webkit-unassigned mailing list