@telnyx/webrtc
Version:
Telnyx WebRTC Client
97 lines (96 loc) • 2.83 kB
TypeScript
import { type ITelnyxWarning } from '../util/constants/warnings';
export interface IRecordingPacket {
rtpSeq: number;
rtpTs: number;
rtpSsrc: number;
capturedAt: string;
payloadBytes: Uint8Array;
}
export declare type RecordingTrackKind = 'local' | 'remote';
export interface ICallRecordingOptions {
enabled: boolean;
flushIntervalMs?: number;
maxBufferBytes?: number;
sampleRate?: number;
tracks?: RecordingTrackKind[];
endpoint?: string;
fetchImpl?: typeof fetch;
}
export interface ICallRecordingContext {
callId: string;
sessionId?: string;
voiceSdkId?: string;
callReportId: string;
host?: string;
recordingId?: string;
}
export interface ICallRecordingEnvelope {
call_report_id: string;
call_id: string;
voice_sdk_id?: string;
recording_id: string;
segment: 'intermediate' | 'final';
track: RecordingTrackKind;
codec: 'pcm-f32-le';
sample_rate: number;
channels: 1;
started_at: string;
ended_at: string;
packet_count: number;
byte_count: number;
packets: Array<{
rtp_seq: number;
rtp_ts: number;
rtp_ssrc: number;
captured_at: string;
payload_b64: string;
}>;
}
export declare class CallRecorder {
private options;
private callContext;
private recordingId;
private _buffers;
private _bufferBytes;
private _trackStates;
private _processors;
private _readerCancellers;
private _flushTimerId;
private _flushing;
private _stopped;
private _started;
private _startedAt;
private _endedAt;
private _overflowWarnedThisWindow;
onWarning: ((warning: ITelnyxWarning) => void) | null;
private static readonly RETRY_DELAYS_MS;
private static readonly KEEPALIVE_BODY_LIMIT_BYTES;
private static readonly PACKET_OVERHEAD_BYTES;
constructor(options: ICallRecordingOptions, callContext: ICallRecordingContext);
start(localTrack?: MediaStreamTrack, remoteTrack?: MediaStreamTrack): void;
stop(): void;
postFinalReport(): Promise<void>;
cleanup(): void;
private _attach;
private _onFrame;
private _pushPacket;
private _flushIntervalMs;
private _maxBufferBytes;
private _sampleRate;
private _scheduleFlush;
private _clearFlushTimer;
private _cancelReaders;
private _periodicFlush;
private _drain;
private _resolveEndpointFromContext;
private _host;
_setHost(host: string): void;
private _callReportId;
_setCallReportId(callReportId: string): void;
private _resolveCallReportId;
private _resolveEndpoint;
private _buildEnvelope;
private _postRecording;
private _emitWarning;
private _toBase64;
}