i am developing one streaming application for iOS and i am getting all audio packets correctly and decoded also but now i am totally confused about how to play it on iPhone.. I have decoded packets using ffmpeg.. All codes i get so far are playing audio from a file but i my case i have to play audio packets which i am getting from server in an order they are coming.. I dont want to save all packets to a file so any code that will help me to solve my problem is appreciated..
Thnak you...
You'll need to use Audio Services to do this. Either AudioQueue
or AudioUnit
. AudioQueue
is better for streaming type applications.
The classic sample - for AudioQueue - is Apple's SpeakHere.
Matt Gallagher also has some superb tutorials with sample code for streaming.
See Streaming MP3/AAC audio again.
If you want to go the AudioUnit
route, see Using RemoteIO audio unit.
By basing your code on Matt Gallagher's sample, possibly also using SpeakHere, you should be able to play your decoded packets. See my other answers for how to play using a buffer rather than from a file.
Don't forget that this is quite advanced stuff. You'll need to be comfortable with buffers, pointers, etc. Make sure you understand frames, packets, etc. as well. Some pain in getting your audio out there is to be expected.