コード例 #1
0
  private void updateCallState(CallInfo ci) {
    TextView tvPeer = (TextView) findViewById(R.id.textViewPeer);
    TextView tvState = (TextView) findViewById(R.id.textViewCallState);
    Button buttonHangup = (Button) findViewById(R.id.buttonHangup);
    Button buttonAccept = (Button) findViewById(R.id.buttonAccept);
    String call_state = "";

    if (ci.getRole() == pjsip_role_e.PJSIP_ROLE_UAC) {
      buttonAccept.setVisibility(View.GONE);
    }

    if (ci.getState().swigValue() < pjsip_inv_state.PJSIP_INV_STATE_CONFIRMED.swigValue()) {
      if (ci.getRole() == pjsip_role_e.PJSIP_ROLE_UAS) {
        call_state = "Incoming call..";
        /* Default button texts are already 'Accept' & 'Reject' */
      } else {
        buttonHangup.setText("Cancel");
        call_state = ci.getStateText();
      }
    } else if (ci.getState().swigValue() >= pjsip_inv_state.PJSIP_INV_STATE_CONFIRMED.swigValue()) {
      buttonAccept.setVisibility(View.GONE);
      call_state = ci.getStateText();
      if (ci.getState() == pjsip_inv_state.PJSIP_INV_STATE_CONFIRMED) {
        buttonHangup.setText("Hangup");
      } else if (ci.getState() == pjsip_inv_state.PJSIP_INV_STATE_DISCONNECTED) {
        buttonHangup.setText("OK");
        call_state = "Call disconnected: " + ci.getLastReason();
        MainActivity.currentCall = null;
      }
    }

    tvPeer.setText(ci.getRemoteUri());
    tvState.setText(call_state);
  }
コード例 #2
0
  /**
   * parse the CallInfo String header
   *
   * @return SIPHeader (CallInfoList object)
   * @throws SIPParseException if the message does not respect the spec.
   */
  public SIPHeader parse() throws ParseException {

    if (debug) dbg_enter("CallInfoParser.parse");
    CallInfoList list = new CallInfoList();

    try {
      headerName(TokenTypes.CALL_INFO);

      while (lexer.lookAhead(0) != '\n') {
        CallInfo callInfo = new CallInfo();
        callInfo.setHeaderName(SIPHeaderNames.CALL_INFO);

        this.lexer.SPorHT();
        this.lexer.match('<');
        URLParser urlParser = new URLParser((Lexer) this.lexer);
        GenericURI uri = urlParser.uriReference(true);
        callInfo.setInfo(uri);
        this.lexer.match('>');
        this.lexer.SPorHT();

        super.parse(callInfo);
        list.add(callInfo);

        while (lexer.lookAhead(0) == ',') {
          this.lexer.match(',');
          this.lexer.SPorHT();

          callInfo = new CallInfo();

          this.lexer.SPorHT();
          this.lexer.match('<');
          urlParser = new URLParser((Lexer) this.lexer);
          uri = urlParser.uriReference(true);
          callInfo.setInfo(uri);
          this.lexer.match('>');
          this.lexer.SPorHT();

          super.parse(callInfo);
          list.add(callInfo);
        }
      }

      return list;
    } finally {
      if (debug) dbg_leave("CallInfoParser.parse");
    }
  }