feat: add {stream} opt to custom protocol registry to configure media player (#22955)
This commit is contained in:
parent
261f385b5e
commit
c6c022dc46
15 changed files with 719 additions and 4 deletions
|
@ -99,3 +99,4 @@ disable_unnecessary_ischromefirstrun_check.patch
|
|||
disable_dcheck_that_fails_with_software_compositing.patch
|
||||
fix_swap_global_proxies_before_initializing_the_windows_proxies.patch
|
||||
fix_default_to_ntlm_v2_in_network_service.patch
|
||||
feat_add_streaming-protocol_registry_to_multibuffer_data_source.patch
|
||||
|
|
|
@ -0,0 +1,82 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Paul Frazee <pfrazee@gmail.com>
|
||||
Date: Sat, 6 Jun 2020 10:30:45 -0500
|
||||
Subject: feat: add streaming-protocol registry to multibuffer_data_source
|
||||
|
||||
blink::WebMediaPlayerImpl - which provides the <video> and <audio> behaviors - needs to know
|
||||
whether a data source will stream or fully buffer the response. It determines this behavior
|
||||
with MultibufferDataSource::AssumeFullyBuffered() which has http/s hardwired. An incorrect
|
||||
determination will cause the video/audio to fail playing.
|
||||
|
||||
This patch adds a list of "streaming protocols" to the MultibufferDataSource in order to allow
|
||||
other protocols to register their streaming behavior. MultibufferDataSource::AssumeFullyBuffered()
|
||||
then refers to the list so that it can correctly determine the data source's settings.
|
||||
|
||||
diff --git a/media/blink/multibuffer_data_source.cc b/media/blink/multibuffer_data_source.cc
|
||||
index 0f6ae1fb8b4ff9f24ce3f407b7359e016fc6de5f..947812e1d877ad0c9434ea958598dd9a38227d46 100644
|
||||
--- a/media/blink/multibuffer_data_source.cc
|
||||
+++ b/media/blink/multibuffer_data_source.cc
|
||||
@@ -10,9 +10,11 @@
|
||||
#include "base/callback_helpers.h"
|
||||
#include "base/location.h"
|
||||
#include "base/macros.h"
|
||||
+#include "base/no_destructor.h"
|
||||
#include "base/numerics/ranges.h"
|
||||
#include "base/numerics/safe_conversions.h"
|
||||
#include "base/single_thread_task_runner.h"
|
||||
+#include "base/strings/string_util.h"
|
||||
#include "media/base/media_log.h"
|
||||
#include "media/blink/buffered_data_source_host_impl.h"
|
||||
#include "media/blink/multibuffer_reader.h"
|
||||
@@ -65,10 +67,22 @@ const int kUpdateBufferSizeFrequency = 32;
|
||||
// How long to we delay a seek after a read?
|
||||
constexpr base::TimeDelta kSeekDelay = base::TimeDelta::FromMilliseconds(20);
|
||||
|
||||
+std::vector<std::string>* GetStreamingSchemes() {
|
||||
+ static base::NoDestructor<std::vector<std::string>> streaming_schemes({
|
||||
+ url::kHttpsScheme,
|
||||
+ url::kHttpScheme
|
||||
+ });
|
||||
+ return streaming_schemes.get();
|
||||
+}
|
||||
+
|
||||
} // namespace
|
||||
|
||||
namespace media {
|
||||
|
||||
+void AddStreamingScheme(const char* new_scheme) {
|
||||
+ GetStreamingSchemes()->push_back(new_scheme);
|
||||
+}
|
||||
+
|
||||
class MultibufferDataSource::ReadOperation {
|
||||
public:
|
||||
ReadOperation(int64_t position,
|
||||
@@ -158,7 +172,14 @@ bool MultibufferDataSource::media_has_played() const {
|
||||
|
||||
bool MultibufferDataSource::AssumeFullyBuffered() const {
|
||||
DCHECK(url_data_);
|
||||
- return !url_data_->url().SchemeIsHTTPOrHTTPS();
|
||||
+
|
||||
+ const std::string scheme = url_data_->url().scheme();
|
||||
+ for (const std::string& streaming_scheme : *GetStreamingSchemes()) {
|
||||
+ if (base::LowerCaseEqualsASCII(scheme, streaming_scheme)) {
|
||||
+ return false;
|
||||
+ }
|
||||
+ }
|
||||
+ return true;
|
||||
}
|
||||
|
||||
void MultibufferDataSource::SetReader(MultiBufferReader* reader) {
|
||||
diff --git a/media/blink/multibuffer_data_source.h b/media/blink/multibuffer_data_source.h
|
||||
index 3da5a7bba5e7cc0f54998a81649f4dd9d78aa7be..938ae6ebc92315b3a75019c3bc8c9058106f7695 100644
|
||||
--- a/media/blink/multibuffer_data_source.h
|
||||
+++ b/media/blink/multibuffer_data_source.h
|
||||
@@ -30,6 +30,8 @@ class BufferedDataSourceHost;
|
||||
class MediaLog;
|
||||
class MultiBufferReader;
|
||||
|
||||
+void MEDIA_BLINK_EXPORT AddStreamingScheme(const char* new_scheme);
|
||||
+
|
||||
// A data source capable of loading URLs and buffering the data using an
|
||||
// in-memory sliding window.
|
||||
//
|
Loading…
Add table
Add a link
Reference in a new issue