While we were busy fixing the server and rendering side of DLNA with Rygel, the guys at Intel OTC are fixing the Client side of DLNA with something called dLeyna, a nice set of APIs to access and maipulate UPnP-AV and DLNA servers / renderers (such as Rygel, of course), so you can easily add DLNA support to your applications, including the obvious server browsing and render remote control, but also the more non-obvious like media pushing, synchronization, server-side playlists. They already prepared a cool set of demos (for example a Firefox extension to send images from your browser to your TV).
So why is this better than using GUPnP for this? Let me show you some examples.
Controlling a renderer
Not much code to see here, you get the usual suspects of player control functions such as start, stop, etc. as well as methods to query device’s capabilities as there are a lot of optional things on UPnP devices.
Well, say you want to upload a file to a server. The code how to do that in GUPnP is available in gupnp-tools and it’s not exactly pretty. With dLeyna, on the other hand, it’s a fewliner:
#!/usr/bin/env python import sys import mediaconsole as mc u = mc.UPNP() d = u.server_from_udn(sys.argv) d.upload_to_any(sys.argv, sys.argv)
In DLNA land, this is called “+UP+”.
Playing a file
Or you want to show some media file you got on your device or app on a DLNA-capable TV? Korva is showing how you can do that with plain GUPnP, again with a lots of lines of code. dLeyna providing a nice and clean solution:
#!/usr/bin/env python import sys import rendererconosle as rc m = rc.Manager() d = m.renderer_from_udn(sys.argv) uri = d.host_file(sys.argv) d.stop() d.open_uri(uri) d.play()
And this is called “+PU+” in DLNA land.
Behind the scenes, this is all GUPnP of course. Currently it consists of two DBus services, dleyna-renderer-service and dleyna-server-service, although other IPC mechanisms are on its way. What happens is that that these two services scan the network for available devices and making them available through a set of DBus interfaces, relieving you from the need of searching for devices yourself (and with that providing a device cache, relieving the network from UDP packet bursts), introspecting the devices for supported capabilities and methods and so on.
If you execute the push script from above you get a python wrapper for the com.intel.dLeynaRenderer.Manager DBus interface, which is then locally looking for the DBus path matching the given UPnP UDN and returning a python object implementing the com.intel.dLeynaRenderer.PushHost and com.intel.dLeynaRenderer.RendererDevice interfaces.
Then we temporarily host the file given on the command-line on dLeyna’s internal HTTP server, stopping the currently running playback (Which translates to RenderingControl:Stop SOAP call), send the URI to the server (RenderingControl:SetAVTransportURI) and last but not least start the playback (RenderingControl:Play) which in the end starts the HTTP streaming from dleyna’s internal HTTP server to (Rygel’s) renderer.
And it doesn’t stop at the application level, there’s even integration with HTML5 through cloudeebus and cloud-dLeyna.
As a sidenote: You might ask how that relates to Grilo’s UPnP-AV support or Korva. This is a very valid question. Grilo and Korva are doing very specific tasks while dLeyna aims to be a more complete SDK. It should be quite easy, for example, to port Grilo’s UPnP-AV suppport to dLeyna.
10 thoughts on “DLNA, client side”
I’m considering to control Rygel’s dmr from a python script given that both are installed on a Rpi.
Have you tried to install dLeyna i a Rpi ? There is not package of dleyna for the raspbian, but It should not be complicated either.
dLeyna should be available on Debian sid if I remember correctly. I’ll have a look at backporting these packages to raspbian and putting them into the Rygel raspbian repository at http://rygel-project.org/raspbian/
Thank a lot !
I didn’t find that much solutions to control a dmr from the same computer. Rygel does not expose himself as a MPRIS device and there is no IPC (dbus) to communicate with dmr plugin of Rygel, is there ?
Keep me posted when you have time to backport dleyna, I would be pleased to test packages 😉
No, there’s no way to communicate with a Rygel renderer than either externally via UPnP or by implementing it yourself (See the fullscreen renderer example https://git.gnome.org/browse/rygel/tree/examples/fullscreen-renderer.c).
Sorry for the delay, I’ve uploaded the dleyna packages to the raspbian repository yesterday
Thanks a lot for the packaging !!! It helped me a lot.
I keep you posted if I find some bug 😉
I added the repo here: http://www.raspbian.org/RaspbianRepository
I reloaded, searched Synaptic for dleyna, no results. Am I missing something?
Will your playing-a-file example work for non-storage devices like Mirror2TV TV dongles?
And with that (after
apt-get update), I get:
I added that repo, but I couldn’t see the packages. After looking around http://vontaene.de/raspbian-updates/ it looks as though those are only arm packages? Are there no Ubuntu Intel 64-bit packages?
Ah yes. That repository is for the raspberry pi only. I can add the packages to our PPA, though.
Comments are closed.