コード例 #1
0
ファイル: g729.c プロジェクト: intiaz/PTT_3G_G729
static pj_status_t g729_open(pjmedia_codec *codec,
			     pjmedia_codec_param *attr )
{
    struct g729_private *priv = (struct g729_private*) codec->codec_data;
    pj_pool_t *pool;

    priv->pt = attr->info.pt;
    pool = priv->pool;

  /* PREPARING THE ENCODER */
  priv->encoder = pj_pool_zalloc(pool, g729a_enc_mem_size());
	if (!priv->encoder)
		return PJMEDIA_CODEC_EFAILED;
    if (!g729a_enc_init(priv->encoder))
    	return PJMEDIA_CODEC_EFAILED;

    /* PREPARING THE DECODER */
    priv->decoder = pj_pool_zalloc(pool, g729a_dec_mem_size());
	if (!priv->decoder)
		return PJMEDIA_CODEC_EFAILED;
    if (!g729a_dec_init(priv->decoder))
		return PJMEDIA_CODEC_EFAILED;

#if !PLC_DISABLED
    priv->plc_enabled = (attr->setting.plc != 0);
#endif
    priv->vad_enabled = (attr->setting.vad != 0);
    return PJ_SUCCESS;
}
コード例 #2
0
JNIEXPORT jint JNICALL Java_org_sipdroid_codecs_G729_open
  (JNIEnv *env, jobject obj) {
	//int ret;
	Flag en;
	Flag de;

	if (codec_open++ != 0)
		return (jint)0;

	/*--------------------------------------------------------------------------*
	 * Initialization of the coder.                                             *
	 *--------------------------------------------------------------------------*/

	encodersize = g729a_enc_mem_size();
	hEncoder = calloc(1, encodersize * sizeof(UWord8));

	if (hEncoder == NULL)
	  {
	    printf("Cannot create encoder\n");
	    exit(2);
	  }
	en=g729a_enc_init(hEncoder);
	if(en == 0)
		  {
		    printf("Cannot create encoder\n");
		    exit(2);
		  }
	/*-----------------------------------------------------------------*
	 *           Initialization of decoder                             *
	 *-----------------------------------------------------------------*/

	decodersize = g729a_dec_mem_size();
	hDecoder = calloc(1, decodersize * sizeof(UWord8));
	  if (hDecoder == NULL)
	  {
	    printf("Cannot create decoder\n");
	    exit(2);
	  }
	  de=g729a_dec_init(hDecoder);
	  if (de == 0)
	  		  {
	  		    printf("Cannot create decoder\n");
	  		    exit(2);
	  		  }

	return (jint)0;
}
コード例 #3
0
bool G729CodecNative::Open()
{
	Flag flag;
	Word32 memSize = g729a_enc_mem_size();
	//_hEncoder = calloc(1, encSize * sizeof(UWord8));
	if( (_hEncoder = calloc(1, memSize * sizeof(UWord8))) == NULL)
		return false;

	//flag = g729a_enc_init(_hEncoder);
	if( (flag = g729a_enc_init(_hEncoder)) == 0)
		return false;

	memSize = g729a_dec_mem_size();
	//_hDecoder = calloc(1, memSize * sizeof(UWord8));
	if ( (_hDecoder = calloc(1, memSize * sizeof(UWord8))) == NULL)
		return false;

	//flag = g729a_dec_init(_hDecoder);
	if( (flag = g729a_dec_init(_hDecoder)) == 0)
		return false;

	_bOpened = true;
	return _bOpened;
}