Bug 1572460 - Refactor `selection` out of the `InspectorFront`. r=yulia
[gecko.git] / dom / media / DecoderTraits.h
blobfdbc27f2fbe5d87a0b3c4fd5c99117f4300c67c7
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 struct MediaFormatReaderInit;
19 class MediaFormatReader;
20 class TrackInfo;
22 enum CanPlayStatus { CANPLAY_NO, CANPLAY_MAYBE, CANPLAY_YES };
24 class DecoderTraits {
25 public:
26 // Returns the CanPlayStatus indicating if we can handle this container type.
27 static CanPlayStatus CanHandleContainerType(
28 const MediaContainerType& aContainerType,
29 DecoderDoctorDiagnostics* aDiagnostics);
31 // Returns true if we should handle this MIME type when it appears
32 // as an <object> or as a toplevel page. If, in practice, our support
33 // for the type is more limited than appears in the wild, we should return
34 // false here even if CanHandleMediaType would return true.
35 static bool ShouldHandleMediaType(const char* aMIMEType,
36 DecoderDoctorDiagnostics* aDiagnostics);
38 // Create a reader for thew given MIME type aType. Returns null
39 // if we were unable to create the reader.
40 static MediaFormatReader* CreateReader(const MediaContainerType& aType,
41 MediaFormatReaderInit& aInit);
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);
48 // Convenience function that returns false if MOZ_FMP4 is not defined,
49 // otherwise defers to MP4Decoder::IsSupportedType().
50 static bool IsMP4SupportedType(const MediaContainerType& aType,
51 DecoderDoctorDiagnostics* aDiagnostics);
53 // Returns true if aType is MIME type of hls.
54 static bool IsHttpLiveStreamingType(const MediaContainerType& aType);
56 // Returns true if aType is matroska type.
57 static bool IsMatroskaType(const MediaContainerType& aType);
59 static bool IsSupportedType(const MediaContainerType& aType);
61 // Returns an array of all TrackInfo objects described by this type.
62 static nsTArray<UniquePtr<TrackInfo>> GetTracksInfo(
63 const MediaContainerType& aType);
66 } // namespace mozilla
68 #endif