Replace unsafe string functions such as sprintf, strcpy with the safer counterparts e.g. snprintf, strxcpy
This commit is contained in:
parent
6f93c61854
commit
7a058dee81
|
@ -45,18 +45,20 @@ static char *sha1_test_results[] = {
|
|||
|
||||
|
||||
static void digest_to_hex(const pj_uint8_t digest[PJ_SHA1_DIGEST_SIZE],
|
||||
char *output)
|
||||
char *output, int output_size)
|
||||
{
|
||||
int i,j;
|
||||
char *c = output;
|
||||
|
||||
for (i = 0; i < PJ_SHA1_DIGEST_SIZE/4; i++) {
|
||||
for (j = 0; j < 4; j++) {
|
||||
sprintf(c,"%02X", digest[i*4+j] & 0xFF);
|
||||
for (i = 0; i < PJ_SHA1_DIGEST_SIZE/4 && output_size >= 2; i++) {
|
||||
for (j = 0; j < 4 && output_size >= 3; j++) {
|
||||
pj_ansi_snprintf(c, output_size, "%02X", digest[i*4+j] & 0xFF);
|
||||
c += 2;
|
||||
output_size -= 2;
|
||||
}
|
||||
sprintf(c, " ");
|
||||
pj_ansi_snprintf(c, output_size, " ");
|
||||
c += 1;
|
||||
output_size -= 1;
|
||||
}
|
||||
*(c - 1) = '\0';
|
||||
}
|
||||
|
@ -78,7 +80,7 @@ static int sha1_test1(void)
|
|||
pj_sha1_update(&context, (pj_uint8_t*)sha1_test_data[k],
|
||||
pj_ansi_strlen(sha1_test_data[k]));
|
||||
pj_sha1_final(&context, digest);
|
||||
digest_to_hex(digest, output);
|
||||
digest_to_hex(digest, output, sizeof(output));
|
||||
|
||||
if (pj_ansi_strcmp(output, sha1_test_results[k])) {
|
||||
PJ_LOG(3, (THIS_FILE, " incorrect hash result on k=%d", k));
|
||||
|
@ -91,7 +93,7 @@ static int sha1_test1(void)
|
|||
for (k = 0; k < MILLION; k++)
|
||||
pj_sha1_update(&context, (pj_uint8_t*)"a", 1);
|
||||
pj_sha1_final(&context, digest);
|
||||
digest_to_hex(digest, output);
|
||||
digest_to_hex(digest, output, sizeof(output));
|
||||
if (strcmp(output, sha1_test_results[2])) {
|
||||
PJ_LOG(3, (THIS_FILE, " incorrect hash result!"));
|
||||
return -20;
|
||||
|
@ -105,7 +107,7 @@ static int sha1_test1(void)
|
|||
pj_sha1_init(&context);
|
||||
pj_sha1_update(&context, block, MILLION);
|
||||
pj_sha1_final(&context, digest);
|
||||
digest_to_hex(digest, output);
|
||||
digest_to_hex(digest, output, sizeof(output));
|
||||
if (strcmp(output, sha1_test_results[2])) {
|
||||
pj_pool_release(pool);
|
||||
PJ_LOG(3, (THIS_FILE, " incorrect hash result for block update!"));
|
||||
|
@ -182,7 +184,7 @@ static int sha1_test2(void)
|
|||
|
||||
pj_sha1_final(&sha, digest);
|
||||
|
||||
digest_to_hex(digest, char_digest);
|
||||
digest_to_hex(digest, char_digest, sizeof(char_digest));
|
||||
if (pj_ansi_strcmp(char_digest, resultarray[i])) {
|
||||
PJ_LOG(3, (THIS_FILE, " digest mismatch in test %d", i));
|
||||
return -40;
|
||||
|
|
|
@ -116,14 +116,24 @@ static int server_thread(void *p)
|
|||
} else if (srv->action == ACTION_REPLY) {
|
||||
pj_size_t send_len = 0;
|
||||
unsigned ctr = 0;
|
||||
pj_ansi_sprintf(pkt, "HTTP/1.0 200 OK\r\n");
|
||||
pkt_len = pj_ansi_snprintf(pkt, srv->buf_size,
|
||||
"HTTP/1.0 200 OK\r\n");
|
||||
PJ_ASSERT_ON_FAIL(pkt_len>0, {
|
||||
PJ_PERROR(2, (THIS_FILE, -pkt_len, "Error creating response"));
|
||||
pj_sock_close(newsock);
|
||||
continue;
|
||||
})
|
||||
if (srv->send_content_length) {
|
||||
pj_ansi_sprintf(pkt + pj_ansi_strlen(pkt),
|
||||
pj_ansi_snprintf(pkt + pkt_len, srv->buf_size - pkt_len,
|
||||
"Content-Length: %d\r\n",
|
||||
srv->data_size);
|
||||
}
|
||||
pj_ansi_sprintf(pkt + pj_ansi_strlen(pkt), "\r\n");
|
||||
pkt_len = pj_ansi_strlen(pkt);
|
||||
pkt_len = pj_ansi_strxcat(pkt, "\r\n", srv->buf_size);
|
||||
if (pkt_len < 0) {
|
||||
PJ_PERROR(2, (THIS_FILE, -pkt_len, "Error creating response"));
|
||||
pj_sock_close(newsock);
|
||||
continue;
|
||||
}
|
||||
rc = pj_sock_send(newsock, pkt, &pkt_len, 0);
|
||||
if (rc != PJ_SUCCESS) {
|
||||
pj_sock_close(newsock);
|
||||
|
@ -135,7 +145,7 @@ static int server_thread(void *p)
|
|||
pkt_len = srv->buf_size;
|
||||
send_len += pkt_len;
|
||||
pj_create_random_string(pkt, pkt_len);
|
||||
pj_ansi_sprintf(pkt, "\nPacket: %d", ++ctr);
|
||||
pj_ansi_snprintf(pkt, srv->buf_size, "\nPacket: %d", ++ctr);
|
||||
pkt[pj_ansi_strlen(pkt)] = '\n';
|
||||
rc = pj_sock_send(newsock, pkt, &pkt_len, 0);
|
||||
if (rc != PJ_SUCCESS)
|
||||
|
@ -176,7 +186,7 @@ static void on_send_data(pj_http_req *hreq,
|
|||
|
||||
sdata = (char*)pj_pool_alloc(pool, sendsz);
|
||||
pj_create_random_string(sdata, sendsz);
|
||||
pj_ansi_sprintf(sdata, "\nSegment #%d\n", ++counter);
|
||||
pj_ansi_snprintf(sdata, sendsz, "\nSegment #%d\n", ++counter);
|
||||
*data = sdata;
|
||||
*size = sendsz;
|
||||
|
||||
|
@ -688,7 +698,7 @@ int http_client_test_put1()
|
|||
pj_strset2(¶m.method, (char*)"PUT");
|
||||
data = (char*)pj_pool_alloc(pool, length);
|
||||
pj_create_random_string(data, length);
|
||||
pj_ansi_sprintf(data, "PUT test\n");
|
||||
pj_ansi_snprintf(data, length, "PUT test\n");
|
||||
param.reqdata.data = data;
|
||||
param.reqdata.size = length;
|
||||
if (pj_http_req_create(pool, &url, timer_heap, ioqueue,
|
||||
|
|
|
@ -1797,7 +1797,7 @@ static void action3_1(const pj_dns_parsed_packet *pkt,
|
|||
res->ans[i].rdata.srv.port = (pj_uint16_t)(PORT3+i);
|
||||
|
||||
target = (char*)pj_pool_alloc(pool, 16);
|
||||
sprintf(target, "sip%02d." DOMAIN3, i);
|
||||
pj_ansi_snprintf(target, 16, "sip%02d." DOMAIN3, i);
|
||||
res->ans[i].rdata.srv.target = pj_str(target);
|
||||
}
|
||||
|
||||
|
|
|
@ -501,7 +501,7 @@ static pj_cli_cmd_spec *get_cmd_name(const pj_cli_t *cli,
|
|||
|
||||
if (group) {
|
||||
char cmd_str[MAX_CMD_ID_LENGTH];
|
||||
pj_ansi_sprintf(cmd_str, "%d", group->id);
|
||||
pj_ansi_snprintf(cmd_str, sizeof(cmd_str), "%d", group->id);
|
||||
pj_strcat2(&cmd_val, cmd_str);
|
||||
}
|
||||
pj_strcat(&cmd_val, cmd);
|
||||
|
@ -522,7 +522,7 @@ static void add_cmd_name(pj_cli_t *cli, pj_cli_cmd_spec *group,
|
|||
|
||||
if (group) {
|
||||
char cmd_str[MAX_CMD_ID_LENGTH];
|
||||
pj_ansi_sprintf(cmd_str, "%d", group->id);
|
||||
pj_ansi_snprintf(cmd_str, sizeof(cmd_str), "%d", group->id);
|
||||
pj_strcat2(&cmd_val, cmd_str);
|
||||
}
|
||||
pj_strcat(&cmd_val, cmd_name);
|
||||
|
|
|
@ -972,6 +972,14 @@
|
|||
# define PJ_BAN_STRCAT PJ_BAN_UNSAFE_STR_FUNCS
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Prohibit the use of sprintf() and pj_ansi_sprintf(),
|
||||
* use pj_ansi_snprintf() instead.
|
||||
*/
|
||||
#ifndef PJ_BAN_SPRINTF
|
||||
# define PJ_BAN_SPRINTF PJ_BAN_UNSAFE_STR_FUNCS
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Prohibit the use of vsprintf() and pj_ansi_vsprintf(),
|
||||
* use pj_ansi_vsnprintf() instead.
|
||||
|
|
|
@ -341,7 +341,8 @@ PJ_DEF(pj_status_t) pj_init(void)
|
|||
return PJ_SUCCESS;
|
||||
}
|
||||
|
||||
pj_ansi_strcpy(main_thread.obj_name, "pjthread");
|
||||
pj_ansi_strxcpy(main_thread.obj_name, "pjthread",
|
||||
sizeof(main_thread.obj_name));
|
||||
|
||||
// Init main thread
|
||||
pj_memset(&main_thread, 0, sizeof(main_thread));
|
||||
|
|
|
@ -70,26 +70,26 @@
|
|||
#endif
|
||||
|
||||
|
||||
static char *ver_info(pj_uint32_t ver, char *buf)
|
||||
static char *ver_info(pj_uint32_t ver, char *buf, unsigned buf_size)
|
||||
{
|
||||
pj_size_t len;
|
||||
|
||||
if (ver == 0) {
|
||||
*buf = '\0';
|
||||
return buf;
|
||||
}
|
||||
|
||||
sprintf(buf, "-%u.%u",
|
||||
pj_ansi_snprintf(buf, buf_size, "-%u.%u",
|
||||
(ver & 0xFF000000) >> 24,
|
||||
(ver & 0x00FF0000) >> 16);
|
||||
len = strlen(buf);
|
||||
|
||||
if (ver & 0xFFFF) {
|
||||
sprintf(buf+len, ".%u", (ver & 0xFF00) >> 8);
|
||||
len = strlen(buf);
|
||||
char tmp[20];
|
||||
|
||||
pj_ansi_snprintf(tmp, sizeof(tmp), ".%u", (ver & 0xFF00) >> 8);
|
||||
pj_ansi_strxcat(buf, tmp, buf_size);
|
||||
|
||||
if (ver & 0x00FF) {
|
||||
sprintf(buf+len, ".%u", (ver & 0xFF));
|
||||
pj_ansi_snprintf(tmp, sizeof(tmp), ".%u", (ver & 0xFF));
|
||||
pj_ansi_strxcat(buf, tmp, buf_size);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -330,12 +330,12 @@ get_sdk_info:
|
|||
cnt = pj_ansi_snprintf(tmp, sizeof(tmp),
|
||||
"%s%s%s%s%s%s%s",
|
||||
si.os_name.ptr,
|
||||
ver_info(si.os_ver, os_ver),
|
||||
ver_info(si.os_ver, os_ver, sizeof(os_ver)),
|
||||
(si.machine.slen ? "/" : ""),
|
||||
si.machine.ptr,
|
||||
(si.sdk_name.slen ? "/" : ""),
|
||||
si.sdk_name.ptr,
|
||||
ver_info(si.sdk_ver, sdk_ver));
|
||||
ver_info(si.sdk_ver, sdk_ver, sizeof(sdk_ver)));
|
||||
if (cnt > 0 && cnt < (int)sizeof(tmp)) {
|
||||
ALLOC_CP_STR(tmp, info);
|
||||
}
|
||||
|
|
|
@ -170,7 +170,8 @@ PJ_DEF(void*) pj_pool_alloc_imp( const char *file, int line,
|
|||
#ifdef TRACE_
|
||||
{
|
||||
char msg[120];
|
||||
pj_ansi_sprintf(msg, "Mem %X (%d+%d bytes) allocated by %s:%d\r\n",
|
||||
pj_ansi_snprintf(msg, sizeof(msg),
|
||||
"Mem %X (%d+%d bytes) allocated by %s:%d\r\n",
|
||||
mem, sz, sizeof(struct pj_pool_mem),
|
||||
file, line);
|
||||
TRACE_(msg);
|
||||
|
|
|
@ -2381,14 +2381,14 @@ static pj_status_t ssl_do_handshake(pj_ssl_sock_t *ssock)
|
|||
len *= 2;
|
||||
if (len >= BUF_SIZE) len = BUF_SIZE;
|
||||
for (i = 0; i < len; i+=2)
|
||||
pj_ansi_sprintf(buf+i, "%02X", sid[i/2]);
|
||||
pj_ansi_snprintf(buf+i, len-i, "%02X", sid[i/2]);
|
||||
buf[len] = '\0';
|
||||
PJ_LOG(5, (THIS_FILE, "Session id: %s", buf));
|
||||
|
||||
sctx = SSL_SESSION_get0_id_context(sess, &len);
|
||||
if (len >= BUF_SIZE) len = BUF_SIZE;
|
||||
for (i = 0; i < len; i++)
|
||||
pj_ansi_sprintf(buf + i, "%d", sctx[i]);
|
||||
pj_ansi_snprintf(buf + i, len-i, "%d", sctx[i]);
|
||||
buf[len] = '\0';
|
||||
PJ_LOG(5, (THIS_FILE, "Session id context: %s", buf));
|
||||
}
|
||||
|
|
|
@ -327,6 +327,9 @@ PJ_EXPORT_SYMBOL(pj_create_random_string)
|
|||
PJ_EXPORT_SYMBOL(pj_strtoul)
|
||||
PJ_EXPORT_SYMBOL(pj_utoa)
|
||||
PJ_EXPORT_SYMBOL(pj_utoa_pad)
|
||||
PJ_EXPORT_SYMBOL(pj_ansi_strxcpy)
|
||||
PJ_EXPORT_SYMBOL(pj_ansi_strxcpy2)
|
||||
PJ_EXPORT_SYMBOL(pj_ansi_strxcat)
|
||||
|
||||
/*
|
||||
* timer.h
|
||||
|
|
|
@ -452,7 +452,7 @@ static int unregister_test(const pj_ioqueue_cfg *cfg)
|
|||
addr.sin_addr = pj_inet_addr2("127.0.0.1");
|
||||
|
||||
/* Init buffer to send */
|
||||
pj_ansi_strcpy(sendbuf, "Hello0123");
|
||||
pj_ansi_strxcpy(sendbuf, "Hello0123", sizeof(sendbuf));
|
||||
|
||||
/* Send one packet. */
|
||||
bytes = sizeof(sendbuf);
|
||||
|
|
|
@ -330,7 +330,7 @@ static int udp_ioqueue_unreg_test_imp(pj_bool_t allow_concur)
|
|||
PJ_LOG(3, (THIS_FILE, "...ioqueue unregister stress test 0/3, unregister in app (%s)",
|
||||
pj_ioqueue_name()));
|
||||
for (i=0; i<LOOP; ++i) {
|
||||
pj_ansi_sprintf(title, "repeat %d/%d", i, LOOP);
|
||||
pj_ansi_snprintf(title, sizeof(title), "repeat %d/%d", i, LOOP);
|
||||
rc = perform_unreg_test(ioqueue, test_pool, title, 0);
|
||||
if (rc != 0)
|
||||
return rc;
|
||||
|
@ -340,7 +340,7 @@ static int udp_ioqueue_unreg_test_imp(pj_bool_t allow_concur)
|
|||
PJ_LOG(3, (THIS_FILE, "...ioqueue unregister stress test 1/3, unregister in app (%s)",
|
||||
pj_ioqueue_name()));
|
||||
for (i=0; i<LOOP; ++i) {
|
||||
pj_ansi_sprintf(title, "repeat %d/%d", i, LOOP);
|
||||
pj_ansi_snprintf(title, sizeof(title), "repeat %d/%d", i, LOOP);
|
||||
rc = perform_unreg_test(ioqueue, test_pool, title, 1);
|
||||
if (rc != 0)
|
||||
return rc;
|
||||
|
@ -351,7 +351,7 @@ static int udp_ioqueue_unreg_test_imp(pj_bool_t allow_concur)
|
|||
PJ_LOG(3, (THIS_FILE, "...ioqueue unregister stress test 2/3, unregister in cb (%s)",
|
||||
pj_ioqueue_name()));
|
||||
for (i=0; i<LOOP; ++i) {
|
||||
pj_ansi_sprintf(title, "repeat %d/%d", i, LOOP);
|
||||
pj_ansi_snprintf(title, sizeof(title), "repeat %d/%d", i, LOOP);
|
||||
rc = perform_unreg_test(ioqueue, test_pool, title, 0);
|
||||
if (rc != 0)
|
||||
return rc;
|
||||
|
@ -361,7 +361,7 @@ static int udp_ioqueue_unreg_test_imp(pj_bool_t allow_concur)
|
|||
PJ_LOG(3, (THIS_FILE, "...ioqueue unregister stress test 3/3, unregister in cb (%s)",
|
||||
pj_ioqueue_name()));
|
||||
for (i=0; i<LOOP; ++i) {
|
||||
pj_ansi_sprintf(title, "repeat %d/%d", i, LOOP);
|
||||
pj_ansi_snprintf(title, sizeof(title), "repeat %d/%d", i, LOOP);
|
||||
rc = perform_unreg_test(ioqueue, test_pool, title, 1);
|
||||
if (rc != 0)
|
||||
return rc;
|
||||
|
|
|
@ -404,8 +404,8 @@ static pj_status_t android_get_dev_info(pjmedia_aud_dev_factory *f,
|
|||
|
||||
pj_bzero(info, sizeof(*info));
|
||||
|
||||
pj_ansi_strcpy(info->name, "Android JNI");
|
||||
pj_ansi_strcpy(info->driver, DRIVER_NAME);
|
||||
pj_ansi_strxcpy(info->name, "Android JNI", sizeof(info->name));
|
||||
pj_ansi_strxcpy(info->driver, DRIVER_NAME, sizeof(info->driver));
|
||||
info->default_samples_per_sec = 8000;
|
||||
info->caps = PJMEDIA_AUD_DEV_CAP_OUTPUT_VOLUME_SETTING |
|
||||
PJMEDIA_AUD_DEV_CAP_INPUT_SOURCE;
|
||||
|
|
|
@ -212,7 +212,7 @@ static pj_status_t bb10_add_dev (struct bb10_factory *af)
|
|||
pj_bzero(adi, sizeof(*adi));
|
||||
|
||||
/* Set device name */
|
||||
strcpy(adi->name, "preferred");
|
||||
pj_ansi_strxcpy(adi->name, "preferred", sizeof(adi->name));
|
||||
|
||||
/* Check the number of playback channels */
|
||||
adi->output_count = (pb_result >= 0) ? 1 : 0;
|
||||
|
@ -224,7 +224,7 @@ static pj_status_t bb10_add_dev (struct bb10_factory *af)
|
|||
adi->default_samples_per_sec = 8000;
|
||||
|
||||
/* Driver name */
|
||||
strcpy(adi->driver, "BB10");
|
||||
pj_ansi_strxcpy(adi->driver, "BB10", sizeof(adi->driver));
|
||||
|
||||
++af->dev_cnt;
|
||||
|
||||
|
|
|
@ -306,12 +306,14 @@ static pj_status_t factory_refresh(pjmedia_aud_dev_factory *f)
|
|||
wf->dev_info[i].deviceId = i;
|
||||
bdIMADpj_getDeviceCapabilities(BD_IMAD_CAPTURE_DEVICES,&wf->dev_info[i].info.caps);
|
||||
wf->dev_info[i].info.default_samples_per_sec = BD_IMAD_DEFAULT_FREQ;
|
||||
strcpy(wf->dev_info[i].info.driver, "BD_IMAD");
|
||||
pj_ansi_strxcpy(wf->dev_info[i].info.driver, "BD_IMAD",
|
||||
sizeof(wf->dev_info[i].info.driver));
|
||||
wf->dev_info[i].info.ext_fmt_cnt = 0;
|
||||
wf->dev_info[i].info.input_count = BD_IMAD_MAX_CHANNELS;
|
||||
wf->dev_info[i].info.output_count = 0;
|
||||
strcpy(wf->dev_info[i].info.name,
|
||||
BD_IMAD_PJ_WCHARtoCHAR(captureDevName[i]));
|
||||
pj_ansi_strxcpy(wf->dev_info[i].info.name,
|
||||
BD_IMAD_PJ_WCHARtoCHAR(captureDevName[i]),
|
||||
sizeof(wf->dev_info[i].info.name));
|
||||
wf->dev_info[i].info.routes = 0;
|
||||
}
|
||||
|
||||
|
@ -321,13 +323,15 @@ static pj_status_t factory_refresh(pjmedia_aud_dev_factory *f)
|
|||
bdIMADpj_getDeviceCapabilities(BD_IMAD_PLAYBACK_DEVICES,&wf->dev_info[captureDeviceCount+i].info.caps);
|
||||
wf->dev_info[captureDeviceCount+i].info.default_samples_per_sec =
|
||||
BD_IMAD_DEFAULT_FREQ;
|
||||
strcpy(wf->dev_info[captureDeviceCount+i].info.driver, "BD_IMAD");
|
||||
pj_ansi_strxcpy(wf->dev_info[captureDeviceCount+i].info.driver, "BD_IMAD",
|
||||
sizeof(wf->dev_info[captureDeviceCount+i].info.driver));
|
||||
wf->dev_info[captureDeviceCount+i].info.ext_fmt_cnt = 0;
|
||||
wf->dev_info[captureDeviceCount+i].info.input_count = 0;
|
||||
wf->dev_info[captureDeviceCount+i].info.output_count =
|
||||
BD_IMAD_MAX_CHANNELS;
|
||||
strcpy(wf->dev_info[captureDeviceCount+i].info.name,
|
||||
BD_IMAD_PJ_WCHARtoCHAR(playbackDevName[i]));
|
||||
pj_ansi_strxcpy(wf->dev_info[captureDeviceCount+i].info.name,
|
||||
BD_IMAD_PJ_WCHARtoCHAR(playbackDevName[i]),
|
||||
sizeof(wf->dev_info[captureDeviceCount+i].info.name));
|
||||
wf->dev_info[captureDeviceCount+i].info.routes = 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -291,8 +291,9 @@ static pj_status_t ca_factory_init(pjmedia_aud_dev_factory *f)
|
|||
cdi = &cf->dev_info[i];
|
||||
pj_bzero(cdi, sizeof(*cdi));
|
||||
cdi->dev_id = 0;
|
||||
strcpy(cdi->info.name, "iPhone IO device");
|
||||
strcpy(cdi->info.driver, "apple");
|
||||
pj_ansi_strxcpy(cdi->info.name, "iPhone IO device",
|
||||
sizeof(cdi->info.name));
|
||||
pj_ansi_strxcpy(cdi->info.driver, "apple", sizeof(cdi->info.driver));
|
||||
cdi->info.input_count = 1;
|
||||
cdi->info.output_count = 1;
|
||||
cdi->info.default_samples_per_sec = 8000;
|
||||
|
@ -549,7 +550,8 @@ static pj_status_t ca_factory_refresh(pjmedia_aud_dev_factory *f)
|
|||
0, NULL,
|
||||
&size, (void *)cdi->info.name);
|
||||
|
||||
strcpy(cdi->info.driver, "core audio");
|
||||
pj_ansi_strxcpy(cdi->info.driver, "core audio",
|
||||
sizeof(cdi->info.driver));
|
||||
|
||||
/* Get the number of input channels */
|
||||
addr.mSelector = kAudioDevicePropertyStreamConfiguration;
|
||||
|
|
|
@ -178,7 +178,7 @@ static pj_status_t factory_get_dev_info(pjmedia_aud_dev_factory *f,
|
|||
info->input_count = si->input_count;
|
||||
info->output_count = si->output_count;
|
||||
info->default_samples_per_sec = si->default_samples_per_sec;
|
||||
pj_ansi_strcpy(info->driver, "legacy");
|
||||
pj_ansi_strxcpy(info->driver, "legacy", sizeof(info->driver));
|
||||
info->caps = PJMEDIA_AUD_DEV_CAP_INPUT_LATENCY |
|
||||
PJMEDIA_AUD_DEV_CAP_OUTPUT_LATENCY;
|
||||
|
||||
|
|
|
@ -142,8 +142,8 @@ static pj_status_t null_factory_init(pjmedia_aud_dev_factory *f)
|
|||
sizeof(struct null_audio_dev_info));
|
||||
ndi = &nf->dev_info[0];
|
||||
pj_bzero(ndi, sizeof(*ndi));
|
||||
strcpy(ndi->info.name, "null device");
|
||||
strcpy(ndi->info.driver, "null");
|
||||
pj_ansi_strxcpy(ndi->info.name, "null device", sizeof(ndi->info.name));
|
||||
pj_ansi_strxcpy(ndi->info.driver, "null", sizeof(ndi->info.driver));
|
||||
ndi->info.input_count = 1;
|
||||
ndi->info.output_count = 1;
|
||||
ndi->info.default_samples_per_sec = 16000;
|
||||
|
|
|
@ -402,8 +402,8 @@ static pj_status_t opensl_get_dev_info(pjmedia_aud_dev_factory *f,
|
|||
|
||||
pj_bzero(info, sizeof(*info));
|
||||
|
||||
pj_ansi_strcpy(info->name, "OpenSL ES Audio");
|
||||
pj_ansi_strcpy(info->driver, DRIVER_NAME);
|
||||
pj_ansi_strxcpy(info->name, "OpenSL ES Audio", sizeof(info->name));
|
||||
pj_ansi_strxcpy(info->driver, DRIVER_NAME, sizeof(info->driver));
|
||||
info->default_samples_per_sec = 8000;
|
||||
info->caps = PJMEDIA_AUD_DEV_CAP_OUTPUT_VOLUME_SETTING;
|
||||
info->input_count = 1;
|
||||
|
|
|
@ -785,8 +785,8 @@ static pj_status_t wasapi_add_dev(struct wasapi_factory *wf)
|
|||
pj_bzero(adi, sizeof(*adi));
|
||||
|
||||
/* Set device name */
|
||||
strcpy(adi->name, "default");
|
||||
strcpy(adi->driver, "wasapi");
|
||||
pj_ansi_strxcpy(adi->name, "default", sizeof(adi->name));
|
||||
pj_ansi_strxcpy(adi->driver, "wasapi", sizeof(adi->driver));
|
||||
|
||||
/* Get default capture device */
|
||||
#if defined(USE_ASYNC_ACTIVATE)
|
||||
|
|
|
@ -342,7 +342,7 @@ static void build_dev_info(UINT deviceId, struct wmme_dev_info *wdi,
|
|||
}
|
||||
|
||||
wdi->info.default_samples_per_sec = 16000;
|
||||
strcpy(wdi->info.driver, "WMME");
|
||||
pj_ansi_strxcpy(wdi->info.driver, "WMME", sizeof(wdi->info.driver));
|
||||
|
||||
if (wic) {
|
||||
wdi->info.input_count = wic->wChannels;
|
||||
|
|
|
@ -376,8 +376,8 @@ static pj_status_t opengl_factory_init(pjmedia_vid_dev_factory *f)
|
|||
qf->dev_count = 0;
|
||||
qdi = &qf->dev_info[qf->dev_count++];
|
||||
pj_bzero(qdi, sizeof(*qdi));
|
||||
strcpy(qdi->info.name, "OpenGL renderer");
|
||||
strcpy(qdi->info.driver, "OpenGL");
|
||||
pj_ansi_strxcpy(qdi->info.name, "OpenGL renderer", sizeof(qdi->info.name));
|
||||
pj_ansi_strxcpy(qdi->info.driver, "OpenGL", sizeof(qdi->info.driver));
|
||||
qdi->info.dir = PJMEDIA_DIR_RENDER;
|
||||
qdi->info.has_callback = PJ_FALSE;
|
||||
qdi->info.caps = PJMEDIA_VID_DEV_CAP_FORMAT;
|
||||
|
|
|
@ -253,7 +253,7 @@ static pj_status_t qt_factory_refresh(pjmedia_vid_dev_factory *f)
|
|||
[[dev uniqueID] getCString:qdi->dev_id
|
||||
maxLength:sizeof(qdi->dev_id)
|
||||
encoding:[NSString defaultCStringEncoding]];
|
||||
strcpy(qdi->info.driver, "QT");
|
||||
pj_ansi_strxcpy(qdi->info.driver, "QT", sizeof(qdi->info.driver));
|
||||
qdi->info.dir = PJMEDIA_DIR_CAPTURE;
|
||||
qdi->info.has_callback = PJ_TRUE;
|
||||
|
||||
|
|
|
@ -1011,16 +1011,16 @@ PJ_DEF(pj_status_t) pjmedia_endpt_create_sdp( pjmedia_endpt *endpt,
|
|||
|
||||
|
||||
#if PJ_LOG_MAX_LEVEL >= 3
|
||||
static const char *good_number(char *buf, pj_int32_t val)
|
||||
static const char *good_number(char *buf, unsigned buf_size, pj_int32_t val)
|
||||
{
|
||||
if (val < 1000) {
|
||||
pj_ansi_sprintf(buf, "%d", val);
|
||||
pj_ansi_snprintf(buf, buf_size, "%d", val);
|
||||
} else if (val < 1000000) {
|
||||
pj_ansi_sprintf(buf, "%d.%dK",
|
||||
pj_ansi_snprintf(buf, buf_size, "%d.%dK",
|
||||
val / 1000,
|
||||
(val % 1000) / 100);
|
||||
} else {
|
||||
pj_ansi_sprintf(buf, "%d.%02dM",
|
||||
pj_ansi_snprintf(buf, buf_size, "%d.%02dM",
|
||||
val / 1000000,
|
||||
(val % 1000000) / 10000);
|
||||
}
|
||||
|
@ -1076,7 +1076,7 @@ PJ_DEF(pj_status_t) pjmedia_endpt_dump(pjmedia_endpt *endpt)
|
|||
codec_info[i].encoding_name.ptr,
|
||||
codec_info[i].clock_rate/1000,
|
||||
codec_info[i].channel_cnt,
|
||||
good_number(bps, param.info.avg_bps),
|
||||
good_number(bps, sizeof(bps), param.info.avg_bps),
|
||||
param.info.frm_ptime * param.setting.frm_per_pkt,
|
||||
(param.setting.vad ? " vad" : ""),
|
||||
(param.setting.cng ? " cng" : ""),
|
||||
|
|
|
@ -52,7 +52,7 @@ PJ_DEF(pj_status_t) pjmedia_stream_info_parse_fmtp( pj_pool_t *pool,
|
|||
pj_bzero(fmtp, sizeof(pjmedia_codec_fmtp));
|
||||
|
||||
/* Get "fmtp" attribute for the format */
|
||||
pj_ansi_sprintf(fmt_buf, "%d", pt);
|
||||
pj_ansi_snprintf(fmt_buf, sizeof(fmt_buf), "%d", pt);
|
||||
fmt = pj_str(fmt_buf);
|
||||
attr = pjmedia_sdp_media_find_attr2(m, "fmtp", &fmt);
|
||||
if (attr == NULL)
|
||||
|
|
|
@ -1021,7 +1021,7 @@ PJ_DEF(pj_status_t) pjmedia_transport_srtp_start(
|
|||
status = pj_base64_encode((pj_uint8_t*)tx->key.ptr, (int)tx->key.slen,
|
||||
b64, &b64_len);
|
||||
if (status != PJ_SUCCESS)
|
||||
b64_len = pj_ansi_sprintf(b64, "--key too long--");
|
||||
b64_len = pj_ansi_snprintf(b64, sizeof(b64), "--key too long--");
|
||||
else
|
||||
b64[b64_len] = '\0';
|
||||
|
||||
|
@ -1038,7 +1038,7 @@ PJ_DEF(pj_status_t) pjmedia_transport_srtp_start(
|
|||
status = pj_base64_encode((pj_uint8_t*)rx->key.ptr, (int)rx->key.slen,
|
||||
b64, &b64_len);
|
||||
if (status != PJ_SUCCESS)
|
||||
b64_len = pj_ansi_sprintf(b64, "--key too long--");
|
||||
b64_len = pj_ansi_snprintf(b64, sizeof(b64), "--key too long--");
|
||||
else
|
||||
b64[b64_len] = '\0';
|
||||
|
||||
|
|
|
@ -333,7 +333,7 @@ static pj_status_t ssl_get_fingerprint(X509 *cert, pj_bool_t is_sha256,
|
|||
{
|
||||
unsigned int len, st_out_len, i;
|
||||
unsigned char tmp[EVP_MAX_MD_SIZE];
|
||||
char *p;
|
||||
char *p, *end=buf+*buf_len;
|
||||
|
||||
if (!X509_digest(cert, (is_sha256?EVP_sha256():EVP_sha1()), tmp, &len))
|
||||
return PJ_EUNKNOWN;
|
||||
|
@ -344,9 +344,10 @@ static pj_status_t ssl_get_fingerprint(X509 *cert, pj_bool_t is_sha256,
|
|||
|
||||
/* Format fingerprint to "SHA-256 XX:XX:XX..." */
|
||||
p = buf;
|
||||
p += pj_ansi_sprintf(p, "SHA-%s %.2X", (is_sha256?"256":"1"), tmp[0]);
|
||||
p += pj_ansi_snprintf(p, end-p, "SHA-%s %.2X",
|
||||
(is_sha256?"256":"1"), tmp[0]);
|
||||
for (i=1; i<len; ++i)
|
||||
p += pj_ansi_sprintf(p, ":%.2X", tmp[i]);
|
||||
p += pj_ansi_snprintf(p, end-p, ":%.2X", tmp[i]);
|
||||
|
||||
*buf_len = st_out_len;
|
||||
|
||||
|
|
|
@ -935,7 +935,7 @@ static void save_rgb_frame(int width, int height, const pjmedia_frame *frm)
|
|||
return;
|
||||
|
||||
// Open file
|
||||
sprintf(szFilename, "frame%02d.ppm", counter++);
|
||||
pj_ansi_snprintf(szFilename, sizeof(szFilename), "frame%02d.ppm", counter++);
|
||||
pFile=fopen(szFilename, "wb");
|
||||
if(pFile==NULL)
|
||||
return;
|
||||
|
|
|
@ -181,7 +181,7 @@ static int stun_destroy_test_session(struct stun_test_session *test_sess)
|
|||
/* Create all clients first */
|
||||
for (i=0; i<MAX_SOCK_CLIENTS; ++i) {
|
||||
char name[10];
|
||||
sprintf(name, "stun%02d", i);
|
||||
pj_ansi_snprintf(name, sizeof(name), "stun%02d", i);
|
||||
status = pj_stun_sock_create(&test_sess->stun_cfg, name, pj_AF_INET(),
|
||||
&stun_cb, NULL, test_sess,
|
||||
&stun_sock[i]);
|
||||
|
|
|
@ -635,11 +635,13 @@ static int perform_test2(const char *title,
|
|||
(caller_cfg->client_flag &
|
||||
(CLIENT_IPV4+CLIENT_IPV6)));
|
||||
|
||||
sprintf(add_title1, "%s%s%s", (server_flag & SERVER_IPV4)?"IPv4":"",
|
||||
pj_ansi_snprintf(add_title1, sizeof(add_title1), "%s%s%s",
|
||||
(server_flag & SERVER_IPV4)?"IPv4":"",
|
||||
((server_flag & SERVER_IPV4)&&(server_flag & SERVER_IPV6))?"+":"",
|
||||
(server_flag & SERVER_IPV6)?"IPv6":"");
|
||||
|
||||
sprintf(add_title2, "%s", client_mix_test?"Mix test":"");
|
||||
pj_ansi_snprintf(add_title2, sizeof(add_title2), "%s",
|
||||
client_mix_test?"Mix test":"");
|
||||
|
||||
PJ_LOG(3,(THIS_FILE, INDENT "%s (%s) %s", title, add_title1, add_title2));
|
||||
|
||||
|
@ -1157,7 +1159,7 @@ int ice_test(void)
|
|||
for (k2=1; k2<=2; ++k2) {
|
||||
char title[120];
|
||||
|
||||
sprintf(title,
|
||||
pj_ansi_snprintf(title, sizeof(title),
|
||||
"%s/%s, %dms answer delay, %d vs %d components",
|
||||
pj_ice_sess_role_name(role[j].ua1),
|
||||
pj_ice_sess_role_name(role[j].ua2),
|
||||
|
|
|
@ -555,24 +555,24 @@ static char* print_binary(const pj_uint8_t *data, unsigned data_len)
|
|||
{
|
||||
static char buf[1500];
|
||||
unsigned length = sizeof(buf);
|
||||
char *p = buf;
|
||||
char *p = buf, *end = buf+sizeof(buf);
|
||||
unsigned i;
|
||||
|
||||
for (i=0; i<data_len;) {
|
||||
unsigned j;
|
||||
|
||||
pj_ansi_snprintf(p, 1500-(p-buf),
|
||||
pj_ansi_snprintf(p, end-p,
|
||||
"%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);
|
||||
pj_ansi_snprintf(p, end-p, "%02x ", (*data) & 0xFF);
|
||||
p += 3;
|
||||
data++;
|
||||
}
|
||||
|
||||
pj_ansi_sprintf(p, "\n");
|
||||
pj_ansi_snprintf(p, end-p, "\n");
|
||||
p++;
|
||||
}
|
||||
|
||||
|
|
|
@ -2564,22 +2564,22 @@ PJ_DEF(pj_status_t) pj_stun_msg_decode(pj_pool_t *pool,
|
|||
static char *print_binary(const pj_uint8_t *data, unsigned data_len)
|
||||
{
|
||||
static char static_buffer[1024];
|
||||
char *buffer = static_buffer;
|
||||
char *buffer = static_buffer, end=static_buffer+sizeof(static_buffer);
|
||||
unsigned length=sizeof(static_buffer), i;
|
||||
|
||||
if (length < data_len * 2 + 8)
|
||||
return "";
|
||||
|
||||
pj_ansi_sprintf(buffer, ", data=");
|
||||
pj_ansi_snprintf(buffer, end-buffer, ", data=");
|
||||
buffer += 7;
|
||||
|
||||
for (i=0; i<data_len; ++i) {
|
||||
pj_ansi_sprintf(buffer, "%02x", (*data) & 0xFF);
|
||||
pj_ansi_snprintf(buffer, end-buffer, "%02x", (*data) & 0xFF);
|
||||
buffer += 2;
|
||||
data++;
|
||||
}
|
||||
|
||||
pj_ansi_sprintf(buffer, "\n");
|
||||
pj_ansi_snprintf(buffer, end-buffer, "\n");
|
||||
buffer++;
|
||||
|
||||
return static_buffer;
|
||||
|
|
|
@ -32,21 +32,22 @@
|
|||
static int print_binary(char *buffer, unsigned length,
|
||||
const pj_uint8_t *data, unsigned data_len)
|
||||
{
|
||||
char *end = buffer+length;
|
||||
unsigned i;
|
||||
|
||||
if (length < data_len * 2 + 8)
|
||||
return -1;
|
||||
|
||||
pj_ansi_sprintf(buffer, ", data=");
|
||||
pj_ansi_snprintf(buffer, end-buffer, ", data=");
|
||||
buffer += 7;
|
||||
|
||||
for (i=0; i<data_len; ++i) {
|
||||
pj_ansi_sprintf(buffer, "%02x", (*data) & 0xFF);
|
||||
pj_ansi_snprintf(buffer, end-buffer, "%02x", (*data) & 0xFF);
|
||||
buffer += 2;
|
||||
data++;
|
||||
}
|
||||
|
||||
pj_ansi_sprintf(buffer, "\n");
|
||||
pj_ansi_snprintf(buffer, end-buffer, "\n");
|
||||
buffer++;
|
||||
|
||||
return data_len * 2 + 8;
|
||||
|
|
|
@ -527,7 +527,8 @@ static void console_main(void)
|
|||
break;
|
||||
}
|
||||
peer = &g.peer[input[0]-'0'];
|
||||
sprintf(input, "Hello from peer%d", input[0]-'0');
|
||||
pj_ansi_snprintf(input, sizeof(input),
|
||||
"Hello from peer%d", input[0]-'0');
|
||||
pj_stun_sock_sendto(peer->stun_sock, NULL, input, strlen(input)+1, 0,
|
||||
&g.relay_addr, pj_sockaddr_get_len(&g.relay_addr));
|
||||
break;
|
||||
|
|
|
@ -1601,7 +1601,7 @@ static void default_config()
|
|||
pjsua_app_config *cfg = &app_config;
|
||||
|
||||
pjsua_config_default(&cfg->cfg);
|
||||
pj_ansi_sprintf(tmp, "PJSUA v%s %s", pj_get_version(),
|
||||
pj_ansi_snprintf(tmp, sizeof(tmp), "PJSUA v%s %s", pj_get_version(),
|
||||
pj_get_sys_info()->info.ptr);
|
||||
pj_strdup2_with_null(app_config.pool, &cfg->cfg.user_agent, tmp);
|
||||
|
||||
|
@ -1693,13 +1693,13 @@ static void write_account_settings(int acc_index, pj_str_t *result)
|
|||
pjsua_acc_config *acc_cfg = &app_config.acc_cfg[acc_index];
|
||||
|
||||
|
||||
pj_ansi_sprintf(line, "\n#\n# Account %d:\n#\n", acc_index);
|
||||
pj_ansi_snprintf(line, sizeof(line), "\n#\n# Account %d:\n#\n", acc_index);
|
||||
pj_strcat2(result, line);
|
||||
|
||||
|
||||
/* Identity */
|
||||
if (acc_cfg->id.slen) {
|
||||
pj_ansi_sprintf(line, "--id %.*s\n",
|
||||
pj_ansi_snprintf(line, sizeof(line), "--id %.*s\n",
|
||||
(int)acc_cfg->id.slen,
|
||||
acc_cfg->id.ptr);
|
||||
pj_strcat2(result, line);
|
||||
|
@ -1707,19 +1707,19 @@ static void write_account_settings(int acc_index, pj_str_t *result)
|
|||
|
||||
/* Registrar server */
|
||||
if (acc_cfg->reg_uri.slen) {
|
||||
pj_ansi_sprintf(line, "--registrar %.*s\n",
|
||||
pj_ansi_snprintf(line, sizeof(line), "--registrar %.*s\n",
|
||||
(int)acc_cfg->reg_uri.slen,
|
||||
acc_cfg->reg_uri.ptr);
|
||||
pj_strcat2(result, line);
|
||||
|
||||
pj_ansi_sprintf(line, "--reg-timeout %u\n",
|
||||
pj_ansi_snprintf(line, sizeof(line), "--reg-timeout %u\n",
|
||||
acc_cfg->reg_timeout);
|
||||
pj_strcat2(result, line);
|
||||
}
|
||||
|
||||
/* Contact */
|
||||
if (acc_cfg->force_contact.slen) {
|
||||
pj_ansi_sprintf(line, "--contact %.*s\n",
|
||||
pj_ansi_snprintf(line, sizeof(line), "--contact %.*s\n",
|
||||
(int)acc_cfg->force_contact.slen,
|
||||
acc_cfg->force_contact.ptr);
|
||||
pj_strcat2(result, line);
|
||||
|
@ -1727,7 +1727,7 @@ static void write_account_settings(int acc_index, pj_str_t *result)
|
|||
|
||||
/* Contact header parameters */
|
||||
if (acc_cfg->contact_params.slen) {
|
||||
pj_ansi_sprintf(line, "--contact-params %.*s\n",
|
||||
pj_ansi_snprintf(line, sizeof(line), "--contact-params %.*s\n",
|
||||
(int)acc_cfg->contact_params.slen,
|
||||
acc_cfg->contact_params.ptr);
|
||||
pj_strcat2(result, line);
|
||||
|
@ -1735,7 +1735,7 @@ static void write_account_settings(int acc_index, pj_str_t *result)
|
|||
|
||||
/* Contact URI parameters */
|
||||
if (acc_cfg->contact_uri_params.slen) {
|
||||
pj_ansi_sprintf(line, "--contact-uri-params %.*s\n",
|
||||
pj_ansi_snprintf(line, sizeof(line), "--contact-uri-params %.*s\n",
|
||||
(int)acc_cfg->contact_uri_params.slen,
|
||||
acc_cfg->contact_uri_params.ptr);
|
||||
pj_strcat2(result, line);
|
||||
|
@ -1744,7 +1744,7 @@ static void write_account_settings(int acc_index, pj_str_t *result)
|
|||
/* */
|
||||
if (acc_cfg->allow_contact_rewrite!=1)
|
||||
{
|
||||
pj_ansi_sprintf(line, "--auto-update-nat %i\n",
|
||||
pj_ansi_snprintf(line, sizeof(line), "--auto-update-nat %i\n",
|
||||
(int)acc_cfg->allow_contact_rewrite);
|
||||
pj_strcat2(result, line);
|
||||
}
|
||||
|
@ -1758,13 +1758,13 @@ static void write_account_settings(int acc_index, pj_str_t *result)
|
|||
{
|
||||
use_srtp = 3;
|
||||
}
|
||||
pj_ansi_sprintf(line, "--use-srtp %i\n", use_srtp);
|
||||
pj_ansi_snprintf(line, sizeof(line), "--use-srtp %i\n", use_srtp);
|
||||
pj_strcat2(result, line);
|
||||
}
|
||||
if (acc_cfg->srtp_secure_signaling !=
|
||||
PJSUA_DEFAULT_SRTP_SECURE_SIGNALING)
|
||||
{
|
||||
pj_ansi_sprintf(line, "--srtp-secure %d\n",
|
||||
pj_ansi_snprintf(line, sizeof(line), "--srtp-secure %d\n",
|
||||
acc_cfg->srtp_secure_signaling);
|
||||
pj_strcat2(result, line);
|
||||
}
|
||||
|
@ -1772,7 +1772,7 @@ static void write_account_settings(int acc_index, pj_str_t *result)
|
|||
|
||||
/* Proxy */
|
||||
for (i=0; i<acc_cfg->proxy_cnt; ++i) {
|
||||
pj_ansi_sprintf(line, "--proxy %.*s\n",
|
||||
pj_ansi_snprintf(line, sizeof(line), "--proxy %.*s\n",
|
||||
(int)acc_cfg->proxy[i].slen,
|
||||
acc_cfg->proxy[i].ptr);
|
||||
pj_strcat2(result, line);
|
||||
|
@ -1781,21 +1781,21 @@ static void write_account_settings(int acc_index, pj_str_t *result)
|
|||
/* Credentials */
|
||||
for (i=0; i<acc_cfg->cred_count; ++i) {
|
||||
if (acc_cfg->cred_info[i].realm.slen) {
|
||||
pj_ansi_sprintf(line, "--realm %.*s\n",
|
||||
pj_ansi_snprintf(line, sizeof(line), "--realm %.*s\n",
|
||||
(int)acc_cfg->cred_info[i].realm.slen,
|
||||
acc_cfg->cred_info[i].realm.ptr);
|
||||
pj_strcat2(result, line);
|
||||
}
|
||||
|
||||
if (acc_cfg->cred_info[i].username.slen) {
|
||||
pj_ansi_sprintf(line, "--username %.*s\n",
|
||||
pj_ansi_snprintf(line, sizeof(line), "--username %.*s\n",
|
||||
(int)acc_cfg->cred_info[i].username.slen,
|
||||
acc_cfg->cred_info[i].username.ptr);
|
||||
pj_strcat2(result, line);
|
||||
}
|
||||
|
||||
if (acc_cfg->cred_info[i].data.slen) {
|
||||
pj_ansi_sprintf(line, "--password %.*s\n",
|
||||
pj_ansi_snprintf(line, sizeof(line), "--password %.*s\n",
|
||||
(int)acc_cfg->cred_info[i].data.slen,
|
||||
acc_cfg->cred_info[i].data.ptr);
|
||||
pj_strcat2(result, line);
|
||||
|
@ -1807,14 +1807,14 @@ static void write_account_settings(int acc_index, pj_str_t *result)
|
|||
|
||||
/* reg-use-proxy */
|
||||
if (acc_cfg->reg_use_proxy != 3) {
|
||||
pj_ansi_sprintf(line, "--reg-use-proxy %d\n",
|
||||
pj_ansi_snprintf(line, sizeof(line), "--reg-use-proxy %d\n",
|
||||
acc_cfg->reg_use_proxy);
|
||||
pj_strcat2(result, line);
|
||||
}
|
||||
|
||||
/* rereg-delay */
|
||||
if (acc_cfg->reg_retry_interval != PJSUA_REG_RETRY_INTERVAL) {
|
||||
pj_ansi_sprintf(line, "--rereg-delay %d\n",
|
||||
pj_ansi_snprintf(line, sizeof(line), "--rereg-delay %d\n",
|
||||
acc_cfg->reg_retry_interval);
|
||||
pj_strcat2(result, line);
|
||||
}
|
||||
|
@ -1826,17 +1826,17 @@ static void write_account_settings(int acc_index, pj_str_t *result)
|
|||
|
||||
/* Session Timer extension */
|
||||
if (acc_cfg->use_timer) {
|
||||
pj_ansi_sprintf(line, "--use-timer %d\n",
|
||||
pj_ansi_snprintf(line, sizeof(line), "--use-timer %d\n",
|
||||
acc_cfg->use_timer);
|
||||
pj_strcat2(result, line);
|
||||
}
|
||||
if (acc_cfg->timer_setting.min_se != 90) {
|
||||
pj_ansi_sprintf(line, "--timer-min-se %d\n",
|
||||
pj_ansi_snprintf(line, sizeof(line), "--timer-min-se %d\n",
|
||||
acc_cfg->timer_setting.min_se);
|
||||
pj_strcat2(result, line);
|
||||
}
|
||||
if (acc_cfg->timer_setting.sess_expires != PJSIP_SESS_TIMER_DEF_SE) {
|
||||
pj_ansi_sprintf(line, "--timer-se %d\n",
|
||||
pj_ansi_snprintf(line, sizeof(line), "--timer-se %d\n",
|
||||
acc_cfg->timer_setting.sess_expires);
|
||||
pj_strcat2(result, line);
|
||||
}
|
||||
|
@ -1863,7 +1863,7 @@ static void write_account_settings(int acc_index, pj_str_t *result)
|
|||
pj_strcat2(result, "--ice-regular\n");
|
||||
|
||||
if (acc_cfg->ice_cfg.ice_opt.trickle > 0) {
|
||||
pj_ansi_sprintf(line, "--ice-trickle %d\n",
|
||||
pj_ansi_snprintf(line, sizeof(line), "--ice-trickle %d\n",
|
||||
acc_cfg->ice_cfg.ice_opt.trickle);
|
||||
pj_strcat2(result, line);
|
||||
}
|
||||
|
@ -1872,7 +1872,7 @@ static void write_account_settings(int acc_index, pj_str_t *result)
|
|||
pj_strcat2(result, "--use-turn\n");
|
||||
|
||||
if (acc_cfg->ice_cfg.ice_max_host_cands >= 0) {
|
||||
pj_ansi_sprintf(line, "--ice_max_host_cands %d\n",
|
||||
pj_ansi_snprintf(line, sizeof(line), "--ice_max_host_cands %d\n",
|
||||
acc_cfg->ice_cfg.ice_max_host_cands);
|
||||
pj_strcat2(result, line);
|
||||
}
|
||||
|
@ -1881,7 +1881,7 @@ static void write_account_settings(int acc_index, pj_str_t *result)
|
|||
pj_strcat2(result, "--ice-no-rtcp\n");
|
||||
|
||||
if (acc_cfg->turn_cfg.turn_server.slen) {
|
||||
pj_ansi_sprintf(line, "--turn-srv %.*s\n",
|
||||
pj_ansi_snprintf(line, sizeof(line), "--turn-srv %.*s\n",
|
||||
(int)acc_cfg->turn_cfg.turn_server.slen,
|
||||
acc_cfg->turn_cfg.turn_server.ptr);
|
||||
pj_strcat2(result, line);
|
||||
|
@ -1891,14 +1891,14 @@ static void write_account_settings(int acc_index, pj_str_t *result)
|
|||
pj_strcat2(result, "--turn-tcp\n");
|
||||
|
||||
if (acc_cfg->turn_cfg.turn_auth_cred.data.static_cred.username.slen) {
|
||||
pj_ansi_sprintf(line, "--turn-user %.*s\n",
|
||||
pj_ansi_snprintf(line, sizeof(line), "--turn-user %.*s\n",
|
||||
(int)acc_cfg->turn_cfg.turn_auth_cred.data.static_cred.username.slen,
|
||||
acc_cfg->turn_cfg.turn_auth_cred.data.static_cred.username.ptr);
|
||||
pj_strcat2(result, line);
|
||||
}
|
||||
|
||||
if (acc_cfg->turn_cfg.turn_auth_cred.data.static_cred.data.slen) {
|
||||
pj_ansi_sprintf(line, "--turn-passwd %.*s\n",
|
||||
pj_ansi_snprintf(line, sizeof(line), "--turn-passwd %.*s\n",
|
||||
(int)acc_cfg->turn_cfg.turn_auth_cred.data.static_cred.data.slen,
|
||||
acc_cfg->turn_cfg.turn_auth_cred.data.static_cred.data.ptr);
|
||||
pj_strcat2(result, line);
|
||||
|
@ -1925,16 +1925,16 @@ int write_settings(pjsua_app_config *config, char *buf, pj_size_t max)
|
|||
|
||||
/* Logging. */
|
||||
pj_strcat2(&cfg, "#\n# Logging options:\n#\n");
|
||||
pj_ansi_sprintf(line, "--log-level %d\n",
|
||||
pj_ansi_snprintf(line, sizeof(line), "--log-level %d\n",
|
||||
config->log_cfg.level);
|
||||
pj_strcat2(&cfg, line);
|
||||
|
||||
pj_ansi_sprintf(line, "--app-log-level %d\n",
|
||||
pj_ansi_snprintf(line, sizeof(line), "--app-log-level %d\n",
|
||||
config->log_cfg.console_level);
|
||||
pj_strcat2(&cfg, line);
|
||||
|
||||
if (config->log_cfg.log_filename.slen) {
|
||||
pj_ansi_sprintf(line, "--log-file %.*s\n",
|
||||
pj_ansi_snprintf(line, sizeof(line), "--log-file %.*s\n",
|
||||
(int)config->log_cfg.log_filename.slen,
|
||||
config->log_cfg.log_filename.ptr);
|
||||
pj_strcat2(&cfg, line);
|
||||
|
@ -1957,7 +1957,7 @@ int write_settings(pjsua_app_config *config, char *buf, pj_size_t max)
|
|||
|
||||
/* Nameservers */
|
||||
for (i=0; i<config->cfg.nameserver_count; ++i) {
|
||||
pj_ansi_sprintf(line, "--nameserver %.*s\n",
|
||||
pj_ansi_snprintf(line, sizeof(line), "--nameserver %.*s\n",
|
||||
(int)config->cfg.nameserver[i].slen,
|
||||
config->cfg.nameserver[i].ptr);
|
||||
pj_strcat2(&cfg, line);
|
||||
|
@ -1965,7 +1965,7 @@ int write_settings(pjsua_app_config *config, char *buf, pj_size_t max)
|
|||
|
||||
/* Outbound proxy */
|
||||
for (i=0; i<config->cfg.outbound_proxy_cnt; ++i) {
|
||||
pj_ansi_sprintf(line, "--outbound %.*s\n",
|
||||
pj_ansi_snprintf(line, sizeof(line), "--outbound %.*s\n",
|
||||
(int)config->cfg.outbound_proxy[i].slen,
|
||||
config->cfg.outbound_proxy[i].ptr);
|
||||
pj_strcat2(&cfg, line);
|
||||
|
@ -1980,12 +1980,13 @@ int write_settings(pjsua_app_config *config, char *buf, pj_size_t max)
|
|||
}
|
||||
|
||||
/* UDP Transport. */
|
||||
pj_ansi_sprintf(line, "--local-port %d\n", config->udp_cfg.port);
|
||||
pj_ansi_snprintf(line, sizeof(line), "--local-port %d\n",
|
||||
config->udp_cfg.port);
|
||||
pj_strcat2(&cfg, line);
|
||||
|
||||
/* IP address, if any. */
|
||||
if (config->udp_cfg.public_addr.slen) {
|
||||
pj_ansi_sprintf(line, "--ip-addr %.*s\n",
|
||||
pj_ansi_snprintf(line, sizeof(line), "--ip-addr %.*s\n",
|
||||
(int)config->udp_cfg.public_addr.slen,
|
||||
config->udp_cfg.public_addr.ptr);
|
||||
pj_strcat2(&cfg, line);
|
||||
|
@ -1993,7 +1994,7 @@ int write_settings(pjsua_app_config *config, char *buf, pj_size_t max)
|
|||
|
||||
/* Bound IP address, if any. */
|
||||
if (config->udp_cfg.bound_addr.slen) {
|
||||
pj_ansi_sprintf(line, "--bound-addr %.*s\n",
|
||||
pj_ansi_snprintf(line, sizeof(line), "--bound-addr %.*s\n",
|
||||
(int)config->udp_cfg.bound_addr.slen,
|
||||
config->udp_cfg.bound_addr.ptr);
|
||||
pj_strcat2(&cfg, line);
|
||||
|
@ -2011,7 +2012,7 @@ int write_settings(pjsua_app_config *config, char *buf, pj_size_t max)
|
|||
|
||||
/* STUN */
|
||||
for (i=0; i<config->cfg.stun_srv_cnt; ++i) {
|
||||
pj_ansi_sprintf(line, "--stun-srv %.*s\n",
|
||||
pj_ansi_snprintf(line, sizeof(line), "--stun-srv %.*s\n",
|
||||
(int)config->cfg.stun_srv[i].slen,
|
||||
config->cfg.stun_srv[i].ptr);
|
||||
pj_strcat2(&cfg, line);
|
||||
|
@ -2022,26 +2023,26 @@ int write_settings(pjsua_app_config *config, char *buf, pj_size_t max)
|
|||
if (config->use_tls)
|
||||
pj_strcat2(&cfg, "--use-tls\n");
|
||||
if (config->udp_cfg.tls_setting.ca_list_file.slen) {
|
||||
pj_ansi_sprintf(line, "--tls-ca-file %.*s\n",
|
||||
pj_ansi_snprintf(line, sizeof(line), "--tls-ca-file %.*s\n",
|
||||
(int)config->udp_cfg.tls_setting.ca_list_file.slen,
|
||||
config->udp_cfg.tls_setting.ca_list_file.ptr);
|
||||
pj_strcat2(&cfg, line);
|
||||
}
|
||||
if (config->udp_cfg.tls_setting.cert_file.slen) {
|
||||
pj_ansi_sprintf(line, "--tls-cert-file %.*s\n",
|
||||
pj_ansi_snprintf(line, sizeof(line), "--tls-cert-file %.*s\n",
|
||||
(int)config->udp_cfg.tls_setting.cert_file.slen,
|
||||
config->udp_cfg.tls_setting.cert_file.ptr);
|
||||
pj_strcat2(&cfg, line);
|
||||
}
|
||||
if (config->udp_cfg.tls_setting.privkey_file.slen) {
|
||||
pj_ansi_sprintf(line, "--tls-privkey-file %.*s\n",
|
||||
pj_ansi_snprintf(line, sizeof(line), "--tls-privkey-file %.*s\n",
|
||||
(int)config->udp_cfg.tls_setting.privkey_file.slen,
|
||||
config->udp_cfg.tls_setting.privkey_file.ptr);
|
||||
pj_strcat2(&cfg, line);
|
||||
}
|
||||
|
||||
if (config->udp_cfg.tls_setting.password.slen) {
|
||||
pj_ansi_sprintf(line, "--tls-password %.*s\n",
|
||||
pj_ansi_snprintf(line, sizeof(line), "--tls-password %.*s\n",
|
||||
(int)config->udp_cfg.tls_setting.password.slen,
|
||||
config->udp_cfg.tls_setting.password.ptr);
|
||||
pj_strcat2(&cfg, line);
|
||||
|
@ -2054,13 +2055,13 @@ int write_settings(pjsua_app_config *config, char *buf, pj_size_t max)
|
|||
pj_strcat2(&cfg, "--tls-verify-client\n");
|
||||
|
||||
if (config->udp_cfg.tls_setting.timeout.sec) {
|
||||
pj_ansi_sprintf(line, "--tls-neg-timeout %d\n",
|
||||
pj_ansi_snprintf(line, sizeof(line), "--tls-neg-timeout %d\n",
|
||||
(int)config->udp_cfg.tls_setting.timeout.sec);
|
||||
pj_strcat2(&cfg, line);
|
||||
}
|
||||
|
||||
for (i=0; i<config->udp_cfg.tls_setting.ciphers_num; ++i) {
|
||||
pj_ansi_sprintf(line, "--tls-cipher 0x%06X # %s\n",
|
||||
pj_ansi_snprintf(line, sizeof(line), "--tls-cipher 0x%06X # %s\n",
|
||||
config->udp_cfg.tls_setting.ciphers[i],
|
||||
pj_ssl_cipher_name(config->udp_cfg.tls_setting.ciphers[i]));
|
||||
pj_strcat2(&cfg, line);
|
||||
|
@ -2086,19 +2087,19 @@ int write_settings(pjsua_app_config *config, char *buf, pj_size_t max)
|
|||
{
|
||||
use_srtp = 3;
|
||||
}
|
||||
pj_ansi_sprintf(line, "--use-srtp %d\n", use_srtp);
|
||||
pj_ansi_snprintf(line, sizeof(line), "--use-srtp %d\n", use_srtp);
|
||||
pj_strcat2(&cfg, line);
|
||||
}
|
||||
if (app_config.cfg.srtp_secure_signaling !=
|
||||
PJSUA_DEFAULT_SRTP_SECURE_SIGNALING)
|
||||
{
|
||||
pj_ansi_sprintf(line, "--srtp-secure %d\n",
|
||||
pj_ansi_snprintf(line, sizeof(line), "--srtp-secure %d\n",
|
||||
app_config.cfg.srtp_secure_signaling);
|
||||
pj_strcat2(&cfg, line);
|
||||
}
|
||||
if (app_config.srtp_keying >= 0 && app_config.srtp_keying <= 1)
|
||||
{
|
||||
pj_ansi_sprintf(line, "--srtp-keying %d\n",
|
||||
pj_ansi_snprintf(line, sizeof(line), "--srtp-keying %d\n",
|
||||
app_config.srtp_keying);
|
||||
pj_strcat2(&cfg, line);
|
||||
}
|
||||
|
@ -2114,33 +2115,35 @@ int write_settings(pjsua_app_config *config, char *buf, pj_size_t max)
|
|||
if (config->auto_conf)
|
||||
pj_strcat2(&cfg, "--auto-conf\n");
|
||||
for (i=0; i<config->wav_count; ++i) {
|
||||
pj_ansi_sprintf(line, "--play-file %s\n",
|
||||
pj_ansi_snprintf(line, sizeof(line), "--play-file %s\n",
|
||||
config->wav_files[i].ptr);
|
||||
pj_strcat2(&cfg, line);
|
||||
}
|
||||
for (i=0; i<config->tone_count; ++i) {
|
||||
pj_ansi_sprintf(line, "--play-tone %d,%d,%d,%d\n",
|
||||
pj_ansi_snprintf(line, sizeof(line), "--play-tone %d,%d,%d,%d\n",
|
||||
config->tones[i].freq1, config->tones[i].freq2,
|
||||
config->tones[i].on_msec, config->tones[i].off_msec);
|
||||
pj_strcat2(&cfg, line);
|
||||
}
|
||||
if (config->rec_file.slen) {
|
||||
pj_ansi_sprintf(line, "--rec-file %s\n",
|
||||
pj_ansi_snprintf(line, sizeof(line), "--rec-file %s\n",
|
||||
config->rec_file.ptr);
|
||||
pj_strcat2(&cfg, line);
|
||||
}
|
||||
if (config->auto_rec)
|
||||
pj_strcat2(&cfg, "--auto-rec\n");
|
||||
if (config->capture_dev != PJSUA_INVALID_ID) {
|
||||
pj_ansi_sprintf(line, "--capture-dev %d\n", config->capture_dev);
|
||||
pj_ansi_snprintf(line, sizeof(line), "--capture-dev %d\n",
|
||||
config->capture_dev);
|
||||
pj_strcat2(&cfg, line);
|
||||
}
|
||||
if (config->playback_dev != PJSUA_INVALID_ID) {
|
||||
pj_ansi_sprintf(line, "--playback-dev %d\n", config->playback_dev);
|
||||
pj_ansi_snprintf(line, sizeof(line), "--playback-dev %d\n",
|
||||
config->playback_dev);
|
||||
pj_strcat2(&cfg, line);
|
||||
}
|
||||
if (config->media_cfg.snd_auto_close_time != -1) {
|
||||
pj_ansi_sprintf(line, "--snd-auto-close %d\n",
|
||||
pj_ansi_snprintf(line, sizeof(line), "--snd-auto-close %d\n",
|
||||
config->media_cfg.snd_auto_close_time);
|
||||
pj_strcat2(&cfg, line);
|
||||
}
|
||||
|
@ -2148,28 +2151,30 @@ int write_settings(pjsua_app_config *config, char *buf, pj_size_t max)
|
|||
pj_strcat2(&cfg, "--no-tones\n");
|
||||
}
|
||||
if (config->media_cfg.jb_max != -1) {
|
||||
pj_ansi_sprintf(line, "--jb-max-size %d\n",
|
||||
pj_ansi_snprintf(line, sizeof(line), "--jb-max-size %d\n",
|
||||
config->media_cfg.jb_max);
|
||||
pj_strcat2(&cfg, line);
|
||||
}
|
||||
|
||||
/* Sound device latency */
|
||||
if (config->capture_lat != PJMEDIA_SND_DEFAULT_REC_LATENCY) {
|
||||
pj_ansi_sprintf(line, "--capture-lat %d\n", config->capture_lat);
|
||||
pj_ansi_snprintf(line, sizeof(line), "--capture-lat %d\n",
|
||||
config->capture_lat);
|
||||
pj_strcat2(&cfg, line);
|
||||
}
|
||||
if (config->playback_lat != PJMEDIA_SND_DEFAULT_PLAY_LATENCY) {
|
||||
pj_ansi_sprintf(line, "--playback-lat %d\n", config->playback_lat);
|
||||
pj_ansi_snprintf(line, sizeof(line), "--playback-lat %d\n",
|
||||
config->playback_lat);
|
||||
pj_strcat2(&cfg, line);
|
||||
}
|
||||
|
||||
/* Media clock rate. */
|
||||
if (config->media_cfg.clock_rate != PJSUA_DEFAULT_CLOCK_RATE) {
|
||||
pj_ansi_sprintf(line, "--clock-rate %d\n",
|
||||
pj_ansi_snprintf(line, sizeof(line), "--clock-rate %d\n",
|
||||
config->media_cfg.clock_rate);
|
||||
pj_strcat2(&cfg, line);
|
||||
} else {
|
||||
pj_ansi_sprintf(line, "#using default --clock-rate %d\n",
|
||||
pj_ansi_snprintf(line, sizeof(line), "#using default --clock-rate %d\n",
|
||||
config->media_cfg.clock_rate);
|
||||
pj_strcat2(&cfg, line);
|
||||
}
|
||||
|
@ -2177,48 +2182,51 @@ int write_settings(pjsua_app_config *config, char *buf, pj_size_t max)
|
|||
if (config->media_cfg.snd_clock_rate &&
|
||||
config->media_cfg.snd_clock_rate != config->media_cfg.clock_rate)
|
||||
{
|
||||
pj_ansi_sprintf(line, "--snd-clock-rate %d\n",
|
||||
pj_ansi_snprintf(line, sizeof(line), "--snd-clock-rate %d\n",
|
||||
config->media_cfg.snd_clock_rate);
|
||||
pj_strcat2(&cfg, line);
|
||||
}
|
||||
|
||||
/* Stereo mode. */
|
||||
if (config->media_cfg.channel_count == 2) {
|
||||
pj_ansi_sprintf(line, "--stereo\n");
|
||||
pj_ansi_snprintf(line, sizeof(line), "--stereo\n");
|
||||
pj_strcat2(&cfg, line);
|
||||
}
|
||||
|
||||
/* quality */
|
||||
if (config->media_cfg.quality != PJSUA_DEFAULT_CODEC_QUALITY) {
|
||||
pj_ansi_sprintf(line, "--quality %d\n",
|
||||
pj_ansi_snprintf(line, sizeof(line), "--quality %d\n",
|
||||
config->media_cfg.quality);
|
||||
pj_strcat2(&cfg, line);
|
||||
} else {
|
||||
pj_ansi_sprintf(line, "#using default --quality %d\n",
|
||||
pj_ansi_snprintf(line, sizeof(line), "#using default --quality %d\n",
|
||||
config->media_cfg.quality);
|
||||
pj_strcat2(&cfg, line);
|
||||
}
|
||||
|
||||
if (config->vid.vcapture_dev != PJMEDIA_VID_DEFAULT_CAPTURE_DEV) {
|
||||
pj_ansi_sprintf(line, "--vcapture-dev %d\n", config->vid.vcapture_dev);
|
||||
pj_ansi_snprintf(line, sizeof(line), "--vcapture-dev %d\n",
|
||||
config->vid.vcapture_dev);
|
||||
pj_strcat2(&cfg, line);
|
||||
}
|
||||
if (config->vid.vrender_dev != PJMEDIA_VID_DEFAULT_RENDER_DEV) {
|
||||
pj_ansi_sprintf(line, "--vrender-dev %d\n", config->vid.vrender_dev);
|
||||
pj_ansi_snprintf(line, sizeof(line), "--vrender-dev %d\n",
|
||||
config->vid.vrender_dev);
|
||||
pj_strcat2(&cfg, line);
|
||||
}
|
||||
for (i=0; i<config->avi_cnt; ++i) {
|
||||
pj_ansi_sprintf(line, "--play-avi %s\n", config->avi[i].path.ptr);
|
||||
pj_ansi_snprintf(line, sizeof(line), "--play-avi %s\n",
|
||||
config->avi[i].path.ptr);
|
||||
pj_strcat2(&cfg, line);
|
||||
}
|
||||
if (config->avi_auto_play) {
|
||||
pj_ansi_sprintf(line, "--auto-play-avi\n");
|
||||
pj_ansi_snprintf(line, sizeof(line), "--auto-play-avi\n");
|
||||
pj_strcat2(&cfg, line);
|
||||
}
|
||||
|
||||
/* ptime */
|
||||
if (config->media_cfg.ptime) {
|
||||
pj_ansi_sprintf(line, "--ptime %d\n",
|
||||
pj_ansi_snprintf(line, sizeof(line), "--ptime %d\n",
|
||||
config->media_cfg.ptime);
|
||||
pj_strcat2(&cfg, line);
|
||||
}
|
||||
|
@ -2230,61 +2238,61 @@ int write_settings(pjsua_app_config *config, char *buf, pj_size_t max)
|
|||
|
||||
/* ec-tail */
|
||||
if (config->media_cfg.ec_tail_len != PJSUA_DEFAULT_EC_TAIL_LEN) {
|
||||
pj_ansi_sprintf(line, "--ec-tail %d\n",
|
||||
pj_ansi_snprintf(line, sizeof(line), "--ec-tail %d\n",
|
||||
config->media_cfg.ec_tail_len);
|
||||
pj_strcat2(&cfg, line);
|
||||
} else {
|
||||
pj_ansi_sprintf(line, "#using default --ec-tail %d\n",
|
||||
pj_ansi_snprintf(line, sizeof(line), "#using default --ec-tail %d\n",
|
||||
config->media_cfg.ec_tail_len);
|
||||
pj_strcat2(&cfg, line);
|
||||
}
|
||||
|
||||
/* ec-opt */
|
||||
if (config->media_cfg.ec_options != 0) {
|
||||
pj_ansi_sprintf(line, "--ec-opt %d\n",
|
||||
pj_ansi_snprintf(line, sizeof(line), "--ec-opt %d\n",
|
||||
config->media_cfg.ec_options);
|
||||
pj_strcat2(&cfg, line);
|
||||
}
|
||||
|
||||
/* ilbc-mode */
|
||||
if (config->media_cfg.ilbc_mode != PJSUA_DEFAULT_ILBC_MODE) {
|
||||
pj_ansi_sprintf(line, "--ilbc-mode %d\n",
|
||||
pj_ansi_snprintf(line, sizeof(line), "--ilbc-mode %d\n",
|
||||
config->media_cfg.ilbc_mode);
|
||||
pj_strcat2(&cfg, line);
|
||||
} else {
|
||||
pj_ansi_sprintf(line, "#using default --ilbc-mode %d\n",
|
||||
pj_ansi_snprintf(line, sizeof(line), "#using default --ilbc-mode %d\n",
|
||||
config->media_cfg.ilbc_mode);
|
||||
pj_strcat2(&cfg, line);
|
||||
}
|
||||
|
||||
/* RTP drop */
|
||||
if (config->media_cfg.tx_drop_pct) {
|
||||
pj_ansi_sprintf(line, "--tx-drop-pct %d\n",
|
||||
pj_ansi_snprintf(line, sizeof(line), "--tx-drop-pct %d\n",
|
||||
config->media_cfg.tx_drop_pct);
|
||||
pj_strcat2(&cfg, line);
|
||||
|
||||
}
|
||||
if (config->media_cfg.rx_drop_pct) {
|
||||
pj_ansi_sprintf(line, "--rx-drop-pct %d\n",
|
||||
pj_ansi_snprintf(line, sizeof(line), "--rx-drop-pct %d\n",
|
||||
config->media_cfg.rx_drop_pct);
|
||||
pj_strcat2(&cfg, line);
|
||||
|
||||
}
|
||||
|
||||
/* Start RTP port. */
|
||||
pj_ansi_sprintf(line, "--rtp-port %d\n",
|
||||
pj_ansi_snprintf(line, sizeof(line), "--rtp-port %d\n",
|
||||
config->rtp_cfg.port);
|
||||
pj_strcat2(&cfg, line);
|
||||
|
||||
/* Disable codec */
|
||||
for (i=0; i<config->codec_dis_cnt; ++i) {
|
||||
pj_ansi_sprintf(line, "--dis-codec %s\n",
|
||||
pj_ansi_snprintf(line, sizeof(line), "--dis-codec %s\n",
|
||||
config->codec_dis[i].ptr);
|
||||
pj_strcat2(&cfg, line);
|
||||
}
|
||||
/* Add codec. */
|
||||
for (i=0; i<config->codec_cnt; ++i) {
|
||||
pj_ansi_sprintf(line, "--add-codec %s\n",
|
||||
pj_ansi_snprintf(line, sizeof(line), "--add-codec %s\n",
|
||||
config->codec_arg[i].ptr);
|
||||
pj_strcat2(&cfg, line);
|
||||
}
|
||||
|
@ -2293,26 +2301,26 @@ int write_settings(pjsua_app_config *config, char *buf, pj_size_t max)
|
|||
|
||||
/* Auto-answer. */
|
||||
if (config->auto_answer != 0) {
|
||||
pj_ansi_sprintf(line, "--auto-answer %d\n",
|
||||
pj_ansi_snprintf(line, sizeof(line), "--auto-answer %d\n",
|
||||
config->auto_answer);
|
||||
pj_strcat2(&cfg, line);
|
||||
}
|
||||
|
||||
/* accept-redirect */
|
||||
if (config->redir_op != PJSIP_REDIRECT_ACCEPT_REPLACE) {
|
||||
pj_ansi_sprintf(line, "--accept-redirect %d\n",
|
||||
pj_ansi_snprintf(line, sizeof(line), "--accept-redirect %d\n",
|
||||
config->redir_op);
|
||||
pj_strcat2(&cfg, line);
|
||||
}
|
||||
|
||||
/* Max calls. */
|
||||
pj_ansi_sprintf(line, "--max-calls %d\n",
|
||||
pj_ansi_snprintf(line, sizeof(line), "--max-calls %d\n",
|
||||
config->cfg.max_calls);
|
||||
pj_strcat2(&cfg, line);
|
||||
|
||||
/* Uas-duration. */
|
||||
if (config->duration != PJSUA_APP_NO_LIMIT_DURATION) {
|
||||
pj_ansi_sprintf(line, "--duration %d\n",
|
||||
pj_ansi_snprintf(line, sizeof(line), "--duration %d\n",
|
||||
config->duration);
|
||||
pj_strcat2(&cfg, line);
|
||||
}
|
||||
|
@ -2335,7 +2343,7 @@ int write_settings(pjsua_app_config *config, char *buf, pj_size_t max)
|
|||
|
||||
/* Add buddies. */
|
||||
for (i=0; i<config->buddy_cnt; ++i) {
|
||||
pj_ansi_sprintf(line, "--add-buddy %.*s\n",
|
||||
pj_ansi_snprintf(line, sizeof(line), "--add-buddy %.*s\n",
|
||||
(int)config->buddy_cfg[i].uri.slen,
|
||||
config->buddy_cfg[i].uri.ptr);
|
||||
pj_strcat2(&cfg, line);
|
||||
|
@ -2349,17 +2357,17 @@ int write_settings(pjsua_app_config *config, char *buf, pj_size_t max)
|
|||
}
|
||||
/* Session Timer extension */
|
||||
if (config->cfg.use_timer) {
|
||||
pj_ansi_sprintf(line, "--use-timer %d\n",
|
||||
pj_ansi_snprintf(line, sizeof(line), "--use-timer %d\n",
|
||||
config->cfg.use_timer);
|
||||
pj_strcat2(&cfg, line);
|
||||
}
|
||||
if (config->cfg.timer_setting.min_se != 90) {
|
||||
pj_ansi_sprintf(line, "--timer-min-se %d\n",
|
||||
pj_ansi_snprintf(line, sizeof(line), "--timer-min-se %d\n",
|
||||
config->cfg.timer_setting.min_se);
|
||||
pj_strcat2(&cfg, line);
|
||||
}
|
||||
if (config->cfg.timer_setting.sess_expires != PJSIP_SESS_TIMER_DEF_SE) {
|
||||
pj_ansi_sprintf(line, "--timer-se %d\n",
|
||||
pj_ansi_snprintf(line, sizeof(line), "--timer-se %d\n",
|
||||
config->cfg.timer_setting.sess_expires);
|
||||
pj_strcat2(&cfg, line);
|
||||
}
|
||||
|
|
|
@ -1667,13 +1667,15 @@ static void ui_adjust_volume()
|
|||
{
|
||||
char buf[128];
|
||||
char text[128];
|
||||
sprintf(buf, "Adjust mic level: [%4.1fx] ", app_config.mic_level);
|
||||
snprintf(buf, sizeof(buf), "Adjust mic level: [%4.1fx] ",
|
||||
app_config.mic_level);
|
||||
if (simple_input(buf,text,sizeof(text))) {
|
||||
char *err;
|
||||
app_config.mic_level = (float)strtod(text, &err);
|
||||
pjsua_conf_adjust_rx_level(0, app_config.mic_level);
|
||||
}
|
||||
sprintf(buf, "Adjust speaker level: [%4.1fx] ", app_config.speaker_level);
|
||||
snprintf(buf, sizeof(buf), "Adjust speaker level: [%4.1fx] ",
|
||||
app_config.speaker_level);
|
||||
if (simple_input(buf,text,sizeof(text))) {
|
||||
char *err;
|
||||
app_config.speaker_level = (float)strtod(text, &err);
|
||||
|
|
|
@ -65,7 +65,7 @@ static void print_menu(const char *indent, char *menu_id, gui_menu *menu)
|
|||
for (i=0; i<menu->submenu_cnt; ++i) {
|
||||
char child_id[10];
|
||||
|
||||
pj_ansi_sprintf(child_id, "%s%u", menu_id, i);
|
||||
pj_ansi_snprintf(child_id, sizeof(child_id), "%s%u", menu_id, i);
|
||||
|
||||
if (!menu->submenus[i])
|
||||
puts("");
|
||||
|
@ -85,7 +85,7 @@ pj_status_t gui_start(gui_menu *menu)
|
|||
puts("---------");
|
||||
for (i=0; i<menu->submenu_cnt; ++i) {
|
||||
char menu_id[11];
|
||||
pj_ansi_sprintf(menu_id, "%u", i);
|
||||
pj_ansi_snprintf(menu_id, sizeof(menu_id), "%u", i);
|
||||
print_menu("", menu_id, menu->submenus[i]);
|
||||
}
|
||||
puts("");
|
||||
|
|
|
@ -250,7 +250,7 @@ pj_status_t app_main(pj_cli_t *c)
|
|||
if (status != PJ_SUCCESS)
|
||||
break;
|
||||
|
||||
//pj_ansi_strcpy(cmdline, "sayhello {Teluu Inc.}");
|
||||
//pj_ansi_strxcpy(cmdline, "sayhello {Teluu Inc.}", sizeof(cmdline));
|
||||
if (status == PJ_CLI_EEXIT) {
|
||||
/* exit is called */
|
||||
break;
|
||||
|
|
|
@ -227,7 +227,8 @@ int main(int argc, char *argv[])
|
|||
);
|
||||
if (status != PJ_SUCCESS) {
|
||||
char title[80];
|
||||
pj_ansi_sprintf(title, "Unable to use %s", argv[i+pj_optind]);
|
||||
pj_ansi_snprintf(title, sizeof(title), "Unable to use %s",
|
||||
argv[i+pj_optind]);
|
||||
app_perror(THIS_FILE, title, status);
|
||||
usage();
|
||||
return 1;
|
||||
|
|
|
@ -105,7 +105,7 @@ int dummy_function()
|
|||
{
|
||||
pj_caching_pool cp;
|
||||
|
||||
sprintf(NULL, "%d", 0);
|
||||
snprintf(NULL, 0, "%d", 0);
|
||||
rand();
|
||||
|
||||
#ifdef HAS_PJLIB
|
||||
|
|
|
@ -747,7 +747,8 @@ static void tx_tick(const pj_time_val *t)
|
|||
|
||||
pj_time_val_normalize(&strm->state.tx.next_schedule);
|
||||
|
||||
sprintf(log_msg, "** Packet #%u tick is at %d.%03d, %d ms jitter applied **",
|
||||
snprintf(log_msg, sizeof(log_msg),
|
||||
"** Packet #%u tick is at %d.%03d, %d ms jitter applied **",
|
||||
strm->state.tx.total_tx+1,
|
||||
(int)strm->state.tx.next_schedule.sec, (int)strm->state.tx.next_schedule.msec,
|
||||
jitter);
|
||||
|
|
|
@ -459,7 +459,7 @@ int main(int argc, char *argv[])
|
|||
}
|
||||
pj_sockaddr_print(&hostaddr, hostip, sizeof(hostip), 2);
|
||||
|
||||
pj_ansi_sprintf(temp, "<sip:simpleuac@%s:%d>",
|
||||
pj_ansi_snprintf(temp, sizeof(temp), "<sip:simpleuac@%s:%d>",
|
||||
hostip, SIP_PORT);
|
||||
local_uri = pj_str(temp);
|
||||
|
||||
|
@ -743,7 +743,7 @@ static pj_bool_t on_rx_request( pjsip_rx_data *rdata )
|
|||
}
|
||||
pj_sockaddr_print(&hostaddr, hostip, sizeof(hostip), 2);
|
||||
|
||||
pj_ansi_sprintf(temp, "<sip:simpleuas@%s:%d>",
|
||||
pj_ansi_snprintf(temp, sizeof(temp), "<sip:simpleuas@%s:%d>",
|
||||
hostip, SIP_PORT);
|
||||
local_uri = pj_str(temp);
|
||||
|
||||
|
|
|
@ -495,7 +495,8 @@ static pj_bool_t on_rx_request( pjsip_rx_data *rdata )
|
|||
return PJ_TRUE;
|
||||
}
|
||||
pj_sockaddr_print(&hostaddr, hostip, sizeof(hostip), 2);
|
||||
pj_ansi_sprintf(temp, "<sip:sipecho@%s:%d>", hostip, sip_port);
|
||||
pj_ansi_snprintf(temp, sizeof(temp), "<sip:sipecho@%s:%d>",
|
||||
hostip, sip_port);
|
||||
local_uri = pj_str(temp);
|
||||
|
||||
status = pjsip_dlg_create_uas_and_inc_lock( pjsip_ua_instance(), rdata,
|
||||
|
@ -641,7 +642,7 @@ int main(int argc, char *argv[])
|
|||
CHECK( pj_gethostip(sip_af, &hostaddr) );
|
||||
pj_sockaddr_print(&hostaddr, hostip, sizeof(hostip), 2);
|
||||
|
||||
pj_ansi_sprintf(temp, "<sip:sipecho@%s:%d>",
|
||||
pj_ansi_snprintf(temp, sizeof(temp), "<sip:sipecho@%s:%d>",
|
||||
hostip, sip_port);
|
||||
local_uri = pj_str(temp);
|
||||
|
||||
|
|
|
@ -985,7 +985,8 @@ static pj_status_t init_options(int argc, char *argv[])
|
|||
app.uri_to_call = pj_str(argv[pj_optind]);
|
||||
|
||||
/* Build local URI and contact */
|
||||
pj_ansi_sprintf( local_uri, "sip:%s:%d", app.local_addr.ptr, app.sip_port);
|
||||
pj_ansi_snprintf(local_uri, sizeof(local_uri),
|
||||
"sip:%s:%d", app.local_addr.ptr, app.sip_port);
|
||||
app.local_uri = pj_str(local_uri);
|
||||
app.local_contact = app.local_uri;
|
||||
|
||||
|
@ -1063,7 +1064,7 @@ static pj_status_t create_sdp( pj_pool_t *pool,
|
|||
pjmedia_sdp_rtpmap rtpmap;
|
||||
char ptstr[10];
|
||||
|
||||
sprintf(ptstr, "%d", app.audio_codec.pt);
|
||||
snprintf(ptstr, sizeof(ptstr), "%d", app.audio_codec.pt);
|
||||
pj_strdup2(pool, &m->desc.fmt[0], ptstr);
|
||||
rtpmap.pt = m->desc.fmt[0];
|
||||
rtpmap.clock_rate = app.audio_codec.clock_rate;
|
||||
|
@ -1537,16 +1538,16 @@ static void call_get_duration(int call_index, pj_time_val *dur)
|
|||
}
|
||||
|
||||
|
||||
static const char *good_number(char *buf, pj_int32_t val)
|
||||
static const char *good_number(char *buf, unsigned buf_size, pj_int32_t val)
|
||||
{
|
||||
if (val < 1000) {
|
||||
pj_ansi_sprintf(buf, "%d", val);
|
||||
pj_ansi_snprintf(buf, buf_size, "%d", val);
|
||||
} else if (val < 1000000) {
|
||||
pj_ansi_sprintf(buf, "%d.%02dK",
|
||||
pj_ansi_snprintf(buf, buf_size, "%d.%02dK",
|
||||
val / 1000,
|
||||
(val % 1000) / 100);
|
||||
} else {
|
||||
pj_ansi_sprintf(buf, "%d.%02dM",
|
||||
pj_ansi_snprintf(buf, buf_size, "%d.%02dM",
|
||||
val / 1000000,
|
||||
(val % 1000000) / 10000);
|
||||
}
|
||||
|
@ -1745,14 +1746,14 @@ static void print_avg_stat(void)
|
|||
|
||||
/* rx */
|
||||
|
||||
good_number(srx_min, min_stat.rx.pkt),
|
||||
good_number(srx_avg, avg_stat.rx.pkt),
|
||||
good_number(srx_max, max_stat.rx.pkt),
|
||||
good_number(srx_min, sizeof(srx_min), min_stat.rx.pkt),
|
||||
good_number(srx_avg, sizeof(srx_avg), avg_stat.rx.pkt),
|
||||
good_number(srx_max, sizeof(srx_max), max_stat.rx.pkt),
|
||||
"packets",
|
||||
|
||||
good_number(brx_min, min_stat.rx.bytes),
|
||||
good_number(brx_avg, avg_stat.rx.bytes),
|
||||
good_number(brx_max, max_stat.rx.bytes),
|
||||
good_number(brx_min, sizeof(brx_min), min_stat.rx.bytes),
|
||||
good_number(brx_avg, sizeof(brx_avg), avg_stat.rx.bytes),
|
||||
good_number(brx_max, sizeof(brx_max), max_stat.rx.bytes),
|
||||
"bytes",
|
||||
|
||||
min_stat.rx.loss, avg_stat.rx.loss, max_stat.rx.loss,
|
||||
|
@ -1777,14 +1778,14 @@ static void print_avg_stat(void)
|
|||
|
||||
/* tx */
|
||||
|
||||
good_number(stx_min, min_stat.tx.pkt),
|
||||
good_number(stx_avg, avg_stat.tx.pkt),
|
||||
good_number(stx_max, max_stat.tx.pkt),
|
||||
good_number(stx_min, sizeof(stx_min), min_stat.tx.pkt),
|
||||
good_number(stx_avg, sizeof(stx_avg), avg_stat.tx.pkt),
|
||||
good_number(stx_max, sizeof(stx_max), max_stat.tx.pkt),
|
||||
"packets",
|
||||
|
||||
good_number(btx_min, min_stat.tx.bytes),
|
||||
good_number(btx_avg, avg_stat.tx.bytes),
|
||||
good_number(btx_max, max_stat.tx.bytes),
|
||||
good_number(btx_min, sizeof(btx_min), min_stat.tx.bytes),
|
||||
good_number(btx_avg, sizeof(btx_avg), avg_stat.tx.bytes),
|
||||
good_number(btx_max, sizeof(btx_max), max_stat.tx.bytes),
|
||||
"bytes",
|
||||
|
||||
min_stat.tx.loss, avg_stat.tx.loss, max_stat.tx.loss,
|
||||
|
|
|
@ -129,8 +129,8 @@ static void print_call(int call_index)
|
|||
audio->si.fmt.encoding_name.ptr,
|
||||
audio->clock_rate,
|
||||
audio->samples_per_frame * 1000 / audio->clock_rate,
|
||||
good_number(bps, audio->bytes_per_frame * audio->clock_rate / audio->samples_per_frame),
|
||||
good_number(ipbps, (audio->bytes_per_frame+32) * audio->clock_rate / audio->samples_per_frame)));
|
||||
good_number(bps, sizeof(bps), audio->bytes_per_frame * audio->clock_rate / audio->samples_per_frame),
|
||||
good_number(ipbps, sizeof(ipbps), (audio->bytes_per_frame+32) * audio->clock_rate / audio->samples_per_frame)));
|
||||
|
||||
if (audio->rtcp.stat.rx.update_cnt == 0)
|
||||
pj_ansi_strxcpy(last_update, "never", sizeof(last_update));
|
||||
|
@ -153,9 +153,9 @@ static void print_call(int call_index)
|
|||
" loss period: %7.3f %7.3f %7.3f %7.3f%s\n"
|
||||
" jitter : %7.3f %7.3f %7.3f %7.3f%s",
|
||||
last_update,
|
||||
good_number(packets, audio->rtcp.stat.rx.pkt),
|
||||
good_number(bytes, audio->rtcp.stat.rx.bytes),
|
||||
good_number(ipbytes, audio->rtcp.stat.rx.bytes + audio->rtcp.stat.rx.pkt * 32),
|
||||
good_number(packets, sizeof(packets), audio->rtcp.stat.rx.pkt),
|
||||
good_number(bytes, sizeof(bytes), audio->rtcp.stat.rx.bytes),
|
||||
good_number(ipbytes, sizeof(ipbytes), audio->rtcp.stat.rx.bytes + audio->rtcp.stat.rx.pkt * 32),
|
||||
"",
|
||||
audio->rtcp.stat.rx.loss,
|
||||
audio->rtcp.stat.rx.loss * 100.0 / (audio->rtcp.stat.rx.pkt + audio->rtcp.stat.rx.loss),
|
||||
|
@ -198,9 +198,9 @@ static void print_call(int call_index)
|
|||
" loss period: %7.3f %7.3f %7.3f %7.3f%s\n"
|
||||
" jitter : %7.3f %7.3f %7.3f %7.3f%s",
|
||||
last_update,
|
||||
good_number(packets, audio->rtcp.stat.tx.pkt),
|
||||
good_number(bytes, audio->rtcp.stat.tx.bytes),
|
||||
good_number(ipbytes, audio->rtcp.stat.tx.bytes + audio->rtcp.stat.tx.pkt * 32),
|
||||
good_number(packets, sizeof(packets), audio->rtcp.stat.tx.pkt),
|
||||
good_number(bytes, sizeof(bytes), audio->rtcp.stat.tx.bytes),
|
||||
good_number(ipbytes, sizeof(ipbytes), audio->rtcp.stat.tx.bytes + audio->rtcp.stat.tx.pkt * 32),
|
||||
"",
|
||||
audio->rtcp.stat.tx.loss,
|
||||
audio->rtcp.stat.tx.loss * 100.0 / (audio->rtcp.stat.tx.pkt + audio->rtcp.stat.tx.loss),
|
||||
|
|
|
@ -910,16 +910,16 @@ on_exit:
|
|||
|
||||
|
||||
|
||||
static const char *good_number(char *buf, pj_int32_t val)
|
||||
static const char *good_number(char *buf, unsigned buf_size, pj_int32_t val)
|
||||
{
|
||||
if (val < 1000) {
|
||||
pj_ansi_sprintf(buf, "%d", val);
|
||||
pj_ansi_snprintf(buf, buf_size, "%d", val);
|
||||
} else if (val < 1000000) {
|
||||
pj_ansi_sprintf(buf, "%d.%dK",
|
||||
pj_ansi_snprintf(buf, buf_size, "%d.%dK",
|
||||
val / 1000,
|
||||
(val % 1000) / 100);
|
||||
} else {
|
||||
pj_ansi_sprintf(buf, "%d.%02dM",
|
||||
pj_ansi_snprintf(buf, buf_size, "%d.%02dM",
|
||||
val / 1000000,
|
||||
(val % 1000000) / 10000);
|
||||
}
|
||||
|
@ -940,9 +940,9 @@ static const char *good_number(char *buf, pj_int32_t val)
|
|||
|
||||
#define PRINT_VOIP_MTC_VAL(s, v) \
|
||||
if (v == 127) \
|
||||
sprintf(s, "(na)"); \
|
||||
snprintf(s, sizeof(s), "(na)"); \
|
||||
else \
|
||||
sprintf(s, "%d", v)
|
||||
snprintf(s, sizeof(s), "%d", v)
|
||||
|
||||
|
||||
/*
|
||||
|
@ -957,6 +957,8 @@ static void print_stream_stat(pjmedia_stream *stream,
|
|||
pjmedia_rtcp_stat stat;
|
||||
pj_time_val now;
|
||||
|
||||
#define SNPRINTF2(s,val) pj_ansi_strxcpy(s, val, sizeof(s))
|
||||
#define SNPRINTF3(s,fmt,val) snprintf(s, sizeof(s), fmt, val)
|
||||
|
||||
pj_gettimeofday(&now);
|
||||
pjmedia_stream_get_stat(stream, &stat);
|
||||
|
@ -966,7 +968,8 @@ static void print_stream_stat(pjmedia_stream *stream,
|
|||
|
||||
/* Print duration */
|
||||
PJ_TIME_VAL_SUB(now, stat.start);
|
||||
sprintf(duration, " Duration: %02ld:%02ld:%02ld.%03ld",
|
||||
snprintf(duration, sizeof(duration),
|
||||
" Duration: %02ld:%02ld:%02ld.%03ld",
|
||||
now.sec / 3600,
|
||||
(now.sec % 3600) / 60,
|
||||
(now.sec % 60),
|
||||
|
@ -976,8 +979,8 @@ static void print_stream_stat(pjmedia_stream *stream,
|
|||
printf(" Info: audio %dHz, %dms/frame, %sB/s (%sB/s +IP hdr)\n",
|
||||
PJMEDIA_PIA_SRATE(&port->info),
|
||||
PJMEDIA_PIA_PTIME(&port->info),
|
||||
good_number(bps, (codec_param->info.avg_bps+7)/8),
|
||||
good_number(ipbps, ((codec_param->info.avg_bps+7)/8) +
|
||||
good_number(bps, sizeof(bps), (codec_param->info.avg_bps+7)/8),
|
||||
good_number(ipbps, sizeof(ipbps), ((codec_param->info.avg_bps+7)/8) +
|
||||
(40 * 1000 /
|
||||
codec_param->setting.frm_per_pkt /
|
||||
codec_param->info.frm_ptime)));
|
||||
|
@ -1002,9 +1005,9 @@ static void print_stream_stat(pjmedia_stream *stream,
|
|||
" loss period: %7.3f %7.3f %7.3f %7.3f %7.3f%s\n"
|
||||
" jitter : %7.3f %7.3f %7.3f %7.3f %7.3f%s\n",
|
||||
last_update,
|
||||
good_number(packets, stat.rx.pkt),
|
||||
good_number(bytes, stat.rx.bytes),
|
||||
good_number(ipbytes, stat.rx.bytes + stat.rx.pkt * 32),
|
||||
good_number(packets, sizeof(packets), stat.rx.pkt),
|
||||
good_number(bytes, sizeof(bytes), stat.rx.bytes),
|
||||
good_number(ipbytes, sizeof(ipbytes), stat.rx.bytes + stat.rx.pkt * 32),
|
||||
"",
|
||||
stat.rx.loss,
|
||||
stat.rx.loss * 100.0 / (stat.rx.pkt + stat.rx.loss),
|
||||
|
@ -1048,9 +1051,9 @@ static void print_stream_stat(pjmedia_stream *stream,
|
|||
" loss period: %7.3f %7.3f %7.3f %7.3f %7.3f%s\n"
|
||||
" jitter : %7.3f %7.3f %7.3f %7.3f %7.3f%s\n",
|
||||
last_update,
|
||||
good_number(packets, stat.tx.pkt),
|
||||
good_number(bytes, stat.tx.bytes),
|
||||
good_number(ipbytes, stat.tx.bytes + stat.tx.pkt * 32),
|
||||
good_number(packets, sizeof(packets), stat.tx.pkt),
|
||||
good_number(bytes, sizeof(bytes), stat.tx.bytes),
|
||||
good_number(ipbytes, sizeof(ipbytes), stat.tx.bytes + stat.tx.pkt * 32),
|
||||
"",
|
||||
stat.tx.loss,
|
||||
stat.tx.loss * 100.0 / (stat.tx.pkt + stat.tx.loss),
|
||||
|
@ -1103,14 +1106,14 @@ static void print_stream_stat(pjmedia_stream *stream,
|
|||
puts(" Statistics Summary");
|
||||
|
||||
if (xr_stat.rx.stat_sum.l)
|
||||
sprintf(loss, "%d", xr_stat.rx.stat_sum.lost);
|
||||
SNPRINTF3(loss, "%d", xr_stat.rx.stat_sum.lost);
|
||||
else
|
||||
sprintf(loss, "(na)");
|
||||
SNPRINTF2(loss, "(na)");
|
||||
|
||||
if (xr_stat.rx.stat_sum.d)
|
||||
sprintf(dup, "%d", xr_stat.rx.stat_sum.dup);
|
||||
SNPRINTF3(dup, "%d", xr_stat.rx.stat_sum.dup);
|
||||
else
|
||||
sprintf(dup, "(na)");
|
||||
SNPRINTF2(dup, "(na)");
|
||||
|
||||
if (xr_stat.rx.stat_sum.j) {
|
||||
unsigned jmin, jmax, jmean, jdev;
|
||||
|
@ -1124,19 +1127,19 @@ static void print_stream_stat(pjmedia_stream *stream,
|
|||
SAMPLES_TO_USEC(jdev,
|
||||
pj_math_stat_get_stddev(&xr_stat.rx.stat_sum.jitter),
|
||||
port->info.fmt.det.aud.clock_rate);
|
||||
sprintf(jitter, "%7.3f %7.3f %7.3f %7.3f",
|
||||
snprintf(jitter, sizeof(jitter), "%7.3f %7.3f %7.3f %7.3f",
|
||||
jmin/1000.0, jmean/1000.0, jmax/1000.0, jdev/1000.0);
|
||||
} else
|
||||
sprintf(jitter, "(report not available)");
|
||||
SNPRINTF2(jitter, "(report not available)");
|
||||
|
||||
if (xr_stat.rx.stat_sum.t) {
|
||||
sprintf(toh, "%11d %11d %11d %11d",
|
||||
snprintf(toh, sizeof(toh), "%11d %11d %11d %11d",
|
||||
xr_stat.rx.stat_sum.toh.min,
|
||||
xr_stat.rx.stat_sum.toh.mean,
|
||||
xr_stat.rx.stat_sum.toh.max,
|
||||
pj_math_stat_get_stddev(&xr_stat.rx.stat_sum.toh));
|
||||
} else
|
||||
sprintf(toh, "(report not available)");
|
||||
SNPRINTF2(toh, "(report not available)");
|
||||
|
||||
if (xr_stat.rx.stat_sum.update.sec == 0)
|
||||
pj_ansi_strxcpy(last_update, "never", sizeof(last_update));
|
||||
|
@ -1167,14 +1170,14 @@ static void print_stream_stat(pjmedia_stream *stream,
|
|||
);
|
||||
|
||||
if (xr_stat.tx.stat_sum.l)
|
||||
sprintf(loss, "%d", xr_stat.tx.stat_sum.lost);
|
||||
SNPRINTF3(loss, "%d", xr_stat.tx.stat_sum.lost);
|
||||
else
|
||||
sprintf(loss, "(na)");
|
||||
SNPRINTF2(loss, "(na)");
|
||||
|
||||
if (xr_stat.tx.stat_sum.d)
|
||||
sprintf(dup, "%d", xr_stat.tx.stat_sum.dup);
|
||||
SNPRINTF3(dup, "%d", xr_stat.tx.stat_sum.dup);
|
||||
else
|
||||
sprintf(dup, "(na)");
|
||||
SNPRINTF2(dup, "(na)");
|
||||
|
||||
if (xr_stat.tx.stat_sum.j) {
|
||||
unsigned jmin, jmax, jmean, jdev;
|
||||
|
@ -1188,19 +1191,19 @@ static void print_stream_stat(pjmedia_stream *stream,
|
|||
SAMPLES_TO_USEC(jdev,
|
||||
pj_math_stat_get_stddev(&xr_stat.tx.stat_sum.jitter),
|
||||
port->info.fmt.det.aud.clock_rate);
|
||||
sprintf(jitter, "%7.3f %7.3f %7.3f %7.3f",
|
||||
snprintf(jitter, sizeof(jitter), "%7.3f %7.3f %7.3f %7.3f",
|
||||
jmin/1000.0, jmean/1000.0, jmax/1000.0, jdev/1000.0);
|
||||
} else
|
||||
sprintf(jitter, "(report not available)");
|
||||
SNPRINTF2(jitter, "(report not available)");
|
||||
|
||||
if (xr_stat.tx.stat_sum.t) {
|
||||
sprintf(toh, "%11d %11d %11d %11d",
|
||||
snprintf(toh, sizeof(toh), "%11d %11d %11d %11d",
|
||||
xr_stat.tx.stat_sum.toh.min,
|
||||
xr_stat.tx.stat_sum.toh.mean,
|
||||
xr_stat.tx.stat_sum.toh.max,
|
||||
pj_math_stat_get_stddev(&xr_stat.rx.stat_sum.toh));
|
||||
} else
|
||||
sprintf(toh, "(report not available)");
|
||||
SNPRINTF2(toh, "(report not available)");
|
||||
|
||||
if (xr_stat.tx.stat_sum.update.sec == 0)
|
||||
pj_ansi_strxcpy(last_update, "never", sizeof(last_update));
|
||||
|
@ -1243,33 +1246,33 @@ static void print_stream_stat(pjmedia_stream *stream,
|
|||
|
||||
switch ((xr_stat.rx.voip_mtc.rx_config>>6) & 3) {
|
||||
case PJMEDIA_RTCP_XR_PLC_DIS:
|
||||
sprintf(plc, "DISABLED");
|
||||
SNPRINTF2(plc, "DISABLED");
|
||||
break;
|
||||
case PJMEDIA_RTCP_XR_PLC_ENH:
|
||||
sprintf(plc, "ENHANCED");
|
||||
SNPRINTF2(plc, "ENHANCED");
|
||||
break;
|
||||
case PJMEDIA_RTCP_XR_PLC_STD:
|
||||
sprintf(plc, "STANDARD");
|
||||
SNPRINTF2(plc, "STANDARD");
|
||||
break;
|
||||
case PJMEDIA_RTCP_XR_PLC_UNK:
|
||||
default:
|
||||
sprintf(plc, "UNKNOWN");
|
||||
SNPRINTF2(plc, "UNKNOWN");
|
||||
break;
|
||||
}
|
||||
|
||||
switch ((xr_stat.rx.voip_mtc.rx_config>>4) & 3) {
|
||||
case PJMEDIA_RTCP_XR_JB_FIXED:
|
||||
sprintf(jba, "FIXED");
|
||||
SNPRINTF2(jba, "FIXED");
|
||||
break;
|
||||
case PJMEDIA_RTCP_XR_JB_ADAPTIVE:
|
||||
sprintf(jba, "ADAPTIVE");
|
||||
SNPRINTF2(jba, "ADAPTIVE");
|
||||
break;
|
||||
default:
|
||||
sprintf(jba, "UNKNOWN");
|
||||
SNPRINTF2(jba, "UNKNOWN");
|
||||
break;
|
||||
}
|
||||
|
||||
sprintf(jbr, "%d", xr_stat.rx.voip_mtc.rx_config & 0x0F);
|
||||
SNPRINTF3(jbr, "%d", xr_stat.rx.voip_mtc.rx_config & 0x0F);
|
||||
|
||||
if (xr_stat.rx.voip_mtc.update.sec == 0)
|
||||
pj_ansi_strxcpy(last_update, "never", sizeof(last_update));
|
||||
|
@ -1331,33 +1334,33 @@ static void print_stream_stat(pjmedia_stream *stream,
|
|||
|
||||
switch ((xr_stat.tx.voip_mtc.rx_config>>6) & 3) {
|
||||
case PJMEDIA_RTCP_XR_PLC_DIS:
|
||||
sprintf(plc, "DISABLED");
|
||||
SNPRINTF2(plc, "DISABLED");
|
||||
break;
|
||||
case PJMEDIA_RTCP_XR_PLC_ENH:
|
||||
sprintf(plc, "ENHANCED");
|
||||
SNPRINTF2(plc, "ENHANCED");
|
||||
break;
|
||||
case PJMEDIA_RTCP_XR_PLC_STD:
|
||||
sprintf(plc, "STANDARD");
|
||||
SNPRINTF2(plc, "STANDARD");
|
||||
break;
|
||||
case PJMEDIA_RTCP_XR_PLC_UNK:
|
||||
default:
|
||||
sprintf(plc, "unknown");
|
||||
SNPRINTF2(plc, "unknown");
|
||||
break;
|
||||
}
|
||||
|
||||
switch ((xr_stat.tx.voip_mtc.rx_config>>4) & 3) {
|
||||
case PJMEDIA_RTCP_XR_JB_FIXED:
|
||||
sprintf(jba, "FIXED");
|
||||
SNPRINTF2(jba, "FIXED");
|
||||
break;
|
||||
case PJMEDIA_RTCP_XR_JB_ADAPTIVE:
|
||||
sprintf(jba, "ADAPTIVE");
|
||||
SNPRINTF2(jba, "ADAPTIVE");
|
||||
break;
|
||||
default:
|
||||
sprintf(jba, "unknown");
|
||||
SNPRINTF2(jba, "unknown");
|
||||
break;
|
||||
}
|
||||
|
||||
sprintf(jbr, "%d", xr_stat.tx.voip_mtc.rx_config & 0x0F);
|
||||
SNPRINTF3(jbr, "%d", xr_stat.tx.voip_mtc.rx_config & 0x0F);
|
||||
|
||||
if (xr_stat.tx.voip_mtc.update.sec == 0)
|
||||
pj_ansi_strxcpy(last_update, "never", sizeof(last_update));
|
||||
|
|
|
@ -924,7 +924,7 @@ pj_status_t acquire_call(const char *title,
|
|||
pjsua_call_id call_id,
|
||||
pjsua_call **p_call,
|
||||
pjsip_dialog **p_dlg);
|
||||
const char *good_number(char *buf, pj_int32_t val);
|
||||
const char *good_number(char *buf, unsigned buf_size, pj_int32_t val);
|
||||
void print_call(const char *title,
|
||||
int call_id,
|
||||
char *buf, pj_size_t size);
|
||||
|
|
|
@ -1288,7 +1288,7 @@ static int pjsip_contact_hdr_print( pjsip_contact_hdr *hdr, char *buf,
|
|||
return -1;
|
||||
|
||||
/*
|
||||
printed = sprintf(buf, ";q=%u.%03u",
|
||||
printed = pj_ansi_snprintf(buf, size, ";q=%u.%03u",
|
||||
hdr->q1000/1000, hdr->q1000 % 1000);
|
||||
*/
|
||||
pj_memcpy(buf, ";q=", 3);
|
||||
|
@ -2161,11 +2161,13 @@ PJ_DEF(pjsip_warning_hdr*) pjsip_warning_hdr_create( pj_pool_t *pool,
|
|||
{
|
||||
const pj_str_t str_warning = { "Warning", 7 };
|
||||
pj_str_t hvalue;
|
||||
unsigned buflen = 10 + /* code */
|
||||
host->slen + 2 + /* host */
|
||||
text->slen + 2; /* text */
|
||||
|
||||
hvalue.ptr = (char*) pj_pool_alloc(pool, 10 + /* code */
|
||||
host->slen + 2 + /* host */
|
||||
text->slen + 2); /* text */
|
||||
hvalue.slen = pj_ansi_sprintf(hvalue.ptr, "%u %.*s \"%.*s\"",
|
||||
hvalue.ptr = (char*) pj_pool_alloc(pool, buflen);
|
||||
hvalue.slen = pj_ansi_snprintf(hvalue.ptr, buflen,
|
||||
"%u %.*s \"%.*s\"",
|
||||
code, (int)host->slen, host->ptr,
|
||||
(int)text->slen, text->ptr);
|
||||
|
||||
|
|
|
@ -18,16 +18,20 @@
|
|||
#include <pjsua-lib/pjsua.h>
|
||||
#include <pjsua-lib/pjsua_internal.h>
|
||||
|
||||
const char *good_number(char *buf, pj_int32_t val)
|
||||
#define SNPRINTF2(s,val) pj_ansi_strxcpy(s, val, sizeof(s))
|
||||
#define SNPRINTF3(s,fmt,val) pj_ansi_snprintf(s, sizeof(s), fmt, val)
|
||||
|
||||
|
||||
const char *good_number(char *buf, unsigned buf_size, pj_int32_t val)
|
||||
{
|
||||
if (val < 1000) {
|
||||
pj_ansi_sprintf(buf, "%d", val);
|
||||
pj_ansi_snprintf(buf, buf_size, "%d", val);
|
||||
} else if (val < 1000000) {
|
||||
pj_ansi_sprintf(buf, "%d.%dK",
|
||||
pj_ansi_snprintf(buf, buf_size, "%d.%dK",
|
||||
val / 1000,
|
||||
(val % 1000) / 100);
|
||||
} else {
|
||||
pj_ansi_sprintf(buf, "%d.%02dM",
|
||||
pj_ansi_snprintf(buf, buf_size, "%d.%02dM",
|
||||
val / 1000000,
|
||||
(val % 1000000) / 10000);
|
||||
}
|
||||
|
@ -83,11 +87,11 @@ static unsigned dump_media_stat(const char *indent,
|
|||
last_update,
|
||||
|
||||
indent,
|
||||
good_number(packets, stat->rx.pkt),
|
||||
good_number(bytes, stat->rx.bytes),
|
||||
good_number(ipbytes, stat->rx.bytes + stat->rx.pkt * 40),
|
||||
good_number(avg_bps, (pj_int32_t)((pj_int64_t)stat->rx.bytes * 8 * 1000 / PJ_TIME_VAL_MSEC(media_duration))),
|
||||
good_number(avg_ipbps, (pj_int32_t)(((pj_int64_t)stat->rx.bytes + stat->rx.pkt * 40) * 8 * 1000 / PJ_TIME_VAL_MSEC(media_duration))),
|
||||
good_number(packets, sizeof(packets), stat->rx.pkt),
|
||||
good_number(bytes, sizeof(bytes), stat->rx.bytes),
|
||||
good_number(ipbytes, sizeof(ipbytes), stat->rx.bytes + stat->rx.pkt * 40),
|
||||
good_number(avg_bps, sizeof(avg_bps), (pj_int32_t)((pj_int64_t)stat->rx.bytes * 8 * 1000 / PJ_TIME_VAL_MSEC(media_duration))),
|
||||
good_number(avg_ipbps, sizeof(avg_ipbps), (pj_int32_t)(((pj_int64_t)stat->rx.bytes + stat->rx.pkt * 40) * 8 * 1000 / PJ_TIME_VAL_MSEC(media_duration))),
|
||||
indent,
|
||||
stat->rx.loss,
|
||||
(stat->rx.loss? stat->rx.loss * 100.0 / (stat->rx.pkt + stat->rx.loss) : 0),
|
||||
|
@ -159,11 +163,18 @@ static unsigned dump_media_stat(const char *indent,
|
|||
last_update,
|
||||
|
||||
indent,
|
||||
good_number(packets, stat->tx.pkt),
|
||||
good_number(bytes, stat->tx.bytes),
|
||||
good_number(ipbytes, stat->tx.bytes + stat->tx.pkt * 40),
|
||||
good_number(avg_bps, (pj_int32_t)((pj_int64_t)stat->tx.bytes * 8 * 1000 / PJ_TIME_VAL_MSEC(media_duration))),
|
||||
good_number(avg_ipbps, (pj_int32_t)(((pj_int64_t)stat->tx.bytes + stat->tx.pkt * 40) * 8 * 1000 / PJ_TIME_VAL_MSEC(media_duration))),
|
||||
good_number(packets, sizeof(packets), stat->tx.pkt),
|
||||
good_number(bytes, sizeof(bytes), stat->tx.bytes),
|
||||
good_number(ipbytes, sizeof(ipbytes),
|
||||
stat->tx.bytes + stat->tx.pkt * 40),
|
||||
good_number(avg_bps, sizeof(avg_bps),
|
||||
(pj_int32_t)((pj_int64_t)stat->tx.bytes * 8 * 1000 /
|
||||
PJ_TIME_VAL_MSEC(media_duration))
|
||||
),
|
||||
good_number(avg_ipbps, sizeof(avg_ipbps),
|
||||
(pj_int32_t)(((pj_int64_t)stat->tx.bytes + stat->tx.pkt * 40) * 8 * 1000 /
|
||||
PJ_TIME_VAL_MSEC(media_duration))
|
||||
),
|
||||
|
||||
indent,
|
||||
stat->tx.loss,
|
||||
|
@ -482,9 +493,9 @@ static void dump_media_session(const char *indent,
|
|||
|
||||
# define PRINT_VOIP_MTC_VAL(s, v) \
|
||||
if (v == 127) \
|
||||
sprintf(s, "(na)"); \
|
||||
pj_ansi_snprintf(s, sizeof(s), "(na)"); \
|
||||
else \
|
||||
sprintf(s, "%d", v)
|
||||
pj_ansi_snprintf(s, sizeof(s), "%d", v)
|
||||
|
||||
# define VALIDATE_PRINT_BUF() \
|
||||
if (len < 1 || len >= end-p) { *p = '\0'; return; } \
|
||||
|
@ -527,14 +538,14 @@ static void dump_media_session(const char *indent,
|
|||
VALIDATE_PRINT_BUF();
|
||||
|
||||
if (xr_stat.rx.stat_sum.l)
|
||||
sprintf(loss, "%d", xr_stat.rx.stat_sum.lost);
|
||||
SNPRINTF3(loss, "%d", xr_stat.rx.stat_sum.lost);
|
||||
else
|
||||
sprintf(loss, "(na)");
|
||||
SNPRINTF2(loss, "(na)");
|
||||
|
||||
if (xr_stat.rx.stat_sum.d)
|
||||
sprintf(dup, "%d", xr_stat.rx.stat_sum.dup);
|
||||
SNPRINTF3(dup, "%d", xr_stat.rx.stat_sum.dup);
|
||||
else
|
||||
sprintf(dup, "(na)");
|
||||
SNPRINTF2(dup, "(na)");
|
||||
|
||||
if (xr_stat.rx.stat_sum.j) {
|
||||
unsigned jmin, jmax, jmean, jdev;
|
||||
|
@ -548,19 +559,21 @@ static void dump_media_session(const char *indent,
|
|||
SAMPLES_TO_USEC(jdev,
|
||||
pj_math_stat_get_stddev(&xr_stat.rx.stat_sum.jitter),
|
||||
clock_rate);
|
||||
sprintf(jitter, "%7.3f %7.3f %7.3f %7.3f",
|
||||
pj_ansi_snprintf(jitter, sizeof(jitter),
|
||||
"%7.3f %7.3f %7.3f %7.3f",
|
||||
jmin/1000.0, jmean/1000.0, jmax/1000.0, jdev/1000.0);
|
||||
} else
|
||||
sprintf(jitter, "(report not available)");
|
||||
SNPRINTF2(jitter, "(report not available)");
|
||||
|
||||
if (xr_stat.rx.stat_sum.t) {
|
||||
sprintf(toh, "%11d %11d %11d %11d",
|
||||
pj_ansi_snprintf(toh, sizeof(toh),
|
||||
"%11d %11d %11d %11d",
|
||||
xr_stat.rx.stat_sum.toh.min,
|
||||
xr_stat.rx.stat_sum.toh.mean,
|
||||
xr_stat.rx.stat_sum.toh.max,
|
||||
pj_math_stat_get_stddev(&xr_stat.rx.stat_sum.toh));
|
||||
} else
|
||||
sprintf(toh, "(report not available)");
|
||||
SNPRINTF2(toh, "(report not available)");
|
||||
|
||||
if (xr_stat.rx.stat_sum.update.sec == 0)
|
||||
pj_ansi_strxcpy(last_update, "never", sizeof(last_update));
|
||||
|
@ -593,14 +606,14 @@ static void dump_media_session(const char *indent,
|
|||
VALIDATE_PRINT_BUF();
|
||||
|
||||
if (xr_stat.tx.stat_sum.l)
|
||||
sprintf(loss, "%d", xr_stat.tx.stat_sum.lost);
|
||||
SNPRINTF3(loss, "%d", xr_stat.tx.stat_sum.lost);
|
||||
else
|
||||
sprintf(loss, "(na)");
|
||||
SNPRINTF2(loss, "(na)");
|
||||
|
||||
if (xr_stat.tx.stat_sum.d)
|
||||
sprintf(dup, "%d", xr_stat.tx.stat_sum.dup);
|
||||
SNPRINTF3(dup, "%d", xr_stat.tx.stat_sum.dup);
|
||||
else
|
||||
sprintf(dup, "(na)");
|
||||
SNPRINTF2(dup, "(na)");
|
||||
|
||||
if (xr_stat.tx.stat_sum.j) {
|
||||
unsigned jmin, jmax, jmean, jdev;
|
||||
|
@ -614,19 +627,21 @@ static void dump_media_session(const char *indent,
|
|||
SAMPLES_TO_USEC(jdev,
|
||||
pj_math_stat_get_stddev(&xr_stat.tx.stat_sum.jitter),
|
||||
clock_rate);
|
||||
sprintf(jitter, "%7.3f %7.3f %7.3f %7.3f",
|
||||
pj_ansi_snprintf(jitter, sizeof(jitter),
|
||||
"%7.3f %7.3f %7.3f %7.3f",
|
||||
jmin/1000.0, jmean/1000.0, jmax/1000.0, jdev/1000.0);
|
||||
} else
|
||||
sprintf(jitter, "(report not available)");
|
||||
SNPRINTF2(jitter, "(report not available)");
|
||||
|
||||
if (xr_stat.tx.stat_sum.t) {
|
||||
sprintf(toh, "%11d %11d %11d %11d",
|
||||
pj_ansi_snprintf(toh, sizeof(toh),
|
||||
"%11d %11d %11d %11d",
|
||||
xr_stat.tx.stat_sum.toh.min,
|
||||
xr_stat.tx.stat_sum.toh.mean,
|
||||
xr_stat.tx.stat_sum.toh.max,
|
||||
pj_math_stat_get_stddev(&xr_stat.rx.stat_sum.toh));
|
||||
} else
|
||||
sprintf(toh, "(report not available)");
|
||||
SNPRINTF2(toh, "(report not available)");
|
||||
|
||||
if (xr_stat.tx.stat_sum.update.sec == 0)
|
||||
pj_ansi_strxcpy(last_update, "never", sizeof(last_update));
|
||||
|
@ -673,33 +688,33 @@ static void dump_media_session(const char *indent,
|
|||
|
||||
switch ((xr_stat.rx.voip_mtc.rx_config>>6) & 3) {
|
||||
case PJMEDIA_RTCP_XR_PLC_DIS:
|
||||
sprintf(plc, "DISABLED");
|
||||
SNPRINTF2(plc, "DISABLED");
|
||||
break;
|
||||
case PJMEDIA_RTCP_XR_PLC_ENH:
|
||||
sprintf(plc, "ENHANCED");
|
||||
SNPRINTF2(plc, "ENHANCED");
|
||||
break;
|
||||
case PJMEDIA_RTCP_XR_PLC_STD:
|
||||
sprintf(plc, "STANDARD");
|
||||
SNPRINTF2(plc, "STANDARD");
|
||||
break;
|
||||
case PJMEDIA_RTCP_XR_PLC_UNK:
|
||||
default:
|
||||
sprintf(plc, "UNKNOWN");
|
||||
SNPRINTF2(plc, "UNKNOWN");
|
||||
break;
|
||||
}
|
||||
|
||||
switch ((xr_stat.rx.voip_mtc.rx_config>>4) & 3) {
|
||||
case PJMEDIA_RTCP_XR_JB_FIXED:
|
||||
sprintf(jba, "FIXED");
|
||||
SNPRINTF2(jba, "FIXED");
|
||||
break;
|
||||
case PJMEDIA_RTCP_XR_JB_ADAPTIVE:
|
||||
sprintf(jba, "ADAPTIVE");
|
||||
SNPRINTF2(jba, "ADAPTIVE");
|
||||
break;
|
||||
default:
|
||||
sprintf(jba, "UNKNOWN");
|
||||
SNPRINTF2(jba, "UNKNOWN");
|
||||
break;
|
||||
}
|
||||
|
||||
sprintf(jbr, "%d", xr_stat.rx.voip_mtc.rx_config & 0x0F);
|
||||
SNPRINTF3(jbr, "%d", xr_stat.rx.voip_mtc.rx_config & 0x0F);
|
||||
|
||||
if (xr_stat.rx.voip_mtc.update.sec == 0)
|
||||
pj_ansi_strxcpy(last_update, "never", sizeof(last_update));
|
||||
|
@ -774,33 +789,33 @@ static void dump_media_session(const char *indent,
|
|||
|
||||
switch ((xr_stat.tx.voip_mtc.rx_config>>6) & 3) {
|
||||
case PJMEDIA_RTCP_XR_PLC_DIS:
|
||||
sprintf(plc, "DISABLED");
|
||||
SNPRINTF2(plc, "DISABLED");
|
||||
break;
|
||||
case PJMEDIA_RTCP_XR_PLC_ENH:
|
||||
sprintf(plc, "ENHANCED");
|
||||
SNPRINTF2(plc, "ENHANCED");
|
||||
break;
|
||||
case PJMEDIA_RTCP_XR_PLC_STD:
|
||||
sprintf(plc, "STANDARD");
|
||||
SNPRINTF2(plc, "STANDARD");
|
||||
break;
|
||||
case PJMEDIA_RTCP_XR_PLC_UNK:
|
||||
default:
|
||||
sprintf(plc, "unknown");
|
||||
SNPRINTF2(plc, "unknown");
|
||||
break;
|
||||
}
|
||||
|
||||
switch ((xr_stat.tx.voip_mtc.rx_config>>4) & 3) {
|
||||
case PJMEDIA_RTCP_XR_JB_FIXED:
|
||||
sprintf(jba, "FIXED");
|
||||
SNPRINTF2(jba, "FIXED");
|
||||
break;
|
||||
case PJMEDIA_RTCP_XR_JB_ADAPTIVE:
|
||||
sprintf(jba, "ADAPTIVE");
|
||||
SNPRINTF2(jba, "ADAPTIVE");
|
||||
break;
|
||||
default:
|
||||
sprintf(jba, "unknown");
|
||||
SNPRINTF2(jba, "unknown");
|
||||
break;
|
||||
}
|
||||
|
||||
sprintf(jbr, "%d", xr_stat.tx.voip_mtc.rx_config & 0x0F);
|
||||
SNPRINTF3(jbr, "%d", xr_stat.tx.voip_mtc.rx_config & 0x0F);
|
||||
|
||||
if (xr_stat.tx.voip_mtc.update.sec == 0)
|
||||
pj_ansi_strxcpy(last_update, "never", sizeof(last_update));
|
||||
|
|
|
@ -4114,7 +4114,7 @@ pj_status_t pjsua_media_channel_update(pjsua_call_id call_id,
|
|||
dir = "unknown";
|
||||
break;
|
||||
}
|
||||
len = pj_ansi_sprintf( info+info_len,
|
||||
len = pj_ansi_snprintf( info+info_len, sizeof(info)-info_len,
|
||||
", stream #%d: %.*s (%s)", mi,
|
||||
(int)si->fmt.encoding_name.slen,
|
||||
si->fmt.encoding_name.ptr,
|
||||
|
@ -4322,7 +4322,7 @@ pj_status_t pjsua_media_channel_update(pjsua_call_id call_id,
|
|||
dir = "unknown";
|
||||
break;
|
||||
}
|
||||
len = pj_ansi_sprintf( info+info_len,
|
||||
len = pj_ansi_snprintf( info+info_len, sizeof(info)-info_len,
|
||||
", stream #%d: %.*s (%s)", mi,
|
||||
(int)si->codec_info.encoding_name.slen,
|
||||
si->codec_info.encoding_name.ptr,
|
||||
|
|
|
@ -1906,7 +1906,7 @@ static int hdr_test(void)
|
|||
len = strlen(test->hcontent);
|
||||
#if defined(PJSIP_UNESCAPE_IN_PLACE) && PJSIP_UNESCAPE_IN_PLACE!=0
|
||||
PJ_ASSERT_RETURN(len < sizeof(hcontent), PJSIP_EMSGTOOLONG);
|
||||
strcpy(hcontent, test->hcontent);
|
||||
pj_ansi_strxcpy(hcontent, test->hcontent, sizeof(hcontent));
|
||||
#else
|
||||
hcontent = test->hcontent;
|
||||
#endif
|
||||
|
@ -1937,7 +1937,7 @@ static int hdr_test(void)
|
|||
len = strlen(test->hcontent);
|
||||
#if defined(PJSIP_UNESCAPE_IN_PLACE) && PJSIP_UNESCAPE_IN_PLACE!=0
|
||||
PJ_ASSERT_RETURN(len < sizeof(hcontent), PJSIP_EMSGTOOLONG);
|
||||
strcpy(hcontent, test->hcontent);
|
||||
pj_ansi_strxcpy(hcontent, test->hcontent, sizeof(hcontent));
|
||||
#else
|
||||
hcontent = test->hcontent;
|
||||
#endif
|
||||
|
@ -2027,7 +2027,8 @@ int msg_test(void)
|
|||
|
||||
PJ_LOG(3,("", " Maximum message detection/sec=%u", max));
|
||||
|
||||
pj_ansi_sprintf(desc, "Number of SIP messages "
|
||||
pj_ansi_snprintf(desc, sizeof(desc),
|
||||
"Number of SIP messages "
|
||||
"can be pre-parse by <tt>pjsip_find_msg()</tt> "
|
||||
"per second (tested with %d message sets with "
|
||||
"average message length of "
|
||||
|
@ -2040,7 +2041,8 @@ int msg_test(void)
|
|||
|
||||
PJ_LOG(3,("", " Maximum message parsing/sec=%u", max));
|
||||
|
||||
pj_ansi_sprintf(desc, "Number of SIP messages "
|
||||
pj_ansi_snprintf(desc, sizeof(desc),
|
||||
"Number of SIP messages "
|
||||
"can be <b>parsed</b> by <tt>pjsip_parse_msg()</tt> "
|
||||
"per second (tested with %d message sets with "
|
||||
"average message length of "
|
||||
|
@ -2060,7 +2062,8 @@ int msg_test(void)
|
|||
|
||||
PJ_LOG(3,("", " Maximum message print/sec=%u", max));
|
||||
|
||||
pj_ansi_sprintf(desc, "Number of SIP messages "
|
||||
pj_ansi_snprintf(desc, sizeof(desc),
|
||||
"Number of SIP messages "
|
||||
"can be <b>printed</b> by <tt>pjsip_msg_print()</tt>"
|
||||
" per second (tested with %d message sets with "
|
||||
"average message length of "
|
||||
|
|
|
@ -1100,7 +1100,8 @@ int regc_test(void)
|
|||
|
||||
t->client_cfg.destroy_on_cb = z;
|
||||
|
||||
sprintf(new_title, "%s [check=%d, xuid=%d, destroy=%d]",
|
||||
pj_ansi_snprintf(new_title, sizeof(new_title),
|
||||
"%s [check=%d, xuid=%d, destroy=%d]",
|
||||
t->title, pjsip_cfg()->regc.check_contact,
|
||||
pjsip_cfg()->regc.add_xuid_param, z);
|
||||
rc = do_test(new_title, &t->server_cfg, &t->client_cfg,
|
||||
|
|
|
@ -184,14 +184,16 @@ static pj_status_t init_report(void)
|
|||
pj_ssize_t len;
|
||||
pj_status_t status;
|
||||
|
||||
pj_ansi_sprintf(tmp, "pjsip-static-bench-%s-%s.htm", PJ_OS_NAME, PJ_CC_NAME);
|
||||
pj_ansi_snprintf(tmp, sizeof(tmp),
|
||||
"pjsip-static-bench-%s-%s.htm", PJ_OS_NAME, PJ_CC_NAME);
|
||||
|
||||
status = pj_file_open(NULL, tmp, PJ_O_WRONLY, &fd_report);
|
||||
if (status != PJ_SUCCESS)
|
||||
return status;
|
||||
|
||||
/* Title */
|
||||
len = pj_ansi_sprintf(buf, "<HTML>\n"
|
||||
len = pj_ansi_snprintf(buf, sizeof(buf),
|
||||
"<HTML>\n"
|
||||
" <HEAD>\n"
|
||||
" <TITLE>PJSIP %s (%s) - Static Benchmark</TITLE>\n"
|
||||
" </HEAD>\n"
|
||||
|
@ -203,19 +205,22 @@ static pj_status_t init_report(void)
|
|||
|
||||
|
||||
/* Title */
|
||||
len = pj_ansi_sprintf(buf, "<H1>PJSIP %s (%s) - Static Benchmark</H1>\n",
|
||||
len = pj_ansi_snprintf(buf, sizeof(buf),
|
||||
"<H1>PJSIP %s (%s) - Static Benchmark</H1>\n",
|
||||
PJ_VERSION,
|
||||
(PJ_DEBUG ? "Debug" : "Release"));
|
||||
pj_file_write(fd_report, buf, &len);
|
||||
|
||||
len = pj_ansi_sprintf(buf, "<P>Below is the benchmark result generated "
|
||||
len = pj_ansi_snprintf(buf, sizeof(buf),
|
||||
"<P>Below is the benchmark result generated "
|
||||
"by <b>test-pjsip</b> program. The program "
|
||||
"is single-threaded only.</P>\n");
|
||||
pj_file_write(fd_report, buf, &len);
|
||||
|
||||
|
||||
/* Write table heading */
|
||||
len = pj_ansi_sprintf(buf, "<TABLE border=\"1\" cellpadding=\"4\">\n"
|
||||
len = pj_ansi_snprintf(buf, sizeof(buf),
|
||||
"<TABLE border=\"1\" cellpadding=\"4\">\n"
|
||||
" <TR><TD bgColor=\"aqua\" align=\"center\">Variable</TD>\n"
|
||||
" <TD bgColor=\"aqua\" align=\"center\">Value</TD>\n"
|
||||
" <TD bgColor=\"aqua\" align=\"center\">Description</TD>\n"
|
||||
|
@ -238,7 +243,7 @@ static pj_status_t init_report(void)
|
|||
|
||||
/* Write time of day */
|
||||
pj_time_decode(×tamp, &date_time);
|
||||
len = pj_ansi_sprintf(tmp, "%04d-%02d-%02d %02d:%02d:%02d",
|
||||
len = pj_ansi_snprintf(tmp, sizeof(tmp), "%04d-%02d-%02d %02d:%02d:%02d",
|
||||
date_time.year, date_time.mon+1, date_time.day,
|
||||
date_time.hour, date_time.min, date_time.sec);
|
||||
report_sval("date-time", tmp, "", "Date/time of the test");
|
||||
|
@ -253,7 +258,7 @@ static pj_status_t init_report(void)
|
|||
|
||||
|
||||
/* Write CC name */
|
||||
len = pj_ansi_sprintf(tmp, "%s-%d.%d.%d", PJ_CC_NAME,
|
||||
len = pj_ansi_snprintf(tmp, sizeof(tmp), "%s-%d.%d.%d", PJ_CC_NAME,
|
||||
PJ_CC_VER_1, PJ_CC_VER_2, PJ_CC_VER_2);
|
||||
report_sval("cc-name", tmp, "", "Compiler name and version");
|
||||
|
||||
|
@ -266,7 +271,8 @@ void report_sval(const char *name, const char* value, const char *valname,
|
|||
{
|
||||
pj_ssize_t len;
|
||||
|
||||
len = pj_ansi_sprintf(buf, " <TR><TD><TT>%s</TT></TD>\n"
|
||||
len = pj_ansi_snprintf(buf, sizeof(buf),
|
||||
" <TR><TD><TT>%s</TT></TD>\n"
|
||||
" <TD align=\"right\"><B>%s %s</B></TD>\n"
|
||||
" <TD>%s</TD>\n"
|
||||
" </TR>\n",
|
||||
|
@ -280,7 +286,8 @@ void report_ival(const char *name, int value, const char *valname,
|
|||
{
|
||||
pj_ssize_t len;
|
||||
|
||||
len = pj_ansi_sprintf(buf, " <TR><TD><TT>%s</TT></TD>\n"
|
||||
len = pj_ansi_snprintf(buf, sizeof(buf),
|
||||
" <TR><TD><TT>%s</TT></TD>\n"
|
||||
" <TD align=\"right\"><B>%d %s</B></TD>\n"
|
||||
" <TD>%s</TD>\n"
|
||||
" </TR>\n",
|
||||
|
@ -294,7 +301,7 @@ static void close_report(void)
|
|||
pj_ssize_t len;
|
||||
|
||||
if (fd_report) {
|
||||
len = pj_ansi_sprintf(buf, "</TABLE>\n</BODY>\n</HTML>\n");
|
||||
len = pj_ansi_snprintf(buf, sizeof(buf), "</TABLE>\n</BODY>\n</HTML>\n");
|
||||
pj_file_write(fd_report, buf, &len);
|
||||
|
||||
pj_file_close(fd_report);
|
||||
|
|
|
@ -172,7 +172,7 @@ int transport_tcp_test(void)
|
|||
status = pj_sockaddr_in_init(&rem_addr, &tpfactory[0]->addr_name.host,
|
||||
(pj_uint16_t)tpfactory[0]->addr_name.port);
|
||||
|
||||
pj_ansi_sprintf(url, "sip:alice@%s:%d;transport=tcp",
|
||||
pj_ansi_snprintf(url, sizeof(url), "sip:alice@%s:%d;transport=tcp",
|
||||
pj_inet_ntop2(pj_AF_INET(), &rem_addr.sin_addr, addr,
|
||||
sizeof(addr)),
|
||||
pj_ntohs(rem_addr.sin_port));
|
||||
|
|
|
@ -139,9 +139,11 @@ int tsx_basic_test(struct tsx_test_param *param)
|
|||
{
|
||||
int status;
|
||||
|
||||
pj_ansi_sprintf(TARGET_URI, "sip:bob@127.0.0.1:%d;transport=%s",
|
||||
pj_ansi_snprintf(TARGET_URI, sizeof(TARGET_URI),
|
||||
"sip:bob@127.0.0.1:%d;transport=%s",
|
||||
param->port, param->tp_type);
|
||||
pj_ansi_sprintf(FROM_URI, "sip:alice@127.0.0.1:%d;transport=%s",
|
||||
pj_ansi_snprintf(FROM_URI, sizeof(FROM_URI),
|
||||
"sip:alice@127.0.0.1:%d;transport=%s",
|
||||
param->port, param->tp_type);
|
||||
|
||||
status = tsx_layer_test();
|
||||
|
|
|
@ -164,7 +164,8 @@ static int uas_tsx_bench(unsigned working_set, pj_timestamp *p_elapsed)
|
|||
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,
|
||||
pj_ansi_snprintf(branch_buf+PJSIP_RFC3261_BRANCH_LEN,
|
||||
sizeof(branch_buf)-PJSIP_RFC3261_BRANCH_LEN,
|
||||
"-%d", i);
|
||||
status = pjsip_tsx_create_uas(&mod_tsx_user, &rdata, &tsx[i]);
|
||||
if (status != PJ_SUCCESS)
|
||||
|
@ -232,7 +233,8 @@ int tsx_bench(void)
|
|||
|
||||
|
||||
/* Report time */
|
||||
pj_ansi_sprintf(desc, "Time to create %d UAC transactions, in miliseconds",
|
||||
pj_ansi_snprintf(desc, sizeof(desc),
|
||||
"Time to create %d UAC transactions, in miliseconds",
|
||||
WORKING_SET);
|
||||
report_ival("create-uac-time", (unsigned)(min.u64 * 1000 / freq.u64), "msec", desc);
|
||||
|
||||
|
@ -241,7 +243,8 @@ int tsx_bench(void)
|
|||
speed = (unsigned)(freq.u64 * WORKING_SET / min.u64);
|
||||
PJ_LOG(3,(THIS_FILE, " UAC created at %d tsx/sec", speed));
|
||||
|
||||
pj_ansi_sprintf(desc, "Number of UAC transactions that potentially can be created per second "
|
||||
pj_ansi_snprintf(desc, sizeof(desc),
|
||||
"Number of UAC transactions that potentially can be created per second "
|
||||
"with <tt>pjsip_tsx_create_uac()</tt>, based on the time "
|
||||
"to create %d simultaneous transactions above.",
|
||||
WORKING_SET);
|
||||
|
@ -272,7 +275,8 @@ int tsx_bench(void)
|
|||
|
||||
|
||||
/* Report time */
|
||||
pj_ansi_sprintf(desc, "Time to create %d UAS transactions, in miliseconds",
|
||||
pj_ansi_snprintf(desc, sizeof(desc),
|
||||
"Time to create %d UAS transactions, in miliseconds",
|
||||
WORKING_SET);
|
||||
report_ival("create-uas-time", (unsigned)(min.u64 * 1000 / freq.u64), "msec", desc);
|
||||
|
||||
|
@ -281,7 +285,8 @@ int tsx_bench(void)
|
|||
speed = (unsigned)(freq.u64 * WORKING_SET / min.u64);
|
||||
PJ_LOG(3,(THIS_FILE, " UAS created at %d tsx/sec", speed));
|
||||
|
||||
pj_ansi_sprintf(desc, "Number of UAS transactions that potentially can be created per second "
|
||||
pj_ansi_snprintf(desc, sizeof(desc),
|
||||
"Number of UAS transactions that potentially can be created per second "
|
||||
"with <tt>pjsip_tsx_create_uas()</tt>, based on the time "
|
||||
"to create %d simultaneous transactions above.",
|
||||
WORKING_SET);
|
||||
|
|
|
@ -1365,9 +1365,9 @@ int tsx_uac_test(struct tsx_test_param *param)
|
|||
/* Get transport flag */
|
||||
tp_flag = pjsip_transport_get_flag_from_type((pjsip_transport_type_e)test_param->type);
|
||||
|
||||
pj_ansi_sprintf(TARGET_URI, "sip:bob@127.0.0.1:%d;transport=%s",
|
||||
pj_ansi_snprintf(TARGET_URI, sizeof(TARGET_URI), "sip:bob@127.0.0.1:%d;transport=%s",
|
||||
param->port, param->tp_type);
|
||||
pj_ansi_sprintf(FROM_URI, "sip:alice@127.0.0.1:%d;transport=%s",
|
||||
pj_ansi_snprintf(FROM_URI, sizeof(FROM_URI), "sip:alice@127.0.0.1:%d;transport=%s",
|
||||
param->port, param->tp_type);
|
||||
|
||||
/* Check if loop transport is configured. */
|
||||
|
|
|
@ -1566,9 +1566,9 @@ int tsx_uas_test(struct tsx_test_param *param)
|
|||
test_param = param;
|
||||
tp_flag = pjsip_transport_get_flag_from_type((pjsip_transport_type_e)param->type);
|
||||
|
||||
pj_ansi_sprintf(TARGET_URI, "sip:bob@127.0.0.1:%d;transport=%s",
|
||||
pj_ansi_snprintf(TARGET_URI, sizeof(TARGET_URI), "sip:bob@127.0.0.1:%d;transport=%s",
|
||||
param->port, param->tp_type);
|
||||
pj_ansi_sprintf(FROM_URI, "sip:alice@127.0.0.1:%d;transport=%s",
|
||||
pj_ansi_snprintf(FROM_URI, sizeof(FROM_URI), "sip:alice@127.0.0.1:%d;transport=%s",
|
||||
param->port, param->tp_type);
|
||||
|
||||
/* Check if loop transport is configured. */
|
||||
|
|
|
@ -1090,7 +1090,8 @@ int uri_test(void)
|
|||
|
||||
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 "
|
||||
pj_ansi_snprintf(desc, sizeof(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)",
|
||||
|
@ -1110,7 +1111,8 @@ int uri_test(void)
|
|||
|
||||
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 "
|
||||
pj_ansi_snprintf(desc, sizeof(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)",
|
||||
|
@ -1124,7 +1126,8 @@ int uri_test(void)
|
|||
|
||||
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 "
|
||||
pj_ansi_snprintf(desc, sizeof(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)",
|
||||
|
|
Loading…
Reference in New Issue