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 25275 - VideoTrackList.selectedIndex initialization confilicts with HTML5 spec, "if no track is selected".
Summary: VideoTrackList.selectedIndex initialization confilicts with HTML5 spec, "if n...
Status: RESOLVED FIXED
Alias: None
Product: WebRTC Working Group
Classification: Unclassified
Component: Media Capture and Streams (show other bugs)
Version: unspecified
Hardware: All All
: P2 normal
Target Milestone: ---
Assignee: public-media-capture@w3.org
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-04-05 18:35 UTC by Kiran
Modified: 2014-05-08 08:07 UTC (History)
5 users (show)

See Also:


Attachments

Description Kiran 2014-04-05 18:35:35 UTC
In Media Capture and Streams spec [1] it is specified that VideoTrackList.selectedIndex should be initialized to "0" if no track is selected.

But according to HTML5 spec [2], VideoTrackList.selectedIndex should be initialized to "-1" if no track is selected.

"media . videoTracks . selectedIndex
Returns the index of the currently selected track, if any, or −1 otherwise."


[1] http://dev.w3.org/2011/webrtc/editor/getusermedia.html#loading-and-playing-a-mediastream-in-a-media-element

[2] http://www.w3.org/TR/html5/embedded-content-0.html#audiotracklist-and-videotracklist-objects
Comment 1 Adam Bergkvist 2014-04-10 08:50:09 UTC
Thanks again for reviewing the spec and sending feedback.

This is my thinking regarding this:

If the MediaStream has no video tracks, it's not right to set the selectedIndex attribute to 0; it should be -1.

But since muted and disabled video tracks render blackness, it we could simply select the first video track if there's at least one in the MediaStream. The benefit of that would be that in the common case where there's one video track available and it's muted or disabled when the stream is assigned to a media element, the video would start playing as soon as the video track gets enabled/unmuted without having to select the track.
Comment 2 Kiran 2014-04-10 09:28:50 UTC
AFAIK It should be -1. It varies when we consider different scenarios. The following is my thinking regarding this.

case 1: If no tracks are present it should be -1. (current spec is not explicitly specifying about this). If we set -1 as default value, this case will be handled by default.

case 2: Current spec is specifying that, it should be set to first available enabled / un-muted track. It is not explicitly specifying anything about selecting the first track after it is enabled or un-muted. (means it says to continue with the already selected track)

case 3: If more than one track is present, for example 2, and the second  track is selected at the time of initialization, then after some time if the selected track is removed and first track got ended because of some reason. In this case, spec is not explicitly specifying which track need to be selected.

case 4: If the first track is muted (and only one is present) and a new track is added after some time (which is enabled and un-muted), spec should explicitly specify it to select the new track.

case 5: As Adam specified if the track is disabled or muted, then enabled after some time then it would played (This is a positive scenario).

Instead of defining different values in each case, it is good to set -1 by default (if no track present or track is disabled / muted) and change its value to required track number in the list, in case like when a track is added or enabled or un-muted.
Comment 3 franklin 2014-04-10 13:50:29 UTC
It seems -1 is the best choice for default value instead of 0.
Comment 4 Adam Bergkvist 2014-04-11 08:50:36 UTC
Actually we don't need to say anything about VideoTrackList.selectedIndex at all. As long as we specify which VideoTrack that is selected, if any, then the media element spec has text that says how VideoTrackList.selectedIndex must be set to reflect that (-1 being the default). Duplicating this text may only lead to inconsistencies.

I'm not sure about trying to continuously (after initialization) change the selected track as tracks are added, removed, enabled or disabled and so on. E.g., enable/disable are controls separate from the VideoTrack.selected feature and it could become confusing for developers if we introduce dependencies. It would be good to have feedback from more implementers here.
Comment 5 steev 2014-04-14 06:57:21 UTC
MediaElement spec has not mentioned anything about "how" to select a track. Is there any special interst for specifying this in media streams spec?
Comment 6 Adam Bergkvist 2014-04-16 07:54:59 UTC
(In reply to steev from comment #5)
> MediaElement spec has not mentioned anything about "how" to select a track.
> Is there any special interst for specifying this in media streams spec?

It says that a media resource can indicate which audio and video tracks that should be enabled [1] (search for "listed first").

[1] http://www.w3.org/TR/html5/embedded-content-0.html#concept-media-load-resource
Comment 8 Stefan Hakansson LK 2014-04-22 07:15:12 UTC
(In reply to Adam Bergkvist from comment #7)
> Proposed fix:
> https://github.com/fluffy/webrtc-w3c/commit/
> 6b0b37d7223537cacbad3b71e98a9a9badf30df5

Looks good to me. When read together with step 11 of the "Once enough of the media data has been fetched to determine the duration of the media resource, its dimensions, and other metadata" phase of the media element's resource fetch algorithm I it is very clear.
Comment 9 Stefan Hakansson LK 2014-05-08 08:07:22 UTC
Fixed in http://dev.w3.org/2011/webrtc/editor/archives/20140507/getusermedia.html