本文整理汇总了C++中pj_ansi_sprintf函数的典型用法代码示例。如果您正苦于以下问题:C++ pj_ansi_sprintf函数的具体用法?C++ pj_ansi_sprintf怎么用?C++ pj_ansi_sprintf使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了pj_ansi_sprintf函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例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;
}
示例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);
}
示例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;
}
示例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;
}
示例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);
}
}
示例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);
}
示例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;
}
示例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;
}
示例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);
}
示例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);
}
示例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]);
}
}
示例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);
}
示例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));
}
示例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");
}