本文整理汇总了C++中pj_timer_heap_create函数的典型用法代码示例。如果您正苦于以下问题:C++ pj_timer_heap_create函数的具体用法?C++ pj_timer_heap_create怎么用?C++ pj_timer_heap_create使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了pj_timer_heap_create函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: create_stun_config
pj_status_t create_stun_config(pj_pool_t *pool, pj_stun_config *stun_cfg)
{
pj_ioqueue_t *ioqueue;
pj_timer_heap_t *timer_heap;
pj_lock_t *lock;
pj_status_t status;
status = pj_ioqueue_create(pool, 64, &ioqueue);
if (status != PJ_SUCCESS) {
app_perror(" pj_ioqueue_create()", status);
return status;
}
status = pj_timer_heap_create(pool, 256, &timer_heap);
if (status != PJ_SUCCESS) {
app_perror(" pj_timer_heap_create()", status);
pj_ioqueue_destroy(ioqueue);
return status;
}
pj_lock_create_recursive_mutex(pool, NULL, &lock);
pj_timer_heap_set_lock(timer_heap, lock, PJ_TRUE);
pj_stun_config_init(stun_cfg, mem, 0, ioqueue, timer_heap);
return PJ_SUCCESS;
}
开发者ID:aemonfly,项目名称:android-client,代码行数:27,代码来源:test.c
示例2: stun_sock_test
int stun_sock_test(void)
{
struct pjlib_state pjlib_state;
pj_stun_config stun_cfg;
pj_ioqueue_t *ioqueue = NULL;
pj_timer_heap_t *timer_heap = NULL;
pj_pool_t *pool = NULL;
pj_status_t status;
int ret = 0;
pool = pj_pool_create(mem, NULL, 512, 512, NULL);
status = pj_ioqueue_create(pool, 12, &ioqueue);
if (status != PJ_SUCCESS) {
app_perror(" pj_ioqueue_create()", status);
ret = -4;
goto on_return;
}
status = pj_timer_heap_create(pool, 100, &timer_heap);
if (status != PJ_SUCCESS) {
app_perror(" pj_timer_heap_create()", status);
ret = -8;
goto on_return;
}
pj_stun_config_init(&stun_cfg, mem, 0, ioqueue, timer_heap);
DO_TEST(timeout_test(&stun_cfg, PJ_FALSE));
DO_TEST(timeout_test(&stun_cfg, PJ_TRUE));
DO_TEST(missing_attr_test(&stun_cfg, PJ_FALSE));
DO_TEST(missing_attr_test(&stun_cfg, PJ_TRUE));
DO_TEST(keep_alive_test(&stun_cfg));
on_return:
if (timer_heap) pj_timer_heap_destroy(timer_heap);
if (ioqueue) pj_ioqueue_destroy(ioqueue);
if (pool) pj_pool_release(pool);
return ret;
}
开发者ID:AmoebaLabs,项目名称:pjsip,代码行数:42,代码来源:stun_sock_test.c
示例3: getURL
pj_status_t getURL(const char *curl)
{
pj_str_t url;
pj_http_req_callback hcb;
pj_status_t status;
pj_bzero(&hcb, sizeof(hcb));
hcb.on_complete = &on_complete;
hcb.on_data_read = &on_data_read;
hcb.on_send_data = &on_send_data;
hcb.on_response = &on_response;
/* Create pool, timer, and ioqueue */
pool = pj_pool_create(mem, NULL, 8192, 4096, NULL);
if (pj_timer_heap_create(pool, 16, &timer_heap))
return -31;
if (pj_ioqueue_create(pool, 16, &ioqueue))
return -32;
pj_strdup2(pool, &url, curl);
if ((status = pj_http_req_create(pool, &url, timer_heap, ioqueue,
NULL, &hcb, &http_req)) != PJ_SUCCESS)
return status;
if ((status = pj_http_req_start(http_req)) != PJ_SUCCESS)
return status;
while (pj_http_req_is_running(http_req)) {
pj_time_val delay = {0, 50};
pj_ioqueue_poll(ioqueue, &delay);
pj_timer_heap_poll(timer_heap, NULL);
}
pj_http_req_destroy(http_req);
pj_ioqueue_destroy(ioqueue);
pj_timer_heap_destroy(timer_heap);
pj_pool_release(pool);
return PJ_SUCCESS;
}
开发者ID:avble,项目名称:natClientEx,代码行数:41,代码来源:httpdemo.c
示例4: create
//
// Create proactor.
//
pj_status_t create( Pj_Pool *pool, pj_size_t max_fd,
pj_size_t timer_entry_count)
{
pj_status_t status;
destroy();
status = pj_ioqueue_create(pool->pool_(), max_fd, &ioq_);
if (status != PJ_SUCCESS)
return status;
status = pj_timer_heap_create(pool->pool_(),
timer_entry_count, &th_);
if (status != PJ_SUCCESS) {
pj_ioqueue_destroy(ioq_);
ioq_ = NULL;
return NULL;
}
return status;
}
开发者ID:BenBarahona,项目名称:Interdig,代码行数:24,代码来源:proactor.hpp
示例5: test_timer_heap
static int test_timer_heap(void)
{
int i, j;
pj_timer_entry *entry;
pj_pool_t *pool;
pj_timer_heap_t *timer;
pj_time_val delay;
pj_status_t rc; int err=0;
unsigned size, count;
size = pj_timer_heap_mem_size(MAX_COUNT)+MAX_COUNT*sizeof(pj_timer_entry);
pool = pj_pool_create( mem, NULL, size, 4000, NULL);
if (!pool) {
PJ_LOG(3,("test", "...error: unable to create pool of %u bytes",
size));
return -10;
}
entry = (pj_timer_entry*)pj_pool_calloc(pool, MAX_COUNT, sizeof(*entry));
if (!entry)
return -20;
for (i=0; i<MAX_COUNT; ++i) {
entry[i].cb = &timer_callback;
}
rc = pj_timer_heap_create(pool, MAX_COUNT, &timer);
if (rc != PJ_SUCCESS) {
app_perror("...error: unable to create timer heap", rc);
return -30;
}
count = MIN_COUNT;
for (i=0; i<LOOP; ++i) {
int early = 0;
int done=0;
int cancelled=0;
int rc;
pj_timestamp t1, t2, t_sched, t_cancel, t_poll;
pj_time_val now, expire;
pj_gettimeofday(&now);
pj_srand(now.sec);
t_sched.u32.lo = t_cancel.u32.lo = t_poll.u32.lo = 0;
// Register timers
for (j=0; j<(int)count; ++j) {
delay.sec = pj_rand() % DELAY;
delay.msec = pj_rand() % 1000;
// Schedule timer
pj_get_timestamp(&t1);
rc = pj_timer_heap_schedule(timer, &entry[j], &delay);
if (rc != 0)
return -40;
pj_get_timestamp(&t2);
t_sched.u32.lo += (t2.u32.lo - t1.u32.lo);
// Poll timers.
pj_get_timestamp(&t1);
rc = pj_timer_heap_poll(timer, NULL);
pj_get_timestamp(&t2);
if (rc > 0) {
t_poll.u32.lo += (t2.u32.lo - t1.u32.lo);
early += rc;
}
}
// Set the time where all timers should finish
pj_gettimeofday(&expire);
delay.sec = DELAY;
delay.msec = 0;
PJ_TIME_VAL_ADD(expire, delay);
// Wait unfil all timers finish, cancel some of them.
do {
int index = pj_rand() % count;
pj_get_timestamp(&t1);
rc = pj_timer_heap_cancel(timer, &entry[index]);
pj_get_timestamp(&t2);
if (rc > 0) {
cancelled += rc;
t_cancel.u32.lo += (t2.u32.lo - t1.u32.lo);
}
pj_gettimeofday(&now);
pj_get_timestamp(&t1);
#if defined(PJ_SYMBIAN) && PJ_SYMBIAN!=0
/* On Symbian, we must use OS poll (Active Scheduler poll) since
* timer is implemented using Active Object.
*/
rc = 0;
while (pj_symbianos_poll(-1, 0))
++rc;
#else
rc = pj_timer_heap_poll(timer, NULL);
#endif
pj_get_timestamp(&t2);
if (rc > 0) {
//.........这里部分代码省略.........
开发者ID:carlosdelfino,项目名称:WorkshopTelefoniaAutomacao,代码行数:101,代码来源:timer.c
示例6: stun_destroy_test
static int stun_destroy_test(void)
{
enum { LOOP = 500 };
struct stun_test_session test_sess;
pj_sockaddr bind_addr;
int addr_len;
pj_caching_pool cp;
pj_pool_t *pool;
unsigned i;
pj_status_t status;
int rc = 0;
PJ_LOG(3,(THIS_FILE, " STUN destroy concurrency test"));
pj_bzero(&test_sess, sizeof(test_sess));
pj_caching_pool_init(&cp, NULL, 0);
pool = pj_pool_create(&cp.factory, "testsess", 512, 512, NULL);
pj_stun_config_init(&test_sess.stun_cfg, &cp.factory, 0, NULL, NULL);
status = pj_timer_heap_create(pool, 1023, &test_sess.stun_cfg.timer_heap);
pj_assert(status == PJ_SUCCESS);
status = pj_lock_create_recursive_mutex(pool, NULL, &test_sess.lock);
pj_assert(status == PJ_SUCCESS);
pj_timer_heap_set_lock(test_sess.stun_cfg.timer_heap, test_sess.lock, PJ_TRUE);
pj_assert(status == PJ_SUCCESS);
status = pj_ioqueue_create(pool, 512, &test_sess.stun_cfg.ioqueue);
pj_assert(status == PJ_SUCCESS);
pj_sock_socket(pj_AF_INET(), pj_SOCK_DGRAM(), 0, &test_sess.server_sock);
pj_sockaddr_init(pj_AF_INET(), &bind_addr, NULL, 0);
status = pj_sock_bind(test_sess.server_sock, &bind_addr, pj_sockaddr_get_len(&bind_addr));
pj_assert(status == PJ_SUCCESS);
addr_len = sizeof(bind_addr);
status = pj_sock_getsockname(test_sess.server_sock, &bind_addr, &addr_len);
pj_assert(status == PJ_SUCCESS);
test_sess.server_port = pj_sockaddr_get_port(&bind_addr);
status = pj_event_create(pool, NULL, PJ_TRUE, PJ_FALSE, &test_sess.server_event);
pj_assert(status == PJ_SUCCESS);
for (i=0; i<SERVER_THREAD_CNT; ++i) {
status = pj_thread_create(pool, NULL,
&server_thread_proc, &test_sess,
0, 0, &test_sess.server_threads[i]);
pj_assert(status == PJ_SUCCESS);
}
for (i=0; i<WORKER_THREAD_CNT; ++i) {
status = pj_thread_create(pool, NULL,
&worker_thread_proc, &test_sess,
0, 0, &test_sess.worker_threads[i]);
pj_assert(status == PJ_SUCCESS);
}
/* Test 1: Main thread calls destroy while callback is processing response */
PJ_LOG(3,(THIS_FILE, " Destroy in main thread while callback is running"));
for (i=0; i<LOOP; ++i) {
int sleep = pj_rand() % 5;
PJ_LOG(3,(THIS_FILE, " Try %-3d of %d", i+1, LOOP));
/* Test 1: destroy at the same time when receiving response */
pj_bzero(&test_sess.param, sizeof(test_sess.param));
test_sess.param.client_sleep_after_start = 20;
test_sess.param.client_sleep_before_destroy = sleep;
test_sess.param.server_wait_for_event = PJ_TRUE;
stun_destroy_test_session(&test_sess);
PJ_LOG(3,(THIS_FILE,
" stun test a: sleep delay:%d: clients with response: %d",
sleep, test_sess.param.client_got_response));
/* Test 2: destroy at the same time with STUN retransmit timer */
test_sess.param.server_drop_request = PJ_TRUE;
test_sess.param.client_sleep_after_start = 0;
test_sess.param.client_sleep_before_destroy = PJ_STUN_RTO_VALUE;
test_sess.param.server_wait_for_event = PJ_FALSE;
stun_destroy_test_session(&test_sess);
PJ_LOG(3,(THIS_FILE, " stun test b: retransmit concurrency"));
/* Test 3: destroy at the same time with receiving response
* AND STUN retransmit timer */
test_sess.param.client_got_response = 0;
test_sess.param.server_drop_request = PJ_FALSE;
test_sess.param.client_sleep_after_start = PJ_STUN_RTO_VALUE;
test_sess.param.client_sleep_before_destroy = 0;
test_sess.param.server_wait_for_event = PJ_TRUE;
stun_destroy_test_session(&test_sess);
PJ_LOG(3,(THIS_FILE,
" stun test c: clients with response: %d",
test_sess.param.client_got_response));
pj_thread_sleep(10);
//.........这里部分代码省略.........
开发者ID:AmoebaLabs,项目名称:pjsip,代码行数:101,代码来源:concur_test.c
示例7: http_client_test_delete
int http_client_test_delete()
{
pj_str_t url;
pj_http_req_callback hcb;
pj_http_req_param param;
char urlbuf[80];
pj_bzero(&hcb, sizeof(hcb));
hcb.on_complete = &on_complete;
hcb.on_response = &on_response;
/* Create pool, timer, and ioqueue */
pool = pj_pool_create(mem, NULL, 8192, 4096, NULL);
if (pj_timer_heap_create(pool, 16, &timer_heap))
return -61;
if (pj_ioqueue_create(pool, 16, &ioqueue))
return -62;
#ifdef USE_LOCAL_SERVER
thread_quit = PJ_FALSE;
g_server.action = ACTION_REPLY;
g_server.send_content_length = PJ_TRUE;
g_server.data_size = 0;
g_server.buf_size = 1024;
sstatus = pj_sock_socket(pj_AF_INET(), pj_SOCK_STREAM(), 0,
&g_server.sock);
if (sstatus != PJ_SUCCESS)
return -41;
pj_sockaddr_in_init(&addr, NULL, 0);
sstatus = pj_sock_bind(g_server.sock, &addr, sizeof(addr));
if (sstatus != PJ_SUCCESS)
return -43;
{
pj_sockaddr_in addr;
int addr_len = sizeof(addr);
sstatus = pj_sock_getsockname(g_server.sock, &addr, &addr_len);
if (sstatus != PJ_SUCCESS)
return -44;
g_server.port = pj_sockaddr_in_get_port(&addr);
pj_ansi_snprintf(urlbuf, sizeof(urlbuf),
"http://127.0.0.1:%d/test/test2.txt",
g_server.port);
url = pj_str(urlbuf);
}
sstatus = pj_sock_listen(g_server.sock, 8);
if (sstatus != PJ_SUCCESS)
return -45;
sstatus = pj_thread_create(pool, NULL, &server_thread, &g_server,
0, 0, &g_server.thread);
if (sstatus != PJ_SUCCESS)
return -47;
#else
pj_cstr(&url, "http://127.0.0.1:280/test/test2.txt");
#endif
pj_http_req_param_default(¶m);
pj_strset2(¶m.method, (char*)"DELETE");
if (pj_http_req_create(pool, &url, timer_heap, ioqueue,
¶m, &hcb, &http_req))
return -63;
if (pj_http_req_start(http_req))
return -65;
while (pj_http_req_is_running(http_req)) {
pj_time_val delay = {0, 50};
pj_ioqueue_poll(ioqueue, &delay);
pj_timer_heap_poll(timer_heap, NULL);
}
#ifdef USE_LOCAL_SERVER
thread_quit = PJ_TRUE;
pj_thread_join(g_server.thread);
pj_sock_close(g_server.sock);
#endif
pj_http_req_destroy(http_req);
pj_ioqueue_destroy(ioqueue);
pj_timer_heap_destroy(timer_heap);
pj_pool_release(pool);
return PJ_SUCCESS;
}
开发者ID:Archipov,项目名称:android-client,代码行数:90,代码来源:http_client.c
示例8: http_client_test2
/*
* GET request scenario 2: using on_complete() to get the
* complete data. Server does not reply with content-length.
* Request timed out, application sets a longer timeout, then
* then restart the request.
*/
int http_client_test2()
{
pj_str_t url;
pj_http_req_callback hcb;
pj_http_req_param param;
pj_time_val timeout;
char urlbuf[80];
pj_bzero(&hcb, sizeof(hcb));
hcb.on_complete = &on_complete;
hcb.on_response = &on_response;
pj_http_req_param_default(¶m);
/* Create pool, timer, and ioqueue */
pool = pj_pool_create(mem, NULL, 8192, 4096, NULL);
if (pj_timer_heap_create(pool, 16, &timer_heap))
return -41;
if (pj_ioqueue_create(pool, 16, &ioqueue))
return -42;
#ifdef USE_LOCAL_SERVER
pj_cstr(&url, "http://127.0.0.1:380");
param.timeout.sec = 0;
param.timeout.msec = 2000;
thread_quit = PJ_FALSE;
g_server.action = ACTION_IGNORE;
g_server.send_content_length = PJ_FALSE;
g_server.data_size = 4173;
g_server.buf_size = 1024;
sstatus = pj_sock_socket(pj_AF_INET(), pj_SOCK_STREAM(), 0,
&g_server.sock);
if (sstatus != PJ_SUCCESS)
return -41;
pj_sockaddr_in_init(&addr, NULL, 0);
sstatus = pj_sock_bind(g_server.sock, &addr, sizeof(addr));
if (sstatus != PJ_SUCCESS)
return -43;
{
pj_sockaddr_in addr;
int addr_len = sizeof(addr);
sstatus = pj_sock_getsockname(g_server.sock, &addr, &addr_len);
if (sstatus != PJ_SUCCESS)
return -44;
g_server.port = pj_sockaddr_in_get_port(&addr);
pj_ansi_snprintf(urlbuf, sizeof(urlbuf),
"http://127.0.0.1:%d",
g_server.port);
url = pj_str(urlbuf);
}
sstatus = pj_sock_listen(g_server.sock, 8);
if (sstatus != PJ_SUCCESS)
return -45;
sstatus = pj_thread_create(pool, NULL, &server_thread, &g_server,
0, 0, &g_server.thread);
if (sstatus != PJ_SUCCESS)
return -47;
#else
pj_cstr(&url, "http://www.google.com.sg");
param.timeout.sec = 0;
param.timeout.msec = 50;
#endif
pj_http_headers_add_elmt2(¶m.headers, (char*)"Accept",
(char*)"image/gif, image/x-xbitmap, image/jpeg, "
"image/pjpeg, application/x-ms-application,"
" application/vnd.ms-xpsdocument, "
"application/xaml+xml, "
"application/x-ms-xbap, "
"application/x-shockwave-flash, "
"application/vnd.ms-excel, "
"application/vnd.ms-powerpoint, "
"application/msword, */*");
pj_http_headers_add_elmt2(¶m.headers, (char*)"Accept-Language",
(char*)"en-sg");
pj_http_headers_add_elmt2(¶m.headers, (char*)"User-Agent",
(char*)"Mozilla/4.0 (compatible; MSIE 7.0; "
"Windows NT 6.0; SLCC1; "
".NET CLR 2.0.50727; "
".NET CLR 3.0.04506)");
if (pj_http_req_create(pool, &url, timer_heap, ioqueue,
¶m, &hcb, &http_req))
return -43;
if (pj_http_req_start(http_req))
return -45;
//.........这里部分代码省略.........
开发者ID:Archipov,项目名称:android-client,代码行数:101,代码来源:http_client.c
示例9: init
static int init()
{
int i;
pj_status_t status;
CHECK( pj_init() );
CHECK( pjlib_util_init() );
CHECK( pjnath_init() );
/* Check that server is specified */
if (!o.srv_addr) {
printf("Error: server must be specified\n");
return PJ_EINVAL;
}
pj_caching_pool_init(&g.cp, &pj_pool_factory_default_policy, 0);
g.pool = pj_pool_create(&g.cp.factory, "main", 1000, 1000, NULL);
/* Init global STUN config */
pj_stun_config_init(&g.stun_config, &g.cp.factory, 0, NULL, NULL);
/* Create global timer heap */
CHECK( pj_timer_heap_create(g.pool, 1000, &g.stun_config.timer_heap) );
/* Create global ioqueue */
CHECK( pj_ioqueue_create(g.pool, 16, &g.stun_config.ioqueue) );
/*
* Create peers
*/
for (i=0; i<(int)PJ_ARRAY_SIZE(g.peer); ++i) {
pj_stun_sock_cb stun_sock_cb;
char name[] = "peer0";
pj_uint16_t port;
pj_stun_sock_cfg ss_cfg;
pj_str_t server;
pj_bzero(&stun_sock_cb, sizeof(stun_sock_cb));
stun_sock_cb.on_rx_data = &stun_sock_on_rx_data;
stun_sock_cb.on_status = &stun_sock_on_status;
g.peer[i].mapped_addr.addr.sa_family = pj_AF_INET();
pj_stun_sock_cfg_default(&ss_cfg);
#if 1
/* make reading the log easier */
ss_cfg.ka_interval = 300;
#endif
name[strlen(name)-1] = '0'+i;
status = pj_stun_sock_create(&g.stun_config, name, pj_AF_INET(),
&stun_sock_cb, &ss_cfg,
&g.peer[i], &g.peer[i].stun_sock);
if (status != PJ_SUCCESS) {
my_perror("pj_stun_sock_create()", status);
return status;
}
if (o.stun_server) {
server = pj_str(o.stun_server);
port = PJ_STUN_PORT;
} else {
server = pj_str(o.srv_addr);
port = (pj_uint16_t)(o.srv_port?atoi(o.srv_port):PJ_STUN_PORT);
}
status = pj_stun_sock_start(g.peer[i].stun_sock, &server,
port, NULL);
if (status != PJ_SUCCESS) {
my_perror("pj_stun_sock_start()", status);
return status;
}
}
/* Start the worker thread */
CHECK( pj_thread_create(g.pool, "stun", &worker_thread, NULL, 0, 0, &g.thread) );
return PJ_SUCCESS;
}
开发者ID:carlosdelfino,项目名称:WorkshopTelefoniaAutomacao,代码行数:80,代码来源:client_main.c
示例10: dummy_function
int dummy_function()
{
pj_caching_pool cp;
sprintf(NULL, "%d", 0);
rand();
#ifdef HAS_PJLIB
pj_init();
pj_caching_pool_init(&cp, NULL, 0);
pj_array_erase(NULL, 0, 0, 0);
pj_create_unique_string(NULL, NULL);
pj_hash_create(NULL, 0);
pj_hash_get(NULL, NULL, 0, NULL);
pj_hash_set(NULL, NULL, NULL, 0, 0, NULL);
pj_ioqueue_create(NULL, 0, NULL);
pj_ioqueue_register_sock(NULL, NULL, 0, NULL, NULL, NULL);
pj_pool_alloc(NULL, 0);
pj_timer_heap_create(NULL, 0, NULL);
#endif
#ifdef HAS_PJLIB_STUN
pjstun_get_mapped_addr(&cp.factory, 0, NULL, NULL, 80, NULL, 80, NULL);
#endif
#ifdef HAS_PJLIB_GETOPT
pj_getopt_long(0, NULL, NULL, NULL, NULL);
#endif
#ifdef HAS_PJLIB_XML
pj_xml_parse(NULL, NULL, 100);
pj_xml_print(NULL, NULL, 10, PJ_FALSE);
pj_xml_clone(NULL, NULL);
pj_xml_node_new(NULL, NULL);
pj_xml_attr_new(NULL, NULL, NULL);
pj_xml_add_node(NULL, NULL);
pj_xml_add_attr(NULL, NULL);
pj_xml_find_node(NULL, NULL);
pj_xml_find_next_node(NULL, NULL, NULL);
pj_xml_find_attr(NULL, NULL, NULL);
pj_xml_find(NULL, NULL, NULL, NULL);
#endif
#ifdef HAS_PJLIB_SCANNER
pj_cis_buf_init(NULL);
pj_cis_init(NULL, NULL);
pj_cis_dup(NULL, NULL);
pj_cis_add_alpha(NULL);
pj_cis_add_str(NULL, NULL);
pj_scan_init(NULL, NULL, 0, 0, NULL);
pj_scan_fini(NULL);
pj_scan_peek(NULL, NULL, NULL);
pj_scan_peek_n(NULL, 0, NULL);
pj_scan_peek_until(NULL, NULL, NULL);
pj_scan_get(NULL, NULL, NULL);
pj_scan_get_unescape(NULL, NULL, NULL);
pj_scan_get_quote(NULL, 0, 0, NULL);
pj_scan_get_n(NULL, 0, NULL);
pj_scan_get_char(NULL);
pj_scan_get_until(NULL, NULL, NULL);
pj_scan_strcmp(NULL, NULL, 0);
pj_scan_stricmp(NULL, NULL, 0);
pj_scan_stricmp_alnum(NULL, NULL, 0);
pj_scan_get_newline(NULL);
pj_scan_restore_state(NULL, NULL);
#endif
#ifdef HAS_PJLIB_DNS
pj_dns_make_query(NULL, NULL, 0, 0, NULL);
pj_dns_parse_packet(NULL, NULL, 0, NULL);
pj_dns_packet_dup(NULL, NULL, 0, NULL);
#endif
#ifdef HAS_PJLIB_RESOLVER
pj_dns_resolver_create(NULL, NULL, 0, NULL, NULL, NULL);
pj_dns_resolver_set_ns(NULL, 0, NULL, NULL);
pj_dns_resolver_handle_events(NULL, NULL);
pj_dns_resolver_destroy(NULL, 0);
pj_dns_resolver_start_query(NULL, NULL, 0, 0, NULL, NULL, NULL);
pj_dns_resolver_cancel_query(NULL, 0);
pj_dns_resolver_add_entry(NULL, NULL, 0);
#endif
#ifdef HAS_PJLIB_SRV_RESOLVER
pj_dns_srv_resolve(NULL, NULL, 0, NULL, NULL, PJ_FALSE, NULL, NULL);
#endif
#ifdef HAS_PJLIB_CRC32
pj_crc32_init(NULL);
pj_crc32_update(NULL, NULL, 0);
pj_crc32_final(NULL);
#endif
#ifdef HAS_PJLIB_HMAC_MD5
pj_hmac_md5(NULL, 0, NULL, 0, NULL);
#endif
#ifdef HAS_PJLIB_HMAC_SHA1
pj_hmac_sha1(NULL, 0, NULL, 0, NULL);
//.........这里部分代码省略.........
开发者ID:0x0B501E7E,项目名称:pjproject,代码行数:101,代码来源:footprint.c
示例11: create
//
// Create
//
pj_status_t create(Pj_Pool *pool, pj_size_t initial_count)
{
destroy();
return pj_timer_heap_create(pool->pool_(), initial_count, &ht_);
}
开发者ID:max3903,项目名称:SFLphone,代码行数:8,代码来源:timer.hpp
示例12: client_non_ssl
/* Raw TCP socket try to connect to SSL socket server, once
* connection established, it will just do nothing, SSL socket
* server should be able to close the connection after specified
* timeout period (set ms_timeout to 0 to disable timer).
*/
static int client_non_ssl(unsigned ms_timeout)
{
pj_pool_t *pool = NULL;
pj_ioqueue_t *ioqueue = NULL;
pj_timer_heap_t *timer = NULL;
pj_ssl_sock_t *ssock_serv = NULL;
pj_activesock_t *asock_cli = NULL;
pj_activesock_cb asock_cb = { 0 };
pj_sock_t sock = PJ_INVALID_SOCKET;
pj_ssl_sock_param param;
struct test_state state_serv = { 0 };
struct test_state state_cli = { 0 };
pj_sockaddr listen_addr;
pj_ssl_cert_t *cert = NULL;
pj_status_t status;
pool = pj_pool_create(mem, "ssl_accept_raw_tcp", 256, 256, NULL);
status = pj_ioqueue_create(pool, 4, &ioqueue);
if (status != PJ_SUCCESS) {
goto on_return;
}
status = pj_timer_heap_create(pool, 4, &timer);
if (status != PJ_SUCCESS) {
goto on_return;
}
/* Set cert */
{
pj_str_t tmp1, tmp2, tmp3, tmp4;
status = pj_ssl_cert_load_from_files(pool,
pj_strset2(&tmp1, (char*)CERT_CA_FILE),
pj_strset2(&tmp2, (char*)CERT_FILE),
pj_strset2(&tmp3, (char*)CERT_PRIVKEY_FILE),
pj_strset2(&tmp4, (char*)CERT_PRIVKEY_PASS),
&cert);
if (status != PJ_SUCCESS) {
goto on_return;
}
}
pj_ssl_sock_param_default(¶m);
param.cb.on_accept_complete = &ssl_on_accept_complete;
param.cb.on_data_read = &ssl_on_data_read;
param.cb.on_data_sent = &ssl_on_data_sent;
param.ioqueue = ioqueue;
param.timer_heap = timer;
param.timeout.sec = 0;
param.timeout.msec = ms_timeout;
pj_time_val_normalize(¶m.timeout);
/* SERVER */
param.user_data = &state_serv;
state_serv.pool = pool;
state_serv.is_server = PJ_TRUE;
state_serv.is_verbose = PJ_TRUE;
status = pj_ssl_sock_create(pool, ¶m, &ssock_serv);
if (status != PJ_SUCCESS) {
goto on_return;
}
status = pj_ssl_sock_set_certificate(ssock_serv, pool, cert);
if (status != PJ_SUCCESS) {
goto on_return;
}
/* Init bind address */
{
pj_str_t tmp_st;
pj_sockaddr_init(PJ_AF_INET, &listen_addr, pj_strset2(&tmp_st, "127.0.0.1"), 0);
}
status = pj_ssl_sock_start_accept(ssock_serv, pool, &listen_addr, pj_sockaddr_get_len(&listen_addr));
if (status != PJ_SUCCESS) {
goto on_return;
}
/* Update listener address */
{
pj_ssl_sock_info info;
pj_ssl_sock_get_info(ssock_serv, &info);
pj_sockaddr_cp(&listen_addr, &info.local_addr);
}
/* CLIENT */
state_cli.pool = pool;
status = pj_sock_socket(pj_AF_INET(), pj_SOCK_STREAM(), 0, &sock);
if (status != PJ_SUCCESS) {
goto on_return;
}
asock_cb.on_connect_complete = &asock_on_connect_complete;
//.........这里部分代码省略.........
开发者ID:kaaustubh,项目名称:pjsip,代码行数:101,代码来源:ssl_sock.c
示例13: PJ_DEF
/*
* Create the resolver.
*/
PJ_DEF(pj_status_t) pj_dns_resolver_create( pj_pool_factory *pf,
const char *name,
unsigned options,
pj_timer_heap_t *timer,
pj_ioqueue_t *ioqueue,
pj_dns_resolver **p_resolver)
{
pj_pool_t *pool;
pj_dns_resolver *resv;
pj_status_t status;
/* Sanity check */
PJ_ASSERT_RETURN(pf && p_resolver, PJ_EINVAL);
if (name == NULL)
name = THIS_FILE;
/* Create and initialize resolver instance */
pool = pj_pool_create(pf, name, 4000, 4000, NULL);
if (!pool)
return PJ_ENOMEM;
/* Create pool and name */
resv = PJ_POOL_ZALLOC_T(pool, struct pj_dns_resolver);
resv->pool = pool;
resv->udp_sock = PJ_INVALID_SOCKET;
pj_strdup2_with_null(pool, &resv->name, name);
/* Create the mutex */
status = pj_mutex_create_recursive(pool, name, &resv->mutex);
if (status != PJ_SUCCESS)
goto on_error;
/* Timer, ioqueue, and settings */
resv->timer = timer;
resv->ioqueue = ioqueue;
resv->last_id = 1;
pj_dns_settings_default(&resv->settings);
resv->settings.options = options;
/* Create the timer heap if one is not specified */
if (resv->timer == NULL) {
status = pj_timer_heap_create(pool, TIMER_SIZE, &resv->timer);
if (status != PJ_SUCCESS)
goto on_error;
}
/* Create the ioqueue if one is not specified */
if (resv->ioqueue == NULL) {
status = pj_ioqueue_create(pool, MAX_FD, &resv->ioqueue);
if (status != PJ_SUCCESS)
goto on_error;
}
/* Response cache hash table */
resv->hrescache = pj_hash_create(pool, RES_HASH_TABLE_SIZE);
/* Query hash table and free list. */
resv->hquerybyid = pj_hash_create(pool, Q_HASH_TABLE_SIZE);
resv->hquerybyres = pj_hash_create(pool, Q_HASH_TABLE_SIZE);
pj_list_init(&resv->query_free_nodes);
/* Initialize the UDP socket */
status = init_sock(resv);
if (status != PJ_SUCCESS)
goto on_error;
/* Looks like everything is okay */
*p_resolver = resv;
return PJ_SUCCESS;
on_error:
pj_dns_resolver_destroy(resv, PJ_FALSE);
return status;
}
开发者ID:avble,项目名称:natClientEx,代码行数:79,代码来源:resolver.c
示例14: PJ_DEF
/*
* Create the ZRTP transport.
*/
PJ_DEF(pj_status_t) pjmedia_transport_zrtp_create(pjmedia_endpt *endpt,
const char *name,
pjmedia_transport *transport,
pjmedia_transport **p_tp,
pj_bool_t close_slave)
{
pj_pool_t *pool;
struct tp_zrtp *zrtp;
pj_status_t rc;
if (name == NULL)
name = "tzrtp%p";
/* Create the pool and initialize the adapter structure */
pool = pjmedia_endpt_create_pool(endpt, name, 5*1024, 512);
zrtp = PJ_POOL_ZALLOC_T(pool, struct tp_zrtp);
zrtp->pool = pool;
pj_ansi_strncpy(zrtp->base.name, pool->obj_name,
sizeof(zrtp->base.name));
zrtp->base.type = (pjmedia_transport_type)
(PJMEDIA_TRANSPORT_TYPE_USER + 2);
zrtp->base.op = &tp_zrtp_op;
#ifndef DYNAMIC_TIMER
if (timer_pool == NULL)
{
timer_pool = pjmedia_endpt_create_pool(endpt, "zrtp_timer", 256, 256);
rc = timer_initialize();
if (rc != PJ_SUCCESS)
{
pj_pool_release(timer_pool);
pj_pool_release(zrtp->pool);
return rc;
}
}
#else
zrtp->timer_heap = NULL;
zrtp->timer_pool = pjmedia_endpt_create_pool(endpt, "zrtp_timer", 256, 256);
rc = pj_timer_heap_create(zrtp->timer_pool, 4, &zrtp->timer_heap);
if (rc != PJ_SUCCESS)
{
pj_pool_release(zrtp->timer_pool);
pj_pool_release(zrtp->pool);
return rc;
}
#endif
/* Create the empty wrapper */
zrtp->zrtpCtx = zrtp_CreateWrapper();
/* Initialize standard values */
zrtp->clientIdString = clientId; /* Set standard name */
zrtp->zrtpSeq = 1; /* TODO: randomize */
rc = pj_mutex_create_simple(zrtp->pool, "zrtp", &zrtp->zrtpMutex);
zrtp->zrtpBuffer = pj_pool_zalloc(pool, MAX_ZRTP_SIZE);
zrtp->sendBuffer = pj_pool_zalloc(pool, MAX_RTP_BUFFER_LEN);
zrtp->sendBufferCtrl = pj_pool_zalloc(pool, MAX_RTCP_BUFFER_LEN);
zrtp->slave_tp = transport;
zrtp->close_slave = close_slave;
zrtp->mitmMode = PJ_FALSE;
/* Done */
zrtp->refcount++;
*p_tp = &zrtp->base;
return PJ_SUCCESS;
}
开发者ID:jresende,项目名称:ZRTP4PJ,代码行数:70,代码来源:transport_zrtp.c
示例15: timer_initialize
static int timer_initialize()
{
pj_status_t rc;
pj_mutex_t* temp_mutex;
rc = pj_mutex_create_simple(timer_pool, "zrtp_timer", &temp_mutex);
if (rc != PJ_SUCCESS)
{
return rc;
}
pj_enter_critical_section();
if (timer_mutex == NULL)
timer_mutex = temp_mutex;
else
pj_mutex_destroy(temp_mutex);
pj_leave_critical_section();
pj_mutex_lock(timer_mutex);
if (timer_initialized)
{
pj_mutex_unlock(timer_mutex);
return PJ_SUCCESS;
}
rc = pj_timer_heap_create(timer_pool, 4, &timer);
if (rc != PJ_SUCCESS)
{
goto ERROR;
}
rc = pj_sem_create(timer_pool, "zrtp_timer", 0, 1, &timer_sem);
if (rc != PJ_SUCCESS)
{
goto ERROR;
}
rc = pj_thread_create(timer_pool, "zrtp_timer", &timer_thread_run, NULL,
PJ_THREAD_DEFAULT_STACK_SIZE, 0, &thread_run);
if (rc != PJ_SUCCESS)
{
goto ERROR;
}
timer_initialized = 1;
pj_mutex_unlock(timer_mutex);
return PJ_SUCCESS;
ERROR:
if (timer != NULL)
{
pj_timer_heap_destroy(timer);
timer = NULL;
}
if (timer_sem != NULL)
{
pj_sem_destroy(timer_sem);
timer_sem = NULL;
}
if (timer_mutex != NULL)
{
pj_mutex_unlock(timer_mutex);
pj_mutex_destroy(timer_mutex);
timer_mutex = NULL;
}
return rc;
}
开发者ID:jresende,项目名称:ZRTP4PJ,代码行数:68,代码来源:transport_zrtp.c
示例16: perf_test
/* Test will perform multiple clients trying to connect to single server.
* Once SSL connection established, echo test will be performed.
*/
static int perf_test(unsigned clients, unsigned ms_handshake_timeout)
{
pj_pool_t *pool = NULL;
pj_ioqueue_t *ioqueue = NULL;
pj_timer_heap_t *timer = NULL;
pj_ssl_sock_t *ssock_serv = NULL;
pj_ssl_sock_t **ssock_cli = NULL;
pj_ssl_sock_param param;
struct test_state state_serv = { 0 };
struct test_state *state_cli = NULL;
pj_sockaddr addr, listen_addr;
pj_ssl_cert_t *cert = NULL;
pj_status_t status;
unsigned i, cli_err = 0, tot_sent = 0, tot_recv = 0;
pj_time_val start;
pool = pj_pool_create(mem, "ssl_perf", 256, 256, NULL);
status = pj_ioqueue_create(pool, PJ_IOQUEUE_MAX_HANDLES, &ioqueue);
if (status != PJ_SUCCESS) {
goto on_return;
}
status = pj_timer_heap_create(pool, PJ_IOQUEUE_MAX_HANDLES, &timer);
if (status != PJ_SUCCESS) {
goto on_return;
}
/* Set cert */
{
pj_str_t tmp1, tmp2, tmp3, tmp4;
status = pj_ssl_cert_load_from_files(pool,
pj_strset2(&tmp1, (char*)CERT_CA_FILE),
pj_strset2(&tmp2, (char*)CERT_FILE),
pj_strset2(&tmp3, (char*)CERT_PRIVKEY_FILE),
pj_strset2(&tmp4, (char*)CERT_PRIVKEY_PASS),
&cert);
if (status != PJ_SUCCESS) {
goto on_return;
}
}
pj_ssl_sock_param_default(¶m);
param.cb.on_accept_complete = &ssl_on_accept_complete;
param.cb.on_connect_complete = &ssl_on_connect_complete;
param.cb.on_data_read = &ssl_on_data_read;
param.cb.on_data_sent = &ssl_on_data_sent;
param.ioqueue = ioqueue;
param.timer_heap = timer;
param.timeout.sec = 0;
param.timeout.msec = ms_handshake_timeout;
pj_time_val_normalize(¶m.timeout);
/* Init default bind address */
{
pj_str_t tmp_st;
pj_sockaddr_init(PJ_AF_INET, &addr, pj_strset2(&tmp_st, "127.0.0.1"), 0);
}
/* SERVER */
param.user_data = &state_serv;
state_serv.pool = pool;
state_serv.echo = PJ_TRUE;
state_serv.is_server = PJ_TRUE;
status = pj_ssl_sock_create(pool, ¶m, &ssock_serv);
if (status != PJ_SUCCESS) {
goto on_return;
}
status = pj_ssl_sock_set_certificate(ssock_serv, pool, cert);
if (status != PJ_SUCCESS) {
goto on_return;
}
status = pj_ssl_sock_start_accept(ssock_serv, pool, &addr, pj_sockaddr_get_len(&addr));
if (status != PJ_SUCCESS) {
goto on_return;
}
/* Get listening address for clients to connect to */
{
pj_ssl_sock_info info;
char buf[64];
pj_ssl_sock_get_info(ssock_serv, &info);
pj_sockaddr_cp(&listen_addr, &info.local_addr);
pj_sockaddr_print((pj_sockaddr_t*)&listen_addr, buf, sizeof(buf), 1);
PJ_LOG(3, ("", "...Listener ready at %s", buf));
}
/* CLIENTS */
clients_num = clients;
//.........这里部分代码省略.........
开发者ID:kaaustubh,项目名称:pjsip,代码行数:101,代码来源:ssl_sock.c
示例17: krx_ice_init
int krx_ice_init(krx_ice* k) {
pj_status_t r;
if(!k) {
return -1;
}
/* initialize pj */
r = pj_init();
CHECK_PJ_STATUS(r, "Error: cannot initialize pj.\n", -2);
r = pjlib_util_init();
CHECK_PJ_STATUS(r, "Error: cannot initialize pj-util.\n", -3);
r = pjnath_init();
CHECK_PJ_STATUS(r, "Error: cannot initialize pjnath.\n", -4);
/* create memory pool */
pj_caching_pool_init(&k->caching_pool, NULL, 0);
/* initialize the ice settings */
pj_ice_strans_cfg_default(&k->ice_cfg);
/* create the pool */
k->pool = pj_pool_create(&k->caching_pool.factory, "krx_ice_pjnath", 512, 512, NULL); /* 512 = initial size, 512 = incremental size */
if(!k->pool) {
printf("Error: cannot create pool.\n");
return -5;
}
k->ice_cfg.stun_cfg.pf = &k->caching_pool.factory;
/* create heap for timers */
r = pj_timer_heap_create(k->pool, 100, &k->ice_cfg.stun_cfg.timer_heap);
CHECK_PJ_STATUS(r, "Error: cannot create timer heap.\n", -6);
/* create ioqueue for network I/O */
r = pj_ioqueue_create(k->pool, 16, &k->ice_cfg.stun_cfg.ioqueue);
CHECK_PJ_STATUS(r, "Error: cannot create ioqueue.\n", -7);
/* create managing thread */
r = pj_thread_create(k->pool, "krx_ice_pjnath", &krx_ice_worker_thread, k, 0, 0, &k->thread);
CHECK_PJ_STATUS(r, "Error: cannot create managing thread.", -8);
k->ice_cfg.af = pj_AF_INET();
/* @todo(roxlu): we could add a nameserver */
k->ice_cfg.opt.aggressive = PJ_FALSE; /* @todo(roxlu): read up the aggressive flag in ice_cfg. */
/* default configs */
k->max_hosts = 4;
k->ncomp = 4;
/* initialize the callbacks */
pj_bzero(&k->ice_cb, sizeof(k->ice_cb));
k->ice_cb.on_rx_data = krx_ice_on_rx_data;
k->ice_cb.on_ice_complete = krx_ice_on_complete;
/* sdp info */
k->ice_ufrag = NULL;
k->ice_pwd = NULL;
return 0;
}
开发者ID:roxlu,项目名称:krx_rtc,代码行数:66,代码来源:krx_pjnath_ice.c
示例18: https_client_test
static int https_client_test(unsigned ms_timeout)
{
pj_pool_t *pool = NULL;
pj_ioqueue_t *ioqueue = NULL;
pj_timer_heap_t *timer = NULL;
pj_ssl_sock_t *ssock = NULL;
pj_ssl_sock_param param;
pj_status_t status;
struct test_state state = {0};
pj_sockaddr local_addr, rem_addr;
pj_str_t tmp_st;
pool = pj_pool_create(mem, "https_get", 256, 256, NULL);
status = pj_ioqueue_create(pool, 4, &ioqueue);
if (status != PJ_SUCCESS) {
goto on_return;
}
status = pj_timer_heap_create(pool, 4, &timer);
if (status != PJ_SUCCESS) {
goto on_return;
}
state.pool = pool;
state.send_str = HTTP_REQ;
state.send_str_len = pj_ansi_strlen(state.send_str);
state.is_verbose = PJ_TRUE;
pj_ssl_sock_param_default(¶m);
param.cb.on_connect_complete = &ssl_on_connect_complete;
param.cb.on_data_read = &ssl_on_data_read;
param.cb.on_data_sent = &ssl_on_data_sent;
param.ioqueue = ioqueue;
param.user_data = &state;
param.server_name = pj_str((char*)HTTP_SERVER_ADDR);
param.timer_heap = timer;
param.timeout.sec = 0;
param.timeout.msec = ms_timeout;
param.proto = PJ_SSL_SOCK_PROTO_SSL23;
pj_time_val_normalize(¶m.timeout);
status = pj_ssl_sock_create(pool, ¶m, &ssock);
if (status != PJ_SUCCESS) {
goto on_return;
}
pj_sockaddr_init(PJ_AF_INET, &local_addr, pj_strset2(&tmp_st, "0.0.0.0"), 0);
pj_sockaddr_init(PJ_AF_INET, &rem_addr, pj_strset2(&tmp_st, HTTP_SERVER_ADDR), HTTP_SERVER_PORT);
status = pj_ssl_sock_start_connect(ssock, pool, &local_addr, &rem_addr, sizeof(rem_addr));
if (status == PJ_SUCCESS) {
ssl_on_connect_complete(ssock, PJ_SUCCESS);
} else if (status == PJ_EPENDING) {
status = PJ_SUCCESS;
} else {
goto on_return;
}
/* Wait until everything has been sent/received */
while (state.err == PJ_SUCCESS && !state.done) {
#ifdef PJ_SYMBIAN
pj_symbianos_poll(-1, 1000);
#else
pj_time_val delay = {0, 100};
pj_ioqueue_poll(ioqueue, &delay);
pj_timer_heap_poll(timer, &delay);
#endif
}
if (state.err) {
status = state.err;
goto on_return;
}
PJ_LOG(3, ("", "...Done!"));
PJ_LOG(3, ("", ".....Sent/recv: %d/%d bytes", state.sent, state.recv));
on_return:
if (ssock && !state.err && !state.done)
pj_ssl_sock_close(ssock);
if (ioqueue)
pj_ioqueue_destroy(ioqueue);
if (timer)
pj_timer_heap_destroy(timer);
if (pool)
pj_pool_release(pool);
return status;
}
开发者ID:kaaustubh,项目名称:pjsip,代码行数:89,代码来源:ssl_sock.c
-
六六分期app的软件客服如何联系?不知道吗?加qq群【895510560】即可!标题:六六分期
阅读:19216|2023-10-27
-
今天小编告诉大家如何处理win10系统火狐flash插件总是崩溃的问题,可能很多用户都不知
阅读:9995|2022-11-06
-
今天小编告诉大家如何对win10系统删除桌面回收站图标进行设置,可能很多用户都不知道
阅读:8331|2022-11-06
-
今天小编告诉大家如何对win10系统电脑设置节能降温的设置方法,想必大家都遇到过需要
阅读:8699|2022-11-06
-
我们在使用xp系统的过程中,经常需要对xp系统无线网络安装向导设置进行设置,可能很多
阅读:8643|2022-11-06
-
今天小编告诉大家如何处理win7系统玩cf老是与主机连接不稳定的问题,可能很多用户都不
阅读:9665|2022-11-06
-
电脑对日常生活的重要性小编就不多说了,可是一旦碰到win7系统设置cf烟雾头的问题,很
阅读:8628|2022-11-06
-
我们在日常使用电脑的时候,有的小伙伴们可能在打开应用的时候会遇见提示应用程序无法
阅读:8003|2022-11-06
-
今天小编告诉大家如何对win7系统打开vcf文件进行设置,可能很多用户都不知道怎么对win
阅读:8661|2022-11-06
-
今天小编告诉大家如何对win10系统s4开启USB调试模式进行设置,可能很多用户都不知道怎
阅读:7537|2022-11-06
|
请发表评论