-
Notifications
You must be signed in to change notification settings - Fork 2
InfobipRTC
constructor(token: string, rtcOptions: any = {})
connect()
disconnect()
on(eventName: string, eventHandler: any)
call(identity: string, options?: CallOptions): OutgoingCall
callPhoneNumber(phoneNumber: string, options?: CallPhoneNumberOptions): OutgoingCall
callConversations(options?: CallOptions): OutgoingCall
getAudioInputDevices(): Promise<MediaDeviceInfo[]>
getAudioOutputDevices(): Promise<MediaDeviceInfo[]>
getVideoInputDevices(): Promise<MediaDeviceInfo[]>
setAudioInputDevice(deviceId: string)
setVideoInputDevice(deviceId: string)
unsetAudioInputDevice(deviceId: string)
unsetVideoInputDevice(deviceId: string)
There are three types of events in Infobip RTC API:
-
RTC events
- Ones that are configured globally, per connection basis. Allowed values are:connected
,disconnected
,reconnecting
,reconnected
andincoming-call
. -
Call events
- Ones that are configured per call basis. Allowed values are:ringing
,early-media
,established
,updated
,hangup
,error
,network-quality-changed
,remote-network-quality-changed
,user-muted
anduser-unmuted
. -
Conference events
- Ones that are configured per conference basis. Allowed values are:joined
,left
,error
,user-joined
,user-left
,user-muted
,user-unmuted
,local-video-added
,local-video-removed
,local-video-updated
,user-video-added
anduser-video-removed
.
Creates a new instance of InfobipRTC
, used to make all requests to Infobip WebRTC platform. This method is only used
for creating the instance, while connecting to WebSocket API is done via connect
method.
-
token
:string
- Authentication token generated by client's app via Infobip's HTTP /webrtc/1/token endpoint. -
rtcOptions
:any
- Optional object containing options used to configure InfobipRTC. The following fields are supported:
none
let infobipRTC = new InfobipRTC('2e29c3a0-730a-4526-93ce-cda44556dab5', {debug: true});
Connects to Infobip's WebSocket API (WebRTC platform), using authentication and options supplied through the
constructor. If any temporary errors occur (e.g. network issue), the connection will be reattempted with an exponential
backoff with an initial delay of 50 ms, up to 1000 ms, over 50 attempts. In case the retries fail, or a permanent error
occurs (e.g. authentication error), an error is thrown. Also throws in case the status isn't OFFLINE
.
none
none
let infobipRTC = new InfobipRTC('2e29c3a0-730a-4526-93ce-cda44556dab5', {debug: true});
infobipRTC.connect();
Disconnects from Infobip's WebSocket API (WebRTC platform), if connected. Throws an error if status is not ONLINE
.
none
none
let infobipRTC = new InfobipRTC('2e29c3a0-730a-4526-93ce-cda44556dab5', {debug: true});
infobipRTC.connect();
infobipRTC.disconnect();
Configures the event handler for RTC events, ones that are configured globally, per connection basis.
-
eventName
:string
- Name of the RTC event. Name of RTC event. Allowed values are:connected
,disconnected
,reconnecting
,reconnected
andincoming-call
. -
eventHandler
:any
- Function that will be called when specified event occurs, with exactly one parameter being passed to the function containing event information. Depending on the event, the passed parameter will contain a set of fields that will describe the event, namely:-
connected
-identity
field (identity set by Infobip client's app, when generating token via Infobip's HTTP /webrtc/1/token endpoint) will be provided.event = {identity: 'alice'}
-
disconnected
-reason
field will be provided, describing the reason why Infobip's WebSocket got disconnected.event = {reason: 'Connection error.'}
-
reconnecting
- No additional fields will be passed.event = {}
-
reconnected
- No additional fields will be passed.event = {}
-
incoming-call
- Incoming call event (instance ofIncomingCallEvent
class), containing incoming call (instance ofCall
class) and custom data, will be provided.event = {incomingCall: callObject, customData: {}}
-
none
let infobipRTC = new InfobipRTC('2e29c3a0-730a-4526-93ce-cda44556dab5', {debug: true});
infobipRTC.connect();
infobipRTC.on('connected', function (event) {
console.log(`Connected with identity: ${event.identity}`);
});
infobipRTC.on('incoming-call', function (event) {
console.log(`Incoming call from: ${event.incomingCall.source().identity}`);
});
Makes an outgoing call to another user of Infobip's WebRTC platform.
-
identity
:string
- Destination identity to call. If the identity does not exist, the call will be hung up with the proper reason. -
options
:CallOptions
- Optional additional options used to configure an outgoing call.
-
OutgoingCall
- Instance of theOutgoingCall
.
- Example of initiating audio call:
let infobipRTC = new InfobipRTC('2e29c3a0-730a-4526-93ce-cda44556dab5', {debug: true});
infobipRTC.connect();
let call = infobipRTC.call('alice');
- Example of initiating video call:
let infobipRTC = new InfobipRTC('2e29c3a0-730a-4526-93ce-cda44556dab5', {debug: true});
infobipRTC.connect();
let call = infobipRTC.call('alice', CallOptions.builder().setVideo(true).build());
- Example of initiating call with video and recording turned on
let infobipRTC = new InfobipRTC('2e29c3a0-730a-4526-93ce-cda44556dab5', {debug: true});
infobipRTC.connect();
let recordingOptions = RecordingOptions.builder()
.setAudio(true)
.setVideo(true)
.build();
let callOptions = CallOptions.builder()
.setVideo(true)
.setRecording(recordingOptions)
.build();
let call = infobipRTC.call('alice', callOptions);
Makes an outgoing call to a given phone number (physical device, connected to Public Switched Telephone Network, mobile or landline).
-
phoneNumber
:string
- Destination phone number to call. If the phone number does not exist, the call will be hung up with the proper reason. -
options
:CallPhoneNumberOptions
- Optional additional options used to configure an outgoing call.
-
OutgoingCall
- Instance of theOutgoingCall
.
- Example of initiating call to a phone number
let infobipRTC = new InfobipRTC('2e29c3a0-730a-4526-93ce-cda44556dab5', {debug: true});
infobipRTC.connect();
let call = infobipRTC.callPhoneNumber('41793026727', CallPhoneNumberOptions.builder().setFrom('33712345678').build());
- Example of initiating call to a phone number with recording turned on
let infobipRTC = new InfobipRTC('2e29c3a0-730a-4526-93ce-cda44556dab5', {debug: true});
infobipRTC.connect();
let recordingOptions = RecordingOptions.builder()
.setAudio(true)
.build();
let callPhoneNumberOptions = CallPhoneNumberOptions.builder()
.setFrom('33712345678')
.setRecording(recordingOptions)
.build();
let call = infobipRTC.callPhoneNumber('41793026727', callPhoneNumberOptions);
Makes an outgoing call to Infobip Conversations platform.
-
options
:CallOptions
- Optional additional options used to configure an outgoing call.
-
OutgoingCall
- Instance of theOutgoingCall
.
- Example of initiating audio call:
let infobipRTC = new InfobipRTC('2e29c3a0-730a-4526-93ce-cda44556dab5', {debug: true});
infobipRTC.connect();
let call = infobipRTC.callConversations();
- Example of initiating video call:
let infobipRTC = new InfobipRTC('2e29c3a0-730a-4526-93ce-cda44556dab5', {debug: true});
infobipRTC.connect();
let call = infobipRTC.callConversations(CallOptions.builder().setVideo(true).build());
- Example of initiating video call with recording turned on
let infobipRTC = new InfobipRTC('2e29c3a0-730a-4526-93ce-cda44556dab5', {debug: true});
infobipRTC.connect();
let recordingOptions = RecordingOptions.builder()
.setAudio(true)
.setVideo(true)
.build();
let callOptions = CallOptions.builder()
.setVideo(true)
.setRecording(recordingOptions)
.build();
let call = infobipRTC.callConversations(callOptions);
Returns available audio input devices.
none
-
Promise<MediaDeviceInfo[]>
- Promise that resolves to an array containing available audio input devices info.
let infobipRTC = new InfobipRTC('2e29c3a0-730a-4526-93ce-cda44556dab5', {debug: true});
infobipRTC.connect();
infobipRTC.getAudioInputDevices()
.then(devices => {
devices.forEach(device => console.log(device.label));
})
.catch(error => console.error(error.message));
Returns available audio output devices.
none
-
Promise<MediaDeviceInfo[]>
- Promise that resolves to an array containing available audio output devices info.
let infobipRTC = new InfobipRTC('2e29c3a0-730a-4526-93ce-cda44556dab5', {debug: true});
infobipRTC.connect();
infobipRTC.getAudioOutputDevices()
.then(devices => {
devices.forEach(device => console.log(device.label));
})
.catch(error => console.error(error.message));
Returns available video input devices.
none
-
Promise<MediaDeviceInfo[]>
- Promise that resolves to an array containing available video input devices info.
let infobipRTC = new InfobipRTC('2e29c3a0-730a-4526-93ce-cda44556dab5', {debug: true});
infobipRTC.connect();
infobipRTC.getVideoInputDevices()
.then(devices => {
devices.forEach(device => console.log(device.label));
})
.catch(error => console.error(error.message));
Sets the audio input device with the given id as the default option for all subsequent calls.
-
deviceId
:string
- Audio input device identifier.
none
let infobipRTC = new InfobipRTC('2e29c3a0-730a-4526-93ce-cda44556dab5', {debug: true});
infobipRTC.connect();
infobipRTC.setAudioInputDevice('audioDeviceId');
Sets the video input device with the given id as the default option for all subsequent calls.
-
deviceId
:string
- Video input device identifier.
none
let infobipRTC = new InfobipRTC('2e29c3a0-730a-4526-93ce-cda44556dab5', {debug: true});
infobipRTC.connect();
infobipRTC.setVideoInputDevice('videoDeviceId');
Clears the specified audio input device as the default device. Instead, the system default will be used for subsequent calls.
-
deviceId
:string
- Audio input device identifier.
none
let infobipRTC = new InfobipRTC('2e29c3a0-730a-4526-93ce-cda44556dab5', {debug: true});
infobipRTC.connect();
infobipRTC.unsetAudioInputDevice('audioDeviceId');
Clears the specified video input device as the default device. Instead, the system default will be used for subsequent calls.
-
deviceId
:string
- Video input device identifier.
none
let infobipRTC = new InfobipRTC('2e29c3a0-730a-4526-93ce-cda44556dab5', {debug: true});
infobipRTC.connect();
infobipRTC.unsetVideoInputDevice('videoDeviceId');
Joins a conference call on Infobip's WebRTC platform.
-
conferenceId
:string
- A unique identifier for every conference room on Infobip RTC platform. -
options
:ConferenceOptions
- Optional additional options used to configure a conference call.
-
Conference
- Instance of theConference
.
let infobipRTC = new InfobipRTC('2e29c3a0-730a-4526-93ce-cda44556dab5', {debug: true});
infobipRTC.connect();
let conference = infobipRTC.joinConference('conference-demo', ConferenceOptions.builder().audio(true).video(true).build());
Makes an outgoing application call through Infobip's Calls platform to your application.
-
applicationId
:string
- Represents the application ID of your backend application that's set up earlier through the Calls API. -
options
:CallOptions
- Optional additional options used to configure an application call.
-
ApplicationCall
- Instance of theApplicationCall
.
- Example of initiating audio call:
let infobipRTC = new InfobipRTC('2e29c3a0-730a-4526-93ce-cda44556dab5', {debug: true});
infobipRTC.connect();
let applicationCall = infobipRTC.callApplication('45g2gql9ay4a2blu55uk1628', CallOptions.builder().setAudio(true).build());
- Example of initiating video call:
let infobipRTC = new InfobipRTC('2e29c3a0-730a-4526-93ce-cda44556dab5', {debug: true});
infobipRTC.connect();
let applicationCall = infobipRTC.callApplication('45g2gql9ay4a2blu55uk1628', CallOptions.builder().setVideo(true).build());
- InfobipRTC
- Call
- IncomingCall
- OutgoingCall
- CallOptions
- CallOptionsBuilder
- RecordingOptions
- RecordingOptionsBuilder
- VideoOptions
- VideoOptionsBuilder
- CameraOrientation
- CallPhoneNumberOptions
- CallPhoneNumberOptionsBuilder
- DeclineOptions
- DeclineOptionsBuilder
- CallStatus
- HangupStatus
- User
- IncomingCallEvent
- Conference
- ConferenceOptions
- ConferenceOptionsBuilder
- ConferenceUser
- NetworkQuality
-
ApplicationCall
-
IncomingApplicationCall
-
ApplicationCallApiEvents
-
IncomingApplicationCallEvent
-
Participant
-
State
-
Media
-
Audio
-
Endpoint
-
EndpointType
-
WebrtcEndpoint
-
PhoneEndpoint
-
SipEndpoint
-
AudioOptions
-
AudioOptionsBuilder
-
AudioFilter
-
AudioFilterFactory
-
VideoFilter
-
VideoFilterFactory