-
Notifications
You must be signed in to change notification settings - Fork 2
ApplicationCall
id(): Stringon(applicationCallApiEvent: CallsApiEvent, eventHandler: CallsEventHandlers): voidstatus(): CallStatusduration(): numberstartTime(): DateestablishTime(): DateendTime(): DateapplicationId(): Stringmute(shouldMute: boolean): Promise<void>muted(): booleansendDTMF(dtmf: String): Promise<void>pauseIncomingVideo(): void;resumeIncomingVideo(): void;cameraVideo(cameraVideo: boolean): Promise<void>hasCameraVideo(): booleanscreenShare(screenShare: boolean): Promise<void>hasScreenShare(): booleansetAudioInputDevice(deviceId: String): Promise<void>setVideoInputDevice(deviceId: String: Promise<void>)setAudioFilter(audioFilter: AudioFilter): Promise<void>setVideoFilter(videoFilter: VideoFilter): Promise<void>cameraOrientation(): CameraOrientationsetCameraOrientation(cameraOrientation: CameraOrientation): Promise<void>hangup(): void
Returns a unique call identifier.
none
-
string- Call ID.
let infobipRTC = createInfobipRtc('2e29c3a0-730a-4526-93ce-cda44556dab5', {debug: true});
let applicationCall = infobipRTC.callApplication('45g2gql9ay4a2blu55uk1628');
console.log(`Call ID: ${applicationCall.id()}`);Configures the event handler for application call events.
-
eventName:CallsApiEvent- Name of the application call event. Allowed values are shown inCallsApiEvent. -
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- Error code data is received in the event object containing threestringvalues that describe why the call hung up.event = {id: string, name: string, description: string}
-
ERROR- Error code data is received in the event object containing threestringvalues that describe what caused the error.event = {id: string, name: string, description: string}
-
CAMERA_VIDEO_ADDED- AMediaStreamobject representing the media in the call is received in the event object.event = {stream: MediaStream}
-
CAMERA_VIDEO_UPDATED- AMediaStreamobject 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- AMediaStreamobject representing the media in the call is received in the event object.event = {stream: MediaStream}
-
SCREEN_SHARE_REMOVED- No additional data is provided in the event object.event = {}
-
CONFERENCE_JOINED- Data containing conference information is received in the event object. It contains conference id, name and array ofParticipantobjects representing the participants that are already in the conference.event = {id: string, name: string, participants: Participant[]}
-
CONFERENCE_LEFT- Error code data is received in the event object containing threestringvalues that describe why the participant left the conference.event = {id: string, name: string, description: string}
-
PARTICIPANT_JOINING- AParticipantobject representing the participant joining the conference.event = {participant: Participant}
-
PARTICIPANT_JOINED- AParticipantobject representing the participant that joined the conference.event = {participant: Participant}
-
PARTICIPANT_MUTED- AParticipantobject representing the participant that was muted.event = {participant: Participant}
-
PARTICIPANT_UNMUTED- AParticipantobject representing the participant that was unmuted.event = {participant: Participant}
-
PARTICIPANT_DEAF- AParticipantobject representing the participant that was deafened.event = {participant: Participant}
-
PARTICIPANT_UNDEAF- AParticipantobject representing the participant that was undeafened.event = {participant: Participant}
-
PARTICIPANT_STARTED_TALKING- AParticipantobject representing the participant that started talking.event = {participant: Participant}
-
PARTICIPANT_STOPPED_TALKING- AParticipantobject representing the participant that stopped talking.event = {participant: Participant}
-
PARTICIPANT_LEFT- AParticipantobject representing the participant that left the conference.event = {participant: Participant}
-
PARTICIPANT_CAMERA_VIDEO_ADDED- AParticipantandMediaStreamobject representing the participant and their camera video stream.event = {participant: Participant, stream: MediaStream}
-
PARTICIPANT_CAMERA_VIDEO_REMOVED- AParticipantobject representing the participant that removed their camera video.event = {participant: Participant}
-
PARTICIPANT_SCREEN_SHARE_ADDED- AParticipantandMediaStreamobject representing the participant and their screen share stream.event = {participant: Participant, stream: MediaStream}
-
PARTICIPANT_SCREEN_SHARE_REMOVED- AParticipantobject representing the participant that removed their screen share.event = {participant: Participant}
-
N/A
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.name}`);
});
applicationCall.on(CallsApiEvent.ERROR, (event) => {
console.log(`An error has occurred. Error: ${event.name}`);
});Returns current call status.
none
-
CallStatus- Call status.
let infobipRTC = createInfobipRtc('2e29c3a0-730a-4526-93ce-cda44556dab5', {debug: true});
let applicationCall = infobipRTC.callApplication('45g2gql9ay4a2blu55uk1628');
console.log(`Call status: ${applicationCall.status()}`);Returns call duration in seconds calculated from the time call was established. Initially, duration is 0.
N/A
-
number- Call duration in seconds.
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 = ('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 = createInfobipRtc('2e29c3a0-730a-4526-93ce-cda44556dab5', {debug: true});
let applicationCall = infobipRTC.callApplication('45g2gql9ay4a2blu55uk1628');
console.log(`Start time: ${applicationCall.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 applicationCall = infobipRTC.callApplication('45g2gql9ay4a2blu55uk1628');
applicationCall.on(CallsApiEvent.ESTABLISHED, _ => {
console.log(`Establish time: ${applicationCall.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 applicationCall = infobipRTC.callApplication('45g2gql9ay4a2blu55uk1628');
applicationCall.on(CallsApiEvent.ESTABLISHED, _ => {
applicationCall.hangup();
});
applicationCall.on(CallsApiEvent.HANGUP, _ => {
console.log(`End time: ${applicationCall.endTime()}`);
});Returns a unique application identifier associated with your backend application.
none
-
string- Application ID.
let infobipRTC = createInfobipRtc('2e29c3a0-730a-4526-93ce-cda44556dab5', {debug: true});
let applicationCall = infobipRTC.callApplication('45g2gql9ay4a2blu55uk1628');
console.log(`Application ID: ${applicationCall.applicationId()}`);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 applicationCall = infobipRTC.callApplication('45g2gql9ay4a2blu55uk1628');
applicationCall.on(CallsApiEvent.ESTABLISHED, _ => {
applicationCall.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 applicationCall = infobipRTC.callApplication('45g2gql9ay4a2blu55uk1628');
applicationCall.on(CallsApiEvent.ESTABLISHED, _ => {
applicationCall.mute(true);
let muted = applicationCall.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:
0to9 - letters:
AtoD - symbols:
*and#
- digits:
-
Promise<void>- Promise that resolves tovoid.
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));
});Stop receiving the video media of other participants.
none
N/A
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();
}
});
});Start receiving the video media of other participants.
none
N/A
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();
}
});
});Controls whether the local camera video should be enabled. For video calls it is enabled by default.
-
cameraVideo:boolean- Whether local camera video should be enabled.
-
Promise<void>- Promise that resolves tovoid.
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));
});Returns information whether the current call has local camera video.
none
-
boolean-trueif the call has local camera video, otherwisefalse.
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.`);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 = 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');
})Returns information whether screen is being shared with remote peer.
none
-
boolean-trueif the screen is being shared, otherwisefalse.
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...');
}
})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 applicationCall = infobipRTC.callApplication('45g2gql9ay4a2blu55uk1628');
applicationCall.on(CallsApiEvent.ESTABLISHED, _ => {
applicationCall.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 = 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));
});Sets the audio filter to be used during the call.
-
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 applicationCall = infobipRTC.callApplication('45g2gql9ay4a2blu55uk1628');
let audioFilter = createAudioFilterImplementation();
applicationCall.setAudioFilter(audioFilter);Sets the video filter to be used during the video call.
-
videoFilter:VideoFilter- An object instance which implements theVideoFilterinterface.
-
Promise<void>- Promise that resolves once the filter has been applied to the current video stream.
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);Returns current camera orientation.
none
-
CameraOrientation- Enum value which corresponds to the camera orientation.
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()}`);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 applicationCall = infobipRTC.callApplication('45g2gql9ay4a2blu55uk1628', ApplicationCallOptions.builder().setVideo(true).build());
applicationCall.on(CallsApiEvent.ESTABLISHED, _ => {
applicationCall.setCameraOrientation(CameraOrientation.BACK)
.catch(error => console.log("Error: {}", error));
});Hangs up a call, which ends up in the party receiving
a CallsApiEvent.HANGUP event, after the hangup is processed by
Infobip's platform.
none
N/A
let infobipRTC = createInfobipRtc('2e29c3a0-730a-4526-93ce-cda44556dab5', {debug: true});
let applicationCall = infobipRTC.callApplication('45g2gql9ay4a2blu55uk1628');
applicationCall.on(CallsApiEvent.ESTABLISHED, _ => {
applicationCall.hangup();
});