Broadcast audiostream to multiple devices

醉酒当歌 提交于 2019-12-11 04:57:09

问题


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:


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);


来源:https://stackoverflow.com/questions/41857076/broadcast-audiostream-to-multiple-devices

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!