sinch-rtc
Version:
RTC JavaScript/Web SDK
114 lines (113 loc) • 5.74 kB
TypeScript
import { CallClientListener } from "./listeners/CallClientListener";
import { Call } from "./Call";
export interface CallClient {
/**
* Makes a call to the user with the given id.
*
* @param toUserId - The app specific id of the user to call. May not be null or empty.
* @param headers - Headers to pass with the call.
* @returns A {@link Call} instance.
* @throws InvalidOperationError if {@link SinchClient} is not started
* @throws ArgumentError if the size of all header strings exceeds 1024 bytes when encoded as UTF-8.
*/
callUser(toUserId: string, headers?: Record<string, string>): Promise<Call>;
/**
* Makes a video call to the user with the given id and adding the given headers.
*
* @param toUserId - The app specific id of the user to call. May not be null or empty.
* @param headers - Headers to pass with the call.
* @returns A {@link Call} instance.
* @throws InvalidOperationError if {@link SinchClient} is not started
* @throws ArgumentError if the size of all header strings exceeds 1024 bytes when encoded as UTF-8.
*/
callUserVideo(toUserId: string, headers?: Record<string, string>): Promise<Call>;
/**
* Calls a phone number and terminates the call to the PSTN-network (Publicly Switched
* Telephone Network).
*
* @param phoneNumber - The phone number to call.
* The phone number should be given according to E.164 number formatting
* (http://en.wikipedia.org/wiki/E.164) and should be prefixed with a '+'.
* E.g. to call the US phone number 415 555 0101, it should be specified as
* "+14155550101", where the '+' is the required prefix and the US country
* code '1' added before the local subscriber number.
* @param headers - Headers to pass with the call.
* @returns A {@link Call} instance.
* @throws InvalidOperationError if {@link SinchClient} is not started
* @throws ArgumentError if conferenceId exceeds 64 characters
* @throws ArgumentError if the size of all header strings exceeds 1024 bytes when encoded as UTF-8.
*/
callPhoneNumber(phoneNumber: string, headers?: Record<string, string>): Promise<Call>;
/**
* Makes a SIP call to the user with the given identity. The identity should be in the form "sip:user\@server".
*
* @param sipIdentity - SIP identity to dial in to.
* @returns A {@link Call} instance.
* @throws InvalidOperationError if {@link SinchClient} is not started
* @throws ArgumentError if sipIdentity exceeds 64 characters
* @throws ArgumentError if the size of all header strings exceeds 1024 bytes when encoded as UTF-8.
*/
callSip(sipIdentity: string, headers?: Record<string, string>): Promise<Call>;
/**
* Calls the conference with the given id and the given headers.
*
* @param conferenceId - Conference ID to dial in to.
* @param headers - Headers to pass with the call.
* @returns A {@link Call} instance.
* @throws InvalidOperationError if {@link SinchClient} is not started
* @throws ArgumentError if the size of all header strings exceeds 1024 bytes when encoded as UTF-8.
*/
callConference(conferenceId: string, headers?: Record<string, string>): Promise<Call>;
/**
* The {@link CallClientListener} object will be notified of new incoming calls.
*
* @param listener - a {@link CallClientListener}
*/
addListener(listener: CallClientListener): void;
/**
* Remove listener for incoming call events.
*
* @param listener - a {@link CallClientListener}
*/
removeListener(listener: CallClientListener): void;
/**
* Returns the {@link Call} object with the identifier `callId`.
*
* @param callId - The call identifier string.
* @returns A {@link Call} instance if one matches, otherwise `undefined`.
*/
getCall(callId: string): Call | undefined;
/**
* Sets or removes audio track constraints that are applied to ongoing calls
* and will also be used for any new Call created.
*
* @param constraints - The constraints to apply for the audio track:
* - Provide a {@link MediaTrackConstraints} object to apply specific constraints
* (e.g. `{ deviceId: { exact: "mic-id" }, echoCancellation: true }`).
* - Pass `null` to remove previously set constraints, falling back to the default device
* when requesting audio.
*
* @example
* ```ts
* callClient.setAudioTrackConstraints({ echoCancellation: true });
* callClient.setAudioTrackConstraints(null); // remove constraints, use default device
* ```
*/
setAudioTrackConstraints(constraints: MediaTrackConstraints | null): void;
/**
* Sets or removes video track constraints that are applied to ongoing calls
* and will also be used for any new Call created.
*
* @param constraints - The constraints to apply for the video track:
* - Provide a {@link MediaTrackConstraints} object to apply specific constraints
* (e.g. `{ width: 1280, height: 720 }`).
* - Pass `null` to remove previously set constraints, falling back to default constraints.
*
* @example
* ```ts
* callClient.setVideoTrackConstraints({ width: 1280, height: 720 });
* callClient.setVideoTrackConstraints(null); // remove constraints, use default/fallback
* ```
*/
setVideoTrackConstraints(constraints: MediaTrackConstraints | null): void;
}