Repository navigation
Join livestreams over HLS when the backend grants HLS playback - #1908
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>
|
@CodeRabbit review |
Action performed
|
Walkthrough
Merge Risk:
|
PR checklist ✅All required conditions are satisfied:
🎉 Great job! This PR is ready for review. |
SDK Size Comparison 📏
|
|
The description still says rendering is PR 3, but |
5a27e0f to
f07c821
Compare
|
Moved the renderer out: this PR is back to the three core commits, and |
…1543-hls-join-sdk # Conflicts: # stream-video-android-core/api/stream-video-android-core.api
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.
|
…ckstage The HLS end-of-call backstop watched CallState.endedAt, which live_ended_at also sets, so stopping live made every HLS viewer leave while WebRTC viewers stayed. It now watches the session's ended_at, which only a real end sets.
…1543-hls-join-sdk



Goal
Refs VID-1543. This lets the backend move livestream viewers to HLS. If the app has registered an HLS player factory, the SDK declares HLS support on the first join. When the response carries an HLS playback grant, the call joins without an SFU connection. The SDK then creates one player for the call and exposes the grant through
call.state.playbackType. Backend: GetStream/chat#19517.Core has no Media3 dependency. The ExoPlayer implementation and the Compose renderer are in a separate opt-in artifact (#1909), so apps that don't use HLS don't pay its size cost.
Implementation
playback_capabilitiesandpreferonJoinCallRequest,playbackonJoinCallResponse, and a newPlaybackResponse. These were added by hand to match the backend spec, not regenerated. They are placed last so no existingcomponentNmoves.HlsPlayerandHlsPlayerFactoryinterfaces incore.call.hls. They are registered through the new trailingStreamVideoBuilder(hlsPlayerFactory = ...)parameter, which defaults tonull.playback_capabilities: ["hls"]only when a factory is registered. Without one, nothing changes and the join always gets SFU credentials. Rejoin and migrate never send it. There is no mid-call switch in v1.preferis not sent. The backend decides the tier throughdelivery.hls_percentage.CallJoinCoordinatorholds anEmptyRtcSession(from Add EmptyRtcSession, an RtcSession without an SFU connection #1903) inCallSessionManager.playbackSession, never as the active session. It skips the SFU connect, session monitoring and media setup. It creates the call's player through the factory, then moves the connection toJoinedand thenConnected. The join fails, with nothing installed, if the grant has an unknown type or a blank URL, if no factory is registered, or if the factory throws.Call.hlsPlayer(@InternalStreamVideoApi) is set on the HLS join. Leave andcleanup()clear it and callrelease(). Renderers only attach and detach the video, so rotation and recomposition don't rebuild the player.HlsVideoRendererfromstream-video-android-hls. After that, playback continues while no renderer is shown or the app is in the background, the same as a WebRTC call, until the call is left.Callis built.PlaybackType(WebRtc/Hls(playlistUrl)) andCallState.playbackType.PlaybackType,HlsPlayer,CallState.playbackTypeandCall.hlsPlayerare@ExperimentalStreamVideoApi.CallReconnector.reconnect()returns early during HLS playback, since there is no SFU connection to recover.state.endedAtis set, so a missedcall.endedevent doesn't leave the viewer connected.cleanup()take the player atomically, so it is released once.playbackTypegetter, and a newStreamVideoBuilderconstructor overload are added. TheJoinCallRequest/JoinCallResponseconstructor andcopysignatures change because of the new trailing parameters, the same as earlier hand-added fields.Testing
New unit tests:
CallJoinCoordinatorTestcovers these cases:CallApiClientTest:playbackCapabilitiesis forwarded only when the caller passes it.CallReconnectorTest: reconnect is skipped during HLS playback.CallLifecycleManagerTest: leaving after HLS releases the player and the playback session, resets the type, and sends no SFU leave event.PlaybackSerializationTest: request JSON, parsing an HLS grant, and unknown values mapping toUnknown.PlaybackSerializationTest: a full HLS join response with empty SFU credentials parses.CallJoinCoordinatorTest: the call is left whenendedAtis set during HLS, a non-https playlist URL fails the join, a leave during the join preamble prevents the HLS install, and a WebRTC join that fails after leave started staysDisconnected../gradlew spotlessCheck apiCheck :stream-video-android-core:testDebugUnitTest :demo-app:compileDevelopmentDebugKotlinpasses.Manual check to run with #1909's demo app, which registers the factory:
delivery.hls_percentage> 0 and a running HLS broadcast.call.state.playbackTypeto beHls(url)and the connection to beConnected, with no SFU connection.Made with Cursor