Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes to make dms work with Samsung TVs and UPnP Monkey on Android #85

Merged
merged 3 commits into from
Sep 6, 2021

Conversation

phillipberndt
Copy link
Contributor

I wanted to make dms work on my Samsung TV, and while debugging against a very hackish Python script I wrote ages ago and which worked found some bugs related to other players as well 🙂 This PR is an attempt to fix them. Changes are:

  • Sort the SOAP response elements
    Some XML parsers are picky about the order of elements, even in situations where a container only contains each tag exactly once. (I guess that allows an optimization in auto-generated parsers..) Since right now you use a map[string]string for this, which is naturally unordered, I had to refactor some code to use [][2]string instead. The order I did use is the one in which the fields are introduced by the specification.
  • Write dc:title tag first
    The specification requires that item/container DIDL-Lite tags have this tag as their first child. This is required for my Samsung TV.
  • Report correct childCount for containers
    Again, my Samsung TV tries to be overly clever. Since dms reports 0 children, it doesn't bother to actually ever Browse the directory. (I am pretty certain that this is wrong and that 0 has some magic meaning, but couldn't find it - anyway, it doesn't harm to report the correct value here.)

Let me know if there's anything you'd like to see changed.

By the way, thanks for writing and maintaining this application! It is really useful for setting up ad-hoc dlna servers 😄

Some parsers are picky about the order of elements in SOAP responses. It
is recommended to follow the order given in the spec/wsdl. This change
replaces the map used to pass the values back to the handler with a
slice of 2-arrays, such that imposing an order is possible, and sorts
the keys in the correct order.

Verified with UPnP Monkey on Android, which before said:

> ServerHandler: failure: org.fourthline.cling.model.action.ActionException: Current state of service prevents invoking that action. Error reading response message. Can't transform message payload: org.fourthline.cling.model.action.ActionException: The argument value is invalid. Wrong order of arguments, expected 'Result' not: TotalMatches..
If a childCount of 0 is reported, Samsung TVs never send a Browse
request, and therefore no content is shown. This change is to report the
proper value.
The DIDL-Lite specification requires that dc:title tags are the first
child of their container. Samsung TVs are picky about this.
@anacrolix
Copy link
Owner

A very tidy PR, thank you!

@anacrolix anacrolix merged commit 544da44 into anacrolix:master Sep 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants