Skip to content
Kenan Genjac edited this page May 9, 2023 · 12 revisions



id()

Description

Returns a unique call identifier.

Arguments

  • none

Returns

Example

String token = obtainToken();
InfobipRTC infobipRTC = InfobipRTC.getInstance();

CallWebrtcRequest callWebrtcRequest = new CallWebrtcRequest(
    token,
    getApplicationContext(),
    "45g2gql9ay4a2blu55uk1628",
    new DefaultWebrtcCallEventListener()
);

WebrtcCall webrtcCall = infobipRTC.callWebrtc(callWebrtcRequest);
Toast.makeText(getApplicationContext(), "Call ID: " + webrtcCall.id(), Toast.LENGTH_LONG);



status()

Description

Returns current call status.

Arguments

  • none

Returns

Example

String token = obtainToken();
InfobipRTC infobipRTC = InfobipRTC.getInstance();

CallWebrtcRequest callWebrtcRequest = new CallWebrtcRequest(
    token,
    getApplicationContext(),
    "45g2gql9ay4a2blu55uk1628",
    new DefaultWebrtcCallEventListener()
);

WebrtcCall webrtcCall = infobipRTC.callWebrtc(callWebrtcRequest);
Toast.makeText(getApplicationContext(), "Call status: " + webrtcCall.status(), Toast.LENGTH_LONG);



duration()

Description

Returns call duration in seconds calculated from the time call was established. 0 if the call has not been established yet.

Arguments

  • none

Returns

  • int - Call duration in seconds

Example

String token = obtainToken();
InfobipRTC infobipRTC = InfobipRTC.getInstance();

CallWebrtcRequest callWebrtcRequest = new CallWebrtcRequest(
    token,
    getApplicationContext(),
    "45g2gql9ay4a2blu55uk1628",
    new DefaultWebrtcCallEventListener()
);

WebrtcCall webrtcCall = infobipRTC.callWebrtc(callWebrtcRequest);
webrtcCall.setEventListener(new WebrtcCallEventListener() {
    ...
    @Override
    public void onHangup(CallHangupEvent callHangupEvent) {
        int durationInSeconds = webrtcCall.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). Initially, startTime is null.

Arguments

  • none

Returns

  • Date - Time when the call was initiated

Example

String token = obtainToken();
InfobipRTC infobipRTC = InfobipRTC.getInstance();

CallWebrtcRequest callWebrtcRequest = new CallWebrtcRequest(
    token,
    getApplicationContext(),
    "45g2gql9ay4a2blu55uk1628",
    new DefaultWebrtcCallEventListener()
);

WebrtcCall webrtcCall = infobipRTC.callWebrtc(callWebrtcRequest);
Toast.makeText(getApplicationContext(), "Start time: " + webrtcCall.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

String token = obtainToken();
InfobipRTC infobipRTC = InfobipRTC.getInstance();

CallWebrtcRequest callWebrtcRequest = new CallWebrtcRequest(
    token,
    getApplicationContext(),
    "45g2gql9ay4a2blu55uk1628",
    new DefaultWebrtcCallEventListener()
);

WebrtcCall webrtcCall = infobipRTC.callWebrtc(callWebrtcRequest);
webrtcCall.setEventListener(new WebrtcCallEventListener() {
    ...
    @Override
    public void onEstablished(CallEstablishedEvent callEstablishedEvent) {
        Toast.makeText(getApplicationContext(), "Establish time: " + webrtcCall.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

String token = obtainToken();
InfobipRTC infobipRTC = InfobipRTC.getInstance();

CallWebrtcRequest callWebrtcRequest = new CallWebrtcRequest(
    token,
    getApplicationContext(),
    "45g2gql9ay4a2blu55uk1628",
    new DefaultWebrtcCallEventListener()
);

WebrtcCall webrtcCall = infobipRTC.callWebrtc(callWebrtcRequest);
webrtcCall.setEventListener(new WebrtcCallEventListener() {
    ...
    @Override
    public void onEstablished(CallEstablishedEvent callEstablishedEvent) {
        webrtcCall.hangup();
    }

    @Override
    public void onHangup(CallHangupEvent callHangupEvent) {
        Toast.makeText(getApplicationContext(), "End time: " + webrtcCall.endTime(), Toast.LENGTH_LONG);
    }
    ...
});



source()

Description

Returns the endpoint from which the call originated.

Arguments

  • none

Returns

  • Endpoint - Endpoint which initiated the call

Example

InfobipRTC infobipRTC = InfobipRTC.getInstance();
Endpoint source = infobipRTC.getActiveCall().source()



destination()

Description

Returns the endpoint which received the call.

Arguments

  • none

Returns

  • Endpoint - Endpoint which received the call

Example

InfobipRTC infobipRTC = InfobipRTC.getInstance();
Endpoint destination = infobipRTC.getActiveCall.destination()



counterpart()

Description

Returns the remote endpoint which is participating in the call.

Arguments

  • none

Returns

  • Endpoint - Remote endpoint which is participating in the call.

Example

InfobipRTC infobipRTC = InfobipRTC.getInstance();
Endpoint counterpart = infobipRTC.getActiveCall.counterpart()



mute(houldMute) throws ActionFailedException

Description

Controls whether the user's audio in the call should be muted after this action. Disabled by default.

Arguments

  • shouldMute: boolean - true if the audio should be muted, otherwise false.

Returns

  • N/A

Throws

Example

InfobipRTC infobipRTC = InfobipRTC.getInstance();
WebrtcCall webrtcCall = (WebrtcCall) infobipRTC.getActiveCall()
webrtcCall.mute()



muted()

Description

Returns the information whether the user's audio is muted or not.

Arguments

  • none

Returns

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

Example

InfobipRTC infobipRTC = InfobipRTC.getInstance();
WebrtcCall webrtcCall = (WebrtcCall) infobipRTC.getActiveCall()
webrtcCall.mute(!webrtcCall.muted())



speakerphone(enabled)

Description

Controls whether the audio should be played on the speakerphone. Disabled by default.

Arguments

  • enabled: boolean - true if the audio should be played on the speakerphone, otherwise false.

Returns

  • N/A

Example

InfobipRTC infobipRTC = InfobipRTC.getInstance();
WebrtcCall webrtcCall = (WebrtcCall) infobipRTC.getActiveCall()
webrtcCall.speakerphone(true)



speakerphone()

Description

Returns information whether speakerphone is enabled.

Arguments

  • none

Returns

  • boolean - true if the speakerphone is enabled, otherwise false.

Example

InfobipRTC infobipRTC = InfobipRTC.getInstance();
WebrtcCall webrtcCall = (WebrtcCall) infobipRTC.getActiveCall()
webrtcCall.speakerphone(!webrtcCall.speakerphone())



sendDTMF(dtmf) throws ActionFailedException

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();
WebrtcCall webrtcCall = (WebrtcCall) infobipRTC.getActiveCall()
webrtcCall.sendDTMF("7")



setNetworkQualityEventListener(networkQualityEventListener)

Description

Configures event handler for network quality events.

Arguments

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

Returns

  • N/A

Example

String token = obtainToken();
InfobipRTC infobipRTC = InfobipRTC.getInstance();

CallWebrtcRequest callWebrtcRequest = new CallWebrtcRequest(
    token,
    getApplicationContext(),
    "45g2gql9ay4a2blu55uk1628",
    new DefaultWebrtcCallEventListener()
);

WebrtcCall webrtcCall = infobipRTC.callWebrtc(callWebrtcRequest);

webrtcCall.setNetworkQualityEventListener(new NetworkQualityEventListener() {
    @Override
    public void onNetworkQualityChanged(NetworkQualityChangedEvent networkQualityChangedEvent) {
        runOnUiThread(() -> {
            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 network quality events.

Arguments

  • none

Returns

Example

String token = obtainToken();
InfobipRTC infobipRTC = InfobipRTC.getInstance();

CallWebrtcRequest callWebrtcRequest = new CallWebrtcRequest(
    token,
    getApplicationContext(),
    "45g2gql9ay4a2blu55uk1628",
    new DefaultWebrtcCallEventListener()
);

WebrtcCall webrtcCall = infobipRTC.callWebrtc(callWebrtcRequest);

NetworkQualityEventListner networkQualityEventListner = webrtcCall.getNetworkQualityEventListener()



hangup()

Description

Hangs up the call, which ends up in both parties receiving the CallHangupEvent, after the hangup is processed by Infobip WebRTC platform.

Arguments

  • none

Returns

  • N/A

Example

InfobipRTC infobipRTC = InfobipRTC.getInstance();
WebrtcCall webrtcCall = (WebrtcCall) infobipRTC.getActiveCall()
webrtcCall.hangup()

Tutorials

Migration guides

Reference documentation

Clone this wiki locally