Repository navigation
feat(livekit): option to use LiveKit as the client's audio state source - #24506
Conversation
WalkthroughAdds LiveKit-driven audio-state support and a runtime switch to prefer LiveKit over GraphQL for mute/talking data. New hooks and modules surface LiveKit participant subscriptions (who is unmuted, who is talking, subscribed audio users) and router hooks that choose LiveKit or GraphQL implementations based on meeting settings. A synchronization hook updates AudioManager reactive state from LiveKit. AudioManager gains helpers to detect LiveKit usage and to opt out of GraphQL voice-observing when LiveKit audio state is enabled. A new config/setting flag Sequence DiagramsequenceDiagram
participant UI as UI Component
participant Container as AudioContainer
participant Hook as useAudioManagerStateSync
participant AM as AudioManager
participant LK as LiveKit (participants/tracks)
participant BBB as GraphQL (useWhoIsUnmuted/useWhoIsTalking)
participant Settings as Meeting Settings
UI->>Container: render
Container->>Hook: invoke
Hook->>Settings: read useLiveKitAudioState + bridge
alt useLiveKitAudioState && bridge is livekit
Hook->>LK: subscribe participant & track events
LK-->>Hook: participant speaking/unmuted updates
Hook->>AM: set isMuted/isTalking and call mute()/unmute()
else fallback to BBB
Hook->>BBB: subscribe unmuted/talking GraphQL hooks
BBB-->>Hook: unmuted/talking data
Hook->>AM: set isMuted/isTalking (no LiveKit mute calls)
end
AM->>AM: update internal reactive vars / UI bindings
Estimated code review effort🎯 5 (Critical) | ⏱️ ~120 minutes 🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
There was a problem hiding this comment.
Actionable comments posted: 4
🤖 Fix all issues with AI agents
In
`@bigbluebutton-html5/imports/ui/core/hooks/livekit/useTalkingUsersLiveKit.tsx`:
- Around line 96-138: The effect in useTalkingUsersLiveKit reads
shouldUseLiveKit but doesn't list it in the dependency array and includes a
noisy console.debug; update the dependency array for the useEffect that contains
logic using shouldUseLiveKit to include shouldUseLiveKit (alongside
remoteParticipants, localParticipant, subscribedAudioUsers, bbbTalkingUsers) so
the effect reruns when LiveKit usage toggles, and remove the
console.debug('Livekit fallback for unsubscribed participant', ...) line; keep
existing state updates via currentTalkingState/currentTalkingStateVar and
references to localParticipant, remoteParticipants, subscribedAudioUsers, and
bbbTalkingUsers unchanged.
- Around line 40-58: The compile error is caused by using user.role from
VoiceActivityResponse which doesn't include role; in dispatchTalkingUserUpdate
replace direct use of user.role with the same fallback pattern used elsewhere in
this file (e.g., derive role from existing userMetadataVar() or fallback string)
or update the GraphQL typegen/schema to include role on the user object;
specifically, in dispatchTalkingUserUpdate (and when constructing
newUserMetadata[userId]) use something like existingRole = user.role ??
userMetadataVar()[userId]?.role ?? '<defaultRole>' instead of assuming user.role
exists, and ensure VoiceActivityResponse type reflects role if you choose the
schema fix.
In `@bigbluebutton-html5/imports/ui/core/hooks/useTalkingUsersGraphql.ts`:
- Around line 28-37: The cleanup function for the consumer count effect must
also clear any pending timers stored in mutedTimeoutRegistry and
spokeTimeoutRegistry to avoid leaks and state updates after unmount; in the
effect cleanup (or a dedicated useEffect cleanup) iterate over
mutedTimeoutRegistry.current and spokeTimeoutRegistry.current, call clearTimeout
on each non-null timer, and set those entries to null (or reset the registry
object) so no dangling references remain — reference the refs
mutedTimeoutRegistry and spokeTimeoutRegistry and the existing cleanup in the
useEffect that increments/decrements countVar to locate where to add this logic.
- Around line 117-168: The loop variable shadows the outer muted array causing
the record to store the array instead of the boolean; inside the muted.forEach
in useTalkingUsersGraphql.ts, stop reusing the identifier muted by either
destructuring voice to pull voice.muted into a new name (e.g., isMuted) or
reference voice.muted explicitly when building the record in setRecord so the
stored property is the boolean (use voice.muted or isMuted) rather than the
outer muted array; keep the rest of logic (mutedTimeoutRegistry,
spokeTimeoutRegistry, TALKING_INDICATOR_TIMEOUT, setRecord) unchanged.
🧹 Nitpick comments (6)
bigbluebutton-html5/imports/ui/core/hooks/types.ts (1)
26-33: Consider allowing error values inTalkingUsersHookResult.The
errorfield is typed asundefined, which prevents the hook from ever returning an actual error object. If error handling is intended to be added later, consider:export type TalkingUsersHookResult = { - error: undefined; + error?: Error | undefined; loading: boolean; data: Record<string, VoiceItem>; };If this is intentional to match the current GraphQL hook pattern, this can be left as-is.
bigbluebutton-html5/imports/ui/core/hooks/useWhoIsTalkingGraphql.ts (1)
50-58: Potential race condition in consumer count management.The increment/decrement pattern using
countVar(countVar() + 1)is not atomic and could cause race conditions if multiple components mount/unmount simultaneously. Additionally, the checkif (countVar() === 0)after decrement may evaluate incorrectly in concurrent scenarios.Consider using a functional update pattern or ensuring atomicity:
♻️ Suggested improvement
useEffect(() => { - countVar(countVar() + 1); + const newCount = countVar() + 1; + countVar(newCount); return () => { - countVar(countVar() - 1); - if (countVar() === 0) { + const updatedCount = countVar() - 1; + countVar(updatedCount); + if (updatedCount === 0) { setWhoIsTalkingState({}); } }; }, []);This ensures the count value used for the zero-check is the same as the value being set.
bigbluebutton-html5/imports/ui/core/hooks/useWhoIsUnmutedGraphql.ts (2)
52-60: Same consumer count race condition asuseWhoIsTalkingGraphql.ts.This file uses the same non-atomic increment/decrement pattern. Apply the same fix suggested for
useWhoIsTalkingGraphql.ts:♻️ Suggested improvement
useEffect(() => { - countVar(countVar() + 1); + const newCount = countVar() + 1; + countVar(newCount); return () => { - countVar(countVar() - 1); - if (countVar() === 0) { + const updatedCount = countVar() - 1; + countVar(updatedCount); + if (updatedCount === 0) { setWhoIsUnmutedState({}); } }; }, []);
5-74: Consider extracting shared logic into a generic factory.Both
useWhoIsUnmutedGraphqlanduseWhoIsTalkingGraphqlshare nearly identical structure. A generic factory could reduce duplication:// Example: createReactiveStateHook<T>(options: { shouldInclude: (item: T) => boolean })This is optional and can be deferred if the current approach is preferred for clarity.
bigbluebutton-html5/imports/ui/core/hooks/useWhoIsTalking.ts (1)
21-31: Both hooks are always invoked regardless of active source.Lines 23-24 unconditionally call both
useWhoIsTalkingGraphql()anduseWhoIsTalkingLiveKit(). This means both data sources are subscribed even when only one is used. While React's rules of hooks require consistent hook calls, this may cause unnecessary GraphQL subscriptions or LiveKit event listeners.Consider whether the underlying hooks can be designed to short-circuit internally when not the active source (which may already be the case based on the pattern in
useWhoIsUnmutedLiveKit).bigbluebutton-html5/imports/ui/core/hooks/livekit/useWhoIsUnmutedLiveKit.tsx (1)
80-92: Redundant local participant unmute check.Lines 83-91 first check
microphoneTrack && !microphoneTrack.isMuted, then if that fails, iterate throughaudioTrackPublicationsto find the microphone source. ThemicrophoneTrackfromuseLocalParticipantis already the microphone publication's track, so the fallback loop may be unnecessary.However, this could be intentional defensive coding for edge cases where
microphoneTrackis undefined but the publication exists.♻️ Consider simplifying if microphoneTrack is reliable
if (localParticipant && Auth.userID) { const localUserId = Auth.userID as string; + const hasMicPublication = localParticipant.audioTrackPublications.values().find( + (pub) => pub.source === Track.Source.Microphone && !pub.isMuted + ); - if (microphoneTrack && !microphoneTrack.isMuted) { + if (hasMicPublication) { newUnmutedUsers[localUserId] = true; - } else { - localParticipant.audioTrackPublications.forEach((publication) => { - if (publication.source === Track.Source.Microphone && !publication.isMuted) { - newUnmutedUsers[localUserId] = true; - } - }); } }
| const mutedTimeoutRegistry = useRef<Record<string, ReturnType<typeof setTimeout> | null>>({}); | ||
| const spokeTimeoutRegistry = useRef<Record<string, ReturnType<typeof setTimeout> | null>>({}); | ||
| const [record, setRecord] = useState<Record<string, VoiceItem>>({}); | ||
|
|
||
| useEffect(() => { | ||
| countVar(countVar() + 1); | ||
| return () => { | ||
| countVar(countVar() - 1); | ||
| }; | ||
| }, []); |
There was a problem hiding this comment.
Timeout cleanup missing on unmount.
The mutedTimeoutRegistry and spokeTimeoutRegistry refs hold active timeouts that aren't cleared when the component unmounts. This can cause memory leaks or attempts to update state after unmount.
Consider clearing all pending timeouts in the cleanup function of the consumer count effect or adding a separate cleanup effect.
💡 Suggested cleanup
useEffect(() => {
countVar(countVar() + 1);
return () => {
countVar(countVar() - 1);
+ // Clear all pending timeouts on unmount
+ Object.values(mutedTimeoutRegistry.current).forEach((timeout) => {
+ if (timeout) clearTimeout(timeout);
+ });
+ Object.values(spokeTimeoutRegistry.current).forEach((timeout) => {
+ if (timeout) clearTimeout(timeout);
+ });
+ mutedTimeoutRegistry.current = {};
+ spokeTimeoutRegistry.current = {};
};
}, []);🤖 Prompt for AI Agents
In `@bigbluebutton-html5/imports/ui/core/hooks/useTalkingUsersGraphql.ts` around
lines 28 - 37, The cleanup function for the consumer count effect must also
clear any pending timers stored in mutedTimeoutRegistry and spokeTimeoutRegistry
to avoid leaks and state updates after unmount; in the effect cleanup (or a
dedicated useEffect cleanup) iterate over mutedTimeoutRegistry.current and
spokeTimeoutRegistry.current, call clearTimeout on each non-null timer, and set
those entries to null (or reset the registry object) so no dangling references
remain — reference the refs mutedTimeoutRegistry and spokeTimeoutRegistry and
the existing cleanup in the useEffect that increments/decrements countVar to
locate where to add this logic.
| muted.forEach((voice) => { | ||
| const { userId, voiceUserId, user } = voice; | ||
| const currentSpokeTimeout = spokeTimeoutRegistry.current[userId]; | ||
| const currentMutedTimeout = mutedTimeoutRegistry.current[userId]; | ||
|
|
||
| setRecord((previousRecord) => { | ||
| const previousIndicator = previousRecord[userId]; | ||
|
|
||
| if (!previousIndicator) { | ||
| return previousRecord; | ||
| } | ||
|
|
||
| const { startTime } = previousIndicator; | ||
|
|
||
| const endTime = previousIndicator.talking | ||
| ? Date.now() | ||
| : previousIndicator.endTime; | ||
|
|
||
| // User has never talked or exited audio | ||
| if (!(endTime || startTime) || !voiceUserId) { | ||
| const newRecord = { ...previousRecord }; | ||
| delete newRecord[userId]; | ||
| return newRecord; | ||
| } | ||
|
|
||
| if (!currentMutedTimeout && !currentSpokeTimeout) { | ||
| mutedTimeoutRegistry.current[userId] = setTimeout(() => { | ||
| setRecord((previousRecord) => { | ||
| const newRecord = { ...previousRecord }; | ||
| delete newRecord[userId]; | ||
| return newRecord; | ||
| }); | ||
| mutedTimeoutRegistry.current[userId] = null; | ||
| }, TALKING_INDICATOR_TIMEOUT); | ||
| } | ||
|
|
||
| return { | ||
| ...previousRecord, | ||
| [userId]: Object.assign( | ||
| previousRecord[userId] || {}, | ||
| { | ||
| userId, | ||
| muted, | ||
| talking: false, | ||
| startTime, | ||
| endTime, | ||
| user, | ||
| }, | ||
| ), | ||
| }; | ||
| }); | ||
| }); |
There was a problem hiding this comment.
Variable shadowing: muted is used both as loop array and property.
On line 117, muted is the array from partition(), but on line 159, you're assigning muted (a boolean property from voice) to the record. However, since you're inside muted.forEach((voice) => ...), the voice object from this array always has muted: true. The assignment muted, on line 159 will use the outer muted array reference, not the voice.muted property.
This is a subtle bug - the record will have muted set to the array instead of true.
🐛 Proposed fix
muted.forEach((voice) => {
- const { userId, voiceUserId, user } = voice;
+ const { userId, voiceUserId, user, muted: isMuted } = voice;
const currentSpokeTimeout = spokeTimeoutRegistry.current[userId];
const currentMutedTimeout = mutedTimeoutRegistry.current[userId];
// ... later in the return object ...
{
userId,
- muted,
+ muted: isMuted,
talking: false,
startTime,
endTime,
user,
},📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| muted.forEach((voice) => { | |
| const { userId, voiceUserId, user } = voice; | |
| const currentSpokeTimeout = spokeTimeoutRegistry.current[userId]; | |
| const currentMutedTimeout = mutedTimeoutRegistry.current[userId]; | |
| setRecord((previousRecord) => { | |
| const previousIndicator = previousRecord[userId]; | |
| if (!previousIndicator) { | |
| return previousRecord; | |
| } | |
| const { startTime } = previousIndicator; | |
| const endTime = previousIndicator.talking | |
| ? Date.now() | |
| : previousIndicator.endTime; | |
| // User has never talked or exited audio | |
| if (!(endTime || startTime) || !voiceUserId) { | |
| const newRecord = { ...previousRecord }; | |
| delete newRecord[userId]; | |
| return newRecord; | |
| } | |
| if (!currentMutedTimeout && !currentSpokeTimeout) { | |
| mutedTimeoutRegistry.current[userId] = setTimeout(() => { | |
| setRecord((previousRecord) => { | |
| const newRecord = { ...previousRecord }; | |
| delete newRecord[userId]; | |
| return newRecord; | |
| }); | |
| mutedTimeoutRegistry.current[userId] = null; | |
| }, TALKING_INDICATOR_TIMEOUT); | |
| } | |
| return { | |
| ...previousRecord, | |
| [userId]: Object.assign( | |
| previousRecord[userId] || {}, | |
| { | |
| userId, | |
| muted, | |
| talking: false, | |
| startTime, | |
| endTime, | |
| user, | |
| }, | |
| ), | |
| }; | |
| }); | |
| }); | |
| muted.forEach((voice) => { | |
| const { userId, voiceUserId, user, muted: isMuted } = voice; | |
| const currentSpokeTimeout = spokeTimeoutRegistry.current[userId]; | |
| const currentMutedTimeout = mutedTimeoutRegistry.current[userId]; | |
| setRecord((previousRecord) => { | |
| const previousIndicator = previousRecord[userId]; | |
| if (!previousIndicator) { | |
| return previousRecord; | |
| } | |
| const { startTime } = previousIndicator; | |
| const endTime = previousIndicator.talking | |
| ? Date.now() | |
| : previousIndicator.endTime; | |
| // User has never talked or exited audio | |
| if (!(endTime || startTime) || !voiceUserId) { | |
| const newRecord = { ...previousRecord }; | |
| delete newRecord[userId]; | |
| return newRecord; | |
| } | |
| if (!currentMutedTimeout && !currentSpokeTimeout) { | |
| mutedTimeoutRegistry.current[userId] = setTimeout(() => { | |
| setRecord((previousRecord) => { | |
| const newRecord = { ...previousRecord }; | |
| delete newRecord[userId]; | |
| return newRecord; | |
| }); | |
| mutedTimeoutRegistry.current[userId] = null; | |
| }, TALKING_INDICATOR_TIMEOUT); | |
| } | |
| return { | |
| ...previousRecord, | |
| [userId]: Object.assign( | |
| previousRecord[userId] || {}, | |
| { | |
| userId, | |
| muted: isMuted, | |
| talking: false, | |
| startTime, | |
| endTime, | |
| user, | |
| }, | |
| ), | |
| }; | |
| }); | |
| }); |
🤖 Prompt for AI Agents
In `@bigbluebutton-html5/imports/ui/core/hooks/useTalkingUsersGraphql.ts` around
lines 117 - 168, The loop variable shadows the outer muted array causing the
record to store the array instead of the boolean; inside the muted.forEach in
useTalkingUsersGraphql.ts, stop reusing the identifier muted by either
destructuring voice to pull voice.muted into a new name (e.g., isMuted) or
reference voice.muted explicitly when building the record in setRecord so the
stored property is the boolean (use voice.muted or isMuted) rather than the
outer muted array; keep the rest of logic (mutedTimeoutRegistry,
spokeTimeoutRegistry, TALKING_INDICATOR_TIMEOUT, setRecord) unchanged.
|
Automated tests Summary✅ All the CI tests have passed! |
antobinary
left a comment
There was a problem hiding this comment.
Tested on a stage-like server. No special proofreading.
|
This pull request has conflicts ☹ |
06859ce to
ed269be
Compare
|
This pull request has conflicts ☹ |
Audio state in the client is provided by BBB data sources. This works
but media has always been a partially decoupled system from BBB -
different signaling transports, different data transports, different
protocols. By consequence, it also has its own state that may be
desync'ed from BBB in scenarios where the BBB signaling pathway is down,
but media is up (or vice-versa).
Ideally, the client should always prefer the media framework's state
*first* for a few reasons, e.g.:
- The media framework's state is what the user is actually
_seeing_/_hearing_, so it should be the most accurate one
when available. The idea here is to prevent mismatching scenarios
such as:
- User X suffers a temporary disconnection from GraphQL, but media
stays up. X is still speaking and being heard by others, but their
talking indicator is missing and their mute actions aren't working.
- Some local states (e.g.: mute/talking) do not need to go E2E through
BBB to be reflected in the interface. Using the locally provided
state by the media framework helps with this and guarantees better
UI reactivity.
With the current framework (bbb-webrtc-sfu/mediasoup), framework provided
media state is not available in a way that is structured and easily
usable. LiveKit does provide it in an idiomatic way through its SDKs,
which makes this work possible.
This commit adds an initial implementation for using LiveKit's audio
state as the client's state source for the mute and talking states.
This can be activated through bbb-html5's
`public.media.livekit.audio.useLiveKitAudioState` (*default is false*,
preserving current behavior).
The changes are centered around the core useWhoisUnmuted,
useWhoIsTalking and useTalkingUsers hooks. They've been extensively
refactored into router hooks that conditionally return either:
- The GraphQL-provided audio state data if useLiveKitAudioState=false
- OR the derived audio states based on both LK and GraphQL data, if
useLiveKitAudioState=true. LiveKit data supersedes GraphQL data when
available, with GraphQL acting as a fallback.
The data types for the router hooks are unchanged from the original
ones, which makes those changes transparent to consumers. The GraphQL
variants were also untouched in functionality.
The other significant change is adapting the how AudioManager handles
local mute/talking states and mute actions:
- If useLiveKitAudioState=false, the current implementation (E2E mute
requests, GraphQL-based mute/talking states) is preserved
- If useLiveKitAudioState=true, mute actions are first run _locally_
through LiveKit. Additionally, mute and talking states are derived
from the router hooks above, which should provide for faster state
transitions and better accuracy.
The role field is a 3.1 thing The 3.0 data model does not carry that information
653a18b to
1e66879
Compare
|
There was a problem hiding this comment.
🧹 Nitpick comments (1)
bigbluebutton-html5/imports/ui/components/nav-bar/nav-bar-graphql/talking-indicator/component.tsx (1)
142-147: Consider a moderator color fallback whencoloris missing.Because
VoiceUserMetadata.coloris optional, moderators can lose their explicit colored indicator whencoloris undefined. A fallback preserves consistent visual affordance.🎯 Suggested change
style={ - (isMuteActionAvailable && color) + isMuteActionAvailable ? { - backgroundColor: color, - border: `solid 2px ${color}`, + backgroundColor: color ?? '#4a148c', + border: `solid 2px ${color ?? '#4a148c'}`, } : undefined }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@bigbluebutton-html5/imports/ui/components/nav-bar/nav-bar-graphql/talking-indicator/component.tsx` around lines 142 - 147, The inline style currently only applies when isMuteActionAvailable && color, causing moderators to lose their indicator if VoiceUserMetadata.color is undefined; change the condition to use a fallback moderator color (e.g., MODERATOR_COLOR_FALLBACK or a theme color) when color is falsy so the style object is applied for moderators even without an explicit color—update the JSX block that builds the style (the ternary using isMuteActionAvailable and color) to use (color || MODERATOR_COLOR_FALLBACK) for backgroundColor and border when isMuteActionAvailable is true.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In
`@bigbluebutton-html5/imports/ui/components/nav-bar/nav-bar-graphql/talking-indicator/component.tsx`:
- Around line 142-147: The inline style currently only applies when
isMuteActionAvailable && color, causing moderators to lose their indicator if
VoiceUserMetadata.color is undefined; change the condition to use a fallback
moderator color (e.g., MODERATOR_COLOR_FALLBACK or a theme color) when color is
falsy so the style object is applied for moderators even without an explicit
color—update the JSX block that builds the style (the ternary using
isMuteActionAvailable and color) to use (color || MODERATOR_COLOR_FALLBACK) for
backgroundColor and border when isMuteActionAvailable is true.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: c0acb84e-55fd-4264-9f21-ba6a6998121f
📒 Files selected for processing (5)
bigbluebutton-html5/imports/ui/Types/meetingClientSettings.tsbigbluebutton-html5/imports/ui/components/audio/audio-graphql/audio-controls/input-stream-live-selector/service.tsbigbluebutton-html5/imports/ui/components/audio/container.jsxbigbluebutton-html5/imports/ui/components/audio/hooks/useAudioManagerStateSync.tsbigbluebutton-html5/imports/ui/components/nav-bar/nav-bar-graphql/talking-indicator/component.tsx
✅ Files skipped from review due to trivial changes (1)
- bigbluebutton-html5/imports/ui/components/audio/hooks/useAudioManagerStateSync.ts
🚧 Files skipped from review as they are similar to previous changes (3)
- bigbluebutton-html5/imports/ui/Types/meetingClientSettings.ts
- bigbluebutton-html5/imports/ui/components/audio/container.jsx
- bigbluebutton-html5/imports/ui/components/audio/audio-graphql/audio-controls/input-stream-live-selector/service.ts
✅ Automated tests have passed! |
de86535
into
bigbluebutton:v3.0.x-develop


What does this PR do?
state as the client's state source for the mute and talking states.
This can be activated through bbb-html5's
public.media.livekit.audio.useLiveKitAudioState(default is false,preserving current behavior).
useWhoIsTalking and useTalkingUsers hooks. They've been extensively
refactored into router hooks that conditionally return either:
useLiveKitAudioState=true. LiveKit data supersedes GraphQL data when
available, with GraphQL acting as a fallback.
ones, which makes those changes transparent to consumers. The GraphQL
variants were also untouched in functionality.
local mute/talking states and mute actions:
requests, GraphQL-based mute/talking states) is preserved
through LiveKit. Additionally, mute and talking states are derived
from the router hooks above, which should provide for faster state
transitions and better accuracy.
Closes Issue(s)
None
Motivation
tl;dr: LiveKit's audio state is a more accurate source of truth.
Using it is reliable and faster (mute/unmute/talking state reactivity).
Audio state in the client is provided by BBB data sources. This works
but media has always been a partially decoupled system from BBB -
different signaling transports, different data transports, different
protocols. By consequence, it also has its own state that may be
desync'ed from BBB in scenarios where the BBB signaling pathway is down,
but media is up (or vice-versa).
Ideally, the client should always prefer the media framework's state
first for a few reasons, e.g.:
seeing/hearing, so it should be the most accurate one
when available. The idea here is to prevent mismatching scenarios
such as:
stays up. X is still speaking and being heard by others, but their
talking indicator is missing and their mute actions aren't working.
BBB to be reflected in the interface. Using the locally provided
state by the media framework helps with this and guarantees better
UI reactivity.
With the current framework (bbb-webrtc-sfu/mediasoup), framework provided
media state is not available in a way that is structured and easily
usable. LiveKit does provide it in an idiomatic way through its SDKs,
which makes this work possible.