MediaDataDecoderProxy.h (2378B)
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 2 /* vim:set ts=2 sw=2 sts=2 et cindent: */ 3 /* This Source Code Form is subject to the terms of the Mozilla Public 4 * License, v. 2.0. If a copy of the MPL was not distributed with this 5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 6 7 #if !defined(MediaDataDecoderProxy_h_) 8 # define MediaDataDecoderProxy_h_ 9 10 # include "PlatformDecoderModule.h" 11 # include "mozilla/Atomics.h" 12 # include "mozilla/RefPtr.h" 13 # include "nsThreadUtils.h" 14 # include "nscore.h" 15 16 namespace mozilla { 17 18 DDLoggedTypeDeclNameAndBase(MediaDataDecoderProxy, MediaDataDecoder); 19 20 class MediaDataDecoderProxy 21 : public MediaDataDecoder, 22 public DecoderDoctorLifeLogger<MediaDataDecoderProxy> { 23 public: 24 NS_INLINE_DECL_THREADSAFE_REFCOUNTING(MediaDataDecoderProxy, final); 25 26 explicit MediaDataDecoderProxy( 27 already_AddRefed<MediaDataDecoder> aProxyDecoder, 28 already_AddRefed<nsISerialEventTarget> aProxyThread = nullptr) 29 : mProxyDecoder(aProxyDecoder), mProxyThread(aProxyThread) { 30 DDLINKCHILD("proxy decoder", mProxyDecoder.get()); 31 } 32 33 RefPtr<InitPromise> Init() override; 34 RefPtr<DecodePromise> Decode(MediaRawData* aSample) override; 35 bool CanDecodeBatch() const override; 36 RefPtr<DecodePromise> DecodeBatch( 37 nsTArray<RefPtr<MediaRawData>>&& aSamples) override; 38 RefPtr<DecodePromise> Drain() override; 39 RefPtr<FlushPromise> Flush() override; 40 RefPtr<ShutdownPromise> Shutdown() override; 41 bool IsHardwareAccelerated(nsACString& aFailureReason) const override; 42 nsCString GetDescriptionName() const override; 43 nsCString GetProcessName() const override; 44 nsCString GetCodecName() const override; 45 void SetSeekThreshold(const media::TimeUnit& aTime) override; 46 bool SupportDecoderRecycling() const override; 47 bool ShouldDecoderAlwaysBeRecycled() const override; 48 ConversionRequired NeedsConversion() const override; 49 Maybe<PropertyValue> GetDecodeProperty(PropertyName aName) const override; 50 51 protected: 52 ~MediaDataDecoderProxy() = default; 53 54 private: 55 // Set on construction and clear on the proxy thread if set. 56 RefPtr<MediaDataDecoder> mProxyDecoder; 57 const nsCOMPtr<nsISerialEventTarget> mProxyThread; 58 59 # if defined(DEBUG) 60 Atomic<bool> mIsShutdown = Atomic<bool>(false); 61 # endif 62 }; 63 64 } // namespace mozilla 65 66 #endif // MediaDataDecoderProxy_h_