diff --git a/third_party/blink/renderer/core/html/media/html_media_element.cc b/third_party/blink/renderer/core/html/media/html_media_element.cc index 0ecba68e421f..e565c5c81d77 100644 --- a/third_party/blink/renderer/core/html/media/html_media_element.cc +++ b/third_party/blink/renderer/core/html/media/html_media_element.cc @@ -124,6 +124,7 @@ // For BUILDFLAG(USE_STARBOARD_MEDIA) #include "build/build_config.h" #if BUILDFLAG(USE_STARBOARD_MEDIA) +#include "base/strings/string_util.h" #include "starboard/media.h" #endif // BUILDFLAG(USE_STARBOARD_MEDIA) @@ -408,7 +409,8 @@ std::ostream& operator<<(std::ostream& stream, #if BUILDFLAG(USE_STARBOARD_MEDIA) // Checks for progressive formats served by the YouTube H5 player. // These formats have a mime type of "video/mp4", and lists both audio and -// video codecs under the "codecs" parameter. +// video codecs under the "codecs" parameter. This is not a comprehensive +// check and may not detect all progressive formats. bool IsProgressiveFormat(const ContentType& content_type) { const String type = content_type.GetType(); const String codecs = content_type.Parameter("codecs"); @@ -418,7 +420,7 @@ bool IsProgressiveFormat(const ContentType& content_type) { } Vector split_codecs; - const String separator(", "); + const String separator(","); codecs.Split(separator, split_codecs); return type.Utf8() == "video/mp4" && split_codecs.size() == 2; } diff --git a/third_party/blink/renderer/core/html/media/html_media_element_test.cc b/third_party/blink/renderer/core/html/media/html_media_element_test.cc index 81841cfae1d3..c3439a87a486 100644 --- a/third_party/blink/renderer/core/html/media/html_media_element_test.cc +++ b/third_party/blink/renderer/core/html/media/html_media_element_test.cc @@ -1578,6 +1578,8 @@ TEST_P(HTMLMediaElementTest, CanFreezeWithMediaPlayerAttached) { TEST(HTMLMediaElementTest, CanHandleCobaltProgressiveSupportQueries) { const ContentType progressive_type( "video/mp4; codecs=\"avc1.42001E, mp4a.40.2\""); + const ContentType progressive_type_missing_whitespace( + "video/mp4; codecs=\"avc1.42001E,mp4a.40.2\""); const ContentType adaptive_video_type( "video/mp4; codecs=\"avc1.4d4015\"; framerate=30"); const ContentType adaptive_audio_type( @@ -1590,6 +1592,11 @@ TEST(HTMLMediaElementTest, CanHandleCobaltProgressiveSupportQueries) { // disabled. EXPECT_EQ(HTMLMediaElement::GetSupportsType(progressive_type), MIMETypeRegistry::kNotSupported); + // Reject progressive content types when the "codecs" parameter lacks + // whitespace. + EXPECT_EQ( + HTMLMediaElement::GetSupportsType(progressive_type_missing_whitespace), + MIMETypeRegistry::kNotSupported); // Continue to support adaptive content types. EXPECT_NE(HTMLMediaElement::GetSupportsType(adaptive_video_type), MIMETypeRegistry::kNotSupported); @@ -1603,6 +1610,11 @@ TEST(HTMLMediaElementTest, CanHandleCobaltProgressiveSupportQueries) { // enabled. EXPECT_NE(HTMLMediaElement::GetSupportsType(progressive_type), MIMETypeRegistry::kNotSupported); + // Continue to accept progressive content types when the "codecs" parameter + // lacks whitespace. + EXPECT_NE( + HTMLMediaElement::GetSupportsType(progressive_type_missing_whitespace), + MIMETypeRegistry::kNotSupported); // Continue to support adaptive content types. EXPECT_NE(HTMLMediaElement::GetSupportsType(adaptive_video_type), MIMETypeRegistry::kNotSupported);