bool GMPChild::AnswerStartPlugin() { LOGD("%s", __FUNCTION__); #if defined(XP_WIN) PreLoadLibraries(mPluginPath); #endif if (!PreLoadPluginVoucher()) { NS_WARNING("Plugin voucher failed to load!"); return false; } PreLoadSandboxVoucher(); nsCString libPath; if (!GetUTF8LibPath(libPath)) { return false; } auto platformAPI = new GMPPlatformAPI(); InitPlatformAPI(*platformAPI, this); mGMPLoader = GMPProcessChild::GetGMPLoader(); if (!mGMPLoader) { NS_WARNING("Failed to get GMPLoader"); delete platformAPI; return false; } #if defined(MOZ_GMP_SANDBOX) && defined(XP_MACOSX) if (!SetMacSandboxInfo()) { NS_WARNING("Failed to set Mac GMP sandbox info"); delete platformAPI; return false; } #endif if (!mGMPLoader->Load(libPath.get(), libPath.Length(), mNodeId.BeginWriting(), mNodeId.Length(), platformAPI)) { NS_WARNING("Failed to load GMP"); delete platformAPI; return false; } void* sh = nullptr; GMPAsyncShutdownHost* host = static_cast<GMPAsyncShutdownHost*>(this); GMPErr err = GetAPI(GMP_API_ASYNC_SHUTDOWN, host, &sh); if (err == GMPNoErr && sh) { mAsyncShutdown = reinterpret_cast<GMPAsyncShutdown*>(sh); SendAsyncShutdownRequired(); } return true; }
mozilla::ipc::IPCResult GMPChild::AnswerStartPlugin(const nsString& aAdapter) { LOGD("%s", __FUNCTION__); nsCString libPath; if (!GetUTF8LibPath(libPath)) { return IPC_FAIL_NO_REASON(this); } auto platformAPI = new GMPPlatformAPI(); InitPlatformAPI(*platformAPI, this); mGMPLoader = MakeUnique<GMPLoader>(); #if defined(MOZ_GMP_SANDBOX) if (!mGMPLoader->CanSandbox()) { LOGD("%s Can't sandbox GMP, failing", __FUNCTION__); delete platformAPI; return IPC_FAIL_NO_REASON(this); } #endif bool isWidevine = aAdapter.EqualsLiteral("widevine"); bool isChromium = aAdapter.EqualsLiteral("chromium"); #if defined(MOZ_GMP_SANDBOX) && defined(XP_MACOSX) MacSandboxPluginType pluginType = MacSandboxPluginType_GMPlugin_Default; if (isWidevine || isChromium) { pluginType = MacSandboxPluginType_GMPlugin_EME_Widevine; } if (!SetMacSandboxInfo(pluginType)) { NS_WARNING("Failed to set Mac GMP sandbox info"); delete platformAPI; return IPC_FAIL_NO_REASON(this); } #endif GMPAdapter* adapter = nullptr; if (isWidevine) { adapter = new WidevineAdapter(); } else if (isChromium) { adapter = new ChromiumCDMAdapter(); } if (!mGMPLoader->Load(libPath.get(), libPath.Length(), platformAPI, adapter)) { NS_WARNING("Failed to load GMP"); delete platformAPI; return IPC_FAIL_NO_REASON(this); } return IPC_OK(); }
mozilla::ipc::IPCResult GMPChild::AnswerStartPlugin(const nsString& aAdapter) { LOGD("%s", __FUNCTION__); nsCString libPath; if (!GetUTF8LibPath(libPath)) { return IPC_FAIL_NO_REASON(this); } auto platformAPI = new GMPPlatformAPI(); InitPlatformAPI(*platformAPI, this); mGMPLoader = GMPProcessChild::GetGMPLoader(); if (!mGMPLoader) { NS_WARNING("Failed to get GMPLoader"); delete platformAPI; return IPC_FAIL_NO_REASON(this); } bool isWidevine = aAdapter.EqualsLiteral("widevine"); #if defined(MOZ_GMP_SANDBOX) && defined(XP_MACOSX) MacSandboxPluginType pluginType = MacSandboxPluginType_GMPlugin_Default; if (isWidevine) { pluginType = MacSandboxPluginType_GMPlugin_EME_Widevine; } if (!SetMacSandboxInfo(pluginType)) { NS_WARNING("Failed to set Mac GMP sandbox info"); delete platformAPI; return IPC_FAIL_NO_REASON(this); } #endif GMPAdapter* adapter = (isWidevine) ? new WidevineAdapter() : nullptr; if (!mGMPLoader->Load(libPath.get(), libPath.Length(), mNodeId.BeginWriting(), mNodeId.Length(), platformAPI, adapter)) { NS_WARNING("Failed to load GMP"); delete platformAPI; return IPC_FAIL_NO_REASON(this); } return IPC_OK(); }
bool GMPChild::AnswerStartPlugin(const nsString& aAdapter) { LOGD("%s", __FUNCTION__); if (!PreLoadPluginVoucher()) { NS_WARNING("Plugin voucher failed to load!"); return false; } PreLoadSandboxVoucher(); nsCString libPath; if (!GetUTF8LibPath(libPath)) { return false; } auto platformAPI = new GMPPlatformAPI(); InitPlatformAPI(*platformAPI, this); mGMPLoader = GMPProcessChild::GetGMPLoader(); if (!mGMPLoader) { NS_WARNING("Failed to get GMPLoader"); delete platformAPI; return false; } bool isWidevine = aAdapter.EqualsLiteral("widevine"); #if defined(MOZ_GMP_SANDBOX) && defined(XP_MACOSX) MacSandboxPluginType pluginType = MacSandboxPluginType_GMPlugin_Default; if (isWidevine) { pluginType = MacSandboxPluginType_GMPlugin_EME_Widevine; } if (!SetMacSandboxInfo(pluginType)) { NS_WARNING("Failed to set Mac GMP sandbox info"); delete platformAPI; return false; } #endif GMPAdapter* adapter = (isWidevine) ? new WidevineAdapter() : nullptr; if (!mGMPLoader->Load(libPath.get(), libPath.Length(), mNodeId.BeginWriting(), mNodeId.Length(), platformAPI, adapter)) { NS_WARNING("Failed to load GMP"); delete platformAPI; return false; } void* sh = nullptr; GMPAsyncShutdownHost* host = static_cast<GMPAsyncShutdownHost*>(this); GMPErr err = GetAPI(GMP_API_ASYNC_SHUTDOWN, host, &sh); if (err == GMPNoErr && sh) { mAsyncShutdown = reinterpret_cast<GMPAsyncShutdown*>(sh); SendAsyncShutdownRequired(); } return true; }