DecoderTraits.h (2442B)
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 7 #ifndef DecoderTraits_h_ 8 #define DecoderTraits_h_ 9 10 #include "mozilla/UniquePtr.h" 11 #include "nsStringFwd.h" 12 #include "nsTArray.h" 13 14 namespace mozilla { 15 16 class DecoderDoctorDiagnostics; 17 class MediaContainerType; 18 class MediaDataDemuxer; 19 struct MediaFormatReaderInit; 20 class MediaFormatReader; 21 class MediaResource; 22 class TrackInfo; 23 24 enum CanPlayStatus { CANPLAY_NO, CANPLAY_MAYBE, CANPLAY_YES }; 25 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); 32 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 nsACString& aMIMEType, 38 DecoderDoctorDiagnostics* aDiagnostics); 39 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); 44 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); 49 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); 54 55 // Returns true if aType is MIME type of hls. 56 static bool IsHttpLiveStreamingType(const MediaContainerType& aType); 57 58 // Returns an array of all TrackInfo objects described by this type. 59 static nsTArray<UniquePtr<TrackInfo>> GetTracksInfo( 60 const MediaContainerType& aType); 61 }; 62 63 } // namespace mozilla 64 65 #endif