- From: Byoungchan Lee via GitHub <sysbot+gh@w3.org>
- Date: Sat, 08 Jun 2024 21:50:33 +0000
- To: public-webrtc@w3.org
bc-lee has just created a new issue for https://github.com/w3c/mediacapture-fromelement: == Different behavior when onaddtrack is fired for element.captureStream == Consider the following code: ```html <!DOCTYPE html> <html> <head> <title>captureStream for Video Element</title> </head> <body> <video id="video"></video> <button onclick="streamFromVideo()">Stream from Video Element</button> <script> function streamFromVideo() { const video = document.getElementById('video'); video.src = './test-av-384k-44100Hz-1ch-320x240-30fps-10kfr.webm'; video.onerror = (error) => { console.error('Error:', error); }; if (typeof video.captureStream !== 'function' && typeof video.mozCaptureStream === 'function') { HTMLVideoElement.prototype.captureStream = HTMLVideoElement.prototype.mozCaptureStream; } const stream = video.captureStream(); stream.onaddtrack = () => { console.log('onAddTrack'); const tracks = stream.getTracks(); for (const track of tracks) { console.log('Track readyState:', track.readyState); console.log('Track kind:', track.kind); } console.log('Video tracks:', stream.getVideoTracks().length); console.log('Audio tracks:', stream.getAudioTracks().length); }; } </script> </body> ``` The test video file [test-av-384k-44100Hz-1ch-320x240-30fps-10kfr.webm](https://github.com/web-platform-tests/wpt/blob/2bd26e124cf17b2f0a25c150794d640b07b2a870/media-source/webm/test-av-384k-44100Hz-1ch-320x240-30fps-10kfr.webm) has both audio and video tracks. This code is almost identical to the one in the [web platform test](https://github.com/web-platform-tests/wpt/blob/d2a2ea62ec000ff6d5c1572ba62a089eeb69e0c4/mediacapture-fromelement/creation.html). Below are the logs from the code above: Chrome 125.0.6422.141: ``` onAddTrack Track readyState: live Track kind: audio Track readyState: live Track kind: video Video tracks: 1 Audio tracks: 1 onAddTrack Track readyState: live Track kind: audio Track readyState: live Track kind: video Video tracks: 1 Audio tracks: 1 ``` Firefox 126.0: ``` onAddTrack Track readyState: live Track kind: audio Video tracks: 0 Audio tracks: 1 onAddTrack Track readyState: live Track kind: audio Track readyState: live Track kind: video Video tracks: 1 Audio tracks: 1 ``` In Chrome, the `onaddtrack` is fired twice, however even with the first event, both audio and video tracks are present in the stream. In Firefox, the `onaddtrack` is fired twice, but the first event only has the audio track, and the second event has both audio and video tracks. I wonder which behavior is correct. The current web platform test assumes that the behavior in Chrome is correct (it checks only the first event), but it may be an implementation detail of Chrome. Please view or discuss this issue at https://github.com/w3c/mediacapture-fromelement/issues/100 using your GitHub account -- Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config
Received on Saturday, 8 June 2024 21:50:34 UTC