From e1eb4fc99f73194460b4b6a7f75eff4c7cb8d3d5 Mon Sep 17 00:00:00 2001 From: Bo-Rong Chen Date: Fri, 13 Sep 2024 20:41:50 -0700 Subject: [PATCH] [android] Fix software video decoder fallback If software video decoder is not available, Cobalt should fallback to hardware video decoder. b/328537630 --- starboard/android/shared/media_codec_bridge.cc | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/starboard/android/shared/media_codec_bridge.cc b/starboard/android/shared/media_codec_bridge.cc index 12f1ecc315f2..c9be40d7f4e9 100644 --- a/starboard/android/shared/media_codec_bridge.cc +++ b/starboard/android/shared/media_codec_bridge.cc @@ -255,7 +255,6 @@ std::unique_ptr MediaCodecBridge::CreateVideoMediaCodecBridge( *error_message = FormatString("Unsupported mime for codec %d", video_codec); return std::unique_ptr(); } - const bool must_support_secure = require_secured_decoder; const bool must_support_hdr = color_metadata; const bool must_support_tunnel_mode = tunnel_mode_audio_session_id != -1; @@ -279,6 +278,16 @@ std::unique_ptr MediaCodecBridge::CreateVideoMediaCodecBridge( /* bitrate = */ 0, /* fps = */ 0); } + if (decoder_name.empty() && require_software_codec) { + // On third pass, forget software codec required. + decoder_name = MediaCapabilitiesCache::GetInstance()->FindVideoDecoder( + mime, must_support_secure, /* must_support_hdr = */ false, + /* require_software_codec = */ false, must_support_tunnel_mode, + /* frame_width = */ 0, + /* frame_height = */ 0, + /* bitrate = */ 0, + /* fps = */ 0); + } if (decoder_name.empty()) { *error_message =