views:

4146

answers:

2

I'm looking to stream some audio files I have on my server to an iPhone-client application I'm writing. Some of the audio files can be rather large in size, even after compression. My question is, is there a Cocoa framework that helps me with buffering the audio so it becomes available to the user while the rest is being brought down the pipes? If not, can anyone point me in the right direction to learn more about the technologies required to make such a thing happen using Objective-C/Cocoa?

A definitive resource on buffering and compression of audio from a server<->client infrastructure would be ideal.

+2  A: 

Unfortunatally, you are going to have a bit of work in front of you. I had to do this for an iPhone project this last summer. Most of what you need is in Audio Queue Services in the AudioToolbox framwork.

Working with audio queue services is kind of tricky, you will have to implement a bunch of callbacks to tell it how to processes your packets after they come off the network.

Someone, I think Matt Gallagar, had some sample code on a blog that was okay, and there is a bunch of stuff on Apple's Core Audio Mailing List.

I did find that I ended up needing to not relay on NSURL Connection to do the network part, because my didrecievedata delegate method was not firing often enough.

Sorry I could not just drop in a few lines of code as an example here, but the class I wrote to do this came in at around 400 lines.

Brad Smith
+12  A: 

Brad mentioned a post that I wrote to stream audio via HTTP. That was this one: Streaming and playing an MP3. I don't mean to be the person that links to his own blog but it does kind of address your question.

In regards to how hard the problem is to solve, you'll notice I've made 4 updates to that post (way more than I've done for anything else), fixing threading errors, memory leaks and network buffering issues. There is a lot to get precisely correct.

Matt Gallagher
Matt, I'm a huge fan of your site. You're one of the few select feeds that has high priority on ensuring I stay active on reads. Thanks so much for giving back with your insight.
Coocoo4Cocoa