DLNA Media Controller plugin as a datasource

@lolodomo Great work on the Media Controller plugin! I installed it and found my Sonos device on the network. I’m hoping to be able to use the data it gets as the “datasource” for some in wall controllers I’m trying to write a MIOS plugin for.
-After I completed the install of V0.5, I clicked on “xxx.xxx.xxx.xxx - Sonos CONNECT Media Server”

  • Then Navigated down “+ Attributes” > “+ Albums” > " which then returned my list of 2,485 Albums in 36 Seconds. I have a few questions:
    ? Is the response time comparable with other’s experience? I’m running a Vera 3.
    ? For my use case, I?d like to limit the time it takes to get a response. 36 seconds is too long for my use case. Is there a way that I can just get all albums starting with ?A? or ?B?, etc or ?A,B,C? so the list is not quite so large?
    ? Along the same lines, should/can my plugin call your DLNA Media Controller to get this information? How can I automate the calls or is there a different approach. I?m including my use case below:

[ul][li]From an in wall keypad, a user selects ‘Sonos Music’
[/li]
[li]
A menu presents ‘By Artist’, ‘By Album’, ‘By Genre’, ‘By Composer’, ‘By Track’, ‘By Playlist’
[/li]
[li]
From a keypad, a user selects ‘By Album’
[/li]
[li]
A menu presents ‘A’, ‘B’, ‘C’… ‘Z’
[/li]
[li]
From a keypad, a user selects ‘A’ to get all the Albums the begin with the letter ‘A’
[/li]
[li]
From a keypad, a user selects a specific album and all the tracks are listed
[/li][/ul]

You can browse (partially) with DLNA but then you can connect media only to Sonos and not to DLNA renderers.

- Then Navigated down "+ Attributes" > "+ Albums" > " which then returned my list of 2,485 Albums in 36 Seconds. I have a few questions: ? Is the response time comparable with other's experience? I'm running a Vera 3. ? For my use case, I?d like to limit the time it takes to get a response. 36 seconds is too long for my use case. Is there a way that I can just get all albums starting with ?A? or ?B?, etc or ?A,B,C? so the list is not quite so large?

2485 entries will generate a very big string, maybe about 250 KB.
I am fetching data by blocks of 100, leading in your case to 25 UPnP requests and 25 merge of strings.
Maybe the result would be better with only one call returning all data in one go.

Other point is that I will reduce the data to keep only what is required for the UI (title, res, …). The result will be smaller in size.

By the way, I have to try myself big data requests.

What you ask (filtering by first letters) is a different structure on the server side. Sonos does not propose that.

? Along the same lines, should/can my plugin call your DLNA Media Controller to get this information? How can I automate the calls or is there a different approach. I?m including my use case below:

[ul][li]From an in wall keypad, a user selects ‘Sonos Music’
[/li]
[li]
A menu presents ‘By Artist’, ‘By Album’, ‘By Genre’, ‘By Composer’, ‘By Track’, ‘By Playlist’
[/li]
[li]
From a keypad, a user selects ‘By Album’
[/li]
[li]
A menu presents ‘A’, ‘B’, ‘C’… ‘Z’
[/li]
[li]
From a keypad, a user selects ‘A’ to get all the Albums the begin with the letter ‘A’
[/li]
[li]
From a keypad, a user selects a specific album and all the tracks are listed
[/li][/ul]

At the end, you will play the music on Sonos ? To do that, you will need to use the Sonos plugin. DLNA server browsing is not exposed through actions in the Sonos plugin but could be.

One soluton is to call an action from the DLNA or Sonos plugin for browsing media and then get the result in a device variable. Then you can use this variable to do what you want.
For the filtering, I could probably add a new parameter and do the filtering in the plugin.

Correction: you can use the DLNA plugin to render Sonos media on Sonos.

For your need (filtering), the Search UPnP request could be the solution, rather than the Browse request I use in my code.
With Search, you can specify a search criteria like title == “toto”. I don’t know if you have the possibility to provide a regular expression, that is required if you want to search only titles starting with A or B or C for example.

Last thing; I think I can probably improve a little the performance of Browse request using its filter parameter, asking only the necessary data in the returned data. The final string will be smaller.

You can browse (partially) with DLNA but then you can connect media only to Sonos and not to DLNA renderers.
That approach aligns with what I was thinking.
By the way, I have to try myself big data requests.
Let me know if you need me to run any tests against my setup. I'll be away from coding for the Vera for the next week, but can help/test once my schedule returns to normal.
At the end, you will play the music on Sonos ?
I will be playing the music on Sonos and I have the Sonos plugin setup and configured. I was planning on using the DLNA plugin for browsing and the Sonos plugin for the execution of requests. I anticipate matching the two entities up by IP Address.

I’m starting to play around with the in wall keypad API. I have some flexibility on how I implement things from my side so I don’t necessarily need to filter by just a letter by could if it increase performance or user experience. For instance, I can send data to a keypad in blocks (rows) of items, say 20 at a time. However, that would mean I would need to get those items as you receive them. I’m not convinced that I want to scroll through 2,500 items either though.

Last thing; I think I can probably improve a little the performance of Browse request using its filter parameter, asking only the necessary data in the returned data. The final string will be smaller.

That’s an interesting thought and I can help with benchmarks. For my use case, I could technically have different users on different keypads making requests. I’ll need to consider how I deal with those situations. For instance a user in one zone is searching by Album and another user is searching by Title.

I’ll need information in the album example like:

[ul][li]Album Title[/li]
[li]Path or some key to play the music[/li]
[li]A numeric primary key that the 3rd party system will send to tell me which item I need to play when the user selects it. When the user selects the item, I’ll take this numeric primary key and do a lookup to the “Path or some key to play the music” and then execute the Sonos request[/li][/ul]

That last bullet item is making me wonder if on startup if I don’t just make a set of serialized requests to the DNLA plugin to go fetch these individual large item lists ( ‘By Artist’, ‘By Album’, ‘By Genre’, ‘By Composer’, ‘By Track’, ‘By Playlist’). I could then take your results, add additional metadata that I need for my use case and then cache them (perhaps on external storage USB Stick) to limit the impact of memory use on the Vera. One thing I’m not sure is when you’re storing these large variables with
these lists in the DNLA plugin are those stored in RAM or NV Memory? My music collection is fairly static so this cache approach might be okay and improve performance on my side.

Correction: you can use the DLNA plugin to render Sonos media on Sonos.

For your need (filtering), the Search UPnP request could be the solution, rather than the Browse request I use in my code.
With Search, you can specify a search criteria like title == “toto”. I don’t know if you have the possibility to provide a regular expression, that is required if you want to search only titles starting with A or B or C for example.


Would I need to build my own DLNA parser to do this or is there a way I could use your plug-in to specify a search?

BTW, I appreciate your input and help. I’m looking forward to trying to tackle some variant of this!

Just a quick message to let you know that I succeeded to improove performance.
For a request returning 1133 items (a final string of around 825000 bytes), it first takes 13 seconds. With my current changes (not yet committed), the same request is now finished in 7,8 seconds.
Amongst these 7,8 s, I have around 3,9 s just for the decode function called on the big string. This function runs a chain of several calls to gsub to replace fews combinations of characters in the string. I am not sure yet how to optimize this function. But I think there is a chance that after a rewriting of the decode function, the run time could then be around 5s.

Unfortunately, I don’t succeed in using the filter parameter of the Browse request. It does filter nothing ! That’s a pity because it could have helped to reduce the amoiunt of returned information and imprrove performance.

I have now committed my changes (in the trunk only).
In addition to better performance for browsing server content, I defined a kind of timeout for the browse action and set it to 30s. That means if you try to fetch a very big amount of data, you could reach the timeout and finally retrieved only a part of the data. I cannot test it (no enough data in my library) but I think the limit is now probably around 4000 items.
Note that the timeout is not exactly 30s. It will be something between 30s and maybe 35s.
Enabling debug logs, you can see a trace each time the function is called with run time, number of fectched elements and size of the result string.

[quote=“hifs, post:4, topic:179070”]

By the way, I have to try myself big data requests.

Let me know if you need me to run any tests against my setup. I’ll be away from coding for the Vera for the next week, but can help/test once my schedule returns to normal.[/quote]

Please try again with the last version in trunk to see how much time it takes now.

At the end, you will play the music on Sonos ?
I will be playing the music on Sonos and I have the Sonos plugin setup and configured. I was planning on using the DLNA plugin for browsing and the Sonos plugin for the execution of requests. I anticipate matching the two entities up by IP Address.

Be careful, it exists a bug in Sonos. As a result, Sonos will not notified two devices in the Vera. So you should absolutely avoid to have in the Vera for the same Sonos unit a device corresponding to the Sonos plugin and a device corresponding to the DLNA plugin with the same Sonos setup as DMR.

For my use case, I could technically have different users on different keypads making requests. I'll need to consider how I deal with those situations. For instance a user in one zone is searching by Album and another user is searching by Title.

I have difficulty to understand what you want to do exactly. You will have your external UI code running on your tablet and you want to use my plugin as a kind of service to provide server information ?
The Vera architecture is not really adapted to this kind of needs because your only entry point is to run an action and unfortunately you have no way to get return data. The only workaround is to have the action filling a variable of the device and then reading from your code the value of the variable (you don’t know when the action finished). Having a big amount of data in a device variable is not something recommended for the Vera.

One option would be to use my lua library to call UPnP Browse action and get the result as return parameter. But of course you have no lua interpreter on your tablet, I imagine.

Later, I will provide a guide to explain how to use this library.

That last bullet item is making me wonder if on startup if I don't just make a set of serialized requests to the DNLA plugin to go fetch these individual large item lists ( 'By Artist', 'By Album', 'By Genre', 'By Composer', 'By Track', 'By Playlist'). I could then take your results, add additional metadata that I need for my use case and then cache them (perhaps on external storage USB Stick) to limit the impact of memory use on the Vera.

That could be a good idea.

One thing I'm not sure is when you're storing these large variables with these lists in the DNLA plugin are those stored in RAM or NV Memory?

Good question.

Would I need to build my own DLNA parser to do this or is there a way I could use your plug-in to specify a search?

I cannot answer until I understand exactly your “architecture” (where your code is running).