-
Notifications
You must be signed in to change notification settings - Fork 0
WebrtcCall
extends
Call
options(): WebrtcCallOptions
customData(): CustomData
pauseIncomingVideo(): void
resumeIncomingVideo(): void
cameraVideo(cameraVideo: boolean): Promise<void>
hasCameraVideo(): boolean
hasRemoteCameraVideo(): boolean
screenShare(screenShare: boolean): Promise<void>
hasScreenShare(): boolean
hasRemoteScreenShare(): boolean
setVideoInputDevice(deviceId: string): Promise<void>
cameraOrientation(): CameraOrientation
setCameraOrientation(cameraOrientation: CameraOrientation): Promise<void>
setVideoFilter(videoFilter: VideoFilter): Promise<void>
videoFilter(): VideoFilter
on(event: CallsApiEvent, eventHandler: CallsEventHandlers): void
Returns the call options this call was started with.
none
-
WebrtcCallOptions
- Call options the call was started with.
Getter for the customData
field.
none
-
CustomData
- Value of thecustomData
field that is defined as an object of key-value string pairs.
let webrtcCallOptions = WebrtcCallOptions.builder().setCustomData({"city": "New York"}).build();
console.log(`WebRTC call with customData options: ${JSON.stringify(webrtcCallOptions.customData)}`);
Stop receiving the video media of the remote participant.
none
N/A
let infobipRTC = createInfobipRtc('2e29c3a0-730a-4526-93ce-cda44556dab5', {debug: true});
let webrtcCall = infobipRTC.callWebrtc('alice');
webrtcCall.on(CallsApiEvent.ESTABLISHED, _ => {
document.addEventListener("visibilitychange", () => {
if (document.visibilityState !== 'visible') {
console.log('Browser lost focus, stop showing remote video media.');
webrtcCall.pauseIncomingVideo();
}
});
});
Start receiving the video media of the remote participant.
none
N/A
let infobipRTC = createInfobipRtc('2e29c3a0-730a-4526-93ce-cda44556dab5', {debug: true});
let webrtcCall = infobipRTC.callWebrtc('alice');
webrtcCall.on(CallsApiEvent.ESTABLISHED, _ => {
document.addEventListener("visibilitychange", () => {
if (document.visibilityState === 'visible') {
console.log('Browser got focus back, start showing remote video media again.');
webrtcCall.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 webrtcCall = infobipRTC.callWebrtc('alice');
webrtcCall.on(CallsApiEvent.ESTABLISHED, _ => {
webrtcCall.cameraVideo(true)
.catch(error => console.log("Error: {}", error));
});
Returns information whether the current call has local camera video.
none
-
boolean
-true
if the call has local camera video, otherwisefalse
.
let infobipRTC = createInfobipRtc('2e29c3a0-730a-4526-93ce-cda44556dab5', {debug: true});
let webrtcCallOptions = WebrtcCallOptions.builder().setVideo(true).build();
let webrtcCall = infobipRTC.callWebrtc('alice', webrtcCallOptions);
let callType = webrtcCall.hasCameraVideo() ? 'video' : 'audio';
console.log(`Making ${callType} WebRTC call.`);
Returns information whether the current call has remote video.
none
-
boolean
-true
if the call has remote video, otherwisefalse
.
let infobipRTC = createInfobipRtc('2e29c3a0-730a-4526-93ce-cda44556dab5', {debug: true});
let webrtcCall = infobipRTC.callWebrtc('alice');
webrtcCall.on(CallsApiEvent.ESTABLISHED, _ => {
let remoteVideo = webrtcCall.hasRemoteCameraVideo() ? 'has camera video' : 'doesn\'t have camera video';
console.log(`Remote user ${remoteVideo}.`);
});
Toggles sharing the screen during the call.
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 webrtcCall = infobipRTC.callWebrtc('alice');
webrtcCall.on('established', _ => {
webrtcCall.screenShare(true)
.catch(error => console.log("Error: {}", error));
});
webrtcCall.on('screen-share-added', _ => {
console.log('Started sharing screen');
})
Returns information whether screen is being shared with remote peer.
none
-
boolean
-true
if screen is being shared, otherwisefalse
.
let infobipRTC = createInfobipRtc('2e29c3a0-730a-4526-93ce-cda44556dab5', {debug: true});
let webrtcCall = infobipRTC.callWebrtc('alice');
webrtcCall.on('established', _ => {
webrtcCall.screenShare(true);
});
webrtcCall.on('screen-share-added', _ => {
if (webrtcCall.hasScreenShare()) {
console.log('Sharing screen...');
}
})
Returns information whether the remote user is sharing their screen.
none
-
boolean
-true
if screen is being shared, otherwisefalse
.
let infobipRTC = createInfobipRtc('2e29c3a0-730a-4526-93ce-cda44556dab5', {debug: true});
let webrtcCall = infobipRTC.callWebrtc('alice');
webrtcCall.on('remote-screen-share-added', _ => {
if (webrtcCall.hasRemoteScreenShare()) {
console.log('Remote user sharing screen...');
}
})
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 webrtcCall = infobipRTC.callWebrtc('alice', WebrtcCallOptions.Builder.setVideo(true).build());
webrtcCall.on('established', _ => {
webrtcCall.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 webrtcCallOptions = WebrtcCallOptions.builder().setVideo(true).setVideoOptions(videoOptions).build();
let webrtcCall = infobipRTC.callWebrtc('alice', webrtcCallOptions);
console.log(`Camera orientation is: ${webrtcCall.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 webrtcCall = infobipRTC.callWebrtc('alice', WebrtcCallOptions.builder().setVideo(true).build());
webrtcCall.on('established', _ => {
webrtcCall.setCameraOrientation(CameraOrientation.BACK)
.catch(error => console.log("Error: {}", error));
});
Sets the video filter to be used during the video call.
Passing null
will remove and release any already existing video filter.
-
videoFilter
:VideoFilter
- An object instance which implements theVideoFilter
interface.
-
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 webrtcCall = infobipRTC.callWebrtc('alice', WebrtcCallOptions.builder().setVideo(true).build());
let videoFilter = createVideoFilterImplementation();
webrtcCall.setVideoFilter(videoFilter);
Gets the video filter that has been set for the video call.
none
-
VideoFilter
- An object instance which implements theVideoFilter
interface.
let infobipRTC = createInfobipRtc('2e29c3a0-730a-4526-93ce-cda44556dab5', {debug: true});
let webrtcCall = infobipRTC.callWebrtc('alice', WebrtcCallOptions.builder().setVideo(true).build());
let videoFilter = createVideoFilterImplementation();
webrtcCall.setVideoFilter(videoFilter);
let currentVideoFilter = webrtcCall.videoFilter();
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
- Error code data is received in the event object containing threestring
values 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 threestring
values that describe what caused the error.event = {id: string, name: string, description: string}
-
CAMERA_VIDEO_ADDED
- AMediaStream
object representing the media in the call is received in the event object.event = {stream: MediaStream}
-
CAMERA_VIDEO_UPDATED
- AMediaStream
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
- AMediaStream
object 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 = {}
-
REMOTE_MUTED
- No additional data is provided in the event object.event = {}
-
REMOTE_UNMUTED
- No additional data is provided in the event object.event = {}
-
REMOTE_CAMERA_VIDEO_ADDED
- AMediaStream
object representing the remote user's camera video stream.event = {stream: MediaStream}
-
REMOTE_CAMERA_VIDEO_REMOVED
- No additional data is provided in the event object.event = {}
-
REMOTE_SCREEN_SHARE_ADDED
- AMediaStream
object representing the remote user's screen share stream.event = {stream: MediaStream}
-
REMOTE_SCREEN_SHARE_REMOVED
- 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
and video HTML elements with the ids cameraVideo
, remoteCameraVideo
,
screenShareVideo
, and remoteScreenShareVideo
.
let infobipRTC = createInfobipRtc('2e29c3a0-730a-4526-93ce-cda44556dab5', {debug: true});
let webrtcCall = infobipRTC.callWebrtc('alice');
webrtcCall.on(CallsApiEvent.RINGING, () => {
console.log('Ringing...');
});
webrtcCall.on(CallsApiEvent.EARLY_MEDIA, (event) => {
console.log('Ringtone playing...');
$('#callAudio').srcObject = event.stream;
});
webrtcCall.on(CallsApiEvent.ESTABLISHED, (event) => {
$('#callAudio').srcObject = event.stream;
});
webrtcCall.on(CallsApiEvent.HANGUP, (event) => {
console.log(`Call finished. Status: ${event.name}`);
});
webrtcCall.on(CallsApiEvent.ERROR, (event) => {
console.log(`An error has occurred. Error: ${event.name}`);
});
webrtcCall.on(CallsApiEvent.CAMERA_VIDEO_ADDED, (event) => {
$('#cameraVideo').srcObject = event.stream;
});
webrtcCall.on(CallsApiEvent.REMOTE_CAMERA_VIDEO_ADDED, (event) => {
$('#remoteCameraVideo').srcObject = event.stream;
});
webrtcCall.on(CallsApiEvent.SCREEN_SHARE_ADDED, (event) => {
$('#screenShareVideo').srcObject = event.stream;
});
webrtcCall.on(CallsApiEvent.REMOTE_SCREEN_SHARE_ADDED, (event) => {
$('#remoteScreenShareVideo').srcObject = event.stream;
});
webrtcCall.on(CallsApiEvent.REMOTE_MUTED, (event) => {
console.log(`Remote user is muted`);
});
webrtcCall.on(CallsApiEvent.REMOTE_UNMUTED, (event) => _ => {
console.log(`Remote user is unmuted`);
});