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
async PRemoteDecoder(RemoteDecoderInfoIPDL info,
OptionSet options,
TextureFactoryIdentifier? identifier);
TextureFactoryIdentifier? identifier,
uint64_t? mediaEngineId);
sync Readback(SurfaceDescriptorGPUVideo sd) returns (SurfaceDescriptor aResult);

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

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

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

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

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

@ -269,18 +269,26 @@ RemoteDecoderManagerChild::CreateAudioDecoder(
return PlatformDecoderModule::CreateDecoderPromise::CreateAndReject(
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 =
(StaticPrefs::media_utility_process_enabled() &&
aLocation == RemoteDecodeIn::UtilityProcess)
? LaunchUtilityProcessIfNeeded()
: LaunchRDDProcessIfNeeded();
useUtilityAudioDecoding ? LaunchUtilityProcessIfNeeded()
: LaunchRDDProcessIfNeeded();
return launchPromise->Then(
managerThread, __func__,
[params = CreateDecoderParamsForAsync(aParams), aLocation](bool) {
auto child = MakeRefPtr<RemoteAudioDecoderChild>();
MediaResult result =
child->InitIPDL(params.AudioConfig(), params.mOptions);
MediaResult result = child->InitIPDL(
params.AudioConfig(), params.mOptions, params.mMediaEngineId);
if (NS_FAILED(result)) {
return PlatformDecoderModule::CreateDecoderPromise::CreateAndReject(
result, __func__);
@ -332,7 +340,8 @@ RemoteDecoderManagerChild::CreateVideoDecoder(
params.VideoConfig(), params.mRate.mValue, params.mOptions,
params.mKnowsCompositor
? Some(params.mKnowsCompositor->GetTextureFactoryIdentifier())
: Nothing());
: Nothing(),
params.mMediaEngineId);
if (NS_FAILED(result)) {
return PlatformDecoderModule::CreateDecoderPromise::CreateAndReject(
result, __func__);
@ -548,7 +557,8 @@ RemoteDecoderManagerChild::LaunchUtilityProcessIfNeeded() {
PRemoteDecoderChild* RemoteDecoderManagerChild::AllocPRemoteDecoderChild(
const RemoteDecoderInfoIPDL& /* not used */,
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
// classes.
MOZ_ASSERT(false,

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

@ -9164,6 +9164,12 @@
value: true
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
- name: media.decoder-doctor.testing