Skip to content

ApplicationCall

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



id()

Description

Returns a unique call identifier.

Arguments

  • none

Returns

Example

InfobipRTC infobipRTC = InfobipRTC.getInstance();
ApplicationCall applicationCall = infobipRTC.getActiveApplicationCall();
Toast.makeText(getApplicationContext(), "Call ID: " + applicationCall.id(), Toast.LENGTH_LONG);



options()

Description

Returns call options used to construct an application call.

Arguments

  • none

Returns

Example

InfobipRTC infobipRTC = InfobipRTC.getInstance();
ApplicationCall applicationCall = infobipRTC.getActiveApplicationCall();
Toast.makeText(getApplicationContext(), "Call options: " + applicationCall.options(), Toast.LENGTH_LONG);



customData()

Description

Getter for the customData field

Arguments

  • none

Returns

Example

InfobipRTC infobipRTC = InfobipRTC.getInstance();
ApplicationCall applicationCall = infobipRTC.getActiveApplicationCall();
Toast.makeText(getApplicationContext(), "Custom data: " + applicationCall.customData(), Toast.LENGTH_LONG);



status()

Description

Returns current call status.

Arguments

  • none

Returns

Example

InfobipRTC infobipRTC = InfobipRTC.getInstance();
ApplicationCall applicationCall = infobipRTC.getActiveApplicationCall();
Toast.makeText(getApplicationContext(), "Call status: " + applicationCal.status(), Toast.LENGTH_LONG);



duration()

Description

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

Arguments

  • none

Returns

  • int - Call duration

Example

InfobipRTC infobipRTC = InfobipRTC.getInstance();
ApplicationCall applicationCall = infobipRTC.getActiveApplicationCall();
applicationCall.setEventListener(new DefaultApplicationCallEventListener() {
    @Override
    public void onHangup(CallHangupEvent callHangupEvent) {
        int durationInSeconds = applicationCall.duration();
        int seconds = durationInSeconds % 60;
        long minutes = durationInSeconds / 60 % 60;
        long hours = durationInSeconds / 3600;
        String duration = String.format(Locale.getDefault(), "%02d:%02d:%02d", hours, minutes, seconds);
        Toast.makeText(getApplicationContext(), "Duration: " + duration, Toast.LENGTH_LONG);
    }
});



startTime()

Description

Returns the time when the call started (but was not yet established).

Arguments

  • none

Returns

  • Date - Time when the call was initiated

Example

InfobipRTC infobipRTC = InfobipRTC.getInstance();
ApplicationCall applicationCall = infobipRTC.getActiveApplicationCall();
Toast.makeText(getApplicationContext(), "Start time: " + applicationCal.startTime(), Toast.LENGTH_LONG).show();



establishTime()

Description

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

Arguments

  • none

Returns

  • Date - Time when the call was established

Example

InfobipRTC infobipRTC = InfobipRTC.getInstance();
ApplicationCall applicationCall = infobipRTC.getActiveApplicationCall();
applicationCall.setEventListener(new DefaultApplicationCallEventListener() {
    @Override
    public void onEstablished(CallEstablishedEvent callEstablishedEvent) {
        Toast.makeText(getApplicationContext(), "Establish time: " + applicationCall.establishTime(), Toast.LENGTH_LONG);
    }
});



endTime()

Description

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

Arguments

  • none

Returns

  • Date - Time when the call finished

Example

InfobipRTC infobipRTC = InfobipRTC.getInstance();
ApplicationCall applicationCall = infobipRTC.getActiveApplicationCall();
applicationCall.setEventListener(new DefaultApplicationCallEventListener() {
    @Override
    public void onHangup(CallHangupEvent callHangupEvent) {
        Toast.makeText(getApplicationContext(), "End time: " + applicationCall.endTime(), Toast.LENGTH_LONG);
    }
});
applicationCall.hangup();



callsConfigurationId()

Description

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

Arguments

  • none

Returns

String - Represents the Calls Configuration ID which is configured using the Calls Configuration API.

Example

InfobipRTC infobipRTC = InfobipRTC.getInstance();
ApplicationCall applicationCall = infobipRTC.getActiveApplicationCall();
Toast.makeText(getApplicationContext(), "Calls Configuration ID: " + applicatioCall.callsConfigurationId(), Toast.LENGTH_LONG);



participants()

Description

Returns the list of participants currently connected with this application call.

Arguments

  • none

Returns

Example

InfobipRTC infobipRTC = InfobipRTC.getInstance();
ApplicationCall applicationCall = infobipRTC.getActiveApplicationCall();
for (Participant participant : applicationCall.participants()) {
    Log.d("WebRTC", String.format("Participant name: %s", participant.endpoint.displayIdentifier()));
}



remoteVideos()

Description

Returns a list of participant's camera videos and screen shares.

Arguments

  • none

Returns

  • Map<String, RemoteVideo> - List of participant's camera videos and screen shares. Can be accessed by participant identifier.



mute(shouldMute)

Description

Toggles mute option.

Arguments

  • shouldMute: boolean - Whether call should be muted after action or not.

Returns

  • N/A

Throws

Example

InfobipRTC infobipRTC = InfobipRTC.getInstance();
ApplicationCall applicationCall = infobipRTC.getActiveApplicationCall();
applicationCall.mute(true);



muted()

Description

Returns information whether audio is muted or not.

Arguments

  • none

Returns

Example

InfobipRTC infobipRTC = InfobipRTC.getInstance();
ApplicationCall applicationCall = infobipRTC.getActiveApplicationCall();
String muted = applicationCall.muted() ? "muted" : "not muted";
Toast.makeText(getApplicationContext(), "Audio is " + muted, Toast.LENGTH_LONG);



speakerphone(enabled)

Description

Controls whether the audio should be played on the speakerphone. Disabled by default. If disabled, the audio will be played through the next available audio device based on the priority order.

Arguments

  • enabled: boolean - Whether sound should be played on the speakerphone or not.

Returns

  • N/A

Example

InfobipRTC infobipRTC = InfobipRTC.getInstance();
ApplicationCall applicationCall = infobipRTC.getActiveApplicationCall();
applicationCall.speakerphone(true);



speakerphone()

Description

Returns information whether speakerphone is enabled or not.

Arguments

  • none

Returns

Example

InfobipRTC infobipRTC = InfobipRTC.getInstance();
ApplicationCall applicationCall = infobipRTC.getActiveApplicationCall();
String speakerphoneOn = applicationCall.speakerphone() ? "on" : "off";
Toast.makeText(getApplicationContext(), "Speakerphone is " + speakerphoneOn, Toast.LENGTH_LONG);



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

  • N/A

Throws

Example

InfobipRTC infobipRTC = InfobipRTC.getInstance();
ApplicationCall applicationCall = infobipRTC.getActiveApplicationCall();
applicationCall.sendDTMF("1");



cameraVideo(cameraVideo)

Description

Toggles whether camera video should be enabled or not. For video calls it is enabled by default.

Arguments

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

Returns

  • N/A

Throws

Example

InfobipRTC infobipRTC = InfobipRTC.getInstance();
ApplicationCall applicationCall = infobipRTC.getActiveApplicationCall();
applicationCall.cameraVideo(true);



hasCameraVideo()

Description

Returns information whether the current application call has camera video or not.

Arguments

  • none

Returns

  • boolean - Represents whether the application call has camera video. true if it does, otherwise false.

Example

InfobipRTC infobipRTC = InfobipRTC.getInstance();
ApplicationCall applicationCall = infobipRTC.getActiveApplicationCall();
String hasCameraVideo = applicationCall.hasCameraVideo() ? "has" : "doesn't have";
Toast.makeText(getApplicationContext(), "Call " + hasCameraVideo + " camera video", Toast.LENGTH_LONG);



startScreenShare(screenCapturer)

Description

Starts sharing screen with the remote peer. Needs to be called after CallEstablishedEvent is received.

Arguments

Returns

  • N/A

Throws

Example

public class Foo extends AppCompatActivity {
    @Override
    public void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        if (requestCode != 1) {
            return;
        }

        ScreenCapturer screenCapturer = new ScreenCapturer(resultCode, data);
        InfobipRTC infobipRTC = InfobipRTC.getInstance();
        ApplicationCall applicationCall = infobipRTC.getActiveApplicationCall();
        applicationCall.startScreenShare(screenCapturer);
    }

    public void startScreenShare() {
        MediaProjectionManager mediaProjectionManager = (MediaProjectionManager) getApplication().getSystemService(Context.MEDIA_PROJECTION_SERVICE);
        startActivityForResult(mediaProjectionManager.createScreenCaptureIntent(), 1);
    }
}



stopScreenShare()

Description

Stops sharing screen with the remote peer.

Arguments

  • none

Returns

  • N/A

Throws

Example

InfobipRTC infobipRTC = InfobipRTC.getInstance();
ApplicationCall applicationCall = infobipRTC.getActiveApplicationCall();
applicationCall.stopScreenShare();



hasScreenShare()

Description

Returns true if screen is being shared, otherwise else false.

Arguments

  • none

Returns

  • boolean - Whether screen is being shared or not

Example

InfobipRTC infobipRTC = InfobipRTC.getInstance();
ApplicationCall applicationCall = infobipRTC.getActiveApplicationCall();
Log.d("WebRTC", String.format("Application call %s is sharing screen: %s", applicationCall.id(), applicationCall.hasScreenShare()));



localCameraTrack()

Description

Returns video track for local camera video.

Arguments

  • none

Returns

Example

InfobipRTC infobipRTC = InfobipRTC.getInstance();
ApplicationCall applicationCall = infobipRTC.getActiveApplicationCall();
RTCVideoTrack localCamera = applicationCall.localCameraTrack();
if (localCamera != null) {
    localCamera.addSink(localVideoRenderer);
}



localScreenShareTrack()

Description

Returns video track for local screen share.

Arguments

  • none

Returns

Example

InfobipRTC infobipRTC = InfobipRTC.getInstance();
ApplicationCall applicationCall = infobipRTC.getActiveApplicationCall();
RTCVideoTrack localScreenShare = applicationCall.localScreenShareTrack();
if (localScreenShare != null) {
    localScreenShare.addSink(localVideoRenderer);
}



setEventListener(applicationCallEventListener)

Description

Configures event handler for application call events.

Arguments

  • applicationCallEventListener: ApplicationCallEventListener - Interface with event methods that should be implemented, method per application call event to be handled.

Returns

  • N/A

Example

InfobipRTC infobipRTC = InfobipRTC.getInstance();
ApplicationCall applicationCall = infobipRTC.getActiveApplicationCall();
applicationCall.setEventListener(new DefaultApplicationCallEventListener() {
    @Override
    public void onRinging(CallRingingEvent callRingingEvent) {
        Toast.makeText(getApplicationContext(), "Ringing!", Toast.LENGTH_LONG);
    }
    
    @Override
    public void onEstablished(CallEstablishedEvent callEstablishedEvent) {
        Toast.makeText(getApplicationContext(), "Established!", Toast.LENGTH_LONG);
    }
    
    @Override
    public void onHangup(CallHangupEvent callHangupEvent) {
        Toast.makeText(getApplicationContext(), "Hangup!", Toast.LENGTH_LONG);
    }
    
    @Override
    public void onError(ErrorEvent errorEvent) {
        Toast.makeText(getApplicationContext(), "Error!", Toast.LENGTH_LONG);
    }
});



getEventListener()

Description

Returns event handler for application call events.

Arguments

  • none

Returns

Example

InfobipRTC infobipRTC = InfobipRTC.getInstance();
ApplicationCall applicationCall = infobipRTC.getActiveApplicationCall();
ApplicationCallEventListener applicationCallEventListener = applicationall.getEventListener();



cameraOrientation(cameraOrientation)

Description

Change local camera orientation.

Arguments

Returns

  • N/A

Example

InfobipRTC infobipRTC = InfobipRTC.getInstance();
ApplicationCall applicationCall = infobipRTC.getActiveApplicationCall();
applicationCall.cameraOrientation(VideoOptions.CameraOrientation.BACK);



cameraOrientation()

Description

Get current camera orientation.

Arguments

  • none

Returns

Example

InfobipRTC infobipRTC = InfobipRTC.getInstance();
ApplicationCall applicationCall = infobipRTC.getActiveApplicationCall();
String cameraOrientation = applicationCall.cameraOrientation().name();
Toast.makeText(getApplicationContext(),"Camera orientation is " + cameraOrientation, Toast.LENGTH_LONG);



pauseIncomingVideo()

Description

Pauses incoming video media.

Arguments

  • none

Returns

  • N/A

Example

InfobipRTC infobipRTC = InfobipRTC.getInstance();
ApplicationCall applicationCall = infobipRTC.getActiveApplicationCall();
applicationCall.pauseIncomingVideo();



resumeIncomingVideo()

Description

Resumes incoming video media.

Arguments

  • none

Returns

  • N/A

Example

InfobipRTC infobipRTC = InfobipRTC.getInstance();
ApplicationCall applicationCall = infobipRTC.getActiveApplicationCall();
applicationCall.resumeIncomingVideo();



setNetworkQualityEventListener(networkQualityEventListener)

Description

Configures event handler for local network quality events.

Arguments

  • networkQualityEventListener: NetworkQualityEventListener - Interface that should be implemented in order to handle local network quality events properly.

Returns

  • N/A

Example

InfobipRTC infobipRTC = InfobipRTC.getInstance();
ApplicationCall applicationCall = infobipRTC.getActiveApplicationCall();
applicationCall.setNetworkQualityEventListener(new NetworkQualityEventListener() {
    @Override
    public void onNetworkQualityChanged(NetworkQualityChangedEvent networkQualityChangedEvent) {
        NetworkQuality networkQuality = networkQualityChangedEvent.getNetworkQuality();
        Log.d("WebRTC", String.format("Local network quality is: %s (score: %s)", networkQuality, networkQuality.getScore()));
    }
});



getNetworkQualityEventListener()

Description

Returns event handler for local network quality events.

Arguments

  • none

Returns

Example

InfobipRTC infobipRTC = InfobipRTC.getInstance();
ApplicationCall applicationCall = infobipRTC.getActiveApplicationCall();
NetworkQualityEventListner networkQualityEventListner = applicationCall.getNetworkQualityEventListener();



setParticipantNetworkQualityEventListener(participantNetworkQualityEventListener)

Description

Configures event handler for other participant's network quality events.

Arguments

  • participantNetworkQualityEventListener: ParticipantNetworkQualityEventListener - Interface that should be implemented in order to handle other participant's network quality events properly.

Returns

  • N/A

Example

InfobipRTC infobipRTC = InfobipRTC.getInstance();
ApplicationCall applicationCall = infobipRTC.getActiveApplicationCall();
applicationCall.setParticipantNetworkQualityEventListener(new ParticipantNetworkQualityEventListener() {
    @Override
    public void onParticipantNetworkQualityChanged(ParticipantNetworkQualityChangedEvent participantNetworkQualityChangedEvent) {
        Participant participant = participantNetworkQualityChangedEvent.getParticipant();
        NetworkQuality networkQuality = participantNetworkQualityChangedEvent.getNetworkQuality();
        Log.d("WebRTC",String.format("%s's network quality changed to %s (value %s)", participant.getEndpoint().identifier(), networkQuality, networkQuality.getScore()));
    }
});



getParticipantNetworkQualityEventListener()

Description

Returns event handler for other participant's network quality events.

Arguments

  • none

Returns

Example

InfobipRTC infobipRTC = InfobipRTC.getInstance();
ApplicationCall applicationCall = infobipRTC.getActiveApplicationCall();
ParticipantNetworkQualityEventListener participantNetworkQualityEventListener = applicationCall.getParticipantNetworkQualityEventListener();



audioDeviceManager()

Description

Returns the instance of AudioDeviceManager that should be used to manage the audio devices in the current call.

Arguments

  • none

Returns

  • AudioDeviceManager - An instance of AudioDeviceManager specifically designed for handling audio devices.

Example

InfobipRTC infobipRTC = InfobipRTC.getInstance();
ApplicationCall applicationCall = infobipRTC.getActiveApplicationCall();
AudioDeviceManager audioDeviceManager = applicationCall.audioDeviceManager();



audioQualityMode(audioQualityMode)

Description

Sets the audio quality mode to a given enum value.

Arguments

Returns

  • N/A

Example

InfobipRTC infobipRTC = InfobipRTC.getInstance();
ApplicationCall applicationCall = infobipRTC.getActiveApplicationCall();
applicationCall.audioQualityMode(AudioOptions.AudioQualityMode.LOW_DATA);



dataChannel()

Description

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

Arguments

  • none

Returns

  • DataChannel - An instance of DataChannel specifically designed for handling actions on data channel. null if data channel is not enabled in call options.

Example

InfobipRTC infobipRTC = InfobipRTC.getInstance();
ApplicationCall applicationCall = infobipRTC.getActiveApplicationCall();
DataChannel dataChannel = applicationCall.dataChannel();



setReconnectHandler(reconnectHandler)

Description

Setter for the reconnectHandler field. If you want to receive ReconnectingEvent and ReconnectedEvent, you must set the custom implementation of the ReconnectHandler.

Arguments

  • reconnectHandler: ReconnectHandler - Interface that should be implemented in order to enable the reconnection of the call when the connection is lost.

Returns

  • N/A

Example

InfobipRTC infobipRTC = InfobipRTC.getInstance();
ApplicationCall applicationCall = infobipRTC.getActiveApplicationCall();
applicationCall.setReconnectHandler(new ReconnectHandler() {
    @Override
    public ApplicationCallOptions prepareForReconnect(String reconnectingCallId, ApplicationCallOptions reconnectingCallOptions) {
        Log.d("WebRTC", String.format("Preparing room call for reconnect, reconnecting call id is: %s", reconnectingCallId));

        // Add any custom data that will help you handle the reconnect flow on your backend application
        reconnectingCallOptions.getCustomData().put("reconnectingCallId", reconnectingCallId);
        return reconnectingCallOptions;
    }
});



getReconnectHandler()

Description

Returns the instance of ReconnectHandler that should be used to manage the reconnection of the current call when the connection is lost.

Arguments

  • none

Returns

  • ReconnectHandler - An instance of ReconnectHandler specifically designed for handling the process of reconnecting the call.

Example

InfobipRTC infobipRTC = InfobipRTC.getInstance();
ApplicationCall applicationCall = infobipRTC.getActiveApplicationCall();
ReconnectHandler reconnectHandler = applicationCall.getReconnectHandler();



getVideoFilter()

Description

This method returns the instance of VideoFilter currently in use.

Arguments

  • none

Returns

Example

// Retrieve the active application call and get the video filter
InfobipRTC infobipRTC = InfobipRTC.getInstance();
ApplicationCall applicationCall = infobipRTC.getActiveApplicationCall();
VideoFilter videoFilter = applicationCall.getVideoFilter();



setVideoFilter(videoFilter)

Description

This method 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 instance of VideoFilter.

Returns

  • N/A

Example

// Create a video filter
VideoFilter videoFilter = createVideoFilter();

// Set the video filter for the active application call
InfobipRTC infobipRTC = InfobipRTC.getInstance();
ApplicationCall applicationCall = infobipRTC.getActiveApplicationCall();
applicationCall.setVideoFilter(videoFilter);



clearVideoFilter()

Description

This convenience method removes the video filter if it is present.

Arguments

  • none

Returns

  • N/A

Example

// Clear the video filter for the active application call
InfobipRTC infobipRTC = InfobipRTC.getInstance();
ApplicationCall applicationCall = infobipRTC.getActiveApplicationCall();
applicationCall.clearVideoFilter();



hangup()

Description

Hangs up call.

Arguments

  • none

Returns

  • N/A

Example

InfobipRTC infobipRTC = InfobipRTC.getInstance();
ApplicationCall applicationCall = infobipRTC.getActiveApplicationCall();
applicationCall.hangup();



getRecordingState()

Description

Returns the instance of the current RecordingState.

Arguments

  • none

Returns

Example

InfobipRTC infobipRTC = InfobipRTC.getInstance();
ApplicationCall applicationCall = infobipRTC.getActiveApplicationCall();
RecordingState recordingState = applicationCall.getRecordingState().getCallRecording();

Tutorials

Migration guides

Reference documentation

Clone this wiki locally