Author Topic: DLNA Media Controller plugin - Common library for UPnP AV  (Read 187035 times)

Offline macfly92

  • Full Member
  • ***
  • Posts: 132
  • Karma: +1/-0
Re: Common library and services for UPnP AV / DLNA control
« Reply #30 on: October 13, 2013, 11:05:24 am »
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:
Code: [Select]
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 ?

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 :)

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 !
« Last Edit: October 13, 2013, 11:07:53 am by macfly92 »

Offline macfly92

  • Full Member
  • ***
  • Posts: 132
  • Karma: +1/-0
Re: Common library and services for UPnP AV / DLNA control
« Reply #31 on: October 13, 2013, 11:13:04 am »
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.

Woot ! I can help :) 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.

Offline lolodomo

  • Moderator
  • Master Member
  • *****
  • Posts: 3484
  • Karma: +74/-10
Re: Common library and services for UPnP AV / DLNA control
« Reply #32 on: October 13, 2013, 01:33:09 pm »
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.

Offline lolodomo

  • Moderator
  • Master Member
  • *****
  • Posts: 3484
  • Karma: +74/-10
Re: Common library and services for UPnP AV / DLNA control
« Reply #33 on: October 13, 2013, 01:56:26 pm »
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.

Woot ! I can help :) 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.

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

Offline lolodomo

  • Moderator
  • Master Member
  • *****
  • Posts: 3484
  • Karma: +74/-10
Re: Common library and services for UPnP AV / DLNA control
« Reply #34 on: October 13, 2013, 03:16:16 pm »
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:

Code: [Select]
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 ?

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">
         <InstanceID>0</InstanceID>
      </u:Pause>
   </s:Body>
</s:Envelope>

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

Offline lolodomo

  • Moderator
  • Master Member
  • *****
  • Posts: 3484
  • Karma: +74/-10
Re: Common library and services for UPnP AV / DLNA control
« Reply #35 on: October 13, 2013, 04:05:29 pm »
I summarize the work/discovery of the week-end:
  • 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.
  • 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
  • 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

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

Offline fhreid

  • Sr. Newbie
  • *
  • Posts: 21
  • Karma: +0/-0
Re: Common library and services for UPnP AV / DLNA control
« Reply #36 on: October 13, 2013, 04:20:35 pm »
That's awesome..  Keep up the good work!

Offline macfly92

  • Full Member
  • ***
  • Posts: 132
  • Karma: +1/-0
Re: Common library and services for UPnP AV / DLNA control
« Reply #37 on: October 13, 2013, 04:22:26 pm »
I summarize the work/discovery of the week-end:
  • 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.
  • 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
  • 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

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

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 !

Offline futzle

  • Beta Testers
  • Master Member
  • *****
  • Posts: 3254
  • Karma: +190/-9
Re: Common library and services for UPnP AV / DLNA control
« Reply #38 on: October 13, 2013, 05:26:17 pm »
Great work, lolodomo. It amazes me how fragile most UPnP implementations are. (Well, not really, *cough*Onkyo*cough*.)  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.

Offline lolodomo

  • Moderator
  • Master Member
  • *****
  • Posts: 3484
  • Karma: +74/-10
Re: Common library and services for UPnP AV / DLNA control
« Reply #39 on: October 14, 2013, 10:18:23 am »
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...

Absolutely.

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

Offline guessed

  • Master Member
  • *******
  • Posts: 5293
  • Karma: +90/-22
  • Release compat is not a bolted-on afterthought
Re: Common library and services for UPnP AV / DLNA control
« Reply #40 on: October 14, 2013, 12:18:09 pm »
It's doable.  Would likely need to be in a freestanding (non Vera) codebase, like @futzle's codebase, for flexibility but the components are all there.

Offline macfly92

  • Full Member
  • ***
  • Posts: 132
  • Karma: +1/-0
Re: Common library and services for UPnP AV / DLNA control
« Reply #41 on: October 14, 2013, 01:12:35 pm »
It's doable.  Would likely need to be in a freestanding (non Vera) codebase, like @futzle's codebase, for flexibility but the components are all there.

Mhhh it's very interesting thing ... maybe we must think again on the concept.

What do you think about a Little program in Java (for ex.) running in daemon, that do Upnp Controller's work and provide to each other component (Vera, Openremote and other) an Json API ....

It must be pretty doable with the famous Cling Library (http://4thline.org/projects/cling/) ...

I think it will be more flexible, more "standardized  method" (more software are compatibles with REST method...) and without Vera restriction and overload ...

I will look forward into it, but i'm very far of an appkiller developer ... or maybe someone know if something like this already exist ?

Offline garrettwp

  • Beta Testers
  • Master Member
  • *****
  • Posts: 6371
  • Karma: +227/-128
  • Vera 3, Lite, ISY994
Re: Common library and services for UPnP AV / DLNA control
« Reply #42 on: October 14, 2013, 01:19:16 pm »
You have to release that the programming languages on Vera are very limited. You are pretty much restricted to using lua with out installing other software dependencies.

- Garrett

Offline macfly92

  • Full Member
  • ***
  • Posts: 132
  • Karma: +1/-0
Re: Common library and services for UPnP AV / DLNA control
« Reply #43 on: October 14, 2013, 01:30:48 pm »
Sure about that, but I'm talking about a software that can running on another computer to help Vera (and other in the same time) to handle Media oriented upnp...

It can be your MediaServer or a little Raspberry Pi or something like this.

Not a vera Plugin, but a Vera companion :) but It's true it's going away from the vera plugin concept ...

Offline guessed

  • Master Member
  • *******
  • Posts: 5293
  • Karma: +90/-22
  • Release compat is not a bolted-on afterthought
Re: Common library and services for UPnP AV / DLNA control
« Reply #44 on: October 14, 2013, 01:41:09 pm »
That's certainly one style of integration, but once you do that you might a well dump Vera altogether (apart from, say, lock support) since you'd end up running both devices.

If you're interested in that type of thing, check out the OpenHAB project.  Just haven't had enough time to cutover yet, runs on Raspi, Mac, etc... And there are a few other Arm based devices getting Java also, with a bunch if RAM so should get interesting in next 6mth of so.