5

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" />
Nova Entropy
  • 5,727
  • 1
  • 19
  • 32

1 Answers1

4

After looking into this a lot, I have discovered that the RTP classes do support sending multicast, but not receiving. Presumably this is because the sockets that get used are not MulticastSockets.

Also, for those interested, the Tab 2 is in fact one of the devices that doesn't support joining multicast groups (i.e. it does not send IGMP join packets), but if you set up static multicast groups in your network infrastructure, then the packets will be received - hence why I mentioned above that I knew that they do support it.

A quick way of seeing if an Android device supports joining multicast groups is by looking for the presence of the /proc/net/igmp file.

Nova Entropy
  • 5,727
  • 1
  • 19
  • 32
  • do you know can the RtpStream associate() with multiple targets? i'm wondering why the document of AudioStream said it can make conference call? seems there is no example for call conferencing – Amos Nov 01 '18 at 03:20
  • if the RtpStream associate() do not support multiple targets, that means there should be 1 AudioStream for 1 remote endpoint, i.e. there are 10 remote endpoints, there are 10 AudioStream run at the same time, seems this will draw all the system resources... – Amos Nov 01 '18 at 03:39