Changeset 235610 in webkit


Ignore:
Timestamp:
Sep 4, 2018 3:27:27 AM (6 years ago)
Author:
commit-queue@webkit.org
Message:

[EME] Add the WebM initData support in ClearKey CDM
https://bugs.webkit.org/show_bug.cgi?id=189240

Patch by Yacine Bandou <yacine.bandou_ext@softathome.com> on 2018-09-04
Reviewed by Xabier Rodriguez-Calvar.

Add the "webm" initDataType support in ClearKey CDM.
Read the WebM initData by following the W3C spec https://www.w3.org/TR/eme-initdata-webm/#common-system,
and put it in JSON object format like is specified in https://www.w3.org/TR/encrypted-media/#clear-key-request-format.

Tests: media/encrypted-media/clearKey/clearKey-encrypted-webm-event-mse.html

media/encrypted-media/clearKey/clearKey-webm-video-playback-mse.html

  • platform/encryptedmedia/clearkey/CDMClearKey.cpp:

(WebCore::extractKeyIdFromWebMInitData):
(WebCore::CDMPrivateClearKey::supportsInitDataType const):
(WebCore::CDMPrivateClearKey::supportsInitData const):
(WebCore::CDMInstanceClearKey::requestLicense):

Location:
trunk/Source/WebCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r235607 r235610  
     12018-09-04  Yacine Bandou  <yacine.bandou_ext@softathome.com>
     2
     3        [EME] Add the WebM initData support in ClearKey CDM
     4        https://bugs.webkit.org/show_bug.cgi?id=189240
     5
     6        Reviewed by Xabier Rodriguez-Calvar.
     7
     8        Add the "webm" initDataType support in ClearKey CDM.
     9        Read the WebM initData by following the W3C spec https://www.w3.org/TR/eme-initdata-webm/#common-system,
     10        and put it in JSON object format like is specified in https://www.w3.org/TR/encrypted-media/#clear-key-request-format.
     11
     12        Tests: media/encrypted-media/clearKey/clearKey-encrypted-webm-event-mse.html
     13               media/encrypted-media/clearKey/clearKey-webm-video-playback-mse.html
     14
     15        * platform/encryptedmedia/clearkey/CDMClearKey.cpp:
     16        (WebCore::extractKeyIdFromWebMInitData):
     17        (WebCore::CDMPrivateClearKey::supportsInitDataType const):
     18        (WebCore::CDMPrivateClearKey::supportsInitData const):
     19        (WebCore::CDMInstanceClearKey::requestLicense):
     20
    1212018-09-03  Andy Estes  <aestes@apple.com>
    222
  • trunk/Source/WebCore/platform/encryptedmedia/clearkey/CDMClearKey.cpp

    r232613 r235610  
    264264}
    265265
     266static Ref<SharedBuffer> extractKeyIdFromWebMInitData(const SharedBuffer& initData)
     267{
     268    Ref<SharedBuffer> keyIds = SharedBuffer::create();
     269
     270    // Check if initData is a valid WebM initData.
     271    if (initData.isEmpty() || initData.size() > std::numeric_limits<unsigned>::max())
     272        return keyIds;
     273
     274    auto object = JSON::Object::create();
     275    auto keyIdsArray = JSON::Array::create();
     276
     277    // Read the KeyId
     278    // 9.1.3 License Request Format
     279    // This section describes the format of the license request provided to the application via the message attribute of the message event.
     280    // The format is a JSON object containing the following members:
     281    // "kids"
     282    // An array of key IDs. Each element of the array is the base64url encoding of the octet sequence containing the key ID value.
     283    String keyId = WTF::base64URLEncode(initData.data(), initData.size());
     284    keyIdsArray->pushString(keyId);
     285
     286    object->setArray("kids", WTFMove(keyIdsArray));
     287    CString jsonData = object->toJSONString().utf8();
     288    keyIds->append(jsonData.data(), jsonData.length());
     289    return keyIds;
     290}
     291
    266292CDMFactoryClearKey& CDMFactoryClearKey::singleton()
    267293{
     
    295321{
    296322    // `keyids` and 'cenc' are the only supported init data type.
    297     return (equalLettersIgnoringASCIICase(initDataType, "keyids") || equalLettersIgnoringASCIICase(initDataType, "cenc"));
     323    return (equalLettersIgnoringASCIICase(initDataType, "keyids") || equalLettersIgnoringASCIICase(initDataType, "cenc") || equalLettersIgnoringASCIICase(initDataType, "webm"));
    298324}
    299325
     
    404430    // Validate the initData buffer as CENC initData.
    405431    if (equalLettersIgnoringASCIICase(initDataType, "cenc") && isCencInitData(initData))
     432        return true;
     433
     434    // Validate the initData buffer as WebM initData.
     435    if (equalLettersIgnoringASCIICase(initDataType, "webm") && !initData.isEmpty())
    406436        return true;
    407437
     
    471501    if (equalLettersIgnoringASCIICase(initDataType, "cenc"))
    472502        initData = extractKeyidsFromCencInitData(initData.get());
     503
     504    if (equalLettersIgnoringASCIICase(initDataType, "webm"))
     505        initData = extractKeyIdFromWebMInitData(initData.get());
    473506
    474507    callOnMainThread(
Note: See TracChangeset for help on using the changeset viewer.