contentType: Are codecs allowed? Use a simpler string to identify the initData format?

[Note: |type| was renamed to |contentType| this morning to resolve bug
24213<https://www.w3.org/Bugs/Public/show_bug.cgi?id=24213>
.]

I have always assumed that contentType - as reported in the needkey event
and passed to createSession() - would be a simple MIME type containing
*only* the container type. For example, "video/webm" or "audio/mp4".
However, I don't think the spec actually has this restriction.

Such a restriction would make both browser and app implementations simpler
(and slightly reduce confusion about the meaning of the values). I suppose
it's possible that an app developer might want to pass the same
codec-containing string to isTypeSupported() and createSession(), but at
the cost of forcing all apps to parse the value rather than doing a simple
string compare. Does anyone object to adding an explicit restriction?

The use of "MIME type" also means that the needkey event could report
either the audio/ or video/ variant regardless of the actual stream(s) in
the media data. This is noted twice in the spec
(example<https://dvcs.w3.org/hg/html-media/raw-file/default/encrypted-media/encrypted-media.html#dom-contenttype>).
Maybe this all would be simpler if we stopped using a MIME type and just
passed the container name. such as "webm" or "mp4". The exact string to use
would be specified in the relevant Container Guidelines. (We could
potentially even use "cenc" and avoid the ambiguity discussed in bug
17673<https://www.w3.org/Bugs/Public/show_bug.cgi?id=17673>
.)

Given the intended values and use, I wonder if we should change
the |contentType| attribute and parameter name to |containerType| or
just |container|. |initDataType| is another option, since that's really
what the value indicates. (This makes even more sense if we use just the
container name as discussed above.) We could revert then
isTypeSupported()'s parameter name to |type| to again be consistent with
canPlayType() and MSE's isTypeSupported(), all of which accept full MIME
types with optional codecs.

If we made both changes, we would have the following signatures:

static bool isTypeSupported(DOMstring keySystem, DOMString? *type*);
MediaKeyNeededEvent.*initDataType*
MediaKeySession createSession(DOMString *initDataType*, Uint8Array
initData);

Example uses:

MediaKeys.isTypeSupported('org.w3.clearkey', 'video/mp4');  // Unchanged
MediaKeys.isTypeSupported('org.w3.clearkey', 'video/mp4; codecs="avc1"');
// Unchanged
if (event.*initDataType* = *'mp4'*) {...}
MediaKeys.createSession(event.*initDataType*, event.initData);
MediaKeys.createSession(*'mp4'*, initDataArray);


Thoughts? Other suggestions?

David

Received on Wednesday, 8 January 2014 02:18:48 UTC