本文整理汇总了C++中pj_ansi_sprintf函数的典型用法代码示例。如果您正苦于以下问题:C++ pj_ansi_sprintf函数的具体用法?C++ pj_ansi_sprintf怎么用?C++ pj_ansi_sprintf使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了pj_ansi_sprintf函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: OnInitStack
//.........这里部分代码省略.........
cfg.outbound_proxy_cnt = 1;
cfg.outbound_proxy[0] = pj_str (SIP_PROXY);
}
if (NAMESERVER) {
cfg.nameserver_count = 1;
cfg.nameserver[0] = pj_str (NAMESERVER);
}
if (NAMESERVER && STUN_DOMAIN) {
cfg.stun_domain = pj_str (STUN_DOMAIN);
} else if (STUN_SERVER) {
cfg.stun_host = pj_str (STUN_SERVER);
}
/* Initialize pjsua */
status = pjsua_init (&cfg, &log_cfg, &media_cfg);
if (status != PJ_SUCCESS) {
OnError (TEXT ("Initialization error"), status);
return FALSE;
}
/* Set codec priority */
pjsua_codec_set_priority (pj_cstr (&tmp, "pcmu"), 240);
pjsua_codec_set_priority (pj_cstr (&tmp, "pcma"), 230);
pjsua_codec_set_priority (pj_cstr (&tmp, "speex/8000"), 190);
pjsua_codec_set_priority (pj_cstr (&tmp, "ilbc"), 189);
pjsua_codec_set_priority (pj_cstr (&tmp, "speex/16000"), 180);
pjsua_codec_set_priority (pj_cstr (&tmp, "speex/32000"), 0);
pjsua_codec_set_priority (pj_cstr (&tmp, "gsm"), 100);
/* Add UDP transport and the corresponding PJSUA account */
status = pjsua_transport_create (PJSIP_TRANSPORT_UDP,
&udp_cfg, &transport_id);
if (status != PJ_SUCCESS) {
OnError (TEXT ("Error starting SIP transport"), status);
return FALSE;
}
pjsua_transport_get_info (transport_id, &transport_info);
g_local_uri.ptr = (char*) pj_pool_alloc (g_pool, 128);
g_local_uri.slen = pj_ansi_sprintf (g_local_uri.ptr,
"<sip:%.*s:%d>",
(int) transport_info.local_name.host.slen,
transport_info.local_name.host.ptr,
transport_info.local_name.port);
/* Add local account */
pjsua_acc_add_local (transport_id, PJ_TRUE, &g_current_acc);
pjsua_acc_set_online_status (g_current_acc, PJ_TRUE);
/* Add account */
if (HAS_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_REALM);
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, &g_current_acc);
if (status != PJ_SUCCESS) {
pjsua_destroy();
return PJ_FALSE;
}
}
/* Add buddy */
if (SIP_DST_URI) {
pjsua_buddy_config bcfg;
pjsua_buddy_config_default (&bcfg);
bcfg.uri = pj_str (SIP_DST_URI);
bcfg.subscribe = PJ_FALSE;
pjsua_buddy_add (&bcfg, NULL);
}
/* Start pjsua */
status = pjsua_start();
if (status != PJ_SUCCESS) {
OnError (TEXT ("Error starting pjsua"), status);
return FALSE;
}
return TRUE;
}
开发者ID:max3903,项目名称:SFLphone,代码行数:101,代码来源:pjsua_wince.cpp
示例2: print_binary
static char* print_binary(const pj_uint8_t *data, unsigned data_len)
{
static char buf[1500];
unsigned length = sizeof(buf);
char *p = buf;
unsigned i;
for (i=0; i<data_len;) {
unsigned j;
pj_ansi_snprintf(p, 1500-(p-buf),
"%04d-%04d ",
i, (i+20 < data_len) ? i+20 : data_len);
p += 12;
for (j=0; j<20 && i<data_len && p<(buf+length-10); ++j, ++i) {
pj_ansi_sprintf(p, "%02x ", (*data) & 0xFF);
p += 3;
data++;
}
pj_ansi_sprintf(p, "\n");
p++;
}
return buf;
}
开发者ID:carlosdelfino,项目名称:WorkshopTelefoniaAutomacao,代码行数:27,代码来源:stun.c
示例3: PJ_DEF
/* Allocate memory from the pool */
PJ_DEF(void*) pj_pool_alloc_imp( const char *file, int line,
pj_pool_t *pool, pj_size_t sz)
{
struct pj_pool_mem *mem;
PJ_UNUSED_ARG(file);
PJ_UNUSED_ARG(line);
mem = malloc(sz + sizeof(struct pj_pool_mem));
if (!mem) {
if (pool->cb)
(*pool->cb)(pool, sz);
return NULL;
}
mem->next = pool->first_mem;
pool->first_mem = mem;
#ifdef TRACE_
{
char msg[120];
pj_ansi_sprintf(msg, "Mem %X (%d+%d bytes) allocated by %s:%d\r\n",
mem, sz, sizeof(struct pj_pool_mem),
file, line);
TRACE_(msg);
}
#endif
return ((char*)mem) + sizeof(struct pj_pool_mem);
}
开发者ID:deveck,项目名称:Deveck.TAM,代码行数:31,代码来源:pool_dbg.c
示例4: pj_ansi_sprintf
static const char *good_number(char *buf, pj_int32_t val)
{
if (val < 1000) {
pj_ansi_sprintf(buf, "%d", val);
} else if (val < 1000000) {
pj_ansi_sprintf(buf, "%d.%dK",
val / 1000,
(val % 1000) / 100);
} else {
pj_ansi_sprintf(buf, "%d.%02dM",
val / 1000000,
(val % 1000000) / 10000);
}
return buf;
}
开发者ID:max3903,项目名称:SFLphone,代码行数:16,代码来源:endpoint.c
示例5: tsx_basic_test
int tsx_basic_test(struct tsx_test_param *param)
{
int status;
pj_ansi_sprintf(TARGET_URI, "sip:[email protected]:%d;transport=%s",
param->port, param->tp_type);
pj_ansi_sprintf(FROM_URI, "sip:[email protected]:%d;transport=%s",
param->port, param->tp_type);
status = tsx_layer_test();
if (status != 0)
return status;
status = double_terminate();
if (status != 0)
return status;
return 0;
}
开发者ID:conght,项目名称:BLM-Lib,代码行数:19,代码来源:tsx_basic_test.c
示例6: close_report
static void close_report(void)
{
pj_ssize_t len;
if (fd_report) {
len = pj_ansi_sprintf(buf, "</TABLE>\n</BODY>\n</HTML>\n");
pj_file_write(fd_report, buf, &len);
pj_file_close(fd_report);
}
}
开发者ID:Agostin,项目名称:csipsimple,代码行数:11,代码来源:test.c
示例7: report_sval
void report_sval(const char *name, const char* value, const char *valname,
const char *desc)
{
pj_ssize_t len;
len = pj_ansi_sprintf(buf, " <TR><TD><TT>%s</TT></TD>\n"
" <TD align=\"right\"><B>%s %s</B></TD>\n"
" <TD>%s</TD>\n"
" </TR>\n",
name, value, valname, desc);
pj_file_write(fd_report, buf, &len);
}
开发者ID:Agostin,项目名称:csipsimple,代码行数:12,代码来源:test.c
示例8: print_binary
static int print_binary(char *buffer, unsigned length,
const pj_uint8_t *data, unsigned data_len)
{
unsigned i;
if (length < data_len * 2 + 8)
return -1;
pj_ansi_sprintf(buffer, ", data=");
buffer += 7;
for (i=0; i<data_len; ++i) {
pj_ansi_sprintf(buffer, "%02x", (*data) & 0xFF);
buffer += 2;
data++;
}
pj_ansi_sprintf(buffer, "\n");
buffer++;
return data_len * 2 + 8;
}
开发者ID:AGProjects,项目名称:python-sipsimple,代码行数:22,代码来源:stun_msg_dump.c
示例9: gui_start
pj_status_t gui_start(gui_menu *menu)
{
while (!console_quit) {
unsigned i;
char input[10], *p;
gui_menu *choice;
puts("M E N U :");
puts("---------");
for (i=0; i<menu->submenu_cnt; ++i) {
char menu_id[4];
pj_ansi_sprintf(menu_id, "%u", i);
print_menu("", menu_id, menu->submenus[i]);
}
puts("");
printf("Enter the menu number: ");
if (!fgets(input, sizeof(input), stdin))
break;
p = input;
choice = menu;
while (*p && *p!='\r' && *p!='\n') {
unsigned d = (*p - '0');
if (d < 0 || d >= choice->submenu_cnt) {
puts("Invalid selection");
choice = NULL;
break;
}
choice = choice->submenus[d];
++p;
}
if (choice && *p!='\r' && *p!='\n') {
puts("Invalid characters entered");
continue;
}
if (choice && choice->handler)
(*choice->handler)();
}
return PJ_SUCCESS;
}
开发者ID:DouglasHeriot,项目名称:pjproject,代码行数:45,代码来源:main_console.c
示例10: cmd_name_exists
/* Check if command already added to command hash */
static pj_bool_t cmd_name_exists(pj_cli_t *cli, pj_cli_cmd_spec *group,
pj_str_t *cmd)
{
pj_str_t cmd_val;
char cmd_ptr[64];
cmd_val.ptr = &cmd_ptr[0];
cmd_val.slen = 0;
if (group) {
char cmd_str[16];
pj_ansi_sprintf(&cmd_str[0], "%d", group->id);
pj_strcat2(&cmd_val, &cmd_str[0]);
}
pj_strcat(&cmd_val, cmd);
return (pj_hash_get(cli->cmd_name_hash,
cmd_val.ptr, cmd_val.slen, NULL) != 0);
}
开发者ID:ClearwaterCore,项目名称:pjsip-upstream,代码行数:19,代码来源:cli.c
示例11: pj_ansi_sprintf
/* Get the command from the command hash */
static pj_cli_cmd_spec *get_cmd_name(const pj_cli_t *cli,
const pj_cli_cmd_spec *group,
const pj_str_t *cmd)
{
pj_str_t cmd_val;
char cmd_ptr[MAX_CMD_HASH_NAME_LENGTH];
cmd_val.ptr = cmd_ptr;
cmd_val.slen = 0;
if (group) {
char cmd_str[MAX_CMD_ID_LENGTH];
pj_ansi_sprintf(cmd_str, "%d", group->id);
pj_strcat2(&cmd_val, cmd_str);
}
pj_strcat(&cmd_val, cmd);
return (pj_cli_cmd_spec *)pj_hash_get(cli->cmd_name_hash, cmd_val.ptr,
(unsigned)cmd_val.slen, NULL);
}
开发者ID:Jetsly,项目名称:pjsip-csharp,代码行数:20,代码来源:cli.c
示例12: print_menu
static void print_menu(const char *indent, char *menu_id, gui_menu *menu)
{
char child_indent[16];
unsigned i;
pj_ansi_snprintf(child_indent, sizeof(child_indent), "%s ", indent);
printf("%s%s: %s\n", indent, menu_id, menu->title);
for (i=0; i<menu->submenu_cnt; ++i) {
char child_id[10];
pj_ansi_sprintf(child_id, "%s%u", menu_id, i);
if (!menu->submenus[i])
puts("");
else
print_menu(child_indent, child_id, menu->submenus[i]);
}
}
开发者ID:DouglasHeriot,项目名称:pjproject,代码行数:20,代码来源:main_console.c
示例13: add_cmd_name
/* Add command to the command hash */
static void add_cmd_name(pj_cli_t *cli, pj_cli_cmd_spec *group,
pj_cli_cmd_spec *cmd, pj_str_t *cmd_name)
{
pj_str_t cmd_val;
pj_str_t add_cmd;
char cmd_ptr[MAX_CMD_HASH_NAME_LENGTH];
cmd_val.ptr = cmd_ptr;
cmd_val.slen = 0;
if (group) {
char cmd_str[MAX_CMD_ID_LENGTH];
pj_ansi_sprintf(cmd_str, "%d", group->id);
pj_strcat2(&cmd_val, cmd_str);
}
pj_strcat(&cmd_val, cmd_name);
pj_strdup(cli->pool, &add_cmd, &cmd_val);
pj_hash_set(cli->pool, cli->cmd_name_hash, cmd_val.ptr,
(unsigned)cmd_val.slen, 0, cmd);
}
开发者ID:Jetsly,项目名称:pjsip-csharp,代码行数:22,代码来源:cli.c
示例14: on_send_data
static void on_send_data(pj_http_req *hreq,
void **data, pj_size_t *size)
{
char *sdata;
pj_size_t sendsz = 8397;
PJ_UNUSED_ARG(hreq);
if (send_size + sendsz > total_size) {
sendsz = total_size - send_size;
}
send_size += sendsz;
sdata = (char*)pj_pool_alloc(pool, sendsz);
pj_create_random_string(sdata, sendsz);
pj_ansi_sprintf(sdata, "\nSegment #%d\n", ++counter);
*data = sdata;
*size = sendsz;
PJ_LOG(5, (THIS_FILE, "\nSending data progress: %d out of %d bytes",
send_size, total_size));
}
开发者ID:Archipov,项目名称:android-client,代码行数:22,代码来源:http_client.c
示例15: default_config
/* Set default config. */
static void default_config(struct app_config *cfg)
{
char tmp[80];
unsigned i;
pjsua_config_default(&cfg->cfg);
pj_ansi_sprintf(tmp, "Sipek on PJSUA v%s/%s", pj_get_version(), PJ_OS_NAME);
pj_strdup2_with_null(app_config.pool, &cfg->cfg.user_agent, tmp);
pjsua_logging_config_default(&cfg->log_cfg);
pjsua_media_config_default(&cfg->media_cfg);
pjsua_transport_config_default(&cfg->udp_cfg);
cfg->udp_cfg.port = 5060;
pjsua_transport_config_default(&cfg->rtp_cfg);
cfg->rtp_cfg.port = 4000;
cfg->duration = NO_LIMIT;
cfg->wav_id = PJSUA_INVALID_ID;
cfg->rec_id = PJSUA_INVALID_ID;
cfg->wav_port = PJSUA_INVALID_ID;
cfg->rec_port = PJSUA_INVALID_ID;
cfg->mic_level = cfg->speaker_level = 1.0;
cfg->capture_dev = PJSUA_INVALID_ID;
cfg->playback_dev = PJSUA_INVALID_ID;
cfg->capture_lat = PJMEDIA_SND_DEFAULT_REC_LATENCY;
cfg->playback_lat = PJMEDIA_SND_DEFAULT_PLAY_LATENCY;
cfg->ringback_slot = PJSUA_INVALID_ID;
cfg->ring_slot = PJSUA_INVALID_ID;
for (i=0; i<PJ_ARRAY_SIZE(cfg->acc_cfg); ++i)
pjsua_acc_config_default(&cfg->acc_cfg[i]);
for (i=0; i<PJ_ARRAY_SIZE(cfg->buddy_cfg); ++i)
pjsua_buddy_config_default(&cfg->buddy_cfg[i]);
cfg->log_cfg.log_filename = pj_str("pjsip.log");
}
开发者ID:deveck,项目名称:Deveck.TAM,代码行数:37,代码来源:pjsipDll_mobile.cpp
示例16: conf_list
/*
* List the ports in conference bridge
*/
static void conf_list(pjmedia_conf *conf, int detail)
{
enum { MAX_PORTS = 32 };
unsigned i, count;
pjmedia_conf_port_info info[MAX_PORTS];
printf("Conference ports:\n");
count = PJ_ARRAY_SIZE(info);
pjmedia_conf_get_ports_info(conf, &count, info);
for (i=0; i<count; ++i) {
char txlist[4*MAX_PORTS];
unsigned j;
pjmedia_conf_port_info *port_info = &info[i];
txlist[0] = '\0';
for (j=0; j<port_info->listener_cnt; ++j) {
char s[10];
pj_ansi_sprintf(s, "#%d ", port_info->listener_slots[j]);
pj_ansi_strcat(txlist, s);
}
if (txlist[0] == '\0') {
txlist[0] = '-';
txlist[1] = '\0';
}
if (!detail) {
printf("Port #%02d %-25.*s transmitting to: %s\n",
port_info->slot,
(int)port_info->name.slen,
port_info->name.ptr,
txlist);
} else {
unsigned tx_level, rx_level;
pjmedia_conf_get_signal_level(conf, port_info->slot,
&tx_level, &rx_level);
printf("Port #%02d:\n"
" Name : %.*s\n"
" Sampling rate : %d Hz\n"
" Samples per frame : %d\n"
" Frame time : %d ms\n"
" Signal level adjustment : tx=%d, rx=%d\n"
" Current signal level : tx=%u, rx=%u\n"
" Transmitting to ports : %s\n\n",
port_info->slot,
(int)port_info->name.slen,
port_info->name.ptr,
port_info->clock_rate,
port_info->samples_per_frame,
port_info->samples_per_frame*1000/port_info->clock_rate,
port_info->tx_adj_level,
port_info->rx_adj_level,
tx_level,
rx_level,
txlist);
}
}
puts("");
}
开发者ID:Archipov,项目名称:android-client,代码行数:68,代码来源:confsample.c
示例17: on_rx_request
static pj_bool_t on_rx_request( pjsip_rx_data *rdata )
{
pj_sockaddr hostaddr;
char temp[80], hostip[PJ_INET6_ADDRSTRLEN];
pj_str_t local_uri;
pjsip_dialog *dlg;
pjsip_rdata_sdp_info *sdp_info;
pjmedia_sdp_session *answer = NULL;
pjsip_tx_data *tdata = NULL;
call_t *call = NULL;
unsigned i;
pj_status_t status;
PJ_LOG(3,(THIS_FILE, "RX %.*s from %s",
(int)rdata->msg_info.msg->line.req.method.name.slen,
rdata->msg_info.msg->line.req.method.name.ptr,
rdata->pkt_info.src_name));
if (rdata->msg_info.msg->line.req.method.id == PJSIP_REGISTER_METHOD) {
/* Let me be a registrar! */
pjsip_hdr hdr_list, *h;
pjsip_msg *msg;
int expires = -1;
pj_list_init(&hdr_list);
msg = rdata->msg_info.msg;
h = (pjsip_hdr*)pjsip_msg_find_hdr(msg, PJSIP_H_EXPIRES, NULL);
if (h) {
expires = ((pjsip_expires_hdr*)h)->ivalue;
pj_list_push_back(&hdr_list, pjsip_hdr_clone(rdata->tp_info.pool, h));
PJ_LOG(3,(THIS_FILE, " Expires=%d", expires));
}
if (expires != 0) {
h = (pjsip_hdr*)pjsip_msg_find_hdr(msg, PJSIP_H_CONTACT, NULL);
if (h)
pj_list_push_back(&hdr_list, pjsip_hdr_clone(rdata->tp_info.pool, h));
}
pjsip_endpt_respond(app.sip_endpt, &mod_sipecho, rdata, 200, NULL,
&hdr_list, NULL, NULL);
return PJ_TRUE;
}
if (rdata->msg_info.msg->line.req.method.id != PJSIP_INVITE_METHOD) {
if (rdata->msg_info.msg->line.req.method.id != PJSIP_ACK_METHOD) {
pj_str_t reason = pj_str("Go away");
pjsip_endpt_respond_stateless( app.sip_endpt, rdata,
400, &reason,
NULL, NULL);
}
return PJ_TRUE;
}
sdp_info = pjsip_rdata_get_sdp_info(rdata);
if (!sdp_info || !sdp_info->sdp) {
pj_str_t reason = pj_str("Require valid offer");
pjsip_endpt_respond_stateless( app.sip_endpt, rdata,
400, &reason,
NULL, NULL);
}
for (i=0; i<MAX_CALLS; ++i) {
if (app.call[i].inv == NULL) {
call = &app.call[i];
break;
}
}
if (i==MAX_CALLS) {
pj_str_t reason = pj_str("We're full");
pjsip_endpt_respond_stateless( app.sip_endpt, rdata,
PJSIP_SC_BUSY_HERE, &reason,
NULL, NULL);
return PJ_TRUE;
}
/* Generate Contact URI */
status = pj_gethostip(AF, &hostaddr);
if (status != PJ_SUCCESS) {
app_perror(THIS_FILE, "Unable to retrieve local host IP", status);
return PJ_TRUE;
}
pj_sockaddr_print(&hostaddr, hostip, sizeof(hostip), 2);
pj_ansi_sprintf(temp, "<sip:[email protected]%s:%d>", hostip, SIP_PORT);
local_uri = pj_str(temp);
status = pjsip_dlg_create_uas( pjsip_ua_instance(), rdata,
&local_uri, &dlg);
if (status == PJ_SUCCESS)
answer = create_answer(call-app.call, dlg->pool, sdp_info->sdp);
if (status == PJ_SUCCESS)
status = pjsip_inv_create_uas( dlg, rdata, answer, 0, &call->inv);
if (status == PJ_SUCCESS)
status = pjsip_inv_initial_answer(call->inv, rdata, 100,
NULL, NULL, &tdata);
if (status == PJ_SUCCESS)
status = pjsip_inv_send_msg(call->inv, tdata);
if (status == PJ_SUCCESS)
//.........这里部分代码省略.........
开发者ID:xhook,项目名称:asterisk-v11,代码行数:101,代码来源:sipecho.c
示例18: server_thread
static int server_thread(void *p)
{
struct server_t *srv = (struct server_t*)p;
char *pkt = (char*)pj_pool_alloc(pool, srv->buf_size);
pj_sock_t newsock = PJ_INVALID_SOCKET;
while (!thread_quit) {
pj_ssize_t pkt_len;
int rc;
pj_fd_set_t rset;
pj_time_val timeout = {0, 500};
while (!thread_quit) {
PJ_FD_ZERO(&rset);
PJ_FD_SET(srv->sock, &rset);
rc = pj_sock_select((int)srv->sock+1, &rset, NULL, NULL, &timeout);
if (rc != 1) {
continue;
}
rc = pj_sock_accept(srv->sock, &newsock, NULL, NULL);
if (rc == PJ_SUCCESS) {
break;
}
}
if (thread_quit)
break;
while (!thread_quit) {
PJ_FD_ZERO(&rset);
PJ_FD_SET(newsock, &rset);
rc = pj_sock_select((int)newsock+1, &rset, NULL, NULL, &timeout);
if (rc != 1) {
PJ_LOG(3,("http test", "client timeout"));
continue;
}
pkt_len = srv->buf_size;
rc = pj_sock_recv(newsock, pkt, &pkt_len, 0);
if (rc == PJ_SUCCESS) {
break;
}
}
if (thread_quit)
break;
/* Simulate network RTT */
pj_thread_sleep(50);
if (srv->action == ACTION_IGNORE) {
continue;
} else if (srv->action == ACTION_REPLY) {
pj_size_t send_size = 0;
unsigned ctr = 0;
pj_ansi_sprintf(pkt, "HTTP/1.0 200 OK\r\n");
if (srv->send_content_length) {
pj_ansi_sprintf(pkt + pj_ansi_strlen(pkt),
"Content-Length: %d\r\n",
srv->data_size);
}
pj_ansi_sprintf(pkt + pj_ansi_strlen(pkt), "\r\n");
pkt_len = pj_ansi_strlen(pkt);
rc = pj_sock_send(newsock, pkt, &pkt_len, 0);
if (rc != PJ_SUCCESS) {
pj_sock_close(newsock);
continue;
}
while (send_size < srv->data_size) {
pkt_len = srv->data_size - send_size;
if (pkt_len > (signed)srv->buf_size)
pkt_len = srv->buf_size;
send_size += pkt_len;
pj_create_random_string(pkt, pkt_len);
pj_ansi_sprintf(pkt, "\nPacket: %d", ++ctr);
pkt[pj_ansi_strlen(pkt)] = '\n';
rc = pj_sock_send(newsock, pkt, &pkt_len, 0);
if (rc != PJ_SUCCESS)
break;
}
pj_sock_close(newsock);
}
}
return 0;
}
开发者ID:Archipov,项目名称:android-client,代码行数:87,代码来源:http_client.c
示例19: uri_test
int uri_test(void)
{
enum { COUNT = 1, DETECT=0, PARSE=1, PRINT=2 };
struct {
unsigned parse;
unsigned print;
unsigned cmp;
} run[COUNT];
unsigned i, max;
pj_ssize_t avg_len;
char desc[200];
pj_status_t status;
status = simple_uri_test();
if (status != PJ_SUCCESS)
return status;
#if INCLUDE_BENCHMARKS
for (i=0; i<COUNT; ++i) {
PJ_LOG(3,(THIS_FILE, " benchmarking (%d of %d)...", i+1, COUNT));
status = uri_benchmark(&run[i].parse, &run[i].print, &run[i].cmp);
if (status != PJ_SUCCESS)
return status;
}
/* Calculate average URI length */
for (i=0, avg_len=0; i<PJ_ARRAY_SIZE(uri_test_array); ++i) {
avg_len += uri_test_array[i].len;
}
avg_len /= PJ_ARRAY_SIZE(uri_test_array);
/*
* Print maximum parse/sec
*/
for (i=0, max=0; i<COUNT; ++i)
if (run[i].parse > max) max = run[i].parse;
PJ_LOG(3,("", " Maximum URI parse/sec=%u", max));
pj_ansi_sprintf(desc, "Number of SIP/TEL URIs that can be <B>parsed</B> with "
"<tt>pjsip_parse_uri()</tt> per second "
"(tested with %d URI set, with average length of "
"%d chars)",
(int)PJ_ARRAY_SIZE(uri_test_array), (int)avg_len);
report_ival("uri-parse-per-sec", max, "URI/sec", desc);
/* URI parsing bandwidth */
report_ival("uri-parse-bandwidth-mb", (int)avg_len*max/1000000, "MB/sec",
"URI parsing bandwidth in megabytes (number of megabytes "
"worth of URI that can be parsed per second)");
/* Print maximum print/sec */
for (i=0, max=0; i<COUNT; ++i)
if (run[i].print > max) max = run[i].print;
PJ_LOG(3,("", " Maximum URI print/sec=%u", max));
pj_ansi_sprintf(desc, "Number of SIP/TEL URIs that can be <B>printed</B> with "
"<tt>pjsip_uri_print()</tt> per second "
"(tested with %d URI set, with average length of "
"%d chars)",
(int)PJ_ARRAY_SIZE(uri_test_array), (int)avg_len);
report_ival("uri-print-per-sec", max, "URI/sec", desc);
/* Print maximum detect/sec */
for (i=0, max=0; i<COUNT; ++i)
if (run[i].cmp > max) max = run[i].cmp;
PJ_LOG(3,("", " Maximum URI comparison/sec=%u", max));
pj_ansi_sprintf(desc, "Number of SIP/TEL URIs that can be <B>compared</B> with "
"<tt>pjsip_uri_cmp()</tt> per second "
"(tested with %d URI set, with average length of "
"%d chars)",
(int)PJ_ARRAY_SIZE(uri_test_array), (int)avg_len);
report_ival("uri-cmp-per-sec", max, "URI/sec", desc);
#endif /* INCLUDE_BENCHMARKS */
return PJ_SUCCESS;
}
开发者ID:Netrounds,项目名称:pjproject-old,代码行数:86,代码来源:uri_test.c
示例20: uas_tsx_bench
static int uas_tsx_bench(unsigned working_set, pj_timestamp *p_elapsed)
{
unsigned i;
pjsip_tx_data *request;
pjsip_via_hdr *via;
pjsip_rx_data rdata;
pj_sockaddr_in remote;
pjsip_transaction **tsx;
pj_timestamp t1, t2, elapsed;
char branch_buf[80] = PJSIP_RFC3261_BRANCH_ID "0000000000";
pj_status_t status;
/* Create the request first. */
pj_str_t str_target = pj_str("sip:[email protected]");
pj_str_t str_from = pj_str("\"Local User\" <sip:[email protected]>");
pj_str_t str_to = pj_str("\"Remote User\" <sip:[email protected]>");
pj_str_t str_contact = str_from;
status = pjsip_endpt_create_request(endpt, &pjsip_invite_method,
&str_target, &str_from, &str_to,
&str_contact, NULL, -1, NULL,
&request);
if (status != PJ_SUCCESS) {
app_perror(" error: unable to create request", status);
return status;
}
/* Create Via */
via = pjsip_via_hdr_create(request->pool);
via->sent_by.host = pj_str("192.168.0.7");
via->sent_by.port = 5061;
via->transport = pj_str("udp");
via->rport_param = 1;
via->recvd_param = pj_str("192.168.0.7");
pjsip_msg_insert_first_hdr(request->msg, (pjsip_hdr*)via);
/* Create "dummy" rdata from the tdata */
pj_bzero(&rdata, sizeof(pjsip_rx_data));
rdata.tp_info.pool = request->pool;
rdata.msg_info.msg = request->msg;
rdata.msg_info.from = (pjsip_from_hdr*) pjsip_msg_find_hdr(request->msg, PJSIP_H_FROM, NULL);
rdata.msg_info.to = (pjsip_to_hdr*) pjsip_msg_find_hdr(request->msg, PJSIP_H_TO, NULL);
rdata.msg_info.cseq = (pjsip_cseq_hdr*) pjsip_msg_find_hdr(request->msg, PJSIP_H_CSEQ, NULL);
rdata.msg_info.cid = (pjsip_cid_hdr*) pjsip_msg_find_hdr(request->msg, PJSIP_H_FROM, NULL);
rdata.msg_info.via = via;
pj_sockaddr_in_init(&remote, 0, 0);
status = pjsip_endpt_acquire_transport(endpt, PJSIP_TRANSPORT_LOOP_DGRAM,
&remote, sizeof(pj_sockaddr_in),
NULL, &rdata.tp_info.transport);
if (status != PJ_SUCCESS) {
app_perror(" error: unable to get loop transport", status);
return status;
}
/* Create transaction array */
tsx = (pjsip_transaction**) pj_pool_zalloc(request->pool, working_set * sizeof(pj_pool_t*));
pj_bzero(&mod_tsx_user, sizeof(mod_tsx_user));
mod_tsx_user.id = -1;
/* Benchmark */
elapsed.u64 = 0;
pj_get_timestamp(&t1);
for (i=0; i<working_set; ++i) {
via->branch_param.ptr = branch_buf;
via->branch_param.slen = PJSIP_RFC3261_BRANCH_LEN +
pj_ansi_sprintf(branch_buf+PJSIP_RFC3261_BRANCH_LEN,
"-%d", i);
status = pjsip_tsx_create_uas(&mod_tsx_user, &rdata, &tsx[i]);
if (status != PJ_SUCCESS)
goto on_error;
}
pj_get_timestamp(&t2);
pj_sub_timestamp(&t2, &t1);
pj_add_timestamp(&elapsed, &t2);
p_elapsed->u64 = elapsed.u64;
status = PJ_SUCCESS;
on_error:
for (i=0; i<working_set; ++i) {
if (tsx[i]) {
pjsip_tsx_terminate(tsx[i], 601);
tsx[i] = NULL;
}
}
pjsip_tx_data_dec_ref(request);
flush_events(2000);
return status;
}
开发者ID:max3903,项目名称:SFLphone,代码行数:95,代码来源:tsx_bench.c
注:本文中的pj_ansi_sprintf函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论