Screen share 21: apps/fluxer screen-share runtime wiring (#168) #245
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "screenshare-21-app-screenshare-runtime"
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?
Stacked on: screenshare-13-core-previews (screenshare-14-audio-capture-linux, screenshare-17-voice-livekit-video and screenshare-20-devserver-screenshare were already on screenshare at
2e06bfe).What this builds
apps/fluxernow executes the screen-share half of the store:capture_rt.rs:Effect::Captureruns on a worker thread that owns theScreenCapturerandStreamAudioCapturer(the system backend is made on that thread, so PipeWire/X11 probing never holds up startup). Port types are converted both ways. Captured frames go toVoiceHandle::push_videoandFrameBus[LocalCapture], gated to the share's frame rate (FrameGate); stream audio (own PID tree excluded) topush_screen_audio; picker thumbnails toFrameBus[Source { id }].Started/Stalled/Resumed/EndedbecomeCoreEvent::Capture; a failed start becomesError, a cancelled system pickerEnded { Cancelled }.CaptureBackend::{system, fake, unsupported, new},Runtime::with_capture_backend,Handle::frame_bus().preview_rt.rs:UploadStreamPreviewencodes the latestLocalCaptureframe withpreview_jpeg, gets the presigned URL (cached in memory, renewed 60 s before expiry, dropped on a failed PUT) and PUTs it. The privacy switch is checked again just before the PUT and drops the cached URL.FetchStreamPreviewdecodes the JPEG intoFrameBus[Preview](404 removes the key).voice_rt.rs: remote video of the screen shares the store subscribed to goes toFrameBus[Remote { sid }], and is taken off when the store unsubscribes (late frames dropped), the track ends, the participant leaves or the room is left. Remote screen-share sound goes to the new mixer sourceStream(identity), soSetGain { Stream }(stream volume) now applies.--capture-fake(featurecapture-fake, on withdevserver);--devserver screenshareuses the fake capture, and its fake room now plays every other member's stream fromVoiceScript::streams()(test pattern at 15 fps and a 440 Hz stereo tone, only while subscribed).--debug-infolists the capture backends (screen, stream audio, in-app picker, window audio), encodable codecs, hardware encoders and decodable codecs (MediaInfo).--recordalso redactsupload_urlandthumbnail(defence in depth; the preview requests are already unobserved influxer-api).ScreenShareStart/Stopnow playstream-start.mp3/stream-stop.mp3(copied from the fork'sfluxer_app/src/media/sounds/).Tests
apps/fluxer/tests/screenshare_runtime.rs(devserverscreenshare+ FakeRoom + NullHost + fake capture):go_live_publishes_and_sends_op4_sequence(self_stream:true only after publication, own key after it, every later op 4 streaming; devserver lists the stream),local_frames_reach_room_and_bus(rate ceiling, own tile removed on stop),watching_fake_streamer_puts_frames_on_bus,stream_audio_reaches_mixer_with_stream_gain(user volume 0 does not mute the stream; 50 % gives the store's curve),preview_uploaded_after_go_live,record_mode_never_contains_upload_url_or_token(no token, no presigned path, noupload_url/thumbnail, no JPEG bytes),capture_end_stops_share,debug_info_lists_capture_and_codecs. Unit tests for the frame gate, rule conversion, URL renewal, JPEG round trip/broken JPEG, privacy switch, video routing, stream/chime mapping, record redaction,--capture-fake.FLUXER_SCREENSHOT_TESTS=1 cargo xtask cigreen locally (Linux). No real-device test is part of this task; noFLUXER_CAPTURE_TESTSrun was needed (the backends are Screen share 4/5/14/15's).Deviations
fluxer-voice/src/session.rs(RemoteAudiogainssource: TrackSource, the only way to tell screen-share sound from the microphone),fluxer-audio/src/engine.rs(push_stream,SourceId::Streamin the level filter),fluxer-audio/tests/clips.rs(13 chimes), READMEs.xtask/src/package/libs.rs: the app now linksfluxer-capture, so the Linux binary needslibpipewire-0.3.so.0and GLib (libglib/gobject/gio-2.0) at load time; they are added toLINUX_DECLARED(spec section 12 declares PipeWire) socargo xtask packagepasses. AppRun, the release container and the README are follow-up #243 (Screen share 30).CaptureOutput::Errorduring a session is logged, not forwarded: the store ends the share onCaptureEvent::Error, while the capture contract says the session goes on (e.g. a failed switch) andEndedfollows when it is over.image(workspace dependency) added toapps/fluxerto decode fetched previews;fluxer-ui::rundoes not take theFrameBusyet, the UI tasks wireHandle::frame_bus().Closes #168
🤖 Generated with Claude Code
Independent review: Screen share 21 (diff 16a3971..39786c5)
Tests (plan Step 1): all 8 named tests exist in
apps/fluxer/tests/screenshare_runtime.rsand assert what the plan asks.go_live_publishes_and_sends_op4_sequencechecks that noself_stream: trueappears before the publication, then that the own key follows and later op 4s keepself_stream: true.local_frames_reach_room_and_buschecks the rate stays under the encode-fps ceiling. Stream gain is checked againststream_gain. The record test looks for the token,upload_url,thumbnail,stream-previewsand JPEG magic. The unit tests also cover the 60 s URL renewal (540 s of a 600 s URL), the privacy switch dropping the cached URL, and broken JPEGs returning an error.Interfaces: everything in Task 21's Produces list is present.
Effect::Captureruns on a worker thread. Frames are gated and go topush_videoandFrameBus[LocalCapture]. Stream audio goes topush_screen_audio, with our own PID excluded. Remote video goes toFrameBus[Remote { sid }]and remote stream audio to mixerSourceId::Stream(identity). Previews (upload URL cached until 60 s before expiry, then PUT) andFetchStreamPreviewgo toFrameBus[Preview]. Thumbnails go toFrameBus[Source { id }].--capture-fake,--devserverand the fake backends are wired, and--debug-infohas the MediaInfo section. The additive changes in other crates (RemoteAudio.source,AudioEngine::push_stream,SourceId::Stream, two new chimes) break no construction on other screenshare branches; I grepped 22, 25, 26 and 28.Invariants: fluxer-core, fluxer-ui, fluxer-video and fluxer-capture are untouched. No LiveKit types appear in new public signatures. The upload URL stays a
SecretStringinsidefluxer-apiand is redacted in records. Server JPEGs are decoded without panicking. No secrets are in code or fixtures beyond the existing demo fixture token.Review Focus 5: satisfied. The privacy switch is re-read before the upload-URL request and again before the PUT. Turning it on drops the cached URL. The record test shows no URL, token or JPEG reaches
--recordoutput.Local CI:
cargo xtask ciin a clean review worktree: green (all steps passed, screenshare_runtime 8/8).Findings
preview_rt::decode_jpegdecodes server-supplied JPEGs with theimagecrate's default limits, which allow allocations of up to about 512 MiB. A hostile or corrupt preview with huge declared dimensions can cause a large allocation. It is not a panic. Considerimage::ImageReaderwith explicitLimitssized to the preview budget (e.g. 4096×4096).VideoRouting::participant_goneremoves the participant's frames but keeps their identity inwanted. If they rejoin with a new share before the store unsubscribes, frames reach the bus without a newSetSubscribed. This is harmless today because the store re-issues subscriptions, but it is inconsistent withwant(false).CaptureRuntime::dropjoins the worker thread. If the worker is blocked inside a backend call (portallist_sources/startwaiting on the user), shutdown waits for it.CaptureOutput::Errorduring a running session is only logged, not sent asCaptureEvent::Error. That is reasonable given the core ends the share on that event and the backend sendsEnded. A short line in spikes or the spec would keep the next reader from treating it as a gap.Verdict: APPROVED. No blocking findings and local CI is green; the remote runners are left to the integrator.