DecoderTraits.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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. #ifndef DecoderTraits_h_
  7. #define DecoderTraits_h_
  8. #include "nsCOMPtr.h"
  9. class nsAString;
  10. class nsACString;
  11. namespace mozilla {
  12. class AbstractMediaDecoder;
  13. class DecoderDoctorDiagnostics;
  14. class MediaContentType;
  15. class MediaDecoder;
  16. class MediaDecoderOwner;
  17. class MediaDecoderReader;
  18. enum CanPlayStatus {
  19. CANPLAY_NO,
  20. CANPLAY_MAYBE,
  21. CANPLAY_YES
  22. };
  23. class DecoderTraits {
  24. public:
  25. // Returns the CanPlayStatus indicating if we can handle this content type.
  26. static CanPlayStatus CanHandleContentType(const MediaContentType& aContentType,
  27. DecoderDoctorDiagnostics* aDiagnostics);
  28. // Returns true if we should handle this MIME type when it appears
  29. // as an <object> or as a toplevel page. If, in practice, our support
  30. // for the type is more limited than appears in the wild, we should return
  31. // false here even if CanHandleMediaType would return true.
  32. static bool ShouldHandleMediaType(const char* aMIMEType,
  33. DecoderDoctorDiagnostics* aDiagnostics);
  34. // Create a decoder for the given aType. Returns null if we
  35. // were unable to create the decoder.
  36. static already_AddRefed<MediaDecoder> CreateDecoder(const nsACString& aType,
  37. MediaDecoderOwner* aOwner,
  38. DecoderDoctorDiagnostics* aDiagnostics);
  39. // Create a reader for thew given MIME type aType. Returns null
  40. // if we were unable to create the reader.
  41. static MediaDecoderReader* CreateReader(const nsACString& aType,
  42. AbstractMediaDecoder* aDecoder);
  43. // Returns true if MIME type aType is supported in video documents,
  44. // or false otherwise. Not all platforms support all MIME types, and
  45. // vice versa.
  46. static bool IsSupportedInVideoDocument(const nsACString& aType);
  47. static bool IsWebMTypeAndEnabled(const nsACString& aType);
  48. static bool IsWebMAudioType(const nsACString& aType);
  49. static bool IsMP4TypeAndEnabled(const nsACString& aType,
  50. DecoderDoctorDiagnostics* aDiagnostics);
  51. };
  52. } // namespace mozilla
  53. #endif