<?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>19156</bug_id>
          
          <creation_ts>2012-10-01 04:57:34 +0000</creation_ts>
          <short_desc>Switching decoders when the key system is specified</short_desc>
          <delta_ts>2013-11-14 08:31:07 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>HTML WG</product>
          <component>Encrypted Media Extensions</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>
          <dependson>19009</dependson>
          <blocked>20336</blocked>
          <everconfirmed>1</everconfirmed>
          <reporter name="David Dorwin">ddorwin</reporter>
          <assigned_to name="Adrian Bateman [MSFT]">adrianba</assigned_to>
          <cc>mike</cc>
    
    <cc>public-html-media</cc>
    
    <cc>strobe</cc>
          
          <qa_contact name="HTML WG Bugzilla archive list">public-html-bugzilla</qa_contact>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>74906</commentid>
    <comment_count>0</comment_count>
    <who name="David Dorwin">ddorwin</who>
    <bug_when>2012-10-01 04:57:34 +0000</bug_when>
    <thetext>Both v0.1 and the current version of the OO API allow the key system to be specified at any point after loading has started. They even require that the key system not be chosen or associated, respectively, until after loading has started. As a result, it is very likely that the key system will be set AFTER some frames have been decoded. For key systems/CDMs that include a decoder (or entire video pipeline), this means that the decoder may change when the key system is selected. This is primarily (only?) a problem if there is some clear content being decoded/played before the encrypted content so decoding could start before a key system was specified.

Supporting decoder changes may be very difficult to implement, especially without restrictions on the content. For example, the switch might occur in the middle of a group of frames that depend on previous frames to decode subsequent frames. While this could be worked around, it might be better to avoid this situation completely.


Some options:
1) Require the key system to be specified before loading and/or decoding starts. If it is not specified by this time, it cannot be set later, meaning decryption would not be possible. This would likely reduce the utility of the needkey event.
2) Allow switching decoders whenever Media Source Extensions allow changing codecs/decoders.
3) Switch decoders when the first encrypted frame is encountered, possibly requiring the next item.
4) Establish limitations on which frames can be encrypted. For example, P-and B-frames may not be encrypted if the I-frame is not. Due to seeking, this would apply throughout a stream and not just to the beginning.
5) Switch immediately and drop frames if necessary.
6) Suggest the above to applications and make it a quality of implementation issue for applications.
7) Leave the behavior undefined, making it a quality of implementation issue for user agents.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>75066</commentid>
    <comment_count>1</comment_count>
    <who name="David Dorwin">ddorwin</who>
    <bug_when>2012-10-02 15:57:00 +0000</bug_when>
    <thetext>There are some implicit assumptions above.

The first is that once you select a key system (and thus decoder), you cannot change it. In other words, you cannot use multiple key systems during the life (between loads) of a media element.

Also, to be clear, unencrypted content is supported even after selecting a key system. This means there is a requirement that CDM decoders can also decode clear/unencryped content.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>83896</commentid>
    <comment_count>2</comment_count>
    <who name="Adrian Bateman [MSFT]">adrianba</who>
    <bug_when>2013-03-02 01:03:39 +0000</bug_when>
    <thetext>We think we should add informative text that suggests applications should create a MediaKeys object and call setMediaKeys before setting the media source if they want to signal to the media engine that a protected pipeline is desired. If the application does not do this then this should be left as a quality of implementation issue.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>87009</commentid>
    <comment_count>3</comment_count>
    <who name="David Dorwin">ddorwin</who>
    <bug_when>2013-04-30 15:39:15 +0000</bug_when>
    <thetext>Resolution of bug 19009 may address this. It should at least consider it.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>88157</commentid>
    <comment_count>4</comment_count>
    <who name="David Dorwin">ddorwin</who>
    <bug_when>2013-05-23 20:10:05 +0000</bug_when>
    <thetext>For the record, this was discussed on the email list last fall: http://lists.w3.org/Archives/Public/public-html-media/2012Oct/0001.html</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>90116</commentid>
    <comment_count>5</comment_count>
    <who name="Adrian Bateman [MSFT]">adrianba</who>
    <bug_when>2013-07-02 15:45:41 +0000</bug_when>
    <thetext>Discussed on the telcon, the current spec address this issue.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>95635</commentid>
    <comment_count>6</comment_count>
    <who name="David Dorwin">ddorwin</who>
    <bug_when>2013-10-31 21:54:46 +0000</bug_when>
    <thetext>I don&apos;t believe the current spec text addresses this issue.

Adrian proposed the following in comment #2. Is this no longer the intended solution?
&gt; We think we should add informative text that suggests applications should
&gt; create a MediaKeys object and call setMediaKeys before setting the media
&gt; source if they want to signal to the media engine that a protected pipeline
&gt; is desired. If the application does not do this then this should be left as
&gt; a quality of implementation issue.

The fix for bug 19009 notes that events may not be fired at MediaKeySession objects until setMediaKeys() is called, but this is not the same as Adrian&apos;s suggestion.

The current setMediaKeys() algorithm text contains the following statement, which is incompatible with this solution:
&quot;In general, applications should wait for an event named needkey or loadstart (per the resource fetch algorithm) before calling this method.&quot;
This text is left over from generateKeyRequest(). I think we can eliminate it since HTMLMediaElement implementations should be able to store a reference to the MediaKeys even if the MediaPlayer is not initialized.

Two questions:
1) Should we add text similar to Adrian&apos;s proposal?
2) Any reason not to remove the text left over from generateKeyRequest()?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>95636</commentid>
    <comment_count>7</comment_count>
    <who name="David Dorwin">ddorwin</who>
    <bug_when>2013-10-31 21:55:59 +0000</bug_when>
    <thetext>In addition to the non-normative text mentioned above, the setMediaKeys() algorithm contains the following normative step, which we should also remove:
&quot;If loading has not started, throw an INVALID_STATE_ERR exception and abort these steps.&quot;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>95637</commentid>
    <comment_count>8</comment_count>
    <who name="David Dorwin">ddorwin</who>
    <bug_when>2013-10-31 22:05:11 +0000</bug_when>
    <thetext>If we do recommend that setMediaKeys() be called before setting the source, we may want to reconsider whether to add the &apos;keySystem&apos; attribute to HTMLSourceElement (issue 20336). Using &lt;source&gt; with &apos;keySystem&apos; would contradict this recommendation, so I don&apos;t think it makes sense to make user agents implement this unlikely-to-be-used feature.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>96301</commentid>
    <comment_count>9</comment_count>
    <who name="Adrian Bateman [MSFT]">adrianba</who>
    <bug_when>2013-11-14 07:50:47 +0000</bug_when>
    <thetext>Updated the spec with changes from comments 6 and 7:
https://dvcs.w3.org/hg/html-media/rev/cda7de85614f

David will file a new bug for comment 8.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>96308</commentid>
    <comment_count>10</comment_count>
    <who name="David Dorwin">ddorwin</who>
    <bug_when>2013-11-14 08:31:07 +0000</bug_when>
    <thetext>The new bug to address the contradiction is bug 23828.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>