Skip to content

Commit

Permalink
[GStreamer][EME] Remove DRM resources release
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=223436

Reviewed by Philippe Normand.

Releasing DRM resources should not be needed according to the
spec. If we needed this in the future because of whatever reason
we need to study it again in some other way.

* platform/encryptedmedia/CDMProxy.cpp:
(WebCore::CDMInstanceProxy::trackSession): Deleted.
(WebCore::CDMInstanceSessionProxy::removeFromInstanceProxy): Deleted.
* platform/encryptedmedia/CDMProxy.h:
(WebCore::CDMProxy::releaseDecryptionResources): Deleted.
(WebCore::CDMInstanceSessionProxy::releaseDecryptionResources): Deleted.
(WebCore::CDMInstanceProxy::removeSession): Deleted.
(WebCore::CDMInstanceProxy::releaseDecryptionResources): Deleted.
* platform/encryptedmedia/clearkey/CDMClearKey.cpp:
(WebCore::CDMInstanceClearKey::createSession):
* platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp:
(WebCore::MediaPlayerPrivateGStreamer::~MediaPlayerPrivateGStreamer):
* platform/graphics/gstreamer/eme/CDMProxyClearKey.cpp:
(WebCore::CDMProxyClearKey::releaseDecryptionResources): Deleted.
* platform/graphics/gstreamer/eme/CDMProxyClearKey.h:
* platform/graphics/gstreamer/eme/CDMThunder.cpp:
(WebCore::CDMInstanceThunder::createSession):
(WebCore::CDMInstanceSessionThunder::requestLicense):
(WebCore::CDMInstanceSessionThunder::closeSession):
(WebCore::CDMInstanceSessionThunder::removeSessionData):
* platform/graphics/gstreamer/eme/CDMThunder.h:


Canonical link: https://commits.webkit.org/235539@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@274719 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
calvaris committed Mar 19, 2021
1 parent daa0edd commit 7b80605
Show file tree
Hide file tree
Showing 9 changed files with 35 additions and 79 deletions.
33 changes: 33 additions & 0 deletions Source/WebCore/ChangeLog
@@ -1,3 +1,36 @@
2021-03-19 Xabier Rodriguez Calvar <calvaris@igalia.com>

[GStreamer][EME] Remove DRM resources release
https://bugs.webkit.org/show_bug.cgi?id=223436

Reviewed by Philippe Normand.

Releasing DRM resources should not be needed according to the
spec. If we needed this in the future because of whatever reason
we need to study it again in some other way.

* platform/encryptedmedia/CDMProxy.cpp:
(WebCore::CDMInstanceProxy::trackSession): Deleted.
(WebCore::CDMInstanceSessionProxy::removeFromInstanceProxy): Deleted.
* platform/encryptedmedia/CDMProxy.h:
(WebCore::CDMProxy::releaseDecryptionResources): Deleted.
(WebCore::CDMInstanceSessionProxy::releaseDecryptionResources): Deleted.
(WebCore::CDMInstanceProxy::removeSession): Deleted.
(WebCore::CDMInstanceProxy::releaseDecryptionResources): Deleted.
* platform/encryptedmedia/clearkey/CDMClearKey.cpp:
(WebCore::CDMInstanceClearKey::createSession):
* platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp:
(WebCore::MediaPlayerPrivateGStreamer::~MediaPlayerPrivateGStreamer):
* platform/graphics/gstreamer/eme/CDMProxyClearKey.cpp:
(WebCore::CDMProxyClearKey::releaseDecryptionResources): Deleted.
* platform/graphics/gstreamer/eme/CDMProxyClearKey.h:
* platform/graphics/gstreamer/eme/CDMThunder.cpp:
(WebCore::CDMInstanceThunder::createSession):
(WebCore::CDMInstanceSessionThunder::requestLicense):
(WebCore::CDMInstanceSessionThunder::closeSession):
(WebCore::CDMInstanceSessionThunder::removeSessionData):
* platform/graphics/gstreamer/eme/CDMThunder.h:

2021-03-19 Devin Rousso <drousso@apple.com>

CSP headers can block default <video> controls
Expand Down
13 changes: 0 additions & 13 deletions Source/WebCore/platform/encryptedmedia/CDMProxy.cpp
Expand Up @@ -373,24 +373,11 @@ void CDMInstanceProxy::removeAllKeysFrom(const KeyStore& keyStore)
m_keyStore.removeAllKeysFrom(keyStore);
}

void CDMInstanceProxy::trackSession(const CDMInstanceSessionProxy& session)
{
ASSERT(!m_sessions.contains(session));
m_sessions.add(session);
}

CDMInstanceSessionProxy::CDMInstanceSessionProxy(CDMInstanceProxy& instance)
: m_instance(makeWeakPtr(instance))
{
}

void CDMInstanceSessionProxy::removeFromInstanceProxy()
{
if (!m_instance)
return;
m_instance->removeSession(*this);
}

} // namespace WebCore

#endif // ENABLE(ENCRYPTED_MEDIA)
26 changes: 0 additions & 26 deletions Source/WebCore/platform/encryptedmedia/CDMProxy.h
Expand Up @@ -158,12 +158,6 @@ class CDMProxy : public ThreadSafeRefCounted<CDMProxy> {
void updateKeyStore(const KeyStore& newKeyStore);
void setInstance(CDMInstanceProxy*);

virtual void releaseDecryptionResources()
{
ASSERT(isMainThread());
m_keyStore.removeAllKeys();
}

protected:
RefPtr<KeyHandle> keyHandle(const KeyIDType&) const;
bool keyAvailable(const KeyIDType&) const;
Expand Down Expand Up @@ -212,8 +206,6 @@ class CDMInstanceProxy;

class CDMInstanceSessionProxy : public CDMInstanceSession, public CanMakeWeakPtr<CDMInstanceSessionProxy, WeakPtrFactoryInitialization::Eager> {
public:
virtual void releaseDecryptionResources() { m_instance.clear(); }
void removeFromInstanceProxy();

protected:
CDMInstanceSessionProxy(CDMInstanceProxy&);
Expand Down Expand Up @@ -249,23 +241,6 @@ class CDMInstanceProxy : public CDMInstance, public CanMakeWeakPtr<CDMInstancePr
void startedWaitingForKey();
void stoppedWaitingForKey();

void removeSession(const CDMInstanceSessionProxy& session) { m_sessions.remove(session); }
virtual void releaseDecryptionResources()
{
ASSERT(isMainThread());
m_keyStore.removeAllKeys();
for (auto& session : m_sessions)
session.releaseDecryptionResources();
m_sessions.clear();
if (m_cdmProxy) {
m_cdmProxy->releaseDecryptionResources();
m_cdmProxy = nullptr;
}
}

protected:
void trackSession(const CDMInstanceSessionProxy&);

private:
RefPtr<CDMProxy> m_cdmProxy;
// FIXME: WeakPtr for the m_player? This is accessed from background and main threads, it's
Expand All @@ -274,7 +249,6 @@ class CDMInstanceProxy : public CDMInstance, public CanMakeWeakPtr<CDMInstancePr
MediaPlayer* m_player { nullptr }; // FIXME: MainThread<T>?

std::atomic<int> m_numDecryptorsWaitingForKey { 0 };
WeakHashSet<CDMInstanceSessionProxy> m_sessions;

KeyStore m_keyStore;
};
Expand Down
Expand Up @@ -450,9 +450,7 @@ const String& CDMInstanceClearKey::keySystem() const

RefPtr<CDMInstanceSession> CDMInstanceClearKey::createSession()
{
auto newSession = adoptRef(new CDMInstanceSessionClearKey(*this));
trackSession(*newSession);
return newSession;
return adoptRef(new CDMInstanceSessionClearKey(*this));
}

void CDMInstanceSessionClearKey::requestLicense(LicenseType, const AtomString& initDataType, Ref<SharedBuffer>&& initData, LicenseCallback&& callback)
Expand Down
Expand Up @@ -262,14 +262,6 @@ MediaPlayerPrivateGStreamer::~MediaPlayerPrivateGStreamer()
if (m_pipeline)
gst_element_set_state(m_pipeline.get(), GST_STATE_NULL);

#if ENABLE(ENCRYPTED_MEDIA)
{
LockHolder lock(m_cdmAttachmentMutex);
if (m_cdmInstance)
m_cdmInstance->releaseDecryptionResources();
}
#endif

m_player = nullptr;
m_notifier->invalidate();
}
Expand Down
Expand Up @@ -215,12 +215,6 @@ bool CDMProxyClearKey::cencDecrypt(CDMProxyClearKey::cencDecryptContext& input)
return input.isSubsampled() ? cencDecryptSubsampled(input) : cencDecryptFullSample(input);
}

void CDMProxyClearKey::releaseDecryptionResources()
{
closeGCryptHandle();
CDMProxy::releaseDecryptionResources();
}

void CDMProxyClearKey::closeGCryptHandle()
{
if (m_gCryptHandle) {
Expand Down
Expand Up @@ -111,7 +111,6 @@ class CDMProxyClearKey final : public CDMProxy, public CanMakeWeakPtr<CDMProxyCl
bool cencDecryptFullSample(cencDecryptContext&);
bool cencDecryptSubsampled(cencDecryptContext&);

void releaseDecryptionResources() final;
void closeGCryptHandle();

// FIXME: It would be nice to use something in WebCore for crypto...
Expand Down
7 changes: 0 additions & 7 deletions Source/WebCore/platform/graphics/gstreamer/eme/CDMThunder.cpp
Expand Up @@ -39,7 +39,6 @@
#include "GStreamerEMEUtilities.h"
#include "Logging.h"
#include "MediaKeyMessageType.h"
#include "MediaKeyStatus.h"
#include "NotImplemented.h"
#include "SharedBuffer.h"
#include "WebKitThunderDecryptorGStreamer.h"
Expand Down Expand Up @@ -328,7 +327,6 @@ RefPtr<CDMInstanceSession> CDMInstanceThunder::createSession()
{
RefPtr<CDMInstanceSessionThunder> newSession = adoptRef(new CDMInstanceSessionThunder(*this));
ASSERT(newSession);
trackSession(*newSession);
return newSession;
}

Expand Down Expand Up @@ -533,7 +531,6 @@ void CDMInstanceSessionThunder::requestLicense(LicenseType licenseType, const At
if (!isValid()) {
GST_WARNING("created invalid session %s", m_sessionID.utf8().data());
callback(initData.releaseNonNull(), m_sessionID, false, Failed);
removeFromInstanceProxy();
return;
}

Expand Down Expand Up @@ -635,8 +632,6 @@ void CDMInstanceSessionThunder::closeSession(const String& sessionID, CloseSessi
if (m_session && !m_sessionID.isEmpty())
opencdm_session_close(m_session.get());

removeFromInstanceProxy();

callback();
}

Expand Down Expand Up @@ -669,8 +664,6 @@ void CDMInstanceSessionThunder::removeSessionData(const String& sessionID, Licen
});
if (!m_session || m_sessionID.isEmpty() || opencdm_session_remove(m_session.get()))
sessionFailure();

removeFromInstanceProxy();
}

void CDMInstanceSessionThunder::storeRecordOfKeyUsage(const String&)
Expand Down
16 changes: 1 addition & 15 deletions Source/WebCore/platform/graphics/gstreamer/eme/CDMThunder.h
Expand Up @@ -36,6 +36,7 @@
#include "CDMPrivate.h"
#include "CDMProxy.h"
#include "GStreamerEMEUtilities.h"
#include "MediaKeyStatus.h"
#include "SharedBuffer.h"
#include <wtf/WeakPtr.h>

Expand Down Expand Up @@ -119,13 +120,6 @@ class CDMInstanceThunder final : public CDMInstanceProxy {

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

void releaseDecryptionResources() final
{
ASSERT(isMainThread());
CDMInstanceProxy::releaseDecryptionResources();
m_thunderSystem.reset(nullptr);
}

private:
Thunder::UniqueThunderSystem m_thunderSystem;
String m_keySystem;
Expand All @@ -147,14 +141,6 @@ class CDMInstanceSessionThunder final : public CDMInstanceSessionProxy {
void setClient(WeakPtr<CDMInstanceSessionClient>&& client) final { m_client = WTFMove(client); }
void clearClient() final { m_client.clear(); }

void releaseDecryptionResources() final
{
ASSERT(isMainThread());
m_keyStore.removeAllKeys();
m_session.reset(nullptr);
CDMInstanceSessionProxy::releaseDecryptionResources();
}

private:
Optional<CDMInstanceThunder&> cdmInstanceThunder() const;

Expand Down

0 comments on commit 7b80605

Please sign in to comment.