W3C home > Mailing lists > Public > public-html-media@w3.org > June 2012

: [EME] Separating key session creation from the media element (using a MediaKeySession constructor)

From: Sunyang (Eric) <eric.sun@huawei.com>
Date: Thu, 28 Jun 2012 08:19:45 +0000
To: David Dorwin <ddorwin@google.com>, "public-html-media@w3.org" <public-html-media@w3.org>
Message-ID: <9254B5E6361B1648AFC00BA447E6E8C32AEAA6BA@szxeml545-mbx.china.huawei.com>
Can I deduce that we the session can be reused by different media element at different time.
Thus the key gotten from license server can be reused when the same content arrives at user agent if the session remained after previous content is decrypted and played.
Right?

________________________________

Ϊ޹˾ Huawei Technologies Co., Ltd.
[Company_logo]

Phone: +86 25 56622934
Fax: +86 25 56624081
Mobile: +86 13851889004
Email: eric.sun@huawei.com
ַϾ껨101 ΪϾ ʱࣺ210012
Huawei Technologies Co., Ltd.
No 101,Software Avenue, Yuhua District,Nanjing 518129, P.R.China
http://www.huawei.com

________________________________
ʼ丽лΪ˾ıϢڷ͸ַгĸ˻Ⱥ顣
ֹκκʽʹãȫ򲿷ֵй¶ơɢʼ
Ϣ˱ʼ绰ʼ֪ͨ˲ɾʼ
This e-mail and its attachments contain confidential information from HUAWEI, which
is intended only for the person or entity whose address is listed above. Any use of the
information contained herein in any way (including, but not limited to, total or partial
disclosure, reproduction, or dissemination) by persons other than the intended
recipient(s) is prohibited. If you receive this e-mail in error, please notify the sender by
phone or email immediately and delete it!
: David Dorwin [mailto:ddorwin@google.com]
ʱ: 2012627 9:30
ռ: public-html-media@w3.org
: [EME] Separating key session creation from the media element (using a MediaKeySession constructor)

In today's teleconference [1], we decided to create a session object [2] with video.generateKeyRequest() rather than video.createKeySession() or something similar. While working on the change proposal, I realized that there are good reasons to consider separating object creation from the media element (something we had not discussed). I think the potential benefits are compelling enough to revisit this issue. Hopefully we can have a quick discussion in email and move forward with one of these solutions. If you are interested in the API design, please provide feedback and/or state your preference soon. In parallel, I'll continue working on the change proposal (ETA is now tomorrow).

The new option is to create session objects using "new MediaKeySession(keySystem, mimeType)". For example:
  function handleNeedKey(event) {
    var session = new MediaKeySession(keySystem, mimeType);
    if (session) {
      session.onkeymessage = handleKeyMessage;
      session.onkeyerror = handleKeyError;
      session.generateKeyRequest(initData);
      var video = event.target;
      video.addKeySession(session);
    }
  }

Another variant would be to add initData to the MediaKeySession constructor and specify that the constructor generates a key request. This would eliminate the need for generateKeyRequest() and have most of the benefits of the video.generateKeyRequest() solution discussed in the teleconference. For example:
  function handleNeedKey(event) {
    var session = new MediaKeySession(keySystem, mimeType, initData);
    if (session) {
      session.onkeymessage = handleKeyMessage;
      session.onkeyerror = handleKeyError;
      var video = event.target;
      video.addKeySession(session);
    }
  }

Advantages of this approach

  1.  This might make more sense if we eventually decide to support sharing sessions between media elements (https://www.w3.org/Bugs/Public/show_bug.cgi?id=16615 and https://www.w3.org/Bugs/Public/show_bug.cgi?id=17202).

     *   Any of the "session = video.foo()" solutions result in an implicit relationship.

  1.  It might enable initiating key exchange before the media element starts loading. [3]
  2.  The resulting object could be used for Key Release (https://www.w3.org/Bugs/Public/show_bug.cgi?id=17199) without needing to create a "dummy" media element (http://lists.w3.org/Archives/Public/public-html-media/2012Jun/0107.html) or defining a separate object just for key release (http://dvcs.w3.org/hg/html-media/raw-file/tip/encrypted-media/encrypted-media.html#key-release-manager).
  3.  MediaSource is using this model ("new MediaSource"; http://lists.w3.org/Archives/Public/public-html-media/2012Jun/0071.html), and it would be nice to have consistency.
  4.  In the first variant only, explicit separation of creation from actions.

Effects of this approach
The primary effect is that the session object is not implicitly associated with a media element.

Because initData should contain all the information (i.e. the appropriate ISO CENC PSSH) necessary to obtain a license and verify that the specified key system is supported, the session object should not need to be associated with a specific element (or source file/stream) until its keys are needed to decrypt content.

However, the separation does require the following:

  *   The MIME type must be explicitly specified to the session object.

     *   This is similar to the MediaSource constructor, which takes a type string.
     *   For the case where the object is created in response to a needkey event, we could even provide the current MIME type as an attribute of the event.
     *   Since the MIME type is specified separately, the media element would need to fail addKeySession() or only use a session if the types were compatible.
     *   (This would be required anyway if we wanted to address advantage #2 above. [3])

  *   Session objects must be implicitly or explicitly associated with media element(s).

     *   This is similar to MediaSource, which provides a URL to video.src.
     *   Implicit example: All media elements may use all sessions.
     *   Explicit example: video.addKeySession(session);

Compared to the video.generateKeyRequest() solution:

  *   The second variant (constructor generates a key request) is very similar.
  *   The first variant (constructor does NOT generate a key request):

     *   Requires one or two more lines of application code during initialization.
     *   Requires an object(s) must be created first for each KeySystem in the use case where generateKeyRequest(keySystem, initData) can be called repeatedly until a supported combination is found.

        *   This seems accpetable. [4]

     *   No longer implicitly enforces that generateKeyRequest() is called before addKey().

        *   We could just choose not to enforce this but instead require that all key systems support generateKeyRequest() by returning a keymessage so that applications can always follow this pattern. That was the main goal of this requirement anyway.

     *   No longer implicitly enforces that a session object represents exactly one initData value.

        *   Instead, subsequent generateKeyRequest() calls should explicitly fail, at least if a previous call was successful.


[1] http://www.w3.org/2012/06/26-html-media-minutes.html


[2] See http://lists.w3.org/Archives/Public/public-html-media/2012Jun/0054.html and https://www.w3.org/Bugs/Public/show_bug.cgi?id=16613


[3] Currently, the media element must have started loading before generateKeyRequest() can be called. WebKit, at least, does not create the underlying media engine until loading starts. Even if we could work around this, the media element would need to somehow know the MIME type it will be provided so that the user agent or the CDM can parse the initData.  If we separate the CDM from the media element, implementations should be able to create the underlying objects immediately regardless of the media implementation.

[4] If the combinations passed to generateKeyRequest() fail

  *   Synchronously:

     *   Creating an object to call this function doesn't seem too bad for the application. It should just be an extra line of code
     *   Note: Failing synchronously in any design may require the user agent to be able to parse at least part of the initData and determine whether it contains data for one of the key systems it supports.
     *   Assuming that creation of the session object causes the related CDM to spin up, CDMs may be spun up unnecessarily in the case that the generateKeyRequest() call fails. Fortunately, this would happen asynchronous to the application and should not affect performance.

  *   Asynchronously:

     *   Creating an object is likely to be a very minor part of the logic required to support this.


image001.jpg
(image/jpeg attachment: image001.jpg)

Received on Thursday, 28 June 2012 08:22:59 UTC

This archive was generated by hypermail 2.3.1 : Tuesday, 6 January 2015 20:32:56 UTC