Bug 1344649 - part 5: deprecate ConfigurationChanged() once again. r=jya a=gchang
authorJohn Lin <jolin@mozilla.com>
Tue, 14 Mar 2017 12:58:27 +0800
changeset 395232 534c39cf5079909579615c0c0adbef90b975568c
parent 395231 3facbb51731c2953b8235a65e679d59f9881e059
child 395233 660fe0a12cf60fbb072e01e46b28267a8a9eeb00
push id1468
push userasasaki@mozilla.com
push dateMon, 05 Jun 2017 19:31:07 +0000
treeherdermozilla-release@0641fc6ee9d1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjya, gchang
bugs1344649
milestone54.0a2
Bug 1344649 - part 5: deprecate ConfigurationChanged() once again. r=jya a=gchang 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"); });
@@ -1987,19 +1983,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
@@ -287,19 +287,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) {
@@ -327,16 +324,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
@@ -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;
   }
--- 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;