103 lines
2.8 KiB
TypeScript
103 lines
2.8 KiB
TypeScript
declare module "twilio-client"
|
|
{
|
|
interface SetupParams
|
|
{
|
|
allowIncomingWhileBusy: boolean;
|
|
audioConstraints: boolean;
|
|
backoffMaxMs: number;
|
|
codecPreferences: ("pcmu" | "opus")[];
|
|
closeProtection: boolean;
|
|
debug: boolean;
|
|
dscp: boolean;
|
|
enableRingingState: boolean;
|
|
fakeLocalDTMF: boolean;
|
|
iceServers: string[];
|
|
region: "au1" | "br1" | "ie1" | "de1" | "jp1" | "sg1" | "us1" | "us2" | "gll";
|
|
rtcConfiguration: object;
|
|
sounds: object;
|
|
warnings: boolean;
|
|
}
|
|
|
|
interface ConnectionParameters
|
|
{
|
|
CallSid: string;
|
|
AccountSid: string;
|
|
From: string;
|
|
To: string;
|
|
ApiVersion: string;
|
|
}
|
|
|
|
type ConnectionStatus = "pending" | "connecting" | "ringing" | "open" | "closed";
|
|
type ConnectionEvent = "accept" | "disconnect" | "error" | "mute" | "ringing" | "sample" | "volume" | "warning" | "warning-cleared";
|
|
|
|
interface Connection
|
|
{
|
|
parameters: ConnectionParameters;
|
|
customParameters: Map<string, string>;
|
|
options: object;
|
|
accept(audioConstraints?: any): void;
|
|
reject(): void;
|
|
ignore(): void;
|
|
disconnect(): void;
|
|
mute(mute: boolean): void;
|
|
isMuted(): boolean;
|
|
getRemoteStream(): any;
|
|
sendDigits(digits: string): void;
|
|
status(): ConnectionStatus;
|
|
on(event: ConnectionEvent, handler: (...args: any[]) => void): void;
|
|
on(event: "mute", handler: (muted: boolean, connection: Connection) => void): void;
|
|
}
|
|
|
|
interface MediaDevicesInfo
|
|
{
|
|
deviceId: string;
|
|
groupId: string;
|
|
kind: string;
|
|
label: string;
|
|
}
|
|
|
|
interface AudioOutputCollection
|
|
{
|
|
get(): Set<MediaDevicesInfo>;
|
|
set(deviceId: string | string[]): void;
|
|
test(soundUrl: string): void;
|
|
}
|
|
|
|
type AudioDeviceEvent = "deviceChange" | "inputVolume";
|
|
|
|
interface DeviceAudio
|
|
{
|
|
setAudioConstraints(audioConstraints: object): void;
|
|
setInputDevice(id: string): void;
|
|
unsetAudioContraints(): void;
|
|
unsetInputDevice(id: string): void;
|
|
on(event: AudioDeviceEvent, callback: (data: any) => void): void;
|
|
audioContraits: object;
|
|
|
|
availableOutputDevices: Map<string, MediaDevicesInfo>;
|
|
availableInputDevices: Map<string, MediaDevicesInfo>;
|
|
inputDevice: MediaDevicesInfo;
|
|
speakerDevices: AudioOutputCollection;
|
|
ringtoneDevices: AudioOutputCollection;
|
|
|
|
isOutputSelectionSupported: boolean;
|
|
}
|
|
|
|
type DeviceStatus = "ready" | "offline" | "busy";
|
|
type DeviceEvent = "cancel" | "connect" | "disconnect" | "error" | "incoming" | "offline" | "ready";
|
|
|
|
class Device
|
|
{
|
|
constructor(token: string, params?: SetupParams);
|
|
public setup(token: string, params?: SetupParams): void;
|
|
public connect(params: any, audioConstraints?: any): Connection;
|
|
public activeConnection(): Connection | undefined;
|
|
public destroy(): void;
|
|
public disconnectAll(): void;
|
|
public status(): DeviceStatus;
|
|
public on(event: DeviceEvent, handler: (...args: any[]) => void): void;
|
|
public audio: DeviceAudio;
|
|
}
|
|
|
|
exports.Device = Device;
|
|
} |