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/. */
|
|
|
|
|
|
|
|
#include "DecoderTraits.h"
|
2017-01-18 03:59:03 +03:00
|
|
|
#include "MediaContainerType.h"
|
2014-09-16 12:07:15 +04:00
|
|
|
#include "nsMimeTypes.h"
|
2013-06-21 03:16:55 +04:00
|
|
|
#include "mozilla/Preferences.h"
|
2013-03-05 18:56:35 +04:00
|
|
|
|
2013-03-05 18:56:34 +04:00
|
|
|
#include "OggDecoder.h"
|
2016-07-21 04:34:42 +03:00
|
|
|
#include "OggDemuxer.h"
|
2015-12-18 11:51:16 +03:00
|
|
|
|
2013-03-05 18:56:34 +04:00
|
|
|
#include "WebMDecoder.h"
|
2015-06-18 16:59:43 +03:00
|
|
|
#include "WebMDemuxer.h"
|
2015-12-12 21:49:07 +03:00
|
|
|
|
2017-05-31 13:37:23 +03:00
|
|
|
#ifdef MOZ_ANDROID_HLS_SUPPORT
|
|
|
|
# include "HLSDecoder.h"
|
|
|
|
#endif
|
2013-11-21 01:04:33 +04:00
|
|
|
#ifdef MOZ_FMP4
|
|
|
|
# include "MP4Decoder.h"
|
2015-05-16 15:35:22 +03:00
|
|
|
# include "MP4Demuxer.h"
|
2013-11-21 01:04:33 +04:00
|
|
|
#endif
|
2015-05-16 15:35:22 +03:00
|
|
|
#include "MediaFormatReader.h"
|
2013-03-05 18:56:34 +04:00
|
|
|
|
2015-06-05 16:53:31 +03:00
|
|
|
#include "MP3Decoder.h"
|
|
|
|
#include "MP3Demuxer.h"
|
|
|
|
|
2016-02-12 04:40:36 +03:00
|
|
|
#include "WaveDecoder.h"
|
|
|
|
#include "WaveDemuxer.h"
|
|
|
|
|
2015-11-27 07:40:36 +03:00
|
|
|
#include "ADTSDecoder.h"
|
|
|
|
#include "ADTSDemuxer.h"
|
|
|
|
|
2016-08-17 08:45:06 +03:00
|
|
|
#include "FlacDecoder.h"
|
|
|
|
#include "FlacDemuxer.h"
|
|
|
|
|
2016-03-11 14:42:02 +03:00
|
|
|
#include "nsPluginHost.h"
|
|
|
|
|
2012-11-22 07:10:41 +04:00
|
|
|
namespace mozilla {
|
2017-05-18 09:47:55 +03:00
|
|
|
|
2019-02-26 01:05:29 +03:00
|
|
|
/* static */
|
|
|
|
bool DecoderTraits::IsHttpLiveStreamingType(const MediaContainerType& aType) {
|
2017-06-21 11:10:11 +03:00
|
|
|
const auto& mimeType = aType.Type();
|
2017-05-18 09:47:55 +03:00
|
|
|
return // For m3u8.
|
|
|
|
// https://tools.ietf.org/html/draft-pantos-http-live-streaming-19#section-10
|
2017-09-04 12:27:43 +03:00
|
|
|
mimeType == MEDIAMIMETYPE("application/vnd.apple.mpegurl") ||
|
|
|
|
// Some sites serve these as the informal m3u type.
|
|
|
|
mimeType == MEDIAMIMETYPE("application/x-mpegurl") ||
|
|
|
|
mimeType == MEDIAMIMETYPE("audio/mpegurl") ||
|
|
|
|
mimeType == MEDIAMIMETYPE("audio/x-mpegurl");
|
2017-05-18 09:47:55 +03:00
|
|
|
}
|
|
|
|
|
2019-02-26 01:05:29 +03:00
|
|
|
/* static */
|
|
|
|
bool DecoderTraits::IsMatroskaType(const MediaContainerType& aType) {
|
2018-01-12 10:40:52 +03:00
|
|
|
const auto& mimeType = aType.Type();
|
|
|
|
// https://matroska.org/technical/specs/notes.html
|
|
|
|
return mimeType == MEDIAMIMETYPE("audio/x-matroska") ||
|
|
|
|
mimeType == MEDIAMIMETYPE("video/x-matroska");
|
|
|
|
}
|
|
|
|
|
2019-02-26 01:05:29 +03:00
|
|
|
/* static */
|
|
|
|
bool DecoderTraits::IsMP4SupportedType(const MediaContainerType& aType,
|
|
|
|
DecoderDoctorDiagnostics* aDiagnostics) {
|
2015-07-21 07:01:07 +03:00
|
|
|
#ifdef MOZ_FMP4
|
2017-01-01 04:27:45 +03:00
|
|
|
return MP4Decoder::IsSupportedType(aType, aDiagnostics);
|
2015-12-28 10:11:26 +03:00
|
|
|
#else
|
2015-07-21 07:01:07 +03:00
|
|
|
return false;
|
2015-12-28 10:11:26 +03:00
|
|
|
#endif
|
2015-07-21 07:01:07 +03:00
|
|
|
}
|
|
|
|
|
2017-01-18 03:59:03 +03:00
|
|
|
static CanPlayStatus CanHandleCodecsType(
|
2016-09-26 09:01:59 +03:00
|
|
|
const MediaContainerType& aType, DecoderDoctorDiagnostics* aDiagnostics) {
|
2016-10-01 11:09:50 +03:00
|
|
|
// We should have been given a codecs string, though it may be empty.
|
2017-01-01 01:24:24 +03:00
|
|
|
MOZ_ASSERT(aType.ExtendedType().HaveCodecs());
|
|
|
|
|
2017-01-18 03:59:03 +03:00
|
|
|
// Container type with the MIME type, no codecs.
|
|
|
|
const MediaContainerType mimeType(aType.Type());
|
2016-10-01 11:09:50 +03:00
|
|
|
|
2017-01-01 04:08:36 +03:00
|
|
|
if (OggDecoder::IsSupportedType(mimeType)) {
|
|
|
|
if (OggDecoder::IsSupportedType(aType)) {
|
2016-08-04 10:14:28 +03:00
|
|
|
return CANPLAY_YES;
|
|
|
|
}
|
2017-02-09 12:32:18 +03:00
|
|
|
// We can only reach this position if a particular codec was requested,
|
|
|
|
// ogg is supported and working: the codec must be invalid.
|
|
|
|
return CANPLAY_NO;
|
2012-11-22 07:10:41 +04:00
|
|
|
}
|
2017-01-18 03:59:03 +03:00
|
|
|
if (WaveDecoder::IsSupportedType(MediaContainerType(mimeType))) {
|
2016-12-20 11:09:41 +03:00
|
|
|
if (WaveDecoder::IsSupportedType(aType)) {
|
2016-11-09 05:08:56 +03:00
|
|
|
return CANPLAY_YES;
|
|
|
|
}
|
2018-06-04 18:07:47 +03:00
|
|
|
// We can only reach this position if a particular codec was requested, wave
|
|
|
|
// is supported and working: the codec must be invalid or not supported.
|
2017-02-09 12:32:18 +03:00
|
|
|
return CANPLAY_NO;
|
2012-11-22 07:10:41 +04:00
|
|
|
}
|
2017-01-01 04:16:38 +03:00
|
|
|
if (WebMDecoder::IsSupportedType(mimeType)) {
|
|
|
|
if (WebMDecoder::IsSupportedType(aType)) {
|
2015-12-03 09:36:36 +03:00
|
|
|
return CANPLAY_YES;
|
|
|
|
}
|
2017-02-09 12:32:18 +03:00
|
|
|
// We can only reach this position if a particular codec was requested,
|
|
|
|
// webm is supported and working: the codec must be invalid.
|
|
|
|
return CANPLAY_NO;
|
2012-11-22 07:10:41 +04:00
|
|
|
}
|
2014-07-04 12:31:19 +04:00
|
|
|
#ifdef MOZ_FMP4
|
2017-01-01 04:27:45 +03:00
|
|
|
if (MP4Decoder::IsSupportedType(mimeType,
|
|
|
|
/* DecoderDoctorDiagnostics* */ nullptr)) {
|
|
|
|
if (MP4Decoder::IsSupportedType(aType, aDiagnostics)) {
|
2013-03-14 00:10:47 +04:00
|
|
|
return CANPLAY_YES;
|
2015-07-21 07:01:07 +03:00
|
|
|
}
|
2017-02-09 12:32:18 +03:00
|
|
|
// We can only reach this position if a particular codec was requested,
|
|
|
|
// fmp4 is supported and working: the codec must be invalid.
|
|
|
|
return CANPLAY_NO;
|
2012-11-22 07:10:41 +04:00
|
|
|
}
|
|
|
|
#endif
|
2018-06-09 14:22:39 +03:00
|
|
|
if (MP3Decoder::IsSupportedType(mimeType)) {
|
|
|
|
if (MP3Decoder::IsSupportedType(aType)) {
|
|
|
|
return CANPLAY_YES;
|
|
|
|
}
|
|
|
|
// We can only reach this position if a particular codec was requested,
|
|
|
|
// mp3 is supported and working: the codec must be invalid.
|
|
|
|
return CANPLAY_NO;
|
2015-07-21 07:01:07 +03:00
|
|
|
}
|
2018-06-09 14:22:39 +03:00
|
|
|
if (ADTSDecoder::IsSupportedType(mimeType)) {
|
|
|
|
if (ADTSDecoder::IsSupportedType(aType)) {
|
|
|
|
return CANPLAY_YES;
|
|
|
|
}
|
|
|
|
// We can only reach this position if a particular codec was requested,
|
|
|
|
// adts is supported and working: the codec must be invalid.
|
|
|
|
return CANPLAY_NO;
|
2015-11-27 07:40:36 +03:00
|
|
|
}
|
2018-06-09 14:22:39 +03:00
|
|
|
if (FlacDecoder::IsSupportedType(mimeType)) {
|
|
|
|
if (FlacDecoder::IsSupportedType(aType)) {
|
|
|
|
return CANPLAY_YES;
|
|
|
|
}
|
|
|
|
// We can only reach this position if a particular codec was requested,
|
|
|
|
// flac is supported and working: the codec must be invalid.
|
|
|
|
return CANPLAY_NO;
|
2016-08-17 08:45:06 +03:00
|
|
|
}
|
2016-12-23 00:43:49 +03:00
|
|
|
|
2017-07-13 13:54:03 +03:00
|
|
|
return CANPLAY_MAYBE;
|
2012-11-22 07:10:41 +04:00
|
|
|
}
|
|
|
|
|
2017-01-18 03:59:03 +03:00
|
|
|
static CanPlayStatus CanHandleMediaType(
|
2016-09-26 09:01:59 +03:00
|
|
|
const MediaContainerType& aType, DecoderDoctorDiagnostics* aDiagnostics) {
|
2017-05-31 13:37:23 +03:00
|
|
|
#ifdef MOZ_ANDROID_HLS_SUPPORT
|
|
|
|
if (HLSDecoder::IsSupportedType(aType)) {
|
|
|
|
return CANPLAY_MAYBE;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2019-08-02 21:17:45 +03:00
|
|
|
if (DecoderTraits::IsMatroskaType(aType)) {
|
2018-01-12 10:40:52 +03:00
|
|
|
Telemetry::Accumulate(Telemetry::MEDIA_MKV_CANPLAY_REQUESTED, true);
|
2016-04-12 00:13:43 +03:00
|
|
|
}
|
|
|
|
|
2017-01-01 01:24:24 +03:00
|
|
|
if (aType.ExtendedType().HaveCodecs()) {
|
2016-10-01 11:09:50 +03:00
|
|
|
CanPlayStatus result = CanHandleCodecsType(aType, aDiagnostics);
|
2015-07-21 07:01:07 +03:00
|
|
|
if (result == CANPLAY_NO || result == CANPLAY_YES) {
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
}
|
2017-01-01 01:24:24 +03:00
|
|
|
|
2017-01-18 03:59:03 +03:00
|
|
|
// Container type with just the MIME type/subtype, no codecs.
|
|
|
|
const MediaContainerType mimeType(aType.Type());
|
2017-01-01 01:24:24 +03:00
|
|
|
|
2017-01-01 04:08:36 +03:00
|
|
|
if (OggDecoder::IsSupportedType(mimeType)) {
|
2015-07-21 07:01:07 +03:00
|
|
|
return CANPLAY_MAYBE;
|
|
|
|
}
|
2016-12-20 11:09:41 +03:00
|
|
|
if (WaveDecoder::IsSupportedType(mimeType)) {
|
2015-07-21 07:01:07 +03:00
|
|
|
return CANPLAY_MAYBE;
|
|
|
|
}
|
2017-01-01 04:27:45 +03:00
|
|
|
#ifdef MOZ_FMP4
|
|
|
|
if (MP4Decoder::IsSupportedType(mimeType, aDiagnostics)) {
|
2015-07-21 07:01:07 +03:00
|
|
|
return CANPLAY_MAYBE;
|
|
|
|
}
|
2017-01-01 04:27:45 +03:00
|
|
|
#endif
|
2017-01-01 04:16:38 +03:00
|
|
|
if (WebMDecoder::IsSupportedType(mimeType)) {
|
2015-07-21 07:01:07 +03:00
|
|
|
return CANPLAY_MAYBE;
|
|
|
|
}
|
2017-01-01 04:34:12 +03:00
|
|
|
if (MP3Decoder::IsSupportedType(mimeType)) {
|
2015-07-21 07:01:07 +03:00
|
|
|
return CANPLAY_MAYBE;
|
|
|
|
}
|
2016-12-20 10:57:26 +03:00
|
|
|
if (ADTSDecoder::IsSupportedType(mimeType)) {
|
2015-11-27 07:40:36 +03:00
|
|
|
return CANPLAY_MAYBE;
|
|
|
|
}
|
2016-12-20 11:24:17 +03:00
|
|
|
if (FlacDecoder::IsSupportedType(mimeType)) {
|
2016-08-17 08:45:06 +03:00
|
|
|
return CANPLAY_MAYBE;
|
|
|
|
}
|
2015-07-21 07:01:07 +03:00
|
|
|
return CANPLAY_NO;
|
|
|
|
}
|
|
|
|
|
2016-09-26 09:43:16 +03:00
|
|
|
/* static */
|
2017-01-18 03:59:03 +03:00
|
|
|
CanPlayStatus DecoderTraits::CanHandleContainerType(
|
|
|
|
const MediaContainerType& aContainerType,
|
|
|
|
DecoderDoctorDiagnostics* aDiagnostics) {
|
|
|
|
return CanHandleMediaType(aContainerType, aDiagnostics);
|
2016-09-26 09:43:16 +03:00
|
|
|
}
|
|
|
|
|
2016-09-26 09:02:59 +03:00
|
|
|
/* static */
|
|
|
|
bool DecoderTraits::ShouldHandleMediaType(
|
|
|
|
const char* aMIMEType, DecoderDoctorDiagnostics* aDiagnostics) {
|
2017-01-18 03:59:03 +03:00
|
|
|
Maybe<MediaContainerType> containerType = MakeMediaContainerType(aMIMEType);
|
|
|
|
if (!containerType) {
|
2017-01-01 04:01:32 +03:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2017-01-18 03:59:03 +03:00
|
|
|
if (WaveDecoder::IsSupportedType(*containerType)) {
|
2016-09-26 09:02:59 +03:00
|
|
|
// We should not return true for Wave types, since there are some
|
|
|
|
// Wave codecs actually in use in the wild that we don't support, and
|
|
|
|
// we should allow those to be handled by plugins or helper apps.
|
|
|
|
// Furthermore people can play Wave files on most platforms by other
|
|
|
|
// means.
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// If an external plugin which can handle quicktime video is available
|
|
|
|
// (and not disabled), prefer it over native playback as there several
|
|
|
|
// codecs found in the wild that we do not handle.
|
2017-01-18 03:59:03 +03:00
|
|
|
if (containerType->Type() == MEDIAMIMETYPE("video/quicktime")) {
|
2016-09-26 09:02:59 +03:00
|
|
|
RefPtr<nsPluginHost> pluginHost = nsPluginHost::GetInst();
|
|
|
|
if (pluginHost &&
|
2017-01-18 03:59:03 +03:00
|
|
|
pluginHost->HavePluginForType(containerType->Type().AsString())) {
|
2016-09-26 09:02:59 +03:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-01-18 03:59:03 +03:00
|
|
|
return CanHandleMediaType(*containerType, aDiagnostics) != CANPLAY_NO;
|
2016-09-26 09:02:59 +03:00
|
|
|
}
|
|
|
|
|
2013-03-05 18:56:35 +04:00
|
|
|
/* static */
|
2019-11-14 19:06:29 +03:00
|
|
|
already_AddRefed<MediaDataDemuxer> DecoderTraits::CreateDemuxer(
|
|
|
|
const MediaContainerType& aType, MediaResource* aResource) {
|
2015-04-24 21:22:20 +03:00
|
|
|
MOZ_ASSERT(NS_IsMainThread());
|
2019-11-14 19:06:29 +03:00
|
|
|
RefPtr<MediaDataDemuxer> demuxer;
|
2017-07-06 11:59:22 +03:00
|
|
|
|
2014-06-17 02:32:18 +04:00
|
|
|
#ifdef MOZ_FMP4
|
2016-12-22 03:57:48 +03:00
|
|
|
if (MP4Decoder::IsSupportedType(aType,
|
2017-01-01 04:27:45 +03:00
|
|
|
/* DecoderDoctorDiagnostics* */ nullptr)) {
|
2019-11-14 19:06:29 +03:00
|
|
|
demuxer = new MP4Demuxer(aResource);
|
2014-06-17 02:32:18 +04:00
|
|
|
} else
|
|
|
|
#endif
|
2016-12-22 03:57:48 +03:00
|
|
|
if (MP3Decoder::IsSupportedType(aType)) {
|
2019-11-14 19:06:29 +03:00
|
|
|
demuxer = new MP3Demuxer(aResource);
|
2016-12-22 03:57:48 +03:00
|
|
|
} else if (ADTSDecoder::IsSupportedType(aType)) {
|
2019-11-14 19:06:29 +03:00
|
|
|
demuxer = new ADTSDemuxer(aResource);
|
2016-12-22 03:57:48 +03:00
|
|
|
} else if (WaveDecoder::IsSupportedType(aType)) {
|
2019-11-14 19:06:29 +03:00
|
|
|
demuxer = new WAVDemuxer(aResource);
|
2016-12-22 03:57:48 +03:00
|
|
|
} else if (FlacDecoder::IsSupportedType(aType)) {
|
2019-11-14 19:06:29 +03:00
|
|
|
demuxer = new FlacDemuxer(aResource);
|
2016-12-22 03:57:48 +03:00
|
|
|
} else if (OggDecoder::IsSupportedType(aType)) {
|
2019-11-14 19:06:29 +03:00
|
|
|
demuxer = new OggDemuxer(aResource);
|
2016-12-22 03:57:48 +03:00
|
|
|
} else if (WebMDecoder::IsSupportedType(aType)) {
|
2019-11-14 19:06:29 +03:00
|
|
|
demuxer = new WebMDemuxer(aResource);
|
|
|
|
}
|
|
|
|
|
|
|
|
return demuxer.forget();
|
|
|
|
}
|
|
|
|
|
|
|
|
/* static */
|
|
|
|
MediaFormatReader* DecoderTraits::CreateReader(const MediaContainerType& aType,
|
|
|
|
MediaFormatReaderInit& aInit) {
|
|
|
|
MOZ_ASSERT(NS_IsMainThread());
|
|
|
|
|
|
|
|
RefPtr<MediaDataDemuxer> demuxer = CreateDemuxer(aType, aInit.mResource);
|
|
|
|
if (!demuxer) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
MediaFormatReader* decoderReader = new MediaFormatReader(aInit, demuxer);
|
|
|
|
|
|
|
|
if (OggDecoder::IsSupportedType(aType)) {
|
|
|
|
static_cast<OggDemuxer*>(demuxer.get())
|
|
|
|
->SetChainingEvents(&decoderReader->TimedMetadataProducer(),
|
|
|
|
&decoderReader->MediaNotSeekableProducer());
|
2017-06-05 13:59:46 +03:00
|
|
|
}
|
2013-03-05 18:56:35 +04:00
|
|
|
|
|
|
|
return decoderReader;
|
|
|
|
}
|
|
|
|
|
2017-08-15 08:38:16 +03:00
|
|
|
/* static */
|
|
|
|
bool DecoderTraits::IsSupportedType(const MediaContainerType& aType) {
|
|
|
|
typedef bool (*IsSupportedFunction)(const MediaContainerType& aType);
|
|
|
|
static const IsSupportedFunction funcs[] = {
|
|
|
|
&ADTSDecoder::IsSupportedType,
|
|
|
|
&FlacDecoder::IsSupportedType,
|
|
|
|
&MP3Decoder::IsSupportedType,
|
|
|
|
#ifdef MOZ_FMP4
|
|
|
|
&MP4Decoder::IsSupportedTypeWithoutDiagnostics,
|
|
|
|
#endif
|
|
|
|
&OggDecoder::IsSupportedType,
|
|
|
|
&WaveDecoder::IsSupportedType,
|
|
|
|
&WebMDecoder::IsSupportedType,
|
|
|
|
};
|
|
|
|
for (IsSupportedFunction func : funcs) {
|
|
|
|
if (func(aType)) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2013-03-05 18:56:35 +04:00
|
|
|
/* static */
|
|
|
|
bool DecoderTraits::IsSupportedInVideoDocument(const nsACString& aType) {
|
2014-08-28 07:33:14 +04:00
|
|
|
// Forbid playing media in video documents if the user has opted
|
|
|
|
// not to, using either the legacy WMF specific pref, or the newer
|
|
|
|
// catch-all pref.
|
2017-09-26 18:00:57 +03:00
|
|
|
if (!Preferences::GetBool("media.wmf.play-stand-alone", true) ||
|
2014-08-28 07:33:14 +04:00
|
|
|
!Preferences::GetBool("media.play-stand-alone", true)) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2017-01-18 03:59:03 +03:00
|
|
|
Maybe<MediaContainerType> type = MakeMediaContainerType(aType);
|
2017-01-01 04:08:36 +03:00
|
|
|
if (!type) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return OggDecoder::IsSupportedType(*type) ||
|
2017-01-01 04:16:38 +03:00
|
|
|
WebMDecoder::IsSupportedType(*type) ||
|
2013-11-21 01:04:33 +04:00
|
|
|
#ifdef MOZ_FMP4
|
2017-01-01 04:27:45 +03:00
|
|
|
MP4Decoder::IsSupportedType(*type,
|
|
|
|
/* DecoderDoctorDiagnostics* */ nullptr) ||
|
2013-11-21 01:04:33 +04:00
|
|
|
#endif
|
2017-01-01 04:34:12 +03:00
|
|
|
MP3Decoder::IsSupportedType(*type) ||
|
2016-12-20 10:57:26 +03:00
|
|
|
ADTSDecoder::IsSupportedType(*type) ||
|
2016-12-20 11:24:17 +03:00
|
|
|
FlacDecoder::IsSupportedType(*type) ||
|
2017-06-13 10:56:32 +03:00
|
|
|
#ifdef MOZ_ANDROID_HLS_SUPPORT
|
|
|
|
HLSDecoder::IsSupportedType(*type) ||
|
|
|
|
#endif
|
2013-03-05 18:56:35 +04:00
|
|
|
false;
|
2012-11-22 07:10:41 +04:00
|
|
|
}
|
|
|
|
|
2019-02-26 01:05:29 +03:00
|
|
|
/* static */
|
|
|
|
nsTArray<UniquePtr<TrackInfo>> DecoderTraits::GetTracksInfo(
|
2018-06-07 17:47:41 +03:00
|
|
|
const MediaContainerType& aType) {
|
|
|
|
// Container type with just the MIME type/subtype, no codecs.
|
|
|
|
const MediaContainerType mimeType(aType.Type());
|
|
|
|
|
|
|
|
if (OggDecoder::IsSupportedType(mimeType)) {
|
|
|
|
return OggDecoder::GetTracksInfo(aType);
|
|
|
|
}
|
|
|
|
if (WaveDecoder::IsSupportedType(mimeType)) {
|
|
|
|
return WaveDecoder::GetTracksInfo(aType);
|
|
|
|
}
|
|
|
|
#ifdef MOZ_FMP4
|
|
|
|
if (MP4Decoder::IsSupportedType(mimeType, nullptr)) {
|
|
|
|
return MP4Decoder::GetTracksInfo(aType);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
if (WebMDecoder::IsSupportedType(mimeType)) {
|
|
|
|
return WebMDecoder::GetTracksInfo(aType);
|
|
|
|
}
|
|
|
|
if (MP3Decoder::IsSupportedType(mimeType)) {
|
|
|
|
return MP3Decoder::GetTracksInfo(aType);
|
|
|
|
}
|
|
|
|
if (ADTSDecoder::IsSupportedType(mimeType)) {
|
|
|
|
return ADTSDecoder::GetTracksInfo(aType);
|
|
|
|
}
|
|
|
|
if (FlacDecoder::IsSupportedType(mimeType)) {
|
|
|
|
return FlacDecoder::GetTracksInfo(aType);
|
|
|
|
}
|
|
|
|
return nsTArray<UniquePtr<TrackInfo>>();
|
|
|
|
}
|
|
|
|
|
2015-07-13 18:25:42 +03:00
|
|
|
} // namespace mozilla
|