16 lines
620 B
TypeScript
16 lines
620 B
TypeScript
import type { LevelSample } from "../../session/session-shape/session-shape.types.js";
|
|
import { useStreamContextOrThrow } from "../internal/use-stream-context.js";
|
|
|
|
/**
|
|
* Returns realtime peak/RMS for the local microphone (when `peerId` is
|
|
* omitted) or for the named peer. Levels come from the peer chain's
|
|
* analyzer slot owned by chunks A+B; this hook is a pure projection.
|
|
*/
|
|
export function useStreamLevels(peerId?: string): LevelSample {
|
|
const { session } = useStreamContextOrThrow();
|
|
if (peerId === undefined) {
|
|
return session.getLocalLevel();
|
|
}
|
|
return session.getPeerLevel(peerId);
|
|
}
|