2012-11-22 03:10:41 +00: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_
|
|
|
|
|
2013-03-05 14:56:34 +00:00
|
|
|
#include "nsCOMPtr.h"
|
2013-09-05 20:25:17 +00:00
|
|
|
|
|
|
|
class nsAString;
|
|
|
|
class nsACString;
|
2012-11-22 03:10:41 +00:00
|
|
|
|
2013-03-05 14:56:35 +00:00
|
|
|
namespace mozilla {
|
2013-03-04 15:24:44 +00:00
|
|
|
|
2017-06-19 07:50:09 +00:00
|
|
|
class ChannelMediaDecoder;
|
2016-04-19 07:36:19 +00:00
|
|
|
class DecoderDoctorDiagnostics;
|
2017-01-18 00:59:03 +00:00
|
|
|
class MediaContainerType;
|
2017-06-07 04:14:11 +00:00
|
|
|
struct MediaDecoderInit;
|
2017-07-19 14:18:37 +00:00
|
|
|
struct MediaFormatReaderInit;
|
2013-03-05 14:56:34 +00:00
|
|
|
class MediaDecoderOwner;
|
2017-07-19 09:01:32 +00:00
|
|
|
class MediaFormatReader;
|
2017-07-05 06:07:54 +00:00
|
|
|
class MediaResource;
|
2013-03-05 14:56:34 +00:00
|
|
|
|
2012-11-22 03:10:41 +00:00
|
|
|
enum CanPlayStatus {
|
|
|
|
CANPLAY_NO,
|
|
|
|
CANPLAY_MAYBE,
|
|
|
|
CANPLAY_YES
|
|
|
|
};
|
|
|
|
|
|
|
|
class DecoderTraits {
|
|
|
|
public:
|
2017-01-18 00:59:03 +00:00
|
|
|
// Returns the CanPlayStatus indicating if we can handle this container type.
|
|
|
|
static CanPlayStatus CanHandleContainerType(const MediaContainerType& aContainerType,
|
|
|
|
DecoderDoctorDiagnostics* aDiagnostics);
|
2016-09-26 06:43:16 +00:00
|
|
|
|
2012-11-22 03:10:41 +00: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 07:36:19 +00:00
|
|
|
static bool ShouldHandleMediaType(const char* aMIMEType,
|
|
|
|
DecoderDoctorDiagnostics* aDiagnostics);
|
2012-11-22 03:10:41 +00:00
|
|
|
|
2013-03-05 14:56:34 +00:00
|
|
|
// Create a decoder for the given aType. Returns null if we
|
|
|
|
// were unable to create the decoder.
|
2017-06-19 07:50:09 +00:00
|
|
|
static already_AddRefed<ChannelMediaDecoder> CreateDecoder(
|
|
|
|
MediaDecoderInit& aInit,
|
|
|
|
DecoderDoctorDiagnostics* aDiagnostics);
|
2013-03-05 14:56:35 +00:00
|
|
|
|
2013-03-05 14:56:35 +00:00
|
|
|
// Create a reader for thew given MIME type aType. Returns null
|
|
|
|
// if we were unable to create the reader.
|
2017-07-19 09:01:32 +00:00
|
|
|
static MediaFormatReader* CreateReader(const MediaContainerType& aType,
|
2017-07-19 14:18:37 +00:00
|
|
|
MediaFormatReaderInit& aInit);
|
2013-03-05 14:56:35 +00:00
|
|
|
|
2013-03-05 14:56:35 +00: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 09:53:36 +00:00
|
|
|
|
2017-01-01 01:27:45 +00:00
|
|
|
// Convenience function that returns false if MOZ_FMP4 is not defined,
|
|
|
|
// otherwise defers to MP4Decoder::IsSupportedType().
|
2017-01-18 00:59:03 +00:00
|
|
|
static bool IsMP4SupportedType(const MediaContainerType& aType,
|
2017-01-01 01:27:45 +00:00
|
|
|
DecoderDoctorDiagnostics* aDiagnostics);
|
2017-05-18 06:47:55 +00:00
|
|
|
|
|
|
|
// Returns true if aType is MIME type of hls.
|
|
|
|
static bool IsHttpLiveStreamingType(const MediaContainerType& aType);
|
2012-11-22 03:10:41 +00:00
|
|
|
};
|
|
|
|
|
2015-07-13 15:25:42 +00:00
|
|
|
} // namespace mozilla
|
2012-11-22 03:10:41 +00:00
|
|
|
|
|
|
|
#endif
|
|
|
|
|