2012-11-22 07:10:41 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim:set ts=2 sw=2 sts=2 et cindent: */
|
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
|
|
|
#ifndef DecoderTraits_h_
|
|
|
|
#define DecoderTraits_h_
|
|
|
|
|
2018-06-07 17:47:41 +03:00
|
|
|
#include "mozilla/UniquePtr.h"
|
2017-08-17 02:48:52 +03:00
|
|
|
#include "nsStringFwd.h"
|
2018-06-07 17:47:41 +03:00
|
|
|
#include "nsTArray.h"
|
2012-11-22 07:10:41 +04:00
|
|
|
|
2013-03-05 18:56:35 +04:00
|
|
|
namespace mozilla {
|
2013-03-04 19:24:44 +04:00
|
|
|
|
2016-04-19 10:36:19 +03:00
|
|
|
class DecoderDoctorDiagnostics;
|
2017-01-18 03:59:03 +03:00
|
|
|
class MediaContainerType;
|
2019-11-14 19:06:29 +03:00
|
|
|
class MediaDataDemuxer;
|
2017-07-19 17:18:37 +03:00
|
|
|
struct MediaFormatReaderInit;
|
2017-07-19 12:01:32 +03:00
|
|
|
class MediaFormatReader;
|
2019-11-14 19:06:29 +03:00
|
|
|
class MediaResource;
|
2018-06-07 17:47:41 +03:00
|
|
|
class TrackInfo;
|
2013-03-05 18:56:34 +04:00
|
|
|
|
2012-11-22 07:10:41 +04:00
|
|
|
enum CanPlayStatus { CANPLAY_NO, CANPLAY_MAYBE, CANPLAY_YES };
|
|
|
|
|
|
|
|
class DecoderTraits {
|
|
|
|
public:
|
2017-01-18 03:59:03 +03:00
|
|
|
// Returns the CanPlayStatus indicating if we can handle this container type.
|
|
|
|
static CanPlayStatus CanHandleContainerType(
|
|
|
|
const MediaContainerType& aContainerType,
|
|
|
|
DecoderDoctorDiagnostics* aDiagnostics);
|
2016-09-26 09:43:16 +03:00
|
|
|
|
2012-11-22 07:10:41 +04:00
|
|
|
// Returns true if we should handle this MIME type when it appears
|
|
|
|
// as an <object> or as a toplevel page. If, in practice, our support
|
|
|
|
// for the type is more limited than appears in the wild, we should return
|
|
|
|
// false here even if CanHandleMediaType would return true.
|
2016-04-19 10:36:19 +03:00
|
|
|
static bool ShouldHandleMediaType(const char* aMIMEType,
|
|
|
|
DecoderDoctorDiagnostics* aDiagnostics);
|
2012-11-22 07:10:41 +04:00
|
|
|
|
2019-11-14 19:06:29 +03:00
|
|
|
// Create a demuxer for the given MIME type aType. Returns null if we
|
|
|
|
// were unable to create the demuxer.
|
|
|
|
static already_AddRefed<MediaDataDemuxer> CreateDemuxer(
|
|
|
|
const MediaContainerType& aType, MediaResource* aResource);
|
|
|
|
|
2013-03-05 18:56:35 +04:00
|
|
|
// Create a reader for thew given MIME type aType. Returns null
|
|
|
|
// if we were unable to create the reader.
|
2017-07-19 12:01:32 +03:00
|
|
|
static MediaFormatReader* CreateReader(const MediaContainerType& aType,
|
2017-07-19 17:18:37 +03:00
|
|
|
MediaFormatReaderInit& aInit);
|
2013-03-05 18:56:35 +04:00
|
|
|
|
2013-03-05 18:56:35 +04:00
|
|
|
// Returns true if MIME type aType is supported in video documents,
|
|
|
|
// or false otherwise. Not all platforms support all MIME types, and
|
|
|
|
// vice versa.
|
|
|
|
static bool IsSupportedInVideoDocument(const nsACString& aType);
|
2013-09-23 13:53:36 +04:00
|
|
|
|
2017-01-01 04:27:45 +03:00
|
|
|
// Convenience function that returns false if MOZ_FMP4 is not defined,
|
|
|
|
// otherwise defers to MP4Decoder::IsSupportedType().
|
2017-01-18 03:59:03 +03:00
|
|
|
static bool IsMP4SupportedType(const MediaContainerType& aType,
|
2017-01-01 04:27:45 +03:00
|
|
|
DecoderDoctorDiagnostics* aDiagnostics);
|
2017-05-18 09:47:55 +03:00
|
|
|
|
|
|
|
// Returns true if aType is MIME type of hls.
|
|
|
|
static bool IsHttpLiveStreamingType(const MediaContainerType& aType);
|
2017-08-15 08:38:16 +03:00
|
|
|
|
2018-01-12 10:40:52 +03:00
|
|
|
// Returns true if aType is matroska type.
|
|
|
|
static bool IsMatroskaType(const MediaContainerType& aType);
|
|
|
|
|
2018-06-07 17:47:41 +03:00
|
|
|
// Returns an array of all TrackInfo objects described by this type.
|
|
|
|
static nsTArray<UniquePtr<TrackInfo>> GetTracksInfo(
|
|
|
|
const MediaContainerType& aType);
|
2012-11-22 07:10:41 +04:00
|
|
|
};
|
|
|
|
|
2015-07-13 18:25:42 +03:00
|
|
|
} // namespace mozilla
|
2012-11-22 07:10:41 +04:00
|
|
|
|
|
|
|
#endif
|