Bug 1941046 - Part 4: Send a callback request for impression and clicks of MARS Top...
[gecko.git] / dom / media / DecoderTraits.h
blobe574ef63d5254705f7fd5eed5aa3a73a0f725b08
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 // Returns true if aType is MIME type of hls.
56 static bool IsHttpLiveStreamingType(const MediaContainerType& aType);
58 // Returns an array of all TrackInfo objects described by this type.
59 static nsTArray<UniquePtr<TrackInfo>> GetTracksInfo(
60 const MediaContainerType& aType);
63 } // namespace mozilla
65 #endif