Backed out changeset d37e28309560 (bug 1306314)

This commit is contained in:
Iris Hsiao 2016-11-14 11:07:19 +08:00
Родитель cd600c5ab4
Коммит 85b8be1656
3 изменённых файлов: 21 добавлений и 41 удалений

Просмотреть файл

@ -13,11 +13,14 @@
#include "gmp-api/gmp-decryption.h"
#include "gmp-api/gmp-video-codec.h"
#include "gmp-api/gmp-platform.h"
#include "mozilla/StaticPtr.h"
static const GMPPlatformAPI* sPlatform = nullptr;
namespace mozilla {
StaticRefPtr<CDMWrapper> sCDMWrapper;
GMPErr GMPGetCurrentTime(GMPTimestamp* aOutTime) {
return sPlatform->getcurrenttime(aOutTime);
}
@ -88,19 +91,19 @@ WidevineAdapter::GMPGetAPI(const char* aAPIName,
void** aPluginAPI,
uint32_t aDecryptorId)
{
Log("WidevineAdapter::GMPGetAPI(%s, 0x%p, 0x%p, %u) this=0x%p",
aAPIName, aHostAPI, aPluginAPI, this, aDecryptorId);
Log("WidevineAdapter::GMPGetAPI(%s, 0x%p, 0x%p) this=0x%p",
aAPIName, aHostAPI, aPluginAPI, this);
if (!strcmp(aAPIName, GMP_API_DECRYPTOR)) {
if (WidevineDecryptor::GetInstance(aDecryptorId)) {
// We only support one CDM instance per PGMPDecryptor. Fail!
Log("WidevineAdapter::GMPGetAPI() Tried to create more than once CDM per IPDL actor! FAIL!");
if (sCDMWrapper) {
// We only support one CDM instance per GMP process. Fail!
Log("WidevineAdapter::GMPGetAPI() Tried to create more than once CDM per process! FAIL!");
return GMPQuotaExceededErr;
}
auto create = reinterpret_cast<decltype(::CreateCdmInstance)*>(
PR_FindFunctionSymbol(mLib, "CreateCdmInstance"));
if (!create) {
Log("WidevineAdapter::GMPGetAPI(%s, 0x%p, 0x%p, %u) this=0x%p FAILED to find CreateCdmInstance",
aAPIName, aHostAPI, aPluginAPI, this, aDecryptorId);
Log("WidevineAdapter::GMPGetAPI(%s, 0x%p, 0x%p) this=0x%p FAILED to find CreateCdmInstance",
aAPIName, aHostAPI, aPluginAPI, this);
return GMPGenericErr;
}
@ -113,24 +116,24 @@ WidevineAdapter::GMPGetAPI(const char* aAPIName,
&GetCdmHost,
decryptor));
if (!cdm) {
Log("WidevineAdapter::GMPGetAPI(%s, 0x%p, 0x%p, %u) this=0x%p FAILED to create cdm",
aAPIName, aHostAPI, aPluginAPI, this, aDecryptorId);
Log("WidevineAdapter::GMPGetAPI(%s, 0x%p, 0x%p) this=0x%p FAILED to create cdm",
aAPIName, aHostAPI, aPluginAPI, this);
return GMPGenericErr;
}
Log("cdm: 0x%x", cdm);
RefPtr<CDMWrapper> wrapper(new CDMWrapper(cdm));
decryptor->SetCDM(wrapper, aDecryptorId);
sCDMWrapper = new CDMWrapper(cdm);
decryptor->SetCDM(RefPtr<CDMWrapper>(sCDMWrapper));
*aPluginAPI = decryptor;
} else if (!strcmp(aAPIName, GMP_API_VIDEO_DECODER)) {
RefPtr<CDMWrapper> wrapper = WidevineDecryptor::GetInstance(aDecryptorId);
if (!wrapper) {
Log("WidevineAdapter::GMPGetAPI(%s, 0x%p, 0x%p, %u) this=0x%p No cdm for video decoder",
aAPIName, aHostAPI, aPluginAPI, thiss, aDecryptorId);
if (!sCDMWrapper) {
Log("WidevineAdapter::GMPGetAPI(%s, 0x%p, 0x%p) this=0x%p No cdm for video decoder",
aAPIName, aHostAPI, aPluginAPI, this);
return GMPGenericErr;
}
*aPluginAPI = new WidevineVideoDecoder(static_cast<GMPVideoHost*>(aHostAPI),
wrapper);
RefPtr<CDMWrapper>(sCDMWrapper));
}
return *aPluginAPI ? GMPNoErr : GMPNotImplementedErr;
}

Просмотреть файл

@ -16,19 +16,6 @@ using namespace std;
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()
: mCallback(nullptr)
@ -43,11 +30,9 @@ WidevineDecryptor::~WidevineDecryptor()
}
void
WidevineDecryptor::SetCDM(RefPtr<CDMWrapper> aCDM, uint32_t aInstanceId)
WidevineDecryptor::SetCDM(RefPtr<CDMWrapper> aCDM)
{
mCDM = aCDM;
mInstanceId = aInstanceId;
sDecryptors[mInstanceId] = aCDM;
}
void
@ -225,12 +210,7 @@ void
WidevineDecryptor::DecryptingComplete()
{
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;
sDecryptors.erase(mInstanceId);
mCallback = nullptr;
Release();
}

Просмотреть файл

@ -24,9 +24,7 @@ public:
WidevineDecryptor();
void SetCDM(RefPtr<CDMWrapper> aCDM, uint32_t aDecryptorId);
static RefPtr<CDMWrapper> GetInstance(uint32_t aDecryptorId);
void SetCDM(RefPtr<CDMWrapper> aCDM);
// GMPDecryptor
void Init(GMPDecryptorCallback* aCallback,
@ -126,7 +124,6 @@ private:
std::map<uint32_t, uint32_t> mPromiseIdToNewSessionTokens;
bool mDistinctiveIdentifierRequired = false;
bool mPersistentStateRequired = false;
uint32_t mInstanceId = 0;
};
} // namespace mozilla