[WIP] media: For URL-Player, Wire duration and buffered ranges from AVPlayer to JS - #11155
Closed
abhijeetk wants to merge 9 commits into
Closed
[WIP] media: For URL-Player, Wire duration and buffered ranges from AVPlayer to JS#11155abhijeetk wants to merge 9 commits into
abhijeetk wants to merge 9 commits into
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
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.
Add duration and buffered time range reporting from the native URL player (AVPlayer) through Mojo to the JS video.duration and video.buffered APIs. Bug: 512045535
Collaborator
Author
|
Thanks for all review comments. We are moving ahead with approach in PR #10698 (UrlPlayer using StarboardRenderer). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add duration and buffered time range reporting from the native URL
player (AVPlayer) through Mojo to the JS video.duration and
video.buffered APIs.
Bug: 512045535