W3C home > Mailing lists > Public > public-webrtc-logs@w3.org > October 2019

Re: [mediacapture-main] applying constraints on an ended track (#628)

From: guest271314 via GitHub <sysbot+gh@w3.org>
Date: Sat, 12 Oct 2019 15:53:26 +0000
To: public-webrtc-logs@w3.org
Message-ID: <issue_comment.created-541337186-1570895605-sysbot+gh@w3.org>
> Testing Firefox, Chrome and Safari, all browsers behave differently:

FWIW the implementations of `MediaStreamTrack` at Chrome, Chromium and Firefox, Nightly are _vastly_ different in several observable ways. 

Have not yet compiled a discrete list of all of the differences that have observed through own experimentation and testing, though can compile such a list if that would be helpful for interoperability and if the gist of this issue is 

> It would be better though to get some alignment there.

which agree with.

Some differences, particularly with regard to capturing a `MediaStream` from an element

- [Issue 957340: MediaStreamTrack ended event not dispatched when the source is changed by setting the src or srcObject attributes of the media element or when the source of the track is disconnected or exhausted](https://bugs.chromium.org/p/chromium/issues/detail?id=957340); https://github.com/w3c/mediacapture-fromelement/issues/78
- `getSettings()` on an `MediaStreamTrack` that is _not_ derived from `getUserMedia()` is an empty JavaScript plain object at Firefox https://bugzilla.mozilla.org/show_bug.cgi?id=1537986
- When a `MediaStream` is set as `srcObject` of an `HTMLMediaElement` then the control pause is clicked
  - Chromium `currentTime` of the media element still increments during paused state, meaning when play is clicked again the `currentTime` is advanced to the value including the time paused
  - Firefox `currentTime` of the media element does not increment during paused state, meaning 
when play is click again the `currentTime` begins at the time when playback was paused
  - Depending on the code used (execute `requestFrame()` at `timeupdate` event of `HTMLMediaElement`) Chrome, Chromium `MediaStreamTrack` (video) could toggle between `mute=true` and `mute=false` every 1-4 seconds, dispatching the events during that span
  - Depending on the code used (execute `requestFrame()` at `timeupdate` event of `HTMLMediaElement`) Chrome, Chromium `MediaStreamTrack` (video) could take (consistently) 4 seconds to toggle from `mute=true` to `mute=false`, dispatching the respective events
```
<!DOCTYPE html>
<html>
<head>
</head>
<body>
  <video controls autoplay muted width="320" height="240"></video>
  <script>
    const video = document.querySelector("video");
    const events = ["play", "playing", "pause", "loadedmetadata"
                   , "loadeddata", "waiting", "stalled"
                   , "emptied", "ended", "abort", "durationchange"]
      .forEach(event => video.addEventListener(event, e => console.log(e.type, {
        paused: video.paused
      })));

    const ms = new MediaStream();
    const canvas = document.createElement("canvas");
    canvas.width = video.width;
    canvas.height = video.height;
    const ctx = canvas.getContext("2d");
    ctx.globalCompositeOperation = "copy";
    const canvasStream = canvas.captureStream(0);
    const [canvasTrack] = canvasStream.getVideoTracks();
    console.log(canvasTrack.muted);
    const videoStream = [canvasStream, canvasTrack]
      .find(({
        requestFrame: rf
      }) => rf);
    const handleTimeupdate = e => {
      console.log(e.type || e.target, video.currentTime);
      const {
        width, videoWidth, height, videoHeight
      } = e.target;

      ctx.clearRect(0, 0, videoWidth || width, videoHeight || height);
      ctx.fillStyle = "#000000";
      ctx.fillRect(0, 0, videoWidth || width, videoHeight || height);
      videoStream.requestFrame();
    }
    video.ontimeupdate = handleTimeupdate;
    handleTimeupdate({
      target: video
    });
    canvasTrack.onmute = e => {
      console.log(e.type);
      handleTimeupdate({
        target: Object.assign(
          video, e.target.getSettings()
        )
      });
    };
    canvasTrack.onunmute = e => console.log(e.type);
    console.log(canvasStream, canvasTrack);
    ms.addTrack(canvasTrack);
    video.srcObject = ms;
  </script>
</body>
</html>
```
- `requestFrame()` defined at `MediaStream` (Firefox) or `MediaStreamTrack` (Chrome, Chromium) https://github.com/w3c/mediacapture-fromelement/issues/76. Not clear at the specification (Media Capture From Element) that `requestFrame()` is asynchronous.
- Mozilla still uses `mozCaptureStream()` https://bugzilla.mozilla.org/show_bug.cgi?id=1541471
- [MediaStream returned by canvas.captureStream() using "bitmaprenderer" and transferFromImageBitmap not recorded by MediaRecorder; MediaStreamTrack mute event not fired](https://bugzilla.mozilla.org/show_bug.cgi?id=1557980)

et al. (the above list is not comprehensive)

-- 
GitHub Notification of comment by guest271314
Please view or discuss this issue at https://github.com/w3c/mediacapture-main/issues/628#issuecomment-541337186 using your GitHub account
Received on Saturday, 12 October 2019 15:53:27 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 19:22:29 UTC