Interface | Description |
---|---|
DataTransfer.Observer |
Observer for this data transfer on incoming data and state changes.
|
Class | Description |
---|---|
Call |
Represents a call which could have any combination of audio/video/dataChannel capabilities.
|
Call.Observer |
Observer class that the application can implement to be informed of changes in the
Call . |
Call.TrickleIceMode |
Trickle ICE modes.
|
CallConfig |
Call Configuration that describes the capabilities (audio/video/data channel) of a call.
|
CallPackage |
Package handler that enables call applications.
|
CallPackage.Observer |
Observer class for the
CallPackage to receive notifications whenever a new call arrives. |
CallState |
Represents the various states of a Call.
|
CallUpdateEvent |
Represents the various states of a Call update event.
|
Cause |
Identifies the
StatusCode and extension headers related to an event. |
DataChannelConfig |
Represents configuration for a specific data channel.
|
DataChannelOption |
Provides options for configuring the data channel.
|
DataTransfer |
Represents handle to all data channel operations.
|
DataTransfer.DataTransferState |
Status of the DataTransfer object.
|
MediaDirection |
Direction of the local media stream.
|
MediaStreamEvent |
Media stream event enumerator.
|
To make an outgoing call:
String callType = CallPackage.PACKAGE_TYPE;
CallPackage callPackage = (CallPackage) session.getPackage(callType);
String calleeId = "bob@example.com";
// Create a call object using the CallPackage object registered with the session for the calleeId.
Call call = callPackage.createCall(calleeId);
// Register an observer for listening to Call Events.
call.setObserver(new MyCallObserver());
// Create a configuration object for an Audio call - Audio:SENDRECV, Video:NONE
CallConfig callConfig = new CallConfig(MediaDirection.SEND_RECV, MediaDirection.NONE);
// Get the local media streams.
PeerConnectionFactory pcf = call.getPeerConnectionFactory();
MediaStream mediaStream = pcf.createLocalMediaStream("ARDAMS");
AudioSource audioSource = pcf.createAudioSource(new MediaConstraints());
mediaStream.addTrack(pcf.createAudioTrack("ARDAMSa0", audioSource));
// Start the call.
call.start(callConfig, mediaStream);
// Class that observes state changes for a Call.
class MyCallObserver extends Call.Observer {
public void stateChanged(CallState state, Cause cause) {
runOnUiThread(new Runnable() {
public void run() {
switch (state) {
case ESTABLISHED:
// Update the UI components to indicate that the call has been accepted...
break;
case ENDED:
// Update the status, and, possibly, close the activity...
break;
}
}
});
}
public void mediaStateChanged(MediaStreamEvent mediaStreamEvent, MediaStream mediaStream) {
// For Video, add to remote VideoRenderer
}
public void callUpdated(CallUpdateState state, CallConfig config, Cause cause) {
// Handle call update scenario
}
}
To handle an incoming call:
Register a call package observer with the CallPackage:
WSCSession session;
CallPackage callPackage = (CallPackage) session.getPackage(CallPackage.PACKAGE_TYPE);
callPackage.setObserver(new MyCallPackageObserver());
// Observer for the Call Package.
class MyCallPackageObserver extends CallPackage.Observer {
public void callArrived(Call call, CallConfig callConfig, Map<String, ?> extHeaders) {
// Register an observer for listening to Call Events
call.setObserver(new MyCallObserver()); // Same class used as given in Outgoing call above
// Get the local media streams.
PeerConnectionFactory pcf = call.getPeerConnectionFactory();
MediaStream mediaStream = pcf.createLocalMediaStream("ARDAMS");
AudioSource audioSource = pcf.createAudioSource(new MediaConstraints());
mediaStream.addTrack(pcf.createAudioTrack("ARDAMSa0", audioSource));
// Accept the call.
call.accept(callConfig, localStreams);
// ...or Decline the call.
// call.decline(StatusCode.DECLINED.getCode());
}
}