From c6c022dc46258b439c311da7feaa15d24dc08b16 Mon Sep 17 00:00:00 2001 From: Paul Frazee Date: Mon, 8 Jun 2020 11:49:36 -0500 Subject: [PATCH] feat: add {stream} opt to custom protocol registry to configure media player (#22955) --- BUILD.gn | 1 + docs/api/protocol.md | 9 +- docs/api/structures/custom-scheme.md | 1 + patches/chromium/.patches | 1 + ..._registry_to_multibuffer_data_source.patch | 82 +++ shell/browser/api/electron_api_protocol.cc | 10 + shell/browser/electron_browser_client.cc | 3 +- shell/common/options_switches.cc | 3 + shell/common/options_switches.h | 1 + shell/renderer/renderer_client_base.cc | 6 + spec-main/api-protocol-spec.ts | 96 ++++ spec-main/index.js | 3 +- spec-main/video-helpers.js | 493 ++++++++++++++++++ spec/fixtures/pages/video.html | 14 + spec/fixtures/video-source-image.webp | Bin 0 -> 63758 bytes 15 files changed, 719 insertions(+), 4 deletions(-) create mode 100644 patches/chromium/feat_add_streaming-protocol_registry_to_multibuffer_data_source.patch create mode 100644 spec-main/video-helpers.js create mode 100644 spec/fixtures/pages/video.html create mode 100644 spec/fixtures/video-source-image.webp diff --git a/BUILD.gn b/BUILD.gn index d7a4e85fb9..a7d8a92156 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -348,6 +348,7 @@ source_set("electron_lib") { "//device/bluetooth", "//device/bluetooth/public/cpp", "//gin", + "//media/blink:blink", "//media/capture/mojom:video_capture", "//media/mojo/mojom", "//net:extras", diff --git a/docs/api/protocol.md b/docs/api/protocol.md index f37c06802b..d922f3f88a 100644 --- a/docs/api/protocol.md +++ b/docs/api/protocol.md @@ -63,8 +63,8 @@ The `protocol` module has the following methods: module gets emitted and can be called only once. Registers the `scheme` as standard, secure, bypasses content security policy for -resources, allows registering ServiceWorker and supports fetch API. Specify a -privilege with the value of `true` to enable the capability. +resources, allows registering ServiceWorker, supports fetch API, and streaming +video/audio. Specify a privilege with the value of `true` to enable the capability. An example of registering a privileged scheme, that bypasses Content Security Policy: @@ -103,6 +103,11 @@ cookies) are disabled for non standard schemes. So in general if you want to register a custom protocol to replace the `http` protocol, you have to register it as a standard scheme. +Protocols that use streams (http and stream protocols) should set `stream: true`. +The `