Bug 1756260 - part4 : set the media engine Id to the format reader, which would be used to find correct remote decoders. r=jolin

In this patch, we assign the Media Engine Id to the format reader, and append that Id into CreateDecoderParams when we want to create a decoder.

That Id would be used as a hint in order to find a correct decoder to send the data to the remote media engine in following patches.

Depends on D139204

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

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

@ -104,7 +104,7 @@ void ExternalEngineStateMachine::OnEngineInitSuccess() {
mEngine->Id());
mEngineInitRequest.Complete();
ChangeStateTo(State::WaitingMetadata);
// TODO : assign engine ID to reader following patch.
mReader->UpdateMediaEngineId(mEngine->Id());
mReader->ReadMetadata()
->Then(OwnerThread(), __func__, this,
&ExternalEngineStateMachine::OnMetadataRead,

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

@ -376,7 +376,8 @@ void MediaFormatReader::DecoderFactory::DoCreateDecoder(Data& aData) {
p = platform->CreateDecoder(
{*ownerData.GetCurrentInfo()->GetAsAudioInfo(), mOwner->mCrashHelper,
CreateDecoderParams::UseNullDecoder(ownerData.mIsNullDecode),
TrackInfo::kAudioTrack, std::move(onWaitingForKeyEvent)});
TrackInfo::kAudioTrack, std::move(onWaitingForKeyEvent),
mOwner->mMediaEngineId});
break;
}
@ -395,7 +396,8 @@ void MediaFormatReader::DecoderFactory::DoCreateDecoder(Data& aData) {
CreateDecoderParams::VideoFrameRate(ownerData.mMeanRate.Mean()),
OptionSet(ownerData.mHardwareDecodingDisabled
? Option::HardwareDecoderNotAllowed
: Option::Default)});
: Option::Default),
mOwner->mMediaEngineId});
break;
}
@ -3052,6 +3054,12 @@ void MediaFormatReader::NotifyDataArrived() {
->Track(mNotifyDataArrivedPromise);
}
void MediaFormatReader::UpdateMediaEngineId(uint64_t aMediaEngineId) {
MOZ_ASSERT(OnTaskQueue());
LOG("Update external media engine Id %" PRIu64, aMediaEngineId);
mMediaEngineId = Some(aMediaEngineId);
}
void MediaFormatReader::UpdateBuffered() {
AUTO_PROFILER_LABEL("MediaFormatReader::UpdateBuffered", MEDIA_PLAYBACK);
MOZ_ASSERT(OnTaskQueue());

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

@ -133,6 +133,10 @@ class MediaFormatReader final
// mBuffered should be recalculated and updated accordingly.
void NotifyDataArrived();
// Update ID for the external playback engine. Currently it's only used on
// Windows when the media engine playback is enabled.
void UpdateMediaEngineId(uint64_t aMediaEngineId);
protected:
// Recomputes mBuffered.
void UpdateBuffered();
@ -830,6 +834,9 @@ class MediaFormatReader final
bool IsDecoderWaitingForCDM(TrackType aTrack);
void GetDebugInfo(dom::MediaFormatReaderDebugInfo& aInfo);
// Only be used on Windows when the media engine playback is enabled.
Maybe<uint64_t> mMediaEngineId;
};
} // namespace mozilla

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

@ -196,4 +196,14 @@ void ReaderProxy::SetCanonicalDuration(
Unused << rv;
}
void ReaderProxy::UpdateMediaEngineId(uint64_t aMediaEngineId) {
MOZ_ASSERT(mOwnerThread->IsCurrentThreadIn());
nsCOMPtr<nsIRunnable> r = NewRunnableMethod<uint64_t>(
"MediaFormatReader::UpdateMediaEngineId", mReader,
&MediaFormatReader::UpdateMediaEngineId, aMediaEngineId);
nsresult rv = mReader->OwnerThread()->Dispatch(r.forget());
MOZ_DIAGNOSTIC_ASSERT(NS_SUCCEEDED(rv));
Unused << rv;
}
} // namespace mozilla

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

@ -84,6 +84,8 @@ class ReaderProxy {
void SetCanonicalDuration(
AbstractCanonical<media::NullableTimeUnit>* aCanonical);
void UpdateMediaEngineId(uint64_t aMediaEngineId);
private:
~ReaderProxy();
RefPtr<MetadataPromise> OnMetadataRead(MetadataHolder&& aMetadata);

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

@ -22,7 +22,8 @@ CreateDecoderParamsForAsync::CreateDecoderParamsForAsync(
mType(aParams.mType),
mOnWaitingForKeyEvent(aParams.mOnWaitingForKeyEvent),
mOptions(aParams.mOptions),
mRate(aParams.mRate) {}
mRate(aParams.mRate),
mMediaEngineId(aParams.mMediaEngineId) {}
CreateDecoderParamsForAsync::CreateDecoderParamsForAsync(
CreateDecoderParamsForAsync&& aParams) = default;

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

@ -108,6 +108,7 @@ struct CreateDecoderParamsForAsync {
mOnWaitingForKeyEvent;
const OptionSet mOptions = OptionSet(Option::Default);
const media::VideoFrameRate mRate;
const Maybe<uint64_t> mMediaEngineId;
};
struct MOZ_STACK_CLASS CreateDecoderParams final {
@ -130,7 +131,8 @@ struct MOZ_STACK_CLASS CreateDecoderParams final {
mType(aParams.mType),
mOnWaitingForKeyEvent(aParams.mOnWaitingForKeyEvent),
mOptions(aParams.mOptions),
mRate(aParams.mRate) {}
mRate(aParams.mRate),
mMediaEngineId(aParams.mMediaEngineId) {}
template <typename T1, typename... Ts>
CreateDecoderParams(const TrackInfo& aConfig, T1&& a1, Ts&&... args)
@ -176,6 +178,8 @@ struct MOZ_STACK_CLASS CreateDecoderParams final {
mOnWaitingForKeyEvent;
OptionSet mOptions = OptionSet(Option::Default);
media::VideoFrameRate mRate;
// Used on Windows when the MF media engine playback is enabled.
Maybe<uint64_t> mMediaEngineId;
private:
void Set(layers::ImageContainer* aImageContainer) {
@ -204,6 +208,9 @@ struct MOZ_STACK_CLASS CreateDecoderParams final {
aOnWaitingForKey) {
mOnWaitingForKeyEvent = aOnWaitingForKey;
}
void Set(const Maybe<uint64_t>& aMediaEngineId) {
mMediaEngineId = aMediaEngineId;
}
void Set(const CreateDecoderParams& aParams) {
// Set all but mTrackInfo;
mImageContainer = aParams.mImageContainer;
@ -216,6 +223,7 @@ struct MOZ_STACK_CLASS CreateDecoderParams final {
mOnWaitingForKeyEvent = aParams.mOnWaitingForKeyEvent;
mOptions = aParams.mOptions;
mRate = aParams.mRate;
mMediaEngineId = aParams.mMediaEngineId;
}
template <typename T1, typename T2, typename... Ts>
void Set(T1&& a1, T2&& a2, Ts&&... args) {
@ -240,7 +248,8 @@ struct MOZ_STACK_CLASS SupportDecoderParams final {
mUseNullDecoder(aParams.mUseNullDecoder),
mNoWrapper(aParams.mNoWrapper),
mOptions(aParams.mOptions),
mRate(aParams.mRate) {}
mRate(aParams.mRate),
mMediaEngineId(aParams.mMediaEngineId) {}
template <typename T1, typename... Ts>
SupportDecoderParams(const TrackInfo& aConfig, T1&& a1, Ts&&... args)
@ -258,6 +267,7 @@ struct MOZ_STACK_CLASS SupportDecoderParams final {
NoWrapper mNoWrapper;
OptionSet mOptions = OptionSet(Option::Default);
VideoFrameRate mRate;
Maybe<uint64_t> mMediaEngineId;
private:
void Set(DecoderDoctorDiagnostics* aDiagnostics) {
@ -276,6 +286,9 @@ struct MOZ_STACK_CLASS SupportDecoderParams final {
MOZ_ASSERT(aKnowsCompositor->IsThreadSafe());
}
}
void Set(const Maybe<uint64_t>& aMediaEngineId) {
mMediaEngineId = aMediaEngineId;
}
template <typename T1, typename T2, typename... Ts>
void Set(T1&& a1, T2&& a2, Ts&&... args) {