static CanPlayStatus CanHandleMediaType(const MediaContentType& aType, DecoderDoctorDiagnostics* aDiagnostics) { MOZ_ASSERT(NS_IsMainThread()); if (IsHttpLiveStreamingType(aType.GetMIMEType())) { Telemetry::Accumulate(Telemetry::MEDIA_HLS_CANPLAY_REQUESTED, true); } if (aType.HaveCodecs()) { CanPlayStatus result = CanHandleCodecsType(aType, aDiagnostics); if (result == CANPLAY_NO || result == CANPLAY_YES) { return result; } } if (IsOggTypeAndEnabled(aType.GetMIMEType())) { return CANPLAY_MAYBE; } if (IsWaveSupportedType(aType.GetMIMEType())) { return CANPLAY_MAYBE; } if (DecoderTraits::IsMP4TypeAndEnabled(aType.GetMIMEType(), aDiagnostics)) { return CANPLAY_MAYBE; } #if !defined(MOZ_OMX_WEBM_DECODER) if (DecoderTraits::IsWebMTypeAndEnabled(aType.GetMIMEType())) { return CANPLAY_MAYBE; } #endif if (IsMP3SupportedType(aType.GetMIMEType())) { return CANPLAY_MAYBE; } if (IsAACSupportedType(aType.GetMIMEType())) { return CANPLAY_MAYBE; } if (IsFlacSupportedType(aType.GetMIMEType())) { return CANPLAY_MAYBE; } #ifdef MOZ_DIRECTSHOW if (DirectShowDecoder::GetSupportedCodecs(aType.GetMIMEType(), nullptr)) { return CANPLAY_MAYBE; } #endif #ifdef MOZ_ANDROID_OMX if (MediaDecoder::IsAndroidMediaPluginEnabled() && EnsureAndroidMediaPluginHost()->FindDecoder(aType.GetMIMEType(), nullptr)) { return CANPLAY_MAYBE; } #endif return CANPLAY_NO; }
// Instantiates but does not initialize decoder. static already_AddRefed<MediaDecoder> InstantiateDecoder(const nsACString& aType, MediaDecoderOwner* aOwner, DecoderDoctorDiagnostics* aDiagnostics) { MOZ_ASSERT(NS_IsMainThread()); RefPtr<MediaDecoder> decoder; #ifdef MOZ_FMP4 if (IsMP4SupportedType(aType, aDiagnostics)) { decoder = new MP4Decoder(aOwner); return decoder.forget(); } #endif if (IsMP3SupportedType(aType)) { decoder = new MP3Decoder(aOwner); return decoder.forget(); } if (IsAACSupportedType(aType)) { decoder = new ADTSDecoder(aOwner); return decoder.forget(); } #ifdef MOZ_RAW if (IsRawType(aType)) { decoder = new RawDecoder(aOwner); return decoder.forget(); } #endif if (IsOggType(aType)) { decoder = new OggDecoder(aOwner); return decoder.forget(); } if (IsWaveType(aType)) { decoder = new WaveDecoder(aOwner); return decoder.forget(); } #ifdef MOZ_OMX_DECODER if (IsOmxSupportedType(aType)) { // we are discouraging Web and App developers from using those formats in // gB2GOnlyTypes, thus we only allow them to be played on WebApps. if (IsB2GSupportOnlyType(aType)) { dom::HTMLMediaElement* element = aOwner->GetMediaElement(); if (!element) { return nullptr; } nsIPrincipal* principal = element->NodePrincipal(); if (!principal) { return nullptr; } if (principal->GetAppStatus() < nsIPrincipal::APP_STATUS_PRIVILEGED) { return nullptr; } } decoder = new MediaOmxDecoder(aOwner); return decoder.forget(); } #endif #ifdef MOZ_ANDROID_OMX if (MediaDecoder::IsAndroidMediaPluginEnabled() && EnsureAndroidMediaPluginHost()->FindDecoder(aType, nullptr)) { decoder = new AndroidMediaDecoder(aOwner, aType); return decoder.forget(); } #endif if (IsWebMSupportedType(aType)) { decoder = new WebMDecoder(aOwner); return decoder.forget(); } #ifdef MOZ_DIRECTSHOW // Note: DirectShow should come before WMF, so that we prefer DirectShow's // MP3 support over WMF's. if (IsDirectShowSupportedType(aType)) { decoder = new DirectShowDecoder(aOwner); return decoder.forget(); } #endif if (IsHttpLiveStreamingType(aType)) { // We don't have an HLS decoder. Telemetry::Accumulate(Telemetry::MEDIA_HLS_DECODER_SUCCESS, false); } return nullptr; }
/* static */ CanPlayStatus DecoderTraits::CanHandleMediaType(const char* aMIMEType, bool aHaveRequestedCodecs, const nsAString& aRequestedCodecs, DecoderDoctorDiagnostics* aDiagnostics) { MOZ_ASSERT(NS_IsMainThread()); if (IsHttpLiveStreamingType(nsDependentCString(aMIMEType))) { Telemetry::Accumulate(Telemetry::MEDIA_HLS_CANPLAY_REQUESTED, true); } if (aHaveRequestedCodecs) { CanPlayStatus result = CanHandleCodecsType(aMIMEType, aRequestedCodecs, aDiagnostics); if (result == CANPLAY_NO || result == CANPLAY_YES) { return result; } } #ifdef MOZ_RAW if (IsRawType(nsDependentCString(aMIMEType))) { return CANPLAY_MAYBE; } #endif if (IsOggType(nsDependentCString(aMIMEType))) { return CANPLAY_MAYBE; } if (IsWaveType(nsDependentCString(aMIMEType))) { return CANPLAY_MAYBE; } if (IsMP4TypeAndEnabled(nsDependentCString(aMIMEType), aDiagnostics)) { return CANPLAY_MAYBE; } #if !defined(MOZ_OMX_WEBM_DECODER) if (IsWebMTypeAndEnabled(nsDependentCString(aMIMEType))) { return CANPLAY_MAYBE; } #endif if (IsMP3SupportedType(nsDependentCString(aMIMEType))) { return CANPLAY_MAYBE; } if (IsAACSupportedType(nsDependentCString(aMIMEType))) { return CANPLAY_MAYBE; } #ifdef MOZ_OMX_DECODER if (IsOmxSupportedType(nsDependentCString(aMIMEType))) { return CANPLAY_MAYBE; } #endif #ifdef MOZ_DIRECTSHOW if (DirectShowDecoder::GetSupportedCodecs(nsDependentCString(aMIMEType), nullptr)) { return CANPLAY_MAYBE; } #endif #ifdef MOZ_ANDROID_OMX if (MediaDecoder::IsAndroidMediaPluginEnabled() && EnsureAndroidMediaPluginHost()->FindDecoder(nsDependentCString(aMIMEType), nullptr)) { return CANPLAY_MAYBE; } #endif return CANPLAY_NO; }
// Instantiates but does not initialize decoder. static already_AddRefed<MediaDecoder> InstantiateDecoder(const nsACString& aType, MediaDecoderOwner* aOwner, DecoderDoctorDiagnostics* aDiagnostics) { MOZ_ASSERT(NS_IsMainThread()); RefPtr<MediaDecoder> decoder; #ifdef MOZ_FMP4 if (IsMP4SupportedType(aType, aDiagnostics)) { decoder = new MP4Decoder(aOwner); return decoder.forget(); } #endif if (IsMP3SupportedType(aType)) { decoder = new MP3Decoder(aOwner); return decoder.forget(); } if (IsAACSupportedType(aType)) { decoder = new ADTSDecoder(aOwner); return decoder.forget(); } if (IsOggSupportedType(aType)) { decoder = new OggDecoder(aOwner); return decoder.forget(); } if (IsWaveSupportedType(aType)) { decoder = new WaveDecoder(aOwner); return decoder.forget(); } if (IsFlacSupportedType(aType)) { decoder = new FlacDecoder(aOwner); return decoder.forget(); } #ifdef MOZ_ANDROID_OMX if (MediaDecoder::IsAndroidMediaPluginEnabled() && EnsureAndroidMediaPluginHost()->FindDecoder(aType, nullptr)) { decoder = new AndroidMediaDecoder(aOwner, aType); return decoder.forget(); } #endif if (IsWebMSupportedType(aType)) { decoder = new WebMDecoder(aOwner); return decoder.forget(); } #ifdef MOZ_DIRECTSHOW // Note: DirectShow should come before WMF, so that we prefer DirectShow's // MP3 support over WMF's. if (IsDirectShowSupportedType(aType)) { decoder = new DirectShowDecoder(aOwner); return decoder.forget(); } #endif if (IsHttpLiveStreamingType(aType)) { // We don't have an HLS decoder. Telemetry::Accumulate(Telemetry::MEDIA_HLS_DECODER_SUCCESS, false); } return nullptr; }