Ejemplo n.º 1
0
/** UI Command **/
static void ui_make_new_call()
{
    char buf[128];
    pjsua_msg_data msg_data;
    input_result result;
    pj_str_t tmp;

    printf("(You currently have %d calls)\n", pjsua_call_get_count());

    ui_input_url("Make call", buf, sizeof(buf), &result);
    if (result.nb_result != PJSUA_APP_NO_NB) {

	if (result.nb_result == -1 || result.nb_result == 0) {
	    puts("You can't do that with make call!");
	    return;
	} else {
	    pjsua_buddy_info binfo;
	    pjsua_buddy_get_info(result.nb_result-1, &binfo);
	    tmp.ptr = buf;
	    pj_strncpy(&tmp, &binfo.uri, sizeof(buf));
	}

    } else if (result.uri_result) {
	tmp = pj_str(result.uri_result);
    } else {
	tmp.slen = 0;
    }

    pjsua_msg_data_init(&msg_data);
    TEST_MULTIPART(&msg_data);
    pjsua_call_make_call(current_acc, &tmp, &call_opt, NULL,
			 &msg_data, &current_call);
}
Ejemplo n.º 2
0
/**
 * \fn _ics_core_transfer_call()
 * \brief Chuyen huong cuoc goi
 * \param agr1: ics_t *data
 * agr2: int call_id_1
 * agr3: int call_id_2
 */
static void _ics_core_transfer_call(ics_t *data, int call_id_1, int call_id_2) {
#if 0
	if ( (call_id_1 != call_id_2) && pjsua_call_is_active(call_id_1) && pjsua_call_is_active(call_id_2) ) {
		pjsua_call_xfer_replaces(call_id_1, call_id_2, 0, NULL);
	}
	else
		printf("Cannot transfer call!\n");
#endif

	//For test only:
#if 1
	int i, max;
	pjsua_call_info ci;

	max = pjsua_call_get_count();
	printf("You have %d active call%s\n", max, (max>1?"s":""));

	for (i = 0; i < max; i++){	
		if (pjsua_call_is_active(i)) {
			pjsua_call_get_info(i, &ci);
			pjsua_call_xfer_replaces(current_call, ci.id, 0, NULL);
			break;
		}
	}
#endif
}
Ejemplo n.º 3
0
/*
 * Show a bit of help.
 */
static void keystroke_help()
{
    pjsua_acc_id acc_ids[16];
    unsigned count = PJ_ARRAY_SIZE(acc_ids);
    int i;

    printf(">>>>\n");

    pjsua_enum_accs(acc_ids, &count);

    printf("Account list:\n");
    for (i=0; i<(int)count; ++i)
	print_acc_status(acc_ids[i]);

    print_buddy_list();

    //puts("Commands:");
    puts("+=============================================================================+");
    puts("|       Call Commands:         |   Buddy, IM & Presence:  |     Account:      |");
    puts("|                              |                          |                   |");
    puts("|  m  Make new call            | +b  Add new buddy       .| +a  Add new accnt |");
    puts("|  M  Make multiple calls      | -b  Delete buddy         | -a  Delete accnt. |");
    puts("|  a  Answer call              |  i  Send IM              | !a  Modify accnt. |");
    puts("|  h  Hangup call  (ha=all)    |  s  Subscribe presence   | rr  (Re-)register |");
    puts("|  H  Hold call                |  u  Unsubscribe presence | ru  Unregister    |");
    puts("|  v  re-inVite (release hold) |  t  ToGgle Online status |  >  Cycle next ac.|");
    puts("|  U  send UPDATE              |  T  Set online status    |  <  Cycle prev ac.|");
    puts("| ],[ Select next/prev call    +--------------------------+-------------------+");
    puts("|  x  Xfer call                |      Media Commands:     |  Status & Config: |");
    puts("|  X  Xfer with Replaces       |                          |                   |");
    puts("|  #  Send RFC 2833 DTMF       | cl  List ports           |  d  Dump status   |");
    puts("|  *  Send DTMF with INFO      | cc  Connect port         | dd  Dump detailed |");
    puts("| dq  Dump curr. call quality  | cd  Disconnect port      | dc  Dump config   |");
    puts("|                              |  V  Adjust audio Volume  |  f  Save config   |");
    puts("|  S  Send arbitrary REQUEST   | Cp  Codec priorities     |                   |");
    puts("+-----------------------------------------------------------------------------+");
#if PJSUA_HAS_VIDEO
    puts("| Video: \"vid help\" for more info                                             |");
    puts("+-----------------------------------------------------------------------------+");
#endif
    puts("|  q  QUIT   L  ReLoad   sleep MS   echo [0|1|txt]     n: detect NAT type     |");
    puts("+=============================================================================+");

    i = pjsua_call_get_count();
    printf("You have %d active call%s\n", i, (i>1?"s":""));

    if (current_call != PJSUA_INVALID_ID) {
	pjsua_call_info ci;
	if (pjsua_call_get_info(current_call, &ci)==PJ_SUCCESS)
	    printf("Current call id=%d to %.*s [%.*s]\n", current_call,
		   (int)ci.remote_info.slen, ci.remote_info.ptr,
		   (int)ci.state_text.slen, ci.state_text.ptr);
    }
}
Ejemplo n.º 4
0
void _ics_core_list_call(ics_t *data) {
	int i, max;
	pjsua_call_info ci;

	max = pjsua_call_get_count();
	printf("Your call list:\n");
	for (i = 0; i < max; i++){	
		if (pjsua_call_is_active(i)) {
			pjsua_call_get_info(i, &ci);
			printf("Call id : %d to %.*s [%.*s]\n", ci.id,
					(int)ci.remote_info.slen, ci.remote_info.ptr,
					(int)ci.state_text.slen, ci.state_text.ptr);
		}
	}
	printf("Your current call id : %d\n", current_call);
}
Ejemplo n.º 5
0
Archivo: ics.c Proyecto: mocidis/ics
void _ics_list_call(ics_t *data) {
    int i, max;
    pjsua_call_info ci;

    PJ_UNUSED_ARG(data);
    max = pjsua_call_get_count();
    SHOW_LOG(3, "Your call list:\n");
    for (i = 0; i < max; i++){	
        if (pjsua_call_is_active(i)) {
            pjsua_call_get_info(i, &ci);
            SHOW_LOG(3, "Call id : %d to %.*s [%.*s]\n", ci.id,
                    (int)ci.remote_info.slen, ci.remote_info.ptr,
                    (int)ci.state_text.slen, ci.state_text.ptr);
        }
    }
    SHOW_LOG(3, "Your current call id : %d\n", current_call);
}
Ejemplo n.º 6
0
static void ui_make_multi_call()
{
    char menuin[32];
    int count;
    char buf[128];
    input_result result;
    pj_str_t tmp;
    int i;

    printf("(You currently have %d calls)\n", pjsua_call_get_count());

    if (!simple_input("Number of calls", menuin, sizeof(menuin)))
	return;

    count = my_atoi(menuin);
    if (count < 1)
	return;

    ui_input_url("Make call", buf, sizeof(buf), &result);
    if (result.nb_result != PJSUA_APP_NO_NB) {
	pjsua_buddy_info binfo;
	if (result.nb_result == -1 || result.nb_result == 0) {
	    puts("You can't do that with make call!");
	    return;
	}
	pjsua_buddy_get_info(result.nb_result-1, &binfo);
	tmp.ptr = buf;
	pj_strncpy(&tmp, &binfo.uri, sizeof(buf));
    } else {
	tmp = pj_str(result.uri_result);
    }

    for (i=0; i<my_atoi(menuin); ++i) {
	pj_status_t status;

	status = pjsua_call_make_call(current_acc, &tmp, &call_opt, NULL,
	    NULL, NULL);
	if (status != PJ_SUCCESS)
	    break;
    }
}
Ejemplo n.º 7
0
//----------------------------------------------------------------------
void SipPhone::incomingCallCb(pjsua_acc_id acc_id, pjsua_call_id call_id,
                              pjsip_rx_data *rdata)
{
    pjsua_call_info ci;

    PJ_UNUSED_ARG(acc_id);
    PJ_UNUSED_ARG(rdata);

    pjsua_call_get_info(call_id, &ci);

    if (pjsua_call_get_count() <= 1)
        Sound::getInstance().startRing();

    Call *call = new Call(self_, Call::TYPE_INCOMING);
    call->setCallId(call_id);
    call->setUrl(ci.remote_contact.ptr);
    call->setName(ci.remote_info.ptr);
    LogInfo info(LogInfo::STATUS_MESSAGE, "pjsip", 0, "Incoming Call");
    self_->signalLogData(info);

    self_->signalIncomingCall(call);
}
Ejemplo n.º 8
0
Archivo: ics.c Proyecto: mocidis/ics
static void _ics_conference_call(ics_t *data, int call_id) {
    int i, max;
    PJ_UNUSED_ARG(data);

    max = pjsua_call_get_count();
    SHOW_LOG(3, "Let's conference call!\n");
    pjsua_call_info ci;

#if 1
    if ( (call_id != current_call) && pjsua_call_is_active(call_id)  ) {
        pjsua_call_reinvite(call_id, PJ_TRUE, NULL);
        for (i = 0; i < max; i++) {
            if (pjsua_call_has_media(i) != 0) {
                pjsua_conf_connect(pjsua_call_get_conf_port(call_id), pjsua_call_get_conf_port(i));		
                pjsua_conf_connect(pjsua_call_get_conf_port(i), pjsua_call_get_conf_port(call_id));
            }
        }
    }
    else
        SHOW_LOG(3, "Cannot transfer call!\n");
#endif

    //For test only:
#if 1


    for (i = 0; i < max; i++){	
        if (pjsua_call_is_active(i) && (i != current_call)) {
            pjsua_call_reinvite(i, PJ_TRUE, NULL);
            pjsua_call_get_info(i, &ci);
            pjsua_conf_connect(pjsua_call_get_conf_port(ci.id), pjsua_call_get_conf_port(current_call));		
            pjsua_conf_connect(pjsua_call_get_conf_port(current_call), pjsua_call_get_conf_port(ci.id));
        }
        break;
    }
#endif

}