feat(lotus): report remote screenshare audio to the host (cinny #277)
New fromWidget action io.lotus.screenshare_audio_state { present }: each
LivekitRoomAudioRenderer reports whether a remote participant's
ScreenShareAudio track is being received; the combined answer is sent to
the host on change, and cleared when a renderer unmounts. cinny uses it to
show "Mute Screenshare Audio" only when there is something to mute.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017PCb59uY3UKqDqt7B6hzd5
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
848dcaafa9
commit
5f4844cad5
@@ -8,6 +8,8 @@ Please see LICENSE in the repository root for full details.
|
||||
import { BehaviorSubject } from "rxjs";
|
||||
|
||||
import { globalScope } from "../state/ObservableScope";
|
||||
import { LotusWidgetActions } from "./lotusActions";
|
||||
import { lotusSendToHost } from "./lotusWidget";
|
||||
|
||||
/**
|
||||
* Whether the host has muted remote screenshare AUDIO (`io.lotus.set_deafen`
|
||||
@@ -25,3 +27,40 @@ export const setScreenshareAudioMuted$ = new BehaviorSubject(false);
|
||||
export const muteScreenshareAudio$ = globalScope.behavior(
|
||||
setScreenshareAudioMuted$,
|
||||
);
|
||||
|
||||
/**
|
||||
* [cinny #277] Whether any remote participant's screenshare AUDIO is being
|
||||
* received, so the host shows its "Mute Screenshare Audio" control only when
|
||||
* there is something to mute. Each `LivekitRoomAudioRenderer` (one per SFU)
|
||||
* reports for its own room; the host gets `io.lotus.screenshare_audio_state
|
||||
* { present }` whenever the combined answer changes.
|
||||
*/
|
||||
const presentByRoom = new Map<string, boolean>();
|
||||
let lastSent: boolean | undefined;
|
||||
|
||||
function sendIfChanged(): void {
|
||||
const present = [...presentByRoom.values()].some(Boolean);
|
||||
if (present === lastSent) return;
|
||||
lastSent = present;
|
||||
lotusSendToHost(LotusWidgetActions.ScreenshareAudioState, { present });
|
||||
}
|
||||
|
||||
export function reportScreenshareAudio(
|
||||
roomKey: string,
|
||||
present: boolean,
|
||||
): void {
|
||||
presentByRoom.set(roomKey, present);
|
||||
sendIfChanged();
|
||||
}
|
||||
|
||||
/** The renderer for `roomKey` went away (call left, SFU switched). */
|
||||
export function clearScreenshareAudio(roomKey: string): void {
|
||||
presentByRoom.delete(roomKey);
|
||||
sendIfChanged();
|
||||
}
|
||||
|
||||
/** Test-only: forget all reports. */
|
||||
export function resetScreenshareAudioPresence(): void {
|
||||
presentByRoom.clear();
|
||||
lastSent = undefined;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user