Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does Android's RTP library support multicast?

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" />
like image 575
tristan2468 Avatar asked Oct 03 '22 20:10

tristan2468


1 Answers

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.

like image 194
tristan2468 Avatar answered Oct 07 '22 19:10

tristan2468