/** INTERNAL: not to be used from the Application */ public void onSipUAConnectionArrived(SipEvent event) { // RCConnectionListener connectionListener = (RCConnectionListener) this.listener; incomingConnection = new RCConnection(); incomingConnection.incoming = true; incomingConnection.state = RCConnection.ConnectionState.CONNECTING; incomingConnection.incomingCallSdp = event.sdp; // incomingConnection.initializeWebrtc(); DeviceImpl.GetInstance().sipuaConnectionListener = incomingConnection; // Important: need to fire the event in UI context cause currently we 're in JAIN SIP thread final String from = event.from; // final String sdp = event.sdp; Handler mainHandler = new Handler(RCClient.getInstance().context.getMainLooper()); Runnable myRunnable = new Runnable() { @Override public void run() { // bring the App to front try { Intent dataIntent = new Intent(); dataIntent.setAction(INCOMING_CALL); dataIntent.putExtra(RCDevice.EXTRA_DID, from); pendingCallIntent.send(RCClient.getInstance().context, 0, dataIntent); } catch (PendingIntent.CanceledException e) { e.printStackTrace(); } } }; mainHandler.post(myRunnable); }
/** * Create an outgoing connection to an endpoint * * @param parameters Parameters such as the endpoint we want to connect to or SIP custom headers. * If you want to pass SIP custom headers, you need to add a separate (String, String) HashMap * inside 'parameters' hash and introduce your headers there. For an example please check * HelloWorld or Messenger samples. * @param listener The listener object that will receive events when the connection state changes * @return An RCConnection object representing the new connection */ public RCConnection connect(Map<String, Object> parameters, RCConnectionListener listener) { Activity activity = (Activity) listener; if (haveConnectivity()) { Boolean enableVideo = (Boolean) parameters.get("video-enabled"); RCConnection connection = new RCConnection(listener); connection.incoming = false; connection.state = RCConnection.ConnectionState.PENDING; DeviceImpl.GetInstance().sipuaConnectionListener = connection; // create a new hash map HashMap<String, String> sipHeaders = null; if (parameters.containsKey("sip-headers")) { sipHeaders = (HashMap<String, String>) parameters.get("sip-headers"); } connection.setupWebrtcAndCall( (String) parameters.get("username"), sipHeaders, enableVideo.booleanValue()); return connection; } else { return null; } }