import type { Logger } from 'zapo-js'; import { type BinaryNode } from 'zapo-js/transport'; import { type AudioSender, EndCallReason, type InboundVideoFrame, type InboundVideoRtpPacket, type WaVoipDeps } from '../types.js'; import { type CallInfo } from './call-state.js'; export interface WaCallMediaSessionDelegate { emitState(call: CallInfo): void; emitIncoming(call: CallInfo): void; emitEnded(call: CallInfo): void; emitInboundAudio(call: CallInfo, data: Float32Array): void; emitInboundVideoRtp(call: CallInfo, packet: InboundVideoRtpPacket): void; emitInboundVideo(call: CallInfo, frame: InboundVideoFrame): void; emitOutboundAudioFinished(call: CallInfo): void; } export interface WaCallMediaSessionOptions { readonly deps: WaVoipDeps; readonly logger: Logger; readonly info: CallInfo; readonly delegate: WaCallMediaSessionDelegate; /** See `WaVoipCoordinatorOptions.useOriginalRelayPort`. */ readonly useOriginalRelayPort?: boolean; } export declare class WaCallMediaSession implements AudioSender { readonly info: CallInfo; private readonly deps; private readonly logger; private readonly delegate; private readonly useOriginalRelayPort; private rtpSession; private videoRtpSession; private srtpSession; private srtcpContext; private opusCodec; private readonly sctpRelay; private readonly audioEngine; private initialTransportSent; private outgoingPreacceptSent; private selfSsrc; private peerSsrcs; private selfStreamSsrcs; private peerStreamSsrcs; private firstPacketSent; private acceptedByJid; private readonly debeEnabled; private audioSendCount; private videoSendFrames; private videoRecvPackets; private audioDropCount; private realAudioSendCount; private static readonly EMPTY_BYTES; private encodeBufferA; private encodeBufferB; private encodeBuffer; private encodeBufferPos; private authPaddingBuffer; private audioRecvCount; private recvRealCount; private recvDtxCount; private subscriptionRefreshInterval; private rtcpInterval; private videoPacketCount; private videoOctetCount; private videoFrameNumber; private videoTransportSequence; private lastVideoRtpTimestamp; private lastVideoSentAt; private videoFirSequence; private receivedVideoKeyFrame; private lastVideoPliAt; private srtpErrorCount; private relayPacketCount; private stunResponseCount; private selfEchoCount; private lastRecvSeq; private recvSeqGaps; private actualPeerSsrc; private ssrcResubscribed; private readonly h264Depacketizers; constructor(options: WaCallMediaSessionOptions); get callId(): string; shouldIgnoreTerminate(peerJid: string | undefined, reason: string | undefined): boolean; initMedia(selfLid: string, peerJid: string): Promise; resetOutgoingFlags(): void; acceptCall(): Promise; rejectCall(reason?: EndCallReason): Promise; endCall(reason?: EndCallReason): Promise; setMute(muted: boolean): void; loadAudio(audioPath: string): Promise; setExternalAudioMode(enabled: boolean): void; feedLiveAudio(data: Float32Array): number; feedLiveVideo(data: Uint8Array, timestampUs: number): number; private isH264KeyFrame; private buildVideoExtension; getLiveBufferMs(): number; sendIncomingPreaccept(peerJid: string): Promise; sendIncomingRelayLatency(): Promise; handleCallAccept(node: BinaryNode, peerJid: string): Promise; handleCallPreaccept(node: BinaryNode, peerJid: string): Promise; handleCallTransport(_node: BinaryNode): Promise; handleCallAck(node: BinaryNode): Promise; handleCallRelaylatency(node: BinaryNode, peerJid: string): Promise; handleRelayElection(node: BinaryNode): void; handleCallMuteV2(node: BinaryNode, peerJid: string): Promise; handleCallTerminate(): void; sendCapturedAudio(data: Float32Array): void; cleanup(): void; private get encodeFrameSamples(); private get rtpTsDelta(); private sendOpusFrame; private ensureDeviceJid; private initSrtpKeys; private resetEncodeState; private onRelayConnected; private onRelayData; private connectRelays; private startMediaFlow; }