diff --git a/Source/WebCore/platform/GStreamer.cmake b/Source/WebCore/platform/GStreamer.cmake index 55f7c973771b..9d41485da55c 100644 --- a/Source/WebCore/platform/GStreamer.cmake +++ b/Source/WebCore/platform/GStreamer.cmake @@ -175,6 +175,13 @@ if (ENABLE_ENCRYPTED_MEDIA AND ENABLE_THUNDER) # Globally add thunder libraries, required for the check_cxx_symbol_exists call. set(CMAKE_REQUIRED_LIBRARIES ${THUNDER_LIBRARIES}) + check_cxx_symbol_exists(opencdm_system_supported_robustness ${THUNDER_INCLUDE_DIR}/open_cdm.h HAS_OCDM_SUPPORTED_ROBUSTNESS) + if (HAS_OCDM_SUPPORTED_ROBUSTNESS) + list(APPEND WebCore_PRIVATE_DEFINITIONS THUNDER_HAS_OCDM_SUPPORTED_ROBUSTNESS=1) + else () + list(APPEND WebCore_PRIVATE_DEFINITIONS THUNDER_HAS_OCDM_SUPPORTED_ROBUSTNESS=0) + endif () + check_cxx_symbol_exists(opencdm_gstreamer_session_decrypt_buffer ${THUNDER_INCLUDE_DIR}/open_cdm_adapter.h HAS_OCDM_DECRYPT_BUFFER) if (HAS_OCDM_DECRYPT_BUFFER) list(APPEND WebCore_PRIVATE_DEFINITIONS THUNDER_HAS_OCDM_DECRYPT_BUFFER=1) diff --git a/Source/WebCore/platform/graphics/gstreamer/eme/CDMThunder.cpp b/Source/WebCore/platform/graphics/gstreamer/eme/CDMThunder.cpp index dbe0195d802f..55a6a220a8ed 100644 --- a/Source/WebCore/platform/graphics/gstreamer/eme/CDMThunder.cpp +++ b/Source/WebCore/platform/graphics/gstreamer/eme/CDMThunder.cpp @@ -171,7 +171,39 @@ bool CDMPrivateThunder::supportsConfiguration(const CDMKeySystemConfiguration& c Vector CDMPrivateThunder::supportedRobustnesses() const { - return { emptyAtom(), "SW_SECURE_DECODE"_s, "SW_SECURE_CRYPTO"_s }; + static const Vector defaultRobustnesses = { emptyAtom(), "SW_SECURE_DECODE"_s, "SW_SECURE_CRYPTO"_s }; + +#if THUNDER_HAS_OCDM_SUPPORTED_ROBUSTNESS + if (!m_thunderSystem) { + GST_WARNING("CDMPrivateThunder: No active OpenCDM system. Falling back to default WebKit robustness levels."); + return defaultRobustnesses; + } + + Vector robustnesses = { emptyAtom() }; + char** buffer = nullptr; + uint16_t count = 0; + + OpenCDMError error = opencdm_system_supported_robustness(m_thunderSystem.get(), &buffer, &count); + if (buffer) { + if (error == ERROR_NONE && count > 0) + robustnesses.reserveCapacity(robustnesses.size() + count); + + for (uint16_t i = 0; i < count; ++i) { + if (error == ERROR_NONE && buffer[i]) + robustnesses.append(AtomString::fromLatin1(buffer[i])); + + free(buffer[i]); + } + free(buffer); + } + + if (error == ERROR_NONE && robustnesses.size() > 1) + return robustnesses; + + GST_WARNING("Failed to get robustness levels from OCDM.Falling back to default WebKit robustness levels."); +#endif + + return defaultRobustnesses; } CDMRequirement CDMPrivateThunder::distinctiveIdentifiersRequirement(const CDMKeySystemConfiguration&, const CDMRestrictions&) const