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

Disable progressive playback support by default #4547

Merged
merged 7 commits into from
Dec 19, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
7 changes: 7 additions & 0 deletions media/base/media_switches.cc
Original file line number Diff line number Diff line change
Expand Up @@ -481,6 +481,13 @@ const base::FeatureParam<int> kDecreaseProcessingAudioFifoSizeValue{

#endif

#if BUILDFLAG(USE_STARBOARD_MEDIA)
// When set, Cobalt rejects progressive video formats.
BASE_FEATURE(kCobaltProgressivePlayback,
"CobaltProgressivePlayback",
base::FEATURE_ENABLED_BY_DEFAULT);
#endif // BUILDFLAG(USE_STARBOARD_MEDIA)

#if BUILDFLAG(IS_CHROMEOS)
// To control running audio communication effect on Chrome OS Audio Server.
BASE_FEATURE(kCrOSSystemAEC,
Expand Down
3 changes: 3 additions & 0 deletions media/base/media_switches.h
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,9 @@ MEDIA_EXPORT BASE_DECLARE_FEATURE(kDecreaseProcessingAudioFifoSize);
MEDIA_EXPORT extern const base::FeatureParam<int>
kDecreaseProcessingAudioFifoSizeValue;
#endif
#if BUILDFLAG(USE_STARBOARD_MEDIA)
MEDIA_EXPORT BASE_DECLARE_FEATURE(kCobaltProgressivePlayback);
#endif // BUILDFLAG(USE_STARBOARD_MEDIA)
#if BUILDFLAG(IS_CHROMEOS)
MEDIA_EXPORT BASE_DECLARE_FEATURE(kCrOSSystemAEC);
MEDIA_EXPORT BASE_DECLARE_FEATURE(kCrOSSystemAECDeactivatedGroups);
Expand Down
11 changes: 9 additions & 2 deletions media/filters/demuxer_manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@
#endif // BUILDFLAG(ENABLE_HLS_DEMUXER)

#if BUILDFLAG(ENABLE_FFMPEG)
// ProgressiveDemuxer is enabled when use_starboard_media=true and media_use_ffmpeg=false.
// The ProgressiveDemuxer is enabled when use_starboard_media=true and
osagie98 marked this conversation as resolved.
Show resolved Hide resolved
// media_use_ffmpeg=false. This can be overridden by the BASE_FEATURE
// CobaltProgressivePlayback, which will disable the ProgressiveDemuxer
// when false.
#elif BUILDFLAG(USE_STARBOARD_MEDIA)
#include "media/starboard/progressive/demuxer_extension_wrapper.h" // nogncheck
#include "media/starboard/progressive/progressive_demuxer.h" // nogncheck
Expand Down Expand Up @@ -417,7 +420,11 @@ PipelineStatus DemuxerManager::CreateDemuxer(
#if BUILDFLAG(ENABLE_FFMPEG)
SetDemuxer(CreateFFmpegDemuxer());
#elif BUILDFLAG(USE_STARBOARD_MEDIA)
SetDemuxer(CreateProgressiveDemuxer());
if (base::FeatureList::IsEnabled(media::kCobaltProgressivePlayback)) {
SetDemuxer(CreateProgressiveDemuxer());
} else {
LOG(INFO) << "Cobalt progressive playback is disabled via base features.";
osagie98 marked this conversation as resolved.
Show resolved Hide resolved
}
#else
return DEMUXER_ERROR_COULD_NOT_OPEN;
#endif
Expand Down
49 changes: 37 additions & 12 deletions third_party/blink/renderer/core/html/media/html_media_element.cc
Original file line number Diff line number Diff line change
Expand Up @@ -405,26 +405,51 @@ std::ostream& operator<<(std::ostream& stream,
return stream << static_cast<void const*>(&media_element);
}

#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 formats under the "codecs" parameter.
bool IsProgressiveFormat(const ContentType& content_type) {
String type = content_type.GetType();
String codecs = content_type.Parameter("codecs");
if (!type.empty() && !codecs.empty()) {
osagie98 marked this conversation as resolved.
Show resolved Hide resolved
Vector<String> split_codecs;
String separator(", ");
codecs.Split(separator, split_codecs);
return type.Utf8() == "video/mp4" && split_codecs.size() == 2;
}
return false;
}
#endif // BUILDFLAG(USE_STARBOARD_MEDIA)

} // anonymous namespace

// static
MIMETypeRegistry::SupportsType HTMLMediaElement::GetSupportsType(
const ContentType& content_type) {
#if BUILDFLAG(USE_STARBOARD_MEDIA)
// Interupt Chromium's IsTypeSupported() from here for better performance.
SbMediaSupportType support_type =
SbMediaCanPlayMimeAndKeySystem(content_type.Raw().Ascii().c_str(), "");
MIMETypeRegistry::SupportsType result;
switch (support_type) {
case kSbMediaSupportTypeNotSupported:
result = MIMETypeRegistry::kNotSupported;
break;
case kSbMediaSupportTypeMaybe:
result = MIMETypeRegistry::kMaybeSupported;
break;
case kSbMediaSupportTypeProbably:
result = MIMETypeRegistry::kSupported;
break;
if (!base::FeatureList::IsEnabled(media::kCobaltProgressivePlayback) &&
IsProgressiveFormat(content_type)) {
LOG(INFO) << "Content type \'" << content_type.Raw()
osagie98 marked this conversation as resolved.
Show resolved Hide resolved
<< "\' is unsupported as Cobalt progressive playback is disabled "
"via base features.";
result = MIMETypeRegistry::kNotSupported;
} else {
SbMediaSupportType support_type =
osagie98 marked this conversation as resolved.
Show resolved Hide resolved
SbMediaCanPlayMimeAndKeySystem(content_type.Raw().Ascii().c_str(), "");
switch (support_type) {
case kSbMediaSupportTypeNotSupported:
result = MIMETypeRegistry::kNotSupported;
break;
case kSbMediaSupportTypeMaybe:
result = MIMETypeRegistry::kMaybeSupported;
break;
case kSbMediaSupportTypeProbably:
result = MIMETypeRegistry::kSupported;
break;
}
}
LOG(INFO) << __func__ << "(" << content_type.Raw() << ") -> " << result;
return result;
Expand Down
Loading