Most of my recent blogs are focusing on what you could do with Mobile OSGi. Today I deliver a real practical example for OSGi - in my opinion a pretty exciting case. My colleague Gábor Pécsy has written a first prototype of a DLNA (Digital Living Network Alliance) Media Server that runs on OSGi on various mobile platforms such as Android and Windows Mobile.
For those who are less familiar with DLNA, let me give you a short intro. DLNA is an industry alliance that developed a number of specifications purposed to standardize the interplay of media devices. There are several types of media devices defined such as Digital Media Server, Digital Media Player, Digital Media Controller, etc. As you can imagine, a Media Server is a network instances that serves media content like pictures, videos or music. Likewise, Media Players are devices capable of playing back media content served from Media Servers. The nice thing about DLNA is that devices automatically find each other in the network without the user to be bothered with configuration issues, setting IP addresses, etc. It's a true hot plugging architecture (which is because DLNA is build over UPnP). If you have a Media Player, like a Sony Playstation 3, a Microsoft Xbox, DLNA enabled TV sets, etc. and put a media server to the network, the players will find the server without further doing.
What we did is implementing parts of the DLNA Digital Media Server specification that runs on mobile phones. The use case is that you generate content while you're on the go (i.e. taking pictures or videos) and play that content back on your bigger home screens like the TV or picture frame. Watch this video to get a live demo on how the Sony Playstation and a picture frame plays back your pictures from your phone:
The current version of the Media Server is entirely headless, that's why you don't see any UI on the phone. Future versions of this app will contain a UI on which you can set the server name, your content sharing policies, etc.
Let's zoom into technology. An interesting aspect about this solution is portability. The media server is implemented in Java and on OSGi, thus it is portable over all handsets that support OSGi. Moreover, it leverages the UPnP Service defined in the OSGi Compendium Specification giving it a clean a lean design. Here's a little diagram about the internals of the server:
The Media Server is both network and device agnostic and thus easily portable. It pulls media content though the Media Manager Service. This service we created to abstract media access. The Media Manager Implementation is platform specific. In case of Windows Mobile or Brew the MM Implementation fetches Media Content from the local file system. The target folders are configurable through the OSGi Configuration Admin API which makes this implementation portable. I.e. on Brew the target folders are different and all it takes to port the implementation is to reconfigure the folder strings. On Android another implementation is required that pulls media content through the respective Android APIs. Support for media content types can be plugged into the Media Server by means of meta-data plugins.
A key enabler for this solution is UPnP. The Media Server registers itself as a UPnP device and Service with the OSGi UPnP Service. The UPnP stack then broadcasts the availability of the media server into the Wifi network. Other UPnP enabled devices will pick up the broadcast messages and learn about the presence of the Media Server, it's physical network address and where to find the respective services. As demoed in the video, the Playstation contains this functionality, find the media server and is capable of playing back the picture content it offers.
The implementation is functional already but we will keep working on it. It'll get an end user UI and support for additional content types. Moreover, the UPnP implementation needs enhancements for better handling network drops (in the interest of battery savings smart phones tend to switch off their Wifi modules whenever they think it makes sense...). It should be ready by the time Sprint launches the first OSGi handsets...