Sending a video content to a DLNA/UPnP software/device using curl

June 21st, 2013

The purpose of this article is to explain how to push the video content captured through AirPlay to a DLNA/UPnP renderer like XBMC. The technique applies to both mobile and desktop applications. curl is used to perform the task so that the reader can easily test it. It is a short guide and I encourage you to review the UPnP/DLNA specifications to get an exhaustive understanding of this logic.

UPnP (Universal Plug and Play) is a networking standard. One of its core capability is to facilitate the discovery of intelligent devices available on the network through its Simple Service Discovery Protocol (SSDP). In theory, with UPnP, you can play or share media anytime you want and anywhere you are.

DLNA is another standard that derives from UPnP. Basically, once a product is DLNA certified, it implies that the device/software is a UPnP device that meets a minimum of requirements. So DLNA can be losely viewed as a more restrictive “subgroup” of UPnP. The objective of DLNA is to ensure full interoperability between compliant devices.

As mentioned earlier, to replicate what is being done in this article, you just need curl and XBMC.

First, you need to identify potential renderers on your network. In our case, we already know that XBMC should be able to answer our requests but let’s pretend that we did not know and let’s run XBMC. As mentioned earlier, all UPnp/DLNA devices announce their availability thanks to SSDP. All you need to do is “ask” these renderers to let you know that they are available by sending a UDP message to the multicast address on port 1900:

MX: 5
Man: “ssdp:discover”
ST: urn:schemas-upnp-org:device:MediaRenderer:1

You should get back something like:

HTTP/1.1 200 OK
Cache-Control: max-age=1800
Server: UPnP/1.0 DLNADOC/1.50 Platinum/
USN: uuid:37f3d9871-b0f7-cd72-1741-86a55e55fce0::urn:schemas-upnp-org:device:MediaRenderer:1
ST: urn:schemas-upnp-org:device:MediaRenderer:1

Next, if you use the Location to query the renderer, you will get a description of the devices and the services that it supports:

<?xml version=”1.0″ encoding=”UTF-8″?>
<root xmlns=”urn:schemas-upnp-org:device-1-0″ xmlns:dlna=”urn:schemas-dlna-org:device-1-0″>
<friendlyName>XBMC (kmer)</friendlyName>
<manufacturer>Team XBMC</manufacturer>
<modelDescription>XBMC Media Center – Media Renderer</modelDescription>
<modelName>XBMC Media Center</modelName>
<modelNumber>13.0-ALPHA4 Git:20130518-0da9a79</modelNumber>

What we are interested in is the AVTransport service which enables to send play and stop instructions to the renderer. Retrieve the controlURL. Mine looks like:


It takes two calls to the renderer to play a video content. The first call to “load” the content and the second call to “play” the content.

Assuming that you have a video content with the url, then you load the content by executing the following command:

curl -H ‘Content-Type: text/xml; charset=utf-8′ -H ‘SOAPAction: “urn:schemas-upnp-org:service:AVTransport:1#SetAVTransportURI”‘ -d ‘<?xml version=”1.0″ encoding=”utf-8″?><s:Envelope s:encodingStyle=”” xmlns:s=””><s:Body><u:SetAVTransportURI xmlns:u=”urn:schemas-upnp-org:service:AVTransport:1″><InstanceID>0</InstanceID><CurrentURI><![CDATA[]]></CurrentURI><CurrentURIMetaData></CurrentURIMetaData></u:SetAVTransportURI></s:Body></s:Envelope>’ ‘

Next, we want to play it:

curl -H ‘Content-Type: text/xml; charset=utf-8′ -H ‘SOAPAction: “urn:schemas-upnp-org:service:AVTransport:1#Play”‘ -d ‘<?xml version=”1.0″ encoding=”utf-8″?><s:Envelope s:encodingStyle=”” xmlns:s=””><s:Body><u:Play xmlns:u=”urn:schemas-upnp-org:service:AVTransport:1″><InstanceID>0</InstanceID><Speed>1</Speed></u:Play></s:Body></s:Envelope>’ ‘

That’s it!

Adam Behnke

Adam is a mobile/web developer for Accella who has been developing telecom and web applications since the mid-90's, before the dot-com bust. With a heavy telecom background, Adam can speak fluently in 3GPP, ASN.1, SS7, and SIGTRAN as well.

3 Responses to “Sending a video content to a DLNA/UPnP software/device using curl”

  1. Vedder says:

    Can you give the curl command for sending the first query ?

  2. OvSleep says:

    Hey wteku! Awesome post. I’m trying to play around with dlna/upnp to stream content from my Pi to my TV through my phone (why?… b/c we can!). I know the info on this post is what I need, but it has some gaps (maybe obvious) that I can’t understand. For example, when you say “…by sending a UDP message to the multicast address on port 1900…”
    How can I do that? from command line using “curl”, or do I need something else to do that?
    And when you say: “…Next, if you use the Location to query the renderer, you will get a description of the devices and the services that it supports…”
    How do I use the Location to get that response?


  3. Michael Murphy says:


    Would this work also for audio songs on a NAS drive?

    e.g. sending song from NAS to a media renderer/streamer?

    Comments appreciated

Leave a Reply