Exemplo n.º 1
0
/*
 * Print log of call states. Since call states may be too long for logger,
 * printing it is a bit tricky, it should be printed part by part as long 
 * as the logger can accept.
 */
void log_call_dump(int call_id) 
{
    unsigned call_dump_len;
    unsigned part_len;
    unsigned part_idx;
    unsigned log_decor;

    pjsua_call_dump(call_id, PJ_TRUE, some_buf, sizeof(some_buf), "  ");
    call_dump_len = (unsigned)strlen(some_buf);

    log_decor = pj_log_get_decor();
    pj_log_set_decor(log_decor & ~(PJ_LOG_HAS_NEWLINE | PJ_LOG_HAS_CR));
    PJ_LOG(3,(THIS_FILE, "\n"));
    pj_log_set_decor(0);

    part_idx = 0;
    part_len = PJ_LOG_MAX_SIZE-80;
    while (part_idx < call_dump_len) {
	char p_orig, *p;

	p = &some_buf[part_idx];
	if (part_idx + part_len > call_dump_len)
	    part_len = call_dump_len - part_idx;
	p_orig = p[part_len];
	p[part_len] = '\0';
	PJ_LOG(3,(THIS_FILE, "%s", p));
	p[part_len] = p_orig;
	part_idx += part_len;
    }
    pj_log_set_decor(log_decor);
}
Exemplo n.º 2
0
 */PJ_DECL(pj_str_t) call_dump(pjsua_call_id call_id, pj_bool_t with_media,
		const char *indent) {
	char some_buf[1024 * 3];
	pj_status_t status = pjsua_call_dump(call_id, with_media, some_buf, sizeof(some_buf), indent);
	if(status != PJ_SUCCESS){
		return pj_strerror(status, some_buf, sizeof(some_buf));
	}
	return pj_str(some_buf);
}
Exemplo n.º 3
0
//Static
void PjsuaManager::OnCallState(pjsua_call_id call_id, pjsip_event *e)
{
	PjsuaManagerPtr manager = PjsuaManager::instance_.lock();

	if (!manager)
		return;

	pjsua_call_info info;
	pj_status_t status;
	if ((status = pjsua_call_get_info(call_id, &info)) == PJ_SUCCESS) 
	{
		std::string str = "PjsuaManager::OnCallState called with PJSIP call id: " + boost::lexical_cast<std::string>(call_id)+", state: " + boost::lexical_cast<std::string>(info.state);
		BlabbleLogging::blabbleLog(0, str.c_str(), 0);
		//BLABBLE_LOG_TRACE("PjsuaManager::OnCallState called with PJSIP call id: " << call_id << ", state: " << info.state);
		BlabbleAccountPtr acc = manager->FindAcc(info.acc_id);
		if (acc)
		{
			acc->OnCallState(call_id, e);
		}

		if (info.state == PJSIP_INV_STATE_DISCONNECTED)
		{
			// REITEK: Dump call statistics

			std::string dbgstr = "Dumping statistics for PJSIP call id: " + boost::lexical_cast<std::string>(call_id);
			BlabbleLogging::blabbleLog(0, dbgstr.c_str(), 0);

			char stats_buf[STATS_BUF_SIZE];
			memset(stats_buf, 0, STATS_BUF_SIZE);

			pjsua_call_dump(call_id, PJ_TRUE, stats_buf, STATS_BUF_SIZE, "  ");
			stats_buf[STATS_BUF_SIZE - 1] = '\0';

			BlabbleLogging::blabbleLog(0, stats_buf, 0);

			//Just make sure we get rid of the call
			pjsua_call_hangup(call_id, 0, NULL, NULL);
		}
	}
	else
	{
		std::string str = "PjsuaManager::OnCallState failed to call pjsua_call_get_info for PJSIP call id: " + boost::lexical_cast<std::string>(call_id)+", got status: " + boost::lexical_cast<std::string>(status);
		BlabbleLogging::blabbleLog(0, str.c_str(), 0);
		//BLABBLE_LOG_ERROR("PjsuaManager::OnCallState failed to call pjsua_call_get_info for PJSIP call id: " << call_id << ", got status: " << status);
	}
}
Exemplo n.º 4
0
/**
 * Get call infos
 */
PJ_DECL(pj_str_t) call_dump(pjsua_call_id call_id, pj_bool_t with_media, const char *indent){
	char some_buf[1024 * 3];
    pjsua_call_dump(call_id, with_media, some_buf,
		    sizeof(some_buf), indent);
    return pj_str(some_buf);
}
Exemplo n.º 5
0
void ScreenPhone::setNetworkRates()
{
    if(this->active_channel() == 1 && this->m_c1_call_id >= 0 && this->m_c1_state != "available")
    {
        static char c1_buffer[1024*1];
        pjsua_call_dump(this->m_c1_call_id, PJ_TRUE, c1_buffer, sizeof(c1_buffer), "  ");

        pjsua_call_info cinfo;
        pjsua_call_get_info(this->m_c1_call_id, &cinfo);

        if(!controller->telApi->has_srtp)
        {
            pjsua_stream_info stat;
            pjsua_call_get_stream_info(this->m_c1_call_id, cinfo.media[0].index, &stat);

            QString codec(stat.info.aud.fmt.encoding_name.ptr);
            codec = codec.mid(0,codec.indexOf("strm")).remove(QRegExp("[^a-zA-Z\\d\\s]"));

            pjsua_stream_stat stream_stat;
            pjsua_call_get_stream_stat(this->m_c1_call_id, cinfo.media[0].index, &stream_stat);

            this->m_c1_latency = QString::number(stream_stat.rtcp.rtt.last/1000);
            this->setC1_stream_info(codec.append("(").append(this->m_c1_latency).append(" ms) ").append(controller->telApi->m_transport.toUpper()));
        }
        else
        {
            this->setC1_stream_info("SRTP Encrypted Call");
        }

        QStringList qbuff = QString(c1_buffer).split("\n");

        //qDebug() << "RTT ::::: " << QString::number(stream_stat.rtcp.rtt.last);
        qDebug() << "RTT ::::: " << QString(c1_buffer);

        this->setC1_downrate(qbuff[5].mid(qbuff[5].indexOf("@avg=")+5).split('/')[1]);
        this->setC1_uprate(qbuff[11].mid(qbuff[11].indexOf("@avg=")+5).split('/')[1]);

        this->setC1_loss(qbuff[6].mid(qbuff[6].indexOf("loss=")+5).split(',')[0]);

        memset(&c1_buffer[0], 0, sizeof(c1_buffer));

        return;
    }

    if(this->active_channel() == 2 && this->m_c2_call_id >= 0 && this->m_c2_state != "available")
    {
        static char c2_buffer[1024*1];
        pjsua_call_dump(this->m_c2_call_id, PJ_TRUE, c2_buffer, sizeof(c2_buffer), "  ");

        pjsua_call_info cinfo;
        pjsua_call_get_info(this->m_c2_call_id, &cinfo);

        if(!controller->telApi->has_srtp)
        {
            pjsua_stream_info stat;
            pjsua_call_get_stream_info(this->m_c2_call_id, cinfo.media[0].index, &stat);

            QString codec(stat.info.aud.fmt.encoding_name.ptr);
            codec = codec.mid(0,codec.indexOf("strm")).remove(QRegExp("[^a-zA-Z\\d\\s]"));

            pjsua_stream_stat stream_stat;
            pjsua_call_get_stream_stat(this->m_c2_call_id, cinfo.media[0].index, &stream_stat);

            this->m_c2_latency = QString::number(stream_stat.rtcp.rtt.last/1000);
            this->setC2_stream_info(codec.append("(").append(this->m_c2_latency).append(" ms) ").append(controller->telApi->m_transport.toUpper()));
        }
        else
        {
            this->setC1_stream_info("SRTP Encrypted Call");
        }

        QStringList qbuff = QString(c2_buffer).split("\n");
        this->setC2_downrate(qbuff[5].mid(qbuff[5].indexOf("@avg=")+5).split('/')[1]);
        this->setC2_uprate(qbuff[11].mid(qbuff[11].indexOf("@avg=")+5).split('/')[1]);

        this->setC2_loss(qbuff[6].mid(qbuff[6].indexOf("loss=")+5).split(',')[0]);

        memset(&c2_buffer[0], 0, sizeof(c2_buffer));

        return;
    }

    this->m_c1_latency = "0";
    this->m_c2_latency = "0";

    this->setC1_downrate("0");
    this->setC1_uprate("0");
    this->setC2_downrate("0");
    this->setC2_uprate("0");
}