Screen share 10: core go-live (#157) #221
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "screenshare-10-core-go-live"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
What this builds
fluxer-core::voice::stream::golive(spec §3.1, §6.3 "Go live", "Stop", "Change stream", "Sharer audio mute"):GoLive { Idle, Picking { switch }, Starting { source, since }, Live { source, video_sid, audio_sid, codec, params }, Stopping }inStreams.outgoing;can_stream(&App) -> Result<(), CannotStream::{NotConnected, NoPermission}>(connected room, STREAM1 << 9or ADMINISTRATOR; DM calls allowed).UserAction::{OpenScreenSharePicker { switch }, CloseScreenSharePicker, StartScreenShare(SourceChoice), ChangeScreenShareSource(SourceChoice), StopScreenShare, SetMuteStreamAudio(bool)}.CaptureCommand::ListSources { thumbnails: true }, orStart { source: SystemPicker, .. }at once once the backend listed itself without an in-app picker (a listing that arrives while the picker is open and says "no in-app picker" also starts the system picker).Start(30 sSTART_TIMEOUT) -> captureStarted->PublishScreenShare-> roomLocalTrackPublished(ScreenShare)-> op 4self_stream: true-> op 4 adding the own key ->Chime::ScreenShareStart.Announced(connection.rs) now carriesself_stream, and the own key is appended toviewer_stream_keysonly while the video is published in the connection's channel, so every op 4 (mute, deafen, watch, resend after READY) carries the current stream flag and key, never before the publication.self_stream: false(own key still listed) ->UnpublishScreenShare->CaptureCommand::Stop-> op 4 without own key ->Chime::ScreenShareStop; thenStoppinguntil the video'sLocalTrackUnpublished(orSTOP_TIMEOUT, 5 s).Ended/Error, STREAM lost (permissions recomputed after every event) or the gateway clearingself_streamafter it had confirmed it, leave, move (the move op 4 already saysself_stream: false, no extra op 4), room lost / replaced, logout (capture stopped, unpublished).CaptureCommand::Switch, publication kept; the switch picker keeps the running share (it still announces while the picker is open).SetMuteStreamAudiosetsvideo.mute_stream_audio(persisted) and sendsSetScreenShareAudioMuted; a share started with it on mutes its audio track when that is published.Tests
crates/fluxer-core/tests/stream_golive.rs:start_order_capture_publish_op4_ownkey_chime,self_stream_never_true_before_publication,stop_order_op4_before_unpublish,capture_ended_stops_share,portal_cancel_returns_idle_without_op4,start_timeout_30s,permission_loss_stops_share,disconnect_and_move_reset_stream,change_source_keeps_publication,no_permission_blocks_start_with_reason, extrasharer_audio_mute_mutes_published_track, and proptestany_event_order_keeps_golive_consistent(128 random event orders: no op 4 saysself_stream/own key unless the video is published, at most one capture runs, publish only after a started capture, every way back to Idle stops a started capture).FLUXER_SCREENSHOT_TESTS=1 cargo xtask cigreen locally. No real-device tests apply to this task.Deviations / for the reviewer
CaptureTargetmax 1920x1080 at the settings' fps (15-60),EncodeParams= captured size scaled to fit (even), 3 Mbit/s; codec =preferred_screen_share_codec, VP8 for Auto. Screen share 11 (encode_params,capture_target) and 12 (select_codec) replace these.Start.audioisSome(AudioRule::default())whenshare_app_audio(window) /share_desktop_audio(screen, system picker) is on;with_audiofollows it.CaptureEvent::Ended { Cancelled }while live (a cancelled switch in the portal) keeps the share; while starting it returns to Idle silently.CaptureEvent::Erroris treated as fatal.STOP_TIMEOUT(5 s) andGoLive::is_published(), not in the plan.reduce_streams, which now takesme, guilds, channels and effects (app.rs one call); it needs guilds for the permission check.event.rs(the newUserActions) andpersist.rs(save onSetMuteStreamAudio) touched minimally, outside the Files list.local.rswas not touched: the merged code builds op 4 inconnection.rs(Announced), soself_streamwent there.Closes #157
🤖 Generated with Claude Code
Independent review: Screen share 10 (core go-live)
Scope:
git diff 9d3c24d..origin/screenshare-10-core-go-live(00c776d).Tests (plan step 1): all 11 named tests exist (
start_order_capture_publish_op4_ownkey_chime,self_stream_never_true_before_publication,stop_order_op4_before_unpublish,capture_ended_stops_share,portal_cancel_returns_idle_without_op4,start_timeout_30s,permission_loss_stops_share,disconnect_and_move_reset_stream,change_source_keeps_publication,no_permission_blocks_start_with_reason, proptestany_event_order_keeps_golive_consistent), plussharer_audio_mute_mutes_published_track. They assert the spec's order and values:START_TIMEOUT == 30 s; start = capture Start, then Publish, then (onLocalTrackPublishedof the video) op 4self_stream:truewith no own key, then op 4 with the own key, thenScreenShareStart; stop = op 4self_stream:falsewith the own key still listed, then Unpublish, then Capture Stop, then op 4 without the key, thenScreenShareStop; a portal cancel or timeout sends no op 4.Interfaces:
GoLivematches spec §6.1 exactly. The sixUserActions,can_stream(&App) -> Result<(), CannotStream::{NotConnected, NoPermission}>and the picker behaviour (ListSources { thumbnails: true }, orStart { SystemPicker }once the backend says it has no in-app picker) are present as written. Additions:STOP_TIMEOUT,GoLive::is_published. The op 4 lives inconnection.rs(Announced.self_stream), notlocal.rs. That is fine because the merged code builds op 4 there.Invariants: fluxer-core gains no dependency and no pixels or samples. Server data cannot panic it (
provisional_paramsguards zero sizes, u64 math). No secrets.Review Focus 1: satisfied.
own_stream_keygates bothself_streamand the own key on a confirmed video publication in the share's channel. Every op 4 goes throughannounced(), which carries the mute, deaf and stream flags and the viewer keys. The proptest checks that no op 4 carriesself_streamor the own key before publication.Implementer's questions:
Ended{Cancelled}while Live keeps the share. I agree for a cancelled system-picker switch. One caveat: if a backend tears down the old capture when the portal switch is cancelled, the share stays published with no frames. Task 4 and Task 21 should make sure a cancelledSwitchkeeps the old capture running.CaptureEvent::Erroris fatal: agreed.self_stream:falsecounts only after the gateway has confirmedtrue: agreed, and it is reset per share.Findings
self_stream:falsefrom the start (for example a permission the client does not model), the share is never confirmed. It then stays Live and published but invisible, with no end. Consider a confirmation timeout later (follow-up material, not blocking).SetMuteStreamAudiochangessettings.videoonly inside the logged-in reducer, while the other voice settings go throughreduce_settings, which runs logged in or not. It is harmless today because the action is only reachable while connected.event.rsandpersist.rschanged outside the plan's Files list. The changes are small and correct; this is noted only as a scope deviation.Local CI:
cargo xtask ciin a fresh worktree passed (all steps passed, exit 0; screenshot and livekit steps skipped as the defaults say).Verdict: APPROVED. No blocking findings; CI green.
Independent review: Screen share 10 (core go-live)
Reviewed
git diff 61a073c..origin/screenshare-10-core-go-live(merge32d0267) cold.(1) Plan tests: all 11 tests the plan names exist in
crates/fluxer-core/tests/stream_golive.rs, plussharer_audio_mute_mutes_published_track. They assert what the plan and spec §6.3 say. The start order is capture → publish → op 4self_stream:true→ op 4 + own key →ScreenShareStart. The stop order is op 4self_stream:false(own key still listed) →UnpublishScreenShare→CaptureCommand::Stop→ op 4 without the key →ScreenShareStop.START_TIMEOUTis 30 s, and a portal cancel or a timeout sends nothing. The proptest checks that no op 4 carriesself_streamor the own key before publication.(2) Interfaces:
GoLive::{Idle, Picking{switch}, Starting{source, since: TimerId}, Live{source, video_sid, audio_sid, codec, params}, Stopping}matches spec §6.1.UserAction::{OpenScreenSharePicker{switch}, CloseScreenSharePicker, StartScreenShare, ChangeScreenShareSource, StopScreenShare, SetMuteStreamAudio}exist as named.can_stream(&App) -> Result<(), CannotStream::{NotConnected, NoPermission}>exists; it uses STREAM1<<9, and ADMINISTRATOR or owner throughpermissions_in. The picker emitsListSources{thumbnails:true}, orStart{SystemPicker}when the backend has no in-app picker. Re-exported fromvoice::stream.(3) Invariants: fluxer-core gets no new dependency and no pixels or samples.
provisional_paramscannot panic: it uses u64 arithmetic,max(2)andtry_from. No secrets.(4) Review Focus 1: satisfied.
Voice::announcednow derivesself_streamand the own key fromown_stream_key, which isSomeonly when the video is confirmed and the share is in the connection's channel. Every op 4 therefore carries the current mute, deaf and stream flags and the viewer keys. A move op 4 carriesself_stream:falseand not the old key. I checked the fork'svalidate_viewer_keys: it does not require the streamer to be streaming, so the stop step's op 4 (own key,self_stream:false) is accepted.Conflict resolution (app.rs):
reduce_streams(&event, me, guilds, channels, effects)runs beforeprofiles.reduce. The two touch disjoint state, so the order is fine.CaptureEvent::Sourcesis still stored; it moved intogolive::on_capture.(5) Local gate:
FLUXER_SCREENSHOT_TESTS=1 cargo xtask ciis green in a fresh review worktree. All steps passed and 12/12 stream_golive tests passed.Findings
GoLive::Live { video_sid: None }has no timeout. If the room never reportsLocalTrackPublished(a publish that fails silently), the share stays "Live" and unannounced until the user stops it. Suggest a follow-up: a publish-confirm timeout, or a publish-failureVoiceEvent.STOP_TIMEOUT(5 s),GoLive::is_published(), theStoppingwait forLocalTrackUnpublished, and the provisional codec and encode params. They are additive and listed in the PR. Tasks 11 and 12 must replaceprovisional_*ingolive.rs.Verdict: APPROVED. No blocking findings, and the local CI is green.