本文整理汇总了C++中pjmedia_endpt_create_pool函数的典型用法代码示例。如果您正苦于以下问题:C++ pjmedia_endpt_create_pool函数的具体用法?C++ pjmedia_endpt_create_pool怎么用?C++ pjmedia_endpt_create_pool使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了pjmedia_endpt_create_pool函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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 = pjsip_endpt_get_timer_heap(pjsua_var.endpt);
#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;
}
示例2: factory_alloc_codec
/*
* Allocate a new Opus codec instance.
*/
static pj_status_t factory_alloc_codec( pjmedia_codec_factory *factory,
const pjmedia_codec_info *ci,
pjmedia_codec **p_codec )
{
pjmedia_codec *codec;
pj_pool_t *pool;
pj_status_t status;
struct opus_data *opus_data;
struct opus_codec_factory *f = (struct opus_codec_factory*) factory;
TRACE_((THIS_FILE, "%s:%d: - TRACE", __FUNCTION__, __LINE__));
pool = pjmedia_endpt_create_pool(f->endpt, "opus", 512, 512);
if (!pool) return PJ_ENOMEM;
opus_data = PJ_POOL_ZALLOC_T(pool, struct opus_data);
codec = PJ_POOL_ZALLOC_T(pool, pjmedia_codec);
status = pj_mutex_create_simple (pool, "opus_mutex", &opus_data->mutex);
if (status != PJ_SUCCESS) {
pj_pool_release(pool);
return status;
}
pj_memcpy(&opus_data->cfg, &opus_cfg, sizeof(pjmedia_codec_opus_config));
opus_data->pool = pool;
codec->op = &opus_op;
codec->factory = factory;
codec->codec_data = opus_data;
*p_codec = codec;
return PJ_SUCCESS;
}
示例3: PJ_DEF
/*
* Create the adapter.
*/
PJ_DEF(pj_status_t) pjmedia_tp_adapter_create( pjmedia_endpt *endpt,
const char *name,
pjmedia_transport *transport,
pj_bool_t del_base,
pjmedia_transport **p_tp)
{
pj_pool_t *pool;
struct tp_adapter *adapter;
if (name == NULL)
name = "tpad%p";
/* Create the pool and initialize the adapter structure */
pool = pjmedia_endpt_create_pool(endpt, name, 512, 512);
adapter = PJ_POOL_ZALLOC_T(pool, struct tp_adapter);
adapter->pool = pool;
pj_ansi_strncpy(adapter->base.name, pool->obj_name,
sizeof(adapter->base.name));
adapter->base.type = (pjmedia_transport_type)
(PJMEDIA_TRANSPORT_TYPE_USER + 1);
adapter->base.op = &tp_adapter_op;
/* Save the transport as the slave transport */
adapter->slave_tp = transport;
adapter->del_base = del_base;
/* Done */
*p_tp = &adapter->base;
return PJ_SUCCESS;
}
示例4: ilbc_alloc_codec
/*
* Allocate a new iLBC codec instance.
*/
static pj_status_t ilbc_alloc_codec(pjmedia_codec_factory *factory,
const pjmedia_codec_info *id,
pjmedia_codec **p_codec)
{
pj_pool_t *pool;
struct ilbc_codec *codec;
PJ_ASSERT_RETURN(factory && id && p_codec, PJ_EINVAL);
PJ_ASSERT_RETURN(factory == &ilbc_factory.base, PJ_EINVAL);
pool = pjmedia_endpt_create_pool(ilbc_factory.endpt, "iLBC%p",
2000, 2000);
PJ_ASSERT_RETURN(pool != NULL, PJ_ENOMEM);
codec = PJ_POOL_ZALLOC_T(pool, struct ilbc_codec);
codec->base.op = &ilbc_op;
codec->base.factory = factory;
codec->pool = pool;
pj_ansi_snprintf(codec->obj_name, sizeof(codec->obj_name),
"ilbc%p", codec);
*p_codec = &codec->base;
return PJ_SUCCESS;
}
示例5: silk_alloc_codec
/*
* Allocate a new SILK codec instance.
*/
static pj_status_t silk_alloc_codec(pjmedia_codec_factory *factory,
const pjmedia_codec_info *id,
pjmedia_codec **p_codec)
{
pj_pool_t *pool;
pjmedia_codec *codec;
silk_private *silk;
PJ_ASSERT_RETURN(factory && id && p_codec, PJ_EINVAL);
PJ_ASSERT_RETURN(factory == &silk_factory.base, PJ_EINVAL);
/* Create pool for codec instance */
pool = pjmedia_endpt_create_pool(silk_factory.endpt, "silk", 512, 512);
/* Allocate codec */
codec = PJ_POOL_ZALLOC_T(pool, pjmedia_codec);
codec->op = &silk_op;
codec->factory = factory;
codec->codec_data = PJ_POOL_ZALLOC_T(pool, silk_private);
silk = (silk_private*) codec->codec_data;
silk->pool = pool;
silk->enc_ready = PJ_FALSE;
silk->dec_ready = PJ_FALSE;
silk->mode = silk_get_mode_from_clock_rate(id->clock_rate);
*p_codec = codec;
return PJ_SUCCESS;
}
示例6: PJ_DEF
/*
* Initialize and register AMR codec factory to pjmedia endpoint.
*/
PJ_DEF(pj_status_t) pjmedia_codec_opencore_amr_init( pjmedia_endpt *endpt,
unsigned options)
{
pjmedia_codec_mgr *codec_mgr;
pj_str_t codec_name;
pj_status_t status;
if (amr_codec_factory.pool != NULL)
return PJ_SUCCESS;
/* Create AMR codec factory. */
amr_codec_factory.base.op = &amr_factory_op;
amr_codec_factory.base.factory_data = NULL;
amr_codec_factory.endpt = endpt;
#ifdef USE_AMRNB
amr_codec_factory.init[IDX_AMR_NB] = ((options & PJMEDIA_AMR_NO_NB) == 0);
#else
amr_codec_factory.init[IDX_AMR_NB] = PJ_FALSE;
#endif
#ifdef USE_AMRWB
amr_codec_factory.init[IDX_AMR_WB] = ((options & PJMEDIA_AMR_NO_WB) == 0);
#else
amr_codec_factory.init[IDX_AMR_WB] = PJ_FALSE;
#endif
amr_codec_factory.pool = pjmedia_endpt_create_pool(endpt, "amr", 1000,
1000);
if (!amr_codec_factory.pool)
return PJ_ENOMEM;
/* Get the codec manager. */
codec_mgr = pjmedia_endpt_get_codec_mgr(endpt);
if (!codec_mgr) {
status = PJ_EINVALIDOP;
goto on_error;
}
/* Register format match callback. */
pj_cstr(&codec_name, "AMR");
status = pjmedia_sdp_neg_register_fmt_match_cb(
&codec_name,
&pjmedia_codec_amr_match_sdp);
if (status != PJ_SUCCESS)
goto on_error;
/* Register codec factory to endpoint. */
status = pjmedia_codec_mgr_register_factory(codec_mgr,
&amr_codec_factory.base);
if (status != PJ_SUCCESS)
goto on_error;
/* Done. */
return PJ_SUCCESS;
on_error:
pj_pool_release(amr_codec_factory.pool);
amr_codec_factory.pool = NULL;
return status;
}
示例7: PJ_DEF
PJ_DEF(pj_status_t) pjmedia_codec_l16_init(pjmedia_endpt *endpt,
unsigned options)
{
pjmedia_codec_mgr *codec_mgr;
pj_status_t status;
PJ_UNUSED_ARG(options);
if (l16_factory.endpt != NULL) {
/* Already initialized. */
return PJ_SUCCESS;
}
/* Init factory */
l16_factory.base.op = &l16_factory_op;
l16_factory.base.factory_data = NULL;
l16_factory.endpt = endpt;
/* Create pool */
l16_factory.pool = pjmedia_endpt_create_pool(endpt, "l16", 4000, 4000);
if (!l16_factory.pool)
return PJ_ENOMEM;
/* Create mutex. */
status = pj_mutex_create_simple(l16_factory.pool, "l16",
&l16_factory.mutex);
if (status != PJ_SUCCESS)
goto on_error;
/* Get the codec manager. */
codec_mgr = pjmedia_endpt_get_codec_mgr(endpt);
if (!codec_mgr) {
return PJ_EINVALIDOP;
}
/* Register codec factory to endpoint. */
status = pjmedia_codec_mgr_register_factory(codec_mgr,
&l16_factory.base);
if (status != PJ_SUCCESS)
return status;
return PJ_SUCCESS;
on_error:
if (l16_factory.mutex) {
pj_mutex_destroy(l16_factory.mutex);
l16_factory.mutex = NULL;
}
if (l16_factory.pool) {
pj_pool_release(l16_factory.pool);
l16_factory.pool = NULL;
}
return status;
}
示例8: l16_alloc_codec
static pj_status_t l16_alloc_codec( pjmedia_codec_factory *factory,
const pjmedia_codec_info *id,
pjmedia_codec **p_codec)
{
pjmedia_codec *codec = NULL;
struct l16_data *data;
unsigned ptime;
pj_pool_t *pool;
pj_status_t status;
PJ_ASSERT_RETURN(factory==&l16_factory.base, PJ_EINVAL);
/* Lock mutex. */
pj_mutex_lock(l16_factory.mutex);
pool = pjmedia_endpt_create_pool(l16_factory.endpt, "l16", 4000, 4000);
codec = PJ_POOL_ZALLOC_T(pool, pjmedia_codec);
codec->codec_data = pj_pool_alloc(pool, sizeof(struct l16_data));
codec->factory = factory;
codec->op = &l16_op;
/* Init private data */
ptime = GET_PTIME(id->clock_rate);
data = (struct l16_data*) codec->codec_data;
data->frame_size = ptime * id->clock_rate * id->channel_cnt * 2 / 1000;
data->clock_rate = id->clock_rate;
data->pool = pool;
#if !PLC_DISABLED
/* Create PLC */
status = pjmedia_plc_create(pool, id->clock_rate,
data->frame_size >> 1, 0,
&data->plc);
if (status != PJ_SUCCESS) {
pj_mutex_unlock(l16_factory.mutex);
return status;
}
#endif
/* Create silence detector */
status = pjmedia_silence_det_create(pool, id->clock_rate,
data->frame_size >> 1,
&data->vad);
if (status != PJ_SUCCESS) {
pj_mutex_unlock(l16_factory.mutex);
return status;
}
*p_codec = codec;
/* Unlock mutex. */
pj_mutex_unlock(l16_factory.mutex);
return PJ_SUCCESS;
}
示例9: PJ_DEF
PJ_DEF(pj_status_t) pjmedia_codec_opus_init(pjmedia_endpt *endpt) {
pjmedia_codec_mgr *codec_mgr;
pj_status_t status;
if (opus_factory.endpt != NULL) {
/* Already initialized. */
return PJ_SUCCESS;
}
/* Init factory */
opus_factory.base.op = &opus_factory_op;
opus_factory.base.factory_data = NULL;
opus_factory.endpt = endpt;
if (opus_factory.internal_clock_rate == 0) {
opus_factory.internal_clock_rate = 48000;
}
/* Create pool */
opus_factory.pool =
pjmedia_endpt_create_pool(endpt, "opus codecs", 4000, 4000);
if (!opus_factory.pool) return PJ_ENOMEM;
/* Init list */
pj_list_init(&opus_factory.codec_list);
/* Create mutex. */
status = pj_mutex_create_simple(opus_factory.pool, "opus codecs",
&opus_factory.mutex);
if (status != PJ_SUCCESS) goto on_error;
PJ_LOG(5, (THIS_FILE, "Init opus"));
/* Get the codec manager. */
codec_mgr = pjmedia_endpt_get_codec_mgr(endpt);
if (!codec_mgr) {
return PJ_EINVALIDOP;
}
PJ_LOG(5, (THIS_FILE, "Init opus > DONE"));
/* Register codec factory to endpoint. */
status = pjmedia_codec_mgr_register_factory(codec_mgr, &opus_factory.base);
if (status != PJ_SUCCESS) return status;
return PJ_SUCCESS;
on_error:
if (opus_factory.mutex) {
pj_mutex_destroy(opus_factory.mutex);
opus_factory.mutex = NULL;
}
if (opus_factory.pool) {
pj_pool_release(opus_factory.pool);
opus_factory.pool = NULL;
}
return status;
}
示例10: 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;
}
示例11: 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;
}
示例12: PJ_DEF
/*
* Initialize and register AMR-NB codec factory to pjmedia endpoint.
*/
PJ_DEF(pj_status_t) pjmedia_codec_opencore_amrnb_init( pjmedia_endpt *endpt )
{
pjmedia_codec_mgr *codec_mgr;
pj_status_t status;
pj_str_t codec_name;
if (amr_codec_factory.pool != NULL)
return PJ_SUCCESS;
/* Create AMR-NB codec factory. */
amr_codec_factory.base.op = &amr_factory_op;
amr_codec_factory.base.factory_data = NULL;
amr_codec_factory.endpt = endpt;
amr_codec_factory.pool = pjmedia_endpt_create_pool(endpt, "amrnb", 1000,
1000);
if (!amr_codec_factory.pool)
return PJ_ENOMEM;
/* Get the codec manager. */
codec_mgr = pjmedia_endpt_get_codec_mgr(endpt);
if (!codec_mgr) {
status = PJ_EINVALIDOP;
goto on_error;
}
/* Register format match callback. */
pj_cstr(&codec_name, "AMR");
status = pjmedia_sdp_neg_register_fmt_match_cb( &codec_name,
&pjmedia_codec_amr_match_sdp);
if (status != PJ_SUCCESS){
goto on_error;
}
/* Register codec factory to endpoint. */
status = pjmedia_codec_mgr_register_factory(codec_mgr,
&amr_codec_factory.base);
if (status != PJ_SUCCESS)
goto on_error;
/* Done. */
return PJ_SUCCESS;
on_error:
pj_pool_release(amr_codec_factory.pool);
amr_codec_factory.pool = NULL;
return status;
}
示例13: PJ_DEF
/*
* Initialize and register Opus codec factory to pjmedia endpoint.
*/
PJ_DEF(pj_status_t) pjmedia_codec_opus_init( pjmedia_endpt *endpt )
{
pj_status_t status;
pjmedia_codec_mgr *codec_mgr;
PJ_ASSERT_RETURN(endpt, PJ_EINVAL);
if (opus_codec_factory.pool != NULL)
return PJ_SUCCESS;
/* Create the Opus codec factory */
opus_codec_factory.base.op = &opus_factory_op;
opus_codec_factory.base.factory_data = &opus_codec_factory;
opus_codec_factory.endpt = endpt;
opus_codec_factory.pool = pjmedia_endpt_create_pool(endpt, "opus-factory",
1024, 1024);
if (!opus_codec_factory.pool) {
PJ_LOG(2, (THIS_FILE, "Unable to create memory pool for Opus codec"));
return PJ_ENOMEM;
}
/* Get the codec manager */
codec_mgr = pjmedia_endpt_get_codec_mgr(endpt);
if (!codec_mgr) {
PJ_LOG(2, (THIS_FILE, "Unable to get the codec manager"));
status = PJ_EINVALIDOP;
goto on_codec_factory_error;
}
/* Register the codec factory */
status = pjmedia_codec_mgr_register_factory (codec_mgr,
&opus_codec_factory.base);
if (status != PJ_SUCCESS) {
PJ_LOG(2, (THIS_FILE, "Unable to register the codec factory"));
goto on_codec_factory_error;
}
return PJ_SUCCESS;
on_codec_factory_error:
pj_pool_release(opus_codec_factory.pool);
opus_codec_factory.pool = NULL;
return status;
}
示例14: g726_alloc_codec
/*
* Allocate a new G726 codec instance.
*/
static pj_status_t g726_alloc_codec( pjmedia_codec_factory *factory,
const pjmedia_codec_info *id,
pjmedia_codec **p_codec)
{
pj_pool_t *pool;
pjmedia_codec *codec;
struct g726_private *priv;
pj_status_t status;
PJ_ASSERT_RETURN(factory && id && p_codec, PJ_EINVAL);
PJ_ASSERT_RETURN(factory == &g726_codec_factory.base, PJ_EINVAL);
pool = pjmedia_endpt_create_pool(g726_codec_factory.endpt, "g726-inst", 512, 512);
codec = PJ_POOL_ZALLOC_T(pool, pjmedia_codec);
PJ_ASSERT_RETURN(codec != NULL, PJ_ENOMEM);
codec->op = &g726_op;
codec->factory = factory;
priv = PJ_POOL_ZALLOC_T(pool, struct g726_private);
priv->pool = pool;
codec->codec_data = priv;
#if USE_PJMEDIA_PLC
/* Create PLC */
status = pjmedia_plc_create(pool, SAMPLE_RATE, SAMPLES_PER_FRAME, 0, &priv->plc);
if (status != PJ_SUCCESS) {
return status;
}
#else
PJ_UNUSED_ARG(status);
#endif
/* Create VAD */
status = pjmedia_silence_det_create(pool, SAMPLE_RATE,
SAMPLES_PER_FRAME, &priv->vad);
if (status != PJ_SUCCESS) {
return status;
}
*p_codec = codec;
return PJ_SUCCESS;
}
示例15: amr_alloc_codec
/*
* Allocate a new AMR-NB codec instance.
*/
static pj_status_t amr_alloc_codec( pjmedia_codec_factory *factory,
const pjmedia_codec_info *id,
pjmedia_codec **p_codec)
{
pj_pool_t *pool;
pjmedia_codec *codec;
struct amr_data *amr_data;
pj_status_t status = PJ_SUCCESS;
PJ_ASSERT_RETURN(factory && id && p_codec, PJ_EINVAL);
PJ_ASSERT_RETURN(factory == &amr_codec_factory.base, PJ_EINVAL);
pool = pjmedia_endpt_create_pool(amr_codec_factory.endpt, "amrnb-inst",
512, 512);
codec = PJ_POOL_ZALLOC_T(pool, pjmedia_codec);
PJ_ASSERT_RETURN(codec != NULL, PJ_ENOMEM);
codec->op = &amr_op;
codec->factory = factory;
amr_data = PJ_POOL_ZALLOC_T(pool, struct amr_data);
codec->codec_data = amr_data;
amr_data->pool = pool;
#if USE_PJMEDIA_PLC
/* Create PLC */
status = pjmedia_plc_create(pool, 8000, 160, 0, &amr_data->plc);
if (status != PJ_SUCCESS) {
return status;
}
#else
PJ_UNUSED_ARG(status);
#endif
status = dlsym_stagefright(amr_data);
if(status != PJ_SUCCESS){
return status;
}
*p_codec = codec;
return PJ_SUCCESS;
}