Beispiel #1
0
static void ui_dump_call_quality()
{
    if (current_call != PJSUA_INVALID_ID) {
	log_call_dump(current_call);
    } else {
	PJ_LOG(3,(THIS_FILE, "No current call"));
    }
}
Beispiel #2
0
/*
 * Handler when invite state has changed.
 */
static void on_call_state(pjsua_call_id call_id, pjsip_event *e)
{
	pjsua_call_info call_info;

	PJ_UNUSED_ARG(e);

	pjsua_call_get_info(call_id, &call_info);

	if (call_info.state == PJSIP_INV_STATE_DISCONNECTED) {

		/* Cancel duration timer, if any */
		if (app_config.call_data[call_id].timer.id != PJSUA_INVALID_ID) {
				struct call_data *cd = &app_config.call_data[call_id];
				pjsip_endpoint *endpt = pjsua_get_pjsip_endpt();

				cd->timer.id = PJSUA_INVALID_ID;
				pjsip_endpt_cancel_timer(endpt, &cd->timer);
		}

		PJ_LOG(3,(THIS_FILE, "Call %d is DISCONNECTED [reason=%d (%s)]", 
				call_id,
				call_info.last_status,
				call_info.last_status_text.ptr));

		if (call_id == current_call) {
				find_next_call();
		}

		/* Dump media state upon disconnected */
		if (1) {
				PJ_LOG(5,(THIS_FILE, 
		      "Call %d disconnected, dumping media stats..", 
		      call_id));
	    log_call_dump(call_id);
		}

  } else {

		if (app_config.duration!=NO_LIMIT && 
				call_info.state == PJSIP_INV_STATE_CONFIRMED) 
		{
				/* Schedule timer to hangup call after the specified duration */
				struct call_data *cd = &app_config.call_data[call_id];
				pjsip_endpoint *endpt = pjsua_get_pjsip_endpt();
				pj_time_val delay;

				cd->timer.id = call_id;
				delay.sec = app_config.duration;
				delay.msec = 0;
				pjsip_endpt_schedule_timer(endpt, &cd->timer, &delay);
		}

		if (call_info.state == PJSIP_INV_STATE_EARLY) {
				int code;
				pj_str_t reason;
				pjsip_msg *msg;

				/* This can only occur because of TX or RX message */
				pj_assert(e->type == PJSIP_EVENT_TSX_STATE);

				if (e->body.tsx_state.type == PJSIP_EVENT_RX_MSG) {
					msg = e->body.tsx_state.src.rdata->msg_info.msg;
				} else {
					msg = e->body.tsx_state.src.tdata->msg;
				}

				code = msg->line.status.code;
				reason = msg->line.status.reason;

				PJ_LOG(3,(THIS_FILE, "Call %d state changed to %s (%d %.*s)", 
						call_id, call_info.state_text.ptr,
						code, (int)reason.slen, reason.ptr));
		} else {
				PJ_LOG(3,(THIS_FILE, "Call %d state changed to %s", 
						call_id,
						call_info.state_text.ptr));
		}

		if (current_call==PJSUA_INVALID_ID)
				current_call = call_id;
	}

	// callback
	if (cb_callstate != 0) cb_callstate(call_id, call_info.state);
}