Bug 1339748: P1. Proxify all MediaDataDecoder's APIs. r?cpearce draft
authorJean-Yves Avenard <jyavenard@mozilla.com>
Fri, 17 Feb 2017 14:03:51 +0100
changeset 486552 129561d536911969ad0ecb0f5b8030bc1024f8f9
parent 486551 b4edeabe251bea191ee67f61042fe4cf00fbdc78
child 486553 c66d5cd4c524d9f786f33266bfdbd2f44be2d87c
child 486566 23a85bd06bcbf3bb9c036d16996ad1f8cef0e809
push id46021
push userbmo:jyavenard@mozilla.com
push dateSat, 18 Feb 2017 13:35:21 +0000
reviewerscpearce
bugs1339748
milestone54.0a1
Bug 1339748: P1. Proxify all MediaDataDecoder's APIs. r?cpearce MozReview-Commit-ID: G5BXkD3siNL
dom/media/platforms/wrappers/MediaDataDecoderProxy.cpp
dom/media/platforms/wrappers/MediaDataDecoderProxy.h
--- a/dom/media/platforms/wrappers/MediaDataDecoderProxy.cpp
+++ b/dom/media/platforms/wrappers/MediaDataDecoderProxy.cpp
@@ -61,21 +61,77 @@ MediaDataDecoderProxy::Drain()
   return InvokeAsync(mProxyThread, __func__,
                      [self, this]() { return mProxyDecoder->Drain(); });
 }
 
 RefPtr<ShutdownPromise>
 MediaDataDecoderProxy::Shutdown()
 {
   MOZ_ASSERT(!mIsShutdown);
+
 #if defined(DEBUG)
   mIsShutdown = true;
 #endif
 
   if (!mProxyThread) {
     return mProxyDecoder->Shutdown();
   }
   RefPtr<MediaDataDecoderProxy> self = this;
   return InvokeAsync(mProxyThread, __func__,
                      [self, this]() { return mProxyDecoder->Shutdown(); });
 }
 
+const char*
+MediaDataDecoderProxy::GetDescriptionName() const
+{
+  MOZ_ASSERT(!mIsShutdown);
+
+  return mProxyDecoder->GetDescriptionName();
+}
+
+bool
+MediaDataDecoderProxy::IsHardwareAccelerated(nsACString& aFailureReason) const
+{
+  MOZ_ASSERT(!mIsShutdown);
+
+  return mProxyDecoder->IsHardwareAccelerated(aFailureReason);
+}
+
+void
+MediaDataDecoderProxy::SetSeekThreshold(const media::TimeUnit& aTime)
+{
+  MOZ_ASSERT(!mIsShutdown);
+
+  if (!mProxyThread) {
+    mProxyDecoder->SetSeekThreshold(aTime);
+    return;
+  }
+  RefPtr<MediaDataDecoderProxy> self = this;
+  media::TimeUnit time = aTime;
+  mProxyThread->Dispatch(NS_NewRunnableFunction(
+    [self, time] { self->mProxyDecoder->SetSeekThreshold(time); }));
+}
+
+bool
+MediaDataDecoderProxy::SupportDecoderRecycling() const
+{
+  MOZ_ASSERT(!mIsShutdown);
+
+  return mProxyDecoder->SupportDecoderRecycling();
+}
+
+void
+MediaDataDecoderProxy::ConfigurationChanged(const TrackInfo& aConfig)
+{
+  MOZ_ASSERT(!mIsShutdown);
+
+  if (!mProxyThread) {
+    mProxyDecoder->ConfigurationChanged(aConfig);
+  }
+  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);
+  }));
+}
+
 } // namespace mozilla
--- a/dom/media/platforms/wrappers/MediaDataDecoderProxy.h
+++ b/dom/media/platforms/wrappers/MediaDataDecoderProxy.h
@@ -41,21 +41,21 @@ public:
     mProxyDecoder = aProxyDecoder;
   }
 
   RefPtr<InitPromise> Init() override;
   RefPtr<DecodePromise> Decode(MediaRawData* aSample) override;
   RefPtr<DecodePromise> Drain() override;
   RefPtr<FlushPromise> Flush() override;
   RefPtr<ShutdownPromise> Shutdown() override;
-
-  const char* GetDescriptionName() const override
-  {
-    return mProxyDecoder->GetDescriptionName();
-  }
+  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;
 
 private:
   RefPtr<MediaDataDecoder> mProxyDecoder;
   RefPtr<AbstractThread> mProxyThread;
 
 #if defined(DEBUG)
   Atomic<bool> mIsShutdown;
 #endif