This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.

Bug 21618 - MediaStreams with no tracks need to not be Ended
Summary: MediaStreams with no tracks need to not be Ended
Status: RESOLVED FIXED
Alias: None
Product: WebRTC Working Group
Classification: Unclassified
Component: Media Capture and Streams (show other bugs)
Version: unspecified
Hardware: PC Linux
: P2 normal
Target Milestone: ---
Assignee: public-media-capture@w3.org
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 22215 22264
  Show dependency treegraph
 
Reported: 2013-04-08 12:19 UTC by Harald Alvestrand
Modified: 2013-10-17 11:32 UTC (History)
3 users (show)

See Also:


Attachments

Description Harald Alvestrand 2013-04-08 12:19:37 UTC
According to the current specs:
a) it is possible to create a MediaStream that has no tracks.
b) if all the tracks in a MediaStream are ended, the state of the MediaStream is ended
c) You can't add tracks to a MediaStream that's ended.

b) is ambiguous for the case where there are no tracks: Is it ended or not?
If it is ended, creating a MediaStream with no tracks becomes useless, and removing all tracks from a MediaStream will end it - rendering it useless.

If it is not ended, the MediaStream is useful - but it also becomes possible to "un-end" a MediaStream by removing all its tracks.

A decision is sought.
Comment 1 Harald Alvestrand 2013-08-21 11:12:17 UTC
Suggestion from Jim Barnett:

I think that if a MediaStream can become active again, that  it shouldn’t have any (immediate) affect on a media element.  As far as I can figure out the HTML5 spec, once a media element goes to ended, the only way it can leave ended is for someone to call play() (or rewind or something).   So when a MediaStream goes to inactive, the media element should also go to ended and stay there even if the MediaStream becomes active again.  If someone calls play(), the media element will pick up the new tracks in the MediaStream, but not before. 

Based on this, suggestion from Harald:

Suggested spec change: Remove the ended state on MediaStream.

Define that a MediaStream is inactive when it contains only MediaStreamTracks that are ended (but don't add an attribute for it), and that a media element enters the ended state when the MediaStream is inactive.
Comment 2 Martin Thomson 2013-08-21 15:59:11 UTC
Seems like a reasonable suggestion.  The alternative is to define the ended property as a direct synthesis of the current states of all MediaStreamTrack instances.

e.g.,

Object.defineProperty(MediaStream.prototype, 'ended', {
  get: function() {
    return this.tracks.reduce(function(a, track) {
      return a && track.ended;
    }, true);
  }, 
  enumerable: true,
  configurable: true
});

A consequence of this algorithm is that a MediaStream with no tracks is always ended.
Comment 3 Adam Bergkvist 2013-08-22 05:57:01 UTC
(In reply to comment #2)
> A consequence of this algorithm is that a MediaStream with no tracks is
> always ended.

That's why I like the "inactive" wording better. If you create a MediaStream with no tracks, "inactive" just says that nothing is going on at the moment. "ended", on the other hand, gives me the feeling that there has been some activity in the stream prior to this state.
Comment 4 Martin Thomson 2013-08-22 15:08:27 UTC
(In reply to comment #3)

> That's why I like the "inactive" wording better. 

"inactive" is good.  Might cause some heartburn due to asymmetry, but you are right, it's has all the right implications.
Comment 5 Harald Alvestrand 2013-09-27 12:19:20 UTC
This was on the agenda for our Aug 27, 2013 telechat.
Comment 6 Adam Bergkvist 2013-10-03 09:54:03 UTC
The new concept of an inactive MediaStream will be included in the next editor's draft.
Comment 7 Adam Bergkvist 2013-10-17 11:32:03 UTC
Fixed in Editor's draft v20131017