Bug 1344649 - part 4: deprecate ConfigurationChanged() once again. r?jya
MozReview-Commit-ID: 4QuG2iLFbHF
--- a/dom/media/MediaFormatReader.cpp
+++ b/dom/media/MediaFormatReader.cpp
@@ -560,20 +560,16 @@ public:
void SetSeekThreshold(const media::TimeUnit& aTime) override
{
mDecoder->SetSeekThreshold(aTime);
}
bool SupportDecoderRecycling() const override
{
return mDecoder->SupportDecoderRecycling();
}
- void ConfigurationChanged(const TrackInfo& aConfig) override
- {
- mDecoder->ConfigurationChanged(aConfig);
- }
RefPtr<ShutdownPromise> Shutdown() override
{
RefPtr<MediaDataDecoder> decoder = mDecoder.forget();
RefPtr<Token> token = mToken.forget();
return decoder->Shutdown()->Then(
AbstractThread::GetCurrent(), __func__,
[token]() {},
[token]() { MOZ_RELEASE_ASSERT(false, "Can't reach here"); });
@@ -1986,19 +1982,16 @@ MediaFormatReader::HandleDemuxedSamples(
LOG("Decoder does not support recycling, recreate decoder.");
// If flushing is required, it will clear our array of queued samples.
// So make a copy now.
nsTArray<RefPtr<MediaRawData>> samples{ Move(decoder.mQueuedSamples) };
ShutdownDecoder(aTrack);
if (sample->mKeyframe) {
decoder.mQueuedSamples.AppendElements(Move(samples));
}
- } else if (decoder.mInfo && *decoder.mInfo != *info) {
- const TrackInfo* trackInfo = *info;
- decoder.mDecoder->ConfigurationChanged(*trackInfo);
}
decoder.mInfo = info;
if (sample->mKeyframe) {
ScheduleUpdate(aTrack);
} else {
TimeInterval time =
--- a/dom/media/platforms/PlatformDecoderModule.h
+++ b/dom/media/platforms/PlatformDecoderModule.h
@@ -292,30 +292,16 @@ public:
virtual void SetSeekThreshold(const media::TimeUnit& aTime) { }
// When playing adaptive playback, recreating an Android video decoder will
// cause the transition not smooth during resolution change.
// Reuse the decoder if the decoder support recycling.
// Currently, only Android video decoder will return true.
virtual bool SupportDecoderRecycling() const { return false; }
- // ConfigurationChanged will be called to inform the video or audio decoder
- // that the format of the next input sample is about to change.
- // If video decoder, aConfig will be a VideoInfo object.
- // If audio decoder, aConfig will be a AudioInfo object.
- // It is not safe to store a reference to this object and the decoder must
- // make a copy.
- // Care should be taken as ConfigurationChanged is called on the reader's
- // taskqueue.
- virtual void ConfigurationChanged(const TrackInfo& aConfig)
- {
- MOZ_ASSERT(SupportDecoderRecycling(),
- "Can only work with a decoder supporting recycling.");
- }
-
enum class ConversionRequired
{
kNeedNone = 0,
kNeedAVCC = 1,
kNeedAnnexB = 2,
};
// Indicates that the decoder requires a specific format.
--- a/dom/media/platforms/wrappers/H264Converter.cpp
+++ b/dom/media/platforms/wrappers/H264Converter.cpp
@@ -14,17 +14,16 @@
#include "mp4_demuxer/H264.h"
namespace mozilla
{
H264Converter::H264Converter(PlatformDecoderModule* aPDM,
const CreateDecoderParams& aParams)
: mPDM(aPDM)
- , mOriginalConfig(aParams.VideoConfig())
, mCurrentConfig(aParams.VideoConfig())
, mKnowsCompositor(aParams.mKnowsCompositor)
, mImageContainer(aParams.mImageContainer)
, mTaskQueue(aParams.mTaskQueue)
, mDecoder(nullptr)
, mGMPCrashHelper(aParams.mCrashHelper)
, mLastError(NS_OK)
, mType(aParams.mType)
@@ -199,33 +198,32 @@ H264Converter::CreateDecoder(DecoderDoct
}
} else {
// SPS was invalid.
mLastError = NS_ERROR_FAILURE;
return NS_ERROR_FAILURE;
}
mDecoder = mPDM->CreateVideoDecoder({
- mUseOriginalConfig ? mOriginalConfig : mCurrentConfig,
+ mCurrentConfig,
mTaskQueue,
aDiagnostics,
mImageContainer,
mKnowsCompositor,
mGMPCrashHelper,
mType,
mOnWaitingForKeyEvent,
mDecoderOptions
});
if (!mDecoder) {
mLastError = NS_ERROR_FAILURE;
return NS_ERROR_FAILURE;
}
- mUseOriginalConfig = false;
mNeedKeyframe = true;
return NS_OK;
}
nsresult
H264Converter::CreateDecoderAndInit(MediaRawData* aSample)
{
@@ -285,19 +283,17 @@ H264Converter::DecodeFirstSample(MediaRa
if (!*mNeedAVCC
&& !mp4_demuxer::AnnexB::ConvertSampleToAnnexB(aSample, mNeedKeyframe)) {
mDecodePromise.Reject(
MediaResult(NS_ERROR_OUT_OF_MEMORY,
RESULT_DETAIL("ConvertSampleToAnnexB")),
__func__);
return;
}
- if (CanRecycleDecoder()) {
- mDecoder->ConfigurationChanged(mCurrentConfig);
- }
+
RefPtr<H264Converter> self = this;
mDecoder->Decode(aSample)
->Then(AbstractThread::GetCurrent()->AsTaskQueue(), __func__,
[self, this](const MediaDataDecoder::DecodedData& aResults) {
mDecodePromiseRequest.Complete();
mDecodePromise.Resolve(aResults, __func__);
},
[self, this](const MediaResult& aError) {
--- a/dom/media/platforms/wrappers/H264Converter.h
+++ b/dom/media/platforms/wrappers/H264Converter.h
@@ -43,22 +43,17 @@ public:
void SetSeekThreshold(const media::TimeUnit& aTime) override;
bool SupportDecoderRecycling() const override
{
if (mDecoder) {
return mDecoder->SupportDecoderRecycling();
}
return false;
}
- void ConfigurationChanged(const TrackInfo& aConfig) override
- {
- if (mDecoder && mDecoder->SupportDecoderRecycling()) {
- mDecoder->ConfigurationChanged(aConfig);
- }
- }
+
ConversionRequired NeedsConversion() const override
{
if (mDecoder) {
return mDecoder->NeedsConversion();
}
// Default so no conversion is performed.
return ConversionRequired::kNeedAVCC;
}
@@ -81,17 +76,16 @@ private:
MOZ_ASSERT(mDecoder);
return MediaPrefs::MediaDecoderCheckRecycling()
&& mDecoder->SupportDecoderRecycling();
}
void DecodeFirstSample(MediaRawData* aSample);
RefPtr<PlatformDecoderModule> mPDM;
- const VideoInfo mOriginalConfig;
VideoInfo mCurrentConfig;
RefPtr<layers::KnowsCompositor> mKnowsCompositor;
RefPtr<layers::ImageContainer> mImageContainer;
const RefPtr<TaskQueue> mTaskQueue;
RefPtr<MediaRawData> mPendingSample;
RefPtr<MediaDataDecoder> mDecoder;
MozPromiseRequestHolder<InitPromise> mInitPromiseRequest;
MozPromiseRequestHolder<DecodePromise> mDecodePromiseRequest;
@@ -99,18 +93,16 @@ private:
MozPromiseRequestHolder<FlushPromise> mFlushRequest;
MozPromiseRequestHolder<ShutdownPromise> mShutdownRequest;
RefPtr<ShutdownPromise> mShutdownPromise;
RefPtr<GMPCrashHelper> mGMPCrashHelper;
Maybe<bool> mNeedAVCC;
nsresult mLastError;
bool mNeedKeyframe = true;
- // Set to true once a decoder has been created.
- bool mUseOriginalConfig = true;
const TrackInfo::TrackType mType;
MediaEventProducer<TrackInfo::TrackType>* const mOnWaitingForKeyEvent;
const CreateDecoderParams::OptionSet mDecoderOptions;
};
} // namespace mozilla
#endif // mozilla_H264Converter_h
--- a/dom/media/platforms/wrappers/MediaDataDecoderProxy.cpp
+++ b/dom/media/platforms/wrappers/MediaDataDecoderProxy.cpp
@@ -113,33 +113,16 @@ MediaDataDecoderProxy::SetSeekThreshold(
bool
MediaDataDecoderProxy::SupportDecoderRecycling() const
{
MOZ_ASSERT(!mIsShutdown);
return mProxyDecoder->SupportDecoderRecycling();
}
-void
-MediaDataDecoderProxy::ConfigurationChanged(const TrackInfo& aConfig)
-{
- MOZ_ASSERT(!mIsShutdown);
-
- if (!mProxyThread) {
- mProxyDecoder->ConfigurationChanged(aConfig);
- return;
- }
- RefPtr<MediaDataDecoderProxy> self = this;
- RefPtr<TrackInfoSharedPtr> config = new TrackInfoSharedPtr(aConfig, 0);
- mProxyThread->Dispatch(NS_NewRunnableFunction([self, config] {
- const TrackInfo* trackInfo = *config;
- self->mProxyDecoder->ConfigurationChanged(*trackInfo);
- }));
-}
-
MediaDataDecoder::ConversionRequired
MediaDataDecoderProxy::NeedsConversion() const
{
MOZ_ASSERT(!mIsShutdown);
return mProxyDecoder->NeedsConversion();
}
--- a/dom/media/platforms/wrappers/MediaDataDecoderProxy.h
+++ b/dom/media/platforms/wrappers/MediaDataDecoderProxy.h
@@ -45,17 +45,16 @@ public:
RefPtr<DecodePromise> Decode(MediaRawData* aSample) override;
RefPtr<DecodePromise> Drain() override;
RefPtr<FlushPromise> Flush() override;
RefPtr<ShutdownPromise> Shutdown() override;
const char* GetDescriptionName() const override;
bool IsHardwareAccelerated(nsACString& aFailureReason) const override;
void SetSeekThreshold(const media::TimeUnit& aTime) override;
bool SupportDecoderRecycling() const override;
- void ConfigurationChanged(const TrackInfo& aConfig) override;
ConversionRequired NeedsConversion() const override;
private:
RefPtr<MediaDataDecoder> mProxyDecoder;
RefPtr<AbstractThread> mProxyThread;
#if defined(DEBUG)
Atomic<bool> mIsShutdown;