本文整理汇总了C++中pj_ansi_strcpy函数的典型用法代码示例。如果您正苦于以下问题:C++ pj_ansi_strcpy函数的具体用法?C++ pj_ansi_strcpy怎么用?C++ pj_ansi_strcpy使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了pj_ansi_strcpy函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: systest_play_wav
/*****************************************************************************
* test: play WAV file
*/
static void systest_play_wav(unsigned path_cnt, const char *paths[])
{
pjsua_player_id play_id = PJSUA_INVALID_ID;
enum gui_key key;
test_item_t *ti;
const char *title = "WAV File Playback Test";
pj_status_t status;
ti = systest_alloc_test_item(title);
if (!ti)
return;
pj_ansi_snprintf(textbuf, sizeof(textbuf),
"This test will play %s file to "
"the speaker. Please listen carefully for audio "
"impairments such as stutter. Let this test run "
"for a while to make sure that everything is okay."
" Press OK to start, CANCEL to skip",
paths[0]);
key = gui_msgbox(title, textbuf,
WITH_OKCANCEL);
if (key != KEY_OK) {
ti->skipped = PJ_TRUE;
return;
}
PJ_LOG(3,(THIS_FILE, "Running %s", title));
/* WAV port */
status = create_player(path_cnt, paths, &play_id);
if (status != PJ_SUCCESS)
goto on_return;
status = pjsua_conf_connect(pjsua_player_get_conf_port(play_id), 0);
if (status != PJ_SUCCESS)
goto on_return;
key = gui_msgbox(title,
"WAV file should be playing now in the "
"speaker. Press OK to stop. ", WITH_OK);
status = PJ_SUCCESS;
on_return:
if (play_id != -1)
pjsua_player_destroy(play_id);
if (status != PJ_SUCCESS) {
systest_perror("Sorry we've encountered error", status);
ti->success = PJ_FALSE;
pj_strerror(status, ti->reason, sizeof(ti->reason));
} else {
key = gui_msgbox(title, "Is the audio okay?", WITH_YESNO);
ti->success = (key == KEY_YES);
if (!ti->success)
pj_ansi_strcpy(ti->reason, USER_ERROR);
}
return;
}
示例2: PJ_DEF
/*
* Register new transport type to PJSIP.
*/
PJ_DEF(pj_status_t) pjsip_transport_register_type( unsigned tp_flag,
const char *tp_name,
int def_port,
int *p_tp_type)
{
unsigned i;
PJ_ASSERT_RETURN(tp_flag && tp_name && def_port, PJ_EINVAL);
PJ_ASSERT_RETURN(pj_ansi_strlen(tp_name) <
PJ_ARRAY_SIZE(transport_names[0].name_buf),
PJ_ENAMETOOLONG);
for (i=1; i<PJ_ARRAY_SIZE(transport_names); ++i) {
if (transport_names[i].type == 0)
break;
}
if (i == PJ_ARRAY_SIZE(transport_names))
return PJ_ETOOMANY;
transport_names[i].type = (pjsip_transport_type_e)i;
transport_names[i].port = (pj_uint16_t)def_port;
pj_ansi_strcpy(transport_names[i].name_buf, tp_name);
transport_names[i].name = pj_str(transport_names[i].name_buf);
transport_names[i].flag = tp_flag;
if (p_tp_type)
*p_tp_type = i;
return PJ_SUCCESS;
}
示例3: transport_read
/*!
* \brief Pass WebSocket data into pjsip transport manager.
*/
static int transport_read(void *data)
{
struct transport_read_data *read_data = data;
struct ws_transport *newtransport = read_data->transport;
struct ast_websocket *session = newtransport->ws_session;
pjsip_rx_data *rdata = &newtransport->rdata;
int recvd;
pj_str_t buf;
int pjsip_pkt_len;
pj_gettimeofday(&rdata->pkt_info.timestamp);
pjsip_pkt_len = PJSIP_MAX_PKT_LEN < read_data->payload_len ? PJSIP_MAX_PKT_LEN : read_data->payload_len;
pj_memcpy(rdata->pkt_info.packet, read_data->payload, pjsip_pkt_len);
rdata->pkt_info.len = pjsip_pkt_len;
rdata->pkt_info.zero = 0;
pj_sockaddr_parse(pj_AF_UNSPEC(), 0, pj_cstr(&buf, ast_sockaddr_stringify(ast_websocket_remote_address(session))), &rdata->pkt_info.src_addr);
rdata->pkt_info.src_addr.addr.sa_family = pj_AF_INET();
rdata->pkt_info.src_addr_len = sizeof(rdata->pkt_info.src_addr);
pj_ansi_strcpy(rdata->pkt_info.src_name, ast_sockaddr_stringify_host(ast_websocket_remote_address(session)));
rdata->pkt_info.src_port = ast_sockaddr_port(ast_websocket_remote_address(session));
recvd = pjsip_tpmgr_receive_packet(rdata->tp_info.transport->tpmgr, rdata);
pj_pool_reset(rdata->tp_info.pool);
return (read_data->payload_len == recvd) ? 0 : -1;
}
示例4: PJ_DEF
/*
* pj_init(void).
* Init PJLIB!
*/
PJ_DEF(pj_status_t) pj_init(void)
{
char stack_ptr;
pj_status_t status;
/* Check if PJLIB have been initialized */
if (initialized) {
++initialized;
return PJ_SUCCESS;
}
pj_ansi_strcpy(main_thread.obj_name, "pjthread");
// Init main thread
pj_memset(&main_thread, 0, sizeof(main_thread));
// Initialize PjSymbianOS instance
PjSymbianOS *os = PjSymbianOS::Instance();
PJ_LOG(4,(THIS_FILE, "Initializing PJLIB for Symbian OS.."));
TInt err;
err = os->Initialize();
if (err != KErrNone)
return PJ_RETURN_OS_ERROR(err);
/* Init logging */
pj_log_init();
/* Initialize exception ID for the pool.
* Must do so after critical section is configured.
*/
status = pj_exception_id_alloc("PJLIB/No memory", &PJ_NO_MEMORY_EXCEPTION);
if (status != PJ_SUCCESS)
goto on_error;
#if defined(PJ_OS_HAS_CHECK_STACK) && PJ_OS_HAS_CHECK_STACK!=0
main_thread.stk_start = &stack_ptr;
main_thread.stk_size = 0xFFFFFFFFUL;
main_thread.stk_max_usage = 0;
#else
stack_ptr = '\0';
#endif
/* Flag PJLIB as initialized */
++initialized;
pj_assert(initialized == 1);
PJ_LOG(5,(THIS_FILE, "PJLIB initialized."));
return PJ_SUCCESS;
on_error:
pj_shutdown();
return PJ_RETURN_OS_ERROR(err);
}
示例5: PJ_DEF
/* Open pcap file */
PJ_DEF(pj_status_t) pj_pcap_open(pj_pool_t *pool,
const char *path,
pj_pcap_file **p_file)
{
pj_pcap_file *file;
pj_ssize_t sz;
pj_status_t status;
PJ_ASSERT_RETURN(pool && path && p_file, PJ_EINVAL);
/* More sanity checks */
TRACE_(("pcap", "sizeof(pj_pcap_eth_hdr)=%d",
sizeof(pj_pcap_eth_hdr)));
PJ_ASSERT_RETURN(sizeof(pj_pcap_eth_hdr)==14, PJ_EBUG);
TRACE_(("pcap", "sizeof(pj_pcap_ip_hdr)=%d",
sizeof(pj_pcap_ip_hdr)));
PJ_ASSERT_RETURN(sizeof(pj_pcap_ip_hdr)==20, PJ_EBUG);
TRACE_(("pcap", "sizeof(pj_pcap_udp_hdr)=%d",
sizeof(pj_pcap_udp_hdr)));
PJ_ASSERT_RETURN(sizeof(pj_pcap_udp_hdr)==8, PJ_EBUG);
file = PJ_POOL_ZALLOC_T(pool, pj_pcap_file);
pj_ansi_strcpy(file->obj_name, "pcap");
status = pj_file_open(pool, path, PJ_O_RDONLY, &file->fd);
if (status != PJ_SUCCESS)
return status;
/* Read file pcap header */
sz = sizeof(file->hdr);
status = pj_file_read(file->fd, &file->hdr, &sz);
if (status != PJ_SUCCESS) {
pj_file_close(file->fd);
return status;
}
/* Check magic number */
if (file->hdr.magic_number == 0xa1b2c3d4) {
file->swap = PJ_FALSE;
} else if (file->hdr.magic_number == 0xd4c3b2a1) {
file->swap = PJ_TRUE;
file->hdr.network = pj_ntohl(file->hdr.network);
} else {
/* Not PCAP file */
pj_file_close(file->fd);
return PJ_EINVALIDOP;
}
TRACE_((file->obj_name, "PCAP file %s opened", path));
*p_file = file;
return PJ_SUCCESS;
}
示例6: pjsip_endpt_create_pool
/* Helper function to create "incoming" packet */
struct recv_list *create_incoming_packet( struct loop_transport *loop,
pjsip_tx_data *tdata )
{
pj_pool_t *pool;
struct recv_list *pkt;
pool = pjsip_endpt_create_pool(loop->base.endpt, "rdata",
PJSIP_POOL_RDATA_LEN,
PJSIP_POOL_RDATA_INC+5);
if (!pool)
return NULL;
pkt = pj_pool_zalloc(pool, sizeof(struct recv_list));
/* Initialize rdata. */
pkt->rdata.tp_info.pool = pool;
pkt->rdata.tp_info.transport = &loop->base;
/* Copy the packet. */
pj_memcpy(pkt->rdata.pkt_info.packet, tdata->buf.start,
tdata->buf.cur - tdata->buf.start);
pkt->rdata.pkt_info.len = tdata->buf.cur - tdata->buf.start;
/* "Source address" info. */
pkt->rdata.pkt_info.src_addr_len = sizeof(pj_sockaddr_in);
if (loop->base.key.type == PJSIP_TRANSPORT_LOOP)
pj_ansi_strcpy(pkt->rdata.pkt_info.src_name, ADDR_LOOP);
else
pj_ansi_strcpy(pkt->rdata.pkt_info.src_name, ADDR_LOOP_DGRAM);
pkt->rdata.pkt_info.src_port = loop->base.local_name.port;
/* When do we need to "deliver" this packet. */
pj_gettimeofday(&pkt->rdata.pkt_info.timestamp);
pkt->rdata.pkt_info.timestamp.msec += loop->recv_delay;
pj_time_val_normalize(&pkt->rdata.pkt_info.timestamp);
/* Done. */
return pkt;
}
示例7: systest_list_audio_devs
/****************************************************************************
* configurations
*/
static void systest_list_audio_devs()
{
unsigned i, dev_count;
pj_size_t len=0;
pj_status_t status;
test_item_t *ti;
enum gui_key key;
const char *title = "Audio Device List";
ti = systest_alloc_test_item(title);
if (!ti)
return;
PJ_LOG(3,(THIS_FILE, "Running %s", title));
dev_count = pjmedia_aud_dev_count();
if (dev_count == 0) {
key = gui_msgbox(title,
"No audio devices are found", WITH_OK);
ti->success = PJ_FALSE;
pj_ansi_strcpy(ti->reason, "No device found");
return;
}
pj_ansi_snprintf(ti->reason+len, sizeof(ti->reason)-len,
"Found %u devices\r\n", dev_count);
len = strlen(ti->reason);
for (i=0; i<dev_count; ++i) {
pjmedia_aud_dev_info info;
status = pjmedia_aud_dev_get_info(i, &info);
if (status != PJ_SUCCESS) {
systest_perror("Error retrieving device info: ", status);
ti->success = PJ_FALSE;
pj_strerror(status, ti->reason, sizeof(ti->reason));
return;
}
pj_ansi_snprintf(ti->reason+len, sizeof(ti->reason)-len,
" %2d: %s [%s] (%d/%d)\r\n",
i, info.driver, info.name,
info.input_count, info.output_count);
len = strlen(ti->reason);
}
ti->reason[len] = '\0';
key = gui_msgbox(title, ti->reason, WITH_OK);
PJ_UNUSED_ARG(key);
ti->success = PJ_TRUE;
}
示例8: gui_msgbox
test_item_t *systest_alloc_test_item(const char *title)
{
test_item_t *ti;
if (test_item_count == SYSTEST_MAX_TEST) {
gui_msgbox("Error", "You have done too many tests", WITH_OK);
return NULL;
}
ti = &test_items[test_item_count++];
pj_bzero(ti, sizeof(*ti));
pj_ansi_strcpy(ti->title, title);
return ti;
}
示例9: on_call_redirected_wrapper
pjsip_redirect_op on_call_redirected_wrapper (pjsua_call_id call_id, const pjsip_uri *target, const pjsip_event *e) {
char uristr[PJSIP_MAX_URL_SIZE];
int len;
pj_str_t uri_pstr;
len = pjsip_uri_print(PJSIP_URI_IN_FROMTO_HDR, target, uristr,
sizeof(uristr));
if (len < 1) {
pj_ansi_strcpy(uristr, "--URI too long--");
}
uri_pstr = pj_str(uristr);
return registeredCallbackObject->on_call_redirected(call_id, &uri_pstr);
}
示例10: factory_init
/* API: init factory */
static pj_status_t factory_init(pjmedia_aud_dev_factory *f)
{
struct mda_factory *af = (struct mda_factory*)f;
pj_ansi_strcpy(af->dev_info.name, "Symbian Audio");
af->dev_info.default_samples_per_sec = 8000;
af->dev_info.caps = PJMEDIA_AUD_DEV_CAP_INPUT_VOLUME_SETTING |
PJMEDIA_AUD_DEV_CAP_OUTPUT_VOLUME_SETTING;
af->dev_info.input_count = 1;
af->dev_info.output_count = 1;
PJ_LOG(4, (THIS_FILE, "Symb Mda initialized"));
return PJ_SUCCESS;
}
示例11: PJ_DEF
/*
* pj_mutex_lock()
*/
PJ_DEF(pj_status_t) pj_mutex_lock(pj_mutex_t *mutex)
{
#if PJ_HAS_THREADS
pj_status_t status;
PJ_CHECK_STACK();
PJ_ASSERT_RETURN(mutex, PJ_EINVAL);
#if PJ_DEBUG
PJ_LOG(6,(mutex->obj_name, "Mutex: thread %s is waiting (mutex owner=%s)",
pj_thread_this()->obj_name,
mutex->owner_name));
#else
PJ_LOG(6,(mutex->obj_name, "Mutex: thread %s is waiting",
pj_thread_this()->obj_name));
#endif
status = pthread_mutex_lock( &mutex->mutex );
#if PJ_DEBUG
if (status == PJ_SUCCESS) {
mutex->owner = pj_thread_this();
pj_ansi_strcpy(mutex->owner_name, mutex->owner->obj_name);
++mutex->nesting_level;
}
PJ_LOG(6,(mutex->obj_name,
(status==0 ?
"Mutex acquired by thread %s (level=%d)" :
"Mutex acquisition FAILED by %s (level=%d)"),
pj_thread_this()->obj_name,
mutex->nesting_level));
#else
PJ_LOG(6,(mutex->obj_name,
(status==0 ? "Mutex acquired by thread %s" : "FAILED by %s"),
pj_thread_this()->obj_name));
#endif
if (status == 0)
return PJ_SUCCESS;
else
return PJ_RETURN_OS_ERROR(status);
#else /* PJ_HAS_THREADS */
pj_assert( mutex == (pj_mutex_t*)1 );
return PJ_SUCCESS;
#endif
}
示例12: android_get_dev_info
/* API: Get device info. */
static pj_status_t android_get_dev_info(pjmedia_aud_dev_factory *f,
unsigned index,
pjmedia_aud_dev_info *info)
{
PJ_UNUSED_ARG(f);
pj_bzero(info, sizeof(*info));
pj_ansi_strcpy(info->name, "Android JNI");
info->default_samples_per_sec = 8000;
info->caps = PJMEDIA_AUD_DEV_CAP_OUTPUT_VOLUME_SETTING;
info->input_count = 1;
info->output_count = 1;
return PJ_SUCCESS;
}
示例13: tls_start_read
/*
* This utility function creates receive data buffers and start
* asynchronous recv() operations from the socket. It is called after
* accept() or connect() operation complete.
*/
static pj_status_t tls_start_read(struct tls_transport *tls)
{
pj_pool_t *pool;
pj_ssize_t size;
pj_sockaddr_in *rem_addr;
void *readbuf[1];
pj_status_t status;
/* Init rdata */
pool = pjsip_endpt_create_pool(tls->base.endpt,
"rtd%p",
PJSIP_POOL_RDATA_LEN,
PJSIP_POOL_RDATA_INC);
if (!pool) {
tls_perror(tls->base.obj_name, "Unable to create pool", PJ_ENOMEM);
return PJ_ENOMEM;
}
tls->rdata.tp_info.pool = pool;
tls->rdata.tp_info.transport = &tls->base;
tls->rdata.tp_info.tp_data = tls;
tls->rdata.tp_info.op_key.rdata = &tls->rdata;
pj_ioqueue_op_key_init(&tls->rdata.tp_info.op_key.op_key,
sizeof(pj_ioqueue_op_key_t));
tls->rdata.pkt_info.src_addr = tls->base.key.rem_addr;
tls->rdata.pkt_info.src_addr_len = sizeof(pj_sockaddr_in);
rem_addr = (pj_sockaddr_in*) &tls->base.key.rem_addr;
pj_ansi_strcpy(tls->rdata.pkt_info.src_name,
pj_inet_ntoa(rem_addr->sin_addr));
tls->rdata.pkt_info.src_port = pj_ntohs(rem_addr->sin_port);
size = sizeof(tls->rdata.pkt_info.packet);
readbuf[0] = tls->rdata.pkt_info.packet;
status = pj_ssl_sock_start_read2(tls->ssock, tls->base.pool, size,
readbuf, 0);
if (status != PJ_SUCCESS && status != PJ_EPENDING) {
PJ_LOG(4, (tls->base.obj_name,
"pj_ssl_sock_start_read() error, status=%d",
status));
return status;
}
return PJ_SUCCESS;
}
示例14: pj_perror_imp
static void pj_perror_imp(int log_level, const char *sender,
pj_status_t status,
const char *title_fmt, va_list marker)
{
char titlebuf[PJ_PERROR_TITLE_BUF_SIZE];
char errmsg[PJ_ERR_MSG_SIZE];
int len;
/* Build the title */
len = pj_ansi_vsnprintf(titlebuf, sizeof(titlebuf), title_fmt, marker);
if (len < 0 || len >= sizeof(titlebuf))
pj_ansi_strcpy(titlebuf, "Error");
/* Get the error */
pj_strerror(status, errmsg, sizeof(errmsg));
/* Send to log */
invoke_log(sender, log_level, "%s: %s", titlebuf, errmsg);
}
示例15: PJ_DEF
/*
* pj_mutex_trylock()
*/
PJ_DEF(pj_status_t) pj_mutex_trylock(pj_mutex_t *mutex)
{
#if PJ_HAS_THREADS
int status;
PJ_CHECK_STACK();
PJ_ASSERT_RETURN(mutex, PJ_EINVAL);
PJ_LOG(6,(mutex->obj_name, "Mutex: thread %s is trying",
pj_thread_this()->obj_name));
status = pthread_mutex_trylock( &mutex->mutex );
if (status==0)
{
#if PJ_DEBUG
mutex->owner = pj_thread_this();
pj_ansi_strcpy(mutex->owner_name, mutex->owner->obj_name);
++mutex->nesting_level;
PJ_LOG(6,(mutex->obj_name, "Mutex acquired by thread %s (level=%d)",
pj_thread_this()->obj_name,
mutex->nesting_level));
#else
PJ_LOG(6,(mutex->obj_name, "Mutex acquired by thread %s",
pj_thread_this()->obj_name));
#endif
}
else
{
PJ_LOG(6,(mutex->obj_name, "Mutex: thread %s's trylock() failed",
pj_thread_this()->obj_name));
}
if (status==0)
return PJ_SUCCESS;
else
return PJ_RETURN_OS_ERROR(status);
#else /* PJ_HAS_THREADS */
pj_assert( mutex == (pj_mutex_t*)1);
return PJ_SUCCESS;
#endif
}