0

Video: Add decoder prefix for IsSupported{Audio|Video}Type related functions

There will be a new function `IsEncoderSupportedVideoType()`
soon, so rename the existing functions first
to make it more clear.

This CL has no actual logic changes, just renaming.

Bug: 40276507
Change-Id: I419647037c57aff0f08636d4ca1cb4b2988dc92f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5952551
Reviewed-by: Zijie He <zijiehe@google.com>
Commit-Queue: Sida Zhu <zhusida@bytedance.com>
Reviewed-by: Dale Curtis <dalecurtis@chromium.org>
Reviewed-by: Lei Zhang <thestig@chromium.org>
Reviewed-by: Arthur Sonzogni <arthursonzogni@chromium.org>
Reviewed-by: Vigen Issahhanjan <vigeni@google.com>
Reviewed-by: Peter Kvitek <kvitekp@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1374246}
This commit is contained in:
Sida Zhu
2024-10-26 03:11:20 +00:00
committed by Chromium LUCI CQ
parent 2ebaf47bd9
commit 01cacf8a1c
43 changed files with 317 additions and 299 deletions

@ -901,7 +901,7 @@ IN_PROC_BROWSER_TEST_F(EncryptedMediaSupportedTypesClearKeyTest,
// High 10-bit Profile is supported when using ClearKey if it is supported for
// clear content on this platform.
if (media::IsBuiltInVideoCodec(media::VideoCodec::kH264)) {
if (media::IsDecoderBuiltInVideoCodec(media::VideoCodec::kH264)) {
EXPECT_PROPRIETARY(IsSupportedByKeySystem(kClearKey, kVideoMP4MimeType,
video_mp4_hi10p_codecs()));
} else {

@ -141,7 +141,7 @@ TEST_F(MediaParserAndroidTest, VideoFrameExtractionH264) {
ExtractFrame(media::GetTestDataFilePath("bear.mp4"), "video/mp4");
ASSERT_TRUE(result);
if (media::IsBuiltInVideoCodec(media::VideoCodec::kH264)) {
if (media::IsDecoderBuiltInVideoCodec(media::VideoCodec::kH264)) {
const auto& frame = result->frame_data->get_decoded_frame();
ASSERT_TRUE(frame);
EXPECT_TRUE(HasValidYUVData(*frame));

@ -68,7 +68,7 @@ void OnEncodedVideoFrameExtracted(
std::unique_ptr<media::MediaLog> log;
std::unique_ptr<media::VideoDecoder> software_decoder;
if (media::IsBuiltInVideoCodec(config.codec())) {
if (media::IsDecoderBuiltInVideoCodec(config.codec())) {
switch (config.codec()) {
case media::VideoCodec::kH264:
#if BUILDFLAG(ENABLE_FFMPEG_VIDEO_DECODERS)
@ -77,7 +77,7 @@ void OnEncodedVideoFrameExtracted(
std::make_unique<media::FFmpegVideoDecoder>(log.get());
break;
#else
// IsBuiltInVideoCodec(H264) should never return true if
// IsDecoderBuiltInVideoCodec(H264) should never return true if
// ENABLE_FFMPEG_VIDEO_DECODERS is false.
NOTREACHED();
#endif
@ -87,7 +87,7 @@ void OnEncodedVideoFrameExtracted(
software_decoder = std::make_unique<media::VpxVideoDecoder>();
break;
#else
// IsBuiltInVideoCodec(VP8|VP9) should never return true if
// IsDecoderBuiltInVideoCodec(VP8|VP9) should never return true if
// ENABLE_FFMPEG_VIDEO_DECODERS is false.
NOTREACHED();
#endif
@ -97,7 +97,7 @@ void OnEncodedVideoFrameExtracted(
std::make_unique<media::NullMediaLog>());
break;
#else
// IsBuiltInVideoCodec(AV1) should never return true if
// IsDecoderBuiltInVideoCodec(AV1) should never return true if
// ENABLE_FFMPEG_VIDEO_DECODERS is false.
NOTREACHED();
#endif

@ -187,7 +187,7 @@ CastContentRendererClient::GetSupportedKeySystems(
#endif // BUILDFLAG(IS_ANDROID)
}
bool CastContentRendererClient::IsSupportedAudioType(
bool CastContentRendererClient::IsDecoderSupportedAudioType(
const ::media::AudioType& type) {
#if BUILDFLAG(IS_ANDROID)
if (type.spatial_rendering)
@ -216,7 +216,7 @@ bool CastContentRendererClient::IsSupportedAudioType(
supported_bitstream_audio_codecs_info_.codecs;
}
return ::media::IsDefaultSupportedAudioType(type);
return ::media::IsDefaultDecoderSupportedAudioType(type);
#else
if (type.profile == ::media::AudioCodecProfile::kXHE_AAC)
return false;
@ -239,7 +239,7 @@ bool CastContentRendererClient::IsSupportedAudioType(
#endif
}
bool CastContentRendererClient::IsSupportedVideoType(
bool CastContentRendererClient::IsDecoderSupportedVideoType(
const ::media::VideoType& type) {
// TODO(servolk): make use of eotf.

@ -59,8 +59,8 @@ class CastContentRendererClient
std::unique_ptr<::media::KeySystemSupportRegistration> GetSupportedKeySystems(
content::RenderFrame* render_frame,
::media::GetSupportedKeySystemsCB cb) override;
bool IsSupportedAudioType(const ::media::AudioType& type) override;
bool IsSupportedVideoType(const ::media::VideoType& type) override;
bool IsDecoderSupportedAudioType(const ::media::AudioType& type) override;
bool IsDecoderSupportedVideoType(const ::media::VideoType& type) override;
bool IsSupportedBitstreamAudioCodec(::media::AudioCodec codec) override;
std::unique_ptr<blink::WebPrescientNetworking> CreatePrescientNetworking(
content::RenderFrame* render_frame) override;

@ -475,7 +475,7 @@ IN_PROC_BROWSER_TEST_P(MediaTest, Navigate) {
}
IN_PROC_BROWSER_TEST_P(MediaTest, AudioOnly_XHE_AAC_MP4) {
if (media::IsSupportedAudioType(
if (media::IsDecoderSupportedAudioType(
{media::AudioCodec::kAAC, media::AudioCodecProfile::kXHE_AAC})) {
PlayAudio("noise-xhe-aac.mp4");
}

@ -78,13 +78,13 @@ IN_PROC_BROWSER_TEST_F(MediaCanPlayTypeTest, CodecSupportTest_mp4) {
// platform_guarantees_ac3_eac3:bool)
ExecuteTest("testMp4Variants(false, false, false)");
#else
const bool is_hevc_supported = media::IsSupportedVideoType({
const bool is_hevc_supported = media::IsDecoderSupportedVideoType({
.codec = media::VideoCodec::kHEVC,
.profile = media::HEVCPROFILE_MIN,
.color_space = media::VideoColorSpace::REC709(),
});
const bool is_ac3_eac3_supported =
media::IsSupportedAudioType({media::AudioCodec::kAC3});
media::IsDecoderSupportedAudioType({media::AudioCodec::kAC3});
ExecuteTest(base::StringPrintf("testMp4Variants(true, %s, %s)",
is_hevc_supported ? "true" : "false",
is_ac3_eac3_supported ? "true" : "false"));
@ -96,7 +96,7 @@ IN_PROC_BROWSER_TEST_F(MediaCanPlayTypeTest, CodecSupportTest_AvcVariants) {
// High 10-bit profile is only available when we can use ffmpeg to decode
// H.264. Even though FFmpeg is used on Android, we only use platform decoders
// for H.264
if (media::IsBuiltInVideoCodec(media::VideoCodec::kH264)) {
if (media::IsDecoderBuiltInVideoCodec(media::VideoCodec::kH264)) {
ExecuteTest("testAvcVariants(true, true)"); // has_proprietary_codecs=true,
// has_software_avc=true
} else {
@ -121,7 +121,7 @@ IN_PROC_BROWSER_TEST_F(MediaCanPlayTypeTest, CodecSupportTest_AvcLevels) {
IN_PROC_BROWSER_TEST_F(MediaCanPlayTypeTest, CodecSupportTest_Mp4aVariants) {
#if BUILDFLAG(USE_PROPRIETARY_CODECS)
if (media::IsSupportedAudioType(
if (media::IsDecoderSupportedAudioType(
{media::AudioCodec::kAAC, media::AudioCodecProfile::kXHE_AAC})) {
ExecuteTest(
"testMp4aVariants(true, true)"); // has_proprietary_codecs=true,

@ -131,7 +131,7 @@ IN_PROC_BROWSER_TEST_F(MediaSourceTest, Playback_AudioOnly_FLAC_MP4) {
}
IN_PROC_BROWSER_TEST_F(MediaSourceTest, Playback_AudioOnly_XHE_AAC_MP4) {
if (media::IsSupportedAudioType(
if (media::IsDecoderSupportedAudioType(
{media::AudioCodec::kAAC, media::AudioCodecProfile::kXHE_AAC})) {
TestSimplePlayback("noise-xhe-aac.mp4", media::kEndedTitle);
}

@ -218,14 +218,16 @@ ContentRendererClient::GetSupportedKeySystems(
return nullptr;
}
bool ContentRendererClient::IsSupportedAudioType(const media::AudioType& type) {
bool ContentRendererClient::IsDecoderSupportedAudioType(
const media::AudioType& type) {
// Defer to media's default support.
return ::media::IsDefaultSupportedAudioType(type);
return ::media::IsDefaultDecoderSupportedAudioType(type);
}
bool ContentRendererClient::IsSupportedVideoType(const media::VideoType& type) {
bool ContentRendererClient::IsDecoderSupportedVideoType(
const media::VideoType& type) {
// Defer to media's default support.
return ::media::IsDefaultSupportedVideoType(type);
return ::media::IsDefaultDecoderSupportedVideoType(type);
}
media::ExternalMemoryAllocator* ContentRendererClient::GetMediaAllocator() {

@ -309,11 +309,11 @@ class CONTENT_EXPORT ContentRendererClient {
GetSupportedKeySystems(RenderFrame* render_frame,
media::GetSupportedKeySystemsCB cb);
// Allows embedder to describe customized audio capabilities.
virtual bool IsSupportedAudioType(const media::AudioType& type);
// Allows embedder to describe customized audio decoder capabilities.
virtual bool IsDecoderSupportedAudioType(const media::AudioType& type);
// Allows embedder to describe customized video capabilities.
virtual bool IsSupportedVideoType(const media::VideoType& type);
// Allows embedder to describe customized video decoder capabilities.
virtual bool IsDecoderSupportedVideoType(const media::VideoType& type);
// Return true if the bitstream format |codec| is supported by the audio sink.
virtual bool IsSupportedBitstreamAudioCodec(media::AudioCodec codec);

@ -18,7 +18,7 @@
namespace {
#if BUILDFLAG(PLATFORM_HAS_OPTIONAL_HEVC_SUPPORT)
void UpdateVideoProfilesInternal(
void UpdateDecoderVideoProfilesInternal(
const media::SupportedVideoDecoderConfigs& supported_configs) {
base::flat_set<media::VideoCodecProfile> media_profiles;
for (const auto& config : supported_configs) {
@ -27,19 +27,19 @@ void UpdateVideoProfilesInternal(
media_profiles.insert(static_cast<media::VideoCodecProfile>(profile));
}
}
media::UpdateDefaultSupportedVideoProfiles(media_profiles);
media::UpdateDefaultDecoderSupportedVideoProfiles(media_profiles);
}
#endif
#if BUILDFLAG(ENABLE_MOJO_AUDIO_DECODER)
void UpdateAudioTypesInternal(
void UpdateDecoderAudioTypesInternal(
const media::SupportedAudioDecoderConfigs& supported_configs) {
base::flat_set<media::AudioType> supported_types;
for (const auto& config : supported_configs) {
media::AudioType type{config.codec, config.profile, false};
supported_types.insert(type);
}
media::UpdateDefaultSupportedAudioTypes(supported_types);
media::UpdateDefaultDecoderSupportedAudioTypes(supported_types);
}
#endif // BUILDFLAG(ENABLE_MOJO_AUDIO_DECODER)
@ -69,7 +69,7 @@ RenderMediaClient::RenderMediaClient()
#if BUILDFLAG(PLATFORM_HAS_OPTIONAL_HEVC_SUPPORT)
// We'll first try to query the supported video decoder configurations
// asynchronously. If IsSupportedVideoType() is called before we get a
// asynchronously. If IsDecoderSupportedVideoType() is called before we get a
// response, that method will block if its not on the main thread or fall
// back to querying the video decoder configurations synchronously otherwise.
@ -143,9 +143,10 @@ RenderMediaClient::~RenderMediaClient() {
NOTREACHED();
}
bool RenderMediaClient::IsSupportedAudioType(const media::AudioType& type) {
bool RenderMediaClient::IsDecoderSupportedAudioType(
const media::AudioType& type) {
#if BUILDFLAG(ENABLE_MOJO_AUDIO_DECODER)
if (!did_audio_update_.IsSignaled()) {
if (!did_audio_decoder_update_.IsSignaled()) {
// The asynchronous request didn't complete in time, so we must now block
// or retrieve the information synchronously.
if (main_task_runner_->BelongsToCurrentThread()) {
@ -156,20 +157,21 @@ bool RenderMediaClient::IsSupportedAudioType(const media::AudioType& type) {
configs.clear();
}
OnGetSupportedAudioDecoderConfigs(configs);
DCHECK(did_audio_update_.IsSignaled());
DCHECK(did_audio_decoder_update_.IsSignaled());
} else {
// There's already an asynchronous request on the main thread, so wait...
did_audio_update_.Wait();
did_audio_decoder_update_.Wait();
}
}
#endif // BUILDFLAG(ENABLE_MOJO_AUDIO_DECODER)
return GetContentClient()->renderer()->IsSupportedAudioType(type);
return GetContentClient()->renderer()->IsDecoderSupportedAudioType(type);
}
bool RenderMediaClient::IsSupportedVideoType(const media::VideoType& type) {
bool RenderMediaClient::IsDecoderSupportedVideoType(
const media::VideoType& type) {
#if BUILDFLAG(PLATFORM_HAS_OPTIONAL_HEVC_SUPPORT)
if (!did_video_update_.IsSignaled()) {
if (!did_video_decoder_update_.IsSignaled()) {
// The asynchronous request didn't complete in time, so we must now block
// or retrieve the information synchronously.
if (main_task_runner_->BelongsToCurrentThread()) {
@ -192,15 +194,15 @@ bool RenderMediaClient::IsSupportedVideoType(const media::VideoType& type) {
configs.clear();
}
OnGetSupportedVideoDecoderConfigs(configs, video_decoder_type);
DCHECK(did_video_update_.IsSignaled());
DCHECK(did_video_decoder_update_.IsSignaled());
} else {
// There's already an asynchronous request on the main thread, so wait...
did_video_update_.Wait();
did_video_decoder_update_.Wait();
}
}
#endif
return GetContentClient()->renderer()->IsSupportedVideoType(type);
return GetContentClient()->renderer()->IsDecoderSupportedVideoType(type);
}
bool RenderMediaClient::IsSupportedBitstreamAudioCodec(
@ -239,17 +241,17 @@ void RenderMediaClient::OnGetSupportedVideoDecoderConfigs(
media::VideoDecoderType type) {
DCHECK_CALLED_ON_VALID_SEQUENCE(main_thread_sequence_checker_);
#if BUILDFLAG(PLATFORM_HAS_OPTIONAL_HEVC_SUPPORT)
if (did_video_update_.IsSignaled()) {
if (did_video_decoder_update_.IsSignaled()) {
return;
}
UpdateVideoProfilesInternal(configs);
did_video_update_.Signal();
UpdateDecoderVideoProfilesInternal(configs);
did_video_decoder_update_.Signal();
video_decoder_for_supported_profiles_
.emplace<mojo::SharedRemote<media::mojom::VideoDecoder>>();
#if BUILDFLAG(ENABLE_MOJO_AUDIO_DECODER)
if (did_audio_update_.IsSignaled()) {
if (did_audio_decoder_update_.IsSignaled()) {
interface_factory_for_supported_profiles_.reset();
}
#else
@ -258,24 +260,20 @@ void RenderMediaClient::OnGetSupportedVideoDecoderConfigs(
#endif
}
media::ExternalMemoryAllocator* RenderMediaClient::GetMediaAllocator() {
return GetContentClient()->renderer()->GetMediaAllocator();
}
void RenderMediaClient::OnGetSupportedAudioDecoderConfigs(
const media::SupportedAudioDecoderConfigs& configs) {
DCHECK_CALLED_ON_VALID_SEQUENCE(main_thread_sequence_checker_);
#if BUILDFLAG(ENABLE_MOJO_AUDIO_DECODER)
if (did_audio_update_.IsSignaled()) {
if (did_audio_decoder_update_.IsSignaled()) {
return;
}
UpdateAudioTypesInternal(configs);
did_audio_update_.Signal();
UpdateDecoderAudioTypesInternal(configs);
did_audio_decoder_update_.Signal();
audio_decoder_for_supported_configs_.reset();
#if BUILDFLAG(PLATFORM_HAS_OPTIONAL_HEVC_SUPPORT)
if (did_video_update_.IsSignaled()) {
if (did_video_decoder_update_.IsSignaled()) {
interface_factory_for_supported_profiles_.reset();
}
#else
@ -284,4 +282,8 @@ void RenderMediaClient::OnGetSupportedAudioDecoderConfigs(
#endif // BUILDFLAG(ENABLE_MOJO_AUDIO_DECODER)
}
media::ExternalMemoryAllocator* RenderMediaClient::GetMediaAllocator() {
return GetContentClient()->renderer()->GetMediaAllocator();
}
} // namespace content

@ -35,8 +35,8 @@ class RenderMediaClient : public media::MediaClient {
static void Initialize();
// MediaClient implementation.
bool IsSupportedAudioType(const media::AudioType& type) final;
bool IsSupportedVideoType(const media::VideoType& type) final;
bool IsDecoderSupportedAudioType(const media::AudioType& type) final;
bool IsDecoderSupportedVideoType(const media::VideoType& type) final;
bool IsSupportedBitstreamAudioCodec(media::AudioCodec codec) final;
std::optional<::media::AudioRendererAlgorithmParameters>
GetAudioRendererAlgorithmParameters(
@ -64,15 +64,17 @@ class RenderMediaClient : public media::MediaClient {
// retrieved from the |video_decoder_for_supported_profiles_|. May be waited
// upon by any thread but the RenderThread since it's always signaled from the
// RenderThread.
[[maybe_unused]] base::WaitableEvent did_video_update_;
[[maybe_unused]] base::WaitableEvent did_video_decoder_update_;
// Used to indicate if optional audio codec support information has been
// retrieved from the MojoAudioDecoder. May be waited upon by any thread but
// the RenderThread since it's always signaled from the RenderThread.
[[maybe_unused]] base::WaitableEvent did_audio_update_;
[[maybe_unused]] base::WaitableEvent did_audio_decoder_update_;
[[maybe_unused]] mojo::Remote<media::mojom::InterfaceFactory>
interface_factory_for_supported_profiles_
GUARDED_BY_CONTEXT(main_thread_sequence_checker_);
[[maybe_unused]] absl::variant<
mojo::SharedRemote<media::mojom::VideoDecoder>,
mojo::SharedRemote<media::stable::mojom::StableVideoDecoder>>

@ -278,12 +278,12 @@ WebEngineContentRendererClient::GetSupportedKeySystems(
return nullptr;
}
bool WebEngineContentRendererClient::IsSupportedVideoType(
bool WebEngineContentRendererClient::IsDecoderSupportedVideoType(
const media::VideoType& type) {
// Fall back to default codec querying logic if software-only codecs are
// enabled.
if (base::FeatureList::IsEnabled(features::kEnableSoftwareOnlyVideoCodecs)) {
return ContentRendererClient::IsSupportedVideoType(type);
return ContentRendererClient::IsDecoderSupportedVideoType(type);
}
return IsSupportedHardwareVideoCodec(type);

@ -54,7 +54,7 @@ class WebEngineContentRendererClient : public content::ContentRendererClient {
std::unique_ptr<media::KeySystemSupportRegistration> GetSupportedKeySystems(
content::RenderFrame* render_frame,
media::GetSupportedKeySystemsCB cb) override;
bool IsSupportedVideoType(const media::VideoType& type) override;
bool IsDecoderSupportedVideoType(const media::VideoType& type) override;
std::unique_ptr<blink::URLLoaderThrottleProvider>
CreateURLLoaderThrottleProvider(
blink::URLLoaderThrottleProviderType type) override;

@ -109,14 +109,15 @@ void HeadlessContentRendererClient::RenderFrameCreated(
#endif
}
bool HeadlessContentRendererClient::IsSupportedVideoType(
bool HeadlessContentRendererClient::IsDecoderSupportedVideoType(
const media::VideoType& type) {
const bool allowed_by_flags =
!video_codecs_allowlist_ ||
video_codecs_allowlist_->IsAllowed(
base::ToLowerASCII(GetCodecName(type.codec)));
// Besides being _allowed_, the codec actually has to be _supported_.
return allowed_by_flags && ContentRendererClient::IsSupportedVideoType(type);
return allowed_by_flags &&
ContentRendererClient::IsDecoderSupportedVideoType(type);
}
std::unique_ptr<blink::URLLoaderThrottleProvider>

@ -22,7 +22,7 @@ class HeadlessContentRendererClient : public content::ContentRendererClient {
private:
// content::ContentRendererClient overrides.
bool IsSupportedVideoType(const media::VideoType& type) override;
bool IsDecoderSupportedVideoType(const media::VideoType& type) override;
void RenderFrameCreated(content::RenderFrame* render_frame) override;
std::unique_ptr<blink::URLLoaderThrottleProvider>
CreateURLLoaderThrottleProvider(

@ -172,8 +172,8 @@ class TestMediaClient : public MediaClient {
~TestMediaClient() override;
// MediaClient implementation.
bool IsSupportedAudioType(const AudioType& type) final;
bool IsSupportedVideoType(const VideoType& type) final;
bool IsDecoderSupportedAudioType(const AudioType& type) final;
bool IsDecoderSupportedVideoType(const VideoType& type) final;
bool IsSupportedBitstreamAudioCodec(AudioCodec codec) final;
ExternalMemoryAllocator* GetMediaAllocator() final;
@ -206,11 +206,11 @@ TestMediaClient::GetSupportedKeySystems(GetSupportedKeySystemsCB cb) {
return nullptr;
}
bool TestMediaClient::IsSupportedAudioType(const AudioType& type) {
bool TestMediaClient::IsDecoderSupportedAudioType(const AudioType& type) {
return true;
}
bool TestMediaClient::IsSupportedVideoType(const VideoType& type) {
bool TestMediaClient::IsDecoderSupportedVideoType(const VideoType& type) {
return true;
}

@ -48,11 +48,11 @@ class MEDIA_EXPORT MediaClient {
MediaClient();
virtual ~MediaClient();
// Returns true if the given audio config is supported.
virtual bool IsSupportedAudioType(const AudioType& type) = 0;
// Returns true if the given audio decoder config is supported.
virtual bool IsDecoderSupportedAudioType(const AudioType& type) = 0;
// Returns true if the given video config is supported.
virtual bool IsSupportedVideoType(const VideoType& type) = 0;
// Returns true if the given video decoder config is supported.
virtual bool IsDecoderSupportedVideoType(const VideoType& type) = 0;
// Returns true if the compressed audio |codec| format is supported by the
// audio sink.

@ -960,7 +960,7 @@ SupportsType MimeUtil::IsCodecSupported(std::string_view mime_type_lower_case,
break;
// Only supported on some hardware and via ffmpeg.
case H264PROFILE_HIGH10PROFILE:
if (IsBuiltInVideoCodec(VideoCodec::kH264)) {
if (IsDecoderBuiltInVideoCodec(VideoCodec::kH264)) {
// FFmpeg is not generally used for encrypted videos, so we do not
// know whether 10-bit is supported.
ambiguous_platform_support = is_encrypted;
@ -978,12 +978,13 @@ SupportsType MimeUtil::IsCodecSupported(std::string_view mime_type_lower_case,
if (codec == MPEG4_XHE_AAC)
audio_profile = AudioCodecProfile::kXHE_AAC;
if (!IsSupportedAudioType({audio_codec, audio_profile, false}))
if (!IsDecoderSupportedAudioType({audio_codec, audio_profile, false})) {
return SupportsType::kNotSupported;
}
}
if (video_codec != VideoCodec::kUnknown) {
if (!IsSupportedVideoType(
if (!IsDecoderSupportedVideoType(
{video_codec, video_profile, video_level, color_space})) {
return SupportsType::kNotSupported;
}
@ -991,7 +992,7 @@ SupportsType MimeUtil::IsCodecSupported(std::string_view mime_type_lower_case,
#if BUILDFLAG(IS_ANDROID)
// TODO(chcunningham): Delete this. Android platform support should be
// handled by (android specific) media::IsSupportedVideoType() above.
// handled by (android specific) media::IsDecoderSupportedVideoType() above.
if (!IsCodecSupportedOnAndroid(codec, mime_type_lower_case, is_encrypted,
video_profile, platform_info_)) {
return SupportsType::kNotSupported;

@ -876,8 +876,8 @@ class MockMediaClient : public media::MediaClient {
~MockMediaClient() override;
// MediaClient implementation.
MOCK_METHOD1(IsSupportedAudioType, bool(const media::AudioType& type));
MOCK_METHOD1(IsSupportedVideoType, bool(const media::VideoType& type));
MOCK_METHOD1(IsDecoderSupportedAudioType, bool(const media::AudioType& type));
MOCK_METHOD1(IsDecoderSupportedVideoType, bool(const media::VideoType& type));
MOCK_METHOD1(IsSupportedBitstreamAudioCodec, bool(media::AudioCodec codec));
MOCK_METHOD1(GetAudioRendererAlgorithmParameters,
std::optional<::media::AudioRendererAlgorithmParameters>(

@ -59,17 +59,18 @@ class SupplementalProfileCache {
base::flat_set<T> profiles_ GUARDED_BY(profiles_lock_);
};
SupplementalProfileCache<VideoCodecProfile>* GetSupplementalProfileCache() {
SupplementalProfileCache<VideoCodecProfile>*
GetSupplementalDecoderVideoProfileCache() {
static base::NoDestructor<SupplementalProfileCache<VideoCodecProfile>> cache;
return cache.get();
}
SupplementalProfileCache<AudioType>* GetSupplementalAudioTypeCache() {
SupplementalProfileCache<AudioType>* GetSupplementalDecoderAudioTypeCache() {
static base::NoDestructor<SupplementalProfileCache<AudioType>> cache;
return cache.get();
}
bool IsSupportedHdrMetadata(const VideoType& type) {
bool IsDecoderSupportedHdrMetadata(const VideoType& type) {
switch (type.hdr_metadata_type) {
case gfx::HdrMetadataType::kNone:
return true;
@ -88,7 +89,7 @@ bool IsSupportedHdrMetadata(const VideoType& type) {
}
}
bool IsColorSpaceSupported(const VideoColorSpace& color_space) {
bool IsDecoderColorSpaceSupported(const VideoColorSpace& color_space) {
switch (color_space.primaries) {
// Transfers supported before color management.
case VideoColorSpace::PrimaryID::BT709:
@ -222,9 +223,10 @@ bool IsAudioCodecProprietary(AudioCodec codec) {
}
#endif // !BUILDFLAG(USE_PROPRIETARY_CODECS)
bool IsHevcProfileSupported(const VideoType& type) {
if (!IsColorSpaceSupported(type.color_space))
bool IsDecoderHevcProfileSupported(const VideoType& type) {
if (!IsDecoderColorSpaceSupported(type.color_space)) {
return false;
}
#if BUILDFLAG(ENABLE_PLATFORM_HEVC)
#if BUILDFLAG(PLATFORM_HAS_OPTIONAL_HEVC_SUPPORT)
@ -243,7 +245,8 @@ bool IsHevcProfileSupported(const VideoType& type) {
return false;
}
#endif // BUILDFLAG(IS_CHROMEOS_ASH)
return GetSupplementalProfileCache()->IsProfileSupported(type.profile);
return GetSupplementalDecoderVideoProfileCache()->IsProfileSupported(
type.profile);
#else
return true;
#endif // BUIDFLAG(PLATFORM_HAS_OPTIONAL_HEVC_SUPPORT)
@ -252,15 +255,16 @@ bool IsHevcProfileSupported(const VideoType& type) {
#endif // BUILDFLAG(ENABLE_PLATFORM_HEVC)
}
bool IsVp9ProfileSupported(const VideoType& type) {
bool IsDecoderVp9ProfileSupported(const VideoType& type) {
#if BUILDFLAG(ENABLE_LIBVPX)
// High bit depth capabilities may be toggled via LibVPX config flags.
static const bool vpx_supports_hbd = (vpx_codec_get_caps(vpx_codec_vp9_dx()) &
VPX_CODEC_CAP_HIGHBITDEPTH) != 0;
// Color management required for HDR to not look terrible.
if (!IsColorSpaceSupported(type.color_space))
if (!IsDecoderColorSpaceSupported(type.color_space)) {
return false;
}
switch (type.profile) {
// LibVPX always supports Profiles 0 and 1.
@ -286,46 +290,47 @@ bool IsVp9ProfileSupported(const VideoType& type) {
return false;
}
bool IsAV1Supported(const VideoType& type) {
bool IsDecoderAV1Supported(const VideoType& type) {
// If the AV1 decoder is enabled, or if we're on Q or later, yes.
#if BUILDFLAG(ENABLE_AV1_DECODER)
return IsColorSpaceSupported(type.color_space);
return IsDecoderColorSpaceSupported(type.color_space);
#elif BUILDFLAG(IS_ANDROID)
return base::android::BuildInfo::GetInstance()->sdk_int() >=
base::android::SDK_VERSION_Q &&
IsColorSpaceSupported(type.color_space);
IsDecoderColorSpaceSupported(type.color_space);
#else
return false;
#endif
}
bool IsAACSupported(const AudioType& type) {
bool IsDecoderAACSupported(const AudioType& type) {
if (type.profile != AudioCodecProfile::kXHE_AAC) {
return true;
}
#if BUILDFLAG(ENABLE_MOJO_AUDIO_DECODER) && \
(BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_MAC) || BUILDFLAG(IS_WIN))
return GetSupplementalAudioTypeCache()->IsProfileSupported(type);
return GetSupplementalDecoderAudioTypeCache()->IsProfileSupported(type);
#else
return false;
#endif
}
bool IsDolbyVisionProfileSupported(const VideoType& type) {
bool IsDecoderDolbyVisionProfileSupported(const VideoType& type) {
#if BUILDFLAG(ENABLE_PLATFORM_HEVC) && \
BUILDFLAG(PLATFORM_HAS_OPTIONAL_HEVC_SUPPORT) && \
BUILDFLAG(ENABLE_PLATFORM_DOLBY_VISION)
return GetSupplementalProfileCache()->IsProfileSupported(type.profile);
return GetSupplementalDecoderVideoProfileCache()->IsProfileSupported(
type.profile);
#else
return false;
#endif
}
bool IsDolbyAc3Eac3Supported(const AudioType& type) {
bool IsDecoderDolbyAc3Eac3Supported(const AudioType& type) {
#if BUILDFLAG(ENABLE_PLATFORM_AC3_EAC3_AUDIO)
#if BUILDFLAG(ENABLE_MOJO_AUDIO_DECODER) && \
(BUILDFLAG(IS_WIN) || BUILDFLAG(IS_MAC))
return GetSupplementalAudioTypeCache()->IsProfileSupported(type);
return GetSupplementalDecoderAudioTypeCache()->IsProfileSupported(type);
#else
// Keep 'true' for other platforms as old code snippet.
return true;
@ -336,10 +341,10 @@ bool IsDolbyAc3Eac3Supported(const AudioType& type) {
#endif // BUILDFLAG(ENABLE_PLATFORM_AC3_EAC3_AUDIO)
}
bool IsDolbyAc4Supported(const AudioType& type) {
bool IsDecoderDolbyAc4Supported(const AudioType& type) {
#if BUILDFLAG(ENABLE_PLATFORM_AC4_AUDIO) && \
BUILDFLAG(ENABLE_MOJO_AUDIO_DECODER) && BUILDFLAG(IS_WIN)
return GetSupplementalAudioTypeCache()->IsProfileSupported(type);
return GetSupplementalDecoderAudioTypeCache()->IsProfileSupported(type);
#else
return false;
#endif // BUILDFLAG(ENABLE_PLATFORM_AC4_AUDIO) &&
@ -348,22 +353,22 @@ bool IsDolbyAc4Supported(const AudioType& type) {
} // namespace
bool IsSupportedAudioType(const AudioType& type) {
bool IsDecoderSupportedAudioType(const AudioType& type) {
if (auto* media_client = GetMediaClient())
return media_client->IsSupportedAudioType(type);
return IsDefaultSupportedAudioType(type);
return media_client->IsDecoderSupportedAudioType(type);
return IsDefaultDecoderSupportedAudioType(type);
}
bool IsSupportedVideoType(const VideoType& type) {
bool IsDecoderSupportedVideoType(const VideoType& type) {
if (auto* media_client = GetMediaClient())
return media_client->IsSupportedVideoType(type);
return IsDefaultSupportedVideoType(type);
return media_client->IsDecoderSupportedVideoType(type);
return IsDefaultDecoderSupportedVideoType(type);
}
// TODO(chcunningham): Add platform specific logic for Android (move from
// MimeUtilInternal).
bool IsDefaultSupportedVideoType(const VideoType& type) {
if (!IsSupportedHdrMetadata(type)) {
bool IsDefaultDecoderSupportedVideoType(const VideoType& type) {
if (!IsDecoderSupportedHdrMetadata(type)) {
return false;
}
@ -374,22 +379,22 @@ bool IsDefaultSupportedVideoType(const VideoType& type) {
switch (type.codec) {
case VideoCodec::kTheora:
return IsBuiltInVideoCodec(type.codec);
return IsDecoderBuiltInVideoCodec(type.codec);
case VideoCodec::kH264:
return true;
case VideoCodec::kVP8:
return IsBuiltInVideoCodec(type.codec)
return IsDecoderBuiltInVideoCodec(type.codec)
? true
: GetSupplementalProfileCache()->IsProfileSupported(
type.profile);
: GetSupplementalDecoderVideoProfileCache()
->IsProfileSupported(type.profile);
case VideoCodec::kAV1:
return IsAV1Supported(type);
return IsDecoderAV1Supported(type);
case VideoCodec::kVP9:
return IsVp9ProfileSupported(type);
return IsDecoderVp9ProfileSupported(type);
case VideoCodec::kHEVC:
return IsHevcProfileSupported(type);
return IsDecoderHevcProfileSupported(type);
case VideoCodec::kDolbyVision:
return IsDolbyVisionProfileSupported(type);
return IsDecoderDolbyVisionProfileSupported(type);
case VideoCodec::kUnknown:
case VideoCodec::kVC1:
case VideoCodec::kMPEG2:
@ -398,7 +403,7 @@ bool IsDefaultSupportedVideoType(const VideoType& type) {
}
}
bool IsDefaultSupportedAudioType(const AudioType& type) {
bool IsDefaultDecoderSupportedAudioType(const AudioType& type) {
if (type.spatial_rendering)
return false;
@ -409,7 +414,7 @@ bool IsDefaultSupportedAudioType(const AudioType& type) {
switch (type.codec) {
case AudioCodec::kAAC:
return IsAACSupported(type);
return IsDecoderAACSupported(type);
case AudioCodec::kFLAC:
case AudioCodec::kMP3:
case AudioCodec::kOpus:
@ -434,13 +439,13 @@ bool IsDefaultSupportedAudioType(const AudioType& type) {
return BUILDFLAG(ENABLE_PLATFORM_DTS_AUDIO);
case AudioCodec::kAC3:
case AudioCodec::kEAC3:
return IsDolbyAc3Eac3Supported(type);
return IsDecoderDolbyAc3Eac3Supported(type);
case AudioCodec::kAC4:
return IsDolbyAc4Supported(type);
return IsDecoderDolbyAc4Supported(type);
}
}
bool IsBuiltInVideoCodec(VideoCodec codec) {
bool IsDecoderBuiltInVideoCodec(VideoCodec codec) {
#if BUILDFLAG(ENABLE_FFMPEG_VIDEO_DECODERS) && BUILDFLAG(USE_PROPRIETARY_CODECS)
if (codec == VideoCodec::kH264 &&
base::FeatureList::IsEnabled(kBuiltInH264Decoder)) {
@ -460,13 +465,14 @@ bool IsBuiltInVideoCodec(VideoCodec codec) {
return false;
}
void UpdateDefaultSupportedVideoProfiles(
void UpdateDefaultDecoderSupportedVideoProfiles(
const base::flat_set<media::VideoCodecProfile>& profiles) {
GetSupplementalProfileCache()->UpdateCache(profiles);
GetSupplementalDecoderVideoProfileCache()->UpdateCache(profiles);
}
void UpdateDefaultSupportedAudioTypes(const base::flat_set<AudioType>& types) {
GetSupplementalAudioTypeCache()->UpdateCache(types);
void UpdateDefaultDecoderSupportedAudioTypes(
const base::flat_set<AudioType>& types) {
GetSupplementalDecoderAudioTypeCache()->UpdateCache(types);
}
} // namespace media

@ -14,29 +14,29 @@ namespace media {
// These functions will attempt to delegate to MediaClient (when present) to
// describe what types of media are supported. When no MediaClient is provided,
// they will fall back to calling the Default functions below.
MEDIA_EXPORT bool IsSupportedAudioType(const AudioType& type);
MEDIA_EXPORT bool IsSupportedVideoType(const VideoType& type);
MEDIA_EXPORT bool IsDecoderSupportedAudioType(const AudioType& type);
MEDIA_EXPORT bool IsDecoderSupportedVideoType(const VideoType& type);
// These functions describe what media/ alone supports. They do not call out to
// MediaClient and do not describe media/ embedder customization. Callers should
// generally prefer the non-Default APIs above.
MEDIA_EXPORT bool IsDefaultSupportedAudioType(const AudioType& type);
MEDIA_EXPORT bool IsDefaultSupportedVideoType(const VideoType& type);
MEDIA_EXPORT bool IsDefaultDecoderSupportedAudioType(const AudioType& type);
MEDIA_EXPORT bool IsDefaultDecoderSupportedVideoType(const VideoType& type);
// This function describe if the specific video codec is a built into the binary
// or not.
MEDIA_EXPORT bool IsBuiltInVideoCodec(VideoCodec codec);
// This function describe if the specific video decoder codec is a built into
// the binary or not.
MEDIA_EXPORT bool IsDecoderBuiltInVideoCodec(VideoCodec codec);
// This function lets the caller add additional codec profiles to those
// supported by default. Used primarily to add hardware codec profiles once
// support is known.
MEDIA_EXPORT void UpdateDefaultSupportedVideoProfiles(
// This function lets the caller add additional video decoder codec profiles to
// those supported by default. Used primarily to add platform supported codec
// profiles once support is known.
MEDIA_EXPORT void UpdateDefaultDecoderSupportedVideoProfiles(
const base::flat_set<VideoCodecProfile>& profiles);
// This function lets the caller add additional codec and profile to those
// supported by default. Used primarily to add platform supported codecs once
// support is known.
MEDIA_EXPORT void UpdateDefaultSupportedAudioTypes(
// This function lets the caller add additional audio decoder codec and profile
// to those supported by default. Used primarily to add platform supported
// codecs once support is known.
MEDIA_EXPORT void UpdateDefaultDecoderSupportedAudioTypes(
const base::flat_set<AudioType>& types);
} // namespace media

@ -26,7 +26,7 @@ const bool kPropCodecsEnabled = true;
const bool kPropCodecsEnabled = false;
#endif
TEST(SupportedTypesTest, IsSupportedVideoTypeBasics) {
TEST(SupportedTypesTest, IsDecoderSupportedVideoTypeBasics) {
// Default to common 709.
const VideoColorSpace kColorSpace = VideoColorSpace::REC709();
@ -34,46 +34,46 @@ TEST(SupportedTypesTest, IsSupportedVideoTypeBasics) {
const int kUnspecifiedLevel = 0;
// Expect support for baseline configuration of known codecs.
EXPECT_TRUE(IsSupportedVideoType(
EXPECT_TRUE(IsDecoderSupportedVideoType(
{VideoCodec::kVP8, VP8PROFILE_ANY, kUnspecifiedLevel, kColorSpace}));
EXPECT_TRUE(IsSupportedVideoType(
EXPECT_TRUE(IsDecoderSupportedVideoType(
{VideoCodec::kVP9, VP9PROFILE_PROFILE0, kUnspecifiedLevel, kColorSpace}));
EXPECT_FALSE(
IsSupportedVideoType({VideoCodec::kTheora, VIDEO_CODEC_PROFILE_UNKNOWN,
kUnspecifiedLevel, kColorSpace}));
EXPECT_FALSE(IsDecoderSupportedVideoType({VideoCodec::kTheora,
VIDEO_CODEC_PROFILE_UNKNOWN,
kUnspecifiedLevel, kColorSpace}));
// Expect non-support for the following.
EXPECT_FALSE(
IsSupportedVideoType({VideoCodec::kUnknown, VIDEO_CODEC_PROFILE_UNKNOWN,
kUnspecifiedLevel, kColorSpace}));
EXPECT_FALSE(
IsSupportedVideoType({VideoCodec::kVC1, VIDEO_CODEC_PROFILE_UNKNOWN,
kUnspecifiedLevel, kColorSpace}));
EXPECT_FALSE(
IsSupportedVideoType({VideoCodec::kMPEG2, VIDEO_CODEC_PROFILE_UNKNOWN,
kUnspecifiedLevel, kColorSpace}));
EXPECT_FALSE(IsDecoderSupportedVideoType({VideoCodec::kUnknown,
VIDEO_CODEC_PROFILE_UNKNOWN,
kUnspecifiedLevel, kColorSpace}));
EXPECT_FALSE(IsDecoderSupportedVideoType({VideoCodec::kVC1,
VIDEO_CODEC_PROFILE_UNKNOWN,
kUnspecifiedLevel, kColorSpace}));
EXPECT_FALSE(IsDecoderSupportedVideoType({VideoCodec::kMPEG2,
VIDEO_CODEC_PROFILE_UNKNOWN,
kUnspecifiedLevel, kColorSpace}));
// Expect conditional support for the following.
EXPECT_EQ(kPropCodecsEnabled,
IsSupportedVideoType(
IsDecoderSupportedVideoType(
{VideoCodec::kH264, H264PROFILE_BASELINE, 1, kColorSpace}));
EXPECT_FALSE(
IsSupportedVideoType({VideoCodec::kMPEG4, VIDEO_CODEC_PROFILE_UNKNOWN,
kUnspecifiedLevel, kColorSpace}));
EXPECT_FALSE(IsDecoderSupportedVideoType({VideoCodec::kMPEG4,
VIDEO_CODEC_PROFILE_UNKNOWN,
kUnspecifiedLevel, kColorSpace}));
#if BUILDFLAG(ENABLE_PLATFORM_HEVC) && \
!BUILDFLAG(PLATFORM_HAS_OPTIONAL_HEVC_SUPPORT)
EXPECT_TRUE(
IsSupportedVideoType({VideoCodec::kHEVC, VIDEO_CODEC_PROFILE_UNKNOWN,
kUnspecifiedLevel, kColorSpace}));
EXPECT_TRUE(IsDecoderSupportedVideoType({VideoCodec::kHEVC,
VIDEO_CODEC_PROFILE_UNKNOWN,
kUnspecifiedLevel, kColorSpace}));
#else
EXPECT_FALSE(
IsSupportedVideoType({VideoCodec::kHEVC, VIDEO_CODEC_PROFILE_UNKNOWN,
kUnspecifiedLevel, kColorSpace}));
EXPECT_FALSE(IsDecoderSupportedVideoType({VideoCodec::kHEVC,
VIDEO_CODEC_PROFILE_UNKNOWN,
kUnspecifiedLevel, kColorSpace}));
#endif
}
TEST(SupportedTypesTest, IsSupportedVideoType_VP9TransferFunctions) {
TEST(SupportedTypesTest, IsDecoderSupportedVideoType_VP9TransferFunctions) {
size_t num_found = 0;
// TODO(hubbe): Verify support for HDR codecs when color management enabled.
const std::set<VideoColorSpace::TransferID> kSupportedTransfers = {
@ -104,13 +104,13 @@ TEST(SupportedTypesTest, IsSupportedVideoType_VP9TransferFunctions) {
if (found)
num_found++;
EXPECT_EQ(found,
IsSupportedVideoType(
IsDecoderSupportedVideoType(
{VideoCodec::kVP9, VP9PROFILE_PROFILE0, 1, color_space}));
}
EXPECT_EQ(kSupportedTransfers.size(), num_found);
}
TEST(SupportedTypesTest, IsSupportedVideoType_VP9Primaries) {
TEST(SupportedTypesTest, IsDecoderSupportedVideoType_VP9Primaries) {
size_t num_found = 0;
// TODO(hubbe): Verify support for HDR codecs when color management enabled.
const std::set<VideoColorSpace::PrimaryID> kSupportedPrimaries = {
@ -136,13 +136,13 @@ TEST(SupportedTypesTest, IsSupportedVideoType_VP9Primaries) {
if (found)
num_found++;
EXPECT_EQ(found,
IsSupportedVideoType(
IsDecoderSupportedVideoType(
{VideoCodec::kVP9, VP9PROFILE_PROFILE0, 1, color_space}));
}
EXPECT_EQ(kSupportedPrimaries.size(), num_found);
}
TEST(SupportedTypesTest, IsSupportedVideoType_VP9Matrix) {
TEST(SupportedTypesTest, IsDecoderSupportedVideoType_VP9Matrix) {
size_t num_found = 0;
// TODO(hubbe): Verify support for HDR codecs when color management enabled.
const std::set<VideoColorSpace::MatrixID> kSupportedMatrix = {
@ -167,22 +167,22 @@ TEST(SupportedTypesTest, IsSupportedVideoType_VP9Matrix) {
if (found)
num_found++;
EXPECT_EQ(found,
IsSupportedVideoType(
IsDecoderSupportedVideoType(
{VideoCodec::kVP9, VP9PROFILE_PROFILE0, 1, color_space}));
}
EXPECT_EQ(kSupportedMatrix.size(), num_found);
}
TEST(SupportedTypesTest, IsSupportedVideoType_VP9Profiles) {
TEST(SupportedTypesTest, IsDecoderSupportedVideoType_VP9Profiles) {
// Default to common 709.
const VideoColorSpace kColorSpace = VideoColorSpace::REC709();
// Some codecs do not have a notion of level.
const int kUnspecifiedLevel = 0;
EXPECT_TRUE(IsSupportedVideoType(
EXPECT_TRUE(IsDecoderSupportedVideoType(
{VideoCodec::kVP9, VP9PROFILE_PROFILE0, kUnspecifiedLevel, kColorSpace}));
EXPECT_TRUE(IsSupportedVideoType(
EXPECT_TRUE(IsDecoderSupportedVideoType(
{VideoCodec::kVP9, VP9PROFILE_PROFILE1, kUnspecifiedLevel, kColorSpace}));
// VP9 Profile2 are supported on x86, ChromeOS on ARM and Mac/Win on ARM64.
@ -190,81 +190,82 @@ TEST(SupportedTypesTest, IsSupportedVideoType_VP9Profiles) {
#if defined(ARCH_CPU_X86_FAMILY) || \
(defined(ARCH_CPU_ARM_FAMILY) && BUILDFLAG(IS_CHROMEOS_ASH)) || \
(defined(ARCH_CPU_ARM64) && (BUILDFLAG(IS_MAC) || BUILDFLAG(IS_WIN)))
EXPECT_TRUE(IsSupportedVideoType(
EXPECT_TRUE(IsDecoderSupportedVideoType(
{VideoCodec::kVP9, VP9PROFILE_PROFILE2, kUnspecifiedLevel, kColorSpace}));
#endif
}
TEST(SupportedTypesTest, IsSupportedAudioTypeWithSpatialRenderingBasics) {
TEST(SupportedTypesTest,
IsDecoderSupportedAudioTypeWithSpatialRenderingBasics) {
const bool is_spatial_rendering = true;
// Dolby Atmos = E-AC3 (Dolby Digital Plus) + spatialRendering. Currently not
// supported.
EXPECT_FALSE(IsSupportedAudioType(
EXPECT_FALSE(IsDecoderSupportedAudioType(
{AudioCodec::kEAC3, AudioCodecProfile::kUnknown, is_spatial_rendering}));
// Expect non-support for codecs with which there is no spatial audio format.
EXPECT_FALSE(IsSupportedAudioType(
EXPECT_FALSE(IsDecoderSupportedAudioType(
{AudioCodec::kAAC, AudioCodecProfile::kUnknown, is_spatial_rendering}));
EXPECT_FALSE(IsSupportedAudioType(
EXPECT_FALSE(IsDecoderSupportedAudioType(
{AudioCodec::kMP3, AudioCodecProfile::kUnknown, is_spatial_rendering}));
EXPECT_FALSE(IsSupportedAudioType(
EXPECT_FALSE(IsDecoderSupportedAudioType(
{AudioCodec::kPCM, AudioCodecProfile::kUnknown, is_spatial_rendering}));
EXPECT_FALSE(
IsSupportedAudioType({AudioCodec::kVorbis, AudioCodecProfile::kUnknown,
is_spatial_rendering}));
EXPECT_FALSE(IsSupportedAudioType(
EXPECT_FALSE(IsDecoderSupportedAudioType({AudioCodec::kVorbis,
AudioCodecProfile::kUnknown,
is_spatial_rendering}));
EXPECT_FALSE(IsDecoderSupportedAudioType(
{AudioCodec::kFLAC, AudioCodecProfile::kUnknown, is_spatial_rendering}));
EXPECT_FALSE(
IsSupportedAudioType({AudioCodec::kAMR_NB, AudioCodecProfile::kUnknown,
is_spatial_rendering}));
EXPECT_FALSE(
IsSupportedAudioType({AudioCodec::kAMR_WB, AudioCodecProfile::kUnknown,
is_spatial_rendering}));
EXPECT_FALSE(
IsSupportedAudioType({AudioCodec::kPCM_MULAW, AudioCodecProfile::kUnknown,
is_spatial_rendering}));
EXPECT_FALSE(
IsSupportedAudioType({AudioCodec::kGSM_MS, AudioCodecProfile::kUnknown,
is_spatial_rendering}));
EXPECT_FALSE(
IsSupportedAudioType({AudioCodec::kPCM_S16BE, AudioCodecProfile::kUnknown,
is_spatial_rendering}));
EXPECT_FALSE(
IsSupportedAudioType({AudioCodec::kPCM_S24BE, AudioCodecProfile::kUnknown,
is_spatial_rendering}));
EXPECT_FALSE(IsSupportedAudioType(
EXPECT_FALSE(IsDecoderSupportedAudioType({AudioCodec::kAMR_NB,
AudioCodecProfile::kUnknown,
is_spatial_rendering}));
EXPECT_FALSE(IsDecoderSupportedAudioType({AudioCodec::kAMR_WB,
AudioCodecProfile::kUnknown,
is_spatial_rendering}));
EXPECT_FALSE(IsDecoderSupportedAudioType({AudioCodec::kPCM_MULAW,
AudioCodecProfile::kUnknown,
is_spatial_rendering}));
EXPECT_FALSE(IsDecoderSupportedAudioType({AudioCodec::kGSM_MS,
AudioCodecProfile::kUnknown,
is_spatial_rendering}));
EXPECT_FALSE(IsDecoderSupportedAudioType({AudioCodec::kPCM_S16BE,
AudioCodecProfile::kUnknown,
is_spatial_rendering}));
EXPECT_FALSE(IsDecoderSupportedAudioType({AudioCodec::kPCM_S24BE,
AudioCodecProfile::kUnknown,
is_spatial_rendering}));
EXPECT_FALSE(IsDecoderSupportedAudioType(
{AudioCodec::kOpus, AudioCodecProfile::kUnknown, is_spatial_rendering}));
EXPECT_FALSE(
IsSupportedAudioType({AudioCodec::kPCM_ALAW, AudioCodecProfile::kUnknown,
is_spatial_rendering}));
EXPECT_FALSE(IsSupportedAudioType(
EXPECT_FALSE(IsDecoderSupportedAudioType({AudioCodec::kPCM_ALAW,
AudioCodecProfile::kUnknown,
is_spatial_rendering}));
EXPECT_FALSE(IsDecoderSupportedAudioType(
{AudioCodec::kALAC, AudioCodecProfile::kUnknown, is_spatial_rendering}));
EXPECT_FALSE(IsSupportedAudioType(
EXPECT_FALSE(IsDecoderSupportedAudioType(
{AudioCodec::kAC3, AudioCodecProfile::kUnknown, is_spatial_rendering}));
EXPECT_FALSE(IsSupportedAudioType({AudioCodec::kMpegHAudio,
AudioCodecProfile::kUnknown,
is_spatial_rendering}));
EXPECT_FALSE(IsDecoderSupportedAudioType({AudioCodec::kMpegHAudio,
AudioCodecProfile::kUnknown,
is_spatial_rendering}));
#if BUILDFLAG(ENABLE_PLATFORM_DTS_AUDIO)
EXPECT_FALSE(IsSupportedAudioType(
EXPECT_FALSE(IsDecoderSupportedAudioType(
{AudioCodec::kDTS, AudioCodecProfile::kUnknown, is_spatial_rendering}));
EXPECT_FALSE(
IsSupportedAudioType({AudioCodec::kDTSXP2, AudioCodecProfile::kUnknown,
is_spatial_rendering}));
EXPECT_FALSE(IsDecoderSupportedAudioType({AudioCodec::kDTSXP2,
AudioCodecProfile::kUnknown,
is_spatial_rendering}));
#endif // BUILDFLAG(ENABLE_PLATFORM_DTS_AUDIO)
#if BUILDFLAG(ENABLE_PLATFORM_AC4_AUDIO)
EXPECT_FALSE(IsSupportedAudioType(
EXPECT_FALSE(IsDecoderSupportedAudioType(
{AudioCodec::kAC4, AudioCodecProfile::kUnknown, is_spatial_rendering}));
#endif // BUILDFLAG(ENABLE_PLATFORM_AC4_AUDIO)
EXPECT_FALSE(
IsSupportedAudioType({AudioCodec::kUnknown, AudioCodecProfile::kUnknown,
is_spatial_rendering}));
EXPECT_FALSE(IsDecoderSupportedAudioType({AudioCodec::kUnknown,
AudioCodecProfile::kUnknown,
is_spatial_rendering}));
}
TEST(SupportedTypesTest, XHE_AACSupported) {
AudioType aac{AudioCodec::kAAC, AudioCodecProfile::kXHE_AAC, false};
EXPECT_EQ(false, IsSupportedAudioType(aac));
EXPECT_EQ(false, IsDecoderSupportedAudioType(aac));
UpdateDefaultSupportedAudioTypes({aac});
UpdateDefaultDecoderSupportedAudioTypes({aac});
EXPECT_EQ(
#if BUILDFLAG(ENABLE_MOJO_AUDIO_DECODER) && \
@ -274,10 +275,10 @@ TEST(SupportedTypesTest, XHE_AACSupported) {
false,
#endif // BUILDFLAG(ENABLE_MOJO_AUDIO_DECODER) && (BUILDFLAG(IS_ANDROID) ||
// BUILDFLAG(IS_MAC) || BUILDFLAG(IS_WIN))
IsSupportedAudioType(aac));
IsDecoderSupportedAudioType(aac));
}
TEST(SupportedTypesTest, IsSupportedVideoTypeWithHdrMetadataBasics) {
TEST(SupportedTypesTest, IsDecoderSupportedVideoTypeWithHdrMetadataBasics) {
// Default to common 709.
VideoColorSpace color_space = VideoColorSpace::REC709();
@ -285,92 +286,92 @@ TEST(SupportedTypesTest, IsSupportedVideoTypeWithHdrMetadataBasics) {
const int kUnspecifiedLevel = 0;
// Expect support for baseline configuration of known codecs.
EXPECT_TRUE(IsSupportedVideoType(
EXPECT_TRUE(IsDecoderSupportedVideoType(
{VideoCodec::kVP8, VP8PROFILE_ANY, kUnspecifiedLevel, color_space}));
EXPECT_TRUE(IsSupportedVideoType(
EXPECT_TRUE(IsDecoderSupportedVideoType(
{VideoCodec::kVP9, VP9PROFILE_PROFILE0, kUnspecifiedLevel, color_space}));
EXPECT_FALSE(
IsSupportedVideoType({VideoCodec::kTheora, VIDEO_CODEC_PROFILE_UNKNOWN,
kUnspecifiedLevel, color_space}));
EXPECT_FALSE(IsDecoderSupportedVideoType({VideoCodec::kTheora,
VIDEO_CODEC_PROFILE_UNKNOWN,
kUnspecifiedLevel, color_space}));
// HDR metadata w/o an HDR color space should return false.
EXPECT_FALSE(
IsSupportedVideoType({VideoCodec::kVP8, VP8PROFILE_ANY, kUnspecifiedLevel,
color_space, gfx::HdrMetadataType::kSmpteSt2086}));
EXPECT_FALSE(IsDecoderSupportedVideoType(
{VideoCodec::kVP8, VP8PROFILE_ANY, kUnspecifiedLevel, color_space,
gfx::HdrMetadataType::kSmpteSt2086}));
// All combinations of combinations of color gamuts and transfer functions
// should be supported.
color_space.primaries = VideoColorSpace::PrimaryID::SMPTEST431_2;
color_space.transfer = VideoColorSpace::TransferID::SMPTEST2084;
EXPECT_TRUE(IsSupportedVideoType(
EXPECT_TRUE(IsDecoderSupportedVideoType(
{VideoCodec::kVP8, VP8PROFILE_ANY, kUnspecifiedLevel, color_space}));
EXPECT_TRUE(IsSupportedVideoType(
EXPECT_TRUE(IsDecoderSupportedVideoType(
{VideoCodec::kVP9, VP9PROFILE_PROFILE0, kUnspecifiedLevel, color_space}));
EXPECT_FALSE(
IsSupportedVideoType({VideoCodec::kTheora, VIDEO_CODEC_PROFILE_UNKNOWN,
kUnspecifiedLevel, color_space}));
EXPECT_TRUE(
IsSupportedVideoType({VideoCodec::kVP8, VP8PROFILE_ANY, kUnspecifiedLevel,
color_space, gfx::HdrMetadataType::kSmpteSt2086}));
EXPECT_FALSE(IsDecoderSupportedVideoType({VideoCodec::kTheora,
VIDEO_CODEC_PROFILE_UNKNOWN,
kUnspecifiedLevel, color_space}));
EXPECT_TRUE(IsDecoderSupportedVideoType(
{VideoCodec::kVP8, VP8PROFILE_ANY, kUnspecifiedLevel, color_space,
gfx::HdrMetadataType::kSmpteSt2086}));
color_space.primaries = VideoColorSpace::PrimaryID::BT2020;
color_space.transfer = VideoColorSpace::TransferID::ARIB_STD_B67;
EXPECT_TRUE(IsSupportedVideoType(
EXPECT_TRUE(IsDecoderSupportedVideoType(
{VideoCodec::kVP8, VP8PROFILE_ANY, kUnspecifiedLevel, color_space}));
EXPECT_TRUE(IsSupportedVideoType(
EXPECT_TRUE(IsDecoderSupportedVideoType(
{VideoCodec::kVP9, VP9PROFILE_PROFILE0, kUnspecifiedLevel, color_space}));
EXPECT_FALSE(
IsSupportedVideoType({VideoCodec::kTheora, VIDEO_CODEC_PROFILE_UNKNOWN,
kUnspecifiedLevel, color_space}));
EXPECT_FALSE(IsDecoderSupportedVideoType({VideoCodec::kTheora,
VIDEO_CODEC_PROFILE_UNKNOWN,
kUnspecifiedLevel, color_space}));
// HDR10 metadata only works with the PQ transfer.
EXPECT_FALSE(
IsSupportedVideoType({VideoCodec::kVP8, VP8PROFILE_ANY, kUnspecifiedLevel,
color_space, gfx::HdrMetadataType::kSmpteSt2086}));
EXPECT_FALSE(IsDecoderSupportedVideoType(
{VideoCodec::kVP8, VP8PROFILE_ANY, kUnspecifiedLevel, color_space,
gfx::HdrMetadataType::kSmpteSt2086}));
// ST2094-10 metadata is not supported even if the codec is dolby vision.
EXPECT_FALSE(IsSupportedVideoType(
EXPECT_FALSE(IsDecoderSupportedVideoType(
{VideoCodec::kDolbyVision, DOLBYVISION_PROFILE5, kUnspecifiedLevel,
color_space, gfx::HdrMetadataType::kSmpteSt2094_10}));
EXPECT_FALSE(IsSupportedVideoType({VideoCodec::kVP8, VP8PROFILE_ANY,
kUnspecifiedLevel, color_space,
gfx::HdrMetadataType::kSmpteSt2094_40}));
EXPECT_FALSE(IsDecoderSupportedVideoType(
{VideoCodec::kVP8, VP8PROFILE_ANY, kUnspecifiedLevel, color_space,
gfx::HdrMetadataType::kSmpteSt2094_40}));
}
TEST(SupportedTypesTest, IsBuiltInVideoCodec) {
TEST(SupportedTypesTest, IsDecoderBuiltInVideoCodec) {
#if BUILDFLAG(USE_PROPRIETARY_CODECS) && BUILDFLAG(ENABLE_FFMPEG_VIDEO_DECODERS)
EXPECT_EQ(base::FeatureList::IsEnabled(kBuiltInH264Decoder),
IsBuiltInVideoCodec(VideoCodec::kH264));
IsDecoderBuiltInVideoCodec(VideoCodec::kH264));
#else
EXPECT_FALSE(IsBuiltInVideoCodec(VideoCodec::kH264));
EXPECT_FALSE(IsDecoderBuiltInVideoCodec(VideoCodec::kH264));
#endif // BUILDFLAG(USE_PROPRIETARY_CODECS) &&
// BUILDFLAG(ENABLE_FFMPEG_VIDEO_DECODERS)
EXPECT_FALSE(IsBuiltInVideoCodec(VideoCodec::kTheora));
EXPECT_FALSE(IsDecoderBuiltInVideoCodec(VideoCodec::kTheora));
#if BUILDFLAG(ENABLE_LIBVPX)
EXPECT_TRUE(IsBuiltInVideoCodec(VideoCodec::kVP8));
EXPECT_TRUE(IsDecoderBuiltInVideoCodec(VideoCodec::kVP8));
#else
EXPECT_FALSE(IsBuiltInVideoCodec(VideoCodec::kVP8));
EXPECT_FALSE(IsDecoderBuiltInVideoCodec(VideoCodec::kVP8));
#endif // BUILDFLAG(ENABLE_LIBVPX)
#if BUILDFLAG(ENABLE_LIBVPX)
EXPECT_TRUE(IsBuiltInVideoCodec(VideoCodec::kVP9));
EXPECT_TRUE(IsDecoderBuiltInVideoCodec(VideoCodec::kVP9));
#else
EXPECT_FALSE(IsBuiltInVideoCodec(VideoCodec::kVP9));
EXPECT_FALSE(IsDecoderBuiltInVideoCodec(VideoCodec::kVP9));
#endif // BUILDFLAG(ENABLE_LIBVPX)
#if BUILDFLAG(ENABLE_AV1_DECODER)
EXPECT_TRUE(IsBuiltInVideoCodec(VideoCodec::kAV1));
EXPECT_TRUE(IsDecoderBuiltInVideoCodec(VideoCodec::kAV1));
#else
EXPECT_FALSE(IsBuiltInVideoCodec(VideoCodec::kAV1));
EXPECT_FALSE(IsDecoderBuiltInVideoCodec(VideoCodec::kAV1));
#endif // BUILDFLAG(ENABLE_AV1_DECODER)
EXPECT_FALSE(IsBuiltInVideoCodec(VideoCodec::kUnknown));
EXPECT_FALSE(IsBuiltInVideoCodec(VideoCodec::kMPEG4));
EXPECT_FALSE(IsBuiltInVideoCodec(VideoCodec::kVC1));
EXPECT_FALSE(IsBuiltInVideoCodec(VideoCodec::kMPEG2));
EXPECT_FALSE(IsBuiltInVideoCodec(VideoCodec::kHEVC));
EXPECT_FALSE(IsBuiltInVideoCodec(VideoCodec::kDolbyVision));
EXPECT_FALSE(IsDecoderBuiltInVideoCodec(VideoCodec::kUnknown));
EXPECT_FALSE(IsDecoderBuiltInVideoCodec(VideoCodec::kMPEG4));
EXPECT_FALSE(IsDecoderBuiltInVideoCodec(VideoCodec::kVC1));
EXPECT_FALSE(IsDecoderBuiltInVideoCodec(VideoCodec::kMPEG2));
EXPECT_FALSE(IsDecoderBuiltInVideoCodec(VideoCodec::kHEVC));
EXPECT_FALSE(IsDecoderBuiltInVideoCodec(VideoCodec::kDolbyVision));
}
} // namespace media

@ -798,7 +798,7 @@ bool AVStreamToVideoDecoderConfig(const AVStream* stream,
// Treat dolby vision contents as dolby vision codec only if the
// device support clear DV decoding, otherwise use the original
// HEVC or AVC codec and profile.
if (media::IsSupportedVideoType(type)) {
if (media::IsDecoderSupportedVideoType(type)) {
codec = type.codec;
profile = type.profile;
}

@ -176,7 +176,7 @@ class AudioDecoderTest
protected:
bool IsSupported() const {
if (params_.profile == AudioCodecProfile::kXHE_AAC) {
return IsSupportedAudioType(
return IsDecoderSupportedAudioType(
{AudioCodec::kAAC, AudioCodecProfile::kXHE_AAC, false});
}
return true;

@ -226,7 +226,8 @@ std::unique_ptr<FFmpegDemuxerStream> FFmpegDemuxerStream::Create(
// IsValidConfig internally and return a null scoped_ptr if not valid.
if (!AVStreamToAudioDecoderConfig(stream, audio_config.get()) ||
!audio_config->IsValidConfig() ||
!IsSupportedAudioType(AudioType::FromDecoderConfig(*audio_config))) {
!IsDecoderSupportedAudioType(
AudioType::FromDecoderConfig(*audio_config))) {
MEDIA_LOG(DEBUG, media_log) << "Warning, FFmpegDemuxer failed to create "
"a valid/supported audio decoder "
"configuration from muxed stream, config:"
@ -243,7 +244,8 @@ std::unique_ptr<FFmpegDemuxerStream> FFmpegDemuxerStream::Create(
// IsValidConfig internally and return a null scoped_ptr if not valid.
if (!AVStreamToVideoDecoderConfig(stream, video_config.get()) ||
!video_config->IsValidConfig() ||
!IsSupportedVideoType(VideoType::FromDecoderConfig(*video_config))) {
!IsDecoderSupportedVideoType(
VideoType::FromDecoderConfig(*video_config))) {
MEDIA_LOG(DEBUG, media_log) << "Warning, FFmpegDemuxer failed to create "
"a valid/supported video decoder "
"configuration from muxed stream, config:"

@ -1336,7 +1336,7 @@ TEST_F(FFmpegDemuxerTest, HEVC_in_MP4_container) {
.profile = HEVCPROFILE_MIN,
.color_space = VideoColorSpace::REC709(),
};
if (IsSupportedVideoType(kHevc)) {
if (IsDecoderSupportedVideoType(kHevc)) {
InitializeDemuxer();
DemuxerStream* video = GetStream(DemuxerStream::VIDEO);
@ -1357,7 +1357,7 @@ TEST_F(FFmpegDemuxerTest, Read_AC3_Audio) {
.codec = AudioCodec::kAC3,
.spatial_rendering = false,
};
if (IsSupportedAudioType(kAc3)) {
if (IsDecoderSupportedAudioType(kAc3)) {
InitializeDemuxer();
// Attempt a read from the audio stream and run the message loop until done.
@ -1379,7 +1379,7 @@ TEST_F(FFmpegDemuxerTest, Read_EAC3_Audio) {
.codec = AudioCodec::kEAC3,
.spatial_rendering = false,
};
if (IsSupportedAudioType(kEac3)) {
if (IsDecoderSupportedAudioType(kEac3)) {
InitializeDemuxer();
// Attempt a read from the audio stream and run the message loop until done.
@ -1458,7 +1458,7 @@ TEST_F(FFmpegDemuxerTest, Read_Mp4_Crbug657437) {
}
TEST_F(FFmpegDemuxerTest, XHE_AAC) {
if (!IsSupportedAudioType(
if (!IsDecoderSupportedAudioType(
{AudioCodec::kAAC, AudioCodecProfile::kXHE_AAC, false})) {
GTEST_SKIP() << "Unsupported platform.";
}

@ -174,7 +174,7 @@ const char* FFmpegGlue::GetAllowedAudioDecoders() {
const char* FFmpegGlue::GetAllowedVideoDecoders() {
// This should match the configured lists in //third_party/ffmpeg.
#if BUILDFLAG(USE_PROPRIETARY_CODECS) && BUILDFLAG(ENABLE_FFMPEG_VIDEO_DECODERS)
return IsBuiltInVideoCodec(VideoCodec::kH264) ? "h264" : "";
return IsDecoderBuiltInVideoCodec(VideoCodec::kH264) ? "h264" : "";
#else
return "";
#endif

@ -127,7 +127,7 @@ static void ReleaseVideoBufferImpl(void* opaque, uint8_t* data) {
// static
bool FFmpegVideoDecoder::IsCodecSupported(VideoCodec codec) {
// We only build support for H.264.
return codec == VideoCodec::kH264 && IsBuiltInVideoCodec(codec);
return codec == VideoCodec::kH264 && IsDecoderBuiltInVideoCodec(codec);
}
FFmpegVideoDecoder::FFmpegVideoDecoder(MediaLog* media_log)

@ -58,7 +58,7 @@ bool AreAllAudioCodecsSupported(const std::vector<AudioType>& audio_types) {
return false;
}
for (const auto& type : audio_types) {
if (!IsSupportedAudioType(type)) {
if (!IsDecoderSupportedAudioType(type)) {
return false;
}
}
@ -70,7 +70,7 @@ bool AreAllVideoCodecsSupported(const std::vector<VideoType>& video_types) {
return false;
}
for (const auto& type : video_types) {
if (!IsSupportedVideoType(type)) {
if (!IsDecoderSupportedVideoType(type)) {
return false;
}
}

@ -74,7 +74,7 @@ std::vector<SupportedVideoDecoderConfig> GenerateSupportedConfigs(
if ((codec == VideoCodec::kVP8 && device_info->IsVp8DecoderAvailable()) ||
(codec == VideoCodec::kVP9 && device_info->IsVp9DecoderAvailable()) ||
(codec == VideoCodec::kAV1 && device_info->IsAv1DecoderAvailable()) ||
(codec == VideoCodec::kH264 && IsBuiltInVideoCodec(codec))) {
(codec == VideoCodec::kH264 && IsDecoderBuiltInVideoCodec(codec))) {
// Don't allow OS software decoding for bundled software decoders unless
// the content is encrypted.
const bool can_use_builtin_software_decoder =
@ -354,7 +354,7 @@ void MediaCodecVideoDecoder::Initialize(const VideoDecoderConfig& config,
// If we don't have support support for a given codec, try to initialize
// anyways -- otherwise we're certain to fail playback.
if (!IsVideoDecoderConfigSupported(GetSupportedConfigsInternal(), config) &&
IsBuiltInVideoCodec(config.codec())) {
IsDecoderBuiltInVideoCodec(config.codec())) {
MEDIA_LOG(INFO, media_log_) << "Video configuration is not valid: "
<< config.AsHumanReadableString();
base::BindPostTaskToCurrentDefault(std::move(init_cb))

@ -148,7 +148,7 @@ void VideoToolboxVideoDecoder::Initialize(const VideoDecoderConfig& config,
// If we don't have support support for a given codec, try to initialize
// anyways -- otherwise we're certain to fail playback.
if (!profile_supported && IsBuiltInVideoCodec(config.codec())) {
if (!profile_supported && IsDecoderBuiltInVideoCodec(config.codec())) {
task_runner_->PostTask(
FROM_HERE, base::BindOnce(std::move(init_cb),
DecoderStatus::Codes::kUnsupportedProfile));

@ -344,7 +344,7 @@ void D3D11VideoDecoder::Initialize(const VideoDecoderConfig& config,
// If we don't have support support for a given codec, try to initialize
// anyways -- otherwise we're certain to fail playback.
if (gpu_workarounds_.disable_d3d11_video_decoder ||
(!is_supported && IsBuiltInVideoCodec(config.codec()))) {
(!is_supported && IsDecoderBuiltInVideoCodec(config.codec()))) {
return PostDecoderStatus(
DecoderStatus(DecoderStatus::Codes::kUnsupportedConfig)
.WithData("config", config));

@ -285,7 +285,7 @@ TEST_F(D3D11VideoDecoderTest, DoesNotSupportsH264HIGH10Profile) {
// When the codec is built in this should fail without H264 decoding being
// attempted. If H264 isn't built-in, we should at least attempt initialize.
const bool expect_success = !IsBuiltInVideoCodec(VideoCodec::kH264);
const bool expect_success = !IsDecoderBuiltInVideoCodec(VideoCodec::kH264);
InitializeDecoder(high10, expect_success);
}
@ -315,7 +315,7 @@ TEST_F(D3D11VideoDecoderTest, DoesNotSupportH264IfNoSupportedConfig) {
// When the codec is built in this should fail without H264 decoding being
// attempted. If H264 isn't built-in, we should at least attempt initialize.
const bool expect_success = !IsBuiltInVideoCodec(VideoCodec::kH264);
const bool expect_success = !IsDecoderBuiltInVideoCodec(VideoCodec::kH264);
InitializeDecoder(normal, expect_success);
}

@ -161,7 +161,7 @@ void MojoVideoDecoder::Initialize(const VideoDecoderConfig& config,
if (gpu_factories_ &&
gpu_factories_->IsDecoderConfigSupported(config) ==
GpuVideoAcceleratorFactories::Supported::kFalse &&
IsBuiltInVideoCodec(config.codec())) {
IsDecoderBuiltInVideoCodec(config.codec())) {
FailInit(std::move(init_cb), DecoderStatus::Codes::kUnsupportedConfig);
return;
}

@ -50,7 +50,7 @@ void AddSupplementalCodecsForTesting(gpu::GpuPreferences gpu_preferences) {
supported_audio_types.emplace(config.codec, config.profile,
/*spatial_rendering=*/false);
}
UpdateDefaultSupportedAudioTypes(supported_audio_types);
UpdateDefaultDecoderSupportedAudioTypes(supported_audio_types);
#endif // BUILDFLAG(ENABLE_MOJO_AUDIO_DECODER)
#if BUILDFLAG(PLATFORM_HAS_OPTIONAL_HEVC_SUPPORT)
@ -61,7 +61,7 @@ void AddSupplementalCodecsForTesting(gpu::GpuPreferences gpu_preferences) {
supported_video_profiles.insert(static_cast<VideoCodecProfile>(profile));
}
}
UpdateDefaultSupportedVideoProfiles(supported_video_profiles);
UpdateDefaultDecoderSupportedVideoProfiles(supported_video_profiles);
#endif // BUILDFLAG(PLATFORM_HAS_OPTIONAL_HEVC_SUPPORT)
#endif // BUILDFLAG(ENABLE_MOJO_AUDIO_DECODER) || \
// BUILDFLAG(PLATFORM_HAS_OPTIONAL_HEVC_SUPPORT)

@ -12,12 +12,12 @@ namespace media {
// Uses the standard MojoMediaClient logic to determine which additional
// platform-dependent codecs are supported and registers them so that they are
// considered in the answer provided by `IsSupportedAudioType()` and
// `IsSupportedVideoType()`.
// considered in the answer provided by `IsDecoderSupportedAudioType()` and
// `IsDecoderSupportedVideoType()`.
// Providing `gpu_preferences` might be necessary to get realistic results with
// respect to video codecs. For example, if
// `gpu_preferences.disable_accelerated_video_decode` is true, then
// `IsSupportedVideoType()` will return false for all video types.
// `IsDecoderSupportedVideoType()` will return false for all video types.
void AddSupplementalCodecsForTesting(gpu::GpuPreferences gpu_preferences = {});
} // namespace media

@ -126,7 +126,7 @@ void DefaultDecoderFactory::CreateVideoDecoders(
#endif
#if BUILDFLAG(ENABLE_FFMPEG_VIDEO_DECODERS)
if (IsBuiltInVideoCodec(VideoCodec::kH264)) {
if (IsDecoderBuiltInVideoCodec(VideoCodec::kH264)) {
video_decoders->push_back(std::make_unique<FFmpegVideoDecoder>(media_log));
}
#endif

@ -133,7 +133,7 @@ TEST_F(MediaFoundationRendererIntegrationTest,
// FFMpegDemuxer will verify if video codec is supported internally, add HEVC
// profile here to let demuxer initialization successfully.
media::UpdateDefaultSupportedVideoProfiles(
media::UpdateDefaultDecoderSupportedVideoProfiles(
{media::VideoCodecProfile::HEVCPROFILE_MAIN});
ASSERT_EQ(PIPELINE_OK, Start("bear-3840x2160-hevc.mp4", kUnreliableDuration));

@ -2101,7 +2101,7 @@ std::unique_ptr<AudioDecoder> CreateXheAacDecoder(
}
TEST_F(PipelineIntegrationTest, BasicPlaybackXHE_AAC) {
if (!IsSupportedAudioType(
if (!IsDecoderSupportedAudioType(
{AudioCodec::kAAC, AudioCodecProfile::kXHE_AAC, false})) {
GTEST_SKIP() << "Unsupported platform.";
}
@ -2128,7 +2128,7 @@ TEST_F(PipelineIntegrationTest, BasicPlaybackXHE_AAC) {
}
TEST_F(PipelineIntegrationTest, MSE_BasicPlaybackXHE_AAC) {
if (!IsSupportedAudioType(
if (!IsDecoderSupportedAudioType(
{AudioCodec::kAAC, AudioCodecProfile::kXHE_AAC, false})) {
GTEST_SKIP() << "Unsupported platform.";
}

@ -692,7 +692,7 @@ bool IsAudioConfigurationSupported(
if (audio_config->hasSpatialRendering())
is_spatial_rendering = audio_config->spatialRendering();
return media::IsSupportedAudioType(
return media::IsDecoderSupportedAudioType(
{audio_codec, audio_profile, is_spatial_rendering});
}
@ -732,9 +732,9 @@ bool IsVideoConfigurationSupported(const String& mime_type,
video_color_space = result->color_space;
}
return media::IsSupportedVideoType({result->codec, result->profile,
result->level, video_color_space,
hdr_metadata_type});
return media::IsDecoderSupportedVideoType({result->codec, result->profile,
result->level, video_color_space,
hdr_metadata_type});
}
void OnMediaCapabilitiesEncodingInfo(
@ -1707,7 +1707,8 @@ void MediaCapabilities::OnGpuFactoriesSupport(int callback_id,
PendingCallbackState* pending_cb = pending_cb_map_.at(callback_id);
pending_cb->is_gpu_factories_supported = is_supported;
pending_cb->is_builtin_video_codec = media::IsBuiltInVideoCodec(video_codec);
pending_cb->is_builtin_video_codec =
media::IsDecoderBuiltInVideoCodec(video_codec);
ResolveCallbackIfReady(callback_id);
}

@ -162,7 +162,7 @@ ScriptPromise<AudioDecoderSupport> AudioDecoder::isConfigSupported(
}
AudioDecoderSupport* support = AudioDecoderSupport::Create();
support->setSupported(media::IsSupportedAudioType(*audio_type));
support->setSupported(media::IsDecoderSupportedAudioType(*audio_type));
support->setConfig(CopyConfig(*config));
return ToResolvedPromise<AudioDecoderSupport>(script_state, support);
}

@ -310,8 +310,8 @@ ScriptPromise<VideoDecoderSupport> VideoDecoder::isConfigSupported(
support->setConfig(config_copy);
if ((hw_pref == HardwarePreference::kPreferSoftware &&
!media::IsBuiltInVideoCodec(video_type->codec)) ||
!media::IsSupportedVideoType(*video_type)) {
!media::IsDecoderBuiltInVideoCodec(video_type->codec)) ||
!media::IsDecoderSupportedVideoType(*video_type)) {
support->setSupported(false);
return ToResolvedPromise<VideoDecoderSupport>(script_state, support);
}