• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ pjmedia_endpt_get_codec_mgr函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: PJ_DEF

/*
 * Unregister G722 codec factory from pjmedia endpoint and deinitialize
 * the G722 codec library.
 */
PJ_DEF(pj_status_t) pjmedia_codec_g722_deinit(void)
{
    pjmedia_codec_mgr *codec_mgr;
    pj_status_t status;

    if (g722_codec_factory.pool == NULL)
	return PJ_SUCCESS;

    /* Get the codec manager. */
    codec_mgr = pjmedia_endpt_get_codec_mgr(g722_codec_factory.endpt);
    if (!codec_mgr) {
	pj_pool_release(g722_codec_factory.pool);
	g722_codec_factory.pool = NULL;
	return PJ_EINVALIDOP;
    }

    /* Unregister G722 codec factory. */
    status = pjmedia_codec_mgr_unregister_factory(codec_mgr,
						  &g722_codec_factory.base);
    
    /* Destroy mutex. */
    pj_mutex_destroy(g722_codec_factory.mutex);

    /* Destroy pool. */
    pj_pool_release(g722_codec_factory.pool);
    g722_codec_factory.pool = NULL;
    
    TRACE_((THIS_FILE, "G722 codec factory shutdown"));
    return status;
}
开发者ID:AmoebaLabs,项目名称:pjsip,代码行数:34,代码来源:g722.c


示例2: pj_mutex_lock

 */ PJ_DEF(pj_status_t) pjmedia_codec_opus_deinit(void) {
  pjmedia_codec_mgr *codec_mgr;
  pj_status_t status;

  if (opus_factory.endpt == NULL) {
    /* Not registered. */
    return PJ_SUCCESS;
  }

  /* Lock mutex. */
  pj_mutex_lock(opus_factory.mutex);

  /* Get the codec manager. */
  codec_mgr = pjmedia_endpt_get_codec_mgr(opus_factory.endpt);
  if (!codec_mgr) {
    opus_factory.endpt = NULL;
    pj_mutex_unlock(opus_factory.mutex);
    return PJ_EINVALIDOP;
  }

  /* Unregister opus codec factory. */
  status = pjmedia_codec_mgr_unregister_factory(codec_mgr, &opus_factory.base);
  opus_factory.endpt = NULL;

  /* Destroy mutex. */
  pj_mutex_destroy(opus_factory.mutex);
  opus_factory.mutex = NULL;

  /* Release pool. */
  pj_pool_release(opus_factory.pool);
  opus_factory.pool = NULL;

  return status;
}
开发者ID:AntonioLebara,项目名称:ios-pjsip,代码行数:34,代码来源:opus.c


示例3: cleanup

static void cleanup()
{
    if (app.srtp) pjmedia_transport_close(app.srtp);
    if (app.wav) {
        pj_ssize_t pos = pjmedia_wav_writer_port_get_pos(app.wav);
        if (pos >= 0) {
            unsigned msec;
            msec = (unsigned)pos / 2 * 1000 / PJMEDIA_PIA_SRATE(&app.wav->info);
            printf("Written: %dm:%02ds.%03d\n",
                    msec / 1000 / 60,
                    (msec / 1000) % 60,
                    msec % 1000);
        }
	pjmedia_port_destroy(app.wav);
    }
    if (app.pcap) pj_pcap_close(app.pcap);
    if (app.codec) {
	pjmedia_codec_mgr *cmgr;
	pjmedia_codec_close(app.codec);
	cmgr = pjmedia_endpt_get_codec_mgr(app.mept);
	pjmedia_codec_mgr_dealloc_codec(cmgr, app.codec);
    }
    if (app.aud_strm) {
	pjmedia_aud_stream_stop(app.aud_strm);
	pjmedia_aud_stream_destroy(app.aud_strm);
    }
    if (app.mept) pjmedia_endpt_destroy(app.mept);
    if (app.pool) pj_pool_release(app.pool);
    pj_caching_pool_destroy(&app.cp);
    pj_shutdown();
}
开发者ID:iamroger,项目名称:voip,代码行数:31,代码来源:pcaputil.c


示例4: PJ_DEF

/*
 * Unregister AMR codec factory from pjmedia endpoint and deinitialize
 * the AMR codec library.
 */
PJ_DEF(pj_status_t) pjmedia_codec_opencore_amr_deinit(void)
{
    pjmedia_codec_mgr *codec_mgr;
    pj_status_t status;

    amr_codec_factory.init[IDX_AMR_NB] = PJ_FALSE;
    amr_codec_factory.init[IDX_AMR_WB] = PJ_FALSE;
    
    if (amr_codec_factory.pool == NULL)
	return PJ_SUCCESS;

    /* Get the codec manager. */
    codec_mgr = pjmedia_endpt_get_codec_mgr(amr_codec_factory.endpt);
    if (!codec_mgr) {
	pj_pool_release(amr_codec_factory.pool);
	amr_codec_factory.pool = NULL;
	return PJ_EINVALIDOP;
    }

    /* Unregister AMR codec factory. */
    status = pjmedia_codec_mgr_unregister_factory(codec_mgr,
						  &amr_codec_factory.base);
    
    /* Destroy pool. */
    pj_pool_release(amr_codec_factory.pool);
    amr_codec_factory.pool = NULL;
    
    return status;
}
开发者ID:iamroger,项目名称:voip,代码行数:33,代码来源:opencore_amr.c


示例5: PJ_DEF

/*
 * Unregister Opus codec factory from pjmedia endpoint and
 * deinitialize the codec.
 */
PJ_DEF(pj_status_t) pjmedia_codec_opus_deinit( void )
{
    pj_status_t status;
    pjmedia_codec_mgr *codec_mgr;

    if (opus_codec_factory.pool == NULL)
	return PJ_SUCCESS;

    /* Get the codec manager */
    codec_mgr = pjmedia_endpt_get_codec_mgr(opus_codec_factory.endpt);
    if (!codec_mgr) {
	PJ_LOG(2, (THIS_FILE, "Unable to get the codec manager"));
	pj_pool_release(opus_codec_factory.pool);
	opus_codec_factory.pool = NULL;
	return PJ_EINVALIDOP;
    }

    /* Unregister the codec factory */
    status = pjmedia_codec_mgr_unregister_factory(codec_mgr,
						  &opus_codec_factory.base);
    if (status != PJ_SUCCESS)
	PJ_LOG(2, (THIS_FILE, "Unable to unregister the codec factory"));

    /* Release the memory pool */
    pj_pool_release(opus_codec_factory.pool);
    opus_codec_factory.pool = NULL;

    return status;
}
开发者ID:chriszeng87,项目名称:pjproject,代码行数:33,代码来源:opus.c


示例6: PJ_DEF

/*
 * Unregister CODEC2 codec factory from pjmedia endpoint and deinitialize
 * the CODEC2 codec library.
 */
PJ_DEF(pj_status_t) pjmedia_codec_codec2_deinit(void)
{
    pjmedia_codec_mgr *codec_mgr;
    pj_status_t status;

    if (codec2_codec_factory.pool == NULL)
	return PJ_SUCCESS;

    /* Get the codec manager. */
    codec_mgr = pjmedia_endpt_get_codec_mgr(codec2_codec_factory.endpt);
    if (!codec_mgr) {
	pj_pool_release(codec2_codec_factory.pool);
	codec2_codec_factory.pool = NULL;
	return PJ_EINVALIDOP;
    }

    /* Unregister GSM codec factory. */
    status = pjmedia_codec_mgr_unregister_factory(codec_mgr,
						  &codec2_codec_factory.base);
    
    /* Destroy mutex. */
    pj_mutex_destroy(codec2_codec_factory.mutex);

    /* Destroy pool. */
    pj_pool_release(codec2_codec_factory.pool);
    codec2_codec_factory.pool = NULL;

    return status;
}
开发者ID:Agostin,项目名称:csipsimple,代码行数:33,代码来源:pj_codec2.c


示例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;
}
开发者ID:carlosdelfino,项目名称:WorkshopTelefoniaAutomacao,代码行数:57,代码来源:l16.c


示例8: 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;
}
开发者ID:AntonioLebara,项目名称:ios-pjsip,代码行数:57,代码来源:opus.c


示例9: pjmedia_codec_opus_set_default_param

pjmedia_codec_opus_set_default_param(const pjmedia_codec_opus_config *cfg,
				     pjmedia_codec_param *param )
{
    const pj_str_t opus_str = {"opus", 4};
    const pjmedia_codec_info *info[1];
    pjmedia_codec_mgr *codec_mgr;
    unsigned count = 1;
    pj_status_t status;

    TRACE_((THIS_FILE, "%s:%d: - TRACE", __FUNCTION__, __LINE__));
    PJ_ASSERT_RETURN(cfg, PJ_EINVAL);

    codec_mgr = pjmedia_endpt_get_codec_mgr(opus_codec_factory.endpt);

    status = pjmedia_codec_mgr_find_codecs_by_id(codec_mgr, &opus_str,
						 &count, info, NULL);
    if (status != PJ_SUCCESS)
	return status;

    /* Set sample rate */
    if (cfg->sample_rate != 8000 && cfg->sample_rate != 12000 &&
	cfg->sample_rate != 16000 && cfg->sample_rate != 24000 &&
	cfg->sample_rate != 48000)
    {
	return PJ_EINVAL;
    }
    param->info.clock_rate = opus_cfg.sample_rate = cfg->sample_rate;

    /* Set channel count */
    if (cfg->channel_cnt != 1 && cfg->channel_cnt != 2)
        return PJ_EINVAL;
    param->info.channel_cnt = opus_cfg.channel_cnt = cfg->channel_cnt;

    /* Set bit_rate */
    if (cfg->bit_rate < 6000 || cfg->bit_rate > 510000) {
	return PJ_EINVAL;
    }
    opus_cfg.bit_rate = cfg->bit_rate;

    /* Set expected packet loss */
    if (cfg->packet_loss >= 100)
	return PJ_EINVAL;
    opus_cfg.packet_loss = cfg->packet_loss;

    /* Set complexity */
    if (cfg->complexity > 10)
	return PJ_EINVAL;
    opus_cfg.complexity = cfg->complexity;

    opus_cfg.cbr = cfg->cbr;
    
    generate_fmtp(param);

    status = pjmedia_codec_mgr_set_default_param(codec_mgr, info[0], param);
    return status;
}
开发者ID:chriszeng87,项目名称:pjproject,代码行数:56,代码来源:opus.c


示例10: 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


示例11: PJ_DEF

/*
 * Unregister iLBC codec factory from pjmedia endpoint and deinitialize
 * the iLBC codec library.
 */
PJ_DEF(pj_status_t) pjmedia_codec_ilbc_deinit(void)
{
    pjmedia_codec_mgr *codec_mgr;
    pj_status_t status;


    /* Get the codec manager. */
    codec_mgr = pjmedia_endpt_get_codec_mgr(ilbc_factory.endpt);
    if (!codec_mgr)
	return PJ_EINVALIDOP;

    /* Unregister iLBC codec factory. */
    status = pjmedia_codec_mgr_unregister_factory(codec_mgr,
						  &ilbc_factory.base);
    
    return status;
}
开发者ID:RyanLee27,项目名称:pjproject,代码行数:21,代码来源:ilbc.c


示例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;
}
开发者ID:RockHardJim,项目名称:idphone,代码行数:49,代码来源:amr_stagefright_dyn_codec.c


示例13: list_codecs

void list_codecs(pjmedia_endpt *ep) {
    unsigned int count = 100;
    int i;
    char buffer[100];
    pjmedia_codec_mgr *mgr = 0;
    pjmedia_codec_info codec[20];

    mgr = pjmedia_endpt_get_codec_mgr(ep);
    pjmedia_codec_mgr_enum_codecs(mgr, &count, codec, NULL);
    
    PJ_LOG(3, (__FILE__, "THERE ARE %d codecs", count));
    for ( i = 0; i < count; i++ ) {
        pj_bzero(buffer, sizeof(buffer));
        pjmedia_codec_info_to_id(&codec[i], buffer, sizeof(buffer));
        PJ_LOG(3, (__FILE__, "Codec : %s", buffer));
    }
}
开发者ID:mocidis,项目名称:media-endpoint,代码行数:17,代码来源:test-codecs.c


示例14: PJ_DEF

/*
 * Unregister Speex codec factory from pjmedia endpoint and deinitialize
 * the Speex codec library.
 */
PJ_DEF(pj_status_t) pjmedia_codec_speex_deinit(void)
{
    pjmedia_codec_mgr *codec_mgr;
    pj_status_t status;

    if (spx_factory.pool == NULL) {
	/* Already deinitialized */
	return PJ_SUCCESS;
    }

    pj_mutex_lock(spx_factory.mutex);

    /* We don't want to deinit if there's outstanding codec. */
    /* This is silly, as we'll always have codec in the list if
       we ever allocate a codec! A better behavior maybe is to 
       deallocate all codecs in the list.
    if (!pj_list_empty(&spx_factory.codec_list)) {
	pj_mutex_unlock(spx_factory.mutex);
	return PJ_EBUSY;
    }
    */

    /* Get the codec manager. */
    codec_mgr = pjmedia_endpt_get_codec_mgr(spx_factory.endpt);
    if (!codec_mgr) {
	pj_pool_release(spx_factory.pool);
	spx_factory.pool = NULL;
	return PJ_EINVALIDOP;
    }

    /* Unregister Speex codec factory. */
    status = pjmedia_codec_mgr_unregister_factory(codec_mgr,
						  &spx_factory.base);
    
    /* Destroy mutex. */
    pj_mutex_destroy(spx_factory.mutex);

    /* Destroy pool. */
    pj_pool_release(spx_factory.pool);
    spx_factory.pool = NULL;

    return status;
}
开发者ID:imace,项目名称:mbgapp,代码行数:47,代码来源:speex_codec.c


示例15: PJ_DEF

/*
 * Initialize and register G726 codec factory to pjmedia endpoint.
 */
PJ_DEF(pj_status_t) pjmedia_codec_g726_init( pjmedia_endpt *endpt )
{
    pjmedia_codec_mgr *codec_mgr;
    pj_status_t status;

    if (g726_codec_factory.pool != NULL)
	return PJ_SUCCESS;

    /* Create G726 codec factory. */
    g726_codec_factory.base.op = &g726_factory_op;
    g726_codec_factory.base.factory_data = NULL;
    g726_codec_factory.endpt = endpt;

    g726_codec_factory.pool = pjmedia_endpt_create_pool(endpt, "g726", 512, 512);
    if (!g726_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 codec factory to endpoint. */
    status = pjmedia_codec_mgr_register_factory(codec_mgr, 
						&g726_codec_factory.base);
    if (status != PJ_SUCCESS)
	goto on_error;

    /* Done. */
    return PJ_SUCCESS;

on_error:
    pj_pool_release(g726_codec_factory.pool);
    g726_codec_factory.pool = NULL;
    return status;
}
开发者ID:0x0B501E7E,项目名称:CSipSimple,代码行数:41,代码来源:pj_g726.c


示例16: enc_dec_test

static pj_status_t enc_dec_test(const char *codec_id,
				const char *filein,
			        const char *fileout)
{
    pj_pool_t *pool;
    pjmedia_codec_mgr *cm;
    pjmedia_codec *codec;
    const pjmedia_codec_info *pci;
    pjmedia_codec_param param;
    unsigned cnt, samples_per_frame;
    pj_str_t tmp;
    pjmedia_port *wavin, *wavout;
    unsigned lost_pct;
    pj_status_t status;

#define T   file_msec_duration/1000, file_msec_duration%1000
    
    pool = pjmedia_endpt_create_pool(mept, "encdec", 1000, 1000);

    cm = pjmedia_endpt_get_codec_mgr(mept);

#ifdef LOST_PCT
    lost_pct = LOST_PCT;
#else
    lost_pct = 0;
#endif
    
    cnt = 1;
    CHECK( pjmedia_codec_mgr_find_codecs_by_id(cm, pj_cstr(&tmp, codec_id), 
					       &cnt, &pci, NULL) );
    CHECK( pjmedia_codec_mgr_get_default_param(cm, pci, &param) );

    samples_per_frame = param.info.clock_rate * param.info.frm_ptime / 1000;

    /* Control VAD */
    param.setting.vad = 1;

    /* Open wav for reading */
    CHECK( pjmedia_wav_player_port_create(pool, filein, 
					  param.info.frm_ptime, 
					  PJMEDIA_FILE_NO_LOOP, 0, &wavin) );

    /* Open wav for writing */
    CHECK( pjmedia_wav_writer_port_create(pool, fileout,
					  param.info.clock_rate, 
					  param.info.channel_cnt,
					  samples_per_frame,
					  16, 0, 0, &wavout) );

    /* Alloc codec */
    CHECK( pjmedia_codec_mgr_alloc_codec(cm, pci, &codec) );
    CHECK( codec->op->init(codec, pool) );
    CHECK( codec->op->open(codec, &param) );
    
    for (;;) {
	pjmedia_frame frm_pcm, frm_bit, out_frm, frames[4];
	pj_int16_t pcmbuf[320];
	pj_timestamp ts;
	pj_uint8_t bitstream[160];

	frm_pcm.buf = (char*)pcmbuf;
	frm_pcm.size = samples_per_frame * 2;

	/* Read from WAV */
	if (pjmedia_port_get_frame(wavin, &frm_pcm) != PJ_SUCCESS)
	    break;
	if (frm_pcm.type != PJMEDIA_FRAME_TYPE_AUDIO)
	    break;;

	/* Update duration */
	file_msec_duration += samples_per_frame * 1000 / 
			      param.info.clock_rate;

	/* Encode */
	frm_bit.buf = bitstream;
	frm_bit.size = sizeof(bitstream);
	CHECK(codec->op->encode(codec, &frm_pcm, sizeof(bitstream), &frm_bit));

	/* On DTX, write zero frame to wavout to maintain duration */
	if (frm_bit.size == 0 || frm_bit.type != PJMEDIA_FRAME_TYPE_AUDIO) {
	    out_frm.buf = (char*)pcmbuf;
	    out_frm.size = 160;
	    CHECK( pjmedia_port_put_frame(wavout, &out_frm) );
	    TRACE_((THIS_FILE, "%d.%03d read: %u, enc: %u",
		    T, frm_pcm.size, frm_bit.size));
	    continue;
	}
	
	/* Parse the bitstream (not really necessary for this case
	 * since we always decode 1 frame, but it's still good
	 * for testing)
	 */
	ts.u64 = 0;
	cnt = PJ_ARRAY_SIZE(frames);
	CHECK( codec->op->parse(codec, bitstream, frm_bit.size, &ts, &cnt, 
			        frames) );
	CHECK( (cnt==1 ? PJ_SUCCESS : -1) );

	/* Decode or simulate packet loss */
	out_frm.buf = (char*)pcmbuf;
//.........这里部分代码省略.........
开发者ID:deveck,项目名称:Deveck.TAM,代码行数:101,代码来源:encdec.c


示例17: PJ_DEF

PJ_DEF(pj_status_t) pjmedia_codec_silk_init(pjmedia_endpt *endpt)
{
    pjmedia_codec_mgr *codec_mgr;
    silk_param *sp;
    pj_status_t status;

    if (silk_factory.endpt != NULL) {
	/* Already initialized. */
	return PJ_SUCCESS;
    }

    /* Init factory */
    pj_bzero(&silk_factory, sizeof(silk_factory));
    silk_factory.base.op = &silk_factory_op;
    silk_factory.base.factory_data = NULL;
    silk_factory.endpt = endpt;

    /* Create pool */
    silk_factory.pool = pjmedia_endpt_create_pool(endpt, "silk", 4000, 4000);
    if (!silk_factory.pool)
	return PJ_ENOMEM;

    /* Create mutex. */
    status = pj_mutex_create_simple(silk_factory.pool, "silk",
				    &silk_factory.mutex);
    if (status != PJ_SUCCESS)
	goto on_error;

    /* Initialize default codec params */

    /* From SILK docs:
       - SILK bitrate tables:
         +----------------+---------+-----------+
         |                | fs (Hz) | BR (kbps) |
         +----------------+---------+-----------+
         |   Narrowband   |   8000  |   6 - 20  |
         |   Mediumband   |  12000  |   7 - 25  |
         |    Wideband    |  16000  |   8 - 30  |
         | Super Wideband |  24000  |  12 - 40  |
         +----------------+---------+-----------+
       - The upper limits of the bit rate ranges in this table are
         recommended values.
     */

    sp = &silk_factory.silk_param[PARAM_NB];
    sp->pt = PJMEDIA_RTP_PT_SILK_NB;
    sp->clock_rate = 8000;
    sp->max_bitrate = 22000;
    sp->bitrate = CALC_BITRATE(sp->max_bitrate);
    sp->ptime = FRAME_LENGTH_MS;
    sp->complexity = PJMEDIA_CODEC_SILK_DEFAULT_COMPLEXITY;
    sp->enabled = 1;

    sp = &silk_factory.silk_param[PARAM_MB];
    sp->pt = PJMEDIA_RTP_PT_SILK_MB;
    sp->clock_rate = 12000;
    sp->max_bitrate = 28000;
    sp->bitrate = CALC_BITRATE(sp->max_bitrate);
    sp->ptime = FRAME_LENGTH_MS;
    sp->complexity = PJMEDIA_CODEC_SILK_DEFAULT_COMPLEXITY;
    sp->enabled = 0;

    sp = &silk_factory.silk_param[PARAM_WB];
    sp->pt = PJMEDIA_RTP_PT_SILK_WB;
    sp->clock_rate = 16000;
    sp->max_bitrate = 36000;
    sp->bitrate = CALC_BITRATE(sp->max_bitrate);
    sp->ptime = FRAME_LENGTH_MS;
    sp->complexity = PJMEDIA_CODEC_SILK_DEFAULT_COMPLEXITY;
    sp->enabled = 1;

    sp = &silk_factory.silk_param[PARAM_SWB];
    sp->pt = PJMEDIA_RTP_PT_SILK_SWB;
    sp->clock_rate = 24000;
    sp->max_bitrate = 46000;
    sp->bitrate = CALC_BITRATE(sp->max_bitrate);
    sp->ptime = FRAME_LENGTH_MS;
    sp->complexity = PJMEDIA_CODEC_SILK_DEFAULT_COMPLEXITY;
    sp->enabled = 0;


    /* 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,
						&silk_factory.base);
    if (status != PJ_SUCCESS)
	return status;

    PJ_LOG(4,(THIS_FILE, "SILK codec version %s initialized",
	      SKP_Silk_SDK_get_version()));
    return PJ_SUCCESS;

on_error:
    if (silk_factory.mutex) {
	pj_mutex_destroy(silk_factory.mutex);
//.........这里部分代码省略.........
开发者ID:avble,项目名称:natClientEx,代码行数:101,代码来源:silk.c


示例18: main


//.........这里部分代码省略.........
	    return 1;
	}
    }
#endif

    /* Must create a pool factory before we can allocate any memory. */
    pj_caching_pool_init(&cp, &pj_pool_factory_default_policy, 0);

    /* 
     * Initialize media endpoint.
     * This will implicitly initialize PJMEDIA too.
     */
    status = pjmedia_endpt_create(&cp.factory, NULL, 1, &med_endpt);
    PJ_ASSERT_RETURN(status == PJ_SUCCESS, 1);

    /* Create memory pool for application purpose */
    pool = pj_pool_create( &cp.factory,	    /* pool factory	    */
			   "app",	    /* pool name.	    */
			   4000,	    /* init size	    */
			   4000,	    /* increment size	    */
			   NULL		    /* callback on error    */
			   );


    /* Register all supported codecs */
    status = init_codecs(med_endpt);
    PJ_ASSERT_RETURN(status == PJ_SUCCESS, 1);


    /* Find which codec to use. */
    if (codec_id) {
	unsigned count = 1;
	pj_str_t str_codec_id = pj_str(codec_id);
	pjmedia_codec_mgr *codec_mgr = pjmedia_endpt_get_codec_mgr(med_endpt);
	status = pjmedia_codec_mgr_find_codecs_by_id( codec_mgr,
						      &str_codec_id, &count,
						      &codec_info, NULL);
	if (status != PJ_SUCCESS) {
	    printf("Error: unable to find codec %s\n", codec_id);
	    return 1;
	}
    } else {
	/* Default to pcmu */
	pjmedia_codec_mgr_get_codec_info( pjmedia_endpt_get_codec_mgr(med_endpt),
					  0, &codec_info);
    }

    /* Create stream based on program arguments */
    status = create_stream(pool, med_endpt, codec_info, dir, local_port, 
			   &remote_addr, 
#if defined(PJMEDIA_HAS_SRTP) && (PJMEDIA_HAS_SRTP != 0)
			   use_srtp, &srtp_crypto_suite, 
			   &srtp_tx_key, &srtp_rx_key,
#endif
			   &stream);
    if (status != PJ_SUCCESS)
	goto on_exit;

    /* Get codec default param for info */
    status = pjmedia_codec_mgr_get_default_param(
				    pjmedia_endpt_get_codec_mgr(med_endpt), 
				    codec_info, 
				    &codec_param);
    /* Should be ok, as create_stream() above succeeded */
    pj_assert(status == PJ_SUCCESS);
开发者ID:0x0B501E7E,项目名称:pjproject,代码行数:66,代码来源:streamutil.c


示例19: PJ_DEF

PJ_DEF(pj_status_t) pjmedia_codec_silk_init(pjmedia_endpt *endpt)
{
    pjmedia_codec_mgr *codec_mgr;
    pj_status_t status;

    if (silk_factory.endpt != NULL) {
	/* Already initialized. */
	return PJ_SUCCESS;
    }

    /* Init factory */
    silk_factory.base.op = &silk_factory_op;
    silk_factory.base.factory_data = NULL;
    silk_factory.endpt = endpt;

    /* Create pool */
    silk_factory.pool = pjmedia_endpt_create_pool(endpt, "silk codecs", 4000, 4000);
    if (!silk_factory.pool)
	return PJ_ENOMEM;

    /* Init list */
    pj_list_init(&silk_factory.codec_list);

    /* Create mutex. */
    status = pj_mutex_create_simple(silk_factory.pool, "silk codecs",
				    &silk_factory.mutex);
    if (status != PJ_SUCCESS)
	goto on_error;
    PJ_LOG(5, (THIS_FILE, "Init silk"));

    /* Table from silk docs
    				| fs (Hz) | BR (kbps)
    ----------------+---------+----------
    Narrowband		|    8000 |  5 - 20
    Mediumband		|   12000 |  7 - 25
    Wideband		|   16000 |  8 - 30
    Super Wideband	|   24000 | 20 - 40
    */
    // The max_bitrate is based on the maximum bitrate that can be used for the encoder.
    // BTW, if a remote side send us something very big, we will not get lost.
    // If such a remote side send us big packets it could be considered unefficient.
    // On our side we set for bitrate the medium value of bitrate for each clock rate based
    // on table above.
    struct silk_param *silk_param;
    silk_param = &silk_factory.silk_param[PARAM_NB];
    silk_param->pt = PJMEDIA_RTP_PT_SILK_NB;
    silk_param->clock_rate = 8000;
    silk_param->bitrate = 13000;
	pj_utoa(silk_param->bitrate, silk_param->bitrate_str);
	silk_param->max_bitrate = SILK_MAX_CODER_BITRATE;
	silk_param->packet_size_ms = FRAME_LENGTH_MS;
	silk_param->complexity = 2;
	silk_param->enabled = 1;

    silk_param = &silk_factory.silk_param[PARAM_MB];
    silk_param->pt = PJMEDIA_RTP_PT_SILK_MB;
    silk_param->clock_rate = 12000;
    silk_param->bitrate = 16000;
    pj_utoa(silk_param->bitrate, silk_param->bitrate_str);
    silk_param->max_bitrate = SILK_MAX_CODER_BITRATE;
    silk_param->packet_size_ms = FRAME_LENGTH_MS;
    silk_param->complexity = 2;
    silk_param->enabled = 1;

    silk_param = &silk_factory.silk_param[PARAM_WB];
    silk_param->pt = PJMEDIA_RTP_PT_SILK_WB;
	silk_param->clock_rate = 16000;
	silk_param->bitrate = 19000;
	pj_utoa(silk_param->bitrate, silk_param->bitrate_str);
	silk_param->max_bitrate = SILK_MAX_CODER_BITRATE;
	silk_param->packet_size_ms = FRAME_LENGTH_MS;
	silk_param->complexity = 2;
	silk_param->enabled = 1;

    silk_param = &silk_factory.silk_param[PARAM_UWB];
    silk_param->pt = PJMEDIA_RTP_PT_SILK_UWB;
    silk_param->clock_rate = 24000;
    silk_param->bitrate = 30000;
	pj_utoa(silk_param->bitrate, silk_param->bitrate_str);
    silk_param->max_bitrate = SILK_MAX_CODER_BITRATE;
	silk_param->packet_size_ms = FRAME_LENGTH_MS;
	silk_param->complexity = 2;
	silk_param->enabled = 1;


    /* Get the codec manager. */
    codec_mgr = pjmedia_endpt_get_codec_mgr(endpt);
    if (!codec_mgr) {
	return PJ_EINVALIDOP;
    }

    PJ_LOG(5, (THIS_FILE, "Init silk > DONE"));

    /* Register codec factory to endpoint. */
    status = pjmedia_codec_mgr_register_factory(codec_mgr,
						&silk_factory.base);
    if (status != PJ_SUCCESS)
	return status;

    return PJ_SUCCESS;
//.........这里部分代码省略.........
开发者ID:lidocan2012,项目名称:csipsimple-2,代码行数:101,代码来源:silk.c


示例20: PJ_DEF

/*
 * Create stream info from SDP media line.
 */
PJ_DEF(pj_status_t) pjmedia_stream_info_from_sdp(
					   pjmedia_stream_info *si,
					   pj_pool_t *pool,
					   pjmedia_endpt *endpt,
					   const pjmedia_sdp_session *local,
					   const pjmedia_sdp_session *remote,
					   unsigned stream_idx)
{
    pjmedia_codec_mgr *mgr;
    const pjmedia_sdp_attr *attr;
    const pjmedia_sdp_media *local_m;
    const pjmedia_sdp_media *rem_m;
    const pjmedia_sdp_conn *local_conn;
    const pjmedia_sdp_conn *rem_conn;
    pjmedia_sdp_rtpmap *rtpmap;
    int local_fmtp_mode = 0, rem_fmtp_mode = 0;
    unsigned i, pt, fmti;
    pj_status_t status;

    
    /* Validate arguments: */
    PJ_ASSERT_RETURN(pool && si && local && remote, PJ_EINVAL);
    PJ_ASSERT_RETURN(stream_idx < local->media_count, PJ_EINVAL);
    PJ_ASSERT_RETURN(stream_idx < remote->media_count, PJ_EINVAL);


    /* Get codec manager. */
    mgr = pjmedia_endpt_get_codec_mgr(endpt);

    /* Keep SDP shortcuts */
    local_m = local->media[stream_idx];
    rem_m = remote->media[stream_idx];

    local_conn = local_m->conn ? local_m->conn : local->conn;
    if (local_conn == NULL)
	return PJMEDIA_SDP_EMISSINGCONN;

    rem_conn = rem_m->conn ? rem_m->conn : remote->conn;
    if (rem_conn == NULL)
	return PJMEDIA_SDP_EMISSINGCONN;


    /* Reset: */

    pj_bzero(si, sizeof(*si));

    /* Media type: */

    if (pj_stricmp(&local_m->desc.media, &ID_AUDIO) == 0) {

	si->type = PJMEDIA_TYPE_AUDIO;

    } else if (pj_stricmp(&local_m->desc.media, &ID_VIDEO) == 0) {

	si->type = PJMEDIA_TYPE_VIDEO;

    } else {

	si->type = PJMEDIA_TYPE_UNKNOWN;
	return PJMEDIA_EINVALIMEDIATYPE;
    }

    /* Transport type must be equal */
    if (pj_stricmp(&rem_m->desc.transport, 
		   &local_m->desc.transport) != 0) 
    {
	si->type = PJMEDIA_TYPE_UNKNOWN;
	return PJMEDIA_SDPNEG_EINVANSTP;
    }

    /* Media direction: */

    if (local_m->desc.port == 0 || 
	pj_inet_addr(&local_conn->addr).s_addr==0 ||
	pj_inet_addr(&rem_conn->addr).s_addr==0 ||
	pjmedia_sdp_media_find_attr(local_m, &STR_INACTIVE, NULL)!=NULL)
    {
	/* Inactive stream. */

	si->dir = PJMEDIA_DIR_NONE;

    } else if (pjmedia_sdp_media_find_attr(local_m, &STR_SENDONLY, NULL)!=NULL) {

	/* Send only stream. */

	si->dir = PJMEDIA_DIR_ENCODING;

    } else if (pjmedia_sdp_media_find_attr(local_m, &STR_RECVONLY, NULL)!=NULL) {

	/* Recv only stream. */

	si->dir = PJMEDIA_DIR_DECODING;

    } else {

	/* Send and receive stream. */

//.........这里部分代码省略.........
开发者ID:tibastral,项目名称:symphonie,代码行数:101,代码来源:session.c



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ pjsip_endpt_cancel_timer函数代码示例发布时间:2022-05-30
下一篇:
C++ pjmedia_endpt_create_pool函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap