Skip to content

[WIP] test: Add URL-player unit tests for demuxer, client, and factory - #11107

Closed
abhijeetk wants to merge 8 commits into
youtube:mainfrom
abhijeetk:url-player-7
Closed

[WIP] test: Add URL-player unit tests for demuxer, client, and factory#11107
abhijeetk wants to merge 8 commits into
youtube:mainfrom
abhijeetk:url-player-7

Conversation

@abhijeetk

Copy link
Copy Markdown
Collaborator

Add 23 unit tests across three test files:

  • url_player_demuxer_unittest.cc (13 tests): IsHlsUrl() predicate
    for .m3u8 and hls_variant detection, UrlPlayerDemuxer URL passthrough,
    placeholder streams, initialization, seek, and memory usage.

  • url_player_renderer_client_unittest.cc (6 tests): Two-event init
    protocol (mojo init + rendering mode), invalid URL handling, mojo
    disconnect, and rejection of unsupported rendering modes.

  • url_player_renderer_client_factory_unittest.cc (4 tests): Factory
    wiring, bypass-mojo-for-media disabled, mojo endpoint propagation,
    and config forwarding.

All 37 URL player tests pass on tvOS simulator.

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
Register kUrlPlayer as a conditional renderer factory using the
IsHlsUrl() predicate so HLS URLs select the URL-player path while
ordinary URLs continue using the Starboard renderer.

Enable CobaltContentRendererClient::OverrideDemuxerForUrl() to create
UrlPlayerDemuxer for HLS URLs.

Add RendererFactorySelectorTest coverage for .m3u8, hls_variant, and
non-HLS URLs.

Build: ninja -C out/tvos-arm64-device_qa cobalt nplb media_unittests

Bug: 512045535
Add 23 unit tests across three test files:

- url_player_demuxer_unittest.cc (13 tests): IsHlsUrl() predicate
  for .m3u8 and hls_variant detection, UrlPlayerDemuxer URL passthrough,
  placeholder streams, initialization, seek, and memory usage.

- url_player_renderer_client_unittest.cc (6 tests): Two-event init
  protocol (mojo init + rendering mode), invalid URL handling, mojo
  disconnect, and rejection of unsupported rendering modes.

- url_player_renderer_client_factory_unittest.cc (4 tests): Factory
  wiring, bypass-mojo-for-media disabled, mojo endpoint propagation,
  and config forwarding.

All 37 URL player tests pass on tvOS simulator.
URL player only supports punch-out mode. The rendering mode is
determined at the Starboard layer by SbUrlPlayerOutputModeSupported()
which returns true only for kSbPlayerOutputModePunchOut. DTT and
invalid modes cannot arrive in production.

Simplify UpdateStarboardRenderingMode() to only handle punch-out,
with LOG(WARNING) for unexpected modes. Remove the DTT/invalid error
paths that called SetMojoRendererInitialized() for non-mojo concerns.
Fix OnMojoRendererInitialized() to check for kPunchOut explicitly
instead of != kInvalid, and add a null guard for init_cb_ to handle
the theoretical late mojo completion race safely.

Add detailed comment documenting the two-event init protocol with
references to SbUrlPlayerOutputModeSupported(),
SbPlayerBridge::ComputeSbUrlPlayerOutputMode(), and
UrlPlayerRenderer::CreatePlayerBridge().

Update tests to verify DTT/invalid modes are ignored rather than
rejected with error codes.
@abhijeetk abhijeetk changed the title test: Add URL-player unit tests for demuxer, client, and factory [WIP] test: Add URL-player unit tests for demuxer, client, and factory Jun 27, 2026
@abhijeetk

Copy link
Copy Markdown
Collaborator Author

Thanks for all review comments. We are moving ahead with approach in PR #10698 (UrlPlayer using StarboardRenderer).
Closing this PR.

@abhijeetk abhijeetk closed this Jul 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant