2014-05-18 07:05:46 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
2015-05-29 05:07:22 +03:00
|
|
|
#include "GMPService.h"
|
2015-02-09 23:54:12 +03:00
|
|
|
#include "GMPServiceParent.h"
|
2015-02-10 13:49:03 +03:00
|
|
|
#include "GMPServiceChild.h"
|
2015-05-29 05:07:22 +03:00
|
|
|
#include "GMPContentParent.h"
|
2014-10-13 02:53:44 +04:00
|
|
|
#include "prio.h"
|
2015-05-19 21:15:34 +03:00
|
|
|
#include "mozilla/Logging.h"
|
2014-05-18 07:05:46 +04:00
|
|
|
#include "GMPParent.h"
|
|
|
|
#include "GMPVideoDecoderParent.h"
|
|
|
|
#include "nsIObserverService.h"
|
|
|
|
#include "GeckoChildProcessHost.h"
|
2014-07-31 01:40:43 +04:00
|
|
|
#include "mozilla/Preferences.h"
|
2014-05-18 07:05:46 +04:00
|
|
|
#include "mozilla/ClearOnShutdown.h"
|
|
|
|
#include "mozilla/SyncRunnable.h"
|
|
|
|
#include "nsXPCOMPrivate.h"
|
|
|
|
#include "mozilla/Services.h"
|
2014-07-10 22:48:11 +04:00
|
|
|
#include "nsNativeCharsetUtils.h"
|
|
|
|
#include "nsIConsoleService.h"
|
2014-07-17 06:59:17 +04:00
|
|
|
#include "mozilla/unused.h"
|
2014-07-28 03:20:34 +04:00
|
|
|
#include "GMPDecryptorParent.h"
|
2014-08-03 01:29:26 +04:00
|
|
|
#include "GMPAudioDecoderParent.h"
|
2014-08-18 01:41:56 +04:00
|
|
|
#include "nsComponentManagerUtils.h"
|
|
|
|
#include "mozilla/Preferences.h"
|
2014-07-28 19:42:55 +04:00
|
|
|
#include "runnable_utils.h"
|
2014-10-13 02:53:43 +04:00
|
|
|
#include "VideoUtils.h"
|
2014-10-01 00:35:21 +04:00
|
|
|
#if defined(XP_LINUX) && defined(MOZ_GMP_SANDBOX)
|
2014-11-25 02:22:13 +03:00
|
|
|
#include "mozilla/SandboxInfo.h"
|
2014-10-01 00:35:21 +04:00
|
|
|
#endif
|
2014-10-13 02:53:44 +04:00
|
|
|
#include "nsAppDirectoryServiceDefs.h"
|
|
|
|
#include "nsDirectoryServiceUtils.h"
|
|
|
|
#include "nsDirectoryServiceDefs.h"
|
|
|
|
#include "nsHashKeys.h"
|
|
|
|
#include "nsIFile.h"
|
2015-01-06 03:00:00 +03:00
|
|
|
#include "nsISimpleEnumerator.h"
|
2014-05-18 07:05:46 +04:00
|
|
|
|
|
|
|
namespace mozilla {
|
2014-07-25 05:47:44 +04:00
|
|
|
|
|
|
|
#ifdef LOG
|
|
|
|
#undef LOG
|
|
|
|
#endif
|
|
|
|
|
|
|
|
PRLogModuleInfo*
|
|
|
|
GetGMPLog()
|
|
|
|
{
|
|
|
|
static PRLogModuleInfo *sLog;
|
|
|
|
if (!sLog)
|
|
|
|
sLog = PR_NewLogModule("GMP");
|
|
|
|
return sLog;
|
|
|
|
}
|
|
|
|
|
2015-06-04 01:25:57 +03:00
|
|
|
#define LOGD(msg) MOZ_LOG(GetGMPLog(), mozilla::LogLevel::Debug, msg)
|
2015-05-21 23:22:04 +03:00
|
|
|
#define LOG(level, msg) MOZ_LOG(GetGMPLog(), (level), msg)
|
2014-07-25 05:47:44 +04:00
|
|
|
|
2014-07-28 19:42:55 +04:00
|
|
|
#ifdef __CLASS__
|
|
|
|
#undef __CLASS__
|
|
|
|
#endif
|
|
|
|
#define __CLASS__ "GMPService"
|
|
|
|
|
2014-05-18 07:05:46 +04:00
|
|
|
namespace gmp {
|
|
|
|
|
|
|
|
static StaticRefPtr<GeckoMediaPluginService> sSingletonService;
|
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
class GMPServiceCreateHelper final : public nsRunnable
|
2014-05-18 07:05:46 +04:00
|
|
|
{
|
|
|
|
nsRefPtr<GeckoMediaPluginService> mService;
|
|
|
|
|
|
|
|
public:
|
|
|
|
static already_AddRefed<GeckoMediaPluginService>
|
|
|
|
GetOrCreate()
|
|
|
|
{
|
|
|
|
nsRefPtr<GeckoMediaPluginService> service;
|
|
|
|
|
|
|
|
if (NS_IsMainThread()) {
|
|
|
|
service = GetOrCreateOnMainThread();
|
|
|
|
} else {
|
|
|
|
nsCOMPtr<nsIThread> mainThread = do_GetMainThread();
|
|
|
|
MOZ_ASSERT(mainThread);
|
|
|
|
|
|
|
|
nsRefPtr<GMPServiceCreateHelper> createHelper = new GMPServiceCreateHelper();
|
|
|
|
|
|
|
|
mozilla::SyncRunnable::DispatchToThread(mainThread, createHelper, true);
|
|
|
|
|
|
|
|
service = createHelper->mService.forget();
|
|
|
|
}
|
|
|
|
|
|
|
|
return service.forget();
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
GMPServiceCreateHelper()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
~GMPServiceCreateHelper()
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(!mService);
|
|
|
|
}
|
|
|
|
|
|
|
|
static already_AddRefed<GeckoMediaPluginService>
|
|
|
|
GetOrCreateOnMainThread()
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(NS_IsMainThread());
|
|
|
|
|
2015-02-09 23:54:12 +03:00
|
|
|
if (!sSingletonService) {
|
2015-02-10 13:49:03 +03:00
|
|
|
if (XRE_GetProcessType() == GeckoProcessType_Default) {
|
|
|
|
nsRefPtr<GeckoMediaPluginServiceParent> service =
|
|
|
|
new GeckoMediaPluginServiceParent();
|
|
|
|
service->Init();
|
|
|
|
sSingletonService = service;
|
|
|
|
} else {
|
|
|
|
nsRefPtr<GeckoMediaPluginServiceChild> service =
|
|
|
|
new GeckoMediaPluginServiceChild();
|
|
|
|
service->Init();
|
|
|
|
sSingletonService = service;
|
|
|
|
}
|
2014-05-18 07:05:46 +04:00
|
|
|
|
|
|
|
ClearOnShutdown(&sSingletonService);
|
|
|
|
}
|
|
|
|
|
2015-02-09 23:54:12 +03:00
|
|
|
nsRefPtr<GeckoMediaPluginService> service = sSingletonService.get();
|
2014-05-18 07:05:46 +04:00
|
|
|
return service.forget();
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHOD
|
|
|
|
Run()
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(NS_IsMainThread());
|
|
|
|
|
|
|
|
mService = GetOrCreateOnMainThread();
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
already_AddRefed<GeckoMediaPluginService>
|
|
|
|
GeckoMediaPluginService::GetGeckoMediaPluginService()
|
|
|
|
{
|
|
|
|
return GMPServiceCreateHelper::GetOrCreate();
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMPL_ISUPPORTS(GeckoMediaPluginService, mozIGeckoMediaPluginService, nsIObserver)
|
|
|
|
|
|
|
|
GeckoMediaPluginService::GeckoMediaPluginService()
|
|
|
|
: mMutex("GeckoMediaPluginService::mMutex")
|
2015-02-09 23:54:12 +03:00
|
|
|
, mGMPThreadShutdown(false)
|
2014-05-18 07:05:46 +04:00
|
|
|
, mShuttingDownOnGMPThread(false)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(NS_IsMainThread());
|
|
|
|
}
|
|
|
|
|
|
|
|
GeckoMediaPluginService::~GeckoMediaPluginService()
|
|
|
|
{
|
2014-10-22 00:45:18 +04:00
|
|
|
}
|
|
|
|
|
2015-03-26 09:55:30 +03:00
|
|
|
void
|
|
|
|
GeckoMediaPluginService::RemoveObsoletePluginCrashCallbacks()
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(NS_IsMainThread());
|
|
|
|
for (size_t i = mPluginCrashCallbacks.Length(); i != 0; --i) {
|
|
|
|
nsRefPtr<PluginCrashCallback>& callback = mPluginCrashCallbacks[i - 1];
|
|
|
|
if (!callback->IsStillValid()) {
|
2015-05-04 22:40:29 +03:00
|
|
|
LOGD(("%s::%s - Removing obsolete callback for pluginId %i",
|
|
|
|
__CLASS__, __FUNCTION__, callback->PluginId()));
|
2015-03-26 09:55:30 +03:00
|
|
|
mPluginCrashCallbacks.RemoveElementAt(i - 1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
GeckoMediaPluginService::AddPluginCrashCallback(
|
|
|
|
nsRefPtr<PluginCrashCallback> aPluginCrashCallback)
|
|
|
|
{
|
|
|
|
RemoveObsoletePluginCrashCallbacks();
|
|
|
|
mPluginCrashCallbacks.AppendElement(aPluginCrashCallback);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2015-05-04 22:40:29 +03:00
|
|
|
GeckoMediaPluginService::RemovePluginCrashCallbacks(const uint32_t aPluginId)
|
2015-03-26 09:55:30 +03:00
|
|
|
{
|
|
|
|
RemoveObsoletePluginCrashCallbacks();
|
|
|
|
for (size_t i = mPluginCrashCallbacks.Length(); i != 0; --i) {
|
|
|
|
nsRefPtr<PluginCrashCallback>& callback = mPluginCrashCallbacks[i - 1];
|
|
|
|
if (callback->PluginId() == aPluginId) {
|
|
|
|
mPluginCrashCallbacks.RemoveElementAt(i - 1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2015-05-04 22:40:29 +03:00
|
|
|
GeckoMediaPluginService::RunPluginCrashCallbacks(const uint32_t aPluginId,
|
|
|
|
const nsACString& aPluginName)
|
2015-03-26 09:55:30 +03:00
|
|
|
{
|
|
|
|
MOZ_ASSERT(NS_IsMainThread());
|
2015-05-04 22:40:29 +03:00
|
|
|
LOGD(("%s::%s(%i)", __CLASS__, __FUNCTION__, aPluginId));
|
2015-03-26 09:55:30 +03:00
|
|
|
for (size_t i = mPluginCrashCallbacks.Length(); i != 0; --i) {
|
|
|
|
nsRefPtr<PluginCrashCallback>& callback = mPluginCrashCallbacks[i - 1];
|
2015-05-04 22:40:29 +03:00
|
|
|
const uint32_t callbackPluginId = callback->PluginId();
|
2015-03-26 09:55:30 +03:00
|
|
|
if (!callback->IsStillValid()) {
|
2015-05-04 22:40:29 +03:00
|
|
|
LOGD(("%s::%s(%i) - Removing obsolete callback for pluginId %i",
|
|
|
|
__CLASS__, __FUNCTION__, aPluginId, callback->PluginId()));
|
2015-03-26 09:55:30 +03:00
|
|
|
mPluginCrashCallbacks.RemoveElementAt(i - 1);
|
|
|
|
} else if (callbackPluginId == aPluginId) {
|
2015-05-04 22:40:29 +03:00
|
|
|
LOGD(("%s::%s(%i) - Running #%u",
|
|
|
|
__CLASS__, __FUNCTION__, aPluginId, i - 1));
|
|
|
|
callback->Run(aPluginName);
|
2015-03-26 09:55:30 +03:00
|
|
|
mPluginCrashCallbacks.RemoveElementAt(i - 1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-10-13 02:53:44 +04:00
|
|
|
nsresult
|
2014-05-18 07:05:46 +04:00
|
|
|
GeckoMediaPluginService::Init()
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(NS_IsMainThread());
|
|
|
|
|
|
|
|
nsCOMPtr<nsIObserverService> obsService = mozilla::services::GetObserverService();
|
|
|
|
MOZ_ASSERT(obsService);
|
|
|
|
MOZ_ALWAYS_TRUE(NS_SUCCEEDED(obsService->AddObserver(this, NS_XPCOM_SHUTDOWN_THREADS_OBSERVER_ID, false)));
|
2015-03-18 21:15:00 +03:00
|
|
|
|
|
|
|
// Kick off scanning for plugins
|
|
|
|
nsCOMPtr<nsIThread> thread;
|
|
|
|
return GetThread(getter_AddRefs(thread));
|
|
|
|
}
|
|
|
|
|
2015-02-09 23:54:12 +03:00
|
|
|
void
|
|
|
|
GeckoMediaPluginService::ShutdownGMPThread()
|
2015-03-18 21:15:00 +03:00
|
|
|
{
|
2015-02-09 23:54:12 +03:00
|
|
|
LOGD(("%s::%s", __CLASS__, __FUNCTION__));
|
|
|
|
nsCOMPtr<nsIThread> gmpThread;
|
|
|
|
{
|
|
|
|
MutexAutoLock lock(mMutex);
|
|
|
|
mGMPThreadShutdown = true;
|
|
|
|
mGMPThread.swap(gmpThread);
|
2014-10-13 02:53:44 +04:00
|
|
|
}
|
|
|
|
|
2015-02-09 23:54:12 +03:00
|
|
|
if (gmpThread) {
|
|
|
|
gmpThread->Shutdown();
|
2014-10-13 02:53:44 +04:00
|
|
|
}
|
2014-05-18 07:05:46 +04:00
|
|
|
}
|
|
|
|
|
2015-01-06 03:00:00 +03:00
|
|
|
nsresult
|
|
|
|
GeckoMediaPluginService::GMPDispatch(nsIRunnable* event, uint32_t flags)
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsIRunnable> r(event);
|
|
|
|
nsCOMPtr<nsIThread> thread;
|
|
|
|
nsresult rv = GetThread(getter_AddRefs(thread));
|
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
return thread->Dispatch(r, flags);
|
|
|
|
}
|
|
|
|
|
2014-07-20 03:14:03 +04:00
|
|
|
// always call with getter_AddRefs, because it does
|
2014-05-18 07:05:46 +04:00
|
|
|
NS_IMETHODIMP
|
|
|
|
GeckoMediaPluginService::GetThread(nsIThread** aThread)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(aThread);
|
|
|
|
|
|
|
|
// This can be called from any thread.
|
|
|
|
MutexAutoLock lock(mMutex);
|
|
|
|
|
|
|
|
if (!mGMPThread) {
|
|
|
|
// Don't allow the thread to be created after shutdown has started.
|
2015-02-09 23:54:12 +03:00
|
|
|
if (mGMPThreadShutdown) {
|
2014-05-18 07:05:46 +04:00
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult rv = NS_NewNamedThread("GMPThread", getter_AddRefs(mGMPThread));
|
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
return rv;
|
|
|
|
}
|
2014-07-10 22:48:11 +04:00
|
|
|
|
|
|
|
// Tell the thread to initialize plugins
|
2015-02-09 23:54:12 +03:00
|
|
|
InitializePlugins();
|
2014-05-18 07:05:46 +04:00
|
|
|
}
|
|
|
|
|
2015-04-19 20:22:35 +03:00
|
|
|
nsCOMPtr<nsIThread> copy = mGMPThread;
|
|
|
|
copy.forget(aThread);
|
2014-05-18 07:05:46 +04:00
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2015-02-10 13:48:42 +03:00
|
|
|
class GetGMPContentParentForAudioDecoderDone : public GetGMPContentParentCallback
|
2015-02-10 13:48:29 +03:00
|
|
|
{
|
|
|
|
public:
|
2015-02-10 13:48:42 +03:00
|
|
|
explicit GetGMPContentParentForAudioDecoderDone(UniquePtr<GetGMPAudioDecoderCallback>&& aCallback)
|
2015-02-10 13:48:29 +03:00
|
|
|
: mCallback(Move(aCallback))
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2015-02-10 13:48:42 +03:00
|
|
|
virtual void Done(GMPContentParent* aGMPParent) override
|
2015-02-10 13:48:29 +03:00
|
|
|
{
|
|
|
|
GMPAudioDecoderParent* gmpADP = nullptr;
|
2015-02-10 13:48:42 +03:00
|
|
|
if (aGMPParent) {
|
|
|
|
aGMPParent->GetGMPAudioDecoder(&gmpADP);
|
|
|
|
}
|
2015-02-10 13:48:29 +03:00
|
|
|
mCallback->Done(gmpADP);
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
UniquePtr<GetGMPAudioDecoderCallback> mCallback;
|
|
|
|
};
|
|
|
|
|
2014-08-03 01:29:26 +04:00
|
|
|
NS_IMETHODIMP
|
|
|
|
GeckoMediaPluginService::GetGMPAudioDecoder(nsTArray<nsCString>* aTags,
|
2014-10-13 02:53:43 +04:00
|
|
|
const nsACString& aNodeId,
|
2015-02-10 13:48:29 +03:00
|
|
|
UniquePtr<GetGMPAudioDecoderCallback>&& aCallback)
|
2014-08-03 01:29:26 +04:00
|
|
|
{
|
|
|
|
MOZ_ASSERT(NS_GetCurrentThread() == mGMPThread);
|
|
|
|
NS_ENSURE_ARG(aTags && aTags->Length() > 0);
|
2015-02-10 13:48:29 +03:00
|
|
|
NS_ENSURE_ARG(aCallback);
|
2014-08-03 01:29:26 +04:00
|
|
|
|
|
|
|
if (mShuttingDownOnGMPThread) {
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
2015-02-10 13:48:42 +03:00
|
|
|
UniquePtr<GetGMPContentParentCallback> callback(
|
|
|
|
new GetGMPContentParentForAudioDecoderDone(Move(aCallback)));
|
|
|
|
if (!GetContentParentFrom(aNodeId, NS_LITERAL_CSTRING(GMP_API_AUDIO_DECODER),
|
|
|
|
*aTags, Move(callback))) {
|
2014-08-03 01:29:26 +04:00
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2015-02-10 13:48:42 +03:00
|
|
|
class GetGMPContentParentForVideoDecoderDone : public GetGMPContentParentCallback
|
2015-02-10 13:48:29 +03:00
|
|
|
{
|
|
|
|
public:
|
2015-02-10 13:48:42 +03:00
|
|
|
explicit GetGMPContentParentForVideoDecoderDone(UniquePtr<GetGMPVideoDecoderCallback>&& aCallback)
|
2015-02-10 13:48:29 +03:00
|
|
|
: mCallback(Move(aCallback))
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2015-02-10 13:48:42 +03:00
|
|
|
virtual void Done(GMPContentParent* aGMPParent) override
|
2015-02-10 13:48:29 +03:00
|
|
|
{
|
|
|
|
GMPVideoDecoderParent* gmpVDP = nullptr;
|
|
|
|
GMPVideoHostImpl* videoHost = nullptr;
|
2015-02-10 13:48:42 +03:00
|
|
|
if (aGMPParent && NS_SUCCEEDED(aGMPParent->GetGMPVideoDecoder(&gmpVDP))) {
|
2015-02-10 13:48:29 +03:00
|
|
|
videoHost = &gmpVDP->Host();
|
|
|
|
}
|
|
|
|
mCallback->Done(gmpVDP, videoHost);
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
UniquePtr<GetGMPVideoDecoderCallback> mCallback;
|
|
|
|
};
|
|
|
|
|
2014-05-18 07:05:46 +04:00
|
|
|
NS_IMETHODIMP
|
2014-06-30 03:02:39 +04:00
|
|
|
GeckoMediaPluginService::GetGMPVideoDecoder(nsTArray<nsCString>* aTags,
|
2014-10-13 02:53:43 +04:00
|
|
|
const nsACString& aNodeId,
|
2015-02-10 13:48:29 +03:00
|
|
|
UniquePtr<GetGMPVideoDecoderCallback>&& aCallback)
|
2014-05-18 07:05:46 +04:00
|
|
|
{
|
|
|
|
MOZ_ASSERT(NS_GetCurrentThread() == mGMPThread);
|
2014-06-30 03:02:39 +04:00
|
|
|
NS_ENSURE_ARG(aTags && aTags->Length() > 0);
|
2015-02-10 13:48:29 +03:00
|
|
|
NS_ENSURE_ARG(aCallback);
|
2014-05-18 07:05:46 +04:00
|
|
|
|
|
|
|
if (mShuttingDownOnGMPThread) {
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
2015-02-10 13:48:42 +03:00
|
|
|
UniquePtr<GetGMPContentParentCallback> callback(
|
|
|
|
new GetGMPContentParentForVideoDecoderDone(Move(aCallback)));
|
|
|
|
if (!GetContentParentFrom(aNodeId, NS_LITERAL_CSTRING(GMP_API_VIDEO_DECODER),
|
|
|
|
*aTags, Move(callback))) {
|
2014-05-18 07:05:46 +04:00
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2015-02-10 13:48:42 +03:00
|
|
|
class GetGMPContentParentForVideoEncoderDone : public GetGMPContentParentCallback
|
2015-02-10 13:48:29 +03:00
|
|
|
{
|
|
|
|
public:
|
2015-02-10 13:48:42 +03:00
|
|
|
explicit GetGMPContentParentForVideoEncoderDone(UniquePtr<GetGMPVideoEncoderCallback>&& aCallback)
|
2015-02-10 13:48:29 +03:00
|
|
|
: mCallback(Move(aCallback))
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2015-02-10 13:48:42 +03:00
|
|
|
virtual void Done(GMPContentParent* aGMPParent) override
|
2015-02-10 13:48:29 +03:00
|
|
|
{
|
|
|
|
GMPVideoEncoderParent* gmpVEP = nullptr;
|
|
|
|
GMPVideoHostImpl* videoHost = nullptr;
|
2015-02-10 13:48:42 +03:00
|
|
|
if (aGMPParent && NS_SUCCEEDED(aGMPParent->GetGMPVideoEncoder(&gmpVEP))) {
|
2015-02-10 13:48:29 +03:00
|
|
|
videoHost = &gmpVEP->Host();
|
|
|
|
}
|
|
|
|
mCallback->Done(gmpVEP, videoHost);
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
UniquePtr<GetGMPVideoEncoderCallback> mCallback;
|
|
|
|
};
|
|
|
|
|
2014-05-18 07:05:46 +04:00
|
|
|
NS_IMETHODIMP
|
2014-06-30 03:02:39 +04:00
|
|
|
GeckoMediaPluginService::GetGMPVideoEncoder(nsTArray<nsCString>* aTags,
|
2014-10-13 02:53:43 +04:00
|
|
|
const nsACString& aNodeId,
|
2015-02-10 13:48:29 +03:00
|
|
|
UniquePtr<GetGMPVideoEncoderCallback>&& aCallback)
|
2014-05-18 07:05:46 +04:00
|
|
|
{
|
|
|
|
MOZ_ASSERT(NS_GetCurrentThread() == mGMPThread);
|
2014-06-30 03:02:39 +04:00
|
|
|
NS_ENSURE_ARG(aTags && aTags->Length() > 0);
|
2015-02-10 13:48:29 +03:00
|
|
|
NS_ENSURE_ARG(aCallback);
|
2014-05-18 07:05:46 +04:00
|
|
|
|
|
|
|
if (mShuttingDownOnGMPThread) {
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
2015-02-10 13:48:42 +03:00
|
|
|
UniquePtr<GetGMPContentParentCallback> callback(
|
|
|
|
new GetGMPContentParentForVideoEncoderDone(Move(aCallback)));
|
|
|
|
if (!GetContentParentFrom(aNodeId, NS_LITERAL_CSTRING(GMP_API_VIDEO_ENCODER),
|
|
|
|
*aTags, Move(callback))) {
|
2014-05-18 07:05:46 +04:00
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2015-02-10 13:48:42 +03:00
|
|
|
class GetGMPContentParentForDecryptorDone : public GetGMPContentParentCallback
|
2015-02-10 13:48:29 +03:00
|
|
|
{
|
|
|
|
public:
|
2015-02-10 13:48:42 +03:00
|
|
|
explicit GetGMPContentParentForDecryptorDone(UniquePtr<GetGMPDecryptorCallback>&& aCallback)
|
2015-02-10 13:48:29 +03:00
|
|
|
: mCallback(Move(aCallback))
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2015-02-10 13:48:42 +03:00
|
|
|
virtual void Done(GMPContentParent* aGMPParent) override
|
2015-02-10 13:48:29 +03:00
|
|
|
{
|
|
|
|
GMPDecryptorParent* ksp = nullptr;
|
2015-02-10 13:48:42 +03:00
|
|
|
if (aGMPParent) {
|
|
|
|
aGMPParent->GetGMPDecryptor(&ksp);
|
|
|
|
}
|
2015-02-10 13:48:29 +03:00
|
|
|
mCallback->Done(ksp);
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
UniquePtr<GetGMPDecryptorCallback> mCallback;
|
|
|
|
};
|
|
|
|
|
2014-07-28 03:20:34 +04:00
|
|
|
NS_IMETHODIMP
|
|
|
|
GeckoMediaPluginService::GetGMPDecryptor(nsTArray<nsCString>* aTags,
|
2014-10-13 02:53:43 +04:00
|
|
|
const nsACString& aNodeId,
|
2015-02-10 13:48:29 +03:00
|
|
|
UniquePtr<GetGMPDecryptorCallback>&& aCallback)
|
2014-07-28 03:20:34 +04:00
|
|
|
{
|
2014-10-01 00:35:21 +04:00
|
|
|
#if defined(XP_LINUX) && defined(MOZ_GMP_SANDBOX)
|
2014-11-25 02:22:13 +03:00
|
|
|
if (!SandboxInfo::Get().CanSandboxMedia()) {
|
2014-10-01 00:35:21 +04:00
|
|
|
NS_WARNING("GeckoMediaPluginService::GetGMPDecryptor: "
|
|
|
|
"EME decryption not available without sandboxing support.");
|
|
|
|
return NS_ERROR_NOT_AVAILABLE;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2014-07-28 03:20:34 +04:00
|
|
|
MOZ_ASSERT(NS_GetCurrentThread() == mGMPThread);
|
|
|
|
NS_ENSURE_ARG(aTags && aTags->Length() > 0);
|
2015-02-10 13:48:29 +03:00
|
|
|
NS_ENSURE_ARG(aCallback);
|
2014-07-28 03:20:34 +04:00
|
|
|
|
|
|
|
if (mShuttingDownOnGMPThread) {
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
2015-02-10 13:48:42 +03:00
|
|
|
UniquePtr<GetGMPContentParentCallback> callback(
|
|
|
|
new GetGMPContentParentForDecryptorDone(Move(aCallback)));
|
|
|
|
if (!GetContentParentFrom(aNodeId, NS_LITERAL_CSTRING(GMP_API_DECRYPTOR),
|
|
|
|
*aTags, Move(callback))) {
|
2014-07-28 03:20:34 +04:00
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2015-02-20 04:37:49 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
GeckoMediaPluginService::HasPluginForAPI(const nsACString& aAPI,
|
|
|
|
nsTArray<nsCString>* aTags,
|
|
|
|
bool* aOutHavePlugin)
|
|
|
|
{
|
2015-02-24 17:03:56 +03:00
|
|
|
nsCString unused;
|
|
|
|
return GetPluginVersionForAPI(aAPI, aTags, aOutHavePlugin, unused);
|
2014-07-17 06:59:17 +04:00
|
|
|
}
|
|
|
|
|
2014-05-18 07:05:46 +04:00
|
|
|
} // namespace gmp
|
|
|
|
} // namespace mozilla
|