AppleDecoderModule.h (2293B)
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 #ifndef mozilla_AppleDecoderModule_h 8 #define mozilla_AppleDecoderModule_h 9 10 #include "MediaCodecsSupport.h" 11 #include "PlatformDecoderModule.h" 12 13 namespace mozilla { 14 15 class AppleDecoderModule : public PlatformDecoderModule { 16 template <typename T, typename... Args> 17 friend already_AddRefed<T> MakeAndAddRef(Args&&...); 18 19 public: 20 const char* Name() const override { return "Apple"; } 21 static already_AddRefed<PlatformDecoderModule> Create(); 22 23 nsresult Startup() override; 24 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 media::DecodeSupportSet SupportsMimeType( 34 const nsACString& aMimeType, 35 DecoderDoctorDiagnostics* aDiagnostics) const override; 36 37 media::DecodeSupportSet Supports( 38 const SupportDecoderParams& aParams, 39 DecoderDoctorDiagnostics* aDiagnostics) const override; 40 41 static void Init(); 42 43 static constexpr int kCMVideoCodecType_H264{'avc1'}; 44 static constexpr int kCMVideoCodecType_VP9{'vp09'}; 45 46 private: 47 AppleDecoderModule() = default; 48 virtual ~AppleDecoderModule() = default; 49 50 static inline bool sInitialized = false; 51 static inline EnumeratedArray<media::MediaCodec, bool, 52 size_t(media::MediaCodec::SENTINEL)> 53 sCanUseHWDecoder; 54 55 bool IsVideoSupported(const VideoInfo& aConfig, 56 const CreateDecoderParams::OptionSet& aOptions = 57 CreateDecoderParams::OptionSet()) const; 58 // Register a HW decoder if it's not registered by default. 59 static bool RegisterSupplementalDecoder(const media::MediaCodec& aCodec); 60 // Return true if a dummy hardware decoder could be created. 61 static bool CanCreateHWDecoder(const media::MediaCodec& aCodec); 62 }; 63 64 } // namespace mozilla 65 66 #endif // mozilla_AppleDecoderModule_h