0

に「電話会議」という機能を追加したいCSipSimple。私は次のコードを書きました:

dispatchTriggerEvent(IOnCallActionTrigger.ADD_CALL);

次のメソッドを呼び出します。

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

次のメソッドを呼び出します。

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);
    }
}

このメソッドから、次のメソッドに入ります。

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);
}

これから、このメソッドに入ります。

    @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);

    }

このメソッドは、アプリケーションが複数の呼び出しを許可するように構成されていないことを示します。複数の通話をサポートするにはどうすればよいですか?

4

2 に答える 2

1

いくつかのオプションがあります。

1) アプリから複数通話をオンにするには、ダイヤラー画面の上部にあるメニューに移動し、[設定] -> [通話オプション] -> [複数通話をサポートする] をオンにします。

2) コードで設定できます: SipConfigManager.setPreferenceBooleanValue(mainActivity,SipConfigManager.SUPPORT_MULTIPLE_CALLS, true );

于 2016-02-03T15:28:31.690 に答える