Exemplo n.º 1
0
void MainWin::hangup()
{
    pj_assert(currentCall_ != -1);
    //pjsua_call_hangup(currentCall_, PJSIP_SC_BUSY_HERE, NULL, NULL);
    pjsua_call_hangup_all();
    emit signalCallReleased();
}
Exemplo n.º 2
0
PjsuaManager::~PjsuaManager()
{
	pjsua_call_hangup_all();

	accounts_.clear();

	if (audio_manager_)
		audio_manager_.reset();

	pjsua_destroy();
}
Exemplo n.º 3
0
/**
 * \fn _ics_core_hangup_call()
 * \brief Ket thuc cuoc goi
 * \param agr1: ics_t *data
 * agr2: int renew (1= hangup all, 0= hangup current call)
 */
static void _ics_core_hangup_call(ics_t *data, int renew) {
	if (current_call == PJSUA_INVALID_ID)
		printf("No current call\n");
	else {
		if (renew == -2) 
			pjsua_call_hangup_all();
		else {
			renew = current_call;
			pjsua_call_hangup(renew, 0, NULL, NULL);	
		}
	}
}
Exemplo n.º 4
0
Arquivo: ics.c Projeto: mocidis/ics
/**
 * \fn _ics_hangup_call()
 * \brief Ket thuc cuoc goi
 * \param agr1: ics_t *data
 * agr2: int renew (1= hangup all, 0= hangup current call)
 */
static void _ics_hangup_call(ics_t *data, int renew) {
    PJ_UNUSED_ARG(data);

    if (current_call == PJSUA_INVALID_ID)
        SHOW_LOG(3, "No current call\n");
    else {
        if (renew == -2) 
            pjsua_call_hangup_all();
        else {
            renew = current_call;
            pjsua_call_hangup(renew, 0, NULL, NULL);	
        }
    }
}
Exemplo n.º 5
0
static void ui_hangup_call(char menuin[])
{
    if (current_call == -1) {
	puts("No current call");
	fflush(stdout);
	return;

    } else if (menuin[1] == 'a') {
	/* Hangup all calls */
	pjsua_call_hangup_all();
    } else {
	/* Hangup current calls */
	pjsua_call_hangup(current_call, 0, NULL, NULL);
    }
}
Exemplo n.º 6
0
SipPhone::~SipPhone() {
  Logger::debug("SipPhone::~SipPhone()...");

  pjsua_call_hangup_all();

#if 0
  pjsua_conf_remove_port(m_mediaConfSilenceId);
  pjmedia_port_destroy(m_mediaPortSilence);

  pj_pool_release(m_Pool);
#endif

#if 0 // see s_Initialized
  pjsua_destroy();
#endif
}
Exemplo n.º 7
0
// display error and exit application
static void error_exit(const char *title, pj_status_t status)
{
	if (!app_exiting)
	{
		app_exiting = 1;
		
		pjsua_perror("SIP Call", title, status);
		
		// check if player/recorder is active and stop them
		if (play_id != -1) pjsua_player_destroy(play_id);
		if (rec_id != -1) pjsua_recorder_destroy(rec_id);
		
		// hangup open calls and stop pjsua
		pjsua_call_hangup_all();
		pjsua_destroy();
		
		exit(1);
	}
}
Exemplo n.º 8
0
// clean application exit
static void app_exit()
{
	if (!app_exiting)
	{
		app_exiting = 1;
		log_message("Stopping application ... ");
		
		// check if player/recorder is active and stop them
		if (play_id != -1) pjsua_player_destroy(play_id);
		if (rec_id != -1) pjsua_recorder_destroy(rec_id);
		
		// hangup open calls and stop pjsua
		pjsua_call_hangup_all();
		pjsua_destroy();
		
		log_message("Done.\n");
		
		exit(0);
	}
}
Exemplo n.º 9
0
/*
 * main()
 *
 * argv[1] may contain URL to call.
 */
int main(int argc, char *argv[])
{
 pjsua_acc_id acc_id;
 pj_status_t status;

 /* Create pjsua first! */
 status = pjsua_create();
 if (status != PJ_SUCCESS) error_exit("Error in pjsua_create()", status);

 /* If argument is specified, it's got to be a valid SIP URL */
 if (argc > 1) {
 status = pjsua_verify_url(argv[1]);
 if (status != PJ_SUCCESS) error_exit("Invalid URL in argv", status);
 }

 /* Init pjsua */
 {
 pjsua_config cfg;
 pjsua_logging_config log_cfg;

 pjsua_config_default(&cfg);
 cfg.cb.on_incoming_call = &on_incoming_call;
 cfg.cb.on_call_media_state = &on_call_media_state;
 cfg.cb.on_call_state = &on_call_state;

 pjsua_logging_config_default(&log_cfg);
 log_cfg.console_level = 4;

 status = pjsua_init(&cfg, &log_cfg, NULL);
 if (status != PJ_SUCCESS) error_exit("Error in pjsua_init()", status);
 }

 /* Add UDP transport. */
 {
 pjsua_transport_config cfg;

 pjsua_transport_config_default(&cfg);
 cfg.port = 5060;
 status = pjsua_transport_create(PJSIP_TRANSPORT_UDP, &cfg, NULL);
 if (status != PJ_SUCCESS) error_exit("Error creating transport", status);
 }

 /* Initialization is done, now start pjsua */
 status = pjsua_start();
 if (status != PJ_SUCCESS) error_exit("Error starting pjsua", status);

 /* Register to SIP server by creating SIP account. */
 {
 pjsua_acc_config cfg;

 pjsua_acc_config_default(&cfg);
 cfg.id = pj_str("sip:" SIP_USER "@" SIP_DOMAIN);
 cfg.reg_uri = pj_str("sip:" SIP_DOMAIN);
 cfg.cred_count = 1;
 cfg.cred_info[0].realm = pj_str(SIP_DOMAIN);
 cfg.cred_info[0].scheme = pj_str("digest");
 cfg.cred_info[0].username = pj_str(SIP_USER);
 cfg.cred_info[0].data_type = PJSIP_CRED_DATA_PLAIN_PASSWD;
 cfg.cred_info[0].data = pj_str(SIP_PASSWD);

 status = pjsua_acc_add(&cfg, PJ_TRUE, &acc_id);
 if (status != PJ_SUCCESS) error_exit("Error adding account", status);
 }

 /* If URL is specified, make call to the URL. */
 if (argc > 1) {
 pj_str_t uri = pj_str(argv[1]);
 status = pjsua_call_make_call(acc_id, &uri, 0, NULL, NULL, NULL);
 if (status != PJ_SUCCESS) error_exit("Error making call", status);
 }

 /* Wait until user press "q" to quit. */
 for (;;) {
 char option[10];

 puts("Press 'h' to hangup all calls, 'q' to quit");
 if (fgets(option, sizeof(option), stdin) == NULL) {
 puts("EOF while reading stdin, will quit now..");
 break;
 }

 if (option[0] == 'q')
 break;

 if (option[0] == 'h')
 pjsua_call_hangup_all();
 }

 /* Destroy pjsua */
 pjsua_destroy();

 return 0;
}
Exemplo n.º 10
0
//----------------------------------------------------------------------
void SipPhone::hangUpAll()
{
    pjsua_call_hangup_all();
    finishIncoming();
}
Exemplo n.º 11
0
/*
 * main()
 *
 * argv[] contains the registration information.
 */
int main(int argc, char *argv[]) {
  pj_status_t status;
  int loglevel = 0;

  if (argc < 4) {
    usage(argv[0]);
    exit(1);
  }

  if (argc > 5){
    sscanf(argv[5], "%d", &loglevel);
  }

  pjsua_acc_id acc_id;

  /* Create pjsua first! */
  status = pjsua_create();
  if (status != PJ_SUCCESS) error_exit("Error in pjsua_create()", status);


  /* Init pjsua */
  {
    pjsua_config cfg;
    pjsua_logging_config log_cfg;
    pjsua_media_config media_cfg;

    // This will prevent the SIP stack from trying to switch to TCP.
    // It will prevent the stack from giving "Transport unavailable" errors.
    // http://trac.pjsip.org/repos/wiki/Using_SIP_TCP
    pjsip_cfg()->endpt.disable_tcp_switch = PJ_TRUE;

    pjsua_config_default(&cfg);
    cfg.cb.on_incoming_call    = &on_incoming_call;
    cfg.cb.on_call_media_state = &on_call_media_state;
    cfg.cb.on_call_state       = &on_call_state;
    cfg.cb.on_call_tsx_state   = &on_call_tsx_state;

    pjsua_logging_config_default(&log_cfg);
    log_cfg.console_level = loglevel; // 0 = Mute console, 3 = somewhat useful, 4 = overly verbose.
    pjsua_media_config_default(&media_cfg);

    status = pjsua_init(&cfg, &log_cfg, &media_cfg);
    if (status != PJ_SUCCESS) error_exit("Error in pjsua_init()", status);
  }
  /* Add UDP transport. */
  {
    pjsua_transport_config cfg;

    pjsua_transport_config_default(&cfg);
    sscanf(argv[4], "%d", &cfg.port);
    status = pjsua_transport_create(PJSIP_TRANSPORT_UDP, &cfg, NULL);
    if (status != PJ_SUCCESS) error_exit("Error creating transport", status);
    printf("Created UDP transport on port %d.\n", cfg.port);
  }

 /* Initialization is done, now start pjsua */
  status = pjsua_start();
  if (status != PJ_SUCCESS) error_exit("Error starting pjsua", status);

  /* Register to SIP server by creating SIP account. */
  {
    char reg_uri_buf[80] = "sip:";

    char uri_buf[80] = "sip:";
    pjsua_acc_config cfg;
    char* username = argv[1];
    char* password = argv[2];
    char* domain   = argv[3];

    strcat (uri_buf, username);
    strcat (reg_uri_buf, domain);

    strcat (uri_buf, "@");
    strcat (uri_buf, domain);

    pjsua_acc_config_default(&cfg);
    cfg.id = pj_str(uri_buf);

    printf("Registering: %.*s.\n", (int)cfg.id.slen, cfg.id.ptr);

    cfg.reg_uri = pj_str(reg_uri_buf);
    cfg.cred_count = 1;
    cfg.cred_info[0].realm = pj_str(domain);
    cfg.cred_info[0].scheme = pj_str("Digest");
    cfg.cred_info[0].username = pj_str(username);
    cfg.cred_info[0].data_type = PJSIP_CRED_DATA_PLAIN_PASSWD;
    cfg.cred_info[0].data = pj_str(password);
    cfg.register_on_acc_add = PJ_FALSE;


    status = pjsua_acc_add(&cfg, PJ_TRUE, &acc_id);
    if (status != PJ_SUCCESS) error_exit("Error adding account", status);

    or_event(OR_READY, "Agent initialized..");

  }

  /* Start by muting the audio device. This a passive agent, and sound
     is just wasted CPU time and uwanted side effects. */
  pjsua_set_null_snd_dev();
  fflush(stdout);
  /* Wait until user press "q" to quit. */
  for (;;) {
    char option[256];

    if (fgets(option, sizeof (option), stdin) == NULL) {
      or_status (OR_ERROR, "EOF while reading stdin, will quit now..");
      break;
    }

    /* Dial command. */
    if (option[0] == 'd') {
      pj_str_t uri = pj_str(&option[1]);
      status = pjsua_call_make_call(acc_id, &uri, 0, NULL, NULL, NULL);
      if (status != PJ_SUCCESS) {
        or_status (OR_ERROR, "Could not make call");
      }
      else {
        or_status (OR_OK, "Dialling...");
      }
    }

    /* Register */
    else if (option[0] == 'r') {
      register_account(acc_id);
    }

    /* Unregister */
    else if (option[0] == 'u') {
      unregister_account(acc_id);
    }

    /* Enable autoanswer */
    else if (option[0] == 'a') {
      if (option[1] == '1') {
        autoanswer[0] = true;
        or_status(OR_OK, "Autoanswer enabled.");
      } else {
        or_status(OR_ERROR, "Invalid account.");
      }
    }

    /* Disable autoanswer (manual answer) */
    else if (option[0] == 'm') {
      autoanswer[0] = false;
      or_status(OR_OK, "Autoanswer disabled.");
    }

    /* Pickup incoming call, unsupported for now. */
    else if (option[0] == 'p') {
      if (current_call != PJSUA_INVALID_ID) {
        pjsua_call_answer(current_call, 200, NULL, NULL);
        or_status(OR_OK, "Call picked up.");
      } else {
        or_status(OR_ERROR, "No call to pick up.");
      }
    }

    /* Hang up current call */
    else if (option[0] == 'H') {
      if (current_call != PJSUA_INVALID_ID) {
        pjsua_call_hangup (current_call, 0,NULL, NULL);
        or_status (OR_OK, "Hanging up current call...");
      } else {
        or_status(OR_ERROR, "No call to hang up.");
      }
    }

    /* Full hangup.. */
    else if (option[0] == 'h') {
      pjsua_call_hangup_all();
      or_status (OR_OK, "Hanging up all calls...");
    }

    /* Status  */
    else if (option[0] == 's') {
      or_dump_status();
    }

    /* Exit application. */
    else if (option[0] == 'q') {
      break;
    }

    else {
      or_status (OR_ERROR, "Unknown command:");
    }
  }
  pjsua_destroy();
  or_status (OR_OK, "Exiting...");

  return 0;
}
Exemplo n.º 12
0
//=============================================================================
void SIPConference::Leave () 
{ 
	VFVW_LOG("entering Leave()");
    pjsua_call_hangup_all(); 
}