Bug 1839170 - Refactor Snap pulling, Add Firefox Snap Core22 and GNOME 42 SDK symbols...
[gecko.git] / dom / media / DecoderTraits.h
blob291d3c11928a8022aa149b7c97d603cebf0fbd8e
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/. */
7 #ifndef DecoderTraits_h_
8 #define DecoderTraits_h_
10 #include "mozilla/UniquePtr.h"
11 #include "nsStringFwd.h"
12 #include "nsTArray.h"
14 namespace mozilla {
16 class DecoderDoctorDiagnostics;
17 class MediaContainerType;
18 class MediaDataDemuxer;
19 struct MediaFormatReaderInit;
20 class MediaFormatReader;
21 class MediaResource;
22 class TrackInfo;
24 enum CanPlayStatus { CANPLAY_NO, CANPLAY_MAYBE, CANPLAY_YES };
26 class DecoderTraits {
27 public:
28 // Returns the CanPlayStatus indicating if we can handle this container type.
29 static CanPlayStatus CanHandleContainerType(
30 const MediaContainerType& aContainerType,
31 DecoderDoctorDiagnostics* aDiagnostics);
33 // Returns true if we should handle this MIME type when it appears
34 // as an <object> or as a toplevel page. If, in practice, our support
35 // for the type is more limited than appears in the wild, we should return
36 // false here even if CanHandleMediaType would return true.
37 static bool ShouldHandleMediaType(const char* aMIMEType,
38 DecoderDoctorDiagnostics* aDiagnostics);
40 // Create a demuxer for the given MIME type aType. Returns null if we
41 // were unable to create the demuxer.
42 static already_AddRefed<MediaDataDemuxer> CreateDemuxer(
43 const MediaContainerType& aType, MediaResource* aResource);
45 // Create a reader for thew given MIME type aType. Returns null
46 // if we were unable to create the reader.
47 static MediaFormatReader* CreateReader(const MediaContainerType& aType,
48 MediaFormatReaderInit& aInit);
50 // Returns true if MIME type aType is supported in video documents,
51 // or false otherwise. Not all platforms support all MIME types, and
52 // vice versa.
53 static bool IsSupportedInVideoDocument(const nsACString& aType);
55 // Convenience function that returns false if MOZ_FMP4 is not defined,
56 // otherwise defers to MP4Decoder::IsSupportedType().
57 static bool IsMP4SupportedType(const MediaContainerType& aType,
58 DecoderDoctorDiagnostics* aDiagnostics);
60 // Returns true if aType is MIME type of hls.
61 static bool IsHttpLiveStreamingType(const MediaContainerType& aType);
63 // Returns true if aType is matroska type.
64 static bool IsMatroskaType(const MediaContainerType& aType);
66 // Returns an array of all TrackInfo objects described by this type.
67 static nsTArray<UniquePtr<TrackInfo>> GetTracksInfo(
68 const MediaContainerType& aType);
71 } // namespace mozilla
73 #endif