지금 현재 FFMPEG를 이용하여 오디오를 재생하고 있습니다.


PCM을 파일로 생성을 하여서 재생을 하다보니 여러 제약사항이 생겨서


PCM을 파일 대신 버퍼를 이용하려고 합니다.


어떻게 해야할지 도저히 감이 잡히지 않아서 글을 올리게 되었습니다.


고수님들께 부탁드립니다.


int *decodeAudioFrame() {


if (mpacket.stream_index == gAudioStreamIdx) {

// get sample byte

mbps = av_get_bytes_per_sample(gAudioCodecCtx->sample_fmt);

// allocate saving buffer size

gOutSize = FFMAX(mpacket.size * mbps, AVCODEC_MAX_AUDIO_FRAME_SIZE) * (mpacket.size * mbps);

// decode audio file and save buffer

gLen = avcodec_decode_audio3(gAudioCodecCtx, (short *) gAudioBuffer, &gOutSize, &mpacket);

// check decoding audio file

if (gLen < 0) {

return -40;

}

// check buffer size

if (gOutSize > 0) {

// write pcm file

fwrite(gAudioBuffer, 1, gOutSize, AudioOutFile);

}

// success decode

return buffers;

}

// fail decode

return -1;

}


현재 디코딩하고 있는 소스 부분입니다. 파일을 버퍼로 바꾸는 일인데 많이 어렵네요ㅠㅠ