-
Notifications
You must be signed in to change notification settings - Fork 0
Call
id(): string
options(): CallOptions
status(): CallStatus
duration(): number
startTime(): Date
establishTime(): Date
endTime(): Date
mute(shouldMute: boolean): Promise<void>
muted(): boolean
sendDTMF(dtmf: string): Promise<void>
source(): Endpoint
destination(): Endpoint
counterpart(): Endpoint
hangup(): void
setAudioInputDevice(deviceId: string): Promise<void>
setAudioFilter(audioFilter: AudioFilter): Promise<void>
audioFilter(): AudioFilter
clearAudioFilter(): Promise<void>
audioQualityMode(audioQualityMode: AudioQualityMode): void
on(event: CallsApiEvent, eventHandler: CallsEventHandlers): void
Returns a unique call identifier on Infobip RTC platform.
none
-
string
- Call ID.
let infobipRTC = createInfobipRtc('2e29c3a0-730a-4526-93ce-cda44556dab5', {debug: true});
let call = infobipRTC.callWebrtc('alice');
console.log(`Call ID: ${call.id()}`);
Returns the call options this call was started with.
none
-
CallOptions
- Call options the call was started with.
let infobipRTC = createInfobipRtc('2e29c3a0-730a-4526-93ce-cda44556dab5', {debug: true});
let webrtcCall = infobipRTC.callWebrtc('alice', WebrtcCallOptions.builder().build());
console.log(`Call options: ${JSON.stringify(webrtcCall.options())}`);
Returns current call status.
none
-
CallStatus
- Call status.
let infobipRTC = createInfobipRtc('2e29c3a0-730a-4526-93ce-cda44556dab5', {debug: true});
let webrtcCall = infobipRTC.callWebrtc('alice');
console.log(`Call status: ${webrtcCall.status()}`);
Returns call duration in seconds calculated from the time call was established. Initially, duration is 0.
none
-
number
- Call duration in seconds.
let infobipRTC = createInfobipRtc('2e29c3a0-730a-4526-93ce-cda44556dab5', {debug: true});
let webrtcCall = infobipRTC.callWebrtc('alice');
webrtcCall.on(CallsApiEvent.HANGUP, _ => {
let durationInSeconds = webrtcCall.duration();
let seconds = `${String(Math.floor(durationInSeconds % 60)).padStart(2, '0')}`;
let minutes = `${String(Math.floor(durationInSeconds / 60) % 60).padStart(2, '0')}`;
let hours = `${String(Math.floor(durationInSeconds / 3600)).padStart(2, '0')}`;
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 = createInfobipRtc('2e29c3a0-730a-4526-93ce-cda44556dab5', {debug: true});
let webrtcCall = infobipRTC.callWebrtc('alice');
console.log(`Start time: ${webrtcCall.startTime()}`);
Returns the time when the call was established. Initially, establishTime is undefined
.
none
-
Date
- Time when the call was established.
let infobipRTC = createInfobipRtc('2e29c3a0-730a-4526-93ce-cda44556dab5', {debug: true});
let webrtcCall = infobipRTC.callWebrtc('alice');
webrtcCall.on(CallsApiEvent.ESTABLISHED, _ => {
console.log(`Establish time: ${webrtcCall.establishTime()}`);
});
Returns the time when the call finished. Initially, endTime is undefined
.
none
-
Date
- Time when the call finished.
let infobipRTC = createInfobipRtc('2e29c3a0-730a-4526-93ce-cda44556dab5', {debug: true});
let webrtcCall = infobipRTC.callWebrtc('alice');
webrtcCall.on(CallsApiEvent.ESTABLISHED, _ => {
webrtcCall.hangup();
});
webrtcCall.on(CallsApiEvent.HANGUP, _ => {
console.log(`End time: ${calwebrtcCalll.endTime()}`);
});
Toggles mute option.
-
shouldMute
:boolean
- Whether the audio should be muted after this action.
-
Promise<void>
- Promise that resolves tovoid
.
let infobipRTC = createInfobipRtc('2e29c3a0-730a-4526-93ce-cda44556dab5', {debug: true});
let webrtcCall = infobipRTC.callWebrtc('alice');
webrtcCall.on(CallsApiEvent.ESTABLISHED, _ => {
webrtcCall.mute(true)
.catch(error => console.log(`Error: ${error}`));
});
Returns information whether the audio is muted.
none
-
boolean
-true
if audio is muted, otherwisefalse
.
let infobipRTC = createInfobipRtc('2e29c3a0-730a-4526-93ce-cda44556dab5', {debug: true});
let webrtcCall = infobipRTC.callWebrtc('alice');
webrtcCall.on(CallsApiEvent.ESTABLISHED, _ => {
webrtcCall.mute(true);
let muted = webrtcCall.muted() ? 'muted' : 'not muted';
console.log(`Audio is ${muted}`);
});
Simulates key-press by sending DTMF (Dual-Tone Multi-Frequency) entry.
- dtmf:
String
- One of the allowed DTMF characters:- digits: 0 to 9
- letters: A to D
- symbols: * and #
-
Promise<void>
- Promise that resolves tovoid
.
let infobipRTC = createInfobipRtc('2e29c3a0-730a-4526-93ce-cda44556dab5', {debug: true});
let webrtcCall = infobipRTC.callWebrtc('alice');
webrtcCall.on(CallsApiEvent.ESTABLISHED, _ => {
webrtcCall.sendDTMF('1')
.catch(error => console.log(`Error: ${error}`));
});
Returns the endpoint from which the call originated.
none
-
Endpoint
- Endpoint which initiated the call.
let infobipRTC = createInfobipRtc('2e29c3a0-730a-4526-93ce-cda44556dab5', {debug: true});
let webrtcCall = infobipRTC.callWebrtc('alice');
webrtcCall.on(CallsApiEvent.ESTABLISHED, _ => {
console.log(`Source of the currently established call: ${webrtcCall.source().identifier}`);
});
Returns the endpoint that received the call.
none
-
Endpoint
- Endpoint which received the call.
let infobipRTC = createInfobipRtc('2e29c3a0-730a-4526-93ce-cda44556dab5', {debug: true});
let webrtcCall = infobipRTC.callWebrtc('alice');
webrtcCall.on(CallsApiEvent.ESTABLISHED, _ => {
console.log(`Destination of the currently established call: ${webrtcCall.destination().identifier}`);
});
Returns the remote endpoint relating to this call. This isn't dependent on where the call originated, but who is calling this method.
none
-
Endpoint
- Remote endpoint with which the user is connected
let infobipRTC = createInfobipRtc('2e29c3a0-730a-4526-93ce-cda44556dab5', {debug: true});
let webrtcCall = infobipRTC.callWebrtc('alice');
webrtcCall.on(CallsApiEvent.ESTABLISHED, _ => {
console.log(`Remote side of the currently established call: ${webrtcCall.counterpart().identifier}`);
});
Hangs up a call, which ends up in both parties receiving a hangup
event, after the hangup is processed by Infobip
WebRTC platform.
none
N/A
let infobipRTC = createInfobipRtc('2e29c3a0-730a-4526-93ce-cda44556dab5', {debug: true});
let webrtcCall = infobipRTC.callWebrtc('alice');
webrtcCall.on(CallsApiEvent.ESTABLISHED, _ => {
webrtcCall.hangup();
});
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 = createInfobipRtc('2e29c3a0-730a-4526-93ce-cda44556dab5', {debug: true});
let webrtcCall = infobipRTC.callWebrtc('alice');
webrtcCall.on(CallsApiEvent.ESTABLISHED, _ => {
webrtcCall.setAudioInputDevice('audioDeviceId')
.catch(error => console.log(`Error: ${error}`));
});
Sets the audio filter to be used during the call.
Passing null
will remove and release any already existing audio filter.
-
audioFilter
:AudioFilter
- An object instance which implements theAudioFilter
interface.
-
Promise<void>
- Promise that resolves once the filter has been applied to the current audio stream.
let infobipRTC = createInfobipRtc('2e29c3a0-730a-4526-93ce-cda44556dab5', {debug: true});
let webrtcCall = infobipRTC.callWebrtc('alice');
let audioFilter = createAudioFilterImplementation();
webrtcCall.setAudioFilter(audioFilter);
Returns the audio filter that is used during the call.
none
-
AudioFilter
- An object instance which implements theAudioFilter
interface.
let infobipRTC = createInfobipRtc('2e29c3a0-730a-4526-93ce-cda44556dab5', {debug: true});
let webrtcCall = infobipRTC.callWebrtc('alice');
webrtcCall.setAudioFilter(createAudioFilterImplementation());
let audioFilter = webrtcCall.audioFilter();
Convenience method that is used to remove the audio filter if it is present.
none
-
Promise<void>
- Promise that resolves once the filter has been removed.
let infobipRTC = createInfobipRtc('2e29c3a0-730a-4526-93ce-cda44556dab5', {debug: true});
let webrtcCall = infobipRTC.callWebrtc('alice');
webrtcCall.setAudioFilter(createAudioFilterImplementation());
webrtcCall.clearAudioFilter();
Sets the audio quality mode to a given enum value.
-
audioQualityMode
- Enum value that corresponds to the audio quality mode.
N/A
let infobipRTC = createInfobipRtc('2e29c3a0-730a-4526-93ce-cda44556dab5', {debug: true});
let webrtcCall = infobipRTC.callWebrtc('alice');
webrtcCall.on(CallsApiEvent.ESTABLISHED, _ => {
webrtcCall.audioQualityMode(AudioQualityMode.LOW_DATA)
});
Configures the event handler for call events.
-
eventName
:CallsApiEvent
- Name of the application call event. Allowed values are a subset ofCallsApiEvent
. -
eventHandler
:CallsEventHandlers
- 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 data is provided in the event object.event = {}
-
EARLY_MEDIA
- AMediaStream
object representing the media being played is received in the event object.event = { stream: MediaStream }
-
ESTABLISHED
- AMediaStream
object representing the media in the call is received in the event object.event = { stream: MediaStream }
-
HANGUP
- A receivedErrorCode
object provides details about the reason for the call hang-up, along with aTotalMediaStats
object that offers a comprehensive summary of the call's audio statistics.event = { errorCode: ErrorCode, totalMediaStats: TotalMediaStats }
-
ERROR
- A receivedErrorCode
object provides details about the reason for the error occurrence.event = { errorCode: ErrorCode }
-
NETWORK_QUALITY_CHANGED
- An event containing a NetworkQuality and a CurrentMediaStats objects provides details on the network quality of a local participant and its corresponding media stats.event = { networkQuality: NetworkQuality, currentMediaStats: CurrentMediaStats }
-
N/A
Let's assume you have an audio HTML element with the id callAudio
.
let infobipRTC = createInfobipRtc('2e29c3a0-730a-4526-93ce-cda44556dab5', {debug: true});
let phoneCall = infobipRTC.callPhone('41793026727');
phoneCall.on(CallsApiEvent.RINGING, () => {
console.log('Ringing...');
});
phoneCall.on(CallsApiEvent.EARLY_MEDIA, (event) => {
console.log('Ringtone playing...');
$('#callAudio').srcObject = event.stream;
});
phoneCall.on(CallsApiEvent.ESTABLISHED, (event) => {
$('#callAudio').srcObject = event.stream;
});
phoneCall.on(CallsApiEvent.HANGUP, (event) => {
console.log(`Call finished. Status: ${event.errorCode.name}`);
});
phoneCall.on(CallsApiEvent.ERROR, (event) => {
console.log(`An error has occurred. Error: ${event.errorCode.name}`);
});
phoneCall.on(CallsApiEvent.NETWORK_QUALITY_CHANGED, (event) => {
console.log(`Local network quality is: ${NetworkQuality[event.networkQuality]}`);
});