Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Source/WebCore/Modules/encryptedmedia/MediaKeys.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,9 @@ void MediaKeys::detachCDMClient(CDMClient& client)
{
ASSERT(m_cdmClients.contains(client));
m_cdmClients.remove(client);
if (m_cdmClients.computesEmpty()) {
m_instance->releaseCDM();
}
}

void MediaKeys::attemptToResumePlaybackOnClients()
Expand Down
6 changes: 6 additions & 0 deletions Source/WebCore/html/HTMLMediaElement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6097,6 +6097,12 @@ void HTMLMediaElement::stop()

if (m_mediaSession)
m_mediaSession->stopSession();

if (m_mediaKeys) {
m_mediaKeys->detachCDMClient(*this);
if (m_player)
m_player->cdmInstanceDetached(m_mediaKeys->cdmInstance());
}
}

void HTMLMediaElement::suspend(ReasonForSuspension reason)
Expand Down
1 change: 1 addition & 0 deletions Source/WebCore/platform/encryptedmedia/CDMInstance.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ class CDMInstance : public RefCounted<CDMInstance> {
virtual void setStorageDirectory(const String&) = 0;
virtual const String& keySystem() const = 0;
virtual RefPtr<CDMInstanceSession> createSession() = 0;
virtual void releaseCDM() { };

enum class HDCPStatus : uint8_t {
Unknown,
Expand Down
14 changes: 12 additions & 2 deletions Source/WebCore/platform/graphics/gstreamer/eme/CDMThunder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,6 @@ bool CDMFactoryThunder::supportsKeySystem(const String& keySystem)

CDMPrivateThunder::CDMPrivateThunder(const String& keySystem)
: m_keySystem(keySystem)
, m_thunderSystem(opencdm_create_system(keySystem.utf8().data()))
{
};

Expand Down Expand Up @@ -204,7 +203,9 @@ void CDMPrivateThunder::loadAndInitialize()

bool CDMPrivateThunder::supportsServerCertificates() const
{
bool isSupported = opencdm_system_supports_server_certificate(m_thunderSystem.get());
OpenCDMSystem *ocdmSystem = opencdm_create_system(m_keySystem.utf8().data());
bool isSupported = opencdm_system_supports_server_certificate(ocdmSystem);
opencdm_destruct_system(ocdmSystem);
GST_DEBUG("server certificate supported %s", boolForPrinting(isSupported));
return isSupported;
}
Expand Down Expand Up @@ -258,6 +259,9 @@ void CDMInstanceThunder::initializeWithConfiguration(const CDMKeySystemConfigura
void CDMInstanceThunder::setServerCertificate(Ref<SharedBuffer>&& certificate, SuccessCallback&& callback)
{
auto data = certificate->extractData();
if (m_thunderSystem.get() == nullptr) {
m_thunderSystem.reset(opencdm_create_system(m_keySystem.utf8().data()));
}
OpenCDMError error = opencdm_system_set_server_certificate(m_thunderSystem.get(), const_cast<uint8_t*>(data.data()), data.size());
callback(!error ? Succeeded : Failed);
}
Expand All @@ -267,6 +271,12 @@ void CDMInstanceThunder::setStorageDirectory(const String& storageDirectory)
FileSystem::makeAllDirectories(storageDirectory);
}

void CDMInstanceThunder::releaseCDM()
{
GST_DEBUG("release CDM resources");
m_thunderSystem.reset();
}

CDMInstanceSessionThunder::CDMInstanceSessionThunder(CDMInstanceThunder& instance)
: CDMInstanceSessionProxy(instance)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@ class CDMPrivateThunder final : public CDMPrivate {

private:
String m_keySystem;
Thunder::UniqueThunderSystem m_thunderSystem;
};

class CDMInstanceThunder final : public CDMInstanceProxy {
Expand All @@ -114,6 +113,7 @@ class CDMInstanceThunder final : public CDMInstanceProxy {
void setStorageDirectory(const String&) final;
const String& keySystem() const final { return m_keySystem; }
RefPtr<CDMInstanceSession> createSession() final;
void releaseCDM() final;

OpenCDMSystem& thunderSystem() const { return *m_thunderSystem.get(); };

Expand Down