I simply want to capture audio on my android and stream it over a socket to another server. Everything works as it should except that the file is not readable on the other end.
After some testing and file comparisons, it appears that when writing audio data to a file, MediaRecorder will update the header at some point, possibly when recording is completed. I don't know if it is the codec or the format that specifies this. The issue becomes apparent when using a FileDescriptor to write to a socket. Obviously the header updates can not happen after the data is written to the socket.
I have read many other posts about streaming audio/video over a socket and have not encounter anyone talking about this issue. Maybe I need to change the format or the codec to something that doesn't require going back and updating the header?
mediaRecorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
mediaRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AAC);