Skip to content

ApplicationCall

Lejla Solak edited this page Aug 5, 2024 · 21 revisions



id()

Description

Returns a unique call identifier.

Arguments

  • none

Returns

Example

let infobipRTC = createInfobipRtc('2e29c3a0-730a-4526-93ce-cda44556dab5', {debug: true});
let applicationCall = infobipRTC.callApplication('45g2gql9ay4a2blu55uk1628');
console.log(`Call ID: ${applicationCall.id()}`);



options()

Description

Returns the call options this call was started with.

Arguments

  • none

Returns

Example

let infobipRTC = createInfobipRtc('2e29c3a0-730a-4526-93ce-cda44556dab5', {debug: true});
let applicationCall = infobipRTC.callApplication('45g2gql9ay4a2blu55uk1628', ApplicationCallOptions.builder().build());
console.log(`Call options: ${JSON.stringify(applicationCall.options())}`);



customData()

Description

Getter for the customData field.

Arguments

  • none

Returns

  • CustomData - Value of the customData field that is defined as an object of key-value string pairs.

Example

let infobipRTC = createInfobipRtc('2e29c3a0-730a-4526-93ce-cda44556dab5', {debug: true});
let applicationCallOptions = ApplicationCallOptions.builder().setCustomData({'city': 'New York'}).build();
let applicationCall = infobipRTC.callApplication('45g2gql9ay4a2blu55uk1628', applicationCallOptions);
console.log(`Custom data: ${JSON.stringify(applicationCall.customData())}`);



status()

Description

Returns current call status.

Arguments

  • none

Returns

Example

let infobipRTC = createInfobipRtc('2e29c3a0-730a-4526-93ce-cda44556dab5', {debug: true});
let applicationCall = infobipRTC.callApplication('45g2gql9ay4a2blu55uk1628');
console.log(`Call status: ${applicationCall.status()}`);



duration()

Description

Returns call duration in seconds calculated from the time call was established. Initially, duration is 0.

Arguments

  • N/A

Returns

  • number - Call duration in seconds.

Example

let infobipRTC = createInfobipRtc('2e29c3a0-730a-4526-93ce-cda44556dab5', {debug: true});
let applicationCall = infobipRTC.callApplication('45g2gql9ay4a2blu55uk1628');
applicationCall.on(CallsApiEvent.HANGUP, _ => {
    let durationInSeconds = applicationCall.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}`);
});



startTime()

Description

Returns the time when the call started (but not yet established). Initially, startTime is undefined.

Arguments

  • none

Returns

  • Date - Time when the call started.

Example

let infobipRTC = createInfobipRtc('2e29c3a0-730a-4526-93ce-cda44556dab5', {debug: true});
let applicationCall = infobipRTC.callApplication('45g2gql9ay4a2blu55uk1628');
console.log(`Start time: ${applicationCall.startTime()}`);



establishTime()

Description

Returns the time when the call was established. Initially, establishTime is undefined.

Arguments

  • none

Returns

  • Date - Time when the call was established.

Example

let infobipRTC = createInfobipRtc('2e29c3a0-730a-4526-93ce-cda44556dab5', {debug: true});
let applicationCall = infobipRTC.callApplication('45g2gql9ay4a2blu55uk1628');
applicationCall.on(CallsApiEvent.ESTABLISHED, _ => {
    console.log(`Establish time: ${applicationCall.establishTime()}`);
});



endTime()

Description

Returns the time when the call finished. Initially, endTime is undefined.

Arguments

  • none

Returns

  • Date - Time when the call finished.

Example

let infobipRTC = createInfobipRtc('2e29c3a0-730a-4526-93ce-cda44556dab5', {debug: true});
let applicationCall = infobipRTC.callApplication('45g2gql9ay4a2blu55uk1628');

applicationCall.on(CallsApiEvent.ESTABLISHED, _ => {
    applicationCall.hangup();
});

applicationCall.on(CallsApiEvent.HANGUP, _ => {
    console.log(`End time: ${applicationCall.endTime()}`);
});



callsConfigurationId()

Description

Returns a unique Calls Configuration identifier associated with your Calls Configuration logical entity created through our Calls API.

Arguments

  • none

Returns

Example

let infobipRTC = createInfobipRtc('2e29c3a0-730a-4526-93ce-cda44556dab5', {debug: true});
let applicationCall = infobipRTC.callApplication('45g2gql9ay4a2blu55uk1628');
console.log(`Calls Configuration ID: ${applicationCall.callsConfigurationId()}`);



mute(shouldMute)

Description

Toggles mute option.

Arguments

  • shouldMute: boolean - Whether the audio should be muted after this action.

Returns

Example

let infobipRTC = createInfobipRtc('2e29c3a0-730a-4526-93ce-cda44556dab5', {debug: true});
let applicationCall = infobipRTC.callApplication('45g2gql9ay4a2blu55uk1628');
applicationCall.on(CallsApiEvent.ESTABLISHED, _ => {
    applicationCall.mute(true)
        .catch(error => console.log(`Error: ${error}`));
});



muted()

Description

Returns information whether the audio is muted.

Arguments

  • none

Returns

  • boolean - true if audio is muted, otherwise false.

Example

let infobipRTC = createInfobipRtc('2e29c3a0-730a-4526-93ce-cda44556dab5', {debug: true});
let applicationCall = infobipRTC.callApplication('45g2gql9ay4a2blu55uk1628');
applicationCall.on(CallsApiEvent.ESTABLISHED, _ => {
    applicationCall.mute(true);
    let muted = applicationCall.muted() ? 'muted' : 'not muted';
    console.log(`Audio is ${muted}`);
});



sendDTMF(dtmf)

Description

Simulates key-press by sending DTMF (Dual-Tone Multi-Frequency) entry.

Arguments

  • dtmf: string - One of the allowed DTMF characters:
    • digits: 0 to 9
    • letters: A to D
    • symbols: * and #

Returns

Example

let infobipRTC = createInfobipRtc('2e29c3a0-730a-4526-93ce-cda44556dab5', {debug: true});
let applicationCall = infobipRTC.callApplication('45g2gql9ay4a2blu55uk1628');
applicationCall.on(CallsApiEvent.ESTABLISHED, _ => {
    applicationCall.sendDTMF('1')
        .catch(error => console.log(`Error: ${error}`));
});



pauseIncomingVideo()

Description

Stop receiving the video media of other participants.

Arguments

  • none

Returns

  • N/A

Example

let infobipRTC = createInfobipRtc('2e29c3a0-730a-4526-93ce-cda44556dab5', {debug: true});
let applicationCall = infobipRTC.callApplication('45g2gql9ay4a2blu55uk1628');
applicationCall.on(CallsApiEvent.ESTABLISHED, _ => {
    document.addEventListener('visibilitychange', () => {
        if (document.visibilityState !== 'visible') {
            console.log('Browser lost focus, stop showing remote video media.');
            applicationCall.pauseIncomingVideo();
        }
    });
});



resumeIncomingVideo()

Description

Start receiving the video media of other participants.

Arguments

  • none

Returns

  • N/A

Example

let infobipRTC = createInfobipRtc('2e29c3a0-730a-4526-93ce-cda44556dab5', {debug: true});
let applicationCall = infobipRTC.callApplication('45g2gql9ay4a2blu55uk1628');
applicationCall.on(CallsApiEvent.ESTABLISHED, _ => {
    document.addEventListener('visibilitychange', () => {
        if (document.visibilityState === 'visible') {
            console.log('Browser got focus back, start showing remote video media again.');
            applicationCall.resumeIncomingVideo();
        }
    });
});



cameraVideo(cameraVideo)

Description

Controls whether the local camera video should be enabled. For video calls it is enabled by default.

Arguments

  • cameraVideo: boolean - Whether local camera video should be enabled.

Returns

Example

let infobipRTC = createInfobipRtc('2e29c3a0-730a-4526-93ce-cda44556dab5', {debug: true});
let applicationCall = infobipRTC.callApplication('45g2gql9ay4a2blu55uk1628');
applicationCall.on(CallsApiEvent.ESTABLISHED, _ => {
    applicationCall.cameraVideo(true)
        .catch(error => console.log(`Error: ${error}`));
});



hasCameraVideo()

Description

Returns information whether the current call has local camera video.

Arguments

  • none

Returns

  • boolean - true if the call has local camera video, otherwise false.

Example

let infobipRTC = createInfobipRtc('2e29c3a0-730a-4526-93ce-cda44556dab5', {debug: true});
let applicationCallOptions = ApplicationCallOptions.builder().setVideo(true).build();
let applicationCall = infobipRTC.callApplication('45g2gql9ay4a2blu55uk1628', applicationCallOptions);
let callType = applicationCall.hasLocalVideo() ? 'video' : 'audio';
console.log(`Making ${callType} application call.`);



screenShare(screenShare)

Please note that this method has been deprecated. Instead, you should use the startScreenShare and stopScreenShare methods.

Description

Toggles sharing the screen during the call.

After one participant in the call starts sharing their screen, the screen-share-added event will be triggered on their side, and participant-screen-share-added event will be triggered for the other side. After one participant in the call stops sharing their screen, the screen-share-removed event will be triggered on their side, and participant-screen-share-removed event will be triggered for the other side.

This method is not available in mobile versions of browsers.

Arguments

  • screenShare: boolean - Controls whether the screen sharing should be started or stopped.

Returns

Example

let infobipRTC = createInfobipRtc('2e29c3a0-730a-4526-93ce-cda44556dab5', {debug: true});
let applicationCall = infobipRTC.callApplication('45g2gql9ay4a2blu55uk1628');
applicationCall.on(CallsApiEvent.ESTABLISHED, _ => {
    applicationCall.screenShare(true)
        .catch(error => console.log(`Error: ${error}`));
});
applicationCall.on(CallsApiEvent.SCREEN_SHARE_ADDED, _ => {
    console.log('Started sharing screen');
})



startScreenShare(displayOptions)

Description

Starts sharing the screen during the call and optionally controls the type of display surfaces which can be shared.

After one participant in the call starts sharing their screen, the screen-share-added event will be triggered on their side, and participant-screen-share-added event will be triggered for the other side.

This method is not available in mobile versions of browsers.

Note that the screenshare control through the DisplayOptions is not supported on all web browsers. Before attempting to use this feature, please consult the browser compatibility table.

Arguments

  • displayOptions: DisplayOptions - Optional argument which provides control over surfaces that can be shared during the call. If not provided, no restrictions on display surfaces that can be shared are set.

Returns

Example

let infobipRTC = createInfobipRtc('2e29c3a0-730a-4526-93ce-cda44556dab5', {debug: true});
let applicationCall = infobipRTC.callApplication('45g2gql9ay4a2blu55uk1628');
let displayOptions: DisplayOptions = {allowedDisplayOptions: ['window', 'monitor']}
applicationCall.on(CallsApiEvent.ESTABLISHED, _ => {
    applicationCall.startScreenShare(displayOptions)
        .catch(error => console.log(`Error: ${error}`));
});
applicationCall.on(CallsApiEvent.SCREEN_SHARE_ADDED, _ => {
    console.log('Started sharing screen');
})



stopScreenShare()

Description

Stops sharing the screen during the call.

After one participant in the call stops sharing their screen, the screen-share-removed event will be triggered on their side, and participant-screen-share-removed event will be triggered for the other side.

This method is not available in mobile versions of browsers.

Arguments

  • none

Returns

Example

let infobipRTC = createInfobipRtc('2e29c3a0-730a-4526-93ce-cda44556dab5', {debug: true});
let applicationCall = infobipRTC.callApplication('45g2gql9ay4a2blu55uk1628');
applicationCall.on(CallsApiEvent.SCREEN_SHARE_ADDED, _ => {
    applicationCall.stopScreenShare()
        .catch(error => console.log(`Error: ${error}`));
});
applicationCall.on(CallsApiEvent.SCREEN_SHARE_REMOVED, _ => {
    console.log('Stopped sharing screen');
})



hasScreenShare()

Description

Returns information whether screen is being shared with remote peer.

Arguments

  • none

Returns

  • boolean - true if the screen is being shared, otherwise false.

Example

let infobipRTC = createInfobipRtc('2e29c3a0-730a-4526-93ce-cda44556dab5', {debug: true});
let applicationCall = infobipRTC.callApplication('45g2gql9ay4a2blu55uk1628');
applicationCall.on(CallsApiEvent.ESTABLISHED, _ => {
    applicationCall.screenShare(true);
});
applicationCall.on(CallsApiEvent.SCREEN_SHARE_ADDED, _ => {
    if (applicationCall.hasScreenShare()) {
        console.log('Sharing screen...');
    }
})



setAudioInputDevice(deviceId)

Description

Sets the audio input device with the given id to be used during the call.

Arguments

  • deviceId: string - Audio input device identifier.

Returns

Example

let infobipRTC = createInfobipRtc('2e29c3a0-730a-4526-93ce-cda44556dab5', {debug: true});
let applicationCall = infobipRTC.callApplication('45g2gql9ay4a2blu55uk1628');
applicationCall.on(CallsApiEvent.ESTABLISHED, _ => {
    applicationCall.setAudioInputDevice('audioDeviceId')
        .catch(error => console.log(`Error: ${error}`));
});



setVideoInputDevice(deviceId)

Description

Sets the video input device with the given id to be used during the call.

Arguments

  • deviceId: string - Video input device identifier.

Returns

Example

let infobipRTC = createInfobipRtc('2e29c3a0-730a-4526-93ce-cda44556dab5', {debug: true});
let applicationCall = infobipRTC.callApplication('45g2gql9ay4a2blu55uk1628', ApplicationCallOptions.builder().setVideo(true).build());
applicationCall.on(CallsApiEvent.ESTABLISHED, _ => {
    applicationCall.setVideoInputDevice('videoDeviceId')
        .catch(error => console.log(`Error: ${error}`));
});



setAudioFilter(audioFilter)

Description

Sets the audio filter to be used during the call. Passing null will remove and release any already existing audio filter.

Arguments

  • audioFilter: AudioFilter - An object instance which implements the AudioFilter interface.

Returns

  • Promise<void> - Promise that resolves once the filter has been applied to the current audio stream.

Example

let infobipRTC = createInfobipRtc('2e29c3a0-730a-4526-93ce-cda44556dab5', {debug: true});
let applicationCall = infobipRTC.callApplication('45g2gql9ay4a2blu55uk1628');
let audioFilter = createAudioFilterImplementation();
applicationCall.setAudioFilter(audioFilter);



clearAudioFilter()

Description

Convenience method that is used to remove the audio filter if it is present.

Arguments

  • none

Returns

  • Promise<void> - Promise that resolves once the filter has been removed.

Example

let infobipRTC = createInfobipRtc('2e29c3a0-730a-4526-93ce-cda44556dab5', {debug: true});
let applicationCall = infobipRTC.callApplication('45g2gql9ay4a2blu55uk1628');
let audioFilter = createAudioFilterImplementation();
applicationCall.setAudioFilter(audioFilter);

applicationCall.clearAudioFilter();



setVideoFilter(videoFilter)

Description

Sets the video filter to be used during the video call. Passing null will remove and release any already existing video filter.

Arguments

  • videoFilter: VideoFilter - An object instance which implements the VideoFilter interface.

Returns

  • Promise<void> - Promise that resolves once the filter has been applied to the current video stream.

Example

let infobipRTC = createInfobipRtc('2e29c3a0-730a-4526-93ce-cda44556dab5', {debug: true});
let applicationCall = infobipRTC.callApplication('45g2gql9ay4a2blu55uk1628', ApplicationCallOptions.builder().setVideo(true).build());
let videoFilter = createVideoFilterImplementation();
applicationCall.setVideoFilter(videoFilter);



clearVideoFilter()

Description

Convenience method that is used to remove the video filter if it is present.

Arguments

  • none

Returns

  • Promise<void> - Promise that resolves once the filter has been removed.

Example

let infobipRTC = createInfobipRtc('2e29c3a0-730a-4526-93ce-cda44556dab5', {debug: true});
let applicationCall = infobipRTC.callApplication('45g2gql9ay4a2blu55uk1628', ApplicationCallOptions.builder().setVideo(true).build());
let videoFilter = createVideoFilterImplementation();
applicationCall.setVideoFilter(videoFilter);

applicationCall.clearVideoFilter();



localCapturer()

Description

Gets an instance of LocalCapturer, which can be used to take screenshots of participants' videos and download them directly to the machine.

Arguments

  • none

Returns

  • LocalCapturer - Returns an instance of a capturer used for storing screenshots locally.

Example

let infobipRTC = createInfobipRtc('2e29c3a0-730a-4526-93ce-cda44556dab5', {debug: true});
let applicationCall = infobipRTC.callApplication('45g2gql9ay4a2blu55uk1628', ApplicationCallOptions.builder().setVideo(true).build());
let identity = "capture_test_identity";
let videoType = VideoType.CAMERA;

// we take a screenshot of the participant's camera, and download it to the local machine as a `.png` file
applicationCall.localCapturer().takeScreenshot(identity, videoType)
    .then(url => {
        const link = document.createElement('a');
        link.download = `${identity}_${videoType.toString().toLowerCase()}.png`;
        link.href = url;
        link.click();
        link.remove();
    });



serverCapturer()

Description

Gets an instance of ServerCapturer, which is used to upload screenshots of participants' videos to the cloud. These screenshots can subsequently be retrieved using the WebRTC Files API.

Arguments

  • none

Returns

  • ServerCapturer - Returns an instance of a capturer used for uploading screenshots to the cloud.

Example

let infobipRTC = createInfobipRtc('2e29c3a0-730a-4526-93ce-cda44556dab5', {debug: true});
let applicationCall = infobipRTC.callApplication('45g2gql9ay4a2blu55uk1628', ApplicationCallOptions.builder().setVideo(true).build());
let identity = "capture_test_identity";
let videoType = VideoType.SCREENSHARE;

// we take a screenshot of the participant's screen share, which is directly uploaded to the server (cloud)
applicationCall.serverCapturer().takeScreenshot(identity, videoType)
    .then(fileResponse => {
        console.log(`Screenshot uploaded to the server with id: ${fileResponse.id}, and name: ${fileResponse.name}`);
    }).catch(err => {
    console.log('There was an error uploading a screenshot to the server!');
});



dataChannel()

Description

Gets an instance of DataChannel, that should be used to send and receive data during the current call.

Arguments

  • none

Returns

Example

let infobipRTC = createInfobipRtc('2e29c3a0-730a-4526-93ce-cda44556dab5', {debug: true});
let applicationCall = infobipRTC.callApplication('45g2gql9ay4a2blu55uk1628', ApplicationCallOptions.builder().setDataChannel(true).build());

applicationCall.dataChannel().send("Hello world!")
    .then(id => {
        console.log(`Sent text with id: ${id}.`)
    });



cameraOrientation()

Description

Returns current camera orientation.

Arguments

  • none

Returns

Example

let videoOptions = VideoOptions.builder().setCameraOrientation(CameraOrientation.BACK).build();
let applicationCallOptions = ApplicationCallOptions.builder().setVideo(true).setVideoOptions(videoOptions).build();
let applicationCall = infobipRTC.callApplication('45g2gql9ay4a2blu55uk1628', applicationCallOptions);
console.log(`Camera orientation is: ${applicationCall.cameraOrientation()}`);



setCameraOrientation(cameraOrientation)

Description

Sets a local camera orientation to the given enum value.

Arguments

Returns

Example

let applicationCall = infobipRTC.callApplication('45g2gql9ay4a2blu55uk1628', ApplicationCallOptions.builder().setVideo(true).build());
applicationCall.on(CallsApiEvent.ESTABLISHED, _ => {
    applicationCall.setCameraOrientation(CameraOrientation.BACK)
        .catch(error => console.log(`Error: ${error}`));
});



audioQualityMode(audioQualityMode)

Description

Sets the audio quality mode to a given enum value.

Arguments

Returns

  • N/A

Example

let applicationCall = infobipRTC.callApplication('45g2gql9ay4a2blu55uk1628', ApplicationCallOptions.builder().setVideo(true).build());
applicationCall.on(CallsApiEvent.ESTABLISHED, _ => {
    applicationCall.audioQualityMode(AudioQualityMode.LOW_DATA)
});



setReconnectHandler(reconnectHandler)

Description

Setter for the ReconnectHandler. This callback is required in order to enable reconnect functionality on the application call level (receive RECONNECTING and RECONNECTED events).

Arguments

Returns

  • N/A

Example

let infobipRTC = createInfobipRtc('2e29c3a0-730a-4526-93ce-cda44556dab5', {debug: true});
let applicationCall = infobipRTC.callApplication('45g2gql9ay4a2blu55uk1628');

applicationCall.setReconnectHandler((reconnectingCallId, reconnectingCallOptions) => {
    // Add any custom data that will help you handle the reconnect flow on your backend application
    reconnectingCallOptions.customData["reconnectingCallId"] = reconnectingCallId;

    // optionally turn off video
    reconnectingCallOptions.video = false

    return reconnectingCallOptions
})



hangup()

Description

Hangs up a call, which ends up in the party receiving a CallsApiEvent.HANGUP event, after the hangup is processed by Infobip's platform.

Arguments

  • none

Returns

  • N/A

Example

let infobipRTC = createInfobipRtc('2e29c3a0-730a-4526-93ce-cda44556dab5', {debug: true});
let applicationCall = infobipRTC.callApplication('45g2gql9ay4a2blu55uk1628');
applicationCall.on(CallsApiEvent.ESTABLISHED, _ => {
    applicationCall.hangup();
});



recordingState()

Description

Getter for the recordingState field.

Arguments

  • none

Returns

  • RecordingState - Value of the recordingState field that represents the recording state of the current call/dialog/conference and is updated each time the recording starts/stops.

Example

let infobipRTC = createInfobipRtc('2e29c3a0-730a-4526-93ce-cda44556dab5', {debug: true});
let applicationCall = infobipRTC.callApplication('45g2gql9ay4a2blu55uk1628');
console.log(`Recording state: ${applicationCall.recordingState()}`);



on(eventName, eventHandler)

Description

Configures the event handler for application call events.

Arguments

  • eventName: CallsApiEvent - Name of the application call event. Allowed values are shown in CallsApiEvent.

  • 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 - A MediaStream object representing the media being played is received in the event object.

      event = { stream: MediaStream }
    • ESTABLISHED - A MediaStream object representing the media in the call is received in the event object.

      event = { stream: MediaStream }
    • HANGUP - A received ErrorCode object provides details about the reason for the call hang-up, along with a TotalMediaStats object that offers a comprehensive summary of the call's audio statistics.

      event = { errorCode: ErrorCode, totalMediaStats: TotalMediaStats }
    • ERROR - A received ErrorCode object provides details about the reason for the error occurrence.

      event = { errorCode: ErrorCode }
    • CAMERA_VIDEO_ADDED - A MediaStream object representing the media in the call is received in the event object.

      event = { stream: MediaStream }
    • CAMERA_VIDEO_UPDATED - A MediaStream object representing the media in the call is received in the event object.

      event = { stream: MediaStream }
    • CAMERA_VIDEO_REMOVED - No additional data is provided in the event object.

      event = {}
    • SCREEN_SHARE_ADDED - A MediaStream object representing the media in the call is received in the event object.

      event = { stream: MediaStream }
    • SCREEN_SHARE_REMOVED - A VideoRemovalReason enum value giving additional info on the reason for removing the screen share.

      event = { reason: VideoRemovalReason }
    • CONFERENCE_JOINED - Data containing conference information is received in the event object. It contains conference id, name and array of Participant objects representing the participants that are already in the conference.

      event = { id: string, name: string, participants: Participant[] }
    • CONFERENCE_LEFT - A received ErrorCode object provides details about the reason for the participant leaving the conference.

      event = { errorCode: ErrorCode }
    • PARTICIPANT_JOINING - A Participant object representing the participant joining the conference.

      event = { participant: Participant }
    • PARTICIPANT_JOINED - A Participant object representing the participant that joined the conference.

      event = { participant: Participant }
    • PARTICIPANT_MUTED - A Participant object representing the participant that was muted.

      event = { participant: Participant }
    • PARTICIPANT_UNMUTED - A Participant object representing the participant that was unmuted.

      event = { participant: Participant }
    • PARTICIPANT_DEAF - A Participant object representing the participant that was deafened.

      event = { participant: Participant }
    • PARTICIPANT_UNDEAF - A Participant object representing the participant that was undeafened.

      event = { participant: Participant }
    • PARTICIPANT_STARTED_TALKING - A Participant object representing the participant that started talking.

      event = { participant: Participant }
    • PARTICIPANT_STOPPED_TALKING - A Participant object representing the participant that stopped talking.

      event = { participant: Participant }
    • PARTICIPANT_LEFT - A Participant object representing the participant that left the conference.

      event = { participant: Participant }
    • PARTICIPANT_CAMERA_VIDEO_ADDED - A Participant and MediaStream object representing the participant and their camera video stream.

      event = { participant: Participant, stream: MediaStream }
    • PARTICIPANT_CAMERA_VIDEO_REMOVED - A Participant object representing the participant that removed their camera video.

      event = { participant: Participant }
    • PARTICIPANT_SCREEN_SHARE_ADDED - A Participant and MediaStream object representing the participant and their screen share stream.

      event = { participant: Participant, stream: MediaStream }
    • PARTICIPANT_SCREEN_SHARE_REMOVED - A Participant object representing the participant that removed their screen share.

      event = { participant: Participant }
    • DIALOG_JOINED - Dialog information is received in the event object. It contains dialog id and a Participant object representing the remote participant of the dialog.

      event = { id: string, remote: Participant }
    • DIALOG_LEFT - A received ErrorCode object provides details about the reason for the participant leaving the dialog.

      event = { errorCode: ErrorCode }
    • RECONNECTING - No additional data is provided in the event object.

      event = {}
    • RECONNECTED - A MediaStream object representing the media in the call is received in the event object.

      event = { stream: MediaStream }
    • 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 }
    • PARTICIPANT_NETWORK_QUALITY_CHANGED - An event containing a NetworkQuality and a Participant objects provides details on the network quality specifically for a given participant.

      event = { participant: Participant, networkQuality: NetworkQuality }
    • 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 }
    • CALL_RECORDING_STOPPED - An event that is triggered once a call recording stops.

      event = { }
    • CONFERENCE_RECORDING_STARTED - An event that is triggered once a conference recording starts. It includes RecordingType object which details the type of recording initiated.

      event = { recordingType: RecordingType }
    • CONFERENCE_RECORDING_STOPPED - An event that is triggered once a conference recording stops.

      event = { }
    • DIALOG_RECORDING_STARTED - An event that is triggered once a dialog recording starts. It includes RecordingType object which details the type of recording initiated.

      event = { recordingType: RecordingType }
    • DIALOG_RECORDING_STOPPED - An event that is triggered once a dialog recording stops.

      event = { }

Returns

  • N/A

Example

Let's assume you have an audio HTML element with the id callAudio and video HTML elements with the ids localVideo and remoteVideo.

let infobipRTC = createInfobipRtc('2e29c3a0-730a-4526-93ce-cda44556dab5', {debug: true});
let applicationCall = infobipRTC.callApplication('45g2gql9ay4a2blu55uk1628');

applicationCall.on(CallsApiEvent.RINGING, () => {
    console.log('Ringing...');
});

applicationCall.on(CallsApiEvent.EARLY_MEDIA, (event) => {
    console.log('Ringtone playing...');
    $('#callAudio').srcObject = event.stream;
});

applicationCall.on(CallsApiEvent.ESTABLISHED, (event) => {
    $('#callAudio').srcObject = event.stream;
});

applicationCall.on(CallsApiEvent.CAMERA_VIDEO_ADDED, (event) => {
    $('#localVideo').srcObject = event.stream;
});

applicationCall.on(CallsApiEvent.PARTICIPANT_CAMERA_VIDEO_ADDED, (event) => {
    console.log(`Participant: ${event.participant.endpoint.identifier} turned on their camera`);
    $('#remoteVideo').srcObject = event.stream;
});

applicationCall.on(CallsApiEvent.PARTICIPANT_MUTED, (event) => {
    console.log(`Participant: ${event.participant.endpoint.identifier} is muted`);
});

applicationCall.on(CallsApiEvent.PARTICIPANT_UNMUTED, (event) => _ => {
    console.log(`Participant: ${event.participant.endpoint.identifier} is unmuted`);
});

applicationCall.on(CallsApiEvent.HANGUP, (event) => {
    console.log(`Call finished. Status: ${event.errorCode.name}`);
});

applicationCall.on(CallsApiEvent.ERROR, (event) => {
    console.log(`An error has occurred. Error: ${event.errorCode.name}`);
});

// make sure to set reconnect handler callback. This is required in order 
// to receive RECONNECTING and RECONNECTED events.
applicationCall.on(CallsApiEvent.RECONNECTING, function (event) {
    console.log('Call is being reconnected, hang tight!');
})

applicationCall.on(CallsApiEvent.RECONNECTED, function (event) {
    $('#remoteAudio').srcObject = event.stream;
    console.log(`You have successfully reconnected the call!`);
});

applicationCall.on(CallsApiEvent.NETWORK_QUALITY_CHANGED, (event) => {
    console.log(`Local network quality is: ${NetworkQuality[event.networkQuality]}`);
});

applicationCall.on(CallsApiEvent.PARTICIPANT_NETWORK_QUALITY_CHANGED, (event) => {
    console.log(`Network quality of ${event.participant.endpoint.identifier} is: ${NetworkQuality[event.networkQuality]}`);
});

applicationCall.on(CallsApiEvent.CALL_RECORDING_STARTED, (event) => {
    console.log(`Call recording started with type ${event.recordingType}`);
});

applicationCall.on(CallsApiEvent.CALL_RECORDING_STOPPED, (event) => {
    console.log(`Call recording stopped`);
});

applicationCall.on(CallsApiEvent.CONFERENCE_RECORDING_STARTED, (event) => {
    console.log(`Conference recording started with type ${event.recordingType}`);
});

applicationCall.on(CallsApiEvent.CONFERENCE_RECORDING_STOPPED, (event) => {
    console.log(`Conference recording stopped`);
});

applicationCall.on(CallsApiEvent.DIALOG_RECORDING_STARTED, (event) => {
    console.log(`Dialog recording started with type ${event.recordingType}`);
});

applicationCall.on(CallsApiEvent.DIALOG_RECORDING_STOPPED, (event) => {
    console.log(`Dialog recording stopped`);
});

Tutorials

Migration guides

Reference documentation

Clone this wiki locally