I am currently writing a program that is a sort of VoIP client. I am trying to establish a connection between 2 clients and send and receive data, that is recorded from microphone.
I am currently using files but it looks like an awful implementation:
The recorder starts recording to a temporary file. A timer kicks in, stop the recorder, look at the file size, to then send the content using a DatagramPacket.
It seems awfully bad. I wonder if the MediaRecorder and MediaPlayer class have a way to take a UPD socket as it's file output and input respectively (that is, a DatagramSocket).
I can use a file descriptor from a socket, but sockets uses TCP. I wanted to use UDP, so I guess DatagramSocket, but I can't seem to find a way to use it in my MediaRecorder and MediaPlayer class.
Does anyone please have a good solution for this?
Thank you very much
You are probably interested in a ParcelFileDescriptor, and then specifically the fromDatagramSocket(...) function, then you could use the getFileDescriptor function to set the Datasource of the player
*update: this only works offcourse if you have android 4.0 or higher: see the api limit
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With