Repository navigation
Add HLS playback stats reporting - #1917
Open
PratimMallick wants to merge 3 commits into
Open
PratimMallick wants to merge 3 commits into
PratimMallick wants to merge 3 commits into
Conversation
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 📏
|
…/vid-1546-hls-stats
PratimMallick
marked this pull request as ready for review
November 20, 2026 15:09
This branch has not been deployed
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 only when the join response sets
stats_options.enable_hls_statsand returnsplayback.stats_token. The backend PR (GetStream/chat#20246) does not returnenable_hls_statsorreporting_hls_interval_msyet, so until it does, nothing is sent.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.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
endedreasons and retries, no reports before first play.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.enable_hls_stats. 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.