import { VoiceSignalMessage } from "../codec/MessageCodec.js"; //#region src/addons/netblocks/src/core/voice/VoiceChat.d.ts export type VoiceTrackHandler = (peerId: string, stream: MediaStream) => void; export type VoiceTrackRemovedHandler = (peerId: string) => void; export interface VoiceChatOptions { iceServers?: RTCIceServer[]; /** Constraints passed to getUserMedia.audio. */ audioConstraints?: MediaTrackConstraints | true; /** * Fired when the local user's voice is enabled or disabled. NetSession * uses this to broadcast the intent over the data channel so other * peers can show a reliable "in voice chat" affordance that doesn't * depend on browser-specific WebRTC track events. */ onLocalStateChange?: (enabled: boolean) => void; /** Mic transmission changed without closing incoming peer audio. */ onLocalMuteChange?: (muted: boolean) => void; /** Capture or peer-connection errors, in addition to console diagnostics. */ onError?: (error: Error, peerId?: string) => void; } export type VoiceSendFn = (msg: VoiceSignalMessage) => void; export declare class VoiceChat { private _opts; private _send; private _onTrack; private _onTrackRemoved; private _localStream?; private _peers; private _enabled; private _muted; private _localId; private _generation; constructor(send: VoiceSendFn, opts?: VoiceChatOptions); setLocalPeerId(id: string): void; /** * Subscribe to remote voice tracks. Multiple listeners can register; * each gets called once per remote `MediaStream`. Returns a function * that removes this listener (idempotent). */ onTrack(handler: VoiceTrackHandler): () => void; /** * Subscribe to remote voice track removals. Multiple listeners can * register. Returns a function that removes this listener. */ onTrackRemoved(handler: VoiceTrackRemovedHandler): () => void; isEnabled(): boolean; /** Whether this peer is not currently transmitting microphone audio. */ isMuted(): boolean; /** * Cancel pending microphone requests and stop any late-granted tracks. * Leaves established capture and incoming peer connections untouched. */ cancelPendingEnable(): void; /** Request mic + start negotiating with all currently-connected peers. */ enable(currentPeers: ReadonlySet): Promise; disable(): void; /** Mute/unmute the local mic without tearing connections down. */ setMuted(muted: boolean): void; /** NetSession invokes this on peer-join so we can negotiate. */ notifyPeerJoined(peerId: string): void; notifyPeerLeft(peerId: string): void; /** NetSession routes inbound voice signals here. */ handleSignal(from: string, msg: VoiceSignalMessage): Promise; private _connectTo; private _makeOffer; private _reportError; private _teardown; } //#endregion