Retrieve all DLNA root storage directories in Cling?

I use the awesome Cling library to scan my network for UPnP devices. My goal is to put together a little DLNA library so that I can learn this technology. Until now, I could 1. scan the network and connect UPnP devices, 2. check each remote device and determine if it has DLNA service, and 3. browse the immediate children of known nodes. In short, this is my method, which is able to run all of this:

  public void remoteDeviceAdded(Registry registry, RemoteDevice device) { logger.debug("remote device added: {}[{}]", device.getDetails().getFriendlyName(), device.getType().getType()); if (device.getType().getType().equals("MediaServer")) { for (RemoteService service : device.getServices()) { if (service.getServiceType().getType().equals("ContentDirectory")) { // '1' is Music, '2' is Video, '3' is Pictures this.service.getControlPoint().execute(new Browse(service, "3", BrowseFlag.DIRECT_CHILDREN) { @Override public void received(ActionInvocation arg0, DIDLContent didl) { logger.debug("found {} items.", didl.getItems().size()); } @Override public void updateStatus(Status arg0) { }; @Override public void failure(ActionInvocation arg0, UpnpResponse arg1, String arg2) { }; }); } } } } 

I know this probably looks like a terrible mess, but it works :) When I look into the debugger, I see what I have. However, unlike the manual instructions here , I do not get any real multimedia elements, but only storage directories in the search results. This approach makes sense because DLNA organizes things in a hierarchy as follows:

 Music All Music Artists Fleetwood Mac ... Albums ... Video All Video Folders ... 

My question is, what is the easiest way to browse through these folders and walk through the hierarchy? I am already at the point where I am connected to the UPnP DLNA server I was looking for, now how can I get these root storage directories? In the above review command, I have to actually pass a string representation of some index to get “Music” or “Video” or the like. How to get top level storage directories, then how can I view each of these directories? My goal is to at least create a simple browser.

+7
source share
1 answer

Well, it turns out that I can answer my own question as a result of some help on the Cling mailing list.

Apparently, all DLNA elements have a unique identification number with which you can refer to them in Cling. To get / , you need to query node "0". To access /../ (one step above the top !?), you can query node "-1". Since the DLNA specification is non-existent useless on this matter, it is only by convention. So the query node "0" really should get the topmost node, but who knows? This can lead to you a red herring or a mad elk or the end of the world. Risks are what we live for, right?

In any case, the DLNA “file system” works as follows:

 /[0] Browse Folders/[1] Music/[2] All Music/[5] Heart Is Hard To Find[6] ... ... Pictures/[3] Video/[4] 

Thus, if I wanted to sequentially browse my path in “All Music”, which is node '5', I would first query for “0”, display containers for children, and then look at node '2' when interacting with the user, then go to node '5' when interacting with the user, then select node '6', which is the actual file I'm looking for, and follow some steps on it.

Understanding how DLNA works is key to facilitating all of this. All important things are transmitted via HTTP, peer discovery is facilitated over UPnP. So, first find all the UPnP clients on your network, then sort all the clients and determine which ones start DLNA, and then go to the browse. Find what you are looking for and then pass it over HTTP to play it back. Theory of victory.

+8
source

All Articles