Skip to content

Commit

Permalink
Bug 1552145 - Make MediaChangeMonitor by default not try to init deco…
Browse files Browse the repository at this point in the history
…der 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
  • Loading branch information
Chris Pearce committed Jun 7, 2019
1 parent 14465d4 commit 96947e1
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 3 deletions.
4 changes: 4 additions & 0 deletions dom/media/platforms/PlatformDecoderModule.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
};
Expand Down
10 changes: 8 additions & 2 deletions dom/media/platforms/wrappers/MediaChangeMonitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down Expand Up @@ -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.
Expand Down
1 change: 1 addition & 0 deletions dom/media/platforms/wrappers/MediaChangeMonitor.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 96947e1

Please sign in to comment.