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

Offline lolodomo

  • Moderator
  • Master Member
  • *****
  • Posts: 3484
  • Karma: +74/-10
Re: DLNA Media Controller plugin - Common library for UPnP AV
« Reply #210 on: November 16, 2013, 07:46:03 am »
With a file "sc?ne.mov", playback is not starting but I found no UPnP error. The URI returned by XBMC is ... /sc%25e8ne.mov

Same file content but named "scene.mov" works well. The URI returned by XBMC is .../scene.mov

%25 seems to be an escape of %.
Even if I first unescape the URL, leading to URI .../sc%e8ne.mov, it does not work.

Offline lolodomo

  • Moderator
  • Master Member
  • *****
  • Posts: 3484
  • Karma: +74/-10
Re: DLNA Media Controller plugin - Common library for UPnP AV
« Reply #211 on: November 16, 2013, 07:58:43 am »
With a file "sc?ne.mov", playback is not starting but I found no UPnP error. The URI returned by XBMC is ... /sc%25e8ne.mov

Same file content but named "scene.mov" works well. The URI returned by XBMC is .../scene.mov

%25 seems to be an escape of %.
Even if I first unescape the URL, leading to URI .../sc%e8ne.mov, it does not work.

The problem could be that UPnP is waiting for a UTF-8 encoding ?
c3a8 would be the right UTF-8 corresponding code.

Offline lolodomo

  • Moderator
  • Master Member
  • *****
  • Posts: 3484
  • Karma: +74/-10
Re: DLNA Media Controller plugin - Common library for UPnP AV
« Reply #212 on: November 16, 2013, 08:43:35 am »
With a file "sc?ne.mov", playback is not starting but I found no UPnP error. The URI returned by XBMC is ... /sc%25e8ne.mov

Same file content but named "scene.mov" works well. The URI returned by XBMC is .../scene.mov

%25 seems to be an escape of %.
Even if I first unescape the URL, leading to URI .../sc%e8ne.mov, it does not work.

The problem could be that UPnP is waiting for a UTF-8 encoding ?
c3a8 would be the right UTF-8 corresponding code.

When creating the SOAP message (XML) for SetAVTransportURI, I tried to replace %e8 by è
Still not working.

Of course, this file is working when selected directly using the XBMC application.
I don't understand what expects XBMC and how to handle special characters.

Offline fhreid

  • Sr. Newbie
  • *
  • Posts: 21
  • Karma: +0/-0
Re: DLNA Media Controller plugin - Common library for UPnP AV
« Reply #213 on: November 16, 2013, 08:46:01 am »
Hi lolodomo:

Forgive me for being somewhat vague and convoluted about creating a scene before.

The basic scenario is this:  Create a scene that will pause my XBMC.  I tried using advanced tab "SetPlayerStatus" to "Pause" to no avail.

The Upnp control is disabled in the the Selection GUI so I can't simply click the pause button.

I believe I have all the files installed correctly as the plug functions.  I have tried this in Chrome as well as IE.

Hope this clears up my issue somewhat.  Any help would be great as this is one use of this plug that I'm pretty excited about

Thanks again

Offline lolodomo

  • Moderator
  • Master Member
  • *****
  • Posts: 3484
  • Karma: +74/-10
Re: DLNA Media Controller plugin - Common library for UPnP AV
« Reply #214 on: November 16, 2013, 09:03:46 am »
Hi lolodomo:

Forgive me for being somewhat vague and convoluted about creating a scene before.

The basic scenario is this:  Create a scene that will pause my XBMC.  I tried using advanced tab "SetPlayerStatus" to "Pause" to no avail.

I am sorry but I still don't understand where you find something named "SetPlayerStatus" in the scene editor.
No action is named like this in the 3 service files I provide.

Do you have other installed service files of type ...AVTransport:1 or ...RenderingControl:1.
As it was explained by others, it is absolutely a case to avoid with the Vera.
What other plugins have you installed ?

Quote
The Upnp control is disabled in the the Selection GUI so I can't simply click the pause button.

What do you mean by Selection GUI ?

Please provide screenshots because I don't understand where you are, even if we use the same ui :)
« Last Edit: November 16, 2013, 10:27:59 am by lolodomo »

Offline a-lurker

  • Hero Member
  • *****
  • Posts: 831
  • Karma: +57/-8
Re: DLNA Media Controller plugin - Common library for UPnP AV
« Reply #215 on: November 16, 2013, 03:38:37 pm »
I think what people are saying, is that the buttons of the player, both in the DLNA plugin and Sonos plugin, are grayed out in the Scene Editor and can't be selected for use in a scene - see graphic. In the associated json file(s) immediately below this line:

Code: [Select]
"halloIconsDir": "pics/hallo",
you can enable the buttons to be selected in the Scene Editor using this:

Code: [Select]
"inScene": "1",

Offline a-lurker

  • Hero Member
  • *****
  • Posts: 831
  • Karma: +57/-8
Re: DLNA Media Controller plugin - Common library for UPnP AV
« Reply #216 on: November 16, 2013, 04:02:12 pm »
Quote
Another thing is that my code still does not communicate with the connection manager of the DMR. As I understood, the normal way would be to ask the connection manager for a new AVTransport instance ... and then use this instance ID. I systematically use instance ID 0.

May be this is why I'm having problems. I can't get the Yamaha AVR to do anything until I use another control point to start it up. Then it works (roughly).

On the mime-types:
I can play this on my Sonos stuff and on the Yamaha I can select this radio station from it own station list and play it. But I get a mime-type error using the plugin. May be because its a stream, rather than a file?

x-rincon-mp3radio://www.live365.com/play/opost57chevy

Last thing - after messing around - the Proxy plugin now says it "Not running" but my WeMo still works. Luup engine restarts make no difference. Get this every 40 seconds or so in the log. May be Futzle can explain what makes this occur and if I can do any further tests on it, before doing a hard reset of Vera.

Code: [Select]
06 11/17/13 7:47:24.135 Device_Variable::m_szValue_set device: 69 service: urn:futzle-com:serviceId:UPnPProxy1 variable: Status was: 0 now: 0 #hooks: 0 upnp: 0 v:0xb64518/NONE duplicate:1 <0x2e6dd680>
06 11/17/13 7:47:24.136 Device_Variable::m_szValue_set device: 69 service: urn:futzle-com:serviceId:UPnPProxy1 variable: StatusText was: Not Running now: Not Running #hooks: 0 upnp: 0 v:(nil)/NONE duplicate:1 <0x2e6dd680>

Keep up the good work.

Offline futzle

  • Beta Testers
  • Master Member
  • *****
  • Posts: 3252
  • Karma: +190/-9
Re: DLNA Media Controller plugin - Common library for UPnP AV
« Reply #217 on: November 16, 2013, 08:51:24 pm »
URL escaping of non-ASCII characters has to follow a strict order. First the characters must be expressed as a UTF-8 byte sequence. Then each byte is percent-encoded if it needs to be. To put "sc?ne" into a URL you will say "sc%C3%A8ne".

Unfortunately, many implementations get this wrong, because developers don't test it, or because they conflate URL escaping with HTML escaping, or conflate characters with bytes. It's often very hard to tell who is at fault in any given example: the one in this thread is a classic demonstration of it.

My rule of thumb is that when dealing with the web, it is not sufficient to claim that you are OK because you are 8-bit clean. You _must_ respect Unicode.

Offline a-lurker

  • Hero Member
  • *****
  • Posts: 831
  • Karma: +57/-8
Re: DLNA Media Controller plugin - Common library for UPnP AV
« Reply #218 on: November 16, 2013, 11:53:16 pm »
It's a miracle anything gets through the net! Also the Javascript escape() has been deprecated - as seen in DLNA_playUri() and Sonos_playUri():

http://stackoverflow.com/questions/75980/best-practice-escape-or-encodeuri-encodeuricomponent

This begs the question in the plugin UI on the Player tab - what should be typed into the URI entry field. A plain string or a percent escaped string? If it's a plain string then what happens if you plug in a percent escaped string? So far I've seen no difference in the result.

« Last Edit: November 17, 2013, 04:29:14 am by a-lurker »

Offline lolodomo

  • Moderator
  • Master Member
  • *****
  • Posts: 3484
  • Karma: +74/-10
Re: DLNA Media Controller plugin - Common library for UPnP AV
« Reply #219 on: November 17, 2013, 05:26:00 am »
URL escaping of non-ASCII characters has to follow a strict order. First the characters must be expressed as a UTF-8 byte sequence. Then each byte is percent-encoded if it needs to be. To put "sc?ne" into a URL you will say "sc%C3%A8ne".

I think you're clearly in the right direction because when I select my file in XBMC, then what I see in the Vera in the received metada is a file name with c3a8.

What is this codage (c3a8) ?
Remember that when I browse the server, I got a HTTP URL with %25e8.
What character shall I put in the URL before c3a8 ?
How convert from my URL with %25e8 to the new URL including code c3a8 ?
And when I produce the XML SOAP message (UPnP request), do I have to do another conversion ?

Thanks for your help, I am clearly lost...
« Last Edit: November 17, 2013, 06:20:18 am by lolodomo »

Offline lolodomo

  • Moderator
  • Master Member
  • *****
  • Posts: 3484
  • Karma: +74/-10
Re: DLNA Media Controller plugin - Common library for UPnP AV
« Reply #220 on: November 17, 2013, 05:41:21 am »
I think what people are saying, is that the buttons of the player, both in the DLNA plugin and Sonos plugin, are grayed out in the Scene Editor and can't be selected for use in a scene - see graphic. In the associated json file(s) immediately below this line:

Code: [Select]
"halloIconsDir": "pics/hallo",
you can enable the buttons to be selected in the Scene Editor using this:

Code: [Select]
"inScene": "1",

Ok, thank you, a drawing is always better, like we said in French.
I will enable it. As you said, it is normally only adding this line.

PS: but it clearly does not explain the mysterious "SetPlayerStatus" which is not present in thsi window too.
« Last Edit: November 17, 2013, 06:16:07 am by lolodomo »

Offline lolodomo

  • Moderator
  • Master Member
  • *****
  • Posts: 3484
  • Karma: +74/-10
Re: DLNA Media Controller plugin - Common library for UPnP AV
« Reply #221 on: November 17, 2013, 05:56:33 am »
Quote
Another thing is that my code still does not communicate with the connection manager of the DMR. As I understood, the normal way would be to ask the connection manager for a new AVTransport instance ... and then use this instance ID. I systematically use instance ID 0.

May be this is why I'm having problems. I can't get the Yamaha AVR to do anything until I use another control point to start it up. Then it works (roughly).

You have to keep the other control point running ?
Or you just starts it and then kill it, and then it is working in the Vera ?

Quote
On the mime-types:
I can play this on my Sonos stuff and on the Yamaha I can select this radio station from it own station list and play it. But I get a mime-type error using the plugin. May be because its a stream, rather than a file?

x-rincon-mp3radio://www.live365.com/play/opost57chevy

A I explained in another post, you cannot use Sonos as a server because Sonos provides URI that can be played only by Sonos.
But just try this URL: http://www.live365.com/play/opost57chevy and it will work (works with XBMC as DMR).

Quote
Last thing - after messing around - the Proxy plugin now says it "Not running" but my WeMo still works. Luup engine restarts make no difference. Get this every 40 seconds or so in the log. May be Futzle can explain what makes this occur and if I can do any further tests on it, before doing a hard reset of Vera.

Code: [Select]
06 11/17/13 7:47:24.135 Device_Variable::m_szValue_set device: 69 service: urn:futzle-com:serviceId:UPnPProxy1 variable: Status was: 0 now: 0 #hooks: 0 upnp: 0 v:0xb64518/NONE duplicate:1 <0x2e6dd680>
06 11/17/13 7:47:24.136 Device_Variable::m_szValue_set device: 69 service: urn:futzle-com:serviceId:UPnPProxy1 variable: StatusText was: Not Running now: Not Running #hooks: 0 upnp: 0 v:(nil)/NONE duplicate:1 <0x2e6dd680>

Keep up the good work.

Unfortunately, I discovered that the proxy is sometimes crashing.
I have not checked if the state on the device is updated when it happens, but you can at least execute this command to check whether the proxy is alive:
Code: [Select]
ps -ef | grep upnpWhen it happens, I run these commands:
Code: [Select]
cd /etc/init.d
./upnp-proxy-daemon start
and then restarts lua.
You have to be sure that the device that is causing the crash has been stopped first. If not, it will probably send the same notification causing the proxy crash, and the proxy will crash again.

I never experiment any proxy crash until I start to debug my current problem with file name with french accents. XBMC was apparently the source of the proxy crash.
Sonos never crashes the proxy.
« Last Edit: November 17, 2013, 06:22:32 am by lolodomo »

Offline lolodomo

  • Moderator
  • Master Member
  • *****
  • Posts: 3484
  • Karma: +74/-10
Re: DLNA Media Controller plugin - Common library for UPnP AV
« Reply #222 on: November 17, 2013, 06:09:32 am »
It's a miracle anything gets through the net! Also the Javascript escape() has been deprecated - as seen in DLNA_playUri() and Sonos_playUri():

http://stackoverflow.com/questions/75980/best-practice-escape-or-encodeuri-encodeuricomponent

This begs the question in the plugin UI on the Player tab - what should be typed into the URI entry field. A plain string or a percent escaped string? If it's a plain string then what happens if you plug in a percent escaped string? So far I've seen no difference in the result.

Yes, escape is required because if not done, the received URL by the called lua function is truncated at the first &.
Writting this sentence, I suddenly think that it could be a bug in the Javascript function to call a lua action !
Edit: escaping is certainly required because calling a lua action from the Javascript is done building a URL (Ajax.Request).

Normally, you have to use an URL without escaping it. The escape stuff has to be done by the soft.
« Last Edit: November 17, 2013, 06:23:39 am by lolodomo »

Offline lolodomo

  • Moderator
  • Master Member
  • *****
  • Posts: 3484
  • Karma: +74/-10
Re: DLNA Media Controller plugin - Common library for UPnP AV
« Reply #223 on: November 17, 2013, 08:00:56 am »
URL escaping of non-ASCII characters has to follow a strict order. First the characters must be expressed as a UTF-8 byte sequence. Then each byte is percent-encoded if it needs to be. To put "sc?ne" into a URL you will say "sc%C3%A8ne".

I think you're clearly in the right direction because when I select my file in XBMC, then what I see in the Vera in the received metada is a file name with c3a8.

What is this codage (c3a8) ?
Remember that when I browse the server, I got a HTTP URL with %25e8.
What character shall I put in the URL before c3a8 ?
How convert from my URL with %25e8 to the new URL including code c3a8 ?
And when I produce the XML SOAP message (UPnP request), do I have to do another conversion ?

Thanks for your help, I am clearly lost...

Ok, it is now a little clearer for me.
For egrave, e8 is its ISO-8559-1 code while c3a8 is its UTF-8 code.
So, if I correctly understood, I have first to unescape my URL to convert %25e8 into %e8 and then convert %e8 to its UTF-8 code, that is %c3a8. And nothing to do when putting this URL in a XML message. Correct ?
Is there a lua library to do this conversion from ISO-8559-1 to UTF-8 ?

I will hardcode the conversion for egrave and see if it solves my problem on this particular file.
« Last Edit: November 17, 2013, 08:02:29 am by lolodomo »

Offline a-lurker

  • Hero Member
  • *****
  • Posts: 831
  • Karma: +57/-8
Re: DLNA Media Controller plugin - Common library for UPnP AV
« Reply #224 on: November 17, 2013, 06:37:12 pm »
I have written a small function to convert ISO 8859 to UTF8 (I think it works OK). It may be of use. You can run it in the Vera Lua code test area and see the results in the log file.

You can set the variable 'charISO8859number' equal to the character's ISO number eg 232 for ? and it will make it into a UTF8 string: in this case 195, 174 = C3h, A8h and print the character in the log.

In actual usage, you would get each character in your ISO8859 string and pass it through the function; using the result to make a new UTF8 string.