2016-01-12 45 views
0

我想添加一個在CSipSimple名爲「電話會議」功能。我寫了下面的代碼:怎樣做才能讓電話會議在csipsimple在Android的

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

    } 

這個方法告訴該應用程序未配置爲允許多個呼叫。我可以做些什麼來支持多個呼叫?

回答

0

你有兩個選擇:

1)您可以通過進入菜單上的撥號器屏幕上,選擇設置在多個呼叫轉從應用程序 - >看漲期權 - >勾選「支持多個調用「

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