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(EMEDecoderModule_h_) 8 #define EMEDecoderModule_h_ 9 10 #include "MediaDataDecoderProxy.h" 11 #include "PlatformDecoderModule.h" 12 #include "PlatformDecoderModule.h" 13 #include "SamplesWaitingForKey.h" 14 15 namespace mozilla { 16 17 class CDMProxy; 18 class PDMFactory; 19 20 class EMEDecoderModule : public PlatformDecoderModule { 21 public: 22 EMEDecoderModule(CDMProxy* aProxy, PDMFactory* aPDM); 23 24 protected: 25 // Decode thread. 26 already_AddRefed<MediaDataDecoder> CreateVideoDecoder( 27 const CreateDecoderParams& aParams) override; 28 29 // Decode thread. 30 already_AddRefed<MediaDataDecoder> CreateAudioDecoder( 31 const CreateDecoderParams& aParams) override; 32 33 bool SupportsMimeType(const nsACString& aMimeType, 34 DecoderDoctorDiagnostics* aDiagnostics) const override; 35 36 private: 37 virtual ~EMEDecoderModule(); 38 RefPtr<CDMProxy> mProxy; 39 // Will be null if CDM has decoding capability. 40 RefPtr<PDMFactory> mPDM; 41 }; 42 43 DDLoggedTypeDeclNameAndBase(EMEMediaDataDecoderProxy, MediaDataDecoderProxy); 44 45 class EMEMediaDataDecoderProxy 46 : public MediaDataDecoderProxy, 47 public DecoderDoctorLifeLogger<EMEMediaDataDecoderProxy> { 48 public: 49 EMEMediaDataDecoderProxy(already_AddRefed<AbstractThread> aProxyThread, 50 CDMProxy* aProxy, 51 const CreateDecoderParams& aParams); 52 EMEMediaDataDecoderProxy(const CreateDecoderParams& aParams, 53 already_AddRefed<MediaDataDecoder> aProxyDecoder, 54 CDMProxy* aProxy); 55 56 RefPtr<DecodePromise> Decode(MediaRawData* aSample) override; 57 RefPtr<FlushPromise> Flush() override; 58 RefPtr<ShutdownPromise> Shutdown() override; 59 60 private: 61 RefPtr<TaskQueue> mTaskQueue; 62 RefPtr<SamplesWaitingForKey> mSamplesWaitingForKey; 63 MozPromiseRequestHolder<SamplesWaitingForKey::WaitForKeyPromise> mKeyRequest; 64 MozPromiseHolder<DecodePromise> mDecodePromise; 65 MozPromiseRequestHolder<DecodePromise> mDecodeRequest; 66 RefPtr<CDMProxy> mProxy; 67 }; 68 69 } // namespace mozilla 70 71 #endif // EMEDecoderModule_h_ 72