Can u please tell me how this can be done ? recording the audio on one device & playing on other (VoIP) ?
I m stuck here: I m getting the input voice data on one device in this function
void AQRecorder::MyInputBufferHandler( void * inUserData,
AudioQueueRef inAQ,
AudioQueueBufferRef inBuffer,
const AudioTimeStamp * inStartTime,
UInt32 inNumPackets,
const AudioStreamPacketDescription* inPacketDesc)
{
AQRecorder *aqr = (AQRecorder *)inUserData;
try {
if (inNumPackets > 0) {
// write packets to file
XThrowIfError(AudioFileWritePackets(aqr->mRecordFile, FALSE, inBuffer->mAudioDataByteSize,
inPacketDesc, aqr->mRecordPacket, &inNumPackets, inBuffer->mAudioData),
"AudioFileWritePackets failed");
//inData = inBuffer->mAudioData;
aqr->mRecordPacket += inNumPackets;
aqr->updateIndata(inBuffer);
}
// if we're not stopping, re-enqueue the buffe so that it gets filled again
if (aqr->IsRunning())
XThrowIfError(AudioQueueEnqueueBuffer(inAQ, inBuffer, 0, NULL), "AudioQueueEnqueueBuffer failed");
} catch (CAXException e) {
char buf[256];
fprintf(stderr, "Error: %s (%s)\n", e.mOperation, e.FormatError(buf));
}
}
and I m sending the packets to UDP:
void AQRecorder::updateIndata(AudioQueueBufferRef inBuffer)
{
SpeakHereAppDelegate *appDelegate = [[UIApplication sharedApplication] delegate];
NSData *audioBytes = [NSData dataWithBytes:inBuffer->mAudioData
length:inBuffer->mAudioDataByteSize];
NSLog(@"bytes: %d", [audioBytes length]);
[appDelegate.udpSocket sendData:audioBytes
toHost:appDelegate.host
port:appDelegate.port
withTimeout:-1
tag:1];
}
& I'm receving the data on other end as NSData but don't know how to play, Can u please help