Bug 1266336 - Clarify expected usage of CDM wrapper - r=cpearce

Assert that the CDM wrapper is given a non-null CDM pointer.
(so GetCDM() doesn't need to be null-checked.)
Renamed WidevineVideoDecoder mCDM to mCDMWrapper, to avoid (my) confusion.
Assert that WidevineVideoDecoder is given a non-null CDM-wrapper pointer.
Assert that WidevineVideoDecoder only accesses the CDM before DecodingComplete.

Small optimization: Move aCDM into mCDM (to save an AddRef/Release pair).

MozReview-Commit-ID: yKupY067ly

--HG--
extra : rebase_source : 94140b423a04f28368de0831761406c145fad93e
This commit is contained in:
Gerald Squelart 2016-05-06 12:10:59 +10:00
Родитель bb3afc2867
Коммит a2b3ad3b63
3 изменённых файлов: 19 добавлений и 8 удалений

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

@ -48,7 +48,9 @@ public:
CDMWrapper(cdm::ContentDecryptionModule_8* aCDM)
: mCDM(aCDM)
{}
{
MOZ_ASSERT(mCDM);
}
cdm::ContentDecryptionModule_8* GetCDM() const { return mCDM; }
private:
cdm::ContentDecryptionModule_8* mCDM;

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

@ -14,14 +14,17 @@ using namespace cdm;
namespace mozilla {
WidevineVideoDecoder::WidevineVideoDecoder(GMPVideoHost* aVideoHost,
RefPtr<CDMWrapper> aCDM)
RefPtr<CDMWrapper> aCDMWrapper)
: mVideoHost(aVideoHost)
, mCDM(aCDM)
, mCDMWrapper(Move(aCDMWrapper))
, mExtraData(new MediaByteBuffer())
, mSentInput(false)
{
// Expect to start with a CDM wrapper, will release it in DecodingComplete().
MOZ_ASSERT(mCDMWrapper);
Log("WidevineVideoDecoder created this=%p", this);
// Corresponding Release is in DecodingComplete().
AddRef();
}
@ -233,10 +236,11 @@ void
WidevineVideoDecoder::DecodingComplete()
{
Log("WidevineVideoDecoder::DecodingComplete()");
if (mCDM) {
if (mCDMWrapper) {
CDM()->DeinitializeDecoder(kStreamTypeVideo);
mCDM = nullptr;
mCDMWrapper = nullptr;
}
// Release that corresponds to AddRef() in constructor.
Release();
}

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

@ -25,7 +25,7 @@ public:
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(WidevineVideoDecoder)
WidevineVideoDecoder(GMPVideoHost* aVideoHost,
RefPtr<CDMWrapper> aCDM);
RefPtr<CDMWrapper> aCDMWrapper);
void InitDecode(const GMPVideoCodec& aCodecSettings,
const uint8_t* aCodecSpecific,
uint32_t aCodecSpecificLength,
@ -44,12 +44,17 @@ private:
~WidevineVideoDecoder();
cdm::ContentDecryptionModule_8* CDM() { return mCDM->GetCDM(); }
cdm::ContentDecryptionModule_8* CDM() const {
// CDM should only be accessed before 'DecodingComplete'.
MOZ_ASSERT(mCDMWrapper);
// CDMWrapper ensure the CDM is non-null, no need to check again.
return mCDMWrapper->GetCDM();
}
bool ReturnOutput(WidevineVideoFrame& aFrame);
GMPVideoHost* mVideoHost;
RefPtr<CDMWrapper> mCDM;
RefPtr<CDMWrapper> mCDMWrapper;
RefPtr<MediaByteBuffer> mExtraData;
RefPtr<MediaByteBuffer> mAnnexB;
GMPVideoDecoderCallback* mCallback;