Bug 1339748: P1. Proxify all MediaDataDecoder's APIs. r?cpearce
MozReview-Commit-ID: G5BXkD3siNL
--- 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