INTERACT FORUM

Please login or register.

Login with username, password and session length
Advanced search  
Pages: [1]   Go Down

Author Topic: UPnP renderer sends incorrect NOTIFY message  (Read 5936 times)

simoncn

  • Recent member
  • *
  • Posts: 17
UPnP renderer sends incorrect NOTIFY message
« on: March 15, 2014, 02:45:22 am »

The "initial event" NOTIFY message sent by the MC UPnP renderer doesn't conform to the UPnP Device Architecture specification and can't be parsed by a spec-compliant UPnP control point.

According to section 4.3.2 of the UPnP Device Architecture 1.1 document (page 98), the required format is:

Code: [Select]
<e:propertyset xmlns:e="urn:schemas-upnp-org:event-1-0">
<e:property>
<firstName>firstValue</firstName>
</e:property>
<e:property>
<secondName>secondValue</secondName>
</e:property>
<e:property>
<thirdName>thirdValue</thirdName>
</e:property>
</e:propertyset>

with a separate <e:property> tag for each value. The MC renderer is sending this:

Code: [Select]
<e:propertyset xmlns:e="urn:schemas-upnp-org:event-1-0">
<e:property>
<firstName>firstValue</firstName>
<secondName>secondValue</secondName>
<thirdName>thirdValue</thirdName>
</e:property>
</e:propertyset>

The control point is (correctly) parsing only the first property value, so the other values are uninitialized. This problem is preventing me from using the MC UPnP renderer.
Logged

AndrewFG

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 3392
Re: UPnP renderer sends incorrect NOTIFY message
« Reply #1 on: March 16, 2014, 10:47:44 am »

The "initial event" NOTIFY message sent by the MC UPnP renderer doesn't conform to the UPnP Device Architecture specification and can't be parsed by a spec-compliant UPnP control point.

According to section 4.3.2 of the UPnP Device Architecture 1.1 document (page 98), the required format is:

Code: [Select]
<e:propertyset xmlns:e="urn:schemas-upnp-org:event-1-0">
<e:property>
<firstName>firstValue</firstName>
</e:property>
<e:property>
<secondName>secondValue</secondName>
</e:property>
<e:property>
<thirdName>thirdValue</thirdName>
</e:property>
</e:propertyset>

with a separate <e:property> tag for each value. The MC renderer is sending this:

Code: [Select]
<e:propertyset xmlns:e="urn:schemas-upnp-org:event-1-0">
<e:property>
<firstName>firstValue</firstName>
<secondName>secondValue</secondName>
<thirdName>thirdValue</thirdName>
</e:property>
</e:propertyset>

The control point is (correctly) parsing only the first property value, so the other values are uninitialized. This problem is preventing me from using the MC UPnP renderer.

I think you are not quite right here...

The UPnP Audio Video specifications require that all events are bundled as a combined XML payload within one single property named LastChange. So compliant UPnP AV Renderers (including MC) always send just this one single property value. You can read about this here: http://upnp.org/specs/av/UPnP-av-AVTransport-v1-Service.pdf

So if you think your are seeing multiple properties in an event notification, (as you describe in your post), then you are probably mistaken. Also if you expect to see multiple properties, you are also certainly mistaken...



Logged
Author of Whitebear Digital Media Renderer Analyser - http://www.whitebear.ch/dmra.htm
Author of Whitebear - http://www.whitebear.ch/mediaserver.htm

simoncn

  • Recent member
  • *
  • Posts: 17
Re: UPnP renderer sends incorrect NOTIFY message
« Reply #2 on: March 16, 2014, 11:31:25 am »

I think you are not quite right here...

The UPnP Audio Video specifications require that all events are bundled as a combined XML payload within one single property named LastChange. So compliant UPnP AV Renderers (including MC) always send just this one single property value. You can read about this here: http://upnp.org/specs/av/UPnP-av-AVTransport-v1-Service.pdf

So if you think your are seeing multiple properties in an event notification, (as you describe in your post), then you are probably mistaken. Also if you expect to see multiple properties, you are also certainly mistaken...

This NOTIFY message is being sent for a subscription to the ConnectionManager:1 service, which doesn't use the LastChange property.

Here is the start of the data that MC is sending (captured from Wireshark):

Code: [Select]
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<e:propertyset xmlns:e="urn:schemas-upnp-org:event-1-0">
<e:property>
<CurrentConnectionIDs>0</CurrentConnectionIDs>
<SourceProtocolInfo/>
<SinkProtocolInfo>http-get:*:audio/L16;rate=22050;channels=1:DLNA.ORG_PN=LPCM,
http-get:*:audio/L16;rate=22050;channels=2:DLNA.ORG_PN=LPCM,
http-get:*:audio/L16;rate=22050;channels=4:DLNA.ORG_PN=LPCM,
http-get:*:audio/L16;rate=22050;channels=6:DLNA.ORG_PN=LPCM,
Logged

AndrewFG

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 3392
Re: UPnP renderer sends incorrect NOTIFY message
« Reply #3 on: March 16, 2014, 01:06:27 pm »

Ok. That does indeed look wrong.

IMHO I would not worry too much about bad formatted events from the ConnectionManager service. Because other than the initial event (to get the status) its properties will probably never change anyway (at least not in MC)...

Logged
Author of Whitebear Digital Media Renderer Analyser - http://www.whitebear.ch/dmra.htm
Author of Whitebear - http://www.whitebear.ch/mediaserver.htm

simoncn

  • Recent member
  • *
  • Posts: 17
Re: UPnP renderer sends incorrect NOTIFY message
« Reply #4 on: March 16, 2014, 04:24:59 pm »

Ok. That does indeed look wrong.

IMHO I would not worry too much about bad formatted events from the ConnectionManager service. Because other than the initial event (to get the status) its properties will probably never change anyway (at least not in MC)...

The problem is that the control point stack chokes on the bad formatting, which is a showstopper for me.
Logged

AndrewFG

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 3392
Re: UPnP renderer sends incorrect NOTIFY message
« Reply #5 on: March 17, 2014, 01:32:00 am »

The problem is that the control point stack chokes on the bad formatting, which is a showstopper for me.

In addition to informing about MC here, you should also inform the CP maker. A CP that falls over like that is a bad design and a security risk.
Logged
Author of Whitebear Digital Media Renderer Analyser - http://www.whitebear.ch/dmra.htm
Author of Whitebear - http://www.whitebear.ch/mediaserver.htm

simoncn

  • Recent member
  • *
  • Posts: 17
Re: UPnP renderer sends incorrect NOTIFY message
« Reply #6 on: March 17, 2014, 04:00:51 am »

In addition to informing about MC here, you should also inform the CP maker. A CP that falls over like that is a bad design and a security risk.

How do you think the control point should react to this? It is unable to retrieve all the property values because of the formatting error. I can think of two options:

1) It could refuse to recognise the MC renderer.

2) It could substitute null values for the properties that it couldn't read, which would leave me unable to use the MC renderer because of the missing protocol information.

In either case, I wouldn't be able to use the MC renderer unless the formatting bug is fixed.
Logged

AndrewFG

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 3392
Re: UPnP renderer sends incorrect NOTIFY message
« Reply #7 on: March 17, 2014, 04:18:52 am »

How do you think the control point should react to this? It is unable to retrieve all the property values because of the formatting error.

Are you writing your own CP?

If the CP receives an Event notification that it is not able to parse, then it should just return an HTTP 4xx error (see the device architecture specifications). In my opinion a CP should never try to double guess what might have been the content of that notification if it would have been able to parse it.

Also in my opinion a CP should never refuse to talk to a UPnP device simply because its event notifications are bad. If the device behaves OK on the Description and Control parts of the specifications, it is probably still usable. (I say this because there are indeed many usable devices that behave badly on the Eventing part of the specification).

unable to use the MC renderer because of the missing protocol information.

Use the GetProtocolInfo method rather than relying on eventing.


EDIT: by the way, if you are indeed writing your own CP I want to give you top praise for wanting to check SinkProtocolInfo before pushing streams to a renderer. Most CPs (including MC) just push what they want without so checking the renderer's capabilities. In my opinion that is lazy. The whole purpose of SinkProtocolInfo and SourceProtocolInfo is to provide a proper clean way for negotiating the highest common denominator stream format that both server and renderer can mutually support. The GetProtocolInfo method is in the specification for a very good reason.

Logged
Author of Whitebear Digital Media Renderer Analyser - http://www.whitebear.ch/dmra.htm
Author of Whitebear - http://www.whitebear.ch/mediaserver.htm

simoncn

  • Recent member
  • *
  • Posts: 17
Re: UPnP renderer sends incorrect NOTIFY message
« Reply #8 on: March 17, 2014, 04:58:52 am »

Are you writing your own CP?

I'm writing a renderer proxy which passes CP invocations to the real renderer and passes renderer event notifications to the CP.

Quote
If the CP receives an Event notification that it is not able to parse, then it should just return an HTTP 4xx error (see the device architecture specifications). In my opinion a CP should never try to double guess what might have been the content of that notification if it would have been able to parse it.

This is the initial event notification (see section 4.1 of the UPnP Device Architecture specification). The initial event notification must be received and processed before other events can be processed. If the control point rejects the initial event, this would mean that eventing is completely disabled for this renderer.

Quote
Also in my opinion a CP should never refuse to talk to a UPnP device simply because its event notifications are bad. If the device behaves OK on the Description and Control parts of the specifications, it is probably still usable. (I say this because there are indeed many usable devices that behave badly on the Eventing part of the specification).

These evented state variables are a required part of the UPnP specification for ConnectionManager:1. Any device that claims to be a UPnP renderer (as MC does) should support them.

Quote
Use the GetProtocolInfo method rather than relying on eventing.

This would work if the control point could safely assume that the value will never change.

Quote
EDIT: by the way, if you are indeed writing your own CP I want to give you top praise for wanting to check SinkProtocolInfo before pushing streams to a renderer. Most CPs (including MC) just push what they want without so checking the renderer's capabilities. In my opinion that is lazy. The whole purpose of SinkProtocolInfo and SourceProtocolInfo is to provide a proper clean way for negotiating the highest common denominator stream format that both server and renderer can mutually support. The GetProtocolInfo method is in the specification for a very good reason.

The problem with this is that some renderers don't send complete and correct protocol information, so a control point that does these checks might refuse to send a stream to a renderer even though the renderer would be able to handle the stream. Also, there is enormous confusion over which MIME types are correct for various stream types, which can cause a similar problem.
Logged

Hendrik

  • Administrator
  • Citizen of the Universe
  • *****
  • Posts: 10970
Re: UPnP renderer sends incorrect NOTIFY message
« Reply #9 on: March 17, 2014, 05:07:35 am »

Do I understand the problem correctly, that instead of the dump you quoted above, it should look like this?

Code: [Select]
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<e:propertyset xmlns:e="urn:schemas-upnp-org:event-1-0">
<e:property>
<CurrentConnectionIDs>0</CurrentConnectionIDs>
</e:property>
<e:property>
<SourceProtocolInfo/>
</e:property>
<e:property>
<SinkProtocolInfo>http-get:*:audio/L16;rate=22050;channels=1:DLNA.ORG_PN=LPCM,
http-get:*:audio/L16;rate=22050;channels=2:DLNA.ORG_PN=LPCM,
http-get:*:audio/L16;rate=22050;channels=4:DLNA.ORG_PN=LPCM,
http-get:*:audio/L16;rate=22050;channels=6:DLNA.ORG_PN=LPCM,.................

I should familiarize myself with the UPnP/DLNA specs.
Until I get a chance, maybe bob sees this and can confirm and fix.
Logged
~ nevcairiel
~ Author of LAV Filters

AndrewFG

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 3392
Re: UPnP renderer sends incorrect NOTIFY message
« Reply #10 on: March 17, 2014, 05:12:51 am »

I'm writing a renderer proxy which passes CP invocations to the real renderer and passes renderer event notifications to the CP.

If your are proxying, then IMHO you should just pass on what you get.

This is the initial event notification (see section 4.1 of the UPnP Device Architecture specification). The initial event notification must be received and processed before other events can be processed. If the control point rejects the initial event, this would mean that eventing is completely disabled for this renderer.

No. It would only be disabled for that particular service (ConnectionManager) on that renderer.

These evented state variables are a required part of the UPnP specification for ConnectionManager:1. Any device that claims to be a UPnP renderer (as MC does) should support them.

Yes. And all renderers that I have seen do actually support those state variables. But not all of them accurately support eventing on those state variables...

This would work if the control point could safely assume that the value will never change.

Personally I would just call GetProtocolInfo every time just before I wanted to push something to the player.
But in reality is extremely unlikely that a renderer would suddenly change the list of formats that it can play; and if it did so, then it is quite likely that it would go bye-bye in between. Or ??

The problem with this is that some renderers don't send complete and correct protocol information, so a control point that does these checks might refuse to send a stream to a renderer even though the renderer would be able to handle the stream. Also, there is enormous confusion over which MIME types are correct for various stream types, which can cause a similar problem.

Yes. This is indeed the argument that many CP writers use as a justification for not calling GetProtocolInfo and just pushing whatever they darn well choose.

Logged
Author of Whitebear Digital Media Renderer Analyser - http://www.whitebear.ch/dmra.htm
Author of Whitebear - http://www.whitebear.ch/mediaserver.htm

AndrewFG

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 3392
Re: UPnP renderer sends incorrect NOTIFY message
« Reply #11 on: March 17, 2014, 05:26:54 am »

Do I understand the problem correctly, that instead of the dump you quoted above, it should look like this?

Code: [Select]
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<e:propertyset xmlns:e="urn:schemas-upnp-org:event-1-0">
<e:property>
<CurrentConnectionIDs>0</CurrentConnectionIDs>
</e:property>
<e:property>
<SourceProtocolInfo/>
</e:property>
<e:property>
<SinkProtocolInfo>http-get:*:audio/L16;rate=22050;channels=1:DLNA.ORG_PN=LPCM,
http-get:*:audio/L16;rate=22050;channels=2:DLNA.ORG_PN=LPCM,
http-get:*:audio/L16;rate=22050;channels=4:DLNA.ORG_PN=LPCM,
http-get:*:audio/L16;rate=22050;channels=6:DLNA.ORG_PN=LPCM,.................

I should familiarize myself with the UPnP/DLNA specs.
Until I get a chance, maybe bob sees this and can confirm and fix.

Correct.

Following is an extract from the UPnP Device Architecture specifications:
Quote
propertyset Required. Contains the following sub element.
property Required. Repeat once for each variable name and value in the event message. Contains the following sub element.
variableName Required. Element is name of a state variable that changed (name sub element of stateVariable element in service description). Value is the new value for this state variable.

EDIT: and instead of sending <SourceProtocolInfo/> I would personally recommend sending <SourceProtocolInfo></SourceProtocolInfo>

Logged
Author of Whitebear Digital Media Renderer Analyser - http://www.whitebear.ch/dmra.htm
Author of Whitebear - http://www.whitebear.ch/mediaserver.htm

simoncn

  • Recent member
  • *
  • Posts: 17
Re: UPnP renderer sends incorrect NOTIFY message
« Reply #12 on: March 17, 2014, 07:26:09 am »

EDIT: and instead of sending <SourceProtocolInfo/> I would personally recommend sending <SourceProtocolInfo></SourceProtocolInfo>

I agree that this change would be desirable. The UPnP Device Architecture 1.1 specification explicitly states on page 98 that property values should use the syntax:

Code: [Select]
<e:property>
<variableName>new value</variableName>
</e:property>

It is safer to use this syntax for an empty value to ensure interoperability with al control points.
Logged

Hendrik

  • Administrator
  • Citizen of the Universe
  • *****
  • Posts: 10970
Re: UPnP renderer sends incorrect NOTIFY message
« Reply #13 on: March 17, 2014, 07:37:35 am »

So we cannot even send proper XML now? :)
Logged
~ nevcairiel
~ Author of LAV Filters

simoncn

  • Recent member
  • *
  • Posts: 17
Re: UPnP renderer sends incorrect NOTIFY message
« Reply #14 on: March 17, 2014, 07:38:57 am »

If your are proxying, then IMHO you should just pass on what you get.

I am trying to do this, but the control point and device stacks that I'm using don't support receiving or sending of incorrectly formatted event messages.

Quote
No. It would only be disabled for that particular service (ConnectionManager) on that renderer.

Agreed.

Quote
Yes. And all renderers that I have seen do actually support those state variables. But not all of them accurately support eventing on those state variables...

As these variables are defined in the service spec as evented, and the Device Architecture spec requires all evented state variables to appear in the initial event message, it seems to me that the renderer is required to send an initial event message containing all these state variables.

Quote
Personally I would just call GetProtocolInfo every time just before I wanted to push something to the player.
But in reality is extremely unlikely that a renderer would suddenly change the list of formats that it can play; and if it did so, then it is quite likely that it would go bye-bye in between. Or ??

The SinkProtocolInfo data from the MC renderer is 12000 bytes long. Retrieving and parsing this every time seems like an overhead that should ideally be avoided.
Logged

AndrewFG

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 3392
Re: UPnP renderer sends incorrect NOTIFY message
« Reply #15 on: March 17, 2014, 03:53:23 pm »

As these variables are defined in the service spec as evented, and the Device Architecture spec requires all evented state variables to appear in the initial event message, it seems to me that the renderer is required to send an initial event message containing all these state variables.

You are quite right. However many don't do that...

The SinkProtocolInfo data from the MC renderer is 12000 bytes long. Retrieving and parsing this every time seems like an overhead that should ideally be avoided.

You are going to be streaming tracks that are tens if not hundreds of megabytes in length. Who cares about an additional 12k before each track...

Logged
Author of Whitebear Digital Media Renderer Analyser - http://www.whitebear.ch/dmra.htm
Author of Whitebear - http://www.whitebear.ch/mediaserver.htm

AndrewFG

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 3392
Re: UPnP renderer sends incorrect NOTIFY message
« Reply #16 on: March 17, 2014, 04:02:09 pm »

So we cannot even send proper XML now? :)

I know you're smiling, but it is worth pointing out that both xml forms are proper for empty strings, and every device must have code to parse the long form, and perhaps some of those devices forgot to implement code to parse the short form. In this business you have to think and code defensively...

Logged
Author of Whitebear Digital Media Renderer Analyser - http://www.whitebear.ch/dmra.htm
Author of Whitebear - http://www.whitebear.ch/mediaserver.htm

Hendrik

  • Administrator
  • Citizen of the Universe
  • *****
  • Posts: 10970
Re: UPnP renderer sends incorrect NOTIFY message
« Reply #17 on: March 17, 2014, 04:07:03 pm »

I should probably figure out why my Sony TV fails at video playback when accessing the MC DLNA server and why I cannot use it as a renderer at all. Then I could actually test some things.
Logged
~ nevcairiel
~ Author of LAV Filters

AndrewFG

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 3392
Re: UPnP renderer sends incorrect NOTIFY message
« Reply #18 on: March 17, 2014, 04:25:20 pm »

I should probably figure out why my Sony TV fails at video playback when accessing the MC DLNA server and why I cannot use it as a renderer at all. Then I could actually test some things.

Sony devices are strict on the DLNA extensions. And specifically they usually only play tracks where the server offers the track item with a resource element that has a ProtocolInfo attribute that has the full monty of DLNA flags attached.

Logged
Author of Whitebear Digital Media Renderer Analyser - http://www.whitebear.ch/dmra.htm
Author of Whitebear - http://www.whitebear.ch/mediaserver.htm

bubbleguuum

  • Junior Woodchuck
  • **
  • Posts: 76
Re: UPnP renderer sends incorrect NOTIFY message
« Reply #19 on: March 18, 2014, 05:56:03 am »

If you are dealing with UPnP devices you didn't write yourself, don't use eventing at all. It is buggy, incomplete or unusable with so many devices that you just cannot rely on it working. The only case I use eventing is to be notified of volume changes. And even that is broken with somes devices.
Logged

AndrewFG

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 3392
Re: UPnP renderer sends incorrect NOTIFY message
« Reply #20 on: March 18, 2014, 06:44:08 am »

Hi bubbleguuum -- it is good to see you over on this forum too !!

If you are dealing with UPnP devices you didn't write yourself, don't use eventing at all. It is buggy, incomplete or unusable with so many devices that you just cannot rely on it working. The only case I use eventing is to be notified of volume changes. And even that is broken with somes devices.

Hmm. That is a very black statement. But basically I do agree with you. Perhaps I see it more gray than black...

As far as MC is concerned, (bob please correct me if I am wrong), I think it first tries to get status via event notifications, and if that fails it falls back to the polling method.

IMO the state variables which change fastest are the xxxTimePosition & xxxCounterPosition variables, and these are not evented variables, so you are forced to use the polling method for them anyway. And the polling method (GetPositionInfo) does pull a lot of (meta) data in each poll, so it is quite a resource hog. But on the other hand, none of the other AV state variables change much and so the polling method can be used for them with little extra overhead.

Logged
Author of Whitebear Digital Media Renderer Analyser - http://www.whitebear.ch/dmra.htm
Author of Whitebear - http://www.whitebear.ch/mediaserver.htm

bob

  • Administrator
  • Citizen of the Universe
  • *****
  • Posts: 13946
Re: UPnP renderer sends incorrect NOTIFY message
« Reply #21 on: March 18, 2014, 01:15:10 pm »

Hi bubbleguuum -- it is good to see you over on this forum too !!

Hmm. That is a very black statement. But basically I do agree with you. Perhaps I see it more gray than black...

As far as MC is concerned, (bob please correct me if I am wrong), I think it first tries to get status via event notifications, and if that fails it falls back to the polling method.
Mostly correct. We look for the events and if we don't get them poll but we'll still deal with the events if we eventually get them.
Which reminds me that I don't think we are asking for volume change events.

Hendrik thanks for fixing the NOTIFY message.
Logged

simoncn

  • Recent member
  • *
  • Posts: 17
Re: UPnP renderer sends incorrect NOTIFY message
« Reply #22 on: March 18, 2014, 04:08:49 pm »

Hendrik thanks for fixing the NOTIFY message.

Will there be an update available soon that I could try (please)?
Logged
Pages: [1]   Go Up