-
Notifications
You must be signed in to change notification settings - Fork 2
Call
String id()
String correlationId()
CallOptions callOptions()
RecordingOptions recordingOptions()
CallStatus status()
void hangup()
void setEventListener(CallEventListener callEventListener)
void setNetworkQualityListener(NetworkQualityListener networkQualityListener)
void mute(boolean shouldMute)
void sendDTMF(String dtmf) throws ActionFailedException
void speakerphone(boolean enabled)
boolean muted()
boolean speakerphone()
int duration()
Date startTime()
Date endTime()
Date establishTime()
boolean hasLocalVideo()
boolean hasRemoteVideo()
void localVideo(boolean localVideo)
User source()
User destination()
void startScreenShare(ScreenCapturer screenCapturer)
void stopScreenShare()
boolean hasScreenShare()
void cameraOrientation(VideoOptions.CameraOrientation cameraOrientation
-
VideoOptions.CameraOrientation cameraOrientation()
Returns ID of a call, unique identifier for every call on Infobip RTC platform.
none
String
- Call ID.
String token = obtainToken();
CallRequest callRequest = new CallRequest(
token,
getApplicationContext(),
"Alice",
new DefaultCallEventListener()
);
OutgoingCall call = InfobipRTC.call(callRequest);
Toast.makeText(getApplicationContext(), "Call ID: " + call.id(), Toast.LENGTH_LONG);
Returns unique conversation identifier shared for every call leg included in single conversation.
none
String
- Correlation ID.
String token = obtainToken();
CallRequest callRequest = new CallRequest(
token,
getApplicationContext(),
"Alice",
new DefaultCallEventListener()
);
OutgoingCall call = InfobipRTC.call(callRequest);
Toast.makeText(getApplicationContext(), "Correlation ID: " + call.correlationId(), Toast.LENGTH_LONG);
Returns call options used to construct a call.
none
CallOptions
- Call options.
String token = obtainToken();
CallRequest callRequest = new CallRequest(
token,
getApplicationContext(),
"Alice",
new DefaultCallEventListener()
);
CallOptions callOptions = CallOptions.builder().build();
OutgoingCall call = InfobipRTC.call(callRequest, callOptions);
Toast.makeText(getApplicationContext(), "Call options: " + call.callOptions(), Toast.LENGTH_LONG);
Returns call recording options indicating whether audio and / or video stream is being recorded.
none
RecordingOptions
- Recording options.
Call call = InfobipRTC.getActiveCall();
RecordingOptions recordingOptions = call.getRecordingOptions();
Toast.makeText(getApplicationContext(),
String.format("Call audio stream recorded: %s, video stream recored: %s", recordingOptions.isAudio(), recordingOptions.isVideo()),
Toast.LENGTH_LONG);
Returns current call status.
none
CallStatus
- Call status.
String token = obtainToken();
CallRequest callRequest = new CallRequest(
token,
getApplicationContext(),
"Alice",
new DefaultCallEventListener()
);
OutgoingCall call = InfobipRTC.call(callRequest);
Toast.makeText(getApplicationContext(), "Call status: " + call.status(), Toast.LENGTH_LONG);
Hangs up call, which ends up in both parties receiving hangup event, after the hangup is processed by Infobip WebRTC platform.
none
none
String token = obtainToken();
CallRequest callRequest = new CallRequest(
token,
getApplicationContext(),
"Alice",
new DefaultCallEventListener()
);
OutgoingCall call = InfobipRTC.call(callRequest);
call.setEventListener(new DefaultCallEventListener() {
@Override
public void onEstablished(CallEstablishedEvent callEstablishedEvent) {
call.hangup();
}
});
Configures event handler for call events.
-
callEventListener
: CallEventListener - Interface with event methods that should be implemented, method per call event to be handled.
none
String token = obtainToken();
CallRequest callRequest = new CallRequest(
token,
getApplicationContext(),
"Alice",
new DefaultCallEventListener()
);
OutgoingCall call = InfobipRTC.call(callRequest);
call.setEventListener(new CallEventListener() {
@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(CallErrorEvent callErrorEvent) {
Toast.makeText(getApplicationContext(), "Error!", Toast.LENGTH_LONG);
}
@Override
public void onRinging(CallRingingEvent callRingingEvent) {
Toast.makeText(getApplicationContext(), "Ringing!", Toast.LENGTH_LONG);
}
});
Configures event handler for network quality events.
-
networkQualityListener
: networkQualityListener - Interface that should be implemented in order to handle network events properly.
none
String token = obtainToken();
CallRequest callRequest = new CallRequest(
token,
getApplicationContext(),
"Alice",
new DefaultCallEventListener()
);
OutgoingCall call = InfobipRTC.call(callRequest);
call.setNetworkQualityListener(new NetworkQualityListener() {
@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()));
});
}
@Override
public void onRemoteNetworkQualityChanged(NetworkQualityChangedEvent remoteNetworkQualityChangedEvent) {
runOnUiThread(() -> {
NetworkQuality networkQuality = remoteNetworkQualityChangedEvent.getNetworkQuality();
Log.d("WebRTC", String.format("Remote network quality is: %s (score: %s)", networkQuality, networkQuality.getScore()));
});
}
});
Toggles mute option.
shouldMute
: boolean
- Whether call should be muted after action or not.
none
String token = obtainToken();
CallRequest callRequest = new CallRequest(
token,
getApplicationContext(),
"Alice",
new DefaultCallEventListener()
);
OutgoingCall call = InfobipRTC.call(callRequest);
call.setEventListener(new DefaultCallEventListener() {
@Override
public void onEstablished(CallEstablishedEvent callEstablishedEvent) {
call.mute(true);
}
});
Simulates key-press by sending DTMF (Dual-Tone Multi-Frequency) entry.
-
dtmf
:String
- One of the allowed DTMF characters:- digits:
0
to9
- letters:
A
toD
- symbols:
*
and#
- digits:
none
ActionFailedException
- if sending fails for any reason.
String token = obtainToken();
CallRequest callRequest = new CallRequest(
token,
getApplicationContext(),
"Alice",
new DefaultCallEventListener()
);
OutgoingCall call = InfobipRTC.call(callRequest);
call.setEventListener(new DefaultCallEventListener() {
@Override
public void onEstablished(CallEstablishedEvent callEstablishedEvent) {
call.sendDTMF("1");
}
});
Toggles whether sound should be played on the speakerphone or not. When call is started, it is disabled by default.
enabled
: boolean
- Whether sound should be played on the speakerphone or not.
none
String token = obtainToken();
CallRequest callRequest = new CallRequest(
token,
getApplicationContext(),
"Alice",
new DefaultCallEventListener()
);
OutgoingCall call = InfobipRTC.call(callRequest);
call.setEventListener(new DefaultCallEventListener() {
@Override
public void onEstablished(CallEstablishedEvent callEstablishedEvent) {
call.speakerphone(true);
}
});
Returns information whether audio is muted or not.
none
boolean
- Is audio muted
String token = obtainToken();
CallRequest callRequest = new CallRequest(
token,
getApplicationContext(),
"Alice",
new DefaultCallEventListener()
);
OutgoingCall call = InfobipRTC.call(callRequest);
String muted = call.muted() ? "muted" : "not muted";
Toast.makeText(getApplicationContext(), "Audio is " + muted , Toast.LENGTH_LONG);
Returns information whether speakerphone is enabled or not.
none
boolean
- Is speakerphone on
String token = obtainToken();
CallRequest callRequest = new CallRequest(
token,
getApplicationContext(),
"Alice",
new DefaultCallEventListener()
);
OutgoingCall call = InfobipRTC.call(callRequest);
String speakerphoneOn = call.speakerphone() ? "on" : "off";
Toast.makeText(getApplicationContext(), "Speakerphone is " + speakerphoneOn, Toast.LENGTH_LONG);
Returns call duration in seconds calculated from the time call was established. Initially, duration is 0
.
none
int
- Call duration
String token = obtainToken();
CallRequest callRequest = new CallRequest(
token,
getApplicationContext(),
"Alice",
new DefaultCallEventListener()
);
OutgoingCall call = InfobipRTC.call(callRequest);
call.setEventListener(new CallEventListener() {
@Override
public void onHangup(CallHangupEvent callHangupEvent) {
int durationInSeconds = call.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);
}
});
Returns time when the call started (but not yet established). Initially, startTime is null
.
none
Date
- Time when the call started
String token = obtainToken();
CallRequest callRequest = new CallRequest(
token,
getApplicationContext(),
"Alice",
new DefaultCallEventListener()
);
OutgoingCall call = InfobipRTC.call(callRequest);
Date startTime = call.startTime();
Toast.makeText(getApplicationContext(), "Start time: " + call.startTime(), Toast.LENGTH_LONG).show();
Returns time when the call finished. Initially, endTime is null
.
none
Date
- Time when the call finished
String token = obtainToken();
CallRequest callRequest = new CallRequest(
token,
getApplicationContext(),
"Alice",
new DefaultCallEventListener()
);
OutgoingCall call = InfobipRTC.call(callRequest);
call.setEventListener(new CallEventListener() {
@Override
public void onEstablished(CallEstablishedEvent callEstablishedEvent) {
call.hangup();
}
@Override
public void onHangup(CallHangupEvent callHangupEvent) {
Toast.makeText(getApplicationContext(), "End time: " + call.endTime(), Toast.LENGTH_LONG);
}
});
Returns time when the call was established. Initially, establishTime is null
.
none
Date
- Time when the call was established
String token = obtainToken();
CallRequest callRequest = new CallRequest(
token,
getApplicationContext(),
"Alice",
new DefaultCallEventListener()
);
OutgoingCall call = InfobipRTC.call(callRequest);
call.setEventListener(new CallEventListener() {
@Override
public void onEstablished(CallEstablishedEvent callEstablishedEvent) {
Toast.makeText(getApplicationContext(), "Establish time: " + call.establishTime(), Toast.LENGTH_LONG);
}
});
Returns information whether the current call has local video or not.
none
boolean
- Call has local video
String token = obtainToken();
CallRequest callRequest = new CallRequest(
token,
getApplicationContext(),
"Alice",
new DefaultCallEventListener()
);
CallOptions callOptions = CallOptions.builder()
.video(true)
.build();
OutgoingCall call = InfobipRTC.call(callRequest, callOptions);
String hasLocalVideo = call.hasLocalVideo() ? "has" : "doesn't have";
Toast.makeText(getApplicationContext(), "Call " + hasLocalVideo + " local video", Toast.LENGTH_LONG);
Returns information whether the current call has remote video or not.
none
boolean
- Call has remote video
IncomingCallEventListener incomingCallEventListener = new IncomingCallEventListener() {
@Override
public void onIncomingCall(IncomingCallEvent incomingCallEvent) {
IncomingCall incomingCall = incomingCallEvent.getIncomingCall();
String hasRemoteVideo = incomingCall.hasRemoteVideo() ? "has" : "doesn't have";
Log.d("WebRTC", "Call " + hasRemoteVideo + " remote video");
}
};
Toggles whether local video should be enabled or not. For video calls it is enabled by default.
localVideo
: boolean
- Whether local video should be enabled or not.
none
Call call = InfobipRTC.getActiveCall();
call.localVideo(true); // Start sending local video stream to remote peer
Returns User who originated call.
none
User
- User who originated call.
IncomingCallEventListener incomingCallEventListener = new IncomingCallEventListener() {
@Override
public void onIncomingCall(IncomingCallEvent incomingCallEvent) {
IncomingCall incomingCall = incomingCallEvent.getIncomingCall();
Log.d("WebRTC", incomingCall.destination().getIdentity() + " received incoming call from: " + incomingCall.source().getIdentity());
}
};
Returns destination User which was called.
none
User
- Destination to which call was placed.
String token = obtainToken();
CallRequest callRequest = new CallRequest(
token,
getApplicationContext(),
"Alice",
new DefaultCallEventListener()
);
OutgoingCall call = InfobipRTC.call(callRequest);
Toast.makeText(getApplicationContext(), call.source().getIdentity() + " is calling " + call.destination().getIdentity(), Toast.LENGTH_LONG);
Starts sharing screen with the remote peer. Needs to be called after CallEstablishedEvent is received.
ScreenCapturer
- Screen capturer used for sharing.
none
public class Foo extends AppCompatActivity {
private Call call;
@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);
Call call = InfobipRTC.getActiveCall();
call.startScreenShare(screenCapturer);
}
public void startScreenShare() {
MediaProjectionManager mediaProjectionManager = (MediaProjectionManager) getApplication().getSystemService(Context.MEDIA_PROJECTION_SERVICE);
startActivityForResult(mediaProjectionManager.createScreenCaptureIntent(), 1);
}
}
Stops sharing screen with the remote peer.
none
none
Call call = InfobipRTC.getActiveCall();
call.stopScreenShare();
Returns true
if screen is being shared with remote peer, else false.
none
boolean
- Whether screen is being shared with remote peer or not
Call call = InfobipRTC.getActiveCall();
Log.d("WebRTC", String.format("Call %s is sharing screen: %s", call.id(), call.hasScreenShare()));
Change local video orientation.
-
cameraOrientation
: VideoOptions.CameraOrientation - Camera orientation.
none
String token = obtainToken();
CallRequest callRequest = new CallRequest(
token,
getApplicationContext(),
"Alice",
new DefaultCallEventListener()
);
VideoOptions videoOptions = VideoOptions.builder()
.cameraOrientation(VideoOptions.CameraOrientation.FRONT)
.build();
CallOptions callOptions = CallOptions.builder()
.video(true)
.videoOptions(videoOptions)
.build();
OutgoingCall call = InfobipRTC.call(callRequest, callOptions);
call.setEventListener(new DefaultCallEventListener() {
@Override
public void onEstablished(CallEstablishedEvent callEstablishedEvent) {
call.cameraOrientation(VideoOptions.CameraOrientation.BACK);
}
});
Get current camera orientation.
none
VideoOptions.CameraOrientation
- Camera orientation.
String token = obtainToken();
CallRequest callRequest = new CallRequest(
token,
getApplicationContext(),
"Alice",
new DefaultCallEventListener()
);
VideoOptions videoOptions = VideoOptions.builder()
.cameraOrientation(VideoOptions.CameraOrientation.FRONT)
.build();
CallOptions callOptions = CallOptions.builder()
.video(true)
.videoOptions(videoOptions)
.build();
OutgoingCall call = InfobipRTC.call(callRequest, callOptions);
String cameraOrientation = call.cameraOrientation().name();
Toast.makeText(getApplicationContext(), "Camera orientation is " + cameraOrientation, Toast.LENGTH_LONG);
});