What to do to allow conference calls in csipsimple in Android

时间:2016-01-12 11:22:26

标签: android csip-simple

I want to add a feature named "conference call" in CSipSimple. I have written the following code :

dispatchTriggerEvent(IOnCallActionTrigger.ADD_CALL);

It calls the following method :

private void dispatchTriggerEvent(int whichHandle) {
        if (onTriggerListener != null) {
            onTriggerListener.onTrigger(whichHandle, currentCall);
        }
    }

It calls the following method :

public void onTrigger(int whichAction, final SipCallSession call) {

    // Sanity check for actions requiring valid call id
    if (whichAction == TAKE_CALL || whichAction == REJECT_CALL || whichAction == DONT_TAKE_CALL ||
        whichAction == TERMINATE_CALL || whichAction == DETAILED_DISPLAY || 
        whichAction == TOGGLE_HOLD || whichAction == START_RECORDING ||
        whichAction == STOP_RECORDING || whichAction == DTMF_DISPLAY ||
        whichAction == XFER_CALL || whichAction == TRANSFER_CALL ||
        whichAction == START_VIDEO || whichAction == STOP_VIDEO ) {
        // We check that current call is valid for any actions
        if (call == null) {
            Log.e(THIS_FILE, "Try to do an action on a null call !!!");
            return;
        }
        if (call.getCallId() == SipCallSession.INVALID_CALL_ID) {
            Log.e(THIS_FILE, "Try to do an action on an invalid call !!!");
            return;
        }
    }

    // Reset proximity sensor timer
    proximityManager.restartTimer();

    try {
        switch (whichAction) {

            case ADD_CALL: {
                Intent pickupIntent = new Intent(this, PickupSipUri.class);
                startActivityForResult(pickupIntent, PICKUP_SIP_URI_NEW_CALL);
                break;
            }
            case START_RECORDING :{
                if(service != null) {
                    // TODO : add a tweaky setting for two channel recording in different files.
                    // Would just result here in two calls to start recording with different bitmask
                    service.startRecording(call.getCallId(), SipManager.BITMASK_ALL);
                }
                break;
            }
            case STOP_RECORDING : {
                if(service != null) {
                    service.stopRecording(call.getCallId());
                }
                break;
            }
            case START_VIDEO :
            case STOP_VIDEO : {
                if(service != null) {
                    Bundle opts = new Bundle();
                    opts.putBoolean(SipCallSession.OPT_CALL_VIDEO, whichAction == START_VIDEO);
                    service.updateCallOptions(call.getCallId(), opts);
                }
                break;
            }
            case ZRTP_TRUST : {
                if(service != null) {
                    service.zrtpSASVerified(call.getCallId());
                }
                break;
            }
            case ZRTP_REVOKE : {
                if(service != null) {
                    service.zrtpSASRevoke(call.getCallId());
                }
                break;
            }
        }
    } catch (RemoteException e) {
        Log.e(THIS_FILE, "Was not able to call service method", e);
    }
}

From this method we go into this method :

protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    switch (requestCode) {

        case PICKUP_SIP_URI_NEW_CALL:
            if (resultCode == RESULT_OK && service != null) {
                String callee = data.getStringExtra(Intent.EXTRA_PHONE_NUMBER);
                long accountId = data.getLongExtra(SipProfile.FIELD_ID,
                        SipProfile.INVALID_ID);
                if (accountId != SipProfile.INVALID_ID) {
                    try {
                        service.makeCall(callee, (int) accountId);
                    } catch (RemoteException e) {
                        // TODO : toaster
                    }
                }
            }
            return;
        default:
            break;
    }
    super.onActivityResult(requestCode, resultCode, data);
}

From this we go into this method :

    @Override
    public void makeCall(final String callee, final int accountId) throws RemoteException {
        makeCallWithOptions(callee, accountId, null);
    }


    @Override
    public void makeCallWithOptions(final String callee, final int accountId, final Bundle options)
            throws RemoteException {
        SipService.this.enforceCallingOrSelfPermission(SipManager.PERMISSION_USE_SIP, null);
        //We have to ensure service is properly started and not just binded
        SipService.this.startService(new Intent(SipService.this, SipService.class));

        if(pjService == null) {
            Log.e(THIS_FILE, "Can't place call if service not started");
            // TODO - we should return a failing status here
            return;
        }

        if(!supportMultipleCalls) {
            // Check if there is no ongoing calls if so drop this request by alerting user
            SipCallSession activeCall = pjService.getActiveCallInProgress();
            if(activeCall != null) {
                if(!CustomDistribution.forceNoMultipleCalls()) {
                    notifyUserOfMessage(R.string.not_configured_multiple_calls);
                }
                return;
            }
        }

        Intent intent = new Intent(SipManager.ACTION_SIP_CALL_LAUNCH);
        intent.putExtra(SipProfile.FIELD_ID, accountId);
        intent.putExtra(SipManager.EXTRA_SIP_CALL_TARGET, callee);
        intent.putExtra(SipManager.EXTRA_SIP_CALL_OPTIONS, options);
        sendOrderedBroadcast (intent , SipManager.PERMISSION_USE_SIP, mPlaceCallResultReceiver, null,  Activity.RESULT_OK, null, null);

    }

This method tells that The application is not configured to allow multiple calls. What can I do to support multiple calls?

2 个答案:

答案 0 :(得分:0)

您有几个选择:

1)您可以通过转到拨号程序屏幕上方的菜单,选择设置 - >来打开应用程序中的多个来电。通话选项 - >检查"支持多个电话"

2)您可以在代码中设置它:SipConfigManager.setPreferenceBooleanValue(mainActivity,SipConfigManager.SUPPORT_MULTIPLE_CALLS,true);

答案 1 :(得分:0)

在电话会议中添加这两行

 case ADD_CALL: {
                    SipConfigManager.setPreferenceBooleanValue(this, 
                    SipConfigManager.SUPPORT_MULTIPLE_CALLS, true);
                    service.sipStart();
                    Intent pickupIntent = new Intent(this, PickupSipUri.class);
                    startActivityForResult(pickupIntent, PICKUP_SIP_URI_NEW_CALL);
                    break;
                    }
相关问题