DLNA Media Controller plugin - Common library for UPnP AV

Your initial idea was cool, but your evolv is great ;D

Ok if I don’t missunderstood your request, this is the description of my renderers and a link for the service description xmls grab with Device Spy:

First is GMrender Resurect. This is a Linux shell apps that listen uPnp Request and play Media. (Actually installed on a Raspberry Pi).

Device Description URL : http://192.168.0.123:49494/description.xml
description.xml

Base URL http://192.168.0.123:49494/
Device icon Present, 128x128
Device URN urn:schemas-upnp-org:device:MediaRenderer:1
Embedded devices 0
Expiration timeout 100
Friendly name SalleDeBain
Has presentation True
Manufacturer URL GitHub - hzeller/gmrender-resurrect: Resource efficient UPnP/DLNA renderer, optimal for Raspberry Pi, CuBox or a general MediaServer. Fork of GMediaRenderer to add some features to make it usable.
Model description gmediarender 0.0.7-git
Model name gmediarender
Model number 2013-09-07_9bcc832
Model URL GitHub - hzeller/gmrender-resurrect: Resource efficient UPnP/DLNA renderer, optimal for Raspberry Pi, CuBox or a general MediaServer. Fork of GMediaRenderer to add some features to make it usable.
Presentation URL http://192.168.0.123:49494/
Product code
Proprietary type
Remote endpoint 192.168.0.123:49494
Serial number
Services 3
Standard type
Unique device name GMediaRender-1_0-000-000-002
Version 1.0

Link to services URL, and xml link :

Methods 12
Parent presentation URL http://192.168.0.123:49494/
Parent UDN urn:schemas-upnp-org:device:MediaRenderer:1
Service ID urn:upnp-org:serviceId:AVTransport
Service URL http://192.168.0.123:49494/upnp/rendertransportSCPD.xml
State variables 30
Version 1.0
rendertransportSCPD.xml

Methods 21
Parent presentation URL http://192.168.0.123:49494/
Parent UDN urn:schemas-upnp-org:device:MediaRenderer:1
Service ID urn:upnp-org:serviceId:RenderingControl
Service URL http://192.168.0.123:49494/upnp/rendercontrolSCPD.xml
State variables 21
Version 1.0
rendercontrolSCPD.xml

Methods 4
Parent presentation URL http://192.168.0.123:49494/
Parent UDN urn:schemas-upnp-org:device:MediaRenderer:1
Service ID urn:upnp-org:serviceId:ConnectionManager
Service URL http://192.168.0.123:49494/upnp/renderconnmgrSCPD.xml
State variables 10
Version 1.0
renderconnmgrSCPD.xml

Second is a SONY Blu-ray HomeTheatre :

Device Description URL : http://192.168.0.90:52323/dmr.xml
dmr.xml

Base URL http://192.168.0.90:52323/
Device icon Present, 48x48
Device URN urn:schemas-upnp-org:device:MediaRenderer:1
Embedded devices 0
Expiration timeout 1800
Friendly name BLU-RAY HOME THEATRE SYSTEM
Has presentation True
Interface to host 192.168.0.10
Manufacturer Sony Corporation
Manufacturer URL http://www.sony.net/
Model description
Model name BDV
Model number
Presentation URL http://192.168.0.90:52323/
Product code
Proprietary type
Remote endpoint 192.168.0.90:52323
Serial number
Services 5
Standard type
Unique device name 00000000-0000-1010-8000-544249199c7c
Version 1.0

Link to services URL, and xml link :

Methods 15
Parent presentation URL http://192.168.0.90:52323/
Parent UDN urn:schemas-upnp-org:device:MediaRenderer:1
Service ID urn:upnp-org:serviceId:AVTransport
Service URL http://192.168.0.90:52323/AVTransportSCPD.xml
State variables 33
Version 1.0
AVTransportSCPD.xml

Methods 6
Parent presentation URL http://192.168.0.90:52323/
Parent UDN urn:schemas-upnp-org:device:MediaRenderer:1
Service ID urn:upnp-org:serviceId:RenderingControl
Service URL http://192.168.0.90:52323/RenderingControlBdvSCPD.xml
State variables 7
Version 1.0
RenderingControlBdvSCPD.xml

Methods 3
Parent presentation URL http://192.168.0.90:52323/
Parent UDN urn:schemas-upnp-org:device:MediaRenderer:1
Service ID urn:upnp-org:serviceId:ConnectionManager
Service URL http://192.168.0.90:52323/ConnectionManagerSCPD.xml
State variables 10
Version 1.0
ConnectionManagerSCPD.xml

If I can provide any other help or beta test, please let me know !

Thanks.

[quote=“macfly92, post:21, topic:177228”]Your initial idea was cool, but your evolv is great ;D

Ok if I don’t missunderstood your request, this is the description of my renderers and a link for the service description xmls grab with Device Spy:[/quote]

In fact, what I need is the URL of the device description file. It is the URL opened when you request menu “Get Device XML” in Device Spy.

PS: it is something normally provided by the UPnP discovry process…

Oww Ok, I edited my first post with the Device XML

Merci !

I tested with Windows Media Player and BubbleUPnP renderers this morning and I encountered problems.

I switch to technical discussion. Help is welcome.

Event subscription is working for Windows Media Player and BubbleUPnP.

Problem with Windows Media Player, variables AVTransportURI, AVTransportURIMetaData and CurrentTrackURI are set to “” ! Is it compliant with the UPnP AV standard ?

Problem with BubbleUPnP, value for AVTransportURIMetaData has some characters replaced by code, for example I got < rather than < and > rather than >. I can fix that problem.

[quote=“lolodomo, post:24, topic:177228”]With Windows Media Player and BubbleUPnP, the UPnP request systematically failed with the HTTP code 415. This error code means I am using a bad format ! Two possibilities:
1 - the XML sent is not standard. The XML model is defined by the variable UPNP_REQUEST in L_Sonos1.lua. I see nothing choking.
2 - the content type is not right. In L_Sonos1.lua, it is set by default to “application/x-www-form-urlencoded”. I tried with “application/xml” and “text/xml” with no success. What value has to be used ?[/quote]

SOLVED.
I got my answer checking futzle’s code in WeMo plugin. She uses text/xml; charset=“utf-8” as content type and bingo it works with Windows Media Player and XBMC. I will check with Sonos and BubbleUPnP too and if it works, I will set this content type as new default in L_Sonos1.lua.
Edit: and it is what is defined by the standard.

Glad to see you are making progress.

  • Garrett

New specific problem with BubbleUPnP: UPnP request failed with code 401 and this description: No action by that name at this service. Missing SOAP action header.
I got the same error whatever the action.
Of course, the “Pause” action exists and I can run it through Device Spy.

Here is what is sent:

UPnP_request: url=[http://192.168.1.15:42316/dev/b4e54b11-54bc-7162-ffff-ffffdee3b0aa/svc/upnp-org/AVTransport/action], body=[<?xml version="1.0" encoding="utf-8"?> <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"> <s:Body> <u:Pause xmlns:u="urn:schemas-upnp-org:service:AVTransport:1"><InstanceID>0</InstanceID></u:Pause> </s:Body> </s:Envelope>] <0x302de680>

Any idea what could be wrong ?

Other problem with Windows Media Player, I cannot request UPnP for RenderingControl. I got an error code 402 and the following description: Invalid Args

Here is my request:

50 10/13/13 15:16:54.936 luup_log:446: XBMC: UPnP_request: url=[http://192.168.1.16:2869/upnphost/udhisapi.dll?control=uuid:1cbdde94-4e1f-442c-9613-298d0aec799f+urn:upnp-org:serviceId:RenderingControl], body=[<?xml version="1.0" encoding="utf-8"?> <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"> <s:Body> <u:SetMute xmlns:u="urn:schemas-upnp-org:service:RenderingControl:1"><InstanceID>0</InstanceID><DesiredMute>1</DesiredMute><Channel>Master</Channel></u:SetMute> </s:Body> </s:Envelope>] <0x2f71a680>
I got the same error with SetVolume.

I see nothing wrong.

Is the order of arguments important ? I mean, should I put in my request Channel before DesiredMute ?
What says the standard about that ?

[quote=“lolodomo, post:27, topic:177228”]New specific problem with BubbleUPnP: UPnP request failed with code 401 and this description: No action by that name at this service. Missing SOAP action header.
I got the same error whatever the action.
Of course, the “Pause” action exists and I can run it through Device Spy.

Here is what is sent:

UPnP_request: url=[http://192.168.1.15:42316/dev/b4e54b11-54bc-7162-ffff-ffffdee3b0aa/svc/upnp-org/AVTransport/action], body=[<?xml version="1.0" encoding="utf-8"?> <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"> <s:Body> <u:Pause xmlns:u="urn:schemas-upnp-org:service:AVTransport:1"><InstanceID>0</InstanceID></u:Pause> </s:Body> </s:Envelope>] <0x302de680>

Any idea what could be wrong ?[/quote]

The only difference I can see between your exemple and when I invoked this action with upnp spy is under the envelope opening tag : In Spy, s:encodingStyle is before xmlns:s … I don’t know if it change something or not … But maybe it is the same problem than your second question : Is the order of arguments count ?

POST /dev/88dc63c0-34c9-8eb5-ffff-ffffb33991ec/svc/upnp-org/AVTransport/action HTTP/1.1
HOST: 192.168.xx.xx:47800
SOAPACTION: “urn:schemas-upnp-org:service:AVTransport:1#Pause”
CONTENT-TYPE: text/xml ; charset=“utf-8”
Content-Length: 331

<?xml version="1.0" encoding="utf-8"?>

<s:Envelope s:encodingStyle=“http://schemas.xmlsoap.org/soap/encoding/” xmlns:s=“http://schemas.xmlsoap.org/soap/envelope/”>
<s:Body>
<u:Pause xmlns:u=“urn:schemas-upnp-org:service:AVTransport:1”>
0
</u:Pause>
</s:Body>
</s:Envelope>

How do you see the SOAP message with Device Spy ?

Yes the order is required by the standard and this is a major problem with the vera already discovered by others in the past. The way we manage things cannot guarantee the good order. I have to do it differently.
While I was reading the spec, I got confirmation that only in parameters have to be passed. I will fix that in Sonos plugin.

I will try to inverse the two tags as you propose.

[quote=“lolodomo, post:28, topic:177228”]Other problem with Windows Media Player, I cannot request UPnP for RenderingControl. I got an error code 402 and the following description: Invalid Args

Here is my request:

50 10/13/13 15:16:54.936 luup_log:446: XBMC: UPnP_request: url=[http://192.168.1.16:2869/upnphost/udhisapi.dll?control=uuid:1cbdde94-4e1f-442c-9613-298d0aec799f+urn:upnp-org:serviceId:RenderingControl], body=[<?xml version="1.0" encoding="utf-8"?> <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"> <s:Body> <u:SetMute xmlns:u="urn:schemas-upnp-org:service:RenderingControl:1"><InstanceID>0</InstanceID><DesiredMute>1</DesiredMute><Channel>Master</Channel></u:SetMute> </s:Body> </s:Envelope>] <0x2f71a680>
I got the same error with SetVolume.

I see nothing wrong.

Is the order of arguments important ? I mean, should I put in my request Channel before DesiredMute ?
What says the standard about that ?[/quote]

For this question and after what I’m able to test, I don’t think arguments orders is important :

I managed to get my GmediaRender working with the help of this thread : http://forum.micasaverde.com/index.php?topic=10220.0

And using this LUA test code :

local lul_arguments = {}
lul_arguments[“InstanceID”] = 0
lul_arguments[“DesiredMute”] = “1”
lul_arguments[“Channel”] = “Master”
lul_resultcode, lul_resultstring, lul_job, lul_returnarguments = luup.call_action(“urn:upnp-org:serviceId:RenderingControl”, “SetMute”, lul_arguments, 37)

… produce same result than this one :

local lul_arguments = {}
lul_arguments[“InstanceID”] = 0
lul_arguments[“Channel”] = “Master”
lul_arguments[“DesiredMute”] = “1”
lul_resultcode, lul_resultstring, lul_job, lul_returnarguments = luup.call_action(“urn:upnp-org:serviceId:RenderingControl”, “SetMute”, lul_arguments, 37)

A good old working mutting command :slight_smile:

But I know you do things with a different way, so I’m not sure if it help…

Desole de ne pouvoir aider plus ! Courage !

[quote=“lolodomo, post:30, topic:177228”]How do you see the SOAP message with Device Spy ?

Yes the order is required by the standard and this is a major problem with the vera already discovered by others in the past. The way we manage things cannot guarantee the good order. I have to do it differently.
While I was reading the spec, I got confirmation that only in parameters have to be passed. I will fix that in Sonos plugin.

I will try to inverse the two tags as you propose.[/quote]

Woot ! I can help :slight_smile: To see SOAP message with Spy :

Right click on Pause in AV Transport → Invok Action → Hit Invok Button, then RIGHT CLICK on Invok Button and click on “Show Packet Capture” or F12

You will see the request and the Ack of the renderer.

Unfortunately, I confirm that the order is important for certain UPnP devices. I made a quick and dirty patch to have InstanceID before Channel and Channel before others arguments, and now SetMute and SetVolume are working to control Windows Media Player.
If it worked before for Sonos and XBMC with a wrong order is just because these devices certainly allow any order for arguments, even if the UPnP AV standard requests to use the order defined by the service.
The way UPnP request is done in Sonos makes impossibile to manage a right order. I have to switch to something similar to what has done futzle in WeMo plugin, that is providing an ordered table as parameter.

[quote=“macfly92, post:32, topic:177228”][quote=“lolodomo, post:30, topic:177228”]How do you see the SOAP message with Device Spy ?

Yes the order is required by the standard and this is a major problem with the vera already discovered by others in the past. The way we manage things cannot guarantee the good order. I have to do it differently.
While I was reading the spec, I got confirmation that only in parameters have to be passed. I will fix that in Sonos plugin.

I will try to inverse the two tags as you propose.[/quote]

Woot ! I can help :slight_smile: To see SOAP message with Spy :

Right click on Pause in AV Transport → Invok Action → Hit Invok Button, then RIGHT CLICK on Invok Button and click on “Show Packet Capture” or F12

You will see the request and the Ack of the renderer.[/quote]

Thank you a lot, it will certainly help me a lot.

[quote=“macfly92, post:29, topic:177228”][quote=“lolodomo, post:27, topic:177228”]New specific problem with BubbleUPnP: UPnP request failed with code 401 and this description: No action by that name at this service. Missing SOAP action header.
I got the same error whatever the action.
Of course, the “Pause” action exists and I can run it through Device Spy.

Here is what is sent:

UPnP_request: url=[http://192.168.1.15:42316/dev/b4e54b11-54bc-7162-ffff-ffffdee3b0aa/svc/upnp-org/AVTransport/action], body=[<?xml version="1.0" encoding="utf-8"?> <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"> <s:Body> <u:Pause xmlns:u="urn:schemas-upnp-org:service:AVTransport:1"><InstanceID>0</InstanceID></u:Pause> </s:Body> </s:Envelope>] <0x302de680>

Any idea what could be wrong ?[/quote]

The only difference I can see between your exemple and when I invoked this action with upnp spy is under the envelope opening tag : In Spy, s:encodingStyle is before xmlns:s … I don’t know if it change something or not … But maybe it is the same problem than your second question : Is the order of arguments count ?

POST /dev/88dc63c0-34c9-8eb5-ffff-ffffb33991ec/svc/upnp-org/AVTransport/action HTTP/1.1
HOST: 192.168.xx.xx:47800
SOAPACTION: “urn:schemas-upnp-org:service:AVTransport:1#Pause”
CONTENT-TYPE: text/xml ; charset=“utf-8”
Content-Length: 331

<?xml version="1.0" encoding="utf-8"?>

<s:Envelope s:encodingStyle=“http://schemas.xmlsoap.org/soap/encoding/” xmlns:s=“http://schemas.xmlsoap.org/soap/envelope/”>
<s:Body>
<u:Pause xmlns:u=“urn:schemas-upnp-org:service:AVTransport:1”>
0
</u:Pause>
</s:Body>
</s:Envelope>[/quote]

I found the explanation. We were not surrounding the SOAPACTION with " in the header.

I summarize the work/discovery of the week-end:

[ul][li]
I fixed few things relative to the way UPnP action is requested in the Sonos plugin, in order to be more compliant with the UPnP specification.
[/li]
[li]
A major problem has been discovered, relative to the order of arguments when requesting an UPnP action. I just implemented a dirty and temporary patch to be able to use SetMute and SetVolume
[/li]
[li]
With few things still hardcoded, I am now able to control (basic commands - play, stop, pause, mute, volume) the following Media Renderers: XBMC, Windows Media Player and BubbleUPnP
[/li][/ul]

PS: One problem with BubbleUPnP is that the port to be used always change when you restart the application.

That’s awesome… Keep up the good work!

[quote=“lolodomo, post:36, topic:177228”]I summarize the work/discovery of the week-end:

[ul][li]
I fixed few things relative to the way UPnP action is requested in the Sonos plugin, in order to be more compliant with the UPnP specification.
[/li]
[li]
A major problem has been discovered, relative to the order of arguments when requesting an UPnP action. I just implemented a dirty and temporary patch to be able to use SetMute and SetVolume
[/li]
[li]
With few things still hardcoded, I am now able to control (basic commands - play, stop, pause, mute, volume) the following Media Renderers: XBMC, Windows Media Player and BubbleUPnP
[/li][/ul]

PS: One problem with BubbleUPnP is that the port to be used always change when you restart the application.[/quote]

For Bubble Upnp I’ve seen the same problem, I think unfortunately getting the port is a part of uPnP discovery method … so we can’t blame it…

anyway it is very great work, keep going man !

Great work, lolodomo. It amazes me how fragile most UPnP implementations are. (Well, not really, coughOnkyocough.) I recall hitting several of the issues you encountered as I was writing the WeMo code. It accounts for some of the odd design decisions such as ordered lists of parameter names and values. If only Lua had an order-preserving hash structure…

I’m way out of my depth with respect to the UPnP transport and media discussion. You lot are managing fine without me, so carry on.

Absolutely.

@futzle, @guessed: any idea if we could iimplement the UPnP discovery code ?