-
Notifications
You must be signed in to change notification settings - Fork 2
Call
id(): stringoptions(): CallOptionscustomData(): CustomDatastatus(): CallStatusduration(): numberstartTime(): DateestablishTime(): DateendTime(): Datemute(shouldMute: boolean): Promise<void>muted(): booleansendDTMF(dtmf: string): Promise<void>source(): Endpointdestination(): Endpointcounterpart(): Endpointhangup(): voidsetAudioInputDevice(deviceId: string): Promise<void>setAudioFilter(audioFilter: AudioFilter): Promise<void>audioFilter(): AudioFilterclearAudioFilter(): Promise<void>setAudioQualityMode(audioQualityMode: AudioQualityMode): voidaudioQualityMode(): AudioQualityModeon(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())}`);Getter for the customData field.
none
-
CustomData- Value of thecustomDatafield that is defined as an object of key-valuestringpairs.
let infobipRTC = createInfobipRtc('2e29c3a0-730a-4526-93ce-cda44556dab5', {debug: true});
let webrtcCallOptions = WebrtcCallOptions.builder().setCustomData({'city': 'New York'}).build();
let webrtcCall = infobipRTC.callWebrtc('alice', webrtcCallOptions);
console.log(`Custom data: ${JSON.stringify(webrtcCall.customData())}`);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-trueif 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 theAudioFilterinterface.
-
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 theAudioFilterinterface.
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.setAudioQualityMode(AudioQualityMode.LOW_DATA)
});Returns the audio quality mode that is used during the call.
none
-
AudioQualityMode- Enum value that corresponds to the audio quality mode.
let infobipRTC = createInfobipRtc('2e29c3a0-730a-4526-93ce-cda44556dab5', {debug: true});
let webrtcCall = infobipRTC.callWebrtc('alice');
console.log(`Audio quality mode: ${webrtcCall.audioQualityMode()}`);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- AMediaStreamobject representing the media being played is received in the event object.event = { stream: MediaStream }
-
ESTABLISHED- AMediaStreamobject representing the media in the call is received in the event object.event = { stream: MediaStream }
-
HANGUP- A receivedErrorCodeobject provides details about the reason for the call hang-up, along with aTotalMediaStatsobject that offers a comprehensive summary of the call's audio statistics.event = { errorCode: ErrorCode, totalMediaStats: TotalMediaStats }
-
ERROR- A receivedErrorCodeobject provides details about the reason for the error occurrence.event = { errorCode: ErrorCode }
-
TALKING_WHILE_MUTED- No additional data is provided in the event object.event = {}
-
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 }
-
CALL_RECORDING_STARTED- An event that is triggered once a call recording starts. It includes RecordingType object which details the type of recording initiated.event = { recordingType: RecordingType }
-
RECONNECTING- No additional data is provided in the event object.event = {}
-
RECONNECTED- No additional data is provided in the event object.event = {}
-
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.TALKING_WHILE_MUTED, (event) => {
console.log(`You are talking while muted. Do you want to unmute?`);
});
phoneCall.on(CallsApiEvent.NETWORK_QUALITY_CHANGED, (event) => {
console.log(`Local network quality is: ${NetworkQuality[event.networkQuality]}`);
});
phoneCall.on(CallsApiEvent.CALL_RECORDING_STARTED, (event) => {
console.log(`Call recording started with type: ${event.recordingType}`);
});
phoneCall.on(CallsApiEvent.DISCONNECTED, (event) => {
console.log('Call disconnected!');
});
phoneCall.on(CallsApiEvent.RECONNECTED, (event) => {
console.log('Call reconnected!');
});