将音频流广播到多个设备

将音频流广播到多个设备

本文介绍了将音频流广播到多个设备的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用android AudioStream在wifi上的两个android设备之间进行双向通信.有什么办法可以同时在多个设备上播放音频消息?

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 ?

是否正在使用多个AudioStreams(一种用于每个设备),一种可能的方式?我需要向40位接收者广播.如果我使用多个AudioStreams,消息是否会延迟?

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 ?

推荐答案

我认为最简单的方法是使用AudioGroup传输所有设备,您只需要为每个客户端创建单独的AudioStream并将它们加入一个AudioGroup.就是这样.

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

这篇关于将音频流广播到多个设备的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-18 15:01