Bug 1060179 - Percolate EME node id to EME child process. r=jesup
--- a/content/media/gmp/GMPChild.cpp
+++ b/content/media/gmp/GMPChild.cpp
@@ -227,26 +227,35 @@ GMPChild::Init(const std::string& aPlugi
if (!Open(aChannel, aParentProcessHandle, aIOLoop)) {
return false;
}
#ifdef MOZ_CRASHREPORTER
SendPCrashReporterConstructor(CrashReporter::CurrentThreadId());
#endif
-#if defined(XP_MACOSX) && defined(MOZ_GMP_SANDBOX)
mPluginPath = aPluginPath;
return true;
-#endif
+}
+bool
+GMPChild::RecvSetNodeId(const nsCString& aNodeId)
+{
+ // TODO: hash mNodeId with machine specific data.
+ mNodeId = std::string(aNodeId.BeginReading(), aNodeId.EndReading());
+ return true;
+}
+
+bool
+GMPChild::RecvStartPlugin()
+{
#if defined(MOZ_SANDBOX) && defined(XP_WIN)
mozilla::SandboxTarget::Instance()->StartSandbox();
#endif
-
- return LoadPluginLibrary(aPluginPath);
+ return LoadPluginLibrary(mPluginPath);
}
bool
GMPChild::LoadPluginLibrary(const std::string& aPluginPath)
{
#if defined(XP_MACOSX) && defined(MOZ_GMP_SANDBOX)
nsAutoCString nativePath;
nativePath.Assign(mPluginBinaryPath);
@@ -394,17 +403,17 @@ GMPChild::DeallocPGMPVideoDecoderChild(P
{
delete aActor;
return true;
}
PGMPDecryptorChild*
GMPChild::AllocPGMPDecryptorChild()
{
- GMPDecryptorChild* actor = new GMPDecryptorChild(this);
+ GMPDecryptorChild* actor = new GMPDecryptorChild(this, mNodeId);
actor->AddRef();
return actor;
}
bool
GMPChild::DeallocPGMPDecryptorChild(PGMPDecryptorChild* aActor)
{
static_cast<GMPDecryptorChild*>(aActor)->Release();
--- a/content/media/gmp/GMPChild.h
+++ b/content/media/gmp/GMPChild.h
@@ -42,16 +42,20 @@ public:
// GMPSharedMem
virtual void CheckThread() MOZ_OVERRIDE;
// GMPAsyncShutdownHost
void ShutdownComplete() MOZ_OVERRIDE;
private:
+
+ virtual bool RecvSetNodeId(const nsCString& aNodeId) MOZ_OVERRIDE;
+ virtual bool RecvStartPlugin() MOZ_OVERRIDE;
+
virtual PCrashReporterChild* AllocPCrashReporterChild(const NativeThreadId& aThread) MOZ_OVERRIDE;
virtual bool DeallocPCrashReporterChild(PCrashReporterChild*) MOZ_OVERRIDE;
virtual PGMPVideoDecoderChild* AllocPGMPVideoDecoderChild() MOZ_OVERRIDE;
virtual bool DeallocPGMPVideoDecoderChild(PGMPVideoDecoderChild* aActor) MOZ_OVERRIDE;
virtual bool RecvPGMPVideoDecoderConstructor(PGMPVideoDecoderChild* aActor) MOZ_OVERRIDE;
virtual PGMPVideoEncoderChild* AllocPGMPVideoEncoderChild() MOZ_OVERRIDE;
@@ -80,18 +84,19 @@ private:
GMPAsyncShutdown* mAsyncShutdown;
nsRefPtr<GMPTimerChild> mTimerChild;
nsRefPtr<GMPStorageChild> mStorage;
PRLibrary* mLib;
GMPGetAPIFunc mGetAPIFunc;
MessageLoop* mGMPMessageLoop;
+ std::string mPluginPath;
#if defined(XP_MACOSX) && defined(MOZ_GMP_SANDBOX)
- std::string mPluginPath;
nsCString mPluginBinaryPath;
#endif
+ std::string mNodeId;
};
} // namespace gmp
} // namespace mozilla
#endif // GMPChild_h_
--- a/content/media/gmp/GMPDecryptorChild.cpp
+++ b/content/media/gmp/GMPDecryptorChild.cpp
@@ -21,19 +21,20 @@
FROM_HERE, NewRunnableMethod(this, &GMPDecryptorChild::_func, __VA_ARGS__) \
); \
} \
} while(false)
namespace mozilla {
namespace gmp {
-GMPDecryptorChild::GMPDecryptorChild(GMPChild* aPlugin)
+GMPDecryptorChild::GMPDecryptorChild(GMPChild* aPlugin, const std::string& aNodeId)
: mSession(nullptr)
, mPlugin(aPlugin)
+ , mNodeId(aNodeId)
{
MOZ_ASSERT(mPlugin);
}
GMPDecryptorChild::~GMPDecryptorChild()
{
}
@@ -171,19 +172,18 @@ GMPDecryptorChild::SetCapabilities(uint6
{
CALL_ON_GMP_THREAD(SendSetCaps, aCaps);
}
void
GMPDecryptorChild::GetNodeId(const char** aOutNodeId,
uint32_t* aOutNodeIdLength)
{
- static const char* id = "placeholder_node_id";
- *aOutNodeId = id;
- *aOutNodeIdLength = strlen(id);
+ *aOutNodeId = mNodeId.c_str();
+ *aOutNodeIdLength = mNodeId.size();
}
void
GMPDecryptorChild::GetSandboxVoucher(const uint8_t** aVoucher,
uint8_t* aVoucherLength)
{
const char* voucher = "placeholder_sandbox_voucher.";
*aVoucher = (uint8_t*)voucher;
--- a/content/media/gmp/GMPDecryptorChild.h
+++ b/content/media/gmp/GMPDecryptorChild.h
@@ -5,30 +5,31 @@
#ifndef GMPDecryptorChild_h_
#define GMPDecryptorChild_h_
#include "mozilla/gmp/PGMPDecryptorChild.h"
#include "gmp-decryption.h"
#include "mozilla/gmp/GMPTypes.h"
#include "GMPEncryptedBufferDataImpl.h"
+#include <string>
namespace mozilla {
namespace gmp {
class GMPChild;
class GMPDecryptorChild : public GMPDecryptorCallback
, public GMPDecryptorHost
, public PGMPDecryptorChild
{
public:
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(GMPDecryptorChild);
- explicit GMPDecryptorChild(GMPChild* aPlugin);
+ explicit GMPDecryptorChild(GMPChild* aPlugin, const std::string& aNodeId);
void Init(GMPDecryptor* aSession);
// GMPDecryptorCallback
virtual void ResolveNewSessionPromise(uint32_t aPromiseId,
const char* aSessionId,
uint32_t aSessionIdLength) MOZ_OVERRIDE;
virtual void ResolveLoadSessionPromise(uint32_t aPromiseId,
@@ -117,14 +118,16 @@ private:
const nsTArray<uint8_t>& aServerCert) MOZ_OVERRIDE;
virtual bool RecvDecryptingComplete() MOZ_OVERRIDE;
// GMP's GMPDecryptor implementation.
// Only call into this on the (GMP process) main thread.
GMPDecryptor* mSession;
GMPChild* mPlugin;
+
+ const std::string mNodeId;
};
} // namespace gmp
} // namespace mozilla
#endif // GMPDecryptorChild_h_
--- a/content/media/gmp/GMPParent.cpp
+++ b/content/media/gmp/GMPParent.cpp
@@ -145,16 +145,32 @@ GMPParent::LoadProcess()
bool opened = Open(mProcess->GetChannel(), mProcess->GetChildProcessHandle());
if (!opened) {
mProcess->Delete();
mProcess = nullptr;
return NS_ERROR_FAILURE;
}
LOGD(("%s::%s: Created new process %p", __CLASS__, __FUNCTION__, (void *)mProcess));
+
+ bool ok = SendSetNodeId(mNodeId);
+ if (!ok) {
+ mProcess->Delete();
+ mProcess = nullptr;
+ return NS_ERROR_FAILURE;
+ }
+ LOGD(("%s::%s: Failed to send node id %p", __CLASS__, __FUNCTION__, (void *)mProcess));
+
+ ok = SendStartPlugin();
+ if (!ok) {
+ mProcess->Delete();
+ mProcess = nullptr;
+ return NS_ERROR_FAILURE;
+ }
+ LOGD(("%s::%s: Failed to send start %p", __CLASS__, __FUNCTION__, (void *)mProcess));
}
mState = GMPStateLoaded;
return NS_OK;
}
void
--- a/content/media/gmp/PGMP.ipdl
+++ b/content/media/gmp/PGMP.ipdl
@@ -35,14 +35,16 @@ parent:
async AsyncShutdownRequired();
child:
async PGMPAudioDecoder();
async PGMPDecryptor();
async PGMPVideoDecoder();
async PGMPVideoEncoder();
+ async SetNodeId(nsCString nodeId);
+ async StartPlugin();
async BeginAsyncShutdown();
async CrashPluginNow();
};
} // namespace gmp
} // namespace mozilla