RemoteLegacyCDMProxy.cpp [plain text]
#include "config.h"
#include "RemoteLegacyCDMProxy.h"
#if ENABLE(GPU_PROCESS) && ENABLE(LEGACY_ENCRYPTED_MEDIA)
#include "GPUConnectionToWebProcess.h"
#include "RemoteMediaPlayerManagerProxy.h"
#include "RemoteMediaPlayerProxy.h"
namespace WebKit {
using namespace WebCore;
std::unique_ptr<RemoteLegacyCDMProxy> RemoteLegacyCDMProxy::create(WeakPtr<RemoteLegacyCDMFactoryProxy> factory, MediaPlayerPrivateRemoteIdentifier&& playerId, std::unique_ptr<WebCore::LegacyCDM>&& cdm)
{
return std::unique_ptr<RemoteLegacyCDMProxy>(new RemoteLegacyCDMProxy(WTFMove(factory), WTFMove(playerId), WTFMove(cdm)));
}
RemoteLegacyCDMProxy::RemoteLegacyCDMProxy(WeakPtr<RemoteLegacyCDMFactoryProxy>&& factory, MediaPlayerPrivateRemoteIdentifier&& playerId, std::unique_ptr<WebCore::LegacyCDM>&& cdm)
: m_factory(WTFMove(factory))
, m_playerId(WTFMove(playerId))
, m_cdm(WTFMove(cdm))
{
m_cdm->setClient(this);
}
RemoteLegacyCDMProxy::~RemoteLegacyCDMProxy() = default;
void RemoteLegacyCDMProxy::supportsMIMEType(const String& mimeType, SupportsMIMETypeCallback&& callback)
{
if (!m_cdm) {
callback(false);
return;
}
callback(m_cdm->supportsMIMEType(mimeType));
}
void RemoteLegacyCDMProxy::createSession(const String& keySystem, CreateSessionCallback&& callback)
{
if (!m_cdm || !m_factory) {
callback({ });
return;
}
auto identifier = RemoteLegacyCDMSessionIdentifier::generate();
auto session = RemoteLegacyCDMSessionProxy::create(makeWeakPtr(m_factory.get()), identifier, *m_cdm);
m_factory->addSession(identifier, WTFMove(session));
callback(WTFMove(identifier));
}
void RemoteLegacyCDMProxy::setPlayerId(Optional<MediaPlayerPrivateRemoteIdentifier>&& playerId)
{
if (!playerId)
m_playerId = { };
m_playerId = WTFMove(*playerId);
}
RefPtr<MediaPlayer> RemoteLegacyCDMProxy::cdmMediaPlayer(const LegacyCDM*) const
{
if (!m_playerId || !m_factory)
return nullptr;
auto proxy = m_factory->gpuConnectionToWebProcess().remoteMediaPlayerManagerProxy().getProxy(m_playerId);
if (!proxy)
return nullptr;
return proxy->mediaPlayer();
}
}
#endif