зеркало из https://github.com/mozilla/gecko-dev.git
Backed out changeset d37e28309560 (bug 1306314)
This commit is contained in:
Родитель
cd600c5ab4
Коммит
85b8be1656
|
@ -13,11 +13,14 @@
|
||||||
#include "gmp-api/gmp-decryption.h"
|
#include "gmp-api/gmp-decryption.h"
|
||||||
#include "gmp-api/gmp-video-codec.h"
|
#include "gmp-api/gmp-video-codec.h"
|
||||||
#include "gmp-api/gmp-platform.h"
|
#include "gmp-api/gmp-platform.h"
|
||||||
|
#include "mozilla/StaticPtr.h"
|
||||||
|
|
||||||
static const GMPPlatformAPI* sPlatform = nullptr;
|
static const GMPPlatformAPI* sPlatform = nullptr;
|
||||||
|
|
||||||
namespace mozilla {
|
namespace mozilla {
|
||||||
|
|
||||||
|
StaticRefPtr<CDMWrapper> sCDMWrapper;
|
||||||
|
|
||||||
GMPErr GMPGetCurrentTime(GMPTimestamp* aOutTime) {
|
GMPErr GMPGetCurrentTime(GMPTimestamp* aOutTime) {
|
||||||
return sPlatform->getcurrenttime(aOutTime);
|
return sPlatform->getcurrenttime(aOutTime);
|
||||||
}
|
}
|
||||||
|
@ -88,19 +91,19 @@ WidevineAdapter::GMPGetAPI(const char* aAPIName,
|
||||||
void** aPluginAPI,
|
void** aPluginAPI,
|
||||||
uint32_t aDecryptorId)
|
uint32_t aDecryptorId)
|
||||||
{
|
{
|
||||||
Log("WidevineAdapter::GMPGetAPI(%s, 0x%p, 0x%p, %u) this=0x%p",
|
Log("WidevineAdapter::GMPGetAPI(%s, 0x%p, 0x%p) this=0x%p",
|
||||||
aAPIName, aHostAPI, aPluginAPI, this, aDecryptorId);
|
aAPIName, aHostAPI, aPluginAPI, this);
|
||||||
if (!strcmp(aAPIName, GMP_API_DECRYPTOR)) {
|
if (!strcmp(aAPIName, GMP_API_DECRYPTOR)) {
|
||||||
if (WidevineDecryptor::GetInstance(aDecryptorId)) {
|
if (sCDMWrapper) {
|
||||||
// We only support one CDM instance per PGMPDecryptor. Fail!
|
// We only support one CDM instance per GMP process. Fail!
|
||||||
Log("WidevineAdapter::GMPGetAPI() Tried to create more than once CDM per IPDL actor! FAIL!");
|
Log("WidevineAdapter::GMPGetAPI() Tried to create more than once CDM per process! FAIL!");
|
||||||
return GMPQuotaExceededErr;
|
return GMPQuotaExceededErr;
|
||||||
}
|
}
|
||||||
auto create = reinterpret_cast<decltype(::CreateCdmInstance)*>(
|
auto create = reinterpret_cast<decltype(::CreateCdmInstance)*>(
|
||||||
PR_FindFunctionSymbol(mLib, "CreateCdmInstance"));
|
PR_FindFunctionSymbol(mLib, "CreateCdmInstance"));
|
||||||
if (!create) {
|
if (!create) {
|
||||||
Log("WidevineAdapter::GMPGetAPI(%s, 0x%p, 0x%p, %u) this=0x%p FAILED to find CreateCdmInstance",
|
Log("WidevineAdapter::GMPGetAPI(%s, 0x%p, 0x%p) this=0x%p FAILED to find CreateCdmInstance",
|
||||||
aAPIName, aHostAPI, aPluginAPI, this, aDecryptorId);
|
aAPIName, aHostAPI, aPluginAPI, this);
|
||||||
return GMPGenericErr;
|
return GMPGenericErr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -113,24 +116,24 @@ WidevineAdapter::GMPGetAPI(const char* aAPIName,
|
||||||
&GetCdmHost,
|
&GetCdmHost,
|
||||||
decryptor));
|
decryptor));
|
||||||
if (!cdm) {
|
if (!cdm) {
|
||||||
Log("WidevineAdapter::GMPGetAPI(%s, 0x%p, 0x%p, %u) this=0x%p FAILED to create cdm",
|
Log("WidevineAdapter::GMPGetAPI(%s, 0x%p, 0x%p) this=0x%p FAILED to create cdm",
|
||||||
aAPIName, aHostAPI, aPluginAPI, this, aDecryptorId);
|
aAPIName, aHostAPI, aPluginAPI, this);
|
||||||
return GMPGenericErr;
|
return GMPGenericErr;
|
||||||
}
|
}
|
||||||
Log("cdm: 0x%x", cdm);
|
Log("cdm: 0x%x", cdm);
|
||||||
RefPtr<CDMWrapper> wrapper(new CDMWrapper(cdm));
|
sCDMWrapper = new CDMWrapper(cdm);
|
||||||
decryptor->SetCDM(wrapper, aDecryptorId);
|
decryptor->SetCDM(RefPtr<CDMWrapper>(sCDMWrapper));
|
||||||
*aPluginAPI = decryptor;
|
*aPluginAPI = decryptor;
|
||||||
|
|
||||||
} else if (!strcmp(aAPIName, GMP_API_VIDEO_DECODER)) {
|
} else if (!strcmp(aAPIName, GMP_API_VIDEO_DECODER)) {
|
||||||
RefPtr<CDMWrapper> wrapper = WidevineDecryptor::GetInstance(aDecryptorId);
|
if (!sCDMWrapper) {
|
||||||
if (!wrapper) {
|
Log("WidevineAdapter::GMPGetAPI(%s, 0x%p, 0x%p) this=0x%p No cdm for video decoder",
|
||||||
Log("WidevineAdapter::GMPGetAPI(%s, 0x%p, 0x%p, %u) this=0x%p No cdm for video decoder",
|
aAPIName, aHostAPI, aPluginAPI, this);
|
||||||
aAPIName, aHostAPI, aPluginAPI, thiss, aDecryptorId);
|
|
||||||
return GMPGenericErr;
|
return GMPGenericErr;
|
||||||
}
|
}
|
||||||
*aPluginAPI = new WidevineVideoDecoder(static_cast<GMPVideoHost*>(aHostAPI),
|
*aPluginAPI = new WidevineVideoDecoder(static_cast<GMPVideoHost*>(aHostAPI),
|
||||||
wrapper);
|
RefPtr<CDMWrapper>(sCDMWrapper));
|
||||||
|
|
||||||
}
|
}
|
||||||
return *aPluginAPI ? GMPNoErr : GMPNotImplementedErr;
|
return *aPluginAPI ? GMPNoErr : GMPNotImplementedErr;
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,19 +16,6 @@ using namespace std;
|
||||||
|
|
||||||
namespace mozilla {
|
namespace mozilla {
|
||||||
|
|
||||||
static map<uint32_t, RefPtr<CDMWrapper>> sDecryptors;
|
|
||||||
|
|
||||||
/* static */
|
|
||||||
RefPtr<CDMWrapper>
|
|
||||||
WidevineDecryptor::GetInstance(uint32_t aInstanceId)
|
|
||||||
{
|
|
||||||
auto itr = sDecryptors.find(aInstanceId);
|
|
||||||
if (itr != sDecryptors.end()) {
|
|
||||||
return itr->second;
|
|
||||||
}
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
WidevineDecryptor::WidevineDecryptor()
|
WidevineDecryptor::WidevineDecryptor()
|
||||||
: mCallback(nullptr)
|
: mCallback(nullptr)
|
||||||
|
@ -43,11 +30,9 @@ WidevineDecryptor::~WidevineDecryptor()
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
WidevineDecryptor::SetCDM(RefPtr<CDMWrapper> aCDM, uint32_t aInstanceId)
|
WidevineDecryptor::SetCDM(RefPtr<CDMWrapper> aCDM)
|
||||||
{
|
{
|
||||||
mCDM = aCDM;
|
mCDM = aCDM;
|
||||||
mInstanceId = aInstanceId;
|
|
||||||
sDecryptors[mInstanceId] = aCDM;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -225,12 +210,7 @@ void
|
||||||
WidevineDecryptor::DecryptingComplete()
|
WidevineDecryptor::DecryptingComplete()
|
||||||
{
|
{
|
||||||
Log("WidevineDecryptor::DecryptingComplete() this=%p", this);
|
Log("WidevineDecryptor::DecryptingComplete() this=%p", this);
|
||||||
// Drop our references to the CDMWrapper. When any other references
|
|
||||||
// held elsewhere are dropped (for example references held by a
|
|
||||||
// WidevineVideoDecoder, or a runnable), the CDMWrapper destroys
|
|
||||||
// the CDM.
|
|
||||||
mCDM = nullptr;
|
mCDM = nullptr;
|
||||||
sDecryptors.erase(mInstanceId);
|
|
||||||
mCallback = nullptr;
|
mCallback = nullptr;
|
||||||
Release();
|
Release();
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,9 +24,7 @@ public:
|
||||||
|
|
||||||
WidevineDecryptor();
|
WidevineDecryptor();
|
||||||
|
|
||||||
void SetCDM(RefPtr<CDMWrapper> aCDM, uint32_t aDecryptorId);
|
void SetCDM(RefPtr<CDMWrapper> aCDM);
|
||||||
|
|
||||||
static RefPtr<CDMWrapper> GetInstance(uint32_t aDecryptorId);
|
|
||||||
|
|
||||||
// GMPDecryptor
|
// GMPDecryptor
|
||||||
void Init(GMPDecryptorCallback* aCallback,
|
void Init(GMPDecryptorCallback* aCallback,
|
||||||
|
@ -126,7 +124,6 @@ private:
|
||||||
std::map<uint32_t, uint32_t> mPromiseIdToNewSessionTokens;
|
std::map<uint32_t, uint32_t> mPromiseIdToNewSessionTokens;
|
||||||
bool mDistinctiveIdentifierRequired = false;
|
bool mDistinctiveIdentifierRequired = false;
|
||||||
bool mPersistentStateRequired = false;
|
bool mPersistentStateRequired = false;
|
||||||
uint32_t mInstanceId = 0;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace mozilla
|
} // namespace mozilla
|
||||||
|
|
Загрузка…
Ссылка в новой задаче