MediaRecorder and UDP (DatagramSocket) on Android

I am currently writing a program that is a kind of VoIP client. I am trying to establish a connection between two clients and send and receive data recorded from a microphone.

I am currently using files, but it looks like a terrible implementation:

The recorder starts recording to a temporary file. The timer starts, stops the recorder, looks at the file size, and then sends the content using DatagramPacket.

It seems terribly bad. I wonder if the MediaRecorder and MediaPlayer classes have a way to use an UPD socket, as it outputs and enters the file accordingly (i.e. DatagramSocket).

I can use a file descriptor from a socket, but sockets use TCP. I wanted to use UDP, so I think DatagramSocket, but I can’t find a way to use it in my MediaRecorder and MediaPlayer class.

Does anyone have a good solution for this?

Many thanks

+5
source share
2 answers

You might be interested in ParcelFileDescriptor and then fromDatagramSocket (...) function , then you can use getFileDescriptor function to set player data source

* update: this only works in disconnected mode if you have Android 4.0 or higher: see api limitation

+3
source

All,

- , LocalServerSocket ( UNIX ). LocalSocket, LocalServerSocket. FileDescriptor LocalSocket OutputFile MediaRecorder. LocalSocket, DatagramSocket. Ez Pz.

, -Rad

0

All Articles