Bug 1337778 - Use counter for decryptor ID instead of IPDL actor Id. r?gerald
The work I did in
bug 1306314 seems to have either regressed or never worked
properly for multiple CDM same origin processes. I'd guess the decryptor IPDL
protocol actor ID must not be as unique as I thought. So if we just use a
counter managed by the GMPDecrytorChild, we'll get a per CDM unique ID, which
is sufficient.
MozReview-Commit-ID: KSh72ptX5fn
--- a/dom/media/gmp/GMPContentChild.cpp
+++ b/dom/media/gmp/GMPContentChild.cpp
@@ -94,17 +94,17 @@ GMPContentChild::DeallocPGMPVideoEncoder
}
mozilla::ipc::IPCResult
GMPContentChild::RecvPGMPDecryptorConstructor(PGMPDecryptorChild* aActor)
{
GMPDecryptorChild* child = static_cast<GMPDecryptorChild*>(aActor);
void* ptr = nullptr;
- GMPErr err = mGMPChild->GetAPI(GMP_API_DECRYPTOR, nullptr, &ptr, aActor->Id());
+ GMPErr err = mGMPChild->GetAPI(GMP_API_DECRYPTOR, nullptr, &ptr, child->DecryptorId());
if (err != GMPNoErr || !ptr) {
NS_WARNING("GMPGetAPI call failed trying to construct decryptor.");
return IPC_FAIL_NO_REASON(this);
}
child->Init(static_cast<GMPDecryptor*>(ptr));
return IPC_OK();
}
--- a/dom/media/gmp/GMPDecryptorChild.cpp
+++ b/dom/media/gmp/GMPDecryptorChild.cpp
@@ -15,19 +15,22 @@
#define ON_GMP_THREAD() (mPlugin->GMPMessageLoop() == MessageLoop::current())
#define CALL_ON_GMP_THREAD(_func, ...) \
CallOnGMPThread(&GMPDecryptorChild::_func, __VA_ARGS__)
namespace mozilla {
namespace gmp {
+static uint32_t sDecryptorCount = 1;
+
GMPDecryptorChild::GMPDecryptorChild(GMPContentChild* aPlugin)
: mSession(nullptr)
, mPlugin(aPlugin)
+ , mDecryptorId(sDecryptorCount++)
{
MOZ_ASSERT(mPlugin);
}
GMPDecryptorChild::~GMPDecryptorChild()
{
}
@@ -68,17 +71,17 @@ void
GMPDecryptorChild::Init(GMPDecryptor* aSession)
{
MOZ_ASSERT(aSession);
mSession = aSession;
// The ID of this decryptor is the IPDL actor ID. Note it's unique inside
// the child process, but not necessarily across all gecko processes. However,
// since GMPDecryptors are segregated by node ID/origin, we shouldn't end up
// with clashes in the content process.
- SendSetDecryptorId(Id());
+ SendSetDecryptorId(DecryptorId());
}
void
GMPDecryptorChild::SetSessionId(uint32_t aCreateSessionToken,
const char* aSessionId,
uint32_t aSessionIdLength)
{
CALL_ON_GMP_THREAD(SendSetSessionId,
--- a/dom/media/gmp/GMPDecryptorChild.h
+++ b/dom/media/gmp/GMPDecryptorChild.h
@@ -70,16 +70,17 @@ public:
void Decrypted(GMPBuffer* aBuffer, GMPErr aResult) override;
void BatchedKeyStatusChanged(const char* aSessionId,
uint32_t aSessionIdLength,
const GMPMediaKeyInfo* aKeyInfos,
uint32_t aKeyInfosLength) override;
+ uint32_t DecryptorId() const { return mDecryptorId; }
private:
~GMPDecryptorChild();
// GMPDecryptorChild
mozilla::ipc::IPCResult RecvInit(const bool& aDistinctiveIdentifierRequired,
const bool& aPersistentStateRequired) override;
mozilla::ipc::IPCResult RecvCreateSession(const uint32_t& aCreateSessionToken,
@@ -117,14 +118,16 @@ private:
template<typename MethodType, typename... ParamType>
void CallOnGMPThread(MethodType, ParamType&&...);
// GMP's GMPDecryptor implementation.
// Only call into this on the (GMP process) main thread.
GMPDecryptor* mSession;
GMPContentChild* mPlugin;
+
+ const uint32_t mDecryptorId;
};
} // namespace gmp
} // namespace mozilla
#endif // GMPDecryptorChild_h_