开发者

playing pcm data on iphone

i need to play linear pcm data live on a iphone.

i get a LIVE datastream via RTSP, and i can currently read it out from iphone, save it into a file, play it on a desktop audioplayer that supports pcm, therefore i think the transport is okay.

now i got stuck, i have completely! no idea what to do with my NSData object containing the data.

i did a bit of research, ending up with AudioUnits, but i just cannot assign my NSdata to the audiobuffer, respectivly i have no clue how.

for my instance, i assigned the callback:

AURenderCallbackStruct input;
input.inputProc = makeSound;
input.inputProcRefCon = self;

and having the function 'makeSound':

   OSStatus makeSound(
                void *inRefCon, 
                AudioUnitRenderActionFlags  *ioActionFlags, 
                const AudioTimeStamp        *inTimeStamp, 
                UInt32                      inBusNumber, 
                UInt32                      inNumberFrames, 
                AudioBufferList             *ioData)

      {

            //so what to do here?
            //ioData->mBuffers[0].mdata = [mySound bytes]; does not work, nor does
            //ioData->mBuffers = [mySound byes];

            return noErr;
       }

is my approeach wrong in gerneral?

of what do i need to know/learn/implement? i am a complete audio-newbie, so my suggestion was, that i dont need several buffers, since when i get the new sound-package from rtsp, the old one is ended, since its a live stream (i base this on my recordings, that just appended the b开发者_如何学Goytes w/o looking up presentation timestamps, since i dont receive some anyways)

Cheers


I don't know if this is exactly what you are looking for but some of Matt Gallagher's AudioStreamer code might be helpful to you. In particular, check out how he handles the audio buffering. http://cocoawithlove.com/2010/03/streaming-mp3aac-audio-again.html

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜