开发者

Android: Implementing a VoIP program

开发者 https://www.devze.com 2023-01-24 18:56 出处:网络
I have some design questions that I want to discuss with people interested in helping me. I am planning to develop a simple VoIP program that allows two Android phones in the same network to use VoIP.

I have some design questions that I want to discuss with people interested in helping me. I am planning to develop a simple VoIP program that allows two Android phones in the same network to use VoIP. My goal is simply to capture sound, send the data with UDP, receive UDP data and play sound.

My current design is to have 2 th开发者_运维技巧reads: one captures the microphone and sends the data; the other one receives bytes and plays them.

I was starting to implement that using MediaPlayer and MediaRecorder. The issue that came up is how do I record and play sound? By that, I would like to know if I need to use a file, although that seems slow, or if there is anyway to have the recording automatically sent to my UDP socket please?

Basically, I wonder if I have to record to a file, then to be able to play it, or if I could just pass a socket (for recording and playing).

Does anyone has any suggestion please?

Thank you very much


MediaRecorder needs an FD so, you can use sockets as well. I dont see any issues with that. It all depends on how you would design your system.


Don't use those classes for streaming audio - use AudioTrack and AudioRecord instead.

They provide the functionality you need for playing and recording raw audio data, without dealing with an FD.

When you record a frame (either byte[] or short[]), wrap it with a UDP packet. When you receive a UDP packet, unpack the relevant byte[] or short[] and play it.

0

精彩评论

暂无评论...
验证码 换一张
取 消