本文整理汇总了C++中pjsip_endpt_create_pool函数的典型用法代码示例。如果您正苦于以下问题:C++ pjsip_endpt_create_pool函数的具体用法?C++ pjsip_endpt_create_pool怎么用?C++ pjsip_endpt_create_pool使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了pjsip_endpt_create_pool函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: parse_test
static int parse_test(void)
{
unsigned i;
for (i=0; i<PJ_ARRAY_SIZE(p_tests); ++i) {
pj_pool_t *pool;
pjsip_media_type ctype;
pjsip_msg_body *body;
pj_str_t str;
int rc;
pool = pjsip_endpt_create_pool(endpt, NULL, 512, 512);
init_media_type(&ctype, p_tests[i].ctype, p_tests[i].csubtype,
p_tests[i].boundary);
pj_strdup2_with_null(pool, &str, p_tests[i].msg);
body = pjsip_multipart_parse(pool, str.ptr, str.slen, &ctype, 0);
if (!body)
return -100;
if (p_tests[i].verify) {
rc = p_tests[i].verify(pool, body);
} else {
rc = 0;
}
pj_pool_release(pool);
if (rc)
return rc;
}
return 0;
}
示例2: mod_ua_load
/*
* mod_ua_load()
*
* Called when module is being loaded by endpoint.
*/
static pj_status_t mod_ua_load(pjsip_endpoint *endpt)
{
pj_status_t status;
/* Initialize the user agent. */
mod_ua.endpt = endpt;
mod_ua.pool = pjsip_endpt_create_pool( endpt, "ua%p", PJSIP_POOL_LEN_UA,
PJSIP_POOL_INC_UA);
if (mod_ua.pool == NULL)
return PJ_ENOMEM;
status = pj_mutex_create_recursive(mod_ua.pool, " ua%p", &mod_ua.mutex);
if (status != PJ_SUCCESS)
return status;
mod_ua.dlg_table = pj_hash_create(mod_ua.pool, PJSIP_MAX_DIALOG_COUNT);
if (mod_ua.dlg_table == NULL)
return PJ_ENOMEM;
pj_list_init(&mod_ua.free_dlgset_nodes);
/* Initialize dialog lock. */
status = pj_thread_local_alloc(&pjsip_dlg_lock_tls_id);
if (status != PJ_SUCCESS)
return status;
pj_thread_local_set(pjsip_dlg_lock_tls_id, NULL);
return PJ_SUCCESS;
}
示例3: msg_err_test
int msg_err_test(void)
{
pj_pool_t *pool;
unsigned i;
PJ_LOG(3,(THIS_FILE, "Testing parsing error"));
pool = pjsip_endpt_create_pool(endpt, "msgerrtest", 4000, 4000);
for (i=0; i<PJ_ARRAY_SIZE(test_entries); ++i) {
pjsip_parser_err_report err_list, *e;
PJ_LOG(3,(THIS_FILE, " Parsing msg %d", i));
pj_list_init(&err_list);
pjsip_parse_msg(pool, test_entries[i].msg,
strlen(test_entries[i].msg), &err_list);
e = err_list.next;
while (e != &err_list) {
PJ_LOG(3,(THIS_FILE,
" reported syntax error at line %d col %d for %.*s",
e->line, e->col,
(int)e->hname.slen,
e->hname.ptr));
e = e->next;
}
}
pj_pool_release(pool);
return 0;
}
示例4: mod_init
/*
* Module initialization.
* This will be called by endpoint when it initializes all modules.
*/
static pj_status_t mod_init( pjsip_endpoint *endpt,
struct pjsip_module *mod, pj_uint32_t id )
{
pj_pool_t *pool;
pool = pjsip_endpt_create_pool(endpt, "esubmgr", MGR_POOL_SIZE, MGR_POOL_INC);
if (!pool)
return -1;
/* Manager initialization: create hash table and mutex. */
mgr.pool = pool;
mgr.endpt = endpt;
mgr.ht = pj_hash_create(pool, HASH_TABLE_SIZE);
if (!mgr.ht)
return -1;
mgr.mutex = pj_mutex_create(pool, "esubmgr", PJ_MUTEX_SIMPLE);
if (!mgr.mutex)
return -1;
/* Attach manager to module. */
mod->mod_data = &mgr;
/* Init package list. */
pj_list_init(&mgr.pkg_list);
/* Init Allow-Events header. */
mgr.allow_events = pjsip_allow_events_hdr_create(mgr.pool);
/* Save the module ID. */
mod_id = id;
pjsip_event_notify_init_parser();
return 0;
}
示例5: PJ_DEF
PJ_DEF(pj_status_t) pjsip_publishc_create( pjsip_endpoint *endpt,
const pjsip_publishc_opt *opt,
void *token,
pjsip_publishc_cb *cb,
pjsip_publishc **p_pubc)
{
pj_pool_t *pool;
pjsip_publishc *pubc;
pjsip_publishc_opt default_opt;
pj_status_t status;
/* Verify arguments. */
PJ_ASSERT_RETURN(endpt && cb && p_pubc, PJ_EINVAL);
pool = pjsip_endpt_create_pool(endpt, "pubc%p", 1024, 1024);
PJ_ASSERT_RETURN(pool != NULL, PJ_ENOMEM);
pubc = PJ_POOL_ZALLOC_T(pool, pjsip_publishc);
pubc->pool = pool;
pubc->endpt = endpt;
pubc->token = token;
pubc->cb = cb;
pubc->expires = PJSIP_PUBC_EXPIRATION_NOT_SPECIFIED;
if (!opt) {
pjsip_publishc_opt_default(&default_opt);
opt = &default_opt;
}
pj_memcpy(&pubc->opt, opt, sizeof(*opt));
pj_list_init(&pubc->pending_reqs);
pj_list_init(&pubc->pending_reqs_empty);
status = pj_mutex_create_recursive(pubc->pool, "pubc%p", &pubc->mutex);
if (status != PJ_SUCCESS) {
pj_pool_release(pool);
return status;
}
status = pjsip_auth_clt_init(&pubc->auth_sess, endpt, pubc->pool, 0);
if (status != PJ_SUCCESS) {
pj_mutex_destroy(pubc->mutex);
pj_pool_release(pool);
return status;
}
pj_list_init(&pubc->route_set);
pj_list_init(&pubc->usr_hdr);
/* Done */
*p_pubc = pubc;
return PJ_SUCCESS;
}
示例6: PJ_DEF
PJ_DEF(pj_status_t) pjsip_regc_create( pjsip_endpoint *endpt, void *token,
pjsip_regc_cb *cb,
pjsip_regc **p_regc)
{
pj_pool_t *pool;
pjsip_regc *regc;
pj_status_t status;
/* Verify arguments. */
PJ_ASSERT_RETURN(endpt && cb && p_regc, PJ_EINVAL);
pool = pjsip_endpt_create_pool(endpt, "regc%p", 1024, 1024);
PJ_ASSERT_RETURN(pool != NULL, PJ_ENOMEM);
regc = PJ_POOL_ZALLOC_T(pool, pjsip_regc);
regc->pool = pool;
regc->endpt = endpt;
regc->token = token;
regc->cb = cb;
regc->expires = PJSIP_REGC_EXPIRATION_NOT_SPECIFIED;
regc->add_xuid_param = pjsip_cfg()->regc.add_xuid_param;
status = pj_lock_create_recursive_mutex(pool, pool->obj_name,
®c->lock);
if (status != PJ_SUCCESS) {
pj_pool_release(pool);
return status;
}
status = pj_atomic_create(pool, 0, ®c->busy_ctr);
if (status != PJ_SUCCESS) {
pj_lock_destroy(regc->lock);
pj_pool_release(pool);
return status;
}
status = pjsip_auth_clt_init(®c->auth_sess, endpt, regc->pool, 0);
if (status != PJ_SUCCESS)
return status;
pj_list_init(®c->route_set);
pj_list_init(®c->hdr_list);
pj_list_init(®c->contact_hdr_list);
pj_list_init(®c->removed_contact_hdr_list);
/* Done */
*p_regc = regc;
return PJ_SUCCESS;
}
示例7: tcp_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 tcp_start_read(struct tcp_transport *tcp)
{
pj_pool_t *pool;
pj_ssize_t size;
pj_sockaddr *rem_addr;
void *readbuf[1];
pj_status_t status;
/* Init rdata */
pool = pjsip_endpt_create_pool(tcp->base.endpt,
"rtd%p",
PJSIP_POOL_RDATA_LEN,
PJSIP_POOL_RDATA_INC);
if (!pool) {
tcp_perror(tcp->base.obj_name, "Unable to create pool", PJ_ENOMEM);
return PJ_ENOMEM;
}
tcp->rdata.tp_info.pool = pool;
tcp->rdata.tp_info.transport = &tcp->base;
tcp->rdata.tp_info.tp_data = tcp;
tcp->rdata.tp_info.op_key.rdata = &tcp->rdata;
pj_ioqueue_op_key_init(&tcp->rdata.tp_info.op_key.op_key,
sizeof(pj_ioqueue_op_key_t));
tcp->rdata.pkt_info.src_addr = tcp->base.key.rem_addr;
tcp->rdata.pkt_info.src_addr_len = sizeof(tcp->rdata.pkt_info.src_addr);
rem_addr = &tcp->base.key.rem_addr;
pj_sockaddr_print(rem_addr, tcp->rdata.pkt_info.src_name,
sizeof(tcp->rdata.pkt_info.src_name), 0);
tcp->rdata.pkt_info.src_port = pj_sockaddr_get_port(rem_addr);
size = sizeof(tcp->rdata.pkt_info.packet);
readbuf[0] = tcp->rdata.pkt_info.packet;
status = pj_activesock_start_read2(tcp->asock, tcp->base.pool, size,
readbuf, 0);
if (status != PJ_SUCCESS && status != PJ_EPENDING) {
PJ_LOG(4, (tcp->base.obj_name,
"pj_activesock_start_read() error, status=%d",
status));
return status;
}
return PJ_SUCCESS;
}
示例8: 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;
}
示例9: pjsip_messaging_create_session
pjsip_messaging_create_session( pjsip_endpoint *endpt, const pj_str_t *param_from,
const pj_str_t *param_to )
{
pj_pool_t *pool;
pjsip_messaging_session *ses;
pj_str_t tmp, to;
pool = pjsip_endpt_create_pool(endpt, "imsess", 1024, 1024);
if (!pool)
return NULL;
ses = pj_pool_calloc(pool, 1, sizeof(pjsip_messaging_session));
ses->pool = pool;
ses->endpt = endpt;
ses->call_id = pjsip_cid_hdr_create(pool);
pj_create_unique_string(pool, &ses->call_id->id);
ses->cseq = pjsip_cseq_hdr_create(pool);
ses->cseq->cseq = pj_rand();
ses->cseq->method = message_method;
ses->from = pjsip_from_hdr_create(pool);
pj_strdup_with_null(pool, &tmp, param_from);
ses->from->uri = pjsip_parse_uri(pool, tmp.ptr, tmp.slen, PJSIP_PARSE_URI_AS_NAMEADDR);
if (ses->from->uri == NULL) {
pjsip_endpt_destroy_pool(endpt, pool);
return NULL;
}
pj_create_unique_string(pool, &ses->from->tag);
ses->to = pjsip_to_hdr_create(pool);
pj_strdup_with_null(pool, &to, param_from);
ses->to->uri = pjsip_parse_uri(pool, to.ptr, to.slen, PJSIP_PARSE_URI_AS_NAMEADDR);
if (ses->to->uri == NULL) {
pjsip_endpt_destroy_pool(endpt, pool);
return NULL;
}
PJ_LOG(4,(THIS_FILE, "IM session created: recipient=%s", to.ptr));
return ses;
}
示例10: PJ_DEF
/*
* Create new transmit buffer.
*/
PJ_DEF(pj_status_t) pjsip_tx_data_create( pjsip_tpmgr *mgr,
pjsip_tx_data **p_tdata )
{
pj_pool_t *pool;
pjsip_tx_data *tdata;
pj_status_t status;
PJ_ASSERT_RETURN(mgr && p_tdata, PJ_EINVAL);
pool = pjsip_endpt_create_pool( mgr->endpt, "tdta%p",
PJSIP_POOL_LEN_TDATA,
PJSIP_POOL_INC_TDATA );
if (!pool)
return PJ_ENOMEM;
tdata = PJ_POOL_ZALLOC_T(pool, pjsip_tx_data);
tdata->pool = pool;
tdata->mgr = mgr;
pj_memcpy(tdata->obj_name, pool->obj_name, PJ_MAX_OBJ_NAME);
status = pj_atomic_create(tdata->pool, 0, &tdata->ref_cnt);
if (status != PJ_SUCCESS) {
pjsip_endpt_release_pool( mgr->endpt, tdata->pool );
return status;
}
//status = pj_lock_create_simple_mutex(pool, "tdta%p", &tdata->lock);
status = pj_lock_create_null_mutex(pool, "tdta%p", &tdata->lock);
if (status != PJ_SUCCESS) {
pjsip_endpt_release_pool( mgr->endpt, tdata->pool );
return status;
}
pj_ioqueue_op_key_init(&tdata->op_key.key, sizeof(tdata->op_key.key));
#if defined(PJ_DEBUG) && PJ_DEBUG!=0
pj_atomic_inc( tdata->mgr->tdata_counter );
#endif
*p_tdata = tdata;
return PJ_SUCCESS;
}
示例11: simple_uri_test
static int simple_uri_test(void)
{
unsigned i;
pj_pool_t *pool;
pj_status_t status;
PJ_LOG(3,(THIS_FILE, " simple test"));
for (i=0; i<PJ_ARRAY_SIZE(uri_test_array); ++i) {
pool = pjsip_endpt_create_pool(endpt, "", POOL_SIZE, POOL_SIZE);
status = do_uri_test(pool, &uri_test_array[i]);
pjsip_endpt_release_pool(endpt, pool);
if (status != PJ_SUCCESS) {
PJ_LOG(3,(THIS_FILE, " error %d when testing entry %d",
status, i));
return status;
}
}
return 0;
}
示例12: permanent_contact_validate
/*! \brief Helper function which validates a permanent contact */
static int permanent_contact_validate(void *data)
{
const char *value = data;
pj_pool_t *pool;
pj_str_t contact_uri;
static const pj_str_t HCONTACT = { "Contact", 7 };
pool = pjsip_endpt_create_pool(ast_sip_get_pjsip_endpoint(), "Permanent Contact Validation", 256, 256);
if (!pool) {
return -1;
}
pj_strdup2_with_null(pool, &contact_uri, value);
if (!pjsip_parse_hdr(pool, &HCONTACT, contact_uri.ptr, contact_uri.slen, NULL)) {
pjsip_endpt_release_pool(ast_sip_get_pjsip_endpoint(), pool);
return -1;
}
pjsip_endpt_release_pool(ast_sip_get_pjsip_endpoint(), pool);
return 0;
}
示例13: 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;
}
示例14: PJ_DEF
PJ_DEF(pj_status_t) pjsip_publishc_create( pjsip_endpoint *endpt,
unsigned options,
void *token,
pjsip_publishc_cb *cb,
pjsip_publishc **p_pubc)
{
pj_pool_t *pool;
pjsip_publishc *pubc;
pj_status_t status;
/* Verify arguments. */
PJ_ASSERT_RETURN(endpt && cb && p_pubc, PJ_EINVAL);
PJ_ASSERT_RETURN(options == 0, PJ_EINVAL);
PJ_UNUSED_ARG(options);
pool = pjsip_endpt_create_pool(endpt, "pubc%p", 1024, 1024);
PJ_ASSERT_RETURN(pool != NULL, PJ_ENOMEM);
pubc = PJ_POOL_ZALLOC_T(pool, pjsip_publishc);
pubc->pool = pool;
pubc->endpt = endpt;
pubc->token = token;
pubc->cb = cb;
pubc->expires = PJSIP_PUBC_EXPIRATION_NOT_SPECIFIED;
status = pjsip_auth_clt_init(&pubc->auth_sess, endpt, pubc->pool, 0);
if (status != PJ_SUCCESS)
return status;
pj_list_init(&pubc->route_set);
/* Done */
*p_pubc = pubc;
return PJ_SUCCESS;
}
示例15: tcp_create
/*
* Common function to create TCP transport, called when pending accept() and
* pending connect() complete.
*/
static pj_status_t tcp_create( struct tcp_listener *listener,
pj_pool_t *pool,
pj_sock_t sock, pj_bool_t is_server,
const pj_sockaddr *local,
const pj_sockaddr *remote,
struct tcp_transport **p_tcp)
{
struct tcp_transport *tcp;
pj_ioqueue_t *ioqueue;
pj_activesock_cfg asock_cfg;
pj_activesock_cb tcp_callback;
const pj_str_t ka_pkt = PJSIP_TCP_KEEP_ALIVE_DATA;
char print_addr[PJ_INET6_ADDRSTRLEN+10];
pj_status_t status;
PJ_ASSERT_RETURN(sock != PJ_INVALID_SOCKET, PJ_EINVAL);
if (pool == NULL) {
pool = pjsip_endpt_create_pool(listener->endpt, "tcp",
POOL_TP_INIT, POOL_TP_INC);
PJ_ASSERT_RETURN(pool != NULL, PJ_ENOMEM);
}
/*
* Create and initialize basic transport structure.
*/
tcp = PJ_POOL_ZALLOC_T(pool, struct tcp_transport);
tcp->is_server = is_server;
tcp->sock = sock;
/*tcp->listener = listener;*/
pj_list_init(&tcp->delayed_list);
tcp->base.pool = pool;
pj_ansi_snprintf(tcp->base.obj_name, PJ_MAX_OBJ_NAME,
(is_server ? "tcps%p" :"tcpc%p"), tcp);
status = pj_atomic_create(pool, 0, &tcp->base.ref_cnt);
if (status != PJ_SUCCESS) {
goto on_error;
}
status = pj_lock_create_recursive_mutex(pool, "tcp", &tcp->base.lock);
if (status != PJ_SUCCESS) {
goto on_error;
}
tcp->base.key.type = listener->factory.type;
pj_sockaddr_cp(&tcp->base.key.rem_addr, remote);
tcp->base.type_name = (char*)pjsip_transport_get_type_name(
(pjsip_transport_type_e)tcp->base.key.type);
tcp->base.flag = pjsip_transport_get_flag_from_type(
(pjsip_transport_type_e)tcp->base.key.type);
tcp->base.info = (char*) pj_pool_alloc(pool, 64);
pj_ansi_snprintf(tcp->base.info, 64, "%s to %s",
tcp->base.type_name,
pj_sockaddr_print(remote, print_addr,
sizeof(print_addr), 3));
tcp->base.addr_len = pj_sockaddr_get_len(remote);
pj_sockaddr_cp(&tcp->base.local_addr, local);
sockaddr_to_host_port(pool, &tcp->base.local_name, local);
sockaddr_to_host_port(pool, &tcp->base.remote_name, remote);
tcp->base.dir = is_server? PJSIP_TP_DIR_INCOMING : PJSIP_TP_DIR_OUTGOING;
tcp->base.endpt = listener->endpt;
tcp->base.tpmgr = listener->tpmgr;
tcp->base.send_msg = &tcp_send_msg;
tcp->base.do_shutdown = &tcp_shutdown;
tcp->base.destroy = &tcp_destroy_transport;
/* Create active socket */
pj_activesock_cfg_default(&asock_cfg);
asock_cfg.async_cnt = 1;
pj_bzero(&tcp_callback, sizeof(tcp_callback));
tcp_callback.on_data_read = &on_data_read;
tcp_callback.on_data_sent = &on_data_sent;
tcp_callback.on_connect_complete = &on_connect_complete;
ioqueue = pjsip_endpt_get_ioqueue(listener->endpt);
status = pj_activesock_create(pool, sock, pj_SOCK_STREAM(), &asock_cfg,
ioqueue, &tcp_callback, tcp, &tcp->asock);
if (status != PJ_SUCCESS) {
goto on_error;
}
/* Register transport to transport manager */
status = pjsip_transport_register(listener->tpmgr, &tcp->base);
if (status != PJ_SUCCESS) {
goto on_error;
}
tcp->is_registered = PJ_TRUE;
//.........这里部分代码省略.........