本文整理汇总了C++中pj_list_init函数的典型用法代码示例。如果您正苦于以下问题:C++ pj_list_init函数的具体用法?C++ pj_list_init怎么用?C++ pj_list_init使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了pj_list_init函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: PJ_DEF
PJ_DEF(void) pjsip_param_clone( pj_pool_t *pool, pjsip_param *dst_list,
const pjsip_param *src_list)
{
const pjsip_param *p = src_list->next;
pj_list_init(dst_list);
while (p && p != src_list) {
pjsip_param *new_param = PJ_POOL_ALLOC_T(pool, pjsip_param);
pj_strdup(pool, &new_param->name, &p->name);
pj_strdup(pool, &new_param->value, &p->value);
pj_list_insert_before(dst_list, new_param);
p = p->next;
}
}
开发者ID:RockHardJim,项目名称:idphone,代码行数:14,代码来源:sip_uri.c
示例2: PJ_DEF
/*
* Initialize and register G722 codec factory to pjmedia endpoint.
*/
PJ_DEF(pj_status_t) pjmedia_codec_g722_init( pjmedia_endpt *endpt )
{
pjmedia_codec_mgr *codec_mgr;
pj_status_t status;
if (g722_codec_factory.pool != NULL)
return PJ_SUCCESS;
/* Create G722 codec factory. */
g722_codec_factory.base.op = &g722_factory_op;
g722_codec_factory.base.factory_data = NULL;
g722_codec_factory.endpt = endpt;
g722_codec_factory.pcm_shift = PJMEDIA_G722_DEFAULT_PCM_SHIFT;
g722_codec_factory.pool = pjmedia_endpt_create_pool(endpt, "g722", 1000,
1000);
if (!g722_codec_factory.pool)
return PJ_ENOMEM;
pj_list_init(&g722_codec_factory.codec_list);
/* Create mutex. */
status = pj_mutex_create_simple(g722_codec_factory.pool, "g722",
&g722_codec_factory.mutex);
if (status != PJ_SUCCESS)
goto on_error;
/* Get the codec manager. */
codec_mgr = pjmedia_endpt_get_codec_mgr(endpt);
if (!codec_mgr) {
status = PJ_EINVALIDOP;
goto on_error;
}
/* Register codec factory to endpoint. */
status = pjmedia_codec_mgr_register_factory(codec_mgr,
&g722_codec_factory.base);
if (status != PJ_SUCCESS)
goto on_error;
TRACE_((THIS_FILE, "G722 codec factory initialized"));
/* Done. */
return PJ_SUCCESS;
on_error:
pj_pool_release(g722_codec_factory.pool);
g722_codec_factory.pool = NULL;
return status;
}
开发者ID:AmoebaLabs,项目名称:pjsip,代码行数:53,代码来源:g722.c
示例3: PJ_DEF
/*
* Create an empty multipart body.
*/
PJ_DEF(pjsip_msg_body*) pjsip_multipart_create( pj_pool_t *pool,
const pjsip_media_type *ctype,
const pj_str_t *boundary)
{
pjsip_msg_body *body;
pjsip_param *ctype_param;
struct multipart_data *mp_data;
pj_str_t STR_BOUNDARY = { "boundary", 8 };
PJ_ASSERT_RETURN(pool, NULL);
body = PJ_POOL_ZALLOC_T(pool, pjsip_msg_body);
/* content-type */
if (ctype && ctype->type.slen) {
pjsip_media_type_cp(pool, &body->content_type, ctype);
} else {
pj_str_t STR_MULTIPART = {"multipart", 9};
pj_str_t STR_MIXED = { "mixed", 5 };
pjsip_media_type_init(&body->content_type,
&STR_MULTIPART, &STR_MIXED);
}
/* multipart data */
mp_data = PJ_POOL_ZALLOC_T(pool, struct multipart_data);
pj_list_init(&mp_data->part_head);
if (boundary) {
pj_strdup(pool, &mp_data->boundary, boundary);
} else {
pj_create_unique_string(pool, &mp_data->boundary);
}
body->data = mp_data;
/* Add ";boundary" parameter to content_type parameter. */
ctype_param = pjsip_param_find(&body->content_type.param, &STR_BOUNDARY);
if (!ctype_param) {
ctype_param = PJ_POOL_ALLOC_T(pool, pjsip_param);
ctype_param->name = STR_BOUNDARY;
pj_list_push_back(&body->content_type.param, ctype_param);
}
ctype_param->value = mp_data->boundary;
/* function pointers */
body->print_body = &multipart_print_body;
body->clone_data = &multipart_clone_data;
return body;
}
开发者ID:cbanta,项目名称:pjproject,代码行数:52,代码来源:sip_multipart.c
示例4: PJ_DEF
/*
* Create new memory pool.
*/
PJ_DEF(pj_pool_t*) pj_pool_create_int( pj_pool_factory *f, const char *name,
pj_size_t initial_size,
pj_size_t increment_size,
pj_pool_callback *callback)
{
pj_pool_t *pool;
pj_pool_block *block;
pj_uint8_t *buffer;
PJ_CHECK_STACK();
/* Size must be at least sizeof(pj_pool)+sizeof(pj_pool_block) */
PJ_ASSERT_RETURN(initial_size >= sizeof(pj_pool_t)+sizeof(pj_pool_block),
NULL);
/* If callback is NULL, set calback from the policy */
if (callback == NULL)
callback = f->policy.callback;
/* Allocate initial block */
buffer = (pj_uint8_t*) (*f->policy.block_alloc)(f, initial_size);
if (!buffer)
return NULL;
/* Set pool administrative data. */
pool = (pj_pool_t*)buffer;
pj_bzero(pool, sizeof(*pool));
pj_list_init(&pool->block_list);
pool->factory = f;
/* Create the first block from the memory. */
block = (pj_pool_block*) (buffer + sizeof(*pool));
block->buf = ((unsigned char*)block) + sizeof(pj_pool_block);
block->end = buffer + initial_size;
/* Set the start pointer, aligning it as needed */
block->cur = ALIGN_PTR(block->buf, PJ_POOL_ALIGNMENT);
pj_list_insert_after(&pool->block_list, block);
pj_pool_init_int(pool, name, increment_size, callback);
/* Pool initial capacity and used size */
pool->capacity = initial_size;
LOG((pool->obj_name, "pool created, size=%u", pool->capacity));
return pool;
}
开发者ID:LuLei2013,项目名称:pjproject,代码行数:52,代码来源:pool.c
示例5: PJ_DEF
/* Init client session. */
PJ_DEF(pj_status_t) pjsip_auth_clt_init( pjsip_auth_clt_sess *sess,
pjsip_endpoint *endpt,
pj_pool_t *pool,
unsigned options)
{
PJ_ASSERT_RETURN(sess && endpt && pool && (options==0), PJ_EINVAL);
sess->pool = pool;
sess->endpt = endpt;
sess->cred_cnt = 0;
sess->cred_info = NULL;
pj_list_init(&sess->cached_auth);
return PJ_SUCCESS;
}
开发者ID:conght,项目名称:BLM-Lib,代码行数:16,代码来源:sip_auth_client.c
示例6: init_media_type
static void init_media_type(pjsip_media_type *mt,
char *type, char *subtype, char *boundary)
{
static pjsip_param prm;
pjsip_media_type_init(mt, NULL, NULL);
if (type) mt->type = pj_str(type);
if (subtype) mt->subtype = pj_str(subtype);
if (boundary) {
pj_list_init(&prm);
prm.name = pj_str("boundary");
prm.value = pj_str(boundary);
pj_list_push_back(&mt->param, &prm);
}
}
开发者ID:carlosdelfino,项目名称:WorkshopTelefoniaAutomacao,代码行数:15,代码来源:multipart_test.c
示例7: pjsua_pres_delete_acc
/* Terminate server subscription for the account */
void pjsua_pres_delete_acc(int acc_id)
{
pjsua_acc *acc = &pjsua_var.acc[acc_id];
pjsua_acc_config *acc_cfg = &pjsua_var.acc[acc_id].cfg;
pjsua_srv_pres *uapres;
uapres = pjsua_var.acc[acc_id].pres_srv_list.next;
/* Notify all subscribers that we're no longer available */
while (uapres != &acc->pres_srv_list) {
pjsip_pres_status pres_status;
pj_str_t reason = { "noresource", 10 };
pjsua_srv_pres *next;
pjsip_tx_data *tdata;
next = uapres->next;
pjsip_pres_get_status(uapres->sub, &pres_status);
pres_status.info[0].basic_open = pjsua_var.acc[acc_id].online_status;
pjsip_pres_set_status(uapres->sub, &pres_status);
if (pjsip_pres_notify(uapres->sub,
PJSIP_EVSUB_STATE_TERMINATED, NULL,
&reason, &tdata)==PJ_SUCCESS)
{
pjsip_pres_send_request(uapres->sub, tdata);
}
uapres = next;
}
/* Clear server presence subscription list because account might be reused
* later. */
pj_list_init(&acc->pres_srv_list);
/* Terminate presence publication, if any */
if (acc->publish_sess) {
acc->online_status = PJ_FALSE;
send_publish(acc_id, PJ_FALSE);
if (acc->publish_sess) {
pjsip_publishc_destroy(acc->publish_sess);
acc->publish_sess = NULL;
}
acc_cfg->publish_enabled = PJ_FALSE;
}
}
开发者ID:svn2github,项目名称:pjproject,代码行数:49,代码来源:pjsua_pres.c
示例8: PJ_DEF
PJ_DEF(pj_status_t) pjsip_publishc_set_headers( pjsip_publishc *pubc,
const pjsip_hdr *hdr_list)
{
const pjsip_hdr *h;
PJ_ASSERT_RETURN(pubc && hdr_list, PJ_EINVAL);
pj_list_init(&pubc->usr_hdr);
h = hdr_list->next;
while (h != hdr_list) {
pj_list_push_back(&pubc->usr_hdr, pjsip_hdr_clone(pubc->pool, h));
h = h->next;
}
return PJ_SUCCESS;
}
开发者ID:CryptoCall,项目名称:pjsip,代码行数:16,代码来源:publishc.c
示例9: PJ_DEF
/*
* Initialize and register GSM codec factory to pjmedia endpoint.
*/
PJ_DEF(pj_status_t) pjmedia_codec_gsm_init( pjmedia_endpt *endpt )
{
pjmedia_codec_mgr *codec_mgr;
pj_status_t status;
if (gsm_codec_factory.pool != NULL)
return PJ_SUCCESS;
/* Create GSM codec factory. */
gsm_codec_factory.base.op = &gsm_factory_op;
gsm_codec_factory.base.factory_data = NULL;
gsm_codec_factory.endpt = endpt;
gsm_codec_factory.pool = pjmedia_endpt_create_pool(endpt, "gsm", 4000,
4000);
if (!gsm_codec_factory.pool)
return PJ_ENOMEM;
pj_list_init(&gsm_codec_factory.codec_list);
/* Create mutex. */
status = pj_mutex_create_simple(gsm_codec_factory.pool, "gsm",
&gsm_codec_factory.mutex);
if (status != PJ_SUCCESS)
goto on_error;
/* Get the codec manager. */
codec_mgr = pjmedia_endpt_get_codec_mgr(endpt);
if (!codec_mgr) {
status = PJ_EINVALIDOP;
goto on_error;
}
/* Register codec factory to endpoint. */
status = pjmedia_codec_mgr_register_factory(codec_mgr,
&gsm_codec_factory.base);
if (status != PJ_SUCCESS)
goto on_error;
/* Done. */
return PJ_SUCCESS;
on_error:
pj_pool_release(gsm_codec_factory.pool);
gsm_codec_factory.pool = NULL;
return status;
}
开发者ID:Archipov,项目名称:android-client,代码行数:50,代码来源:gsm.c
示例10: PJ_DEF
PJ_DEF(pj_status_t) pjsip_regc_set_route_set( pjsip_regc *regc,
const pjsip_route_hdr *route_set)
{
const pjsip_route_hdr *chdr;
PJ_ASSERT_RETURN(regc && route_set, PJ_EINVAL);
pj_list_init(®c->route_set);
chdr = route_set->next;
while (chdr != route_set) {
pj_list_push_back(®c->route_set, pjsip_hdr_clone(regc->pool, chdr));
chdr = chdr->next;
}
return PJ_SUCCESS;
}
开发者ID:iamroger,项目名称:voip,代码行数:17,代码来源:sip_reg.c
示例11: PJ_DEF
PJ_DEF(int) session_info_init(Session_Info *session_info, packet_alloc_t *packet_alloc) {
pj_assert(session_info != NULL && packet_alloc != NULL);
session_info->session_nacked = PJ_FALSE;
session_info->isComplete = PJ_FALSE;
session_info->isDecodable = PJ_FALSE;
session_info->previous_frame_loss = PJ_TRUE;
session_info->frame_type = PJMEDIA_FRAME_TYPE_NONE;
session_info->isKeyFrame = PJ_FALSE;
//init list
pj_list_init(&session_info->packetList);
session_info->empty_low_seq_num = -1;
session_info->empty_high_seq_num = -1;
session_info->packets_not_decodable = 0;
session_info->packets_count = 0;
session_info->packet_alloc = packet_alloc;
return 0;
}
开发者ID:icefreedom,项目名称:jitter_buffer,代码行数:19,代码来源:session_info.c
示例12: create_tdata
static pj_status_t create_tdata(pj_stun_session *sess,
pj_stun_tx_data **p_tdata)
{
pj_pool_t *pool;
pj_stun_tx_data *tdata;
/* Create pool and initialize basic tdata attributes */
pool = pj_pool_create(sess->cfg->pf, "tdata%p",
TDATA_POOL_SIZE, TDATA_POOL_INC, NULL);
PJ_ASSERT_RETURN(pool, PJ_ENOMEM);
tdata = PJ_POOL_ZALLOC_T(pool, pj_stun_tx_data);
tdata->pool = pool;
tdata->sess = sess;
pj_list_init(tdata);
*p_tdata = tdata;
return PJ_SUCCESS;
}
开发者ID:AmongOthers,项目名称:PJSIP-iOS,代码行数:21,代码来源:stun_session.c
示例13: PJ_DEF
/*
* Set route-set.
*/
PJ_DEF(pj_status_t) pjsip_event_sub_set_route_set( pjsip_event_sub *sub,
const pjsip_route_hdr *route_set )
{
const pjsip_route_hdr *hdr;
pj_mutex_lock(sub->mutex);
/* Clear existing route set. */
pj_list_init(&sub->route_set);
/* Duplicate route headers. */
hdr = route_set->next;
while (hdr != route_set) {
pjsip_route_hdr *new_hdr = pjsip_hdr_clone(sub->pool, hdr);
pj_list_insert_before(&sub->route_set, new_hdr);
hdr = hdr->next;
}
pj_mutex_unlock(sub->mutex);
return 0;
}
开发者ID:svn2github,项目名称:pjproject,代码行数:25,代码来源:event_notify.c
示例14: multipart_clone_data
static void* multipart_clone_data(pj_pool_t *pool, const void *data,
unsigned len)
{
const struct multipart_data *src;
struct multipart_data *dst;
const pjsip_multipart_part *src_part;
PJ_UNUSED_ARG(len);
src = (const struct multipart_data*) data;
dst = PJ_POOL_ALLOC_T(pool, struct multipart_data);
pj_list_init(&dst->part_head);
pj_strdup(pool, &dst->boundary, &src->boundary);
src_part = src->part_head.next;
while (src_part != &src->part_head) {
pjsip_multipart_part *dst_part;
const pjsip_hdr *src_hdr;
dst_part = pjsip_multipart_create_part(pool);
src_hdr = src_part->hdr.next;
while (src_hdr != &src_part->hdr) {
pjsip_hdr *dst_hdr = (pjsip_hdr*)pjsip_hdr_clone(pool, src_hdr);
pj_list_push_back(&dst_part->hdr, dst_hdr);
src_hdr = src_hdr->next;
}
dst_part->body = pjsip_msg_body_clone(pool, src_part->body);
pj_list_push_back(&dst->part_head, dst_part);
src_part = src_part->next;
}
return (void*)dst;
}
开发者ID:cbanta,项目名称:pjproject,代码行数:38,代码来源:sip_multipart.c
示例15: PJ_DEF
/*
* Initialize codec manager.
*/
PJ_DEF(pj_status_t) pjmedia_codec_mgr_init (pjmedia_codec_mgr *mgr,
pj_pool_factory *pf)
{
pj_status_t status;
PJ_ASSERT_RETURN(mgr && pf, PJ_EINVAL);
/* Init codec manager */
pj_bzero(mgr, sizeof(pjmedia_codec_mgr));
mgr->pf = pf;
pj_list_init (&mgr->factory_list);
mgr->codec_cnt = 0;
/* Create pool */
mgr->pool = pj_pool_create(mgr->pf, "codec-mgr", 256, 256, NULL);
/* Create mutex */
status = pj_mutex_create_recursive(mgr->pool, "codec-mgr", &mgr->mutex);
if (status != PJ_SUCCESS)
return status;
return PJ_SUCCESS;
}
开发者ID:xhook,项目名称:asterisk-v11,代码行数:26,代码来源:codec.c
示例16: 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;
}
开发者ID:svn2github,项目名称:pjproject,代码行数:37,代码来源:publishc.c
示例17: gcc_test
static int gcc_test()
{
char msgbuf[512];
pj_str_t target = pj_str("sip:[email protected]:5061;x-param=param%201"
"?X-Hdr-1=Header%201"
"&X-Empty-Hdr=");
pjsip_tx_data *tdata;
pjsip_parser_err_report err_list;
pjsip_msg *msg;
int len;
pj_status_t status;
PJ_LOG(3,(THIS_FILE, " header param in URI to create request"));
/* Create request with header param in target URI. */
status = pjsip_endpt_create_request(endpt, &pjsip_invite_method, &target,
&target, &target, &target, NULL, -1,
NULL, &tdata);
if (status != 0) {
app_perror(" error: Unable to create request", status);
return -200;
}
/* Print and parse the request.
* We'll check that header params are not present in
*/
len = pjsip_msg_print(tdata->msg, msgbuf, sizeof(msgbuf));
if (len < 1) {
PJ_LOG(3,(THIS_FILE, " error: printing message"));
pjsip_tx_data_dec_ref(tdata);
return -250;
}
msgbuf[len] = '\0';
PJ_LOG(5,(THIS_FILE, "%d bytes request created:--begin-msg--\n"
"%s\n"
"--end-msg--", len, msgbuf));
/* Now parse the message. */
pj_list_init(&err_list);
msg = pjsip_parse_msg( tdata->pool, msgbuf, len, &err_list);
if (msg == NULL) {
pjsip_parser_err_report *e;
PJ_LOG(3,(THIS_FILE, " error: parsing message message"));
e = err_list.next;
while (e != &err_list) {
PJ_LOG(3,(THIS_FILE, " %s in line %d col %d hname=%.*s",
pj_exception_id_name(e->except_code),
e->line, e->col+1,
(int)e->hname.slen,
e->hname.ptr));
e = e->next;
}
pjsip_tx_data_dec_ref(tdata);
return -255;
}
pjsip_tx_data_dec_ref(tdata);
return 0;
}
开发者ID:Antares84,项目名称:asuswrt-merlin,代码行数:63,代码来源:txdata_test.c
示例18: process_register_request
//.........这里部分代码省略.........
gen_hdr = pjsip_generic_string_hdr_create(tdata->pool,
&STR_SUPPORTED,
&STR_OUTBOUND);
if (gen_hdr == NULL)
{
// LCOV_EXCL_START - can't see how this could ever happen
LOG_ERROR("Failed to add RFC 5626 headers");
tdata->msg->line.status.code = PJSIP_SC_INTERNAL_SERVER_ERROR;
status = pjsip_endpt_send_response2(stack_data.endpt, rdata, tdata, NULL, NULL);
delete aor_data;
return;
// LCOV_EXCL_STOP
}
pjsip_msg_add_hdr(tdata->msg, (pjsip_hdr*)gen_hdr);
// Add contact headers for all active bindings.
for (RegData::AoR::Bindings::const_iterator i = aor_data->bindings().begin();
i != aor_data->bindings().end();
++i)
{
RegData::AoR::Binding* binding = i->second;
if (binding->_expires > now)
{
// The binding hasn't expired.
pjsip_uri* uri = PJUtils::uri_from_string(binding->_uri, tdata->pool);
if (uri != NULL)
{
// Contact URI is well formed, so include this in the response.
pjsip_contact_hdr* contact = pjsip_contact_hdr_create(tdata->pool);
contact->star = 0;
contact->uri = uri;
contact->q1000 = binding->_priority;
contact->expires = binding->_expires - now;
pj_list_init(&contact->other_param);
for (std::list<std::pair<std::string, std::string> >::iterator j = binding->_params.begin();
j != binding->_params.end();
++j)
{
pjsip_param *new_param = PJ_POOL_ALLOC_T(tdata->pool, pjsip_param);
pj_strdup2(tdata->pool, &new_param->name, j->first.c_str());
pj_strdup2(tdata->pool, &new_param->value, j->second.c_str());
pj_list_insert_before(&contact->other_param, new_param);
}
pjsip_msg_add_hdr(tdata->msg, (pjsip_hdr*)contact);
}
else
{
// Contact URI is malformed. Log an error, but otherwise don't try and
// fix it.
// LCOV_EXCL_START hard to hit - needs bad data in the store
LOG_WARNING("Badly formed contact URI %s for address of record %s",
binding->_uri.c_str(), aor.c_str());
// LCOV_EXCL_STOP
}
}
}
// Deal with path header related fields in the response.
pjsip_generic_string_hdr* path_hdr =
(pjsip_generic_string_hdr*)pjsip_msg_find_hdr_by_name(msg, &STR_PATH, NULL);
if ((path_hdr != NULL) &&
(!aor_data->bindings().empty()))
{
// We have bindings with path headers so we must require outbound.
pjsip_require_hdr* require_hdr = pjsip_require_hdr_create(tdata->pool);
require_hdr->count = 1;
开发者ID:sa4250mnpo70,项目名称:sprout,代码行数:67,代码来源:registrar.cpp
示例19: 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;
//.........这里部分代码省略.........
开发者ID:ChrisKwon,项目名称:spore,代码行数:101,代码来源:sip_transport_tcp.c
示例20: PJ_DEF
/*
* pj_ioqueue_create()
*
* Create select ioqueue.
*/
PJ_DEF(pj_status_t) pj_ioqueue_create( pj_pool_t *pool,
pj_size_t max_fd,
pj_ioqueue_t **p_ioqueue)
{
pj_ioqueue_t *ioqueue;
pj_status_t rc;
pj_lock_t *lock;
int i;
/* Check that arguments are valid. */
PJ_ASSERT_RETURN(pool != NULL && p_ioqueue != NULL &&
max_fd > 0, PJ_EINVAL);
/* Check that size of pj_ioqueue_op_key_t is sufficient */
PJ_ASSERT_RETURN(sizeof(pj_ioqueue_op_key_t)-sizeof(void*) >=
sizeof(union operation_key), PJ_EBUG);
ioqueue = pj_pool_alloc(pool, sizeof(pj_ioqueue_t));
ioqueue_init(ioqueue);
ioqueue->max = max_fd;
ioqueue->count = 0;
pj_list_init(&ioqueue->active_list);
#if PJ_IOQUEUE_HAS_SAFE_UNREG
/* When safe unregistration is used (the default), we pre-create
* all keys and put them in the free list.
*/
/* Mutex to protect key's reference counter
* We don't want to use key's mutex or ioqueue's mutex because
* that would create deadlock situation in some cases.
*/
rc = pj_mutex_create_simple(pool, NULL, &ioqueue->ref_cnt_mutex);
if (rc != PJ_SUCCESS)
return rc;
/* Init key list */
pj_list_init(&ioqueue->free_list);
pj_list_init(&ioqueue->closing_list);
/* Pre-create all keys according to max_fd */
for ( i=0; i<max_fd; ++i) {
pj_ioqueue_key_t *key;
key = PJ_POOL_ALLOC_T(pool, pj_ioqueue_key_t);
key->ref_count = 0;
rc = pj_lock_create_recursive_mutex(pool, NULL, &key->lock);
if (rc != PJ_SUCCESS) {
key = ioqueue->free_list.next;
while (key != &ioqueue->free_list) {
pj_lock_destroy(key->lock);
key = key->next;
}
pj_mutex_destroy(ioqueue->ref_cnt_mutex);
return rc;
}
pj_list_push_back(&ioqueue->free_list, key);
}
#endif
rc = pj_lock_create_simple_mutex(pool, "ioq%p", &lock);
if (rc != PJ_SUCCESS)
return rc;
rc = pj_ioqueue_set_lock(ioqueue, lock, PJ_TRUE);
if (rc != PJ_SUCCESS)
return rc;
ioqueue->epfd = os_epoll_create(max_fd);
if (ioqueue->epfd < 0) {
ioqueue_destroy(ioqueue);
return PJ_RETURN_OS_ERROR(pj_get_native_os_error());
}
/*ioqueue->events = pj_pool_calloc(pool, max_fd, sizeof(struct epoll_event));
PJ_ASSERT_RETURN(ioqueue->events != NULL, PJ_ENOMEM);
ioqueue->queue = pj_pool_calloc(pool, max_fd, sizeof(struct queue));
PJ_ASSERT_RETURN(ioqueue->queue != NULL, PJ_ENOMEM);
*/
PJ_LOG(4, ("pjlib", "epoll I/O Queue created (%p)", ioqueue));
*p_ioqueue = ioqueue;
return PJ_SUCCESS;
}
开发者ID:LuLei2013,项目名称:pjproject,代码行数:95,代码来源:ioqueue_epoll.c
注:本文中的pj_list_init函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论