How do I encode audio to u-law g.711? Then send that audio to a remote server via http.
AUDIO STREAM: Send a continuous stream of audio to the
currently viewed camera. Audio needs to be encoded at G711 mu-law at
64 kbit/s for transfer to the Axis camera at the bedside. send (this
should be a POST URL in SSL to connected server): POST
/transmitaudio?id= Content-type: audio/basic
Content-Length: 99999 (length is ignored)
I have searched on google and on here but mostly what I find are ways to stream from a server to an I device and not the other way around. I did find this posting (http://stackoverflow.com/questions/7750329/how-to-send-audio-file-through-http-post-to-a-server-from-ios) however it seems likes the answers are not very descriptive nor has any of them been accepted.
Here is what I have so far.
{
NSNumber *formatObject;
switch (self.recordEncoding) {
case (ENC_AAC):
formatObject = [NSNumber numberWithInt: kAudioFormatMPEG4AAC];
break;
case (ENC_ALAC):
formatObject = [NSNumber numberWithInt: kAudioFormatAppleLossless];
break;
case (ENC_IMA4):
formatObject = [NSNumber numberWithInt: kAudioFormatAppleIMA4];
break;
case (ENC_ILBC):
formatObject = [NSNumber numberWithInt: kAudioFormatiLBC];
break;
case (ENC_ULAW):
formatObject = [NSNumber numberWithInt: kAudioFormatULaw];
break;
default:
formatObject = [NSNumber numberWithInt: kAudioFormatAppleIMA4];
}
[recordSettings setObject:formatObject forKey: AVFormatIDKey];
[recordSettings setObject:[NSNumber numberWithFloat:44100.0] forKey: AVSampleRateKey];
[recordSettings setObject:[NSNumber numberWithInt:2] forKey:AVNumberOfChannelsKey];
[recordSettings setObject:[NSNumber numberWithInt:12800] forKey:AVEncoderBitRateKey];
[recordSettings setObject:[NSNumber numberWithInt:16] forKey:AVLinearPCMBitDepthKey];
[recordSettings setObject:[NSNumber numberWithInt: AVAudioQualityHigh] forKey: AVEncoderAudioQualityKey];
}
This appears to be U-law (hence the name of the encode), however I know nothing about audio codecs and dont know if G711 mu-law is even possible on ios.
How do I get my audio encoded in the right format?
Then how to send that encoded audio to the server? Right now I have it going to a temporary file location but even if I changed that I dont see how that would help. I know this is alot to ask for and I’m not looking to have an answer given to me, but I need a place to start because at the moment I’m fairly lost as to how to do this.
This sends the audio after it is done recording