Bug 1756260 - part5 : pass the engine Id via IPC. r=jolin

We need to padd the media engine Id to the remote process in order to create correct remote decoders.

Differential Revision: https://phabricator.services.mozilla.com/D143807
This commit is contained in:
alwu 2022-05-11 17:46:13 +00:00
Родитель 565f1630ee
Коммит ba773486a6
13 изменённых файлов: 75 добавлений и 32 удалений

Просмотреть файл

@ -46,7 +46,8 @@ parent:
#endif #endif
async PRemoteDecoder(RemoteDecoderInfoIPDL info, async PRemoteDecoder(RemoteDecoderInfoIPDL info,
OptionSet options, OptionSet options,
TextureFactoryIdentifier? identifier); TextureFactoryIdentifier? identifier,
uint64_t? mediaEngineId);
sync Readback(SurfaceDescriptorGPUVideo sd) returns (SurfaceDescriptor aResult); sync Readback(SurfaceDescriptorGPUVideo sd) returns (SurfaceDescriptor aResult);

Просмотреть файл

@ -39,8 +39,8 @@ MediaResult RemoteAudioDecoderChild::ProcessOutput(
} }
MediaResult RemoteAudioDecoderChild::InitIPDL( MediaResult RemoteAudioDecoderChild::InitIPDL(
const AudioInfo& aAudioInfo, const AudioInfo& aAudioInfo, const CreateDecoderParams::OptionSet& aOptions,
const CreateDecoderParams::OptionSet& aOptions) { const Maybe<uint64_t>& aMediaEngineId) {
RefPtr<RemoteDecoderManagerChild> manager = RefPtr<RemoteDecoderManagerChild> manager =
RemoteDecoderManagerChild::GetSingleton(mLocation); RemoteDecoderManagerChild::GetSingleton(mLocation);
@ -59,21 +59,24 @@ MediaResult RemoteAudioDecoderChild::InitIPDL(
mIPDLSelfRef = this; mIPDLSelfRef = this;
Unused << manager->SendPRemoteDecoderConstructor(this, aAudioInfo, aOptions, Unused << manager->SendPRemoteDecoderConstructor(this, aAudioInfo, aOptions,
Nothing()); Nothing(), aMediaEngineId);
return NS_OK; return NS_OK;
} }
RemoteAudioDecoderParent::RemoteAudioDecoderParent( RemoteAudioDecoderParent::RemoteAudioDecoderParent(
RemoteDecoderManagerParent* aParent, const AudioInfo& aAudioInfo, RemoteDecoderManagerParent* aParent, const AudioInfo& aAudioInfo,
const CreateDecoderParams::OptionSet& aOptions, const CreateDecoderParams::OptionSet& aOptions,
nsISerialEventTarget* aManagerThread, TaskQueue* aDecodeTaskQueue) nsISerialEventTarget* aManagerThread, TaskQueue* aDecodeTaskQueue,
: RemoteDecoderParent(aParent, aOptions, aManagerThread, aDecodeTaskQueue), Maybe<uint64_t> aMediaEngineId)
: RemoteDecoderParent(aParent, aOptions, aManagerThread, aDecodeTaskQueue,
aMediaEngineId),
mAudioInfo(aAudioInfo) {} mAudioInfo(aAudioInfo) {}
IPCResult RemoteAudioDecoderParent::RecvConstruct( IPCResult RemoteAudioDecoderParent::RecvConstruct(
ConstructResolver&& aResolver) { ConstructResolver&& aResolver) {
auto params = CreateDecoderParams{mAudioInfo, mOptions, auto params =
CreateDecoderParams::NoWrapper(true)}; CreateDecoderParams{mAudioInfo, mOptions,
CreateDecoderParams::NoWrapper(true), mMediaEngineId};
mParent->EnsurePDMFactory().CreateDecoder(params)->Then( mParent->EnsurePDMFactory().CreateDecoder(params)->Then(
GetCurrentSerialEventTarget(), __func__, GetCurrentSerialEventTarget(), __func__,

Просмотреть файл

@ -18,7 +18,8 @@ class RemoteAudioDecoderChild final : public RemoteDecoderChild {
MOZ_IS_CLASS_INIT MOZ_IS_CLASS_INIT
MediaResult InitIPDL(const AudioInfo& aAudioInfo, MediaResult InitIPDL(const AudioInfo& aAudioInfo,
const CreateDecoderParams::OptionSet& aOptions); const CreateDecoderParams::OptionSet& aOptions,
const Maybe<uint64_t>& aMediaEngineId);
MediaResult ProcessOutput(DecodedOutputIPDL&& aDecodedData) override; MediaResult ProcessOutput(DecodedOutputIPDL&& aDecodedData) override;
}; };
@ -29,7 +30,8 @@ class RemoteAudioDecoderParent final : public RemoteDecoderParent {
const AudioInfo& aAudioInfo, const AudioInfo& aAudioInfo,
const CreateDecoderParams::OptionSet& aOptions, const CreateDecoderParams::OptionSet& aOptions,
nsISerialEventTarget* aManagerThread, nsISerialEventTarget* aManagerThread,
TaskQueue* aDecodeTaskQueue); TaskQueue* aDecodeTaskQueue,
Maybe<uint64_t> aMediaEngineId);
protected: protected:
IPCResult RecvConstruct(ConstructResolver&& aResolver) override; IPCResult RecvConstruct(ConstructResolver&& aResolver) override;

Просмотреть файл

@ -269,18 +269,26 @@ RemoteDecoderManagerChild::CreateAudioDecoder(
return PlatformDecoderModule::CreateDecoderPromise::CreateAndReject( return PlatformDecoderModule::CreateDecoderPromise::CreateAndReject(
NS_ERROR_DOM_MEDIA_CANCELED, __func__); NS_ERROR_DOM_MEDIA_CANCELED, __func__);
} }
bool useUtilityAudioDecoding = StaticPrefs::media_utility_process_enabled() &&
aLocation == RemoteDecodeIn::UtilityProcess;
#ifdef MOZ_WMF
// If the media engine Id is specified, using the media engine in the RDD
// process instead.
useUtilityAudioDecoding = useUtilityAudioDecoding &&
!(aParams.mMediaEngineId &&
StaticPrefs::media_wmf_media_engine_enabled());
#endif
RefPtr<GenericNonExclusivePromise> launchPromise = RefPtr<GenericNonExclusivePromise> launchPromise =
(StaticPrefs::media_utility_process_enabled() && useUtilityAudioDecoding ? LaunchUtilityProcessIfNeeded()
aLocation == RemoteDecodeIn::UtilityProcess) : LaunchRDDProcessIfNeeded();
? LaunchUtilityProcessIfNeeded()
: LaunchRDDProcessIfNeeded();
return launchPromise->Then( return launchPromise->Then(
managerThread, __func__, managerThread, __func__,
[params = CreateDecoderParamsForAsync(aParams), aLocation](bool) { [params = CreateDecoderParamsForAsync(aParams), aLocation](bool) {
auto child = MakeRefPtr<RemoteAudioDecoderChild>(); auto child = MakeRefPtr<RemoteAudioDecoderChild>();
MediaResult result = MediaResult result = child->InitIPDL(
child->InitIPDL(params.AudioConfig(), params.mOptions); params.AudioConfig(), params.mOptions, params.mMediaEngineId);
if (NS_FAILED(result)) { if (NS_FAILED(result)) {
return PlatformDecoderModule::CreateDecoderPromise::CreateAndReject( return PlatformDecoderModule::CreateDecoderPromise::CreateAndReject(
result, __func__); result, __func__);
@ -332,7 +340,8 @@ RemoteDecoderManagerChild::CreateVideoDecoder(
params.VideoConfig(), params.mRate.mValue, params.mOptions, params.VideoConfig(), params.mRate.mValue, params.mOptions,
params.mKnowsCompositor params.mKnowsCompositor
? Some(params.mKnowsCompositor->GetTextureFactoryIdentifier()) ? Some(params.mKnowsCompositor->GetTextureFactoryIdentifier())
: Nothing()); : Nothing(),
params.mMediaEngineId);
if (NS_FAILED(result)) { if (NS_FAILED(result)) {
return PlatformDecoderModule::CreateDecoderPromise::CreateAndReject( return PlatformDecoderModule::CreateDecoderPromise::CreateAndReject(
result, __func__); result, __func__);
@ -548,7 +557,8 @@ RemoteDecoderManagerChild::LaunchUtilityProcessIfNeeded() {
PRemoteDecoderChild* RemoteDecoderManagerChild::AllocPRemoteDecoderChild( PRemoteDecoderChild* RemoteDecoderManagerChild::AllocPRemoteDecoderChild(
const RemoteDecoderInfoIPDL& /* not used */, const RemoteDecoderInfoIPDL& /* not used */,
const CreateDecoderParams::OptionSet& aOptions, const CreateDecoderParams::OptionSet& aOptions,
const Maybe<layers::TextureFactoryIdentifier>& aIdentifier) { const Maybe<layers::TextureFactoryIdentifier>& aIdentifier,
const Maybe<uint64_t>& aMediaEngineId) {
// RemoteDecoderModule is responsible for creating RemoteDecoderChild // RemoteDecoderModule is responsible for creating RemoteDecoderChild
// classes. // classes.
MOZ_ASSERT(false, MOZ_ASSERT(false,

Просмотреть файл

@ -92,6 +92,9 @@ class RemoteDecoderManagerChild final
RemoteDecodeIn Location() const { return mLocation; } RemoteDecodeIn Location() const { return mLocation; }
layers::VideoBridgeSource GetSource() const; layers::VideoBridgeSource GetSource() const;
// A thread-safe method to launch the RDD process if it hasn't launched yet.
static RefPtr<GenericNonExclusivePromise> LaunchRDDProcessIfNeeded();
protected: protected:
void InitIPDL(); void InitIPDL();
@ -102,7 +105,8 @@ class RemoteDecoderManagerChild final
PRemoteDecoderChild* AllocPRemoteDecoderChild( PRemoteDecoderChild* AllocPRemoteDecoderChild(
const RemoteDecoderInfoIPDL& aRemoteDecoderInfo, const RemoteDecoderInfoIPDL& aRemoteDecoderInfo,
const CreateDecoderParams::OptionSet& aOptions, const CreateDecoderParams::OptionSet& aOptions,
const Maybe<layers::TextureFactoryIdentifier>& aIdentifier); const Maybe<layers::TextureFactoryIdentifier>& aIdentifier,
const Maybe<uint64_t>& aMediaEngineId);
bool DeallocPRemoteDecoderChild(PRemoteDecoderChild* actor); bool DeallocPRemoteDecoderChild(PRemoteDecoderChild* actor);
PMFMediaEngineChild* AllocPMFMediaEngineChild(); PMFMediaEngineChild* AllocPMFMediaEngineChild();
@ -120,7 +124,6 @@ class RemoteDecoderManagerChild final
Endpoint<PRemoteDecoderManagerChild>&& aEndpoint); Endpoint<PRemoteDecoderManagerChild>&& aEndpoint);
static void OpenForUtilityProcess( static void OpenForUtilityProcess(
Endpoint<PRemoteDecoderManagerChild>&& aEndpoint); Endpoint<PRemoteDecoderManagerChild>&& aEndpoint);
static RefPtr<GenericNonExclusivePromise> LaunchRDDProcessIfNeeded();
static RefPtr<GenericNonExclusivePromise> LaunchUtilityProcessIfNeeded(); static RefPtr<GenericNonExclusivePromise> LaunchUtilityProcessIfNeeded();
RefPtr<RemoteDecoderManagerChild> mIPDLSelfRef; RefPtr<RemoteDecoderManagerChild> mIPDLSelfRef;

Просмотреть файл

@ -191,7 +191,8 @@ void RemoteDecoderManagerParent::ActorDestroy(
PRemoteDecoderParent* RemoteDecoderManagerParent::AllocPRemoteDecoderParent( PRemoteDecoderParent* RemoteDecoderManagerParent::AllocPRemoteDecoderParent(
const RemoteDecoderInfoIPDL& aRemoteDecoderInfo, const RemoteDecoderInfoIPDL& aRemoteDecoderInfo,
const CreateDecoderParams::OptionSet& aOptions, const CreateDecoderParams::OptionSet& aOptions,
const Maybe<layers::TextureFactoryIdentifier>& aIdentifier) { const Maybe<layers::TextureFactoryIdentifier>& aIdentifier,
const Maybe<uint64_t>& aMediaEngineId) {
RefPtr<TaskQueue> decodeTaskQueue = RefPtr<TaskQueue> decodeTaskQueue =
TaskQueue::Create(GetMediaThreadPool(MediaThreadType::PLATFORM_DECODER), TaskQueue::Create(GetMediaThreadPool(MediaThreadType::PLATFORM_DECODER),
"RemoteVideoDecoderParent::mDecodeTaskQueue"); "RemoteVideoDecoderParent::mDecodeTaskQueue");
@ -202,13 +203,14 @@ PRemoteDecoderParent* RemoteDecoderManagerParent::AllocPRemoteDecoderParent(
aRemoteDecoderInfo.get_VideoDecoderInfoIPDL(); aRemoteDecoderInfo.get_VideoDecoderInfoIPDL();
return new RemoteVideoDecoderParent( return new RemoteVideoDecoderParent(
this, decoderInfo.videoInfo(), decoderInfo.framerate(), aOptions, this, decoderInfo.videoInfo(), decoderInfo.framerate(), aOptions,
aIdentifier, sRemoteDecoderManagerParentThread, decodeTaskQueue); aIdentifier, sRemoteDecoderManagerParentThread, decodeTaskQueue,
aMediaEngineId);
} }
if (aRemoteDecoderInfo.type() == RemoteDecoderInfoIPDL::TAudioInfo) { if (aRemoteDecoderInfo.type() == RemoteDecoderInfoIPDL::TAudioInfo) {
return new RemoteAudioDecoderParent( return new RemoteAudioDecoderParent(
this, aRemoteDecoderInfo.get_AudioInfo(), aOptions, this, aRemoteDecoderInfo.get_AudioInfo(), aOptions,
sRemoteDecoderManagerParentThread, decodeTaskQueue); sRemoteDecoderManagerParentThread, decodeTaskQueue, aMediaEngineId);
} }
MOZ_CRASH("unrecognized type of RemoteDecoderInfoIPDL union"); MOZ_CRASH("unrecognized type of RemoteDecoderInfoIPDL union");

Просмотреть файл

@ -58,7 +58,8 @@ class RemoteDecoderManagerParent final
PRemoteDecoderParent* AllocPRemoteDecoderParent( PRemoteDecoderParent* AllocPRemoteDecoderParent(
const RemoteDecoderInfoIPDL& aRemoteDecoderInfo, const RemoteDecoderInfoIPDL& aRemoteDecoderInfo,
const CreateDecoderParams::OptionSet& aOptions, const CreateDecoderParams::OptionSet& aOptions,
const Maybe<layers::TextureFactoryIdentifier>& aIdentifier); const Maybe<layers::TextureFactoryIdentifier>& aIdentifier,
const Maybe<uint64_t>& aMediaEngineId);
bool DeallocPRemoteDecoderParent(PRemoteDecoderParent* actor); bool DeallocPRemoteDecoderParent(PRemoteDecoderParent* actor);
PMFMediaEngineParent* AllocPMFMediaEngineParent(); PMFMediaEngineParent* AllocPMFMediaEngineParent();

Просмотреть файл

@ -13,11 +13,13 @@ namespace mozilla {
RemoteDecoderParent::RemoteDecoderParent( RemoteDecoderParent::RemoteDecoderParent(
RemoteDecoderManagerParent* aParent, RemoteDecoderManagerParent* aParent,
const CreateDecoderParams::OptionSet& aOptions, const CreateDecoderParams::OptionSet& aOptions,
nsISerialEventTarget* aManagerThread, TaskQueue* aDecodeTaskQueue) nsISerialEventTarget* aManagerThread, TaskQueue* aDecodeTaskQueue,
Maybe<uint64_t> aMediaEngineId)
: ShmemRecycleAllocator(this), : ShmemRecycleAllocator(this),
mParent(aParent), mParent(aParent),
mOptions(aOptions), mOptions(aOptions),
mDecodeTaskQueue(aDecodeTaskQueue), mDecodeTaskQueue(aDecodeTaskQueue),
mMediaEngineId(aMediaEngineId),
mManagerThread(aManagerThread) { mManagerThread(aManagerThread) {
MOZ_COUNT_CTOR(RemoteDecoderParent); MOZ_COUNT_CTOR(RemoteDecoderParent);
MOZ_ASSERT(OnManagerThread()); MOZ_ASSERT(OnManagerThread());

Просмотреть файл

@ -26,7 +26,8 @@ class RemoteDecoderParent : public ShmemRecycleAllocator<RemoteDecoderParent>,
RemoteDecoderParent(RemoteDecoderManagerParent* aParent, RemoteDecoderParent(RemoteDecoderManagerParent* aParent,
const CreateDecoderParams::OptionSet& aOptions, const CreateDecoderParams::OptionSet& aOptions,
nsISerialEventTarget* aManagerThread, nsISerialEventTarget* aManagerThread,
TaskQueue* aDecodeTaskQueue); TaskQueue* aDecodeTaskQueue,
Maybe<uint64_t> aMediaEngineId);
void Destroy(); void Destroy();
@ -55,6 +56,9 @@ class RemoteDecoderParent : public ShmemRecycleAllocator<RemoteDecoderParent>,
const RefPtr<TaskQueue> mDecodeTaskQueue; const RefPtr<TaskQueue> mDecodeTaskQueue;
RefPtr<MediaDataDecoder> mDecoder; RefPtr<MediaDataDecoder> mDecoder;
// Only be used on Windows when the media engine playback is enabled.
const Maybe<uint64_t> mMediaEngineId;
private: private:
void DecodeNextSample(const RefPtr<ArrayOfRemoteMediaRawData>& aData, void DecodeNextSample(const RefPtr<ArrayOfRemoteMediaRawData>& aData,
size_t aIndex, MediaDataDecoder::DecodedData&& aOutput, size_t aIndex, MediaDataDecoder::DecodedData&& aOutput,

Просмотреть файл

@ -91,7 +91,8 @@ MediaResult RemoteVideoDecoderChild::ProcessOutput(
MediaResult RemoteVideoDecoderChild::InitIPDL( MediaResult RemoteVideoDecoderChild::InitIPDL(
const VideoInfo& aVideoInfo, float aFramerate, const VideoInfo& aVideoInfo, float aFramerate,
const CreateDecoderParams::OptionSet& aOptions, const CreateDecoderParams::OptionSet& aOptions,
Maybe<layers::TextureFactoryIdentifier> aIdentifier) { Maybe<layers::TextureFactoryIdentifier> aIdentifier,
const Maybe<uint64_t>& aMediaEngineId) {
MOZ_ASSERT_IF(mLocation == RemoteDecodeIn::GpuProcess, aIdentifier); MOZ_ASSERT_IF(mLocation == RemoteDecodeIn::GpuProcess, aIdentifier);
RefPtr<RemoteDecoderManagerChild> manager = RefPtr<RemoteDecoderManagerChild> manager =
@ -123,7 +124,7 @@ MediaResult RemoteVideoDecoderChild::InitIPDL(
mIPDLSelfRef = this; mIPDLSelfRef = this;
VideoDecoderInfoIPDL decoderInfo(aVideoInfo, aFramerate); VideoDecoderInfoIPDL decoderInfo(aVideoInfo, aFramerate);
Unused << manager->SendPRemoteDecoderConstructor(this, decoderInfo, aOptions, Unused << manager->SendPRemoteDecoderConstructor(this, decoderInfo, aOptions,
aIdentifier); aIdentifier, aMediaEngineId);
return NS_OK; return NS_OK;
} }
@ -132,8 +133,10 @@ RemoteVideoDecoderParent::RemoteVideoDecoderParent(
RemoteDecoderManagerParent* aParent, const VideoInfo& aVideoInfo, RemoteDecoderManagerParent* aParent, const VideoInfo& aVideoInfo,
float aFramerate, const CreateDecoderParams::OptionSet& aOptions, float aFramerate, const CreateDecoderParams::OptionSet& aOptions,
const Maybe<layers::TextureFactoryIdentifier>& aIdentifier, const Maybe<layers::TextureFactoryIdentifier>& aIdentifier,
nsISerialEventTarget* aManagerThread, TaskQueue* aDecodeTaskQueue) nsISerialEventTarget* aManagerThread, TaskQueue* aDecodeTaskQueue,
: RemoteDecoderParent(aParent, aOptions, aManagerThread, aDecodeTaskQueue), Maybe<uint64_t> aMediaEngineId)
: RemoteDecoderParent(aParent, aOptions, aManagerThread, aDecodeTaskQueue,
aMediaEngineId),
mVideoInfo(aVideoInfo), mVideoInfo(aVideoInfo),
mFramerate(aFramerate) { mFramerate(aFramerate) {
if (aIdentifier) { if (aIdentifier) {
@ -157,6 +160,7 @@ IPCResult RemoteVideoDecoderParent::RecvConstruct(
mVideoInfo, mKnowsCompositor, mVideoInfo, mKnowsCompositor,
imageContainer, CreateDecoderParams::VideoFrameRate(mFramerate), imageContainer, CreateDecoderParams::VideoFrameRate(mFramerate),
mOptions, CreateDecoderParams::NoWrapper(true), mOptions, CreateDecoderParams::NoWrapper(true),
mMediaEngineId,
}; };
mParent->EnsurePDMFactory().CreateDecoder(params)->Then( mParent->EnsurePDMFactory().CreateDecoder(params)->Then(

Просмотреть файл

@ -39,7 +39,8 @@ class RemoteVideoDecoderChild : public RemoteDecoderChild {
MOZ_IS_CLASS_INIT MediaResult MOZ_IS_CLASS_INIT MediaResult
InitIPDL(const VideoInfo& aVideoInfo, float aFramerate, InitIPDL(const VideoInfo& aVideoInfo, float aFramerate,
const CreateDecoderParams::OptionSet& aOptions, const CreateDecoderParams::OptionSet& aOptions,
mozilla::Maybe<layers::TextureFactoryIdentifier> aIdentifier); mozilla::Maybe<layers::TextureFactoryIdentifier> aIdentifier,
const Maybe<uint64_t>& aMediaEngineId);
MediaResult ProcessOutput(DecodedOutputIPDL&& aDecodedData) override; MediaResult ProcessOutput(DecodedOutputIPDL&& aDecodedData) override;
@ -53,7 +54,8 @@ class RemoteVideoDecoderParent final : public RemoteDecoderParent {
RemoteDecoderManagerParent* aParent, const VideoInfo& aVideoInfo, RemoteDecoderManagerParent* aParent, const VideoInfo& aVideoInfo,
float aFramerate, const CreateDecoderParams::OptionSet& aOptions, float aFramerate, const CreateDecoderParams::OptionSet& aOptions,
const Maybe<layers::TextureFactoryIdentifier>& aIdentifier, const Maybe<layers::TextureFactoryIdentifier>& aIdentifier,
nsISerialEventTarget* aManagerThread, TaskQueue* aDecodeTaskQueue); nsISerialEventTarget* aManagerThread, TaskQueue* aDecodeTaskQueue,
Maybe<uint64_t> aMediaEngineId);
protected: protected:
IPCResult RecvConstruct(ConstructResolver&& aResolver) override; IPCResult RecvConstruct(ConstructResolver&& aResolver) override;

Просмотреть файл

@ -67,6 +67,9 @@ if CONFIG["MOZ_WMF"]:
"MFMediaEngineParent.h", "MFMediaEngineParent.h",
"MFMediaEngineUtils.h", "MFMediaEngineUtils.h",
] ]
LOCAL_INCLUDES += [
"../platforms/wmf",
]
# so we can include nsMacUtilsImpl.h in RDDParent.cpp for sandboxing # so we can include nsMacUtilsImpl.h in RDDParent.cpp for sandboxing
LOCAL_INCLUDES += [ LOCAL_INCLUDES += [

Просмотреть файл

@ -9164,6 +9164,12 @@
value: true value: true
mirror: always mirror: always
# Using Windows Media Foundation Media Engine for encrypted playback
- name: media.wmf.media-engine.enabled
type: RelaxedAtomicBool
value: false
mirror: always
#endif # MOZ_WMF #endif # MOZ_WMF
- name: media.decoder-doctor.testing - name: media.decoder-doctor.testing