⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 273311 in webkit


Ignore:
Timestamp:
Feb 23, 2021, 9:09:50 AM (6 years ago)
Author:
calvaris@igalia.com
Message:

[GStreamer][EME][Thunder] Initialize decryptor lazily
​https://bugs.webkit.org/show_bug.cgi?id=222314

Reviewed by Philippe Normand.

In some cases, WebKit can be run before Thunder nano services are
up and without PSON, the result can be that you end up with WebKit
thinking there is no DRM system available.

First thing this patch does it removing the once flag so we keep
asking if there are DRM systems available if we are asked about
them from JS.

Second thing is that if we are queried from JS about the
availability of DRM systems and there are some available, we
initialize the decryptor.

  • platform/graphics/gstreamer/GStreamerCommon.cpp:

(WebCore::registerWebKitGStreamerElements):

  • platform/graphics/gstreamer/eme/CDMThunder.cpp:

(WebCore::CDMFactoryThunder::supportedKeySystems const):

  • platform/graphics/gstreamer/eme/WebKitThunderDecryptorGStreamer.cpp:
Location:
trunk/Source/WebCore
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r273310 r273311  
     12021-02-23  Xabier Rodriguez Calvar  <calvaris@igalia.com>
     2
     3        [GStreamer][EME][Thunder] Initialize decryptor lazily
     4        https://bugs.webkit.org/show_bug.cgi?id=222314
     5
     6        Reviewed by Philippe Normand.
     7
     8        In some cases, WebKit can be run before Thunder nano services are
     9        up and without PSON, the result can be that you end up with WebKit
     10        thinking there is no DRM system available.
     11
     12        First thing this patch does it removing the once flag so we keep
     13        asking if there are DRM systems available if we are asked about
     14        them from JS.
     15
     16        Second thing is that if we are queried from JS about the
     17        availability of DRM systems and there are some available, we
     18        initialize the decryptor.
     19
     20        * platform/graphics/gstreamer/GStreamerCommon.cpp:
     21        (WebCore::registerWebKitGStreamerElements):
     22        * platform/graphics/gstreamer/eme/CDMThunder.cpp:
     23        (WebCore::CDMFactoryThunder::supportedKeySystems const):
     24        * platform/graphics/gstreamer/eme/WebKitThunderDecryptorGStreamer.cpp:
     25
    1262021-02-23  Don Olmstead  <don.olmstead@sony.com>
    227
  • trunk/Source/WebCore/platform/graphics/gstreamer/GStreamerCommon.cpp

    r272129 r273311  
    312312#if ENABLE(ENCRYPTED_MEDIA)
    313313        gst_element_register(nullptr, "webkitclearkey", GST_RANK_PRIMARY + 200, WEBKIT_TYPE_MEDIA_CK_DECRYPT);
    314 #if ENABLE(THUNDER)
    315         unsigned thunderRank = isThunderRanked() ? 300 : 100;
    316         gst_element_register(nullptr, "webkitthunder", GST_RANK_PRIMARY + thunderRank, WEBKIT_TYPE_MEDIA_THUNDER_DECRYPT);
    317 #endif
    318314#endif
    319315
  • trunk/Source/WebCore/platform/graphics/gstreamer/eme/CDMThunder.cpp

    r272369 r273311  
    4343#include "NotImplemented.h"
    4444#include "SharedBuffer.h"
     45#include "WebKitThunderDecryptorGStreamer.h"
    4546#include <algorithm>
    4647#include <iterator>
    … …  
    115116const Vector<String>& CDMFactoryThunder::supportedKeySystems() const
    116117{
    117     static std::once_flag onceFlag;
     118    ASSERT(isMainThread());
     119
    118120    static Vector<String> supportedKeySystems;
    119     std::call_once(onceFlag, [] {
     121    if (supportedKeySystems.isEmpty()) {
    120122        std::string emptyString;
    121123        if (opencdm_is_type_supported(GStreamerEMEUtilities::s_WidevineKeySystem, emptyString.c_str()) == ERROR_NONE)
    122124            supportedKeySystems.append(GStreamerEMEUtilities::s_WidevineKeySystem);
     125        if (!supportedKeySystems.isEmpty()) {
     126            unsigned thunderRank = isThunderRanked() ? 300 : 100;
     127            gst_element_register(nullptr, "webkitthunder", GST_RANK_PRIMARY + thunderRank, WEBKIT_TYPE_MEDIA_THUNDER_DECRYPT);
     128        }
    123129#ifndef NDEBUG
    124         if (supportedKeySystems.isEmpty() && isThunderRanked()) {
    125             ASSERT_NOT_REACHED_WITH_MESSAGE("Thunder is up-ranked as preferred decryptor but Thunder is not supporting any encryption system. Is "
     130        else if (isThunderRanked())
     131            GST_WARNING("Thunder is up-ranked as preferred decryptor but Thunder is not supporting any encryption system. Is "
    126132                "Thunder running? Are the plugins built?");
    127         }
    128133#endif
    129     });
     134        GST_DEBUG("%u supported key systems", supportedKeySystems.size());
     135    };
    130136    return supportedKeySystems;
    131137}
  • trunk/Source/WebCore/platform/graphics/gstreamer/eme/WebKitThunderDecryptorGStreamer.cpp

    r272369 r273311  
    7171    GRefPtr<GstCaps> caps = adoptGRef(gst_caps_new_empty());
    7272
    73     if (CDMFactoryThunder::singleton().supportedKeySystems().isEmpty()) {
     73    auto& supportedKeySystems = CDMFactoryThunder::singleton().supportedKeySystems();
     74
     75    if (supportedKeySystems.isEmpty()) {
    7476        GST_WARNING("no supported key systems in Thunder, we won't be able to decrypt anything with the its decryptor");
    7577        return caps;
    … …  
    8082            cencEncryptionMediaTypes[i], nullptr));
    8183    }
    82     for (const auto& keySystem : CDMFactoryThunder::singleton().supportedKeySystems()) {
     84    for (const auto& keySystem : supportedKeySystems) {
    8385        for (int i = 0; cencEncryptionMediaTypes[i]; ++i) {
    8486            gst_caps_append_structure(caps.get(), gst_structure_new("application/x-cenc", "original-media-type", G_TYPE_STRING,
Note: See TracChangeset for help on using the changeset viewer.