3

I want to develop an application that enables the users to do real time audio chatting with each other. I am using rtpstream to implement this. Following is my code. I am using two phones to test my application. The port number to the audio stream is assigned on run-time randomly. This means I have to send the port number from Phone 1 to Phone 2 on run-time to establish a connection.The problem here is that the communication is only one-sided i.e. Phone 1 can talk to Phone 2 but cannot hear Phone 1's reply. What should I do to make it two sided? Also is there any way to assign the port number to audiostream manually? Any help will be appreciated.

audioGroup = new AudioGroup();
audioGroup.setMode(AudioGroup.MODE_NORMAL);
audioStream = new AudioStream(InetAddress.getByAddress(MyIP));
PORT = audioStream.getLocalPort();
audioStream.setCodec(AudioCodec.PCMU);
audioStream.setMode(RtpStream.MODE_NORMAL);
audioStream.associate(InetAddress.getByAddress(ReceiverIP), PORT);
audioStream.join(audioGroup);
AudioManager Audio =  (AudioManager) getSystemService(Context.AUDIO_SERVICE);      
Audio.setMode(AudioManager.MODE_IN_COMMUNICATION);
4

2 回答 2

2

正确的方法是首先设置 RTP Stream,然后获取流正在侦听的端口号,然后在 SIP INVITE 的 SDP 部分中发送该端口。看看这个例子https://github.com/Mobicents/restcomm-android-sdk/tree/master/Examples/JAIN%20SIP

于 2014-10-28T18:31:54.057 回答
0

我正在尝试完成相同的操作,一种可能性是 user1 与 user2 共享他的 ip。两个用户都可以创建一个 audiogroup 和 audiostream 。音频流加入其他用户的音频组。

于 2013-03-21T07:09:03.617 回答