2016-01-12 6 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);

 Смежные вопросы

  • Нет связанных вопросов^_^