Bug 1344649 - part 5: deprecate ConfigurationChanged() once again. r?jya draft
authorJohn Lin <jolin@mozilla.com>
Tue, 14 Mar 2017 12:58:27 +0800
changeset 497996 2e31b72a1d7e9bdc5b7a6b1e0107c142e492fb19
parent 497994 7b7dcc98d0d855d35d127712fd080a0bc4ef5796
child 498050 261d62d8e405114575bd84380d0cf0e13b6964fb
child 498072 765b8a96bccab40b274d8b22e1ea591f886640bf
push id49081
push userbmo:jolin@mozilla.com
push dateTue, 14 Mar 2017 04:59:46 +0000
reviewersjya
bugs1344649
milestone55.0a1
Bug 1344649 - part 5: deprecate ConfigurationChanged() once again. r?jya MozReview-Commit-ID: D9b8rljlNzP
dom/media/MediaFormatReader.cpp
dom/media/platforms/PlatformDecoderModule.h
dom/media/platforms/wrappers/H264Converter.cpp
dom/media/platforms/wrappers/H264Converter.h
dom/media/platforms/wrappers/MediaDataDecoderProxy.cpp
dom/media/platforms/wrappers/MediaDataDecoderProxy.h
--- 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
@@ -297,19 +297,16 @@ H264Converter::DecodeFirstSample(MediaRa
       MediaResult(NS_ERROR_OUT_OF_MEMORY,
                   RESULT_DETAIL("ConvertSampleToAnnexB")),
       __func__);
     return;
   }
 
   mNeedKeyframe = false;
 
-  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) {
@@ -337,16 +334,19 @@ H264Converter::CheckForSPSChange(MediaRa
     UpdateConfigFromExtraData(extra_data);
     // Ideally we would want to drain the decoder instead of flushing it.
     // However the draining operation requires calling Drain and looping several
     // times which isn't possible from within the H264Converter. So instead we
     // flush the decoder. In practice, this is a no-op as SPS change will only
     // be used with MSE. And with MSE, the MediaFormatReader would have drained
     // the decoder already.
     RefPtr<H264Converter> self = this;
+    if (!sample->mTrackInfo) {
+      sample->mTrackInfo = new TrackInfoSharedPtr(mCurrentConfig, 0);
+    }
     mDecoder->Flush()
       ->Then(AbstractThread::GetCurrent()->AsTaskQueue(),
              __func__,
              [self, sample, this]() {
                mFlushRequest.Complete();
                DecodeFirstSample(sample);
              },
              [self, this](const MediaResult& aError) {
--- a/dom/media/platforms/wrappers/H264Converter.h
+++ b/dom/media/platforms/wrappers/H264Converter.h
@@ -45,22 +45,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;
   }
--- 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;