Bug 1156708: Part2. Add pref to toggle new code. r=kentuckyfriedtakahe

media.format-reader.mp4=true: Will enable the new format decoder for mp4
media.mediasource.format-reader.mp4=true: Will enable new format decoder for
 mp4 within MSE.
This commit is contained in:
Jean-Yves Avenard 2015-05-18 15:41:22 +10:00
parent 2c142fbf23
commit 84a6a82bf6
5 changed files with 25 additions and 15 deletions

View File

@ -336,7 +336,6 @@ MediaFormatReader::OnDemuxerInitDone(nsresult)
}
mSeekable = mDemuxer->IsSeekable();
mInitDone = true;
// Create demuxer object for main thread.
mMainThreadDemuxer = mDemuxer->Clone();
@ -356,6 +355,8 @@ MediaFormatReader::OnDemuxerInitDone(nsresult)
MOZ_ASSERT(mAudioTrackDemuxer);
}
mInitDone = true;
if (!IsWaitingOnCDMResource() && !EnsureDecodersSetup()) {
mMetadataPromise.Reject(ReadMetadataFailureReason::METADATA_ERROR, __func__);
} else {
@ -1276,19 +1277,11 @@ void MediaFormatReader::ReleaseMediaResources()
}
}
void MediaFormatReader::NotifyResourcesStatusChanged()
{
if (mDecoder) {
mDecoder->NotifyWaitingForResourcesStatusChanged();
}
}
void
MediaFormatReader::SetIdle()
{
if (mSharedDecoderManager && mVideo.mDecoder) {
mSharedDecoderManager->SetIdle(mVideo.mDecoder);
NotifyResourcesStatusChanged();
}
}
@ -1337,6 +1330,7 @@ MediaFormatReader::NotifyDataArrived(const char* aBuffer, uint32_t aLength, int6
return;
}
MOZ_ASSERT(mMainThreadDemuxer);
mMainThreadDemuxer->NotifyDataArrived(aLength, aOffset);
// Queue a task to notify our main demuxer.

View File

@ -138,7 +138,6 @@ private:
void DrainComplete(TrackType aTrack);
bool IsSupportedAudioMimeType(const nsACString& aMimeType);
bool IsSupportedVideoMimeType(const nsACString& aMimeType);
void NotifyResourcesStatusChanged();
bool ShouldSkip(bool aSkipToNextKeyframe, media::TimeUnit aTimeThreshold);
@ -166,9 +165,6 @@ private:
virtual void DrainComplete() override {
mReader->DrainComplete(mType);
}
virtual void NotifyResourcesStatusChanged() override {
mReader->NotifyResourcesStatusChanged();
}
virtual void ReleaseMediaResources() override {
mReader->ReleaseMediaResources();
}

View File

@ -7,6 +7,8 @@
#include "MP4Decoder.h"
#include "MP4Reader.h"
#include "MediaDecoderStateMachine.h"
#include "MediaFormatReader.h"
#include "MP4Demuxer.h"
#include "mozilla/Preferences.h"
#include "nsCharSeparatedTokenizer.h"
#ifdef MOZ_EME
@ -34,7 +36,13 @@ namespace mozilla {
MediaDecoderStateMachine* MP4Decoder::CreateStateMachine()
{
return new MediaDecoderStateMachine(this, new MP4Reader(this));
bool useFormatDecoder =
Preferences::GetBool("media.format-reader.mp4", false);
nsRefPtr<MediaDecoderReader> reader = useFormatDecoder ?
static_cast<MediaDecoderReader*>(new MediaFormatReader(this, new MP4Demuxer(GetResource()))) :
static_cast<MediaDecoderReader*>(new MP4Reader(this));
return new MediaDecoderStateMachine(this, reader);
}
#ifdef MOZ_EME

View File

@ -10,6 +10,7 @@
#include "mozilla/dom/TimeRanges.h"
#include "DecoderTraits.h"
#include "MediaDecoderOwner.h"
#include "MediaFormatReader.h"
#include "MediaSourceDecoder.h"
#include "MediaSourceUtils.h"
#include "SourceBufferDecoder.h"
@ -19,6 +20,7 @@
#ifdef MOZ_FMP4
#include "SharedDecoderManager.h"
#include "MP4Decoder.h"
#include "MP4Demuxer.h"
#include "MP4Reader.h"
#endif
@ -688,7 +690,12 @@ CreateReaderForType(const nsACString& aType, AbstractMediaDecoder* aDecoder)
if ((aType.LowerCaseEqualsLiteral("video/mp4") ||
aType.LowerCaseEqualsLiteral("audio/mp4")) &&
MP4Decoder::IsEnabled() && aDecoder) {
return new MP4Reader(aDecoder);
bool useFormatDecoder =
Preferences::GetBool("media.mediasource.format-reader.mp4", false);
MediaDecoderReader* reader = useFormatDecoder ?
static_cast<MediaDecoderReader*>(new MediaFormatReader(aDecoder, new MP4Demuxer(aDecoder->GetResource()))) :
static_cast<MediaDecoderReader*>(new MP4Reader(aDecoder));
return reader;
}
#endif
return DecoderTraits::CreateReader(aType, aDecoder);

View File

@ -453,6 +453,11 @@ pref("media.mediasource.whitelist", false);
pref("media.mediasource.mp4.enabled", true);
pref("media.mediasource.webm.enabled", false);
// Enable new MediaFormatReader architecture for mp4 in MSE
pref("media.mediasource.format-reader.mp4", false);
// Enable new MediaFormatReader architecture for plain mp4.
pref("media.format-reader.mp4", false);
#ifdef MOZ_WEBSPEECH
pref("media.webspeech.recognition.enable", false);
pref("media.webspeech.synth.enabled", false);