예제 #1
0
MediaDecoderStateMachine*
MediaOmxCommonDecoder::CreateStateMachine()
{
  mReader = CreateReader();
  if (mReader != nullptr) {
    mReader->SetAudioChannel(GetAudioChannel());
  }
  return CreateStateMachineFromReader(mReader);
}
예제 #2
0
int g7712aac::init()
{
    nRet = 0;
    nTmp = 0;
    nCount = 0;
    nStatus = 0;
    nPCMRead = 0;
    PCMSize = /*320*/CON_PCM_SIZE;
    nPCMBufferSize = 0;

    unsigned int objectType = LOW;
    unsigned int mpegVersion = MPEG2;
    static unsigned int useTns = 0; //#define DEFAULT_TNS     0

    //TODO: config this
    unsigned int nChannels = 1;
	nChannels = GetAudioChannel();
    nPCMBitSize = 16;
    nInputSamples = 0;
    unsigned long nSampleRate = 8000;
	nSampleRate = GetAudioSamplerate();
    nMaxOutputBytes = 0;

    /*open FAAC engine*/
    hEncoder = faacEncOpen(nSampleRate, nChannels, &nInputSamples, &nMaxOutputBytes);
    if (hEncoder == NULL)
    {
        if(AAC_DEBUG) printf("%s:[%d] failed to call faacEncOpen !\n", __FUNCTION__, __LINE__);
        return -1;
    }

    nPCMBufferSize = (nInputSamples * (nPCMBitSize / 8));
    pbPCMBuffer = (unsigned char*) malloc(nPCMBufferSize * sizeof (unsigned char));
    memset(pbPCMBuffer, 0, nPCMBufferSize);

    pbAACBuffer = (unsigned char*) malloc(nMaxOutputBytes * sizeof (unsigned char));
    memset(pbAACBuffer, 0, nMaxOutputBytes);

    pbG711ABuffer = (unsigned char *) malloc(/*164*/G711_ONE_LEN * sizeof (unsigned char));
    memset(pbG711ABuffer, 0, /*164*/G711_ONE_LEN);

    audio_buffer_ = new audio_buffer();

    pbPCMTmpBuffer = (unsigned char *) malloc(PCMSize * sizeof (unsigned char));
    memset(pbPCMTmpBuffer, 0, PCMSize);

    /*get current encoding configuration*/
    pConfiguration = faacEncGetCurrentConfiguration(hEncoder);
    pConfiguration->inputFormat = FAAC_INPUT_16BIT;

    /*0 - raw; 1 - ADTS*/
    pConfiguration->outputFormat = 1;
    pConfiguration->useTns = useTns;
    pConfiguration->aacObjectType = objectType;
    pConfiguration->mpegVersion = mpegVersion;

    /*set encoding configuretion*/
    faacEncSetConfiguration(hEncoder, pConfiguration);

    // bStart = true;
    //thread.reset(new boost::thread(boost::bind(encode_routine, this)));

	return 0;
}
MediaDecoderStateMachine* MediaOmxDecoder::CreateStateMachine()
{
  mReader = new MediaOmxReader(this);
  mReader->SetAudioChannel(GetAudioChannel());
  return new MediaDecoderStateMachine(this, mReader);
}