Broadcast audiostream to multiple devices

2019-08-02 14:34发布

I am using android AudioStream to communicate between 2 android devices on wifi, both ways. Is there any way to broadcast an audio message on multiple devices, in the same time ?

Is using multiple AudioStreams, one for each device, a possible way? I need to broadcast to 40 receivers. Will the message be delayed if I use multiple AudioStreams ?

Do you know other solutions ?

1条回答
叼着烟拽天下
2楼-- · 2019-08-02 15:18

I think the simplest way is to stream all devices using AudioGroup, you just need to create separate AudioStream for each clients and join them to one AudioGroup. That is it.

AudioGroup audio = new AudioGroup();
audio.setMode(AudioGroup.MODE_NORMAL);
AudioStream stream1 = new AudioStream(yourLocalIP);
stream1.setCodec(AudioCodec.PCMU);
stream1.setMode(RtpStream.MODE_SEND_ONLY);
stream1.associate(firstClientIP, anyport);
stream1.join(audio);

AudioStream stream2 = new AudioStream(yourLocalIP);
stream2.setCodec(AudioCodec.PCMU);
stream2.setMode(RtpStream.MODE_SEND_ONLY);
stream2.associate(secondClientIP, anyport);
stream2.join(audio);
查看更多
登录 后发表回答