Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to Send and Receive Live audio from one iPhone mic to the another iPhone speaker?
    primarykey
    data
    text
    <p>I have managed to send and receive NSData from one iPhone to Another using Bonjour. I have wrote callbacks for recording audio using Audio Queue and sent the NSData using the following callback on the sender side:</p> <pre><code> void AudioInputCallback(void * inUserData, AudioQueueRef inAQ, AudioQueueBufferRef inBuffer, const AudioTimeStamp * inStartTime, UInt32 inNumberPacketDescriptions, const AudioStreamPacketDescription * inPacketDescs) { RecordState * recordState = (RecordState*)inUserData; if (!recordState-&gt;recording) { printf("Not recording, returning\n"); } // if (inNumberPacketDescriptions == 0 &amp;&amp; recordState-&gt;dataFormat.mBytesPerPacket != 0) // { // inNumberPacketDescriptions = inBuffer-&gt;mAudioDataByteSize / recordState-&gt;dataFormat.mBytesPerPacket; // } printf("Writing buffer %lld\n", recordState-&gt;currentPacket); OSStatus status = AudioFileWritePackets(recordState-&gt;audioFile, false, inBuffer-&gt;mAudioDataByteSize, inPacketDescs, recordState-&gt;currentPacket, &amp;inNumberPacketDescriptions, inBuffer-&gt;mAudioData); NSLog(@"DATA = %@",[NSData dataWithBytes:inBuffer-&gt;mAudioData length:inBuffer-&gt;mAudioDataByteSize]); [[NSNotificationCenter defaultCenter] postNotificationName:@"Recording" object:[NSData dataWithBytes:inBuffer-&gt;mAudioData length:inBuffer-&gt;mAudioDataByteSize]]; if (status == 0) { recordState-&gt;currentPacket += inNumberPacketDescriptions; } AudioQueueEnqueueBuffer(recordState-&gt;queue, inBuffer, 0, NULL); } </code></pre> <p>In the above code I have managed to send the inBuffer->mAudioData converted to NSData and send it on the other iPhone. I have also received the same data on the receiver iPhone.</p> <p>But now I do not know how to read this NSData. How to convert this data into an audio format and listen this audio on the speaker. Do I need to use Audio Queues on the receiver side or do I use simple AVPlayer to listen to the sound. If anyone can help solve it would be a great help.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload