20

How would I go about streaming audio FROM an iOS device to another device like a Mac or another iOS device? I can only find solutions like AirPlay on Google and nothing about how to do it in your own app. I would assume you would have to go through a server of some kind.

To be clear, I am not looking to replicate AirPlay. I am looking to do very basic VoIP.

David Beck
  • 10,099
  • 5
  • 51
  • 88
  • Yeah, that's very true. Amazingly enough, the APIs that Apple wrote into the iOS software let you use the iOS device as an AirPlay server (sender) which sends data to the AirPlay client (recvr) which allows you to do what you just said. So you could either license the AirPlay tech for yourself, or you could duplicate the functionality of the iOS AirPlay technology, and convince the iOS to ... I think you see where I'm going here. What are you trying to do? Don't all iOS devices have a headphone port? Aren't they all intended for personal media consumption? – jcolebrand May 29 '11 at 05:02

5 Answers5

2

crude VOIP use case:

Step 1. record audio with AV Foundation using a compressive encoder
Step 2. Stream packets to another device (ie RTP)
Step 3. Decode & play the audio packets on the remote device

More complex VOIP uses case include discovering users, establishing connections.

These links might get you started

http://developer.apple.com/library/ios/#DOCUMENTATION/AudioVideo/Conceptual/MultimediaPG/UsingAudio/UsingAudio.html

http://en.wikipedia.org/wiki/Real-time_Transport_Protocol

greg
  • 49
  • 5
1

EDIT - Aug 12, 2011

I didn't realize you wanted to go from device to device with the audio. You can always use CFNetwork and simply socket into a device. The trick is going to be detecting it. Look into bonjour services as well. You will still need to use AudioToolbox to process the audio into buffers and through either bonjour or a socket.

End edit

@greg AVFoundation gives you things like AVAudioRecorder, but it doesn't quite let you stream out packets like he wants.

I'd take a look at AudioToolbox. If you use an AudioQueue, you can specify a format for streaming. Then, add an input queue callback and you get access to the raw packets of recorded audio.

Take a look at iLBC for a codec. It has a small enough footprint to let you do everything over 3g.

Here's a great apple reference on AudioQueue programming: http://developer.apple.com/library/mac/#documentation/MusicAudio/Conceptual/AudioQueueProgrammingGuide/AQRecord/RecordingAudio.html

Good luck!

Dexter
  • 5,666
  • 6
  • 33
  • 45
0

You would do it exactly like this:

https://m.box.com/intent/open?type=shared_item&shared_link=https%3A%2F%2Fapp.box.com%2Fs%2Fta353zq58bgoj5d7j6kndkhpxa02banz

Run this app on two iOS devices; it will automatically connect both devices to your network and start streaming audio between them.

The interface consists of a single UI component, specifically, a text field into which app events are logged. It'll make it easy to understand the app's architecture.

enter image description here

You need the latest beta release versions of Xcode 9 and iOS 11.

Let me know if you have any questions.

James Bush
  • 1,485
  • 14
  • 19
0

You say that you don't want to use AirPlay. Going with that, you will need to run your own server on the iOS device. This is certainly possible, and there are apps that run various servers for various tasks. However, I'm not very familiar with the subject, and it seems that you are correct that there isn't much information on this online.

That said, I'd suggest having a look at Darwin Streaming Server. It seems that it's a little old, but it's open source and might be of use to you.

Moshe
  • 57,511
  • 78
  • 272
  • 425
0

I think a good start would be to understand the old example for CoreAudio: SpeakHere (it records and plays sounds using low level C APIs. CoreAudio is one of the ascendants of AVFoundation)

As @DexterW said you will need knowledge of AudioQueue, etc.

After that you can start thinking in the servers/packets to stream to :)

Hope it helps.

nacho4d
  • 43,720
  • 45
  • 157
  • 240