@telnyx/webrtc
Version:
Telnyx WebRTC Client
175 lines (174 loc) • 5.82 kB
TypeScript
import type { ICallReportFlushReason } from './CallReportCollector';
import { State } from './constants';
export interface IMediaSettings {
useSdpASBandwidthKbps?: boolean;
sdpASBandwidthKbps?: number;
}
export interface IHangupParams {
cause?: string;
causeCode?: number;
sipCode?: number;
sipReason?: string;
sip_call_id?: string;
dialogParams?: {
customHeaders?: Array<{
name: string;
value: string;
}>;
};
isRecovering?: boolean;
initiator?: string;
}
export interface IVertoCallOptions {
destinationNumber?: string;
remoteCallerName?: string;
remoteCallerNumber?: string;
callerName?: string;
callerNumber?: string;
id?: string;
remoteSdp?: string;
localStream?: MediaStream;
remoteStream?: MediaStream;
localElement?: HTMLMediaElement | string | Function;
remoteElement?: HTMLMediaElement | string | Function;
iceServers?: RTCIceServer[];
audio?: boolean | MediaTrackConstraints;
video?: boolean | MediaTrackConstraints;
attach?: boolean;
useStereo?: boolean;
micId?: string;
micLabel?: string;
camId?: string;
camLabel?: string;
speakerId?: string;
userVariables?: Record<string, any>;
screenShare?: boolean;
onNotification?: Function;
googleMaxBitrate?: number;
googleMinBitrate?: number;
googleStartBitrate?: number;
ringtoneFile?: string;
ringbackFile?: string;
telnyxCallControlId?: string;
telnyxSessionId?: string;
telnyxLegId?: string;
clientState?: string;
skipNotifications?: boolean;
negotiateAudio?: boolean;
negotiateVideo?: boolean;
mediaSettings?: IMediaSettings;
customHeaders?: Array<{
name: string;
value: string;
}>;
debug?: boolean;
debugOutput?: 'socket' | 'file';
preferred_codecs?: RTCRtpCodecCapability[];
receiveOnlyAudio?: boolean;
prefetchIceCandidates?: boolean;
forceRelayCandidate?: boolean;
trickleIce?: boolean;
keepConnectionAliveOnSocketClose?: boolean;
mutedMicOnStart?: boolean;
applyDesiredAudioMuteState?: () => void;
recoveredCallId?: string;
}
export interface IStatsBinding {
constraints: any;
callback: Function;
}
export interface AnswerParams {
customHeaders?: Array<{
name: string;
value: string;
}>;
video?: boolean;
remoteElement?: HTMLMediaElement | string | Function;
localElement?: HTMLMediaElement | string | Function;
}
export interface IWebRTCCall {
id: string;
recoveredCallId?: string;
state: string;
prevState: string;
direction: string;
peer?: {
instance?: RTCPeerConnection | null;
restartedIceOnConnectionStateFailed?: boolean;
restartStatsReporter?: () => Promise<void>;
isConnectionHealthy?: () => boolean;
close?: () => Promise<void>;
} | null;
options: IVertoCallOptions;
cause: string;
causeCode: number;
channels: string[];
role: string;
extension: string;
localStream: MediaStream;
remoteStream: MediaStream;
isAudioMuted: boolean;
creatingPeer: boolean;
signalingStateClosed: boolean;
invite: () => void;
answer: (params: AnswerParams) => void;
hangup: (params?: IHangupParams, execute?: boolean) => Promise<void>;
flushIntermediateCallReport?: (reason?: ICallReportFlushReason) => void;
hold: () => void;
unhold: () => void;
toggleHold: () => void;
dtmf: (dtmf: string) => void;
message: (to: string, body: string) => void;
muteAudio: () => void;
unmuteAudio: () => void;
toggleAudioMute: () => void;
setAudioInDevice: (deviceId: string, muted?: boolean) => Promise<void>;
muteVideo: () => void;
unmuteVideo: () => void;
toggleVideoMute: () => void;
setVideoDevice: (deviceId: string) => Promise<void>;
deaf: () => void;
undeaf: () => void;
toggleDeaf: () => void;
setAudioBandwidthEncodingsMaxBps: (max: number) => void;
setVideoBandwidthEncodingsMaxBps: (max: number) => void;
getStats: (callback: Function, constraints: any) => void;
shouldForceRelayCandidateForRecovery?: () => boolean;
setState: (state: State) => void;
handleMessage: (msg: any) => void;
_addChannel: (laChannel: any) => void;
handleConferenceUpdate: (packet: any, pvtData: any) => Promise<string>;
startScreenShare?: (opts?: object) => Promise<IWebRTCCall>;
stopScreenShare?: () => Promise<void>;
setAudioOutDevice?: (deviceId: string) => Promise<boolean>;
setSpeakerPhone?: (flag: boolean) => void;
sendConversationMessage?: (message: string, attachments?: string[]) => void;
sendAIConversationMessage?: (item: import('./AIConversationTypes').FunctionCallOutputItem) => void;
recordSessionWarning?: (code: string, name: string, message: string, activeCallIds?: string[]) => void;
}
export interface IWebRTCInfo {
browserInfo: any;
browserName: string;
browserVersion: number;
supportWebRTC: boolean;
supportWebRTCAudio: boolean;
supportWebRTCVideo: boolean;
supportRTCPeerConnection: boolean;
supportSessionDescription: boolean;
supportIceCandidate: boolean;
supportMediaDevices: boolean;
supportGetUserMedia: boolean;
}
export interface IWebRTCBrowser {
browserName: string;
features?: Array<string>;
supported: string;
}
export interface IWebRTCSupportedBrowser {
operationSystem: string;
supported: Array<IWebRTCBrowser>;
}
export interface IAudio extends HTMLAudioElement {
_playFulfilled: boolean;
_promise: Promise<any>;
}