Repository navigation
Add HLS playback stats reporting - #1917
Merged
Merged
Conversation
…nection RtcSession becomes open and gains an internal initializeRtc flag. When the flag is false, the session never creates the SFU connection or any peer connection and leaves the shared peer connection factory untouched. EmptyRtcSession uses it and turns every public member into a no-op. cleanup() no longer assumes the SFU connection module exists. Prepares for joining a call without WebRTC media (VID-1543). No behaviour change for existing sessions. Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Stock LivestreamPlayer shows the playlist when the backend grants HLS. Custom screens opt in by composing HlsVideoRenderer, and VideoRenderer stays WebRTC-only.
…1543-hls-join-sdk # Conflicts: # stream-video-android-core/api/stream-video-android-core.api
…sdk' into pratimmallick/vid-1543-hls-renderer
Media3 adds about 2 MB, and few apps need HLS, so the player moves to a separate artifact. Core keeps the contract: HlsPlayer and HlsPlayerFactory, registered through StreamVideoBuilder.hlsPlayerFactory. The first join only declares HLS support when a factory is registered, so an app without one is never served HLS. An HLS join creates the call's player next to the playback session; leave releases it. A player that cannot be created fails the join and installs nothing.
…sdk' into pratimmallick/vid-1543-hls-renderer
Adds stream-video-android-hls with ExoHlsPlayerFactory and the Compose HlsVideoRenderer. Core and ui-compose no longer depend on Media3, and the process-wide playback store is gone: the renderer attaches to the call's player and detaches (pauses) on dispose, while the SDK releases it on leave. The demo app registers the factory and shows a minimal HLS viewer screen when a call joins over HLS.
…/vid-1543-hls-renderer
…/vid-1543-hls-renderer
Send started, periodic stats and ended reports to hls_stats while a call plays over HLS, when the join response enables HLS stats. The player reports its state, errors and readings through new optional HlsPlayer hooks; ExoHlsPlayer implements them.
Contributor
Author
|
@CodeRabbit review |
Contributor
PR checklist ✅All required conditions are satisfied:
🎉 Great job! This PR is ready for review. |
Contributor
SDK Size Comparison 📏
|
PratimMallick
marked this pull request as ready for review
November 20, 2026 15:09
…rer' into pratimmallick/vid-1546-hls-stats
ExoPlayer stretches each frame over the SurfaceView buffer, which kept its own size, so in portrait the 16:9 box showed a stretched crop. The buffer now takes the video's size and the compositor scales it into the aspect-ratio box.
…/vid-1546-hls-stats
5 of 7 tasks
A fatal error idles the player, which reports no state, so watch time and an open stall kept growing until the viewer left.
The default policy failed playback after a few seconds offline and the player stayed idle. Client errors (4xx) still fail at once.
Integrations decide how to recover when HLS playback ends or fails. The SDK now listens to the player with or without stats reporting.
…rer' into pratimmallick/vid-1546-hls-stats # Conflicts: # stream-video-android-hls/src/main/kotlin/io/getstream/video/android/hls/ExoHlsPlayer.kt
The broadcast playlist keeps every segment, so after a long stall the player resumed minutes behind live and never fell out of the window.
…/vid-1546-hls-stats
The broadcast playlist has no program date times, so the live offset is always unknown and the jump to the live edge never happened.
…/vid-1546-hls-stats
Playback can be ready again before the refresh that moves the live position arrives, so checking only on ready missed the drift.
…/vid-1546-hls-stats
…/vid-1546-hls-stats
LivestreamPlayer showed "host video not available" for HLS viewers, since an HLS call has no participants. The new hlsContent slot renders the broadcast instead, under the regular overlay. ui-compose does not depend on the HLS module, so integrators pass HlsVideoRenderer in.
A load error before the first frame (for example an empty media playlist) cannot recover and previously sent no report at all, so the backend never learned about the failed viewer. Send a single `ended` with the error instead, and send `started` before `ended` when a leave right after the first frame cancelled it.
A restarted HLS broadcast writes a new playlist, so the viewer's player stayed ended on the old one. On `call.hls_broadcasting_started` while playing HLS, switch to the playlist from the event: build a new player, start a new stats session for it, and release the old player.
Once the player reaches the end of a stopped broadcast, send `ended` instead of reporting frozen stats until the viewer leaves. A restart starts a new session.
The backend only accepts `left` and `error` as end reasons, so a stopped broadcast showed up as the viewer leaving. Add a `stream_ended` player event when playback reaches the end of the stream; it rides on the `ended` report and appears as `hls.stream_ended` in the timeline.
aleksandar-apostolov
approved these changes
Nov 26, 2026
…1543-hls-renderer
…rer' into pratimmallick/vid-1546-hls-stats
Base automatically changed from
pratimmallick/vid-1543-hls-renderer
to
develop
November 27, 2026 14:49
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.
Stacked on #1909. Merge after parent.
Goal
Refs VID-1546 — report HLS viewers' playback to
POST /video/call/{type}/{id}/hls_stats, so they appear in the dashboard's call stats with their watch time, stalls and errors.Reports are sent when the join response returns
playback.stats_token, unlessstats_options.enable_hls_statsisfalseor the app setStreamVideoBuilder(enableStatsReporting = false).Implementation
reportHLSStatsendpoint and its models.PlaybackResponse.statsToken,StatsOptions.enableHlsStats/reportingHlsIntervalMs, andJoinCallRequest.unifiedSessionIdare added as trailing nullable fields. The join now sends the call's existingunifiedSessionId.HlsPlayergets two optional hooks with default bodies, so existing players still compile:setPlaybackListener(state and error code) andreadPlaybackMetrics. New public types:HlsPlaybackListener,HlsPlaybackState,HlsPlaybackMetrics.HlsStatsCollectorapplies the stall definition shared across SDKs. A stall is Playing followed by Buffering; the initial load, seeks and pauses are not stalls. Watch time counts only time spent Playing. It buffersstall_start,stall_end(withduration_ms) anderrorevents until a report carrying them is handled.HlsStatsReportersends onestartedon first play, thenstatseveryreporting_hls_interval_ms(falling back toreporting_interval_ms, then 10 s), andendedon leave.endedusesend_reasonleft, orerrorwitherror_codeafter a playback error. All reports share oneuser_session_id. Delivery rules:endedis sent.startedandendedare retried with backoff.endedis sent withend_reason: "error", the error code and the error event. Nostartedor periodic stats are sent for a session that never played.ended(end_reason: "left") with astream_endedevent instead of reporting frozen stats. The event shows up ashls.stream_endedin the timeline.call.hls_broadcasting_started), playback switches to the new playlist from the event: a new player and a new stats session. The old session ends withended.CallState.hlsPlaybackStateandhlsPlaybackError(experimental) expose the player's state and last fatal error code, so the app can decide what to do when playback ends or fails. The SDK does not rejoin on its own.CallJoinCoordinatorstarts the reporter after the player is installed. If the reporter fails to start, the HLS join still succeeds.CallLifecycleManagerstops it before releasing the player.endedis sent on the client scope, so it outlives the call scope.ExoHlsPlayermaps ExoPlayer state toHlsPlaybackState, reportsPlaybackException.errorCodeName, and reads bitrate, buffered duration, live offset, dropped frames and resolution.user_id(the backend takes it from the auth token) and the browser fields. It sendssdk = stream-android, the SDK version,os = Androidand the OS version. Logs never include the stats token or the playlist URL.copyofStatsOptionschange shape (the usual effect of regenerating a generated model).JoinCallRequestandPlaybackResponsealready changed in Join livestreams over HLS when the backend grants HLS playback #1908.Testing
stream_endedwhen the stream ends.endedreasons and retries, no reports before first play, a singleendedfor an error before the first frame,endedwhen the stream ends.unified_session_idon the join.HlsPlaybackState../gradlew spotlessCheck apiCheck :stream-video-android-core:testDebugUnitTest :stream-video-android-hls:testDebugUnitTest :demo-app:compileDevelopmentDebugKotlin: all passed. The repo has nodetekttask.hls_statsendpoint. Join a livestream that is served as HLS and watch for a few intervals. Turning on airplane mode should produce a stall and then an error. Leave, then check that the call stats show the viewer with astarted, periodicstats, and oneended.