Bug 1552145 - Make MediaChangeMonitor by default not try to init decoder until it receives extradata. r=jya

In bug 1538508 we changed the MediaChangeMonitor to raise an error when we try
to create a decoder and we don't yet have the H.264 extra data, to maintain the
assumptions made by OpenH264/WebRTC. This however doesn't play nice with the
HLS demuxer, which won't always give you extra data after a seek.

So change the MediaChangeMonitor to by default assume that it should just drop
frames until it has the extra data it needs to create a decoder. We can flag
this mode off in the WebRTC MediaDataDecoder.

Differential Revision: https://phabricator.services.mozilla.com/D34079

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Chris Pearce 2019-06-07 00:10:35 +00:00
parent d1f4ea261c
commit f782f59b09
4 changed files with 15 additions and 3 deletions

View File

@ -49,6 +49,10 @@ struct MOZ_STACK_CLASS CreateDecoderParams final {
LowLatency,
HardwareDecoderNotAllowed,
FullH264Parsing,
ErrorIfNoInitializationData, // By default frames delivered before
// initialization data are dropped. Pass this
// option to raise an error if frames are
// delivered before initialization data.
SENTINEL // one past the last valid value
};

View File

@ -225,6 +225,8 @@ MediaChangeMonitor::MediaChangeMonitor(PlatformDecoderModule* aPDM,
mDecoder(nullptr),
mGMPCrashHelper(aParams.mCrashHelper),
mLastError(NS_OK),
mErrorIfNoInitializationData(aParams.mOptions.contains(
CreateDecoderParams::Option::ErrorIfNoInitializationData)),
mType(aParams.mType),
mOnWaitingForKeyEvent(aParams.mOnWaitingForKeyEvent),
mDecoderOptions(aParams.mOptions),
@ -289,8 +291,12 @@ RefPtr<MediaDataDecoder::DecodePromise> MediaChangeMonitor::Decode(
if (rv == NS_ERROR_NOT_INITIALIZED) {
// We are missing the required init data to create the decoder.
// This frame can't be decoded and should be treated as an error.
return DecodePromise::CreateAndReject(rv, __func__);
if (mErrorIfNoInitializationData) {
// This frame can't be decoded and should be treated as an error.
return DecodePromise::CreateAndReject(rv, __func__);
}
// Swallow the frame, and await delivery of init data.
return DecodePromise::CreateAndResolve(DecodedData(), __func__);
}
if (rv == NS_ERROR_DOM_MEDIA_INITIALIZING_DECODER) {
// The decoder is pending initialization.

View File

@ -114,6 +114,7 @@ class MediaChangeMonitor : public MediaDataDecoder,
RefPtr<GMPCrashHelper> mGMPCrashHelper;
MediaResult mLastError;
bool mNeedKeyframe = true;
const bool mErrorIfNoInitializationData;
const TrackInfo::TrackType mType;
MediaEventProducer<TrackInfo::TrackType>* const mOnWaitingForKeyEvent;
const CreateDecoderParams::OptionSet mDecoderOptions;

View File

@ -57,7 +57,8 @@ int32_t WebrtcMediaDataDecoder::InitDecode(
{mInfo, mTaskQueue,
CreateDecoderParams::OptionSet(
CreateDecoderParams::Option::LowLatency,
CreateDecoderParams::Option::FullH264Parsing),
CreateDecoderParams::Option::FullH264Parsing,
CreateDecoderParams::Option::ErrorIfNoInitializationData),
mTrackType, mImageContainer, knowsCompositor});
if (!mDecoder) {