开发者

How to play raw audio in Iphone? (using ffmpeg)

I am a student who is trying to make mms stream audio app.

I got mms stream using libmms, and decoded wma audio using ffmpeg.

But however I don't know What to do next.

I recently saw similar question in stackoverflow site. (Writer is c4r1o5)

But He used cfwritestreamwrite after avcodec_decode_audio2.

Is that right? I think It is not necessary because network problem finished after mms_connect, ffmpeg dec开发者_Go百科ode.

Is that necessary to use?

I tried to put raw audio to audio buffer. and when play, It only comes with white noise.

Please help me.

Any hint or comment would be vey appreciated.

Thanks in advance.

How to play raw audio in Iphone? (using ffmpeg)


Please post necessary code.
And, You don't necessarily use CFWriteStreamWrite.
Even though I have no experience with CFWriteStreamWrite, It is not necessary in mms streaming.
All you need is to Connect MMS, Decode wma audio file, Queue audio buffer to play in iphone.
I think you have to know about iphone Audio Queue Service
And be sure to use thread when get audio frame.
Basic information lies that site.

Finally, the reason only comes with white noise is because you set wrong mAudioData.
Use memcpy to copy audio memory.


You have to implement the AudioQueueOutputCallback to pass the decoded audio data to AudioQueue.

- (void)handlePlayCallback:(AudioQueueRef) inAudioQueue buffer:(AudioQueueBufferRef) inBuffer {
    // copy decoded audio data to inBuffer->mAudioData
    // and set the size of the copied data like this
    // inBuffer->mAudioDataByteSize = data_written

    if(inBuffer->mAudioDataByteSize > 0) {
        AudioQueueEnqueueBuffer(inAudioQueue, inBuffer, 0, NULL);
    }
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜