Skip to content

Commit 678fb40

Browse files
fix: video scrubbing on playback (#47703)
* fix: fix video scrubbing on playback * chore: address review feedback --------- Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>
1 parent 8806499 commit 678fb40

File tree

1 file changed

+70
-15
lines changed

1 file changed

+70
-15
lines changed

patches/chromium/feat_add_streaming-protocol_registry_to_multibuffer_data_source.patch

Lines changed: 70 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,12 @@ This patch adds a list of "streaming protocols" to the MultibufferDataSource in
1212
other protocols to register their streaming behavior. MultibufferDataSource::AssumeFullyBuffered()
1313
then refers to the list so that it can correctly determine the data source's settings.
1414

15+
This patch also reverts https://chromium-review.googlesource.com/c/chromium/src/+/6431846,
16+
which removed range-requests-supported on non-http protocols. See https://issues.chromium.org/issues/41161335
17+
for more information.
18+
1519
diff --git a/third_party/blink/renderer/platform/media/multi_buffer_data_source.cc b/third_party/blink/renderer/platform/media/multi_buffer_data_source.cc
16-
index 14eeb24b27ae9c3798fac7cfbb2ef53b85250dbe..2ce01bf1d8827a57c666a9d92454e0746396580b 100644
20+
index 14eeb24b27ae9c3798fac7cfbb2ef53b85250dbe..dfcb69a1bf75af5e315e02702109b958fa8edfcf 100644
1721
--- a/third_party/blink/renderer/platform/media/multi_buffer_data_source.cc
1822
+++ b/third_party/blink/renderer/platform/media/multi_buffer_data_source.cc
1923
@@ -11,8 +11,10 @@
@@ -27,28 +31,33 @@ index 14eeb24b27ae9c3798fac7cfbb2ef53b85250dbe..2ce01bf1d8827a57c666a9d92454e074
2731
#include "media/base/media_log.h"
2832
#include "net/base/net_errors.h"
2933
#include "third_party/blink/renderer/platform/media/buffered_data_source_host_impl.h"
30-
@@ -67,8 +69,20 @@ const int kUpdateBufferSizeFrequency = 32;
31-
// How long to we delay a seek after a read?
32-
constexpr base::TimeDelta kSeekDelay = base::Milliseconds(20);
34+
@@ -69,6 +71,10 @@ constexpr base::TimeDelta kSeekDelay = base::Milliseconds(20);
3335

34-
+std::vector<std::string>* GetStreamingSchemes() {
35-
+ static base::NoDestructor<std::vector<std::string>> streaming_schemes({
36-
+ url::kHttpsScheme,
37-
+ url::kHttpScheme
38-
+ });
39-
+ return streaming_schemes.get();
40-
+}
41-
+
4236
} // namespace
4337

4438
+void AddStreamingScheme(const char* new_scheme) {
45-
+ GetStreamingSchemes()->push_back(new_scheme);
39+
+ MultiBufferDataSource::GetStreamingSchemes()->push_back(new_scheme);
4640
+}
4741
+
4842
class MultiBufferDataSource::ReadOperation {
4943
public:
5044
ReadOperation() = delete;
51-
@@ -149,7 +163,14 @@ bool MultiBufferDataSource::media_has_played() const {
45+
@@ -143,13 +149,29 @@ MultiBufferDataSource::~MultiBufferDataSource() {
46+
DCHECK(render_task_runner_->BelongsToCurrentThread());
47+
}
48+
49+
+// static
50+
+std::vector<std::string>* MultiBufferDataSource::GetStreamingSchemes() {
51+
+ static base::NoDestructor<std::vector<std::string>> streaming_schemes({
52+
+ url::kHttpsScheme,
53+
+ url::kHttpScheme
54+
+ });
55+
+ return streaming_schemes.get();
56+
+}
57+
+
58+
bool MultiBufferDataSource::media_has_played() const {
59+
return media_has_played_;
60+
}
5261

5362
bool MultiBufferDataSource::AssumeFullyBuffered() const {
5463
DCHECK(url_data_);
@@ -65,7 +74,7 @@ index 14eeb24b27ae9c3798fac7cfbb2ef53b85250dbe..2ce01bf1d8827a57c666a9d92454e074
6574

6675
void MultiBufferDataSource::SetReader(
6776
diff --git a/third_party/blink/renderer/platform/media/multi_buffer_data_source.h b/third_party/blink/renderer/platform/media/multi_buffer_data_source.h
68-
index 8c92f1c0c5028069cdad967b5be2bccf8005ed43..40217c27a4cfc43d3143c7eeb2b1e54d8e20cbf6 100644
77+
index 8c92f1c0c5028069cdad967b5be2bccf8005ed43..8b49dc182296f7f277981aed29b58947fb0980cb 100644
6978
--- a/third_party/blink/renderer/platform/media/multi_buffer_data_source.h
7079
+++ b/third_party/blink/renderer/platform/media/multi_buffer_data_source.h
7180
@@ -17,6 +17,7 @@
@@ -85,3 +94,49 @@ index 8c92f1c0c5028069cdad967b5be2bccf8005ed43..40217c27a4cfc43d3143c7eeb2b1e54d
8594
// A data source capable of loading URLs and buffering the data using an
8695
// in-memory sliding window.
8796
//
97+
@@ -63,6 +66,8 @@ class PLATFORM_EXPORT MultiBufferDataSource
98+
return url_data_->mime_type();
99+
}
100+
101+
+ static std::vector<std::string>* GetStreamingSchemes();
102+
+
103+
// Method called on the render thread.
104+
using InitializeCB = base::OnceCallback<void(bool)>;
105+
void Initialize(InitializeCB init_cb) override;
106+
diff --git a/third_party/blink/renderer/platform/media/resource_multi_buffer_data_provider.cc b/third_party/blink/renderer/platform/media/resource_multi_buffer_data_provider.cc
107+
index 1fdc54c1de28ef0c32fc9a386097d95b48aedcaa..5822251daaa9fa5a49ace1bdad684e0076c225dc 100644
108+
--- a/third_party/blink/renderer/platform/media/resource_multi_buffer_data_provider.cc
109+
+++ b/third_party/blink/renderer/platform/media/resource_multi_buffer_data_provider.cc
110+
@@ -8,6 +8,7 @@
111+
#include <stddef.h>
112+
113+
#include <utility>
114+
+#include <algorithm>
115+
116+
#include "base/containers/contains.h"
117+
#include "base/location.h"
118+
@@ -30,6 +31,7 @@
119+
#include "third_party/blink/public/platform/web_url_response.h"
120+
#include "third_party/blink/public/web/web_associated_url_loader.h"
121+
#include "third_party/blink/renderer/platform/media/cache_util.h"
122+
+#include "third_party/blink/renderer/platform/media/multi_buffer_data_source.h"
123+
#include "third_party/blink/renderer/platform/media/resource_fetch_context.h"
124+
#include "third_party/blink/renderer/platform/media/url_index.h"
125+
#include "third_party/blink/renderer/platform/weborigin/security_origin.h"
126+
@@ -313,6 +315,16 @@ void ResourceMultiBufferDataProvider::DidReceiveResponse(
127+
do_fail = true;
128+
}
129+
} else {
130+
+ // For non-HTTP protocols, only set range_supported for registered streaming schemes
131+
+ const std::string scheme = destination_url_data->url().Protocol().Ascii();
132+
+
133+
+ if (std::ranges::any_of(*MultiBufferDataSource::GetStreamingSchemes(),
134+
+ [&scheme](const std::string& streaming_scheme) {
135+
+ return base::EqualsCaseInsensitiveASCII(scheme, streaming_scheme);
136+
+ })) {
137+
+ destination_url_data->set_range_supported();
138+
+ }
139+
+
140+
if (content_length != kPositionNotSpecified) {
141+
destination_url_data->set_length(content_length + byte_pos());
142+
}

0 commit comments

Comments
 (0)