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

Improvements to dlna server #2326

Merged
merged 10 commits into from
Feb 11, 2020
Merged

Improvements to dlna server #2326

merged 10 commits into from
Feb 11, 2020

Conversation

Bond-009
Copy link
Member

  • Improve response writer
  • Add analyzers
  • Error on warnings in release mode
  • Disable doc warnings

* Improve response writer
* Add analyzers
* Error on warnings in release mode
* Disable doc warnings
Emby.Dlna/ContentDirectory/ControlHandler.cs Outdated Show resolved Hide resolved
Emby.Dlna/ContentDirectory/ControlHandler.cs Outdated Show resolved Hide resolved
Emby.Dlna/ContentDirectory/ControlHandler.cs Outdated Show resolved Hide resolved
Emby.Dlna/ContentDirectory/ControlHandler.cs Outdated Show resolved Hide resolved
@PrplHaz4
Copy link
Contributor

As of 82112b6 this looks to have broken the BROWSE control again (so no media is listed when browsing via DLNA)...

@Bond-009
Copy link
Member Author

I’ll take a look when I’ve got time (and maybe add some tests)

@Bond-009
Copy link
Member Author

Don't know why it's broken atm

@Bond-009
Copy link
Member Author

@PrplHaz4 Did that last commit fix it?

@PrplHaz4
Copy link
Contributor

@PrplHaz4 Did that last commit fix it?

@Bond-009 At first blush it does not appear to have fixed it. I will try to grab some wireshark traces.

On that note, have you happened to look at why the DLNA debug logging isn't working? (#2317) or is that on purpose since they're so chatty?

@PrplHaz4
Copy link
Contributor

@Bond-009 Two things I noticed that differ between the working responses and the non-working ones:

  1. DIDL-Lite contents of is HTML Encoded in the working (old) response but not the new one
    <u:Result>&lt;DIDL-Lite xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:dlna="urn:schemas-dlna-org:metadata-1-0/" xmlns:upnp="urn:schemas-upnp-org:metadata-1-0/upnp/" xmlns="urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/"&gt; &lt;container restricted="1" searchable="1" childCount="582" id="2b2bca16aacc8a14d53a11bb829eafa5" parentID="e9d5075a555c1cbc394eec4cef295274"&gt;...etc

  2. Count of records returned is off by one - <NumberReturned> is 3, but there are only 2 <container>s returned

I will keep looking but hopefully this is enough to go on.

Copy link
Contributor

@JustAMan JustAMan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stuff looks okay now, pending confirmation that this doesn't break DLNA :)

@Bond-009
Copy link
Member Author

@PrplHaz4 Can you give the full responses with and without the changes?

@PrplHaz4
Copy link
Contributor

PrplHaz4 commented Jan 27, 2020

@PrplHaz4 Can you give the full responses with and without the changes?

@Bond-009 @JustAMan this is the response to the BROWSE command from VLC - it appears the windows media player client uses the SEARCH command, which IS working for listing the media items. (the DLNA test script is starting to get a little complex it seems)

BEFORE (master 1ed92b0)

<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<Envelope SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
	<Body>
		<BrowseResponse xmlns:u="urn:schemas-upnp-org:service:ContentDirectory:1">
			<Result>
				&lt;DIDL-Lite xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:dlna="urn:schemas-dlna-org:metadata-1-0/" xmlns:upnp="urn:schemas-upnp-org:metadata-1-0/upnp/" xmlns="urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/"&gt;&lt;container restricted="1" searchable="1" childCount="129" id="2b2bca16aacc8a14d53a11bb829eafa5" parentID="e9d5075a555c1cbc394eec4cef295274"&gt;&lt;dc:title&gt;Live TV&lt;/dc:title&gt;&lt;upnp:class&gt;object.container.storageFolder&lt;/upnp:class&gt;&lt;/container&gt;&lt;container restricted="1" searchable="1" childCount="6" id="f137a2dd21bbc1b99aa5c0f6bf02a805" parentID="e9d5075a555c1cbc394eec4cef295274"&gt;&lt;dc:title&gt;Movies&lt;/dc:title&gt;&lt;upnp:class&gt;object.container.storageFolder&lt;/upnp:class&gt;&lt;upnp:albumArtURI dlna:profileID="JPEG_SM"&gt;http://192.168.4.14:8096/Items/f137a2dd21bbc1b99aa5c0f6bf02a805/Images/Primary/0/985d4292b159647f2eac85ee1b6b5489/jpg/480/480/0/0&lt;/upnp:albumArtURI&gt;&lt;upnp:icon&gt;http://192.168.4.14:8096/Items/f137a2dd21bbc1b99aa5c0f6bf02a805/Images/Primary/0/985d4292b159647f2eac85ee1b6b5489/jpg/48/48/0/0&lt;/upnp:icon&gt;&lt;res protocolInfo="http-get:*:image/jpeg:DLNA.ORG_PN=JPEG_LRG;DLNA.ORG_OP=00;DLNA.ORG_CI=0;DLNA.ORG_FLAGS=00D00000000000000000000000000000" resolution="960x540"&gt;http://192.168.4.14:8096/Items/f137a2dd21bbc1b99aa5c0f6bf02a805/Images/Primary/0/985d4292b159647f2eac85ee1b6b5489/jpg/4096/4096/0/0&lt;/res&gt;&lt;res protocolInfo="http-get:*:image/jpeg:DLNA.ORG_PN=JPEG_MED;DLNA.ORG_OP=00;DLNA.ORG_CI=0;DLNA.ORG_FLAGS=00D00000000000000000000000000000" resolution="960x540"&gt;http://192.168.4.14:8096/Items/f137a2dd21bbc1b99aa5c0f6bf02a805/Images/Primary/0/985d4292b159647f2eac85ee1b6b5489/jpg/1024/768/0/0&lt;/res&gt;&lt;res protocolInfo="http-get:*:image/jpeg:DLNA.ORG_PN=JPEG_SM;DLNA.ORG_OP=00;DLNA.ORG_CI=0;DLNA.ORG_FLAGS=00D00000000000000000000000000000" resolution="640x360"&gt;http://192.168.4.14:8096/Items/f137a2dd21bbc1b99aa5c0f6bf02a805/Images/Primary/0/985d4292b159647f2eac85ee1b6b5489/jpg/640/480/0/0&lt;/res&gt;&lt;res protocolInfo="http-get:*:image/png:DLNA.ORG_PN=PNG_LRG;DLNA.ORG_OP=00;DLNA.ORG_CI=0;DLNA.ORG_FLAGS=00D00000000000000000000000000000" resolution="960x540"&gt;http://192.168.4.14:8096/Items/f137a2dd21bbc1b99aa5c0f6bf02a805/Images/Primary/0/985d4292b159647f2eac85ee1b6b5489/png/4096/4096/0/0&lt;/res&gt;&lt;res protocolInfo="http-get:*:image/png:DLNA.ORG_PN=PNG_TN;DLNA.ORG_OP=00;DLNA.ORG_CI=0;DLNA.ORG_FLAGS=00D00000000000000000000000000000" resolution="160x90"&gt;http://192.168.4.14:8096/Items/f137a2dd21bbc1b99aa5c0f6bf02a805/Images/Primary/0/985d4292b159647f2eac85ee1b6b5489/png/160/160/0/0&lt;/res&gt;&lt;res protocolInfo="http-get:*:image/jpeg:DLNA.ORG_PN=JPEG_TN;DLNA.ORG_OP=00;DLNA.ORG_CI=0;DLNA.ORG_FLAGS=00D00000000000000000000000000000" resolution="160x90"&gt;http://192.168.4.14:8096/Items/f137a2dd21bbc1b99aa5c0f6bf02a805/Images/Primary/0/985d4292b159647f2eac85ee1b6b5489/jpg/160/160/0/0&lt;/res&gt;&lt;/container&gt;&lt;/DIDL-Lite&gt;
			</Result>
			<NumberReturned>
				2
			</NumberReturned>
			<TotalMatches>
				2
			</TotalMatches>
			<UpdateID>
				2063
			</UpdateID>
		</BrowseResponse>
	</Body>
</Envelope>

AFTER (dlnawarnings bade359)

<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<Envelope SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
	<Body>
		<BrowseResponse xmlns:u="urn:schemas-upnp-org:service:ContentDirectory:1">
			<Result>
				<DIDL-Lite xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:dlna="urn:schemas-dlna-org:metadata-1-0/" xmlns:upnp="urn:schemas-upnp-org:metadata-1-0/upnp/" xmlns="urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/">
					<container restricted="1" searchable="1" childCount="129" id="2b2bca16aacc8a14d53a11bb829eafa5" parentID="e9d5075a555c1cbc394eec4cef295274">
						<title>
							Live TV
						</title>
						<class>
							object.container.storageFolder
						</class>
					</container>
					<container restricted="1" searchable="1" childCount="6" id="f137a2dd21bbc1b99aa5c0f6bf02a805" parentID="e9d5075a555c1cbc394eec4cef295274">
						<title>
							Movies
						</title>
						<class>
							object.container.storageFolder
						</class>
						<albumArtURI dlna:profileID="JPEG_SM">
							http://192.168.4.14:8096/Items/f137a2dd21bbc1b99aa5c0f6bf02a805/Images/Primary/0/985d4292b159647f2eac85ee1b6b5489/jpg/480/480/0/0
						</albumArtURI>
						<icon>
							http://192.168.4.14:8096/Items/f137a2dd21bbc1b99aa5c0f6bf02a805/Images/Primary/0/985d4292b159647f2eac85ee1b6b5489/jpg/48/48/0/0
						</icon>
						<res protocolInfo="http-get:*:image/jpeg:DLNA.ORG_PN=JPEG_LRG;DLNA.ORG_OP=00;DLNA.ORG_CI=0;DLNA.ORG_FLAGS=00D00000000000000000000000000000" resolution="960x540">
							http://192.168.4.14:8096/Items/f137a2dd21bbc1b99aa5c0f6bf02a805/Images/Primary/0/985d4292b159647f2eac85ee1b6b5489/jpg/4096/4096/0/0
						</res>
						<res protocolInfo="http-get:*:image/jpeg:DLNA.ORG_PN=JPEG_MED;DLNA.ORG_OP=00;DLNA.ORG_CI=0;DLNA.ORG_FLAGS=00D00000000000000000000000000000" resolution="960x540">
							http://192.168.4.14:8096/Items/f137a2dd21bbc1b99aa5c0f6bf02a805/Images/Primary/0/985d4292b159647f2eac85ee1b6b5489/jpg/1024/768/0/0
						</res>
						<res protocolInfo="http-get:*:image/jpeg:DLNA.ORG_PN=JPEG_SM;DLNA.ORG_OP=00;DLNA.ORG_CI=0;DLNA.ORG_FLAGS=00D00000000000000000000000000000" resolution="640x360">
							http://192.168.4.14:8096/Items/f137a2dd21bbc1b99aa5c0f6bf02a805/Images/Primary/0/985d4292b159647f2eac85ee1b6b5489/jpg/640/480/0/0
						</res>
						<res protocolInfo="http-get:*:image/png:DLNA.ORG_PN=PNG_LRG;DLNA.ORG_OP=00;DLNA.ORG_CI=0;DLNA.ORG_FLAGS=00D00000000000000000000000000000" resolution="960x540">
							http://192.168.4.14:8096/Items/f137a2dd21bbc1b99aa5c0f6bf02a805/Images/Primary/0/985d4292b159647f2eac85ee1b6b5489/png/4096/4096/0/0
						</res>
						<res protocolInfo="http-get:*:image/png:DLNA.ORG_PN=PNG_TN;DLNA.ORG_OP=00;DLNA.ORG_CI=0;DLNA.ORG_FLAGS=00D00000000000000000000000000000" resolution="160x90">
							http://192.168.4.14:8096/Items/f137a2dd21bbc1b99aa5c0f6bf02a805/Images/Primary/0/985d4292b159647f2eac85ee1b6b5489/png/160/160/0/0
						</res>
						<res protocolInfo="http-get:*:image/jpeg:DLNA.ORG_PN=JPEG_TN;DLNA.ORG_OP=00;DLNA.ORG_CI=0;DLNA.ORG_FLAGS=00D00000000000000000000000000000" resolution="160x90">
							http://192.168.4.14:8096/Items/f137a2dd21bbc1b99aa5c0f6bf02a805/Images/Primary/0/985d4292b159647f2eac85ee1b6b5489/jpg/160/160/0/0
						</res>
					</container>
				</DIDL-Lite>
			</Result>
			<NumberReturned>
				2
			</NumberReturned>
			<TotalMatches>
				2
			</TotalMatches>
			<UpdateID>
				2063
			</UpdateID>
		</BrowseResponse>
	</Body>
</Envelope>

@Bond-009
Copy link
Member Author

I see, I’ll fix this tonight

@Bond-009
Copy link
Member Author

@PrplHaz4 What filter are you using on wireshark to capture these, so I can stop bothering you ;)

@PrplHaz4
Copy link
Contributor

PrplHaz4 commented Jan 27, 2020

@Bond-009 doesn't seem to be fixed with fc578de

<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<Envelope SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
	<Body>
		<BrowseResponse xmlns:u="urn:schemas-upnp-org:service:ContentDirectory:1">
			<Result>
				<DIDL-Lite xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:dlna="urn:schemas-dlna-org:metadata-1-0/" xmlns:upnp="urn:schemas-upnp-org:metadata-1-0/upnp/" xmlns="urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/">
					<container restricted="1" searchable="1" childCount="89" id="2b2bca16aacc8a14d53a11bb829eafa5" parentID="e9d5075a555c1cbc394eec4cef295274">
						<title>
							Live TV
						</title>
						<class>
							object.container.storageFolder
						</class>
					</container>
					<container restricted="1" searchable="1" childCount="6" id="f137a2dd21bbc1b99aa5c0f6bf02a805" parentID="e9d5075a555c1cbc394eec4cef295274">
						<title>
							Movies
						</title>
						<class>
							object.container.storageFolder
						</class>
						<albumArtURI dlna:profileID="JPEG_SM">
							http://192.168.4.14:8096/Items/f137a2dd21bbc1b99aa5c0f6bf02a805/Images/Primary/0/985d4292b159647f2eac85ee1b6b5489/jpg/480/480/0/0
						</albumArtURI>
						<icon>
							http://192.168.4.14:8096/Items/f137a2dd21bbc1b99aa5c0f6bf02a805/Images/Primary/0/985d4292b159647f2eac85ee1b6b5489/jpg/48/48/0/0
						</icon>
						<res protocolInfo="http-get:*:image/jpeg:DLNA.ORG_PN=JPEG_LRG;DLNA.ORG_OP=00;DLNA.ORG_CI=0;DLNA.ORG_FLAGS=00D00000000000000000000000000000" resolution="960x540">
							http://192.168.4.14:8096/Items/f137a2dd21bbc1b99aa5c0f6bf02a805/Images/Primary/0/985d4292b159647f2eac85ee1b6b5489/jpg/4096/4096/0/0
						</res>
						<res protocolInfo="http-get:*:image/jpeg:DLNA.ORG_PN=JPEG_MED;DLNA.ORG_OP=00;DLNA.ORG_CI=0;DLNA.ORG_FLAGS=00D00000000000000000000000000000" resolution="960x540">
							http://192.168.4.14:8096/Items/f137a2dd21bbc1b99aa5c0f6bf02a805/Images/Primary/0/985d4292b159647f2eac85ee1b6b5489/jpg/1024/768/0/0
						</res>
						<res protocolInfo="http-get:*:image/jpeg:DLNA.ORG_PN=JPEG_SM;DLNA.ORG_OP=00;DLNA.ORG_CI=0;DLNA.ORG_FLAGS=00D00000000000000000000000000000" resolution="640x360">
							http://192.168.4.14:8096/Items/f137a2dd21bbc1b99aa5c0f6bf02a805/Images/Primary/0/985d4292b159647f2eac85ee1b6b5489/jpg/640/480/0/0
						</res>
						<res protocolInfo="http-get:*:image/png:DLNA.ORG_PN=PNG_LRG;DLNA.ORG_OP=00;DLNA.ORG_CI=0;DLNA.ORG_FLAGS=00D00000000000000000000000000000" resolution="960x540">
							http://192.168.4.14:8096/Items/f137a2dd21bbc1b99aa5c0f6bf02a805/Images/Primary/0/985d4292b159647f2eac85ee1b6b5489/png/4096/4096/0/0
						</res>
						<res protocolInfo="http-get:*:image/png:DLNA.ORG_PN=PNG_TN;DLNA.ORG_OP=00;DLNA.ORG_CI=0;DLNA.ORG_FLAGS=00D00000000000000000000000000000" resolution="160x90">
							http://192.168.4.14:8096/Items/f137a2dd21bbc1b99aa5c0f6bf02a805/Images/Primary/0/985d4292b159647f2eac85ee1b6b5489/png/160/160/0/0
						</res>
						<res protocolInfo="http-get:*:image/jpeg:DLNA.ORG_PN=JPEG_TN;DLNA.ORG_OP=00;DLNA.ORG_CI=0;DLNA.ORG_FLAGS=00D00000000000000000000000000000" resolution="160x90">
							http://192.168.4.14:8096/Items/f137a2dd21bbc1b99aa5c0f6bf02a805/Images/Primary/0/985d4292b159647f2eac85ee1b6b5489/jpg/160/160/0/0
						</res>
					</container>
				</DIDL-Lite>
			</Result>
			<NumberReturned>
				2
			</NumberReturned>
			<TotalMatches>
				2
			</TotalMatches>
			<UpdateID>
				2069
			</UpdateID>
		</BrowseResponse>
	</Body>
</Envelope>

@PrplHaz4
Copy link
Contributor

@PrplHaz4 What filter are you using on wireshark to capture these, so I can stop bothering you ;)

@Bond-009 haha...you have too much faith in me...
search box: ip.src_host contains "jftest" || ip.dst_host contains "jftest"
and then just look for POST /dlna/af9f06335f4d490685987391b5f6b4be/contentdirectory/control HTTP/1.1 and the response that goes with it 🤷‍♂

@Bond-009
Copy link
Member Author

VLC can't seem to find my instance :/

@PrplHaz4
Copy link
Contributor

It'll be a couple hours before I can test again. Maybe check your dlna settings I'm jf and make sure intervals are 60 and 120 instead of the 1800 that was default at one point.

@PrplHaz4
Copy link
Contributor

@Bond-009 nope, not that one 6b68521

<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<Envelope SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
	<Body>
		<Fault>
			<faultcode>
				500
			</faultcode>
			<faultstring>
				WriteStartDocument cannot be called on writers created with ConformanceLevel.Fragment.
			</faultstring>
			<detail>
				<UPnPError xmlns="urn:schemas-upnp-org:control-1-0">
					<errorCode>
						401
					</errorCode>
					<errorDescription>
						Invalid Action
					</errorDescription>
				</UPnPError>
			</detail>
		</Fault>
	</Body>
</Envelope>

@cvium
Copy link
Member

cvium commented Jan 28, 2020

Note that since the DIDL-Lite format of Result is based on XML, it needs to be escaped (using the normal XML rules: [XML] Section 2.4 Character Data and Markup) before embedding in a SOAP response message. In addition, when a variable of type A_ARG_TYPE_Result is employed as a parameter in a comma-separated list, commas (‘,’) that appear within XML CDATA must be escaped (as ,), see section 2.3.1.

Section 2.5.4 http://upnp.org/specs/av/UPnP-av-ContentDirectory-v1-Service.pdf

XML Section 2.4: https://www.w3.org/TR/REC-xml/#syntax

@PrplHaz4
Copy link
Contributor

@Bond-009 doesn't look like 36d62c3 is working but didn't have time to grab a trace on the train - will have to get it tonight.

@Bond-009
Copy link
Member Author

@PrplHaz4 My bad, forgot to revert the previous (failed) fix

@PrplHaz4
Copy link
Contributor

@PrplHaz4 My bad, forgot to revert the previous (failed) fix

@Bond-009 not working as of 6ee0485 - will be a few hrs before I can get a trace - maybe time to fix logging in the DLNA area - it looks like the control requests aren't being logged anymore either. VLC and Windows Explorer are not listing any media under jellyfin.

@PrplHaz4
Copy link
Contributor

@Bond-009 Here's the response with 6ee0485 - "Result" is empty

<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<Envelope SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
	<Body>
		<BrowseResponse xmlns:u="urn:schemas-upnp-org:service:ContentDirectory:1">
			<Result />
			<NumberReturned>
				2
			</NumberReturned>
			<TotalMatches>
				2
			</TotalMatches>
			<UpdateID>
				2050
			</UpdateID>
		</BrowseResponse>
	</Body>
</Envelope>

@PrplHaz4
Copy link
Contributor

Looks like that d698706 did it! Thanks and nice work @Bond-009

Movies are working fine now, but VLC is not listing my LiveTV channels through DLNA. The individual channels are listed on my Samsung TV DLNA client and Windows Explorer. That might be another issue entirely - LMK if you think it's worth opening a new issue with new traces...
image

@PrplHaz4
Copy link
Contributor

Looks like that d698706 did it! Thanks and nice work @Bond-009

Movies are working fine now, but VLC is not listing my LiveTV channels through DLNA. The individual channels are listed on my Samsung TV DLNA client and Windows Explorer. That might be another issue entirely - LMK if you think it's worth opening a new issue with new traces...

@Bond-009 answering my own question - this PR should be merged and I will create a new issue for the LiveTV Browse in VLC over DLNA.

@cvium
Copy link
Member

cvium commented Feb 3, 2020

Hmm, I forgot that Github creates merge commits when handling conflicts.

@PrplHaz4
Copy link
Contributor

PrplHaz4 commented Feb 3, 2020

Looks like that d698706 did it! Thanks and nice work @Bond-009
Movies are working fine now, but VLC is not listing my LiveTV channels through DLNA. The individual channels are listed on my Samsung TV DLNA client and Windows Explorer. That might be another issue entirely - LMK if you think it's worth opening a new issue with new traces...

@Bond-009 answering my own question - this PR should be merged and I will create a new issue for the LiveTV Browse in VLC over DLNA.

As promised, here is the issue I've created for LiveTV/DLNA/VLC: jellyfin/jellyfin-plugin-dlna#8

Copy link
Contributor

@JustAMan JustAMan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here's hoping you all tested that properly :)

@dkanada dkanada merged commit 662e116 into jellyfin:master Feb 11, 2020
@Bond-009 Bond-009 deleted the dlnawarnings branch February 11, 2020 17:46
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.

None yet

5 participants