-
Notifications
You must be signed in to change notification settings - Fork 0
Call
id(): string
hangup(): void
on(event: string, eventHandler: any): void
mute(shouldMute: boolean): Promise<void>
sendDTMF(dtmf: string): Promise<void>
muted(): boolean
status(): CallStatus
correlationId(): string
duration(): number
startTime(): Date
establishTime(): Date
endTime(): Date
localVideo(localVideo: boolean): Promise<void>
hasLocalVideo(): boolean
hasRemoteVideo(): boolean
screenShare(screenShare: boolean): Promise<void>
hasScreenShare(): boolean
source(): User
destination(): User
getRecordingOptions(): RecordingOptions
setAudioInputDevice(deviceId: string): Promise<void>
setVideoInputDevice(deviceId: string: Promise<void>)
cameraOrientation(): CameraOrientation
-
setCameraOrientation(cameraOrientation: CameraOrientation): Promise<void>
Returns a unique call identifier on Infobip RTC platform.
none
-
string
- Call ID.
let infobipRTC = new InfobipRTC('2e29c3a0-730a-4526-93ce-cda44556dab5', {debug: true});
let call = infobipRTC.call('alice');
console.log(`Call ID: ${call.id()}`);
Hangs up a call, which ends up in both parties receiving a hangup
event, after the hangup is processed by Infobip
WebRTC platform.
none
none
let infobipRTC = new InfobipRTC('2e29c3a0-730a-4526-93ce-cda44556dab5', {debug: true});
let call = infobipRTC.call('alice');
call.on('established', _ => {
call.hangup();
});
Configures the event handler for call events.
-
eventName
:string
- Name of the call event. Allowed values are:ringing
,early-media
,established
,updated
,hangup
,error
,network-quality-changed
,remote-network-quality-changed
,user-muted
anduser-unmuted
.ringing
andearly-media
events are forOutgoingCall
only.early-media
event is used for phone number calls only. It is emitted when other side is sending ringback tone. -
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:-
ringing
- No additional fields will be passed.event = {}
-
early-media
-localStream
andremoteStream
fields (media streams of both parties of the call) will be provided.event = {localStream: streamObject, remoteStream: streamObject}
-
established
-localStream
andremoteStream
fields (media streams of both parties of the call) will be provided.event = {localStream: streamObject, remoteStream: streamObject}
-
updated
-localStream
andremoteStream
fields (media streams of both parties of the call) will be provided.event = {localStream: streamObject, remoteStream: streamObject}
-
hangup
- Call status field (instance ofHangupStatus
class), describing the reason why the call was hung up will be provided.event = {id: 0, description: 'No error.', name: 'NO_ERROR'}
-
error
- Contains call status field (instance ofHangupStatus
class), describing the reason why the error occurred, will be provided.event = {id: 5002, description: 'The end user is currently busy and can not receive a call.', name: ' EC_VOICE_USER_BUSY'}
-
network-quality-changed
-NetworkQuality
enum value which corresponds to the local network quality will be provided.event = {networkQuality: networkQualityObject}
-
remote-network-quality-changed
-NetworkQuality
enum value which corresponds to the remote network quality will be provided.event = {networkQuality: networkQualityObject}
-
user-muted
- Fires when user mutes themselves. No additional fields will be passed.event = {}
-
user-unmuted
- Fires when user unmutes themselves. No additional fields will be passed.event = {}
-
none
Let's assume you have an audio HTML element with the id callAudio
and video HTML elements with the ids localVideo
and remoteVideo
.
When you receive the established
event from our SDK, you will have local and remote video streams in this event (if
they exist), which you need to set as a source on your corresponding HTML elements.
In case some changes occurred during the call (e.g. a participant toggles video), you will receive updated
event with
updated video streams, both local and remote.
For instance, let's consider a participant toggles video or screen share, then:
-
In case it's an audio call, when a local participant starts sending video or initiates screen share, they should display the HTML element with the id
localVideo
snd attach the local stream received in this event on it. The remote participant should start displaying the HTML element with the idremoteVideo
and attach the remote stream received in this event on it. -
In a video call where both participants already have video, when one participant starts sharing their screen, the local participant should update their local stream received in this event, while the remote participant doesn't have to perform any actions as they are already displaying the remote stream.
let infobipRTC = new InfobipRTC('2e29c3a0-730a-4526-93ce-cda44556dab5', {debug: true});
let call = infobipRTC.call('alice');
call.on('ringing', () => _ => {
console.log('Ringing....');
});
call.on('early-media', () => _ => {
console.log('Ringing....');
});
call.on('established', (event) => {
$('#localVideo').srcObject = event.localStream;
$('#remoteVideo').srcObject = event.remoteStream;
});
call.on('updated', (event) => {
$('#localVideo').srcObject = event.localStream;
$('#remoteVideo').srcObject = event.remoteStream;
});
call.on('network-quality-changed', (event) => {
});
call.on('remote-network-quality-changed', (event) => {
});
call.on('user-muted', () => _ => {
console.log('User muted');
});
call.on('user-unmuted', () => _ => {
console.log('User unmuted');
});
call.on('hangup', function (event) {
console.log(`Call finished. Status: ${event.name}`);
});
call.on('error', function (event) {
console.log(`Call finished. Error: ${event.name}`);
});
Toggles mute option.
-
shouldMute
:boolean
- Whether the audio should be muted after this action.
-
Promise<void>
- Promise that resolves tovoid
.
let infobipRTC = new InfobipRTC('2e29c3a0-730a-4526-93ce-cda44556dab5', {debug: true});
let call = infobipRTC.call('alice');
call.on('established', _ => {
call.mute(true)
.catch(error => console.log("Error: {}", error));
});
Simulates key-press by sending DTMF (Dual-Tone Multi-Frequency) entry.
-
dtmf
:string
- One of the allowed DTMF characters (digits from0
to9
, letters fromA
toD
, symbols*
and#
).
-
Promise<void>
- Promise that resolves tovoid
.
let infobipRTC = new InfobipRTC('2e29c3a0-730a-4526-93ce-cda44556dab5', {debug: true});
let call = infobipRTC.call('alice');
call.on('established', _ => {
call.sendDTMF('1')
.catch(error => console.log("Error: {}", error));
});
Returns information whether the audio is muted.
none
-
boolean
-true
if audio is muted, otherwisefalse
.
let infobipRTC = new InfobipRTC('2e29c3a0-730a-4526-93ce-cda44556dab5', {debug: true});
let call = infobipRTC.call('alice');
call.on('established', _ => {
call.mute(true);
let muted = call.muted() ? "muted" : "not muted";
console.log(`Audio is ${muted}`);
});
Returns current call status.
none
-
CallStatus
- Call status.
let infobipRTC = new InfobipRTC('2e29c3a0-730a-4526-93ce-cda44556dab5', {debug: true});
let call = infobipRTC.call('alice');
console.log(`Call status: ${call.status()}`);
Returns a unique conversation identifier shared for every call leg included in a single conversation.
none
-
string
- Correlation ID.
let infobipRTC = new InfobipRTC('2e29c3a0-730a-4526-93ce-cda44556dab5', {debug: true});
let call = infobipRTC.call('alice');
console.log(`Correlation ID: ${call.correlationId()}`);
Returns call duration in seconds calculated from the time call was established. Initially, duration is 0.
none
-
number
- Call duration in seconds.
let infobipRTC = new InfobipRTC('2e29c3a0-730a-4526-93ce-cda44556dab5', {debug: true});
let call = infobipRTC.call('alice');
call.on('hangup', _ => {
let durationInSeconds = call.duration();
let seconds = ('0' + Math.floor(durationInSeconds % 60)).slice(-2);
let minutes = ('0' + (Math.floor(durationInSeconds / 60) % 60)).slice(-2);
let hours = ('0' + Math.floor(durationInSeconds / 3600)).slice(-2);
console.log(`Duration: ${hours}:${minutes}:${seconds}`);
});
Returns the time when the call started (but not yet established). Initially, startTime is undefined
.
none
-
Date
- Time when the call started.
let infobipRTC = new InfobipRTC('2e29c3a0-730a-4526-93ce-cda44556dab5', {debug: true});
let call = infobipRTC.call('alice');
console.log(`Start time: ${call.startTime()}`);
Returns the time when the call was established. Initially, establishTime is undefined
.
none
-
Date
- Time when the call was established.
let infobipRTC = new InfobipRTC('2e29c3a0-730a-4526-93ce-cda44556dab5', {debug: true});
let call = infobipRTC.call('alice');
call.on('established', _ => {
console.log(`Establish time: ${call.establishTime()}`);
});
Returns the time when the call finished. Initially, endTime is undefined
.
none
-
Date
- Time when the call finished.
let infobipRTC = new InfobipRTC('2e29c3a0-730a-4526-93ce-cda44556dab5', {debug: true});
let call = infobipRTC.call('alice');
call.on('established', _ => {
call.hangup();
});
call.on('hangup', _ => {
console.log(`End time: ${call.endTime()}`);
});
Controls whether the local video should be enabled. For video calls it is enabled by default.
-
localVideo
:boolean
- Whether local video should be enabled.
-
Promise<void>
- Promise that resolves tovoid
.
let infobipRTC = new InfobipRTC('2e29c3a0-730a-4526-93ce-cda44556dab5', {debug: true});
let call = infobipRTC.call('alice');
call.on('established', _ => {
call.localVideo(true)
.catch(error => console.log("Error: {}", error));
});
Returns information whether the current call has local video.
none
-
boolean
-true
if the call has local video, otherwisefalse
.
let infobipRTC = new InfobipRTC('2e29c3a0-730a-4526-93ce-cda44556dab5', {debug: true});
let callOptions = CallOptions.builder().setVideo(true).build();
let outgoingCall = infobipRTC.call('alice', callOptions);
let callType = outgoingCall.hasLocalVideo() ? 'video' : 'audio';
console.log(`Making ${callType} outgoing call.`);
Returns information whether the current call has remote video.
none
-
boolean
-true
if the call has remote video, otherwisefalse
.
let infobipRTC = new InfobipRTC('2e29c3a0-730a-4526-93ce-cda44556dab5', {debug: true});
infobipRTC.on('incoming-call', function (incomingCallEvent) {
let incomingCall = incomingCallEvent.incomingCall;
let callType = incomingCall.hasRemoteVideo() ? 'video' : 'audio';
console.log(`Received ${callType} incoming call.`);
});
Toggles sharing the screen during the call.
After one participant in the call toggles this option and starts sharing their screen, the updated
event will be
triggered on both sides.
This method is not available in mobile versions of browsers.
-
screenShare
:boolean
- Controls whether the screen sharing should be started or stopped.
-
Promise<void>
- Promise that resolves tovoid
.
let infobipRTC = new InfobipRTC('2e29c3a0-730a-4526-93ce-cda44556dab5', {debug: true});
let call = infobipRTC.call('alice');
call.on('established', _ => {
call.screenShare(true)
.catch(error => console.log("Error: {}", error));
});
call.on('updated', _ => {
console.log('Started sharing screen');
})
Returns information whether screen is being shared with remote peer.
none
-
boolean
-true
if screen is being share, otherwisefalse
.
let infobipRTC = new InfobipRTC('2e29c3a0-730a-4526-93ce-cda44556dab5', {debug: true});
let call = infobipRTC.call('alice');
call.on('established', _ => {
call.screenShare(true);
});
call.on('updated', _ => {
if (call.hasScreenShare()) {
console.log('Sharing screen...');
}
})
Returns the user who originated the call.
none
-
User
- User who initiated the call.
let infobipRTC = new InfobipRTC('2e29c3a0-730a-4526-93ce-cda44556dab5', {debug: true});
infobipRTC.on('incoming-call', function (incomingCallEvent) {
const incomingCall = incomingCallEvent.incomingCall;
console.log(`Received incoming call from: ${incomingCall.source().identity()}`);
});
Returns the user who is receiving the call.
none
-
User
- User who received the call.
let infobipRTC = new InfobipRTC('2e29c3a0-730a-4526-93ce-cda44556dab5', {debug: true});
let outgoingCall = infobipRTC.call('alice');
console.log(`Calling ${outgoingCall.destination().identity()}`);
Returns call recording options indicating whether audio and/or video stream is being recorded.
none
-
RecordingOptions
- Recording options.
let infobipRTC = new InfobipRTC('2e29c3a0-730a-4526-93ce-cda44556dab5', {debug: true});
let call = infobipRTC.call('alice');
call.on('established', _ => {
console.log(`Call audio is being recorded: ${call.getRecordingOptions().audio()}`);
});
Sets the audio input device with the given id to be used during the call.
-
deviceId
:string
- Audio input device identifier.
-
Promise<void>
- Promise that resolves tovoid
.
let infobipRTC = new InfobipRTC('2e29c3a0-730a-4526-93ce-cda44556dab5', {debug: true});
let call = infobipRTC.call('alice');
call.on('established', _ => {
call.setAudioInputDevice('audioDeviceId')
.catch(error => console.log("Error: {}", error));
});
Sets the video input device with the given id to be used during the call.
-
deviceId
:string
- Video input device identifier.
-
Promise<void>
- Promise that resolves tovoid
.
let infobipRTC = new InfobipRTC('2e29c3a0-730a-4526-93ce-cda44556dab5', {debug: true});
let call = infobipRTC.call('alice', CallOptions.Builder.setVideo(true).build());
call.on('established', _ => {
call.setVideoInputDevice('videoDeviceId')
.catch(error => console.log("Error: {}", error));
});
Returns current camera orientation.
none
-
CameraOrientation
- Enum value which corresponds to the camera orientation.
let videoOptions = VideoOptions.builder().setCameraOrientation(CameraOrientation.BACK).build();
let callOptions = CallOptions.builder().setVideo(true).setVideoOptions(videoOptions).build();
let call = infobipRTC.call('alice', callOptions);
console.log(`Camera orientation is: ${call.cameraOrientation()}`);
Sets a local camera orientation to the given enum value.
-
CameraOrientation
- Enum value which corresponds to the camera orientation.
-
Promise<void>
- Promise that resolves tovoid
.
let call = infobipRTC.call('alice', CallOptions.Builder.setVideo(true).build());
call.on('established', _ => {
call.setCameraOrientation(CameraOrientation.BACK)
.catch(error => console.log("Error: {}", error));
});