diff --git a/cobalt/browser/browser_module.cc b/cobalt/browser/browser_module.cc index 75a27b117a44..70ff6dc75aa5 100644 --- a/cobalt/browser/browser_module.cc +++ b/cobalt/browser/browser_module.cc @@ -398,6 +398,10 @@ BrowserModule::BrowserModule(const GURL& url, base::Unretained(this)))); } + if (command_line->HasSwitch(switches::kDisableProgressivePlayback)) { + can_play_type_handler_->DisableProgressiveSupport(); + } + // Set the fallback splash screen url to the default fallback url. fallback_splash_screen_url_ = options.fallback_splash_screen_url; diff --git a/cobalt/browser/switches.cc b/cobalt/browser/switches.cc index 7a3b5026324e..161b13f750e4 100644 --- a/cobalt/browser/switches.cc +++ b/cobalt/browser/switches.cc @@ -333,6 +333,10 @@ const char kOmitDeviceAuthenticationQueryParametersHelp[] = "When set, no device authentication parameters will be appended to the" "initial URL."; +const char kDisableProgressivePlayback[] = "disable_progressive_playback"; +const char kDisableProgressivePlaybackHelp[] = + "Setting this switch disables support for progressive media playback"; + const char kProxy[] = "proxy"; const char kProxyHelp[] = "Specifies a proxy to use for network connections. " @@ -507,6 +511,7 @@ std::string HelpMessage() { {kOffscreenTargetCacheSizeInBytes, kOffscreenTargetCacheSizeInBytesHelp}, {kOmitDeviceAuthenticationQueryParameters, kOmitDeviceAuthenticationQueryParametersHelp}, + {kDisableProgressivePlayback, kDisableProgressivePlaybackHelp}, {kProxy, kProxyHelp}, {kQrCodeOverlay, kQrCodeOverlayHelp}, {kRemoteTypefaceCacheSizeInBytes, kRemoteTypefaceCacheSizeInBytesHelp}, diff --git a/cobalt/browser/switches.h b/cobalt/browser/switches.h index 982389104553..4cfeb24877f5 100644 --- a/cobalt/browser/switches.h +++ b/cobalt/browser/switches.h @@ -131,6 +131,7 @@ extern const char kOffscreenTargetCacheSizeInBytes[]; extern const char kOffscreenTargetCacheSizeInBytesHelp[]; extern const char kOmitDeviceAuthenticationQueryParameters[]; extern const char kOmitDeviceAuthenticationQueryParametersHelp[]; +extern const char kDisableProgressivePlayback[]; extern const char kProxy[]; extern const char kProxyHelp[]; extern const char kQrCodeOverlay[]; diff --git a/cobalt/media/can_play_type_handler.h b/cobalt/media/can_play_type_handler.h index cc9734b22665..906b44749831 100644 --- a/cobalt/media/can_play_type_handler.h +++ b/cobalt/media/can_play_type_handler.h @@ -33,6 +33,7 @@ class CanPlayTypeHandler { virtual void SetDisabledMediaCodecs(const std::string& codecs) = 0; virtual void SetDisabledMediaEncryptionSchemes( const std::string& disabled_encryption_schemes) = 0; + virtual void DisableProgressiveSupport() = 0; protected: CanPlayTypeHandler() {} diff --git a/cobalt/media/media_module.cc b/cobalt/media/media_module.cc index f245ac43a9e3..0e0ed2062d69 100644 --- a/cobalt/media/media_module.cc +++ b/cobalt/media/media_module.cc @@ -93,24 +93,6 @@ static std::string ExtractEncryptionScheme(const std::string& key_system) { class CanPlayTypeHandlerStarboard : public CanPlayTypeHandler { public: - void SetDisabledMediaCodecs( - const std::string& disabled_media_codecs) override { - disabled_media_codecs_ = - base::SplitString(disabled_media_codecs, ";", base::TRIM_WHITESPACE, - base::SPLIT_WANT_NONEMPTY); - LOG(INFO) << "Disabled media codecs \"" << disabled_media_codecs - << "\" from console/command line."; - } - - void SetDisabledMediaEncryptionSchemes( - const std::string& disabled_encryption_schemes) override { - disabled_encryption_schemes_ = - base::SplitString(disabled_encryption_schemes, ";", - base::TRIM_WHITESPACE, base::SPLIT_WANT_NONEMPTY); - LOG(INFO) << "Disabled encryption scheme(s) \"" - << disabled_encryption_schemes << "\" from command line."; - } - SbMediaSupportType CanPlayProgressive( const std::string& mime_type) const override { // |mime_type| is something like: @@ -122,8 +104,9 @@ class CanPlayTypeHandlerStarboard : public CanPlayTypeHandler { // progressive. SbMediaSupportType support_type; media::FormatSupportQueryMetrics metrics; - if (strstr(mime_type.c_str(), "video/mp4") == 0 && - strstr(mime_type.c_str(), "application/x-mpegURL") == 0) { + if (disable_progressive_support_ || + (strstr(mime_type.c_str(), "video/mp4") == 0 && + strstr(mime_type.c_str(), "application/x-mpegURL") == 0)) { support_type = kSbMediaSupportTypeNotSupported; } else { support_type = CanPlayType(mime_type, ""); @@ -145,6 +128,29 @@ class CanPlayTypeHandlerStarboard : public CanPlayTypeHandler { return support_type; } + void SetDisabledMediaCodecs( + const std::string& disabled_media_codecs) override { + disabled_media_codecs_ = + base::SplitString(disabled_media_codecs, ";", base::TRIM_WHITESPACE, + base::SPLIT_WANT_NONEMPTY); + LOG(INFO) << "Disabled media codecs \"" << disabled_media_codecs + << "\" from console/command line."; + } + + void SetDisabledMediaEncryptionSchemes( + const std::string& disabled_encryption_schemes) override { + disabled_encryption_schemes_ = + base::SplitString(disabled_encryption_schemes, ";", + base::TRIM_WHITESPACE, base::SPLIT_WANT_NONEMPTY); + LOG(INFO) << "Disabled encryption scheme(s) \"" + << disabled_encryption_schemes << "\" from command line."; + } + + void DisableProgressiveSupport() override { + disable_progressive_support_ = true; + LOG(INFO) << "Disabled progressive playback support from command line"; + } + private: SbMediaSupportType CanPlayType(const std::string& mime_type, const std::string& key_system) const { @@ -181,6 +187,7 @@ class CanPlayTypeHandlerStarboard : public CanPlayTypeHandler { // List of disabled DRM encryption schemes that will be treated as // unsupported. std::vector disabled_encryption_schemes_; + bool disable_progressive_support_ = false; }; } // namespace @@ -247,6 +254,11 @@ bool MediaModule::SetConfiguration(const std::string& name, int32 value) { return true; } } + } else if (name == "DisableProgressivePlayback") { + disable_progressive_playback_ = value; + LOG(INFO) << "Progressive playback is " << (value ? "disabled" : "enabled") + << "."; + return true; } return false; @@ -268,7 +280,7 @@ std::unique_ptr MediaModule::CreateWebMediaPlayer( #if SB_API_VERSION >= 15 audio_write_duration_local_, audio_write_duration_remote_, #endif // SB_API_VERSION >= 15 - &media_log_)); + disable_progressive_playback_, &media_log_)); } void MediaModule::Suspend() { diff --git a/cobalt/media/media_module.h b/cobalt/media/media_module.h index f29973a1f615..73283348ebb7 100644 --- a/cobalt/media/media_module.h +++ b/cobalt/media/media_module.h @@ -141,6 +141,8 @@ class MediaModule : public WebMediaPlayerFactory, #endif // SB_API_VERSION >= 15 DecoderBufferAllocator decoder_buffer_allocator_; + + bool disable_progressive_playback_ = false; }; } // namespace media diff --git a/cobalt/media/player/web_media_player_impl.cc b/cobalt/media/player/web_media_player_impl.cc index 62189b7b3061..c08109989f1e 100644 --- a/cobalt/media/player/web_media_player_impl.cc +++ b/cobalt/media/player/web_media_player_impl.cc @@ -13,6 +13,7 @@ #include "base/bind.h" #include "base/bind_helpers.h" +#include "base/command_line.h" #include "base/metrics/histogram.h" #include "base/metrics/histogram_macros.h" #include "base/strings/string_number_conversions.h" @@ -22,6 +23,7 @@ #include "base/task/sequenced_task_runner.h" #include "base/trace_event/trace_event.h" #include "cobalt/base/instance_counter.h" +#include "cobalt/browser/switches.h" #include "cobalt/media/base/drm_system.h" #include "cobalt/media/base/metrics_provider.h" #include "cobalt/media/base/sbplayer_pipeline.h" @@ -115,7 +117,7 @@ WebMediaPlayerImpl::WebMediaPlayerImpl( base::TimeDelta audio_write_duration_local, base::TimeDelta audio_write_duration_remote, #endif // SB_API_VERSION >= 15 - ::media::MediaLog* const media_log) + bool disable_progressive_playback, ::media::MediaLog* const media_log) : pipeline_thread_("media_pipeline"), network_state_(WebMediaPlayer::kNetworkStateEmpty), ready_state_(WebMediaPlayer::kReadyStateHaveNothing), @@ -126,6 +128,7 @@ WebMediaPlayerImpl::WebMediaPlayerImpl( max_audio_samples_per_write_(max_audio_samples_per_write), force_punch_out_by_default_(force_punch_out_by_default), proxy_(new WebMediaPlayerProxy(task_runner_, this)), + disable_progressive_playback_(disable_progressive_playback), media_log_(media_log), is_local_source_(false), suppress_destruction_errors_(false), @@ -270,6 +273,17 @@ void WebMediaPlayerImpl::LoadProgressive( DCHECK_EQ(task_runner_, base::SequencedTaskRunner::GetCurrentDefault()); UMA_HISTOGRAM_ENUMERATION("Media.URLScheme", URLScheme(url), kMaxURLScheme); + base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); + if (disable_progressive_playback_ || + command_line->HasSwitch(browser::switches::kDisableProgressivePlayback)) { + LOG(INFO) + << "Disabled progressive playback support via command line or H5vcc"; + SetNetworkError( + WebMediaPlayer::kNetworkStateFormatError, + "Disabled progressive playback support via command line or H5vcc"); + return; + } + LOG(INFO) << "Start PROGRESSIVE playback"; // Handle any volume changes that occurred before load(). diff --git a/cobalt/media/player/web_media_player_impl.h b/cobalt/media/player/web_media_player_impl.h index 6d4c55f39f9c..213b964b4403 100644 --- a/cobalt/media/player/web_media_player_impl.h +++ b/cobalt/media/player/web_media_player_impl.h @@ -116,6 +116,7 @@ class WebMediaPlayerImpl : public WebMediaPlayer, base::TimeDelta audio_write_duration_local, base::TimeDelta audio_write_duration_remote, #endif // SB_API_VERSION >= 15 + bool disable_progressive_playback, ::media::MediaLog* const media_log); ~WebMediaPlayerImpl() override; @@ -329,6 +330,8 @@ class WebMediaPlayerImpl : public WebMediaPlayer, bool is_resuming_from_background_mode_ = false; + const bool disable_progressive_playback_; + DISALLOW_COPY_AND_ASSIGN(WebMediaPlayerImpl); };