зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1681043 - P3. Retrieve decoding capabilities in GPU or RDD process and pass it to content. r=alwu,bryce
Upon starting the RDD and GPU process; we check their decoding capabilities and send it to the parent process. It will then broadcast this information to all content children so that RemodeDecoderModule::Supports can return if a codec is supported or not. Differential Revision: https://phabricator.services.mozilla.com/D100306
This commit is contained in:
Родитель
1781f8be7f
Коммит
ff614fdaa3
|
@ -1323,7 +1323,6 @@ void ContentChild::InitXPCOM(
|
|||
|
||||
DataStorage::SetCachedStorageEntries(aXPCOMInit.dataStorage());
|
||||
|
||||
PDMFactory::SetSupported(aXPCOMInit.codecsSupported());
|
||||
// Initialize the RemoteDecoderManager thread and its associated PBackground
|
||||
// channel.
|
||||
RemoteDecoderManagerChild::Init();
|
||||
|
@ -4453,6 +4452,14 @@ IPCResult ContentChild::RecvFlushFOGData(FlushFOGDataResolver&& aResolver) {
|
|||
return IPC_OK();
|
||||
}
|
||||
|
||||
IPCResult ContentChild::RecvUpdateMediaCodecsSupported(
|
||||
RemoteDecodeIn aLocation,
|
||||
const PDMFactory::MediaCodecsSupported& aSupported) {
|
||||
RemoteDecoderManagerChild::SetSupported(aLocation, aSupported);
|
||||
|
||||
return IPC_OK();
|
||||
}
|
||||
|
||||
} // namespace dom
|
||||
|
||||
#if defined(__OpenBSD__) && defined(MOZ_SANDBOX)
|
||||
|
|
|
@ -837,6 +837,10 @@ class ContentChild final : public PContentChild,
|
|||
private:
|
||||
mozilla::ipc::IPCResult RecvFlushFOGData(FlushFOGDataResolver&& aResolver);
|
||||
|
||||
mozilla::ipc::IPCResult RecvUpdateMediaCodecsSupported(
|
||||
RemoteDecodeIn aLocation,
|
||||
const PDMFactory::MediaCodecsSupported& aSupported);
|
||||
|
||||
#ifdef NIGHTLY_BUILD
|
||||
virtual PContentChild::Result OnMessageReceived(const Message& aMsg) override;
|
||||
#else
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
# include "mozilla/a11y/AccessibleWrap.h"
|
||||
# include "mozilla/a11y/Compatibility.h"
|
||||
#endif
|
||||
#include <map>
|
||||
#include <utility>
|
||||
|
||||
#include "BrowserParent.h"
|
||||
|
@ -37,7 +38,6 @@
|
|||
#include "Geolocation.h"
|
||||
#include "GfxInfoBase.h"
|
||||
#include "MMPrinter.h"
|
||||
#include "PDMFactory.h"
|
||||
#include "PreallocatedProcessManager.h"
|
||||
#include "ProcessPriorityManager.h"
|
||||
#include "SandboxHal.h"
|
||||
|
@ -368,6 +368,9 @@ namespace dom {
|
|||
|
||||
LazyLogModule gProcessLog("Process");
|
||||
|
||||
static std::map<RemoteDecodeIn, PDMFactory::MediaCodecsSupported>
|
||||
sCodecsSupported;
|
||||
|
||||
/* static */
|
||||
LogModule* ContentParent::GetLog() { return gProcessLog; }
|
||||
|
||||
|
@ -1502,6 +1505,16 @@ void ContentParent::BroadcastThemeUpdate(widget::ThemeChangeKind aKind) {
|
|||
}
|
||||
}
|
||||
|
||||
/*static */
|
||||
void ContentParent::BroadcastMediaCodecsSupportedUpdate(
|
||||
RemoteDecodeIn aLocation,
|
||||
const PDMFactory::MediaCodecsSupported& aSupported) {
|
||||
sCodecsSupported[aLocation] = aSupported;
|
||||
for (auto* cp : AllProcesses(eAll)) {
|
||||
Unused << cp->SendUpdateMediaCodecsSupported(aLocation, aSupported);
|
||||
}
|
||||
}
|
||||
|
||||
const nsACString& ContentParent::GetRemoteType() const { return mRemoteType; }
|
||||
|
||||
void ContentParent::Init() {
|
||||
|
@ -2789,9 +2802,9 @@ bool ContentParent::InitInternal(ProcessPriority aInitialPriority) {
|
|||
// Send the dynamic scalar definitions to the new process.
|
||||
TelemetryIPC::GetDynamicScalarDefinitions(xpcomInit.dynamicScalarDefs());
|
||||
|
||||
// Pre-calculate the various PlatformDecoderModule (PDM) supported on this
|
||||
// machine.
|
||||
xpcomInit.codecsSupported() = PDMFactory::Supported();
|
||||
for (auto const& [location, supported] : sCodecsSupported) {
|
||||
Unused << SendUpdateMediaCodecsSupported(location, supported);
|
||||
}
|
||||
|
||||
// Must send screen info before send initialData
|
||||
ScreenManager& screenManager = ScreenManager::GetSingleton();
|
||||
|
|
|
@ -257,6 +257,10 @@ class ContentParent final
|
|||
|
||||
static void BroadcastThemeUpdate(widget::ThemeChangeKind);
|
||||
|
||||
static void BroadcastMediaCodecsSupportedUpdate(
|
||||
RemoteDecodeIn aLocation,
|
||||
const PDMFactory::MediaCodecsSupported& aSupported);
|
||||
|
||||
const nsACString& GetRemoteType() const override;
|
||||
|
||||
virtual void DoGetRemoteType(nsACString& aRemoteType,
|
||||
|
|
|
@ -146,6 +146,7 @@ using class mozilla::dom::SessionHistoryInfo from "mozilla/dom/SessionHistoryEnt
|
|||
using struct nsPoint from "nsPoint.h";
|
||||
using struct mozilla::dom::LoadingSessionHistoryInfo from "mozilla/dom/SessionHistoryEntry.h";
|
||||
using mozilla::PDMFactory::MediaCodecsSupported from "PDMFactory.h";
|
||||
using mozilla::RemoteDecodeIn from "mozilla/RemoteDecoderManagerChild.h";
|
||||
using mozilla::dom::PerformanceTimingData from "mozilla/dom/PerformanceTiming.h";
|
||||
|
||||
union ChromeRegistryItem
|
||||
|
@ -327,7 +328,6 @@ struct XPCOMInitData
|
|||
nsCString[] requestedLocales;
|
||||
DynamicScalarDefinition[] dynamicScalarDefs;
|
||||
SystemParameterKVPair[] systemParameters;
|
||||
MediaCodecsSupported codecsSupported;
|
||||
};
|
||||
|
||||
struct VisitedQueryResult
|
||||
|
@ -947,6 +947,9 @@ child:
|
|||
async DispatchBeforeUnloadToSubtree(MaybeDiscardedBrowsingContext aStartingAt)
|
||||
returns (PermitUnloadResult result);
|
||||
|
||||
// Update the cached list of codec supported in the given process.
|
||||
async UpdateMediaCodecsSupported(RemoteDecodeIn aLocation, MediaCodecsSupported aSupported);
|
||||
|
||||
parent:
|
||||
/**
|
||||
* This is a temporary way to pass index and length through parent process.
|
||||
|
|
|
@ -15,6 +15,7 @@ using mozilla::dom::NativeThreadId from "mozilla/dom/NativeThreadId.h";
|
|||
using moveonly mozilla::UntrustedModulesData from "mozilla/UntrustedModulesData.h";
|
||||
using moveonly mozilla::ModulePaths from "mozilla/UntrustedModulesData.h";
|
||||
using moveonly mozilla::ModulesMapResult from "mozilla/UntrustedModulesData.h";
|
||||
using mozilla::PDMFactory::MediaCodecsSupported from "PDMFactory.h";
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
|
@ -58,6 +59,10 @@ child:
|
|||
|
||||
async GetModulesTrust(ModulePaths aModPaths, bool aRunAtNormalPriority)
|
||||
returns (ModulesMapResult? modMapResult);
|
||||
|
||||
// Update the cached list of codec supported following a check in the
|
||||
// RDD parent.
|
||||
async UpdateMediaCodecsSupported(MediaCodecsSupported aSupported);
|
||||
};
|
||||
|
||||
} // namespace mozilla
|
||||
|
|
|
@ -6,11 +6,12 @@
|
|||
#include "RDDChild.h"
|
||||
|
||||
#include "mozilla/RDDProcessManager.h"
|
||||
#include "mozilla/dom/ContentParent.h"
|
||||
#include "mozilla/dom/MemoryReportRequest.h"
|
||||
#include "mozilla/gfx/GPUProcessManager.h"
|
||||
#include "mozilla/gfx/gfxVars.h"
|
||||
#include "mozilla/ipc/CrashReporterHost.h"
|
||||
#include "mozilla/ipc/Endpoint.h"
|
||||
#include "mozilla/gfx/gfxVars.h"
|
||||
#include "mozilla/gfx/GPUProcessManager.h"
|
||||
|
||||
#if defined(XP_LINUX) && defined(MOZ_SANDBOX)
|
||||
# include "mozilla/SandboxBroker.h"
|
||||
|
@ -138,6 +139,13 @@ mozilla::ipc::IPCResult RDDChild::RecvGetModulesTrust(
|
|||
#endif // defined(XP_WIN)
|
||||
}
|
||||
|
||||
mozilla::ipc::IPCResult RDDChild::RecvUpdateMediaCodecsSupported(
|
||||
const PDMFactory::MediaCodecsSupported& aSupported) {
|
||||
dom::ContentParent::BroadcastMediaCodecsSupportedUpdate(
|
||||
RemoteDecodeIn::RddProcess, aSupported);
|
||||
return IPC_OK();
|
||||
}
|
||||
|
||||
void RDDChild::ActorDestroy(ActorDestroyReason aWhy) {
|
||||
if (aWhy == AbnormalShutdown) {
|
||||
GenerateCrashReport(OtherPid());
|
||||
|
|
|
@ -6,11 +6,10 @@
|
|||
#ifndef _include_dom_media_ipc_RDDChild_h_
|
||||
#define _include_dom_media_ipc_RDDChild_h_
|
||||
#include "mozilla/PRDDChild.h"
|
||||
|
||||
#include "mozilla/ipc/CrashReporterHelper.h"
|
||||
#include "mozilla/UniquePtr.h"
|
||||
#include "mozilla/gfx/gfxVarReceiver.h"
|
||||
#include "mozilla/gfx/GPUProcessListener.h"
|
||||
#include "mozilla/gfx/gfxVarReceiver.h"
|
||||
#include "mozilla/ipc/CrashReporterHelper.h"
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
|
@ -45,6 +44,8 @@ class RDDChild final : public PRDDChild,
|
|||
mozilla::ipc::IPCResult RecvGetModulesTrust(
|
||||
ModulePaths&& aModPaths, bool aRunAtNormalPriority,
|
||||
GetModulesTrustResolver&& aResolver);
|
||||
mozilla::ipc::IPCResult RecvUpdateMediaCodecsSupported(
|
||||
const PDMFactory::MediaCodecsSupported& aSupported);
|
||||
|
||||
bool SendRequestMemoryReport(const uint32_t& aGeneration,
|
||||
const bool& aAnonymize,
|
||||
|
|
|
@ -6,16 +6,19 @@
|
|||
#include "RDDParent.h"
|
||||
|
||||
#if defined(XP_WIN)
|
||||
# include "mozilla/gfx/DeviceManagerDx.h"
|
||||
# include "WMF.h"
|
||||
# include <process.h>
|
||||
# include <dwrite.h>
|
||||
# include <process.h>
|
||||
|
||||
# include "WMF.h"
|
||||
# include "mozilla/WinDllServices.h"
|
||||
# include "mozilla/gfx/DeviceManagerDx.h"
|
||||
#else
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
|
||||
#include "PDMFactory.h"
|
||||
#include "chrome/common/ipc_channel.h"
|
||||
#include "gfxConfig.h"
|
||||
#include "mozilla/Assertions.h"
|
||||
#include "mozilla/HangDetails.h"
|
||||
#include "mozilla/Preferences.h"
|
||||
|
@ -23,10 +26,9 @@
|
|||
#include "mozilla/RemoteDecoderManagerParent.h"
|
||||
#include "mozilla/TimeStamp.h"
|
||||
#include "mozilla/dom/MemoryReportRequest.h"
|
||||
#include "mozilla/gfx/gfxVars.h"
|
||||
#include "mozilla/ipc/CrashReporterClient.h"
|
||||
#include "mozilla/ipc/ProcessChild.h"
|
||||
#include "mozilla/gfx/gfxVars.h"
|
||||
#include "gfxConfig.h"
|
||||
|
||||
#if defined(XP_LINUX) && defined(MOZ_SANDBOX)
|
||||
# include "mozilla/Sandbox.h"
|
||||
|
@ -37,14 +39,14 @@
|
|||
#endif
|
||||
|
||||
#if defined(XP_MACOSX) && defined(MOZ_SANDBOX)
|
||||
# include "RDDProcessHost.h"
|
||||
# include "mozilla/Sandbox.h"
|
||||
# include "nsMacUtilsImpl.h"
|
||||
# include "RDDProcessHost.h"
|
||||
#endif
|
||||
|
||||
#include "ProcessUtils.h"
|
||||
#include "nsDebugImpl.h"
|
||||
#include "nsThreadManager.h"
|
||||
#include "ProcessUtils.h"
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
|
@ -120,6 +122,9 @@ mozilla::ipc::IPCResult RDDParent::RecvInit(
|
|||
gfxVars::ApplyUpdate(var);
|
||||
}
|
||||
|
||||
auto supported = PDMFactory::Supported();
|
||||
Unused << SendUpdateMediaCodecsSupported(supported);
|
||||
|
||||
#if defined(MOZ_SANDBOX)
|
||||
# if defined(XP_MACOSX)
|
||||
// Close all current connections to the WindowServer. This ensures that the
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
#include "RemoteDecoderManagerChild.h"
|
||||
|
||||
#include "PDMFactory.h"
|
||||
#include "RemoteAudioDecoder.h"
|
||||
#include "RemoteMediaDataDecoder.h"
|
||||
#include "RemoteVideoDecoder.h"
|
||||
|
@ -45,6 +46,11 @@ static StaticRefPtr<RemoteDecoderManagerChild>
|
|||
sRemoteDecoderManagerChildForGPUProcess;
|
||||
static UniquePtr<nsTArray<RefPtr<Runnable>>> sRecreateTasks;
|
||||
|
||||
static StaticDataMutex<Maybe<PDMFactory::MediaCodecsSupported>> sGPUSupported(
|
||||
"RDMC::sGPUSupported");
|
||||
static StaticDataMutex<Maybe<PDMFactory::MediaCodecsSupported>> sRDDSupported(
|
||||
"RDMC::sRDDSupported");
|
||||
|
||||
class ShutdownObserver final : public nsIObserver {
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
|
@ -190,18 +196,30 @@ nsISerialEventTarget* RemoteDecoderManagerChild::GetManagerThread() {
|
|||
bool RemoteDecoderManagerChild::Supports(
|
||||
RemoteDecodeIn aLocation, const SupportDecoderParams& aParams,
|
||||
DecoderDoctorDiagnostics* aDiagnostics) {
|
||||
RefPtr<PDMFactory> pdm;
|
||||
Maybe<PDMFactory::MediaCodecsSupported> supported;
|
||||
switch (aLocation) {
|
||||
case RemoteDecodeIn::RddProcess:
|
||||
pdm = PDMFactory::PDMFactoryForRdd();
|
||||
case RemoteDecodeIn::RddProcess: {
|
||||
auto supportedRDD = sRDDSupported.Lock();
|
||||
supported = *supportedRDD;
|
||||
break;
|
||||
case RemoteDecodeIn::GpuProcess:
|
||||
pdm = PDMFactory::PDMFactoryForGpu();
|
||||
}
|
||||
case RemoteDecodeIn::GpuProcess: {
|
||||
auto supportedGPU = sGPUSupported.Lock();
|
||||
supported = *supportedGPU;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
return pdm->Supports(aParams, aDiagnostics);
|
||||
if (!supported) {
|
||||
// We haven't received the correct information yet from either the GPU or
|
||||
// the RDD process; assume it is supported to prevent false negative.
|
||||
return true;
|
||||
}
|
||||
|
||||
// We can ignore the SupportDecoderParams argument for now as creation of the
|
||||
// decoder will actually fail later and fallback PDMs will be tested on later.
|
||||
return PDMFactory::SupportsMimeType(aParams.MimeType(), *supported);
|
||||
}
|
||||
|
||||
/* static */
|
||||
|
@ -574,4 +592,23 @@ void RemoteDecoderManagerChild::HandleFatalError(const char* aMsg) const {
|
|||
dom::ContentChild::FatalErrorIfNotUsingGPUProcess(aMsg, OtherPid());
|
||||
}
|
||||
|
||||
void RemoteDecoderManagerChild::SetSupported(
|
||||
RemoteDecodeIn aLocation,
|
||||
const PDMFactory::MediaCodecsSupported& aSupported) {
|
||||
switch (aLocation) {
|
||||
case RemoteDecodeIn::GpuProcess: {
|
||||
auto supported = sGPUSupported.Lock();
|
||||
*supported = Some(aSupported);
|
||||
break;
|
||||
}
|
||||
case RemoteDecodeIn::RddProcess: {
|
||||
auto supported = sRDDSupported.Lock();
|
||||
*supported = Some(aSupported);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
MOZ_CRASH("Not to be used for any other process");
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace mozilla
|
||||
|
|
|
@ -5,7 +5,10 @@
|
|||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
#ifndef include_dom_media_ipc_RemoteDecoderManagerChild_h
|
||||
#define include_dom_media_ipc_RemoteDecoderManagerChild_h
|
||||
|
||||
#include "GPUVideoImage.h"
|
||||
#include "ipc/EnumSerializer.h"
|
||||
#include "mozilla/EnumTypeTraits.h"
|
||||
#include "mozilla/PRemoteDecoderManagerChild.h"
|
||||
#include "mozilla/layers/VideoBridgeUtils.h"
|
||||
|
||||
|
@ -17,6 +20,8 @@ enum class RemoteDecodeIn {
|
|||
Unspecified,
|
||||
RddProcess,
|
||||
GpuProcess,
|
||||
|
||||
SENTINEL,
|
||||
};
|
||||
|
||||
class RemoteDecoderManagerChild final
|
||||
|
@ -32,6 +37,8 @@ class RemoteDecoderManagerChild final
|
|||
static RemoteDecoderManagerChild* GetSingleton(RemoteDecodeIn aLocation);
|
||||
|
||||
static void Init();
|
||||
static void SetSupported(RemoteDecodeIn aLocation,
|
||||
const PDMFactory::MediaCodecsSupported& aSupported);
|
||||
|
||||
// Can be called from any thread.
|
||||
static bool Supports(RemoteDecodeIn aLocation,
|
||||
|
@ -114,4 +121,12 @@ class RemoteDecoderManagerChild final
|
|||
|
||||
} // namespace mozilla
|
||||
|
||||
namespace IPC {
|
||||
template <>
|
||||
struct ParamTraits<mozilla::RemoteDecodeIn>
|
||||
: public ContiguousEnumSerializer<mozilla::RemoteDecodeIn,
|
||||
mozilla::RemoteDecodeIn::Unspecified,
|
||||
mozilla::RemoteDecodeIn::SENTINEL> {};
|
||||
} // namespace IPC
|
||||
|
||||
#endif // include_dom_media_ipc_RemoteDecoderManagerChild_h
|
||||
|
|
|
@ -6,6 +6,9 @@
|
|||
|
||||
#include "PDMFactory.h"
|
||||
|
||||
#ifdef MOZ_AV1
|
||||
# include "AOMDecoder.h"
|
||||
#endif
|
||||
#include "AgnosticDecoderModule.h"
|
||||
#include "AudioTrimmer.h"
|
||||
#include "BlankDecoderModule.h"
|
||||
|
@ -16,8 +19,12 @@
|
|||
#include "MP4Decoder.h"
|
||||
#include "MediaChangeMonitor.h"
|
||||
#include "MediaInfo.h"
|
||||
#include "VideoUtils.h"
|
||||
#include "OpusDecoder.h"
|
||||
#include "TheoraDecoder.h"
|
||||
#include "VPXDecoder.h"
|
||||
#include "VideoUtils.h"
|
||||
#include "VorbisDecoder.h"
|
||||
#include "WAVDecoder.h"
|
||||
#include "mozilla/ClearOnShutdown.h"
|
||||
#include "mozilla/RemoteDecoderManagerChild.h"
|
||||
#include "mozilla/RemoteDecoderModule.h"
|
||||
|
@ -54,10 +61,6 @@
|
|||
|
||||
namespace mozilla {
|
||||
|
||||
// Set on the main thread, in content processes before any PDMFactory will ever
|
||||
// be created; never modified after.
|
||||
static Maybe<PDMFactory::MediaCodecsSupported> sSupported;
|
||||
|
||||
extern already_AddRefed<PlatformDecoderModule> CreateNullDecoderModule();
|
||||
|
||||
class PDMFactoryImpl final {
|
||||
|
@ -68,8 +71,6 @@ class PDMFactoryImpl final {
|
|||
} else if (XRE_IsRDDProcess()) {
|
||||
InitRddPDMs();
|
||||
} else if (XRE_IsContentProcess()) {
|
||||
MOZ_DIAGNOSTIC_ASSERT(sSupported.isSome(),
|
||||
"PDMFactory accessed while not initialized");
|
||||
InitContentPDMs();
|
||||
} else {
|
||||
MOZ_DIAGNOSTIC_ASSERT(
|
||||
|
@ -231,31 +232,6 @@ PDMFactory::PDMFactory() {
|
|||
|
||||
PDMFactory::~PDMFactory() = default;
|
||||
|
||||
PDMFactory::PDMFactory(const RemoteDecodeIn& aProcess) {
|
||||
switch (aProcess) {
|
||||
case RemoteDecodeIn::RddProcess:
|
||||
CreateRddPDMs();
|
||||
break;
|
||||
case RemoteDecodeIn::GpuProcess:
|
||||
CreateGpuPDMs();
|
||||
break;
|
||||
default:
|
||||
MOZ_CRASH("Not to be used for any other process");
|
||||
}
|
||||
}
|
||||
|
||||
/* static */
|
||||
already_AddRefed<PDMFactory> PDMFactory::PDMFactoryForRdd() {
|
||||
RefPtr<PDMFactory> pdm = new PDMFactory(RemoteDecodeIn::RddProcess);
|
||||
return pdm.forget();
|
||||
}
|
||||
|
||||
/* static */
|
||||
already_AddRefed<PDMFactory> PDMFactory::PDMFactoryForGpu() {
|
||||
RefPtr<PDMFactory> pdm = new PDMFactory(RemoteDecodeIn::GpuProcess);
|
||||
return pdm.forget();
|
||||
}
|
||||
|
||||
/* static */
|
||||
void PDMFactory::EnsureInit() {
|
||||
{
|
||||
|
@ -643,11 +619,6 @@ void PDMFactory::SetCDMProxy(CDMProxy* aProxy) {
|
|||
|
||||
/* static */
|
||||
PDMFactory::MediaCodecsSupported PDMFactory::Supported() {
|
||||
if (XRE_IsContentProcess()) {
|
||||
return *sSupported;
|
||||
}
|
||||
MOZ_ASSERT(XRE_IsParentProcess());
|
||||
|
||||
static MediaCodecsSupported supported = []() {
|
||||
auto pdm = MakeRefPtr<PDMFactory>();
|
||||
MediaCodecsSupported supported;
|
||||
|
@ -662,6 +633,18 @@ PDMFactory::MediaCodecsSupported PDMFactory::Supported() {
|
|||
if (pdm->SupportsMimeType("video/avc"_ns, nullptr)) {
|
||||
supported += MediaCodecs::H264;
|
||||
}
|
||||
if (pdm->SupportsMimeType("video/vp9"_ns, nullptr)) {
|
||||
supported += MediaCodecs::VP9;
|
||||
}
|
||||
if (pdm->SupportsMimeType("video/vp8"_ns, nullptr)) {
|
||||
supported += MediaCodecs::VP8;
|
||||
}
|
||||
if (pdm->SupportsMimeType("video/av1"_ns, nullptr)) {
|
||||
supported += MediaCodecs::AV1;
|
||||
}
|
||||
if (pdm->SupportsMimeType("video/theora"_ns, nullptr)) {
|
||||
supported += MediaCodecs::Theora;
|
||||
}
|
||||
if (pdm->SupportsMimeType("audio/mp4a-latm"_ns, nullptr)) {
|
||||
supported += MediaCodecs::AAC;
|
||||
}
|
||||
|
@ -669,28 +652,60 @@ PDMFactory::MediaCodecsSupported PDMFactory::Supported() {
|
|||
if (pdm->SupportsMimeType("audio/mpeg"_ns, nullptr)) {
|
||||
supported += MediaCodecs::MP3;
|
||||
}
|
||||
// The codecs below are potentially always supported as we ship native
|
||||
// support for them. If they are disabled through pref, it will be handled
|
||||
// in MediaDecoder class that could use those.
|
||||
supported += MediaCodecs::VP9;
|
||||
supported += MediaCodecs::VP8;
|
||||
supported += MediaCodecs::AV1;
|
||||
supported += MediaCodecs::Theora;
|
||||
supported += MediaCodecs::Opus;
|
||||
supported += MediaCodecs::Vorbis;
|
||||
supported += MediaCodecs::Flac;
|
||||
supported += MediaCodecs::Wave;
|
||||
|
||||
if (pdm->SupportsMimeType("audio/opus"_ns, nullptr)) {
|
||||
supported += MediaCodecs::Opus;
|
||||
}
|
||||
if (pdm->SupportsMimeType("audio/vorbis"_ns, nullptr)) {
|
||||
supported += MediaCodecs::Vorbis;
|
||||
}
|
||||
if (pdm->SupportsMimeType("audio/flac"_ns, nullptr)) {
|
||||
supported += MediaCodecs::Flac;
|
||||
}
|
||||
if (pdm->SupportsMimeType("audio/x-wav"_ns, nullptr)) {
|
||||
supported += MediaCodecs::Wave;
|
||||
}
|
||||
return supported;
|
||||
}();
|
||||
return supported;
|
||||
}
|
||||
|
||||
/* static */
|
||||
void PDMFactory::SetSupported(const MediaCodecsSupported& aSupported) {
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
sSupported = Some(aSupported);
|
||||
bool PDMFactory::SupportsMimeType(const nsACString& aMimeType,
|
||||
const MediaCodecsSupported& aSupported) {
|
||||
if (MP4Decoder::IsH264(aMimeType)) {
|
||||
return aSupported.contains(MediaCodecs::H264);
|
||||
}
|
||||
if (VPXDecoder::IsVP9(aMimeType)) {
|
||||
return aSupported.contains(MediaCodecs::VP9);
|
||||
}
|
||||
if (VPXDecoder::IsVP8(aMimeType)) {
|
||||
return aSupported.contains(MediaCodecs::VP8);
|
||||
}
|
||||
if (AOMDecoder::IsAV1(aMimeType)) {
|
||||
return aSupported.contains(MediaCodecs::AV1);
|
||||
}
|
||||
if (TheoraDecoder::IsTheora(aMimeType)) {
|
||||
return aSupported.contains(MediaCodecs::Theora);
|
||||
}
|
||||
if (MP4Decoder::IsAAC(aMimeType)) {
|
||||
return aSupported.contains(MediaCodecs::AAC);
|
||||
}
|
||||
if (aMimeType.EqualsLiteral("audio/mpeg")) {
|
||||
return aSupported.contains(MediaCodecs::MP3);
|
||||
}
|
||||
if (OpusDataDecoder::IsOpus(aMimeType)) {
|
||||
return aSupported.contains(MediaCodecs::Opus);
|
||||
}
|
||||
if (VorbisDataDecoder::IsVorbis(aMimeType)) {
|
||||
return aSupported.contains(MediaCodecs::Vorbis);
|
||||
}
|
||||
if (aMimeType.EqualsLiteral("audio/flac")) {
|
||||
return aSupported.contains(MediaCodecs::Flac);
|
||||
}
|
||||
if (WaveDataDecoder::IsWave(aMimeType)) {
|
||||
return aSupported.contains(MediaCodecs::Wave);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
} // namespace mozilla
|
||||
|
|
|
@ -44,11 +44,6 @@ class PDMFactory final {
|
|||
|
||||
PDMFactory();
|
||||
|
||||
// To be called in the content process only, used to determine which PDMs are
|
||||
// usable in their respective process.
|
||||
static already_AddRefed<PDMFactory> PDMFactoryForRdd();
|
||||
static already_AddRefed<PDMFactory> PDMFactoryForGpu();
|
||||
|
||||
// Factory method that creates the appropriate PlatformDecoderModule for
|
||||
// the platform we're running on.
|
||||
RefPtr<PDMCreateDecoderPromise> CreateDecoder(
|
||||
|
@ -93,14 +88,11 @@ class PDMFactory final {
|
|||
using MediaCodecsSupported = EnumSet<MediaCodecs>;
|
||||
|
||||
static MediaCodecsSupported Supported();
|
||||
static void SetSupported(const MediaCodecsSupported& aSupported);
|
||||
static bool SupportsMimeType(const nsACString& aMimeType,
|
||||
const MediaCodecsSupported& aSupported);
|
||||
|
||||
private:
|
||||
virtual ~PDMFactory();
|
||||
// Will set PDM list for the required process.
|
||||
// This is used to determine which PDMs are available on the given process
|
||||
// from the content process.
|
||||
explicit PDMFactory(const RemoteDecodeIn& aProcess);
|
||||
|
||||
void CreatePDMs();
|
||||
void CreateNullPDM();
|
||||
|
|
|
@ -249,41 +249,26 @@ static bool CanCreateWMFDecoder() {
|
|||
|
||||
/* static */
|
||||
bool WMFDecoderModule::HasH264() {
|
||||
if (XRE_IsContentProcess()) {
|
||||
return PDMFactory::Supported().contains(PDMFactory::MediaCodecs::H264);
|
||||
}
|
||||
return CanCreateWMFDecoder<CLSID_CMSH264DecoderMFT>();
|
||||
}
|
||||
|
||||
/* static */
|
||||
bool WMFDecoderModule::HasVP8() {
|
||||
if (XRE_IsContentProcess()) {
|
||||
return PDMFactory::Supported().contains(PDMFactory::MediaCodecs::VP8);
|
||||
}
|
||||
return sUsableVPXMFT && CanCreateWMFDecoder<CLSID_WebmMfVpxDec>();
|
||||
}
|
||||
|
||||
/* static */
|
||||
bool WMFDecoderModule::HasVP9() {
|
||||
if (XRE_IsContentProcess()) {
|
||||
return PDMFactory::Supported().contains(PDMFactory::MediaCodecs::VP9);
|
||||
}
|
||||
return sUsableVPXMFT && CanCreateWMFDecoder<CLSID_WebmMfVpxDec>();
|
||||
}
|
||||
|
||||
/* static */
|
||||
bool WMFDecoderModule::HasAAC() {
|
||||
if (XRE_IsContentProcess()) {
|
||||
return PDMFactory::Supported().contains(PDMFactory::MediaCodecs::AAC);
|
||||
}
|
||||
return CanCreateWMFDecoder<CLSID_CMSAACDecMFT>();
|
||||
}
|
||||
|
||||
/* static */
|
||||
bool WMFDecoderModule::HasMP3() {
|
||||
if (XRE_IsContentProcess()) {
|
||||
return PDMFactory::Supported().contains(PDMFactory::MediaCodecs::MP3);
|
||||
}
|
||||
return CanCreateWMFDecoder<CLSID_CMP3DecMediaObject>();
|
||||
}
|
||||
|
||||
|
|
|
@ -4,26 +4,29 @@
|
|||
* 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/. */
|
||||
#include "GPUChild.h"
|
||||
#include "gfxConfig.h"
|
||||
#include "GfxInfoBase.h"
|
||||
#include "gfxPlatform.h"
|
||||
|
||||
#include "GPUProcessHost.h"
|
||||
#include "GPUProcessManager.h"
|
||||
#include "GfxInfoBase.h"
|
||||
#include "VRProcessManager.h"
|
||||
#include "gfxConfig.h"
|
||||
#include "gfxPlatform.h"
|
||||
#include "mozilla/StaticPrefs_dom.h"
|
||||
#include "mozilla/Telemetry.h"
|
||||
#include "mozilla/TelemetryIPC.h"
|
||||
#include "mozilla/dom/CheckerboardReportService.h"
|
||||
#include "mozilla/dom/ContentParent.h"
|
||||
#include "mozilla/dom/MemoryReportRequest.h"
|
||||
#include "mozilla/gfx/gfxVars.h"
|
||||
#if defined(XP_WIN)
|
||||
# include "mozilla/gfx/DeviceManagerDx.h"
|
||||
#endif
|
||||
#include "mozilla/HangDetails.h"
|
||||
#include "mozilla/RemoteDecoderManagerChild.h" // For RemoteDecodeIn
|
||||
#include "mozilla/Unused.h"
|
||||
#include "mozilla/ipc/Endpoint.h"
|
||||
#include "mozilla/layers/APZInputBridgeChild.h"
|
||||
#include "mozilla/layers/LayerTreeOwnerTracker.h"
|
||||
#include "mozilla/Unused.h"
|
||||
#include "mozilla/HangDetails.h"
|
||||
#include "nsIGfxInfo.h"
|
||||
#include "nsIObserverService.h"
|
||||
|
||||
|
@ -297,6 +300,13 @@ mozilla::ipc::IPCResult GPUChild::RecvBHRThreadHang(
|
|||
return IPC_OK();
|
||||
}
|
||||
|
||||
mozilla::ipc::IPCResult GPUChild::RecvUpdateMediaCodecsSupported(
|
||||
const PDMFactory::MediaCodecsSupported& aSupported) {
|
||||
dom::ContentParent::BroadcastMediaCodecsSupportedUpdate(
|
||||
RemoteDecodeIn::GpuProcess, aSupported);
|
||||
return IPC_OK();
|
||||
}
|
||||
|
||||
class DeferredDeleteGPUChild : public Runnable {
|
||||
public:
|
||||
explicit DeferredDeleteGPUChild(UniquePtr<GPUChild>&& aChild)
|
||||
|
|
|
@ -68,6 +68,8 @@ class GPUChild final : public ipc::CrashReporterHelper<GeckoProcessType_GPU>,
|
|||
mozilla::ipc::IPCResult RecvUsedFallback(const Fallback& aFallback,
|
||||
const nsCString& aMessage);
|
||||
mozilla::ipc::IPCResult RecvBHRThreadHang(const HangDetails& aDetails);
|
||||
mozilla::ipc::IPCResult RecvUpdateMediaCodecsSupported(
|
||||
const PDMFactory::MediaCodecsSupported& aSupported);
|
||||
|
||||
bool SendRequestMemoryReport(const uint32_t& aGeneration,
|
||||
const bool& aAnonymize,
|
||||
|
|
|
@ -142,9 +142,7 @@ bool GPUParent::Init(base::ProcessId aParentPid, const char* aParentBuildID,
|
|||
LayerTreeOwnerTracker::Initialize();
|
||||
CompositorBridgeParent::InitializeStatics();
|
||||
mozilla::ipc::SetThisProcessName("GPU Process");
|
||||
#ifdef XP_WIN
|
||||
wmf::MFStartup();
|
||||
#endif
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -295,6 +293,19 @@ mozilla::ipc::IPCResult GPUParent::RecvInit(
|
|||
RecvGetDeviceStatus(&data);
|
||||
Unused << SendInitComplete(data);
|
||||
|
||||
// Dispatch a task to run when idle that will determine which codecs are
|
||||
// usable. The primary goal is to determine if the media feature pack is
|
||||
// installed.
|
||||
MOZ_ALWAYS_SUCCEEDS(NS_DispatchToCurrentThreadQueue(
|
||||
NS_NewRunnableFunction(
|
||||
"GPUParent::Supported",
|
||||
[]() {
|
||||
auto supported = PDMFactory::Supported();
|
||||
Unused << GPUParent::GetSingleton()->SendUpdateMediaCodecsSupported(
|
||||
supported);
|
||||
}),
|
||||
2000 /* 2 seconds timeout */, EventQueuePriority::Idle));
|
||||
|
||||
Telemetry::AccumulateTimeDelta(Telemetry::GPU_PROCESS_INITIALIZATION_TIME_MS,
|
||||
mLaunchTime);
|
||||
return IPC_OK();
|
||||
|
|
|
@ -35,6 +35,7 @@ using mozilla::Telemetry::DiscardedData from "mozilla/TelemetryComms.h";
|
|||
using mozilla::gfx::Feature from "gfxFeature.h";
|
||||
using mozilla::gfx::Fallback from "gfxFallback.h";
|
||||
using mozilla::layers::LayersId from "mozilla/layers/LayersTypes.h";
|
||||
using mozilla::PDMFactory::MediaCodecsSupported from "PDMFactory.h";
|
||||
|
||||
namespace mozilla {
|
||||
namespace gfx {
|
||||
|
@ -154,6 +155,10 @@ child:
|
|||
async UsedFallback(Fallback aFallback, nsCString message);
|
||||
|
||||
async BHRThreadHang(HangDetails aDetails);
|
||||
|
||||
// Update the cached list of codec supported following a check in the
|
||||
// GPU parent.
|
||||
async UpdateMediaCodecsSupported(MediaCodecsSupported aSupported);
|
||||
};
|
||||
|
||||
} // namespace gfx
|
||||
|
|
Загрузка…
Ссылка в новой задаче