DLNA Media Server for Android

Recently we had a project at Onirica about creating/porting a DLNA Media Server for/to the Android platform. It was a good choice to start playing with the Android platform as it allowed us to evaluate several things:

  • Android APIs usage (UI, Activities, Services, Content Providers, …)
  • Effort to port existing java code to Android
  • Android tools

As our intention was not re-invent the wheel, we looked for some available Media Servers coded in Java to re-use and we found two:

The main problem with ps3mediaserver (that is the one I use at home) was that it was too oriented to transcoding and the code was not abtracted enough to get only the DLNA/upnp bits. The main problem with Cidero Server was that it was not serving local files at all, only links to internet radio stations, so one of the main functionalities was missing. Finally we choose to take the Cidero code, adapt it to the android platform, implement the missing parts and code the android specific parts.
The adapt/port process included:

  • Adding a hook for opening local files (originally included in the .jar file) to use through android R.raw
  • Replace the Xerces based parsing code with the XML stack available in Android

And the new bits we had to implement:

  • http transfer for local files, including 206 Partial-Content support
  • Scanning android MediaStore providers to get info (size, duration, title, mime types, etc…) from the content and add it to the server
  • Minimal UI
  • Activity and Service

As in every software development process we found some unexpected problems:

  • Android emulator does not support multicast. UPnP servers use SSDP packets to announce the server in the local network using a multicast address. It was not trivial to solve: we had to create a dummy server doing only the SSDP announce outside the emulator and port redirection (android redir inside the amulator and rinetd on the host) so the clients in our local network could access the server
  • Unexpected bugs on the android SDK

But finally the application is working nicely:

click on the image to view a demo video

This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *