Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update check for progressive formats #4624

Merged
merged 4 commits into from
Dec 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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");
Expand All @@ -418,7 +420,7 @@ bool IsProgressiveFormat(const ContentType& content_type) {
}

Vector<String> split_codecs;
const String separator(", ");
const String separator(",");
codecs.Split(separator, split_codecs);
return type.Utf8() == "video/mp4" && split_codecs.size() == 2;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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);
Expand All @@ -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);
Expand Down
Loading