michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* vim:set ts=2 sw=2 sts=2 et cindent: */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #include "DecoderTraits.h" michael@0: #include "MediaDecoder.h" michael@0: #include "nsCharSeparatedTokenizer.h" michael@0: #include "mozilla/Preferences.h" michael@0: michael@0: #ifdef MOZ_MEDIA_PLUGINS michael@0: #include "MediaPluginHost.h" michael@0: #endif michael@0: michael@0: #include "OggDecoder.h" michael@0: #include "OggReader.h" michael@0: #ifdef MOZ_WAVE michael@0: #include "WaveDecoder.h" michael@0: #include "WaveReader.h" michael@0: #endif michael@0: #ifdef MOZ_WEBM michael@0: #include "WebMDecoder.h" michael@0: #include "WebMReader.h" michael@0: #endif michael@0: #ifdef MOZ_RAW michael@0: #include "RawDecoder.h" michael@0: #include "RawReader.h" michael@0: #endif michael@0: #ifdef MOZ_GSTREAMER michael@0: #include "GStreamerDecoder.h" michael@0: #include "GStreamerReader.h" michael@0: #endif michael@0: #ifdef MOZ_MEDIA_PLUGINS michael@0: #include "MediaPluginHost.h" michael@0: #include "MediaPluginDecoder.h" michael@0: #include "MediaPluginReader.h" michael@0: #include "MediaPluginHost.h" michael@0: #endif michael@0: #ifdef MOZ_OMX_DECODER michael@0: #include "MediaOmxDecoder.h" michael@0: #include "MediaOmxReader.h" michael@0: #include "nsIPrincipal.h" michael@0: #include "mozilla/dom/HTMLMediaElement.h" michael@0: #endif michael@0: #ifdef NECKO_PROTOCOL_rtsp michael@0: #include "RtspOmxDecoder.h" michael@0: #include "RtspOmxReader.h" michael@0: #endif michael@0: #ifdef MOZ_WMF michael@0: #include "WMFDecoder.h" michael@0: #include "WMFReader.h" michael@0: #endif michael@0: #ifdef MOZ_DIRECTSHOW michael@0: #include "DirectShowDecoder.h" michael@0: #include "DirectShowReader.h" michael@0: #endif michael@0: #ifdef MOZ_APPLEMEDIA michael@0: #include "AppleDecoder.h" michael@0: #include "AppleMP3Reader.h" michael@0: #endif michael@0: #ifdef MOZ_FMP4 michael@0: #include "MP4Reader.h" michael@0: #include "MP4Decoder.h" michael@0: #endif michael@0: michael@0: namespace mozilla michael@0: { michael@0: michael@0: template michael@0: static bool michael@0: CodecListContains(char const *const * aCodecs, const String& aCodec) michael@0: { michael@0: for (int32_t i = 0; aCodecs[i]; ++i) { michael@0: if (aCodec.EqualsASCII(aCodecs[i])) michael@0: return true; michael@0: } michael@0: return false; michael@0: } michael@0: michael@0: #ifdef MOZ_RAW michael@0: static const char* gRawTypes[3] = { michael@0: "video/x-raw", michael@0: "video/x-raw-yuv", michael@0: nullptr michael@0: }; michael@0: michael@0: static const char* gRawCodecs[1] = { michael@0: nullptr michael@0: }; michael@0: michael@0: static bool michael@0: IsRawType(const nsACString& aType) michael@0: { michael@0: if (!MediaDecoder::IsRawEnabled()) { michael@0: return false; michael@0: } michael@0: michael@0: return CodecListContains(gRawTypes, aType); michael@0: } michael@0: #endif michael@0: michael@0: // See http://www.rfc-editor.org/rfc/rfc5334.txt for the definitions michael@0: // of Ogg media types and codec types michael@0: static const char* const gOggTypes[4] = { michael@0: "video/ogg", michael@0: "audio/ogg", michael@0: "application/ogg", michael@0: nullptr michael@0: }; michael@0: michael@0: static char const *const gOggCodecs[3] = { michael@0: "vorbis", michael@0: "theora", michael@0: nullptr michael@0: }; michael@0: michael@0: static char const *const gOggCodecsWithOpus[4] = { michael@0: "vorbis", michael@0: "opus", michael@0: "theora", michael@0: nullptr michael@0: }; michael@0: michael@0: static bool michael@0: IsOggType(const nsACString& aType) michael@0: { michael@0: if (!MediaDecoder::IsOggEnabled()) { michael@0: return false; michael@0: } michael@0: michael@0: return CodecListContains(gOggTypes, aType); michael@0: } michael@0: michael@0: #ifdef MOZ_WAVE michael@0: // See http://www.rfc-editor.org/rfc/rfc2361.txt for the definitions michael@0: // of WAVE media types and codec types. However, the audio/vnd.wave michael@0: // MIME type described there is not used. michael@0: static const char* const gWaveTypes[5] = { michael@0: "audio/x-wav", michael@0: "audio/wav", michael@0: "audio/wave", michael@0: "audio/x-pn-wav", michael@0: nullptr michael@0: }; michael@0: michael@0: static char const *const gWaveCodecs[2] = { michael@0: "1", // Microsoft PCM Format michael@0: nullptr michael@0: }; michael@0: michael@0: static bool michael@0: IsWaveType(const nsACString& aType) michael@0: { michael@0: if (!MediaDecoder::IsWaveEnabled()) { michael@0: return false; michael@0: } michael@0: michael@0: return CodecListContains(gWaveTypes, aType); michael@0: } michael@0: #endif michael@0: michael@0: #ifdef MOZ_WEBM michael@0: static const char* const gWebMTypes[3] = { michael@0: "video/webm", michael@0: "audio/webm", michael@0: nullptr michael@0: }; michael@0: michael@0: static char const *const gWebMCodecs[7] = { michael@0: "vp8", michael@0: "vp8.0", michael@0: "vp9", michael@0: "vp9.0", michael@0: "vorbis", michael@0: "opus", michael@0: nullptr michael@0: }; michael@0: michael@0: static bool michael@0: IsWebMType(const nsACString& aType) michael@0: { michael@0: if (!MediaDecoder::IsWebMEnabled()) { michael@0: return false; michael@0: } michael@0: michael@0: return CodecListContains(gWebMTypes, aType); michael@0: } michael@0: #endif michael@0: michael@0: #ifdef MOZ_GSTREAMER michael@0: static bool michael@0: IsGStreamerSupportedType(const nsACString& aMimeType) michael@0: { michael@0: if (!MediaDecoder::IsGStreamerEnabled()) michael@0: return false; michael@0: michael@0: #ifdef MOZ_WEBM michael@0: if (IsWebMType(aMimeType) && !Preferences::GetBool("media.prefer-gstreamer", false)) michael@0: return false; michael@0: #endif michael@0: if (IsOggType(aMimeType) && !Preferences::GetBool("media.prefer-gstreamer", false)) michael@0: return false; michael@0: michael@0: return GStreamerDecoder::CanHandleMediaType(aMimeType, nullptr); michael@0: } michael@0: #endif michael@0: michael@0: #ifdef MOZ_OMX_DECODER michael@0: static const char* const gOmxTypes[7] = { michael@0: "audio/mpeg", michael@0: "audio/mp4", michael@0: "audio/amr", michael@0: "video/mp4", michael@0: "video/3gpp", michael@0: "video/quicktime", michael@0: nullptr michael@0: }; michael@0: michael@0: static bool michael@0: IsOmxSupportedType(const nsACString& aType) michael@0: { michael@0: if (!MediaDecoder::IsOmxEnabled()) { michael@0: return false; michael@0: } michael@0: michael@0: return CodecListContains(gOmxTypes, aType); michael@0: } michael@0: michael@0: static char const *const gH264Codecs[9] = { michael@0: "avc1.42E01E", // H.264 Constrained Baseline Profile Level 3.0 michael@0: "avc1.42001E", // H.264 Baseline Profile Level 3.0 michael@0: "avc1.58A01E", // H.264 Extended Profile Level 3.0 michael@0: "avc1.4D401E", // H.264 Main Profile Level 3.0 michael@0: "avc1.64001E", // H.264 High Profile Level 3.0 michael@0: "avc1.64001F", // H.264 High Profile Level 3.1 michael@0: "mp4v.20.3", // 3GPP michael@0: "mp4a.40.2", // AAC-LC michael@0: nullptr michael@0: }; michael@0: michael@0: static char const *const gMpegAudioCodecs[2] = { michael@0: "mp3", // MP3 michael@0: nullptr michael@0: }; michael@0: #endif michael@0: michael@0: #ifdef NECKO_PROTOCOL_rtsp michael@0: static const char* const gRtspTypes[2] = { michael@0: "RTSP", michael@0: nullptr michael@0: }; michael@0: michael@0: static bool michael@0: IsRtspSupportedType(const nsACString& aMimeType) michael@0: { michael@0: return MediaDecoder::IsRtspEnabled() && michael@0: CodecListContains(gRtspTypes, aMimeType); michael@0: } michael@0: #endif michael@0: michael@0: /* static */ michael@0: bool DecoderTraits::DecoderWaitsForOnConnected(const nsACString& aMimeType) { michael@0: #ifdef NECKO_PROTOCOL_rtsp michael@0: return CodecListContains(gRtspTypes, aMimeType); michael@0: #else michael@0: return false; michael@0: #endif michael@0: } michael@0: michael@0: #ifdef MOZ_MEDIA_PLUGINS michael@0: static bool michael@0: IsMediaPluginsType(const nsACString& aType) michael@0: { michael@0: if (!MediaDecoder::IsMediaPluginsEnabled()) { michael@0: return false; michael@0: } michael@0: michael@0: static const char* supportedTypes[] = { michael@0: "audio/mpeg", "audio/mp4", "video/mp4", nullptr michael@0: }; michael@0: return CodecListContains(supportedTypes, aType); michael@0: } michael@0: #endif michael@0: michael@0: #ifdef MOZ_WMF michael@0: static bool michael@0: IsWMFSupportedType(const nsACString& aType) michael@0: { michael@0: return WMFDecoder::CanPlayType(aType, NS_LITERAL_STRING("")); michael@0: } michael@0: #endif michael@0: michael@0: #ifdef MOZ_DIRECTSHOW michael@0: static bool michael@0: IsDirectShowSupportedType(const nsACString& aType) michael@0: { michael@0: return DirectShowDecoder::GetSupportedCodecs(aType, nullptr); michael@0: } michael@0: #endif michael@0: michael@0: #ifdef MOZ_FMP4 michael@0: static bool michael@0: IsMP4SupportedType(const nsACString& aType) michael@0: { michael@0: return Preferences::GetBool("media.fragmented-mp4.exposed", false) && michael@0: MP4Decoder::GetSupportedCodecs(aType, nullptr); michael@0: } michael@0: #endif michael@0: michael@0: #ifdef MOZ_APPLEMEDIA michael@0: static const char * const gAppleMP3Types[] = { michael@0: "audio/mp3", michael@0: "audio/mpeg", michael@0: nullptr, michael@0: }; michael@0: michael@0: static const char * const gAppleMP3Codecs[] = { michael@0: "mp3", michael@0: nullptr michael@0: }; michael@0: michael@0: static bool michael@0: IsAppleMediaSupportedType(const nsACString& aType, michael@0: const char * const ** aCodecs = nullptr) michael@0: { michael@0: if (MediaDecoder::IsAppleMP3Enabled() michael@0: && CodecListContains(gAppleMP3Types, aType)) { michael@0: michael@0: if (aCodecs) { michael@0: *aCodecs = gAppleMP3Codecs; michael@0: } michael@0: michael@0: return true; michael@0: } michael@0: michael@0: // TODO MP4 michael@0: michael@0: return false; michael@0: } michael@0: #endif michael@0: michael@0: /* static */ michael@0: bool DecoderTraits::ShouldHandleMediaType(const char* aMIMEType) michael@0: { michael@0: #ifdef MOZ_WAVE michael@0: if (IsWaveType(nsDependentCString(aMIMEType))) { michael@0: // We should not return true for Wave types, since there are some michael@0: // Wave codecs actually in use in the wild that we don't support, and michael@0: // we should allow those to be handled by plugins or helper apps. michael@0: // Furthermore people can play Wave files on most platforms by other michael@0: // means. michael@0: return false; michael@0: } michael@0: #endif michael@0: return CanHandleMediaType(aMIMEType, false, EmptyString()) != CANPLAY_NO; michael@0: } michael@0: michael@0: /* static */ michael@0: CanPlayStatus michael@0: DecoderTraits::CanHandleMediaType(const char* aMIMEType, michael@0: bool aHaveRequestedCodecs, michael@0: const nsAString& aRequestedCodecs) michael@0: { michael@0: char const* const* codecList = nullptr; michael@0: CanPlayStatus result = CANPLAY_NO; michael@0: #ifdef MOZ_RAW michael@0: if (IsRawType(nsDependentCString(aMIMEType))) { michael@0: codecList = gRawCodecs; michael@0: result = CANPLAY_MAYBE; michael@0: } michael@0: #endif michael@0: if (IsOggType(nsDependentCString(aMIMEType))) { michael@0: codecList = MediaDecoder::IsOpusEnabled() ? gOggCodecsWithOpus : gOggCodecs; michael@0: result = CANPLAY_MAYBE; michael@0: } michael@0: #ifdef MOZ_WAVE michael@0: if (IsWaveType(nsDependentCString(aMIMEType))) { michael@0: codecList = gWaveCodecs; michael@0: result = CANPLAY_MAYBE; michael@0: } michael@0: #endif michael@0: #ifdef MOZ_WEBM michael@0: if (IsWebMType(nsDependentCString(aMIMEType))) { michael@0: codecList = gWebMCodecs; michael@0: result = CANPLAY_MAYBE; michael@0: } michael@0: #endif michael@0: #ifdef MOZ_GSTREAMER michael@0: if (GStreamerDecoder::CanHandleMediaType(nsDependentCString(aMIMEType), michael@0: aHaveRequestedCodecs ? &aRequestedCodecs : nullptr)) { michael@0: if (aHaveRequestedCodecs) michael@0: return CANPLAY_YES; michael@0: return CANPLAY_MAYBE; michael@0: } michael@0: #endif michael@0: #ifdef MOZ_OMX_DECODER michael@0: if (IsOmxSupportedType(nsDependentCString(aMIMEType))) { michael@0: result = CANPLAY_MAYBE; michael@0: if (nsDependentCString(aMIMEType).EqualsASCII("audio/mpeg")) { michael@0: codecList = gMpegAudioCodecs; michael@0: } else { michael@0: codecList = gH264Codecs; michael@0: } michael@0: } michael@0: #endif michael@0: #ifdef MOZ_DIRECTSHOW michael@0: // Note: DirectShow should come before WMF, so that we prefer DirectShow's michael@0: // MP3 support over WMF's. michael@0: if (DirectShowDecoder::GetSupportedCodecs(nsDependentCString(aMIMEType), &codecList)) { michael@0: result = CANPLAY_MAYBE; michael@0: } michael@0: #endif michael@0: #ifdef MOZ_WMF michael@0: if (IsWMFSupportedType(nsDependentCString(aMIMEType))) { michael@0: if (!aHaveRequestedCodecs) { michael@0: return CANPLAY_MAYBE; michael@0: } michael@0: return WMFDecoder::CanPlayType(nsDependentCString(aMIMEType), michael@0: aRequestedCodecs) michael@0: ? CANPLAY_YES : CANPLAY_NO; michael@0: } michael@0: #endif michael@0: #ifdef MOZ_APPLEMEDIA michael@0: if (IsAppleMediaSupportedType(nsDependentCString(aMIMEType), &codecList)) { michael@0: result = CANPLAY_MAYBE; michael@0: } michael@0: #endif michael@0: #ifdef MOZ_MEDIA_PLUGINS michael@0: if (MediaDecoder::IsMediaPluginsEnabled() && michael@0: GetMediaPluginHost()->FindDecoder(nsDependentCString(aMIMEType), &codecList)) michael@0: result = CANPLAY_MAYBE; michael@0: #endif michael@0: #ifdef NECKO_PROTOCOL_rtsp michael@0: if (IsRtspSupportedType(nsDependentCString(aMIMEType))) { michael@0: result = CANPLAY_MAYBE; michael@0: } michael@0: #endif michael@0: if (result == CANPLAY_NO || !aHaveRequestedCodecs || !codecList) { michael@0: return result; michael@0: } michael@0: michael@0: // See http://www.rfc-editor.org/rfc/rfc4281.txt for the description michael@0: // of the 'codecs' parameter michael@0: nsCharSeparatedTokenizer tokenizer(aRequestedCodecs, ','); michael@0: bool expectMoreTokens = false; michael@0: while (tokenizer.hasMoreTokens()) { michael@0: const nsSubstring& token = tokenizer.nextToken(); michael@0: michael@0: if (!CodecListContains(codecList, token)) { michael@0: // Totally unsupported codec michael@0: return CANPLAY_NO; michael@0: } michael@0: expectMoreTokens = tokenizer.separatorAfterCurrentToken(); michael@0: } michael@0: if (expectMoreTokens) { michael@0: // Last codec name was empty michael@0: return CANPLAY_NO; michael@0: } michael@0: return CANPLAY_YES; michael@0: } michael@0: michael@0: // Instantiates but does not initialize decoder. michael@0: static michael@0: already_AddRefed michael@0: InstantiateDecoder(const nsACString& aType, MediaDecoderOwner* aOwner) michael@0: { michael@0: nsRefPtr decoder; michael@0: michael@0: #ifdef MOZ_GSTREAMER michael@0: if (IsGStreamerSupportedType(aType)) { michael@0: decoder = new GStreamerDecoder(); michael@0: return decoder.forget(); michael@0: } michael@0: #endif michael@0: #ifdef MOZ_RAW michael@0: if (IsRawType(aType)) { michael@0: decoder = new RawDecoder(); michael@0: return decoder.forget(); michael@0: } michael@0: #endif michael@0: if (IsOggType(aType)) { michael@0: decoder = new OggDecoder(); michael@0: return decoder.forget(); michael@0: } michael@0: #ifdef MOZ_WAVE michael@0: if (IsWaveType(aType)) { michael@0: decoder = new WaveDecoder(); michael@0: return decoder.forget(); michael@0: } michael@0: #endif michael@0: #ifdef MOZ_OMX_DECODER michael@0: if (IsOmxSupportedType(aType)) { michael@0: // AMR audio is enabled for MMS, but we are discouraging Web and App michael@0: // developers from using AMR, thus we only allow AMR to be played on WebApps. michael@0: if (aType.EqualsASCII("audio/amr")) { michael@0: dom::HTMLMediaElement* element = aOwner->GetMediaElement(); michael@0: if (!element) { michael@0: return nullptr; michael@0: } michael@0: nsIPrincipal* principal = element->NodePrincipal(); michael@0: if (!principal) { michael@0: return nullptr; michael@0: } michael@0: if (principal->GetAppStatus() < nsIPrincipal::APP_STATUS_PRIVILEGED) { michael@0: return nullptr; michael@0: } michael@0: } michael@0: decoder = new MediaOmxDecoder(); michael@0: return decoder.forget(); michael@0: } michael@0: #endif michael@0: #ifdef NECKO_PROTOCOL_rtsp michael@0: if (IsRtspSupportedType(aType)) { michael@0: decoder = new RtspOmxDecoder(); michael@0: return decoder.forget(); michael@0: } michael@0: #endif michael@0: #ifdef MOZ_MEDIA_PLUGINS michael@0: if (MediaDecoder::IsMediaPluginsEnabled() && michael@0: GetMediaPluginHost()->FindDecoder(aType, nullptr)) { michael@0: decoder = new MediaPluginDecoder(aType); michael@0: return decoder.forget(); michael@0: } michael@0: #endif michael@0: #ifdef MOZ_WEBM michael@0: if (IsWebMType(aType)) { michael@0: decoder = new WebMDecoder(); michael@0: return decoder.forget(); michael@0: } michael@0: #endif michael@0: #ifdef MOZ_DIRECTSHOW michael@0: // Note: DirectShow should come before WMF, so that we prefer DirectShow's michael@0: // MP3 support over WMF's. michael@0: if (IsDirectShowSupportedType(aType)) { michael@0: decoder = new DirectShowDecoder(); michael@0: return decoder.forget(); michael@0: } michael@0: #endif michael@0: #ifdef MOZ_FMP4 michael@0: if (IsMP4SupportedType(aType)) { michael@0: decoder = new MP4Decoder(); michael@0: return decoder.forget(); michael@0: } michael@0: #endif michael@0: #ifdef MOZ_WMF michael@0: if (IsWMFSupportedType(aType)) { michael@0: decoder = new WMFDecoder(); michael@0: return decoder.forget(); michael@0: } michael@0: #endif michael@0: #ifdef MOZ_APPLEMEDIA michael@0: if (IsAppleMediaSupportedType(aType)) { michael@0: decoder = new AppleDecoder(); michael@0: return decoder.forget(); michael@0: } michael@0: #endif michael@0: michael@0: NS_ENSURE_TRUE(decoder != nullptr, nullptr); michael@0: NS_ENSURE_TRUE(decoder->Init(aOwner), nullptr); michael@0: return nullptr; michael@0: } michael@0: michael@0: /* static */ michael@0: already_AddRefed michael@0: DecoderTraits::CreateDecoder(const nsACString& aType, MediaDecoderOwner* aOwner) michael@0: { michael@0: nsRefPtr decoder(InstantiateDecoder(aType, aOwner)); michael@0: NS_ENSURE_TRUE(decoder != nullptr, nullptr); michael@0: NS_ENSURE_TRUE(decoder->Init(aOwner), nullptr); michael@0: michael@0: return decoder.forget(); michael@0: } michael@0: michael@0: /* static */ michael@0: MediaDecoderReader* DecoderTraits::CreateReader(const nsACString& aType, AbstractMediaDecoder* aDecoder) michael@0: { michael@0: MediaDecoderReader* decoderReader = nullptr; michael@0: michael@0: #ifdef MOZ_GSTREAMER michael@0: if (IsGStreamerSupportedType(aType)) { michael@0: decoderReader = new GStreamerReader(aDecoder); michael@0: } else michael@0: #endif michael@0: #ifdef MOZ_RAW michael@0: if (IsRawType(aType)) { michael@0: decoderReader = new RawReader(aDecoder); michael@0: } else michael@0: #endif michael@0: if (IsOggType(aType)) { michael@0: decoderReader = new OggReader(aDecoder); michael@0: } else michael@0: #ifdef MOZ_WAVE michael@0: if (IsWaveType(aType)) { michael@0: decoderReader = new WaveReader(aDecoder); michael@0: } else michael@0: #endif michael@0: #ifdef MOZ_OMX_DECODER michael@0: if (IsOmxSupportedType(aType)) { michael@0: decoderReader = new MediaOmxReader(aDecoder); michael@0: } else michael@0: #endif michael@0: #ifdef MOZ_MEDIA_PLUGINS michael@0: if (MediaDecoder::IsMediaPluginsEnabled() && michael@0: GetMediaPluginHost()->FindDecoder(aType, nullptr)) { michael@0: decoderReader = new MediaPluginReader(aDecoder, aType); michael@0: } else michael@0: #endif michael@0: #ifdef MOZ_WEBM michael@0: if (IsWebMType(aType)) { michael@0: decoderReader = new WebMReader(aDecoder); michael@0: } else michael@0: #endif michael@0: #ifdef MOZ_DIRECTSHOW michael@0: // Note: DirectShowReader is preferred for MP3, but if it's disabled we michael@0: // fallback to the WMFReader. michael@0: if (IsDirectShowSupportedType(aType)) { michael@0: decoderReader = new DirectShowReader(aDecoder); michael@0: } else michael@0: #endif michael@0: #ifdef MOZ_FMP4 michael@0: if (IsMP4SupportedType(aType)) { michael@0: decoderReader = new MP4Reader(aDecoder); michael@0: } else michael@0: #endif michael@0: #ifdef MOZ_WMF michael@0: if (IsWMFSupportedType(aType)) { michael@0: decoderReader = new WMFReader(aDecoder); michael@0: } else michael@0: #endif michael@0: #ifdef MOZ_APPLEMEDIA michael@0: if (IsAppleMediaSupportedType(aType)) { michael@0: decoderReader = new AppleMP3Reader(aDecoder); michael@0: } else michael@0: #endif michael@0: if (false) {} // dummy if to take care of the dangling else michael@0: michael@0: return decoderReader; michael@0: } michael@0: michael@0: /* static */ michael@0: bool DecoderTraits::IsSupportedInVideoDocument(const nsACString& aType) michael@0: { michael@0: return michael@0: IsOggType(aType) || michael@0: #ifdef MOZ_OMX_DECODER michael@0: // We support amr inside WebApps on firefoxOS but not in general web content. michael@0: // Ensure we dont create a VideoDocument when accessing amr URLs directly. michael@0: (IsOmxSupportedType(aType) && !aType.EqualsASCII("audio/amr")) || michael@0: #endif michael@0: #ifdef MOZ_WEBM michael@0: IsWebMType(aType) || michael@0: #endif michael@0: #ifdef MOZ_GSTREAMER michael@0: IsGStreamerSupportedType(aType) || michael@0: #endif michael@0: #ifdef MOZ_MEDIA_PLUGINS michael@0: (MediaDecoder::IsMediaPluginsEnabled() && IsMediaPluginsType(aType)) || michael@0: #endif michael@0: #ifdef MOZ_FMP4 michael@0: IsMP4SupportedType(aType) || michael@0: #endif michael@0: #ifdef MOZ_WMF michael@0: (IsWMFSupportedType(aType) && michael@0: Preferences::GetBool("media.windows-media-foundation.play-stand-alone", true)) || michael@0: #endif michael@0: #ifdef MOZ_DIRECTSHOW michael@0: IsDirectShowSupportedType(aType) || michael@0: #endif michael@0: #ifdef MOZ_APPLEMEDIA michael@0: IsAppleMediaSupportedType(aType) || michael@0: #endif michael@0: #ifdef NECKO_PROTOCOL_rtsp michael@0: IsRtspSupportedType(aType) || michael@0: #endif michael@0: false; michael@0: } michael@0: michael@0: }