media: Add URL-player demuxer and HLS URL predicate - #11067
Conversation
Add use_starboard_url_player GN capability flag, derived from use_starboard_media and tvOS platform detection. Expose it as BUILDFLAG(USE_STARBOARD_URL_PLAYER) through build_config.h and register matching Mojo enabled_features entry. Add RendererType::kUrlPlayer = 13 to the C++ enum, Mojom enum, traits mapping, and histogram. The new enum is gated behind USE_STARBOARD_URL_PLAYER so non-tvOS builds are unaffected. This establishes the capability boundary for all subsequent URL-player CLs. Bug: 512045535
Add mojom::Renderer::InitializeWithUrl(client, source_url) to deliver the URL on the renderer Mojo pipe, keeping URL delivery and initialization ordered on the same pipe. Add UrlPlayerRenderer for tvOS URL-based playback via SbPlayerBridge and UrlPlayerRendererWrapper as the Mojo service bridge. The wrapper's InitializeWithUrl() sets the URL on the renderer internally then calls Initialize(). MojoRendererService validates the renderer type and URL before forwarding via static_cast, guarded by GetRendererType() == kUrlPlayer and ReportBadMessage(). Bug: 512045535
Add UrlPlayerRendererClient to the tvOS URL-player build, which drives URL-player playback over Mojo by calling InitializeWithUrl() directly on the renderer pipe. Add MediaResource::GetMediaUrl() behind USE_STARBOARD_URL_PLAYER so the client can retrieve the media URL from the demuxer. The base implementation returns an empty GURL; UrlPlayerDemuxer will override it in a later CL. Client unit tests are deferred to a later CL when all their dependencies (InitializeWithStreamPointers, SetSourceUrl mojom) are available. Build: ninja -C out/tvos-arm64-device_qa cobalt media_unittests (pass)
Add CreateUrlPlayerRenderer to mojom::InterfaceFactory, guarded by use_starboard_url_player, and route it through the renderer process, browser media proxy, and GPU media service. Add UrlPlayerRendererClientFactory, which creates a URL-player MojoRenderer via MojoRendererFactory::CreateUrlPlayerRenderer and wraps it in UrlPlayerRendererClient. Add URL-player factory coverage and update fake InterfaceFactory implementations in tests. Build: ninja -C out/tvos-arm64-device_qa cobalt nplb media_unittests Bug: 512045535
Add UrlPlayerDemuxer for tvOS URL-based playback. The demuxer provides placeholder audio/video DemuxerStreams required by PipelineImpl while the platform handles actual demuxing, and exposes the source URL through GetMediaUrl(). Add IsHlsUrl() for detecting HLS URLs, plus a stub OverrideDemuxerForUrl() in CobaltContentRendererClient. The override is left inactive until the renderer routing CL lands. Add kUrlPlayerDemuxer to DemuxerType, including the Mojom enum, traits mapping, and histogram entry. Build: ninja -C out/tvos-arm64-device_qa cobalt nplb media_unittests Bug: 512045535
| #include "third_party/blink/public/web/web_security_policy.h" | ||
| #include "third_party/blink/public/web/web_view.h" | ||
| #include "ui/gfx/geometry/size_conversions.h" | ||
|
|
There was a problem hiding this comment.
small nit: this looks stylistically wrong
|
|
||
| #include "base/task/bind_post_task.h" | ||
| #include "base/time/time.h" | ||
| #include "build/build_config.h" |
There was a problem hiding this comment.
This doesn't look necessary.
| #include "media/base/key_systems_support_registration.h" | ||
| #include "media/base/media_log.h" | ||
| #include "media/base/renderer_factory.h" | ||
| #include "media/media_buildflags.h" |
| bool IsHlsUrl(const GURL& url) { | ||
| // See | ||
| // https://github.com/youtube/cobalt/blob/25.lts.stable/cobalt/dom/html_media_element.cc#L103 | ||
| auto path = url.path_piece(); |
| return path.ends_with(".m3u8") || | ||
| path.find("hls_variant") != std::string_view::npos; |
There was a problem hiding this comment.
Just double checking: in C25 the entire URL was checked for the presence of "hls_variant", but this code only checks the path part. Is this intentional? Could you add a comment with an example of what an expected YT URL looks like?
| // Placeholder stream used only to satisfy Chromium's stream-based pipeline | ||
| // initialization. The URL player path ignores these streams and delegates | ||
| // loading, demuxing, buffering, and decoding to the platform URL player. | ||
| class MEDIA_EXPORT UrlPlayerDemuxerStream : public DemuxerStream { |
There was a problem hiding this comment.
So Cobalt modified DemuxerStream already to carry MIME type, it seems like the job for UrlPlayerDemuxerStream is to carry URL to SbPlayer.
Is there any reason that instead of making a new UrlPlayerDemuxerStream, just add a URL to DemuxerStream and gate it by tvOS flag?
There was a problem hiding this comment.
MIME type is per-stream metadata: each track has its own content type. The
source URL is per-resource metadata: one URL produces both audio and video
tracks. Putting it on DemuxerStream would duplicate it across both placeholder
streams.
More importantly, adding URL to DemuxerStream does not eliminate the new class.
DemuxerStream is an abstract interface requiring concrete implementations of
Read(), audio_decoder_config(), video_decoder_config(), type(), and
SupportsConfigChanges(). The URL-player path needs concrete placeholder
streams that provide dummy audio/video configs and stream types for pipeline
initialization, while making Read() unreachable because AVPlayer owns fetching,
demuxing, buffering, and decoding. We do not want Chromium to download the media
in this path; AVPlayer should own that.
That placeholder stream behavior has to live in a concrete class somewhere, and
existing stream classes (FFmpegDemuxerStream, etc.) are wired to real data
sources. Even if the URL were added to the base DemuxerStream, we would still
need the dummy stream class. We would end up with both: URL-player-specific
metadata on DemuxerStream, and a concrete placeholder stream implementation
that still cannot be avoided.
UrlPlayerDemuxerStream is the concrete placeholder stream implementation that
the pipeline requires. It is not a URL container; the URL lives on
UrlPlayerDemuxer (which is a MediaResource) and is exposed through
MediaResource::GetMediaUrl().
We implemented similar apporach in our initial patch : #10698
but discarded it for separate media pipeline for URLPlayer.
|
Thanks for all review comments. We are moving ahead with approach in PR #10698 (UrlPlayer using StarboardRenderer). |
Add UrlPlayerDemuxer for tvOS URL-based playback. The demuxer
provides placeholder audio/video DemuxerStreams required by PipelineImpl
while the platform handles actual demuxing, and exposes the source URL
through GetMediaUrl().
Add IsHlsUrl() for detecting HLS URLs, plus a stub
OverrideDemuxerForUrl() in CobaltContentRendererClient. The override is
left inactive until the renderer routing CL lands.
Add kUrlPlayerDemuxer to DemuxerType, including the Mojom enum, traits
mapping, and histogram entry.
Build: ninja -C out/tvos-arm64-simulator_qa cobalt nplb media_unittests
Bug: 512045535