Stream audio from iOS

后端 未结 5 1992
太阳男子
太阳男子 2020-12-29 06:05

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 abou

相关标签:
5条回答
  • 2020-12-29 06:21

    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.

    0 讨论(0)
  • 2020-12-29 06:23

    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.

    0 讨论(0)
  • 2020-12-29 06:24

    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

    0 讨论(0)
  • 2020-12-29 06:33

    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!

    0 讨论(0)
  • 2020-12-29 06:39

    You would do it exactly like this:

    https://app.box.com/s/ta353zq58bgoj5d7j6kndkhpxa02banz

    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.

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

    Let me know if you have any questions.

    0 讨论(0)
提交回复
热议问题