/* static */ bool MP4Decoder::CanHandleMediaType(const nsACString& aType, const nsAString& aCodecs, bool& aOutContainsAAC, bool& aOutContainsH264, bool& aOutContainsMP3) { if (!IsEnabled()) { return false; } if (aType.EqualsASCII("audio/mp4") || aType.EqualsASCII("audio/x-m4a")) { return MP4Decoder::CanCreateAACDecoder() && (aCodecs.IsEmpty() || IsSupportedAudioCodec(aCodecs, aOutContainsAAC, aOutContainsMP3)); } #ifdef MOZ_GONK_MEDIACODEC if (aType.EqualsASCII(VIDEO_3GPP)) { return Preferences::GetBool("media.fragmented-mp4.gonk.enabled", false); } #endif if ((!aType.EqualsASCII("video/mp4") && !aType.EqualsASCII("video/x-m4v")) || !MP4Decoder::CanCreateH264Decoder()) { return false; } // Verify that all the codecs specifed are ones that we expect that // we can play. nsCharSeparatedTokenizer tokenizer(aCodecs, ','); bool expectMoreTokens = false; while (tokenizer.hasMoreTokens()) { const nsSubstring& token = tokenizer.nextToken(); expectMoreTokens = tokenizer.separatorAfterCurrentToken(); if (IsSupportedAudioCodec(token, aOutContainsAAC, aOutContainsMP3)) { continue; } if (IsSupportedH264Codec(token)) { aOutContainsH264 = true; continue; } return false; } if (expectMoreTokens) { // Last codec name was empty return false; } return true; }
/* static */ bool MP4Decoder::CanHandleMediaType(const nsACString& aType, const nsAString& aCodecs, bool& aOutContainsAAC, bool& aOutContainsH264, bool& aOutContainsMP3) { if (!IsEnabled()) { return false; } if (aType.EqualsASCII("audio/mp4") || aType.EqualsASCII("audio/x-m4a")) { return aCodecs.IsEmpty() || IsSupportedAudioCodec(aCodecs, aOutContainsAAC, aOutContainsMP3); } if (!aType.EqualsASCII("video/mp4")) { return false; } // Verify that all the codecs specifed are ones that we expect that // we can play. nsCharSeparatedTokenizer tokenizer(aCodecs, ','); bool expectMoreTokens = false; while (tokenizer.hasMoreTokens()) { const nsSubstring& token = tokenizer.nextToken(); expectMoreTokens = tokenizer.separatorAfterCurrentToken(); if (IsSupportedAudioCodec(token, aOutContainsAAC, aOutContainsMP3)) { continue; } if (IsSupportedH264Codec(token)) { aOutContainsH264 = true; continue; } return false; } if (expectMoreTokens) { // Last codec name was empty return false; } return true; }