Bug 1361900: Part 1 - Make CDMProxy.h compatible with mozilla::Result. r?JamesCheng
MozReview-Commit-ID: DiO7IPFYKbE
--- a/dom/media/eme/CDMProxy.h
+++ b/dom/media/eme/CDMProxy.h
@@ -14,22 +14,26 @@
#include "mozilla/dom/MediaKeys.h"
#include "nsIThread.h"
namespace mozilla {
class MediaRawData;
class ChromiumCDMProxy;
+namespace eme {
enum DecryptStatus {
Ok = 0,
GenericErr = 1,
NoKeyErr = 2,
AbortedErr = 3,
};
+}
+
+using eme::DecryptStatus;
struct DecryptResult {
DecryptResult(DecryptStatus aStatus, MediaRawData* aSample)
: mStatus(aStatus)
, mSample(aSample)
{}
DecryptStatus mStatus;
RefPtr<MediaRawData> mSample;
--- a/dom/media/gmp/ChromiumCDMParent.cpp
+++ b/dom/media/gmp/ChromiumCDMParent.cpp
@@ -13,16 +13,18 @@
#include "content_decryption_module.h"
#include "GMPLog.h"
#include "MediaPrefs.h"
#include "GMPUtils.h"
namespace mozilla {
namespace gmp {
+using namespace eme;
+
ChromiumCDMParent::ChromiumCDMParent(GMPContentParent* aContentParent,
uint32_t aPluginId)
: mPluginId(aPluginId)
, mContentParent(aContentParent)
, mVideoShmemLimit(MediaPrefs::EMEChromiumAPIVideoShmemCount())
{
GMP_LOG(
"ChromiumCDMParent::ChromiumCDMParent(this=%p, contentParent=%p, id=%u)",
--- a/dom/media/gmp/ChromiumCDMProxy.cpp
+++ b/dom/media/gmp/ChromiumCDMProxy.cpp
@@ -7,16 +7,18 @@
#include "ChromiumCDMProxy.h"
#include "mozilla/dom/MediaKeySession.h"
#include "GMPUtils.h"
#include "nsPrintfCString.h"
#include "GMPService.h"
namespace mozilla {
+using namespace eme;
+
ChromiumCDMProxy::ChromiumCDMProxy(dom::MediaKeys* aKeys,
const nsAString& aKeySystem,
GMPCrashHelper* aCrashHelper,
bool aDistinctiveIdentifierRequired,
bool aPersistentStateRequired,
nsIEventTarget* aMainThread)
: CDMProxy(aKeys,
aKeySystem,
--- a/dom/media/gmp/DecryptJob.cpp
+++ b/dom/media/gmp/DecryptJob.cpp
@@ -31,17 +31,17 @@ DecryptJob::PostResult(DecryptStatus aRe
void
DecryptJob::PostResult(DecryptStatus aResult,
Span<const uint8_t> aDecryptedData)
{
if (aDecryptedData.Length() != mSample->Size()) {
NS_WARNING("CDM returned incorrect number of decrypted bytes");
}
- if (aResult == Ok) {
+ if (aResult == eme::Ok) {
UniquePtr<MediaRawDataWriter> writer(mSample->CreateWriter());
PodCopy(writer->Data(),
aDecryptedData.Elements(),
std::min<size_t>(aDecryptedData.Length(), mSample->Size()));
} else if (aResult == NoKeyErr) {
NS_WARNING("CDM returned NoKeyErr");
// We still have the encrypted sample, so we can re-enqueue it to be
// decrypted again once the key is usable again.
--- a/dom/media/gmp/GMPDecryptorParent.cpp
+++ b/dom/media/gmp/GMPDecryptorParent.cpp
@@ -6,16 +6,18 @@
#include "GMPDecryptorParent.h"
#include "GMPContentParent.h"
#include "MediaData.h"
#include "mozilla/SizePrintfMacros.h"
#include "mozilla/Unused.h"
namespace mozilla {
+using namespace eme;
+
#ifdef LOG
#undef LOG
#endif
extern LogModule* GetGMPLog();
#define LOGV(msg) MOZ_LOG(GetGMPLog(), mozilla::LogLevel::Verbose, msg)
#define LOGD(msg) MOZ_LOG(GetGMPLog(), mozilla::LogLevel::Debug, msg)
@@ -395,17 +397,17 @@ GMPDecryptorParent::RecvBatchedKeyStatus
}
return IPC_OK();
}
DecryptStatus
ToDecryptStatus(GMPErr aError)
{
switch (aError) {
- case GMPNoErr: return Ok;
+ case GMPNoErr: return eme::Ok;
case GMPNoKeyErr: return NoKeyErr;
case GMPAbortedErr: return AbortedErr;
default: return GenericErr;
}
}
mozilla::ipc::IPCResult
GMPDecryptorParent::RecvDecrypted(const uint32_t& aId,
--- a/dom/media/platforms/agnostic/eme/EMEDecoderModule.cpp
+++ b/dom/media/platforms/agnostic/eme/EMEDecoderModule.cpp
@@ -19,16 +19,18 @@
#include "mozilla/Unused.h"
#include "nsAutoPtr.h"
#include "nsClassHashtable.h"
#include "nsServiceManagerUtils.h"
#include "DecryptThroughputLimit.h"
namespace mozilla {
+using namespace eme;
+
typedef MozPromiseRequestHolder<DecryptPromise> DecryptPromiseRequestHolder;
extern already_AddRefed<PlatformDecoderModule> CreateBlankDecoderModule();
class EMEDecryptor : public MediaDataDecoder
{
public:
EMEDecryptor(MediaDataDecoder* aDecoder, CDMProxy* aProxy,
TaskQueue* aDecodeTaskQueue, TrackInfo::TrackType aType,
@@ -127,17 +129,17 @@ public:
return;
}
if (aDecrypted.mStatus == NoKeyErr) {
// Key became unusable after we sent the sample to CDM to decrypt.
// Call Decode() again, so that the sample is enqueued for decryption
// if the key becomes usable again.
AttemptDecode(aDecrypted.mSample);
- } else if (aDecrypted.mStatus != Ok) {
+ } else if (aDecrypted.mStatus != eme::Ok) {
mDecodePromise.RejectIfExists(
MediaResult(
NS_ERROR_DOM_MEDIA_FATAL_ERR,
RESULT_DETAIL("decrypted.mStatus=%u", uint32_t(aDecrypted.mStatus))),
__func__);
} else {
MOZ_ASSERT(!mIsShutdown);
// The sample is no longer encrypted, so clear its crypto metadata.