tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

AndroidDecoderModule.h (3091B)


      1 /* This Source Code Form is subject to the terms of the Mozilla Public
      2 * License, v. 2.0. If a copy of the MPL was not distributed with this
      3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
      4 
      5 #ifndef AndroidDecoderModule_h_
      6 #define AndroidDecoderModule_h_
      7 
      8 #include "MediaCodecsSupport.h"
      9 #include "PlatformDecoderModule.h"
     10 #include "mozilla/MediaDrmCDMProxy.h"
     11 #include "mozilla/StaticPtr.h"  // for StaticAutoPtr
     12 
     13 namespace mozilla {
     14 
     15 class AndroidDecoderModule : 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 "Android MediaCodec w/ proxy"; }
     21  static already_AddRefed<PlatformDecoderModule> Create(
     22      CDMProxy* aProxy = nullptr);
     23 
     24  already_AddRefed<MediaDataDecoder> CreateVideoDecoder(
     25      const CreateDecoderParams& aParams) override;
     26 
     27  already_AddRefed<MediaDataDecoder> CreateAudioDecoder(
     28      const CreateDecoderParams& aParams) override;
     29 
     30  media::DecodeSupportSet SupportsMimeType(
     31      const nsACString& aMimeType,
     32      DecoderDoctorDiagnostics* aDiagnostics) const override;
     33 
     34  static media::DecodeSupportSet SupportsMimeType(const nsACString& aMimeType);
     35 
     36  static nsTArray<nsCString> GetSupportedMimeTypes();
     37  // Like GetSupportedMimeTypes, but adds SW/HW prefix to indicate accel support
     38  static nsTArray<nsCString> GetSupportedMimeTypesPrefixed();
     39 
     40  static void SetSupportedMimeTypes();
     41  static void SetSupportedMimeTypes(nsTArray<nsCString>&& aSupportedTypes);
     42 
     43  media::DecodeSupportSet Supports(
     44      const SupportDecoderParams& aParams,
     45      DecoderDoctorDiagnostics* aDiagnostics) const override;
     46 
     47  // Return supported codecs (querying via JNI if not already cached)
     48  static media::MediaCodecsSupported GetSupportedCodecs();
     49 
     50  static bool IsJavaDecoderModuleAllowed();
     51 
     52 protected:
     53  bool SupportsColorDepth(
     54      gfx::ColorDepth aColorDepth,
     55      DecoderDoctorDiagnostics* aDiagnostics) const override;
     56 
     57 private:
     58  explicit AndroidDecoderModule(CDMProxy* aProxy = nullptr);
     59  virtual ~AndroidDecoderModule() = default;
     60 
     61  static bool AreSupportedMimeTypesReady();
     62  static bool IsSupportedCodecsReady();
     63 
     64  RefPtr<MediaDrmCDMProxy> mProxy;
     65  // SW compatible MIME type strings
     66  static inline StaticAutoPtr<nsTArray<nsCString>> sSupportedSwMimeTypes
     67      MOZ_GUARDED_BY(sMutex);
     68  // HW compatible MIME type strings
     69  static inline StaticAutoPtr<nsTArray<nsCString>> sSupportedHwMimeTypes
     70      MOZ_GUARDED_BY(sMutex);
     71  // EnumSet containing SW/HW codec support information parsed from
     72  // MIME type strings. If a specific codec could not be determined
     73  // it will not be included in this EnumSet. All supported MIME type strings
     74  // are still stored in sSupportedSwMimeTypes and sSupportedHwMimeTypes.
     75  static inline StaticAutoPtr<media::MediaCodecsSupported> sSupportedCodecs
     76      MOZ_GUARDED_BY(sMutex);
     77 
     78  static inline StaticMutex sMutex;
     79 };
     80 
     81 extern LazyLogModule sAndroidDecoderModuleLog;
     82 
     83 nsCString TranslateMimeType(const nsACString& aMimeType);
     84 
     85 }  // namespace mozilla
     86 
     87 #endif