Oracle® Communications WebRTC Session Controller Android API Reference
E55129-01
7.1

Package oracle.wsc.android.call

Provides a Call handling API.

See: Description

Package oracle.wsc.android.call Description

Provides a Call handling API.

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))
 CallConfig callConfig = new CallConfig(/* audio*\/ MediaDirection.SEND_RECV, /* video*\/ 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 indicated 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) {
     ...
   }

   public void callUpdated(CallUpdateState state, CallConfig config, Cause cause) {
     ...
   }
 }
 
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());
   }

   public void callResurrected(Call call) {
     ...
   }
 }
 
 
Oracle® Communications WebRTC Session Controller Android API Reference
E55129-01
7.1

Copyright © 2013, 2015, Oracle and/or its affiliates. All rights reserved.