Maybe<MediaContainerType> MakeMediaContainerType(const nsAString& aType) { Maybe<MediaExtendedMIMEType> mime = MakeMediaExtendedMIMEType(aType); if (mime) { return Some(MediaContainerType(std::move(*mime))); } return Nothing(); }
static CanPlayStatus CanHandleCodecsType(const MediaContainerType& aType, DecoderDoctorDiagnostics* aDiagnostics) { // We should have been given a codecs string, though it may be empty. MOZ_ASSERT(aType.ExtendedType().HaveCodecs()); // Container type with the MIME type, no codecs. const MediaContainerType mimeType(aType.Type()); if (OggDecoder::IsSupportedType(mimeType)) { if (OggDecoder::IsSupportedType(aType)) { return CANPLAY_YES; } // 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; } if (WaveDecoder::IsSupportedType(MediaContainerType(mimeType))) { if (WaveDecoder::IsSupportedType(aType)) { return CANPLAY_YES; } // 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; } #if !defined(MOZ_OMX_WEBM_DECODER) if (WebMDecoder::IsSupportedType(mimeType)) { if (WebMDecoder::IsSupportedType(aType)) { return CANPLAY_YES; } // 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; } #endif #ifdef MOZ_FMP4 if (MP4Decoder::IsSupportedType(mimeType, /* DecoderDoctorDiagnostics* */ nullptr)) { if (MP4Decoder::IsSupportedType(aType, aDiagnostics)) { return CANPLAY_YES; } // 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; } #endif if (MP3Decoder::IsSupportedType(aType)) { return CANPLAY_YES; } if (ADTSDecoder::IsSupportedType(aType)) { return CANPLAY_YES; } if (FlacDecoder::IsSupportedType(aType)) { return CANPLAY_YES; } return CANPLAY_MAYBE; }
// static bool VP9Benchmark::IsVP9DecodeFast() { MOZ_ASSERT(NS_IsMainThread()); #ifdef MOZ_WIDGET_ANDROID return false; #else bool hasPref = Preferences::HasUserValue(sBenchmarkFpsPref); uint32_t hadRecentUpdate = Preferences::GetUint(sBenchmarkFpsVersionCheck, 0U); if (!sHasRunTest && (!hasPref || hadRecentUpdate != sBenchmarkVersionID)) { sHasRunTest = true; RefPtr<WebMDemuxer> demuxer = new WebMDemuxer( new BufferMediaResource(sWebMSample, sizeof(sWebMSample), nullptr, MediaContainerType(MEDIAMIMETYPE("video/webm")))); RefPtr<Benchmark> estimiser = new Benchmark(demuxer, { Preferences::GetInt("media.benchmark.frames", 300), // frames to measure 1, // start benchmarking after decoding this frame. 8, // loop after decoding that many frames. TimeDuration::FromMilliseconds( Preferences::GetUint("media.benchmark.timeout", 1000)) }); estimiser->Run()->Then( // Non-DocGroup version of AbstractThread::MainThread for utility function. AbstractThread::MainThread(), __func__, [](uint32_t aDecodeFps) { if (XRE_IsContentProcess()) { dom::ContentChild* contentChild = dom::ContentChild::GetSingleton(); if (contentChild) { contentChild->SendNotifyBenchmarkResult(NS_LITERAL_STRING("VP9"), aDecodeFps); } } else { Preferences::SetUint(sBenchmarkFpsPref, aDecodeFps); Preferences::SetUint(sBenchmarkFpsVersionCheck, sBenchmarkVersionID); } Telemetry::Accumulate(Telemetry::HistogramID::VIDEO_VP9_BENCHMARK_FPS, aDecodeFps); }, []() { }); } if (!hasPref) { return false; } uint32_t decodeFps = Preferences::GetUint(sBenchmarkFpsPref); uint32_t threshold = Preferences::GetUint("media.benchmark.vp9.threshold", 150); return decodeFps >= threshold; #endif }