Changeset 231699 in webkit


Ignore:
Timestamp:
May 11, 2018 3:50:37 AM (6 years ago)
Author:
commit-queue@webkit.org
Message:

[EME][GStreamer] Handle the protection event in MediaPlayerPrivate
https://bugs.webkit.org/show_bug.cgi?id=185535

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

This patch is based on this calvaris's commit
https://github.com/WebPlatformForEmbedded/WPEWebKit/commit/d966168b0d2b65f9ca9415426e26d3752c78b03e

It adds a handler for the protection event in MediaPalyerPrivateGStreamerBase, it extracts the InitData from the event
and sends the encrypted event to JS via HTMLMediaElement.

  • platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp:

(WebCore::MediaPlayerPrivateGStreamerBase::initializationDataEncountered):
(WebCore::MediaPlayerPrivateGStreamerBase::handleProtectionEvent):

  • platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.h:
  • platform/graphics/gstreamer/eme/GStreamerEMEUtilities.h: Add a new type InitData.
Location:
trunk/Source/WebCore
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r231696 r231699  
     12018-05-11  Yacine Bandou  <yacine.bandou_ext@softathome.com>
     2
     3        [EME][GStreamer] Handle the protection event in MediaPlayerPrivate
     4        https://bugs.webkit.org/show_bug.cgi?id=185535
     5
     6        Reviewed by Xabier Rodriguez-Calvar.
     7
     8        This patch is based on this calvaris's commit
     9        https://github.com/WebPlatformForEmbedded/WPEWebKit/commit/d966168b0d2b65f9ca9415426e26d3752c78b03e
     10
     11        It adds a handler for the protection event in MediaPalyerPrivateGStreamerBase, it extracts the InitData from the event
     12        and sends the encrypted event to JS via HTMLMediaElement.
     13        * platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp:
     14        (WebCore::MediaPlayerPrivateGStreamerBase::initializationDataEncountered):
     15        (WebCore::MediaPlayerPrivateGStreamerBase::handleProtectionEvent):
     16        * platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.h:
     17        * platform/graphics/gstreamer/eme/GStreamerEMEUtilities.h: Add a new type InitData.
     18
    1192018-05-11  Basuke Suzuki  <Basuke.Suzuki@sony.com>
    220
  • trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp

    r231551 r231699  
    12051205
    12061206#if ENABLE(ENCRYPTED_MEDIA)
     1207void MediaPlayerPrivateGStreamerBase::initializationDataEncountered(GstEvent* event)
     1208{
     1209    // FIXME: Inform that we are waiting for a key.
     1210    const char* eventKeySystemUUID = nullptr;
     1211    GstBuffer* data = nullptr;
     1212    gst_event_parse_protection(event, &eventKeySystemUUID, &data, nullptr);
     1213
     1214    // Check if the system key of the protection event is the same of the CDM instance.
     1215    // For example: we can receive a new Widevine protection event but the CDM instance initialized with
     1216    // Playready, so we ignore this event.
     1217    if (m_cdmInstance && g_strcmp0(GStreamerEMEUtilities::keySystemToUuid(m_cdmInstance->keySystem()), eventKeySystemUUID)) {
     1218        GST_DEBUG("The protection event with UUID %s is ignored because it isn't supported by the CDM %s", eventKeySystemUUID, m_cdmInstance->keySystem().utf8().data());
     1219        return;
     1220    }
     1221
     1222    GstMapInfo mapInfo;
     1223    if (!gst_buffer_map(data, &mapInfo, GST_MAP_READ)) {
     1224        GST_WARNING("cannot map %s protection data", eventKeySystemUUID);
     1225        return;
     1226    }
     1227
     1228    GST_TRACE("init data encountered for %s of size %" G_GSIZE_FORMAT, eventKeySystemUUID, mapInfo.size);
     1229    GST_MEMDUMP("init data", reinterpret_cast<const uint8_t*>(mapInfo.data), mapInfo.size);
     1230    InitData initData(reinterpret_cast<const uint8_t*>(mapInfo.data), mapInfo.size);
     1231    gst_buffer_unmap(data, &mapInfo);
     1232
     1233    String eventKeySystemUUIDString = eventKeySystemUUID;
     1234    RunLoop::main().dispatch([weakThis = m_weakPtrFactory.createWeakPtr(*this), eventKeySystemUUID = eventKeySystemUUIDString, initData] {
     1235        if (!weakThis)
     1236            return;
     1237
     1238        GST_DEBUG("scheduling initializationDataEncountered event for %s with init data size of %" G_GSIZE_FORMAT, eventKeySystemUUID.utf8().data(), initData.sizeInBytes());
     1239        GST_MEMDUMP("init datas", reinterpret_cast<const uint8_t*>(initData.characters8()), initData.sizeInBytes());
     1240        weakThis->m_player->initializationDataEncountered(ASCIILiteral("cenc"), ArrayBuffer::create(reinterpret_cast<const uint8_t*>(initData.characters8()), initData.sizeInBytes()));
     1241    });
     1242}
     1243
    12071244void MediaPlayerPrivateGStreamerBase::cdmInstanceAttached(CDMInstance& instance)
    12081245{
     
    12571294    if (m_handledProtectionEvents.contains(GST_EVENT_SEQNUM(event))) {
    12581295        GST_DEBUG_OBJECT(pipeline(), "event %u already handled", GST_EVENT_SEQNUM(event));
    1259         m_handledProtectionEvents.remove(GST_EVENT_SEQNUM(event));
    1260         if (m_needToResendCredentials) {
    1261             GST_DEBUG_OBJECT(pipeline(), "resending credentials");
    1262             attemptToDecryptWithLocalInstance();
    1263         }
    1264         return;
    1265     }
    1266 
    1267     const gchar* eventKeySystemId = nullptr;
    1268     gst_event_parse_protection(event, &eventKeySystemId, nullptr, nullptr);
    1269     GST_WARNING("FIXME: unhandled protection event for %s", eventKeySystemId);
    1270     ASSERT_NOT_REACHED();
     1296        return;
     1297    }
     1298    initializationDataEncountered(event);
    12711299}
    12721300#endif
  • trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.h

    r231088 r231699  
    145145    void attemptToDecryptWithInstance(CDMInstance&) override;
    146146    void dispatchCDMInstance();
     147    void initializationDataEncountered(GstEvent*);
    147148#endif
    148149
  • trunk/Source/WebCore/platform/graphics/gstreamer/eme/GStreamerEMEUtilities.h

    r230625 r231699  
    3232namespace WebCore {
    3333
     34using InitData = String;
     35
    3436class GStreamerEMEUtilities {
    3537
Note: See TracChangeset for help on using the changeset viewer.