Exemplo n.º 1
0
/* static */
CanPlayStatus
DecoderTraits::CanHandleCodecsType(const char* aMIMEType,
                                   const nsAString& aRequestedCodecs,
                                   DecoderDoctorDiagnostics* aDiagnostics)
{
  char const* const* codecList = nullptr;
#ifdef MOZ_RAW
  if (IsRawType(nsDependentCString(aMIMEType))) {
    codecList = gRawCodecs;
  }
#endif
  if (IsOggType(nsDependentCString(aMIMEType))) {
    codecList = MediaDecoder::IsOpusEnabled() ? gOggCodecsWithOpus : gOggCodecs;
  }
  if (IsWaveType(nsDependentCString(aMIMEType))) {
    codecList = gWaveCodecs;
  }
#if !defined(MOZ_OMX_WEBM_DECODER)
  if (IsWebMTypeAndEnabled(nsDependentCString(aMIMEType))) {
    if (IsWebMSupportedType(nsDependentCString(aMIMEType), aRequestedCodecs)) {
      return CANPLAY_YES;
    } else {
      // 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 (IsMP4TypeAndEnabled(nsDependentCString(aMIMEType), aDiagnostics)) {
    if (IsMP4SupportedType(nsDependentCString(aMIMEType), aDiagnostics, aRequestedCodecs)) {
      return CANPLAY_YES;
    } else {
      // 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 (IsMP3SupportedType(nsDependentCString(aMIMEType), aRequestedCodecs)) {
    return CANPLAY_YES;
  }
  if (IsAACSupportedType(nsDependentCString(aMIMEType), aRequestedCodecs)) {
    return CANPLAY_YES;
  }
#ifdef MOZ_OMX_DECODER
  if (IsOmxSupportedType(nsDependentCString(aMIMEType))) {
    if (nsDependentCString(aMIMEType).EqualsASCII("audio/mpeg")) {
      codecList = gMpegAudioCodecs;
#ifdef MOZ_OMX_WEBM_DECODER
    } else if (nsDependentCString(aMIMEType).EqualsASCII("audio/webm") ||
               nsDependentCString(aMIMEType).EqualsASCII("video/webm")) {
      codecList = gOMXWebMCodecs;
#endif
    } else {
      codecList = gH264Codecs;
    }
  }
#endif
#ifdef MOZ_DIRECTSHOW
  DirectShowDecoder::GetSupportedCodecs(nsDependentCString(aMIMEType), &codecList);
#endif
#ifdef MOZ_ANDROID_OMX
  if (MediaDecoder::IsAndroidMediaPluginEnabled()) {
    EnsureAndroidMediaPluginHost()->FindDecoder(nsDependentCString(aMIMEType), &codecList);
  }
#endif
  if (!codecList) {
    return CANPLAY_MAYBE;
  }

  // See http://www.rfc-editor.org/rfc/rfc4281.txt for the description
  // of the 'codecs' parameter
  nsCharSeparatedTokenizer tokenizer(aRequestedCodecs, ',');
  bool expectMoreTokens = false;
  while (tokenizer.hasMoreTokens()) {
    const nsSubstring& token = tokenizer.nextToken();

    if (!CodecListContains(codecList, token)) {
      // Totally unsupported codec
      return CANPLAY_NO;
    }
    expectMoreTokens = tokenizer.separatorAfterCurrentToken();
  }
  if (expectMoreTokens) {
    // Last codec name was empty
    return CANPLAY_NO;
  }

  return CANPLAY_YES;
}
Exemplo n.º 2
0
/* 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;
}
Exemplo n.º 3
0
/* static */
CanPlayStatus
DecoderTraits::CanHandleMediaType(const char* aMIMEType,
                                  bool aHaveRequestedCodecs,
                                  const nsAString& aRequestedCodecs)
{
  MOZ_ASSERT(NS_IsMainThread());

  if (aHaveRequestedCodecs) {
    CanPlayStatus result = CanHandleCodecsType(aMIMEType, aRequestedCodecs);
    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;
  }
#ifdef MOZ_WAVE
  if (IsWaveType(nsDependentCString(aMIMEType))) {
    return CANPLAY_MAYBE;
  }
#endif
  if (IsMP4TypeAndEnabled(nsDependentCString(aMIMEType))) {
    return CANPLAY_MAYBE;
  }
#if !defined(MOZ_OMX_WEBM_DECODER)
  if (IsWebMTypeAndEnabled(nsDependentCString(aMIMEType))) {
    return CANPLAY_MAYBE;
  }
#endif
  if (IsMP3SupportedType(nsDependentCString(aMIMEType))) {
    return CANPLAY_MAYBE;
  }
#ifdef MOZ_GSTREAMER
  if (GStreamerDecoder::CanHandleMediaType(nsDependentCString(aMIMEType),
                                           aHaveRequestedCodecs ? &aRequestedCodecs : nullptr)) {
    return aHaveRequestedCodecs ? CANPLAY_YES : CANPLAY_MAYBE;
  }
#endif
#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::IsAndroidMediaEnabled() &&
      EnsureAndroidMediaPluginHost()->FindDecoder(nsDependentCString(aMIMEType), nullptr)) {
    return CANPLAY_MAYBE;
  }
#endif
#ifdef NECKO_PROTOCOL_rtsp
  if (IsRtspSupportedType(nsDependentCString(aMIMEType))) {
    return CANPLAY_MAYBE;
  }
#endif
  return CANPLAY_NO;
}