当前位置: 首页>>代码示例>>C++>>正文


C++ pj_thread_create函数代码示例

本文整理汇总了C++中pj_thread_create函数的典型用法代码示例。如果您正苦于以下问题:C++ pj_thread_create函数的具体用法?C++ pj_thread_create怎么用?C++ pj_thread_create使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了pj_thread_create函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: init_stack

static pj_status_t init_stack()
{
    pj_sockaddr addr;
    pjsip_inv_callback inv_cb;
    pj_status_t status;

    pj_log_set_level(5);

    status = pj_init();
    CHECK_STATUS();

    pj_log_set_level(3);

    status = pjlib_util_init();
    CHECK_STATUS();

    pj_caching_pool_init(&app.cp, NULL, 0);
    app.pool = pj_pool_create( &app.cp.factory, "sipecho", 512, 512, 0);

    status = pjsip_endpt_create(&app.cp.factory, NULL, &app.sip_endpt);
    CHECK_STATUS();

    pj_log_set_level(4);
    pj_sockaddr_init(AF, &addr, NULL, (pj_uint16_t)SIP_PORT);
    if (AF == pj_AF_INET()) {
	status = pjsip_udp_transport_start( app.sip_endpt, &addr.ipv4, NULL,
					    1, NULL);
    } else if (AF == pj_AF_INET6()) {
	status = pjsip_udp_transport_start6(app.sip_endpt, &addr.ipv6, NULL,
					    1, NULL);
    } else {
	status = PJ_EAFNOTSUP;
    }

    pj_log_set_level(3);
    CHECK_STATUS();

    status = pjsip_tsx_layer_init_module(app.sip_endpt) ||
	     pjsip_ua_init_module( app.sip_endpt, NULL );
    CHECK_STATUS();

    pj_bzero(&inv_cb, sizeof(inv_cb));
    inv_cb.on_state_changed = &call_on_state_changed;
    inv_cb.on_new_session = &call_on_forked;
    inv_cb.on_media_update = &call_on_media_update;
    inv_cb.on_rx_offer = &call_on_rx_offer;

    status = pjsip_inv_usage_init(app.sip_endpt, &inv_cb) ||
	     pjsip_100rel_init_module(app.sip_endpt) ||
	     pjsip_endpt_register_module( app.sip_endpt, &mod_sipecho) ||
	     pjsip_endpt_register_module( app.sip_endpt, &msg_logger) ||
	     //pjmedia_endpt_create(&app.cp.factory,
		//		  pjsip_endpt_get_ioqueue(app.sip_endpt),
		//		  0, &app.med_endpt) ||
             pj_thread_create(app.pool, "sipecho", &worker_proc, NULL, 0, 0,
                              &app.worker_thread);
    CHECK_STATUS();

    return PJ_SUCCESS;
}
开发者ID:xhook,项目名称:asterisk-v11,代码行数:60,代码来源:sipecho.c

示例2: job_queue_create

static pj_status_t job_queue_create(pj_pool_t *pool, job_queue **pjq)
{
    unsigned i;
    pj_status_t status;
    
    job_queue *jq = PJ_POOL_ZALLOC_T(pool, job_queue);
    jq->size = MAX_JOBS;
    status = pj_sem_create(pool, "thread_sem", 0, jq->size + 1, &jq->sem);
    if (status != PJ_SUCCESS)
        goto on_error;

    for (i = 0; i < jq->size; i++) {
        status = pj_sem_create(pool, "job_sem", 0, 1, &jq->job_sem[i]);
        if (status != PJ_SUCCESS)
            goto on_error;
    }
    
    status = pj_mutex_create_recursive(pool, "job_mutex", &jq->mutex);
    if (status != PJ_SUCCESS)
        goto on_error;
    
    status = pj_thread_create(pool, "job_th", job_thread, jq, 0, 0,
                              &jq->thread);
    if (status != PJ_SUCCESS)
        goto on_error;
    
    *pjq = jq;
    return PJ_SUCCESS;
    
on_error:
    job_queue_destroy(jq);
    return status;
}
开发者ID:CloudStyleStudio,项目名称:csip,代码行数:33,代码来源:android_opengl.c

示例3: m_global

pjs_frame_processor::pjs_frame_processor(pjs_global& global,
		unsigned capacity, unsigned samples_per_frame) :
		m_global(global), m_samples_per_frame(samples_per_frame)
{
	m_started = false;
	m_thread = NULL;
	m_ready = false;
	m_exit = false;
	m_pool = pj_pool_create(m_global.get_pool_factory(), "pjs_frame_processor",
			128, 128, NULL);
	m_lock = new PPJ_SemaphoreLock(m_pool, NULL, 1, 1);
	pj_status_t status = pjmedia_circ_buf_create(m_pool, capacity, &m_buffer);
	if (status == PJ_SUCCESS)
	{
		status = pj_thread_create(m_pool, "frame processor thread",
				(pj_thread_proc*) &s_thread_proc, this, PJ_THREAD_DEFAULT_STACK_SIZE, PJ_THREAD_SUSPENDED,
				&m_thread);

		if (status != PJ_SUCCESS)
			m_thread = NULL;
		else
			m_ready = true;
	}
	else
		m_buffer = NULL;
}
开发者ID:ddv2005,项目名称:intercom,代码行数:26,代码来源:pjs_frame_processor.cpp

示例4: PJ_DEF

/*
 * Start the clock. 
 */
PJ_DEF(pj_status_t) pjmedia_clock_start(pjmedia_clock *clock)
{
    pj_timestamp now;
    pj_status_t status;

    PJ_ASSERT_RETURN(clock != NULL, PJ_EINVAL);

    if (clock->running)
	return PJ_SUCCESS;

    status = pj_get_timestamp(&now);
    if (status != PJ_SUCCESS)
	return status;

    clock->next_tick.u64 = now.u64 + clock->interval.u64;
    clock->running = PJ_TRUE;
    clock->quitting = PJ_FALSE;

    if ((clock->options & PJMEDIA_CLOCK_NO_ASYNC) == 0 && !clock->thread) {
	status = pj_thread_create(clock->pool, "clock", &clock_thread, clock,
				  0, 0, &clock->thread);
	if (status != PJ_SUCCESS) {
	    pj_lock_destroy(clock->lock);
	    return status;
	}
    }

    return PJ_SUCCESS;
}
开发者ID:conght,项目名称:BLM-Lib,代码行数:32,代码来源:clock_thread.c

示例5: udp_echo_srv_ioqueue

int udp_echo_srv_ioqueue(void)
{
    pj_pool_t *pool;
    pj_sock_t sock;
    pj_ioqueue_t *ioqueue;
    pj_ioqueue_callback callback;
    int i;
    pj_thread_t *thread[ECHO_SERVER_MAX_THREADS];
    pj_status_t rc;

    pj_bzero(&callback, sizeof(callback));
    callback.on_read_complete = &on_read_complete;
    callback.on_write_complete = &on_write_complete;

    pool = pj_pool_create(mem, NULL, 4000, 4000, NULL);
    if (!pool)
        return -10;

    rc = pj_ioqueue_create(pool, 2, &ioqueue);
    if (rc != PJ_SUCCESS) {
        app_perror("...pj_ioqueue_create error", rc);
        return -20;
    }

    rc = app_socket(pj_AF_INET(), pj_SOCK_DGRAM(), 0, 
                    ECHO_SERVER_START_PORT, &sock);
    if (rc != PJ_SUCCESS) {
        app_perror("...app_socket error", rc);
        return -30;
    }

    rc = pj_ioqueue_register_sock(pool, ioqueue, sock, NULL,
                                  &callback, &key);
    if (rc != PJ_SUCCESS) {
        app_perror("...error registering socket", rc);
        return -40;
    }

    rc = pj_atomic_create(pool, 0, &total_bytes);
    if (rc != PJ_SUCCESS) {
        app_perror("...error creating atomic variable", rc);
        return -45;
    }

    for (i=0; i<ECHO_SERVER_MAX_THREADS; ++i) {
        rc = pj_thread_create(pool, NULL, &worker_thread, ioqueue,
                              PJ_THREAD_DEFAULT_STACK_SIZE, 0,
                              &thread[i]);
        if (rc != PJ_SUCCESS) {
            app_perror("...create thread error", rc);
            return -50;
        }
    }

    echo_srv_common_loop(total_bytes);

    return 0;
}
开发者ID:AbhaySingh,项目名称:pjproject,代码行数:58,代码来源:udp_echo_srv_ioqueue.c

示例6: create

 //
 // Create a thread.
 //
 static pj_status_t create( Pj_Pool *pool, pj_thread_t **thread,
                            pj_thread_proc *proc, void *arg,
                            unsigned flags = 0,
                            const char *name = NULL,
                            pj_size_t stack_size = 0 )
 {
     return pj_thread_create(pool->pool_(), name, proc, arg, stack_size,
                             flags, thread);
 }
开发者ID:0x0B501E7E,项目名称:pjproject,代码行数:12,代码来源:os.hpp

示例7: strm_start

/* API: start stream. */
static pj_status_t strm_start(pjmedia_aud_stream *s)
{
	struct android_aud_stream *stream = (struct android_aud_stream*)s;


	PJ_LOG(4,(THIS_FILE, "Starting %s stream..", stream->name.ptr));
	stream->quit_flag = 0;

	JNIEnv *jni_env = 0;
	ATTACH_JVM(jni_env);

	pj_status_t status;

	//Start threads
	if(stream->record){

		status = pj_thread_create(stream->pool, "android_recorder", &AndroidRecorderCallback, stream, 0, 0,  &stream->rec_thread);
		if (status != PJ_SUCCESS) {
			goto on_error;
		}
//		pj_sem_wait(stream->audio_launch_sem);
	}

	if(stream->track){
		status = pj_thread_create(stream->pool, "android_track", &AndroidTrackCallback, stream, 0, 0,  &stream->play_thread);
		if (status != PJ_SUCCESS) {
			goto on_error;
		}
//		pj_sem_wait(stream->audio_launch_sem);
	}

	PJ_LOG(4,(THIS_FILE, "Starting done"));

	status = PJ_SUCCESS;

on_error:
	DETACH_JVM(jni_env);
	if(status != PJ_SUCCESS){
		strm_destroy(&stream->base);
	}
	return status;
}
开发者ID:RockHardJim,项目名称:idphone,代码行数:43,代码来源:android_jni_dev.cpp

示例8: PJ_DEF

/*
 * Create media clock.
 */
PJ_DEF(pj_status_t) pjmedia_clock_create( pj_pool_t *pool,
					  unsigned clock_rate,
					  unsigned channel_count,
					  unsigned samples_per_frame,
					  unsigned options,
					  pjmedia_clock_callback *cb,
					  void *user_data,
					  pjmedia_clock **p_clock)
{
    pjmedia_clock *clock;
    pj_status_t status;

    PJ_ASSERT_RETURN(pool && clock_rate && samples_per_frame && p_clock,
		     PJ_EINVAL);

    clock = PJ_POOL_ALLOC_T(pool, pjmedia_clock);

    
    status = pj_get_timestamp_freq(&clock->freq);
    if (status != PJ_SUCCESS)
	return status;

    clock->interval.u64 = samples_per_frame * clock->freq.u64 / 
			  channel_count / clock_rate;
    clock->next_tick.u64 = 0;
    clock->timestamp.u64 = 0;
    clock->max_jump = MAX_JUMP_MSEC * clock->freq.u64 / 1000;
    clock->timestamp_inc = samples_per_frame / channel_count;
    clock->options = options;
    clock->cb = cb;
    clock->user_data = user_data;
    clock->thread = NULL;
    clock->running = PJ_FALSE;
    clock->quitting = PJ_FALSE;
    
    /* I don't think we need a mutex, so we'll use null. */
    status = pj_lock_create_null_mutex(pool, "clock", &clock->lock);
    if (status != PJ_SUCCESS)
	return status;

    if ((clock->options & PJMEDIA_CLOCK_NO_ASYNC) == 0) {
	status = pj_thread_create(pool, "clock", &clock_thread, clock,
				  0, 0, &clock->thread);
	if (status != PJ_SUCCESS) {
	    pj_lock_destroy(clock->lock);
	    return status;
	}
    }


    *p_clock = clock;

    return PJ_SUCCESS;
}
开发者ID:Agostin,项目名称:csipsimple,代码行数:57,代码来源:clock_thread.c

示例9: start_stack

pj_status_t start_stack()
{
  pj_status_t status = PJ_SUCCESS;

  quit_flag = PJ_FALSE;

  // Create worker threads first as they take work from the PJSIP threads so
  // need to be ready.
  for (size_t ii = 0; ii < worker_threads.size(); ++ii)
  {
    pj_thread_t* thread;
    status = pj_thread_create(stack_data.pool, "worker", &worker_thread,
                              NULL, 0, 0, &thread);
    if (status != PJ_SUCCESS)
    {
      LOG_ERROR("Error creating worker thread, %s",
                PJUtils::pj_status_to_string(status).c_str());
      return 1;
    }
    worker_threads[ii] = thread;
  }

  // Now create the PJSIP threads.
  for (size_t ii = 0; ii < pjsip_threads.size(); ++ii)
  {
    pj_thread_t* thread;
    status = pj_thread_create(stack_data.pool, "pjsip", &pjsip_thread,
                              NULL, 0, 0, &thread);
    if (status != PJ_SUCCESS)
    {
      LOG_ERROR("Error creating PJSIP thread, %s",
                PJUtils::pj_status_to_string(status).c_str());
      return 1;
    }
    pjsip_threads[ii] = thread;
  }

  return status;
}
开发者ID:gangbanlau,项目名称:sprout,代码行数:39,代码来源:stack.cpp

示例10: PJ_DEF

/*
 * Create media clock.
 */
PJ_DEF(pj_status_t) pjmedia_clock_create( pj_pool_t *pool,
					  unsigned clock_rate,
					  unsigned samples_per_frame,
					  unsigned options,
					  pjmedia_clock_callback *cb,
					  void *user_data,
					  pjmedia_clock **p_clock)
{
    pjmedia_clock *clock;
    pj_status_t status;

    PJ_ASSERT_RETURN(pool && clock_rate && samples_per_frame && p_clock,
		     PJ_EINVAL);

    clock = pj_pool_alloc(pool, sizeof(pjmedia_clock));

    
    status = pj_get_timestamp_freq(&clock->freq);
    if (status != PJ_SUCCESS)
	return status;

    clock->interval.u64 = samples_per_frame * clock->freq.u64 / clock_rate;
    clock->next_tick.u64 = 0;
    clock->timestamp.u64 = 0;
    clock->samples_per_frame = samples_per_frame;
    clock->options = options;
    clock->cb = cb;
    clock->user_data = user_data;
    clock->thread = NULL;
    clock->running = PJ_FALSE;
    clock->quitting = PJ_FALSE;
    
    /* I don't think we need a mutex, so we'll use null. */
    status = pj_lock_create_null_mutex(pool, "clock", &clock->lock);
    if (status != PJ_SUCCESS)
	return status;

    status = pj_thread_create(pool, "clock", &clock_thread, clock,
			      0, 0, &clock->thread);
    if (status != PJ_SUCCESS) {
	pj_lock_destroy(clock->lock);
	return status;
    }


    *p_clock = clock;

    return PJ_SUCCESS;
}
开发者ID:svn2github,项目名称:pjproject,代码行数:52,代码来源:clock_thread.c

示例11: alsa_stream_start

/* API: start stream */
static pj_status_t alsa_stream_start (pjmedia_aud_stream *s)
{
    struct alsa_stream *stream = (struct alsa_stream*)s;
    pj_status_t status = PJ_SUCCESS;

    stream->quit = 0;
    if (stream->param.dir & PJMEDIA_DIR_PLAYBACK) {
	status = pj_thread_create (stream->pool,
				   "alsasound_playback",
				   pb_thread_func,
				   stream,
				   0, //ZERO,
				   0,
				   &stream->pb_thread);
	if (status != PJ_SUCCESS)
	    return status;
    }

    if (stream->param.dir & PJMEDIA_DIR_CAPTURE) {
	status = pj_thread_create (stream->pool,
				   "alsasound_playback",
				   ca_thread_func,
				   stream,
				   0, //ZERO,
				   0,
				   &stream->ca_thread);
	if (status != PJ_SUCCESS) {
	    stream->quit = PJ_TRUE;
	    pj_thread_join(stream->pb_thread);
	    pj_thread_destroy(stream->pb_thread);
	    stream->pb_thread = NULL;
	}
    }

    return status;
}
开发者ID:elimelec,项目名称:pjproject,代码行数:37,代码来源:alsa_dev.c

示例12: echo_srv_sync

int echo_srv_sync(void)
{
    pj_pool_t *pool;
    pj_sock_t sock;
    pj_thread_t *thread[ECHO_SERVER_MAX_THREADS];
    pj_status_t rc;
    int i;

    pool = pj_pool_create(mem, NULL, 4000, 4000, NULL);
    if (!pool)
        return -5;

    rc = pj_atomic_create(pool, 0, &total_bytes);
    if (rc != PJ_SUCCESS) {
        app_perror("...unable to create atomic_var", rc);
        return -6;
    }

    rc = app_socket(pj_AF_INET(), pj_SOCK_DGRAM(),0, ECHO_SERVER_START_PORT, &sock);
    if (rc != PJ_SUCCESS) {
        app_perror("...socket error", rc);
        return -10;
    }

    for (i=0; i<ECHO_SERVER_MAX_THREADS; ++i) {
        rc = pj_thread_create(pool, NULL, &worker_thread, (void*)sock,
                              PJ_THREAD_DEFAULT_STACK_SIZE, 0,
                              &thread[i]);
        if (rc != PJ_SUCCESS) {
            app_perror("...unable to create thread", rc);
            return -20;
        }
    }

    PJ_LOG(3,("", "...UDP echo server running with %d threads at port %d",
                  ECHO_SERVER_MAX_THREADS, ECHO_SERVER_START_PORT));
    PJ_LOG(3,("", "...Press Ctrl-C to abort"));

    echo_srv_common_loop(total_bytes);
    return 0;
}
开发者ID:LuLei2013,项目名称:pjproject,代码行数:41,代码来源:udp_echo_srv_sync.c

示例13: PJ_DEF

PJ_DEF(pj_status_t) pjmedia_event_mgr_create(pj_pool_t *pool,
                                             unsigned options,
				             pjmedia_event_mgr **p_mgr)
{
    pjmedia_event_mgr *mgr;
    pj_status_t status;

    mgr = PJ_POOL_ZALLOC_T(pool, pjmedia_event_mgr);
    mgr->pool = pj_pool_create(pool->factory, "evt mgr", 500, 500, NULL);
    pj_list_init(&mgr->esub_list);
    pj_list_init(&mgr->free_esub_list);

    if (!(options & PJMEDIA_EVENT_MGR_NO_THREAD)) {
        status = pj_sem_create(mgr->pool, "ev_sem", 0, MAX_EVENTS + 1,
                               &mgr->sem);
        if (status != PJ_SUCCESS)
            return status;

        status = pj_thread_create(mgr->pool, "ev_thread",
                                  &event_worker_thread,
                                  mgr, 0, 0, &mgr->thread);
        if (status != PJ_SUCCESS) {
            pjmedia_event_mgr_destroy(mgr);
            return status;
        }
    }

    status = pj_mutex_create_recursive(mgr->pool, "ev_mutex", &mgr->mutex);
    if (status != PJ_SUCCESS) {
        pjmedia_event_mgr_destroy(mgr);
        return status;
    }

    if (!event_manager_instance)
	event_manager_instance = mgr;

    if (p_mgr)
	*p_mgr = mgr;

    return PJ_SUCCESS;
}
开发者ID:LuLei2013,项目名称:pjproject,代码行数:41,代码来源:event.c

示例14: start_pjsip_threads

pj_status_t start_pjsip_threads()
{
  pj_status_t status = PJ_SUCCESS;

  for (size_t ii = 0; ii < pjsip_threads.size(); ++ii)
  {
    pj_thread_t* thread;

    status = pj_thread_create(stack_data.pool, "pjsip", &pjsip_thread_func,
                              NULL, 0, 0, &thread);
    if (status != PJ_SUCCESS)
    {
        LOG_ERROR("Error creating PJSIP thread, %s",
                  PJUtils::pj_status_to_string(status).c_str());
        return 1;
    }
    pjsip_threads[ii] = thread;
  }
  
  return PJ_SUCCESS;
}
开发者ID:matt-williams,项目名称:sprout,代码行数:21,代码来源:stack.cpp

示例15: create_connection

void ConnectionPool::init()
{
  // Create an initial set of connections.
  for (int ii = 0; ii < _num_connections; ++ii)
  {
    create_connection(ii);
  }

  if (_recycle_period != 0)
  {
    // Spawn a thread to recycle connections
    pj_status_t status = pj_thread_create(_pool, "recycler",
                                          &recycle_thread,
                                          (void*)this, 0, 0, &_recycler);
    if (status != PJ_SUCCESS)
    {
      TRC_ERROR("Error creating recycler thread, %s",
                PJUtils::pj_status_to_string(status).c_str());
    }
  }

  TRC_DEBUG("Started %d connections to %.*s:%d", _num_connections, _target.host.slen, _target.host.ptr, _target.port);
}
开发者ID:AiprNick,项目名称:sprout,代码行数:23,代码来源:connection_pool.cpp


注:本文中的pj_thread_create函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。