<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://www.w3.org/Bugs/Public/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4"
          urlbase="https://www.w3.org/Bugs/Public/"
          
          maintainer="sysbot+bugzilla@w3.org"
>

    <bug>
          <bug_id>25275</bug_id>
          
          <creation_ts>2014-04-05 18:35:35 +0000</creation_ts>
          <short_desc>VideoTrackList.selectedIndex initialization confilicts with HTML5 spec, &quot;if no track is selected&quot;.</short_desc>
          <delta_ts>2014-05-08 08:07:22 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebRTC Working Group</product>
          <component>Media Capture and Streams</component>
          <version>unspecified</version>
          <rep_platform>All</rep_platform>
          <op_sys>All</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Kiran">kiran.guduru</reporter>
          <assigned_to name="public-media-capture@w3.org">public-media-capture</assigned_to>
          <cc>adam.bergkvist</cc>
    
    <cc>franklin.blek</cc>
    
    <cc>public-media-capture</cc>
    
    <cc>steev.a.james</cc>
    
    <cc>stefan.lk.hakansson</cc>
          
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>103451</commentid>
    <comment_count>0</comment_count>
    <who name="Kiran">kiran.guduru</who>
    <bug_when>2014-04-05 18:35:35 +0000</bug_when>
    <thetext>In Media Capture and Streams spec [1] it is specified that VideoTrackList.selectedIndex should be initialized to &quot;0&quot; if no track is selected.

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

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


[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</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>103658</commentid>
    <comment_count>1</comment_count>
    <who name="Adam Bergkvist">adam.bergkvist</who>
    <bug_when>2014-04-10 08:50:09 +0000</bug_when>
    <thetext>Thanks again for reviewing the spec and sending feedback.

This is my thinking regarding this:

If the MediaStream has no video tracks, it&apos;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&apos;s at least one in the MediaStream. The benefit of that would be that in the common case where there&apos;s one video track available and it&apos;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.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>103660</commentid>
    <comment_count>2</comment_count>
    <who name="Kiran">kiran.guduru</who>
    <bug_when>2014-04-10 09:28:50 +0000</bug_when>
    <thetext>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.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>103672</commentid>
    <comment_count>3</comment_count>
    <who name="franklin">franklin.blek</who>
    <bug_when>2014-04-10 13:50:29 +0000</bug_when>
    <thetext>It seems -1 is the best choice for default value instead of 0.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>103726</commentid>
    <comment_count>4</comment_count>
    <who name="Adam Bergkvist">adam.bergkvist</who>
    <bug_when>2014-04-11 08:50:36 +0000</bug_when>
    <thetext>Actually we don&apos;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&apos;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.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>103803</commentid>
    <comment_count>5</comment_count>
    <who name="steev">steev.a.james</who>
    <bug_when>2014-04-14 06:57:21 +0000</bug_when>
    <thetext>MediaElement spec has not mentioned anything about &quot;how&quot; to select a track. Is there any special interst for specifying this in media streams spec?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>103940</commentid>
    <comment_count>6</comment_count>
    <who name="Adam Bergkvist">adam.bergkvist</who>
    <bug_when>2014-04-16 07:54:59 +0000</bug_when>
    <thetext>(In reply to steev from comment #5)
&gt; MediaElement spec has not mentioned anything about &quot;how&quot; to select a track.
&gt; 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 &quot;listed first&quot;).

[1] http://www.w3.org/TR/html5/embedded-content-0.html#concept-media-load-resource</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>104014</commentid>
    <comment_count>7</comment_count>
    <who name="Adam Bergkvist">adam.bergkvist</who>
    <bug_when>2014-04-17 07:36:51 +0000</bug_when>
    <thetext>Proposed fix: https://github.com/fluffy/webrtc-w3c/commit/6b0b37d7223537cacbad3b71e98a9a9badf30df5</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>104147</commentid>
    <comment_count>8</comment_count>
    <who name="Stefan Hakansson LK">stefan.lk.hakansson</who>
    <bug_when>2014-04-22 07:15:12 +0000</bug_when>
    <thetext>(In reply to Adam Bergkvist from comment #7)
&gt; Proposed fix:
&gt; https://github.com/fluffy/webrtc-w3c/commit/
&gt; 6b0b37d7223537cacbad3b71e98a9a9badf30df5

Looks good to me. When read together with step 11 of the &quot;Once enough of the media data has been fetched to determine the duration of the media resource, its dimensions, and other metadata&quot; phase of the media element&apos;s resource fetch algorithm I it is very clear.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>105406</commentid>
    <comment_count>9</comment_count>
    <who name="Stefan Hakansson LK">stefan.lk.hakansson</who>
    <bug_when>2014-05-08 08:07:22 +0000</bug_when>
    <thetext>Fixed in http://dev.w3.org/2011/webrtc/editor/archives/20140507/getusermedia.html</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>