From f744c99d0c6f3908753f797c932dee82739be56d Mon Sep 17 00:00:00 2001 From: Chris Pearce Date: Tue, 12 Apr 2016 16:12:21 +1200 Subject: [PATCH] Bug 1245789 - Send name of GMPAdapter over to GMP process in StartPlugin message. r=gerald This lets the GMPChild know whether it needs to instantiate the WidevineAdapter. MozReview-Commit-ID: 5X6IrRZPHdu --- dom/media/gmp/GMPChild.cpp | 8 ++++++-- dom/media/gmp/GMPChild.h | 2 +- dom/media/gmp/GMPParent.cpp | 4 +++- dom/media/gmp/GMPParent.h | 1 + dom/media/gmp/PGMP.ipdl | 2 +- 5 files changed, 12 insertions(+), 5 deletions(-) diff --git a/dom/media/gmp/GMPChild.cpp b/dom/media/gmp/GMPChild.cpp index 60ad6bd48ae0..b3a01629dbff 100644 --- a/dom/media/gmp/GMPChild.cpp +++ b/dom/media/gmp/GMPChild.cpp @@ -21,6 +21,7 @@ #include "mozilla/dom/CrashReporterChild.h" #include "GMPUtils.h" #include "prio.h" +#include "widevine-adapter/WidevineAdapter.h" using mozilla::dom::CrashReporterChild; @@ -345,7 +346,7 @@ GMPChild::GetUTF8LibPath(nsACString& aOutLibPath) } bool -GMPChild::AnswerStartPlugin() +GMPChild::AnswerStartPlugin(const nsString& aAdapter) { LOGD("%s", __FUNCTION__); @@ -378,11 +379,14 @@ GMPChild::AnswerStartPlugin() } #endif + GMPAdapter* adapter = aAdapter.EqualsLiteral("widevine") + ? new WidevineAdapter() : nullptr; if (!mGMPLoader->Load(libPath.get(), libPath.Length(), mNodeId.BeginWriting(), mNodeId.Length(), - platformAPI)) { + platformAPI, + adapter)) { NS_WARNING("Failed to load GMP"); delete platformAPI; return false; diff --git a/dom/media/gmp/GMPChild.h b/dom/media/gmp/GMPChild.h index 9b8f4274ff8b..3be5e93a396f 100644 --- a/dom/media/gmp/GMPChild.h +++ b/dom/media/gmp/GMPChild.h @@ -53,7 +53,7 @@ private: bool GetUTF8LibPath(nsACString& aOutLibPath); bool RecvSetNodeId(const nsCString& aNodeId) override; - bool AnswerStartPlugin() override; + bool AnswerStartPlugin(const nsString& aAdapter) override; bool RecvPreloadLibs(const nsCString& aLibs) override; PCrashReporterChild* AllocPCrashReporterChild(const NativeThreadId& aThread) override; diff --git a/dom/media/gmp/GMPParent.cpp b/dom/media/gmp/GMPParent.cpp index d33e016d20b6..971801056c2b 100644 --- a/dom/media/gmp/GMPParent.cpp +++ b/dom/media/gmp/GMPParent.cpp @@ -95,6 +95,7 @@ GMPParent::CloneFrom(const GMPParent* aOther) for (const GMPCapability& cap : aOther->mCapabilities) { mCapabilities.AppendElement(cap); } + mAdapter = aOther->mAdapter; return NS_OK; } @@ -190,7 +191,7 @@ GMPParent::LoadProcess() #endif // Intr call to block initialization on plugin load. - ok = CallStartPlugin(); + ok = CallStartPlugin(mAdapter); if (!ok) { LOGD("%s: Failed to send start to child process", __FUNCTION__); return NS_ERROR_FAILURE; @@ -941,6 +942,7 @@ GMPParent::ParseChromiumManifest(nsString aJSON) mCapabilities.AppendElement(Move(decrypt)); MOZ_ASSERT(mName.EqualsLiteral("widevinecdm")); + mAdapter = NS_LITERAL_STRING("widevine"); #ifdef XP_WIN mLibs = NS_LITERAL_CSTRING("dxva2.dll"); #endif diff --git a/dom/media/gmp/GMPParent.h b/dom/media/gmp/GMPParent.h index e643cf3f2a8e..9f2535222b89 100644 --- a/dom/media/gmp/GMPParent.h +++ b/dom/media/gmp/GMPParent.h @@ -213,6 +213,7 @@ private: #ifdef XP_WIN nsCString mLibs; #endif + nsString mAdapter; uint32_t mPluginId; nsTArray mCapabilities; GMPProcessParent* mProcess; diff --git a/dom/media/gmp/PGMP.ipdl b/dom/media/gmp/PGMP.ipdl index 695fb5307b06..b421f0280f94 100644 --- a/dom/media/gmp/PGMP.ipdl +++ b/dom/media/gmp/PGMP.ipdl @@ -34,7 +34,7 @@ parent: child: async BeginAsyncShutdown(); async CrashPluginNow(); - intr StartPlugin(); + intr StartPlugin(nsString adapter); async SetNodeId(nsCString nodeId); async PreloadLibs(nsCString libs); async CloseActive();