I am trying to multicast an audio stream from one device to many others using Android's RTP classes.
I do not want to use any third party libraries if at all possible.
I am able to stream two way audio between two devices using AudioStream
and AudioGroup
set up with each other's IP addresses, but I would like to stream to a multicast group.
If I try to instantiate the AudioStream
with a multicast address such as 239.1.1.1
and then, on the other device use audioStream.associate()
with the same multicast address, but the streams are not heard.
I have read about some Android devices not supporting multicast, but my devices (both Samsung Galaxy Tab 2s) do support it. I have even added the following to my code to try to obtain a multicast lock:
WifiManager wifi = (WifiManager) getSystemService(Context.WIFI_SERVICE);
multicastLock = wifi.createMulticastLock("multicastLock");
multicastLock.setReferenceCounted(true);
multicastLock.acquire();
Additionally I have the following permissions in my manifest file:
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.CHANGE_WIFI_MULTICAST_STATE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />