hzeller / gmrender-resurrect

Resource efficient UPnP/DLNA renderer, optimal for Raspberry Pi, CuBox or a general MediaServer. Fork of GMediaRenderer to add some features to make it usable.
GNU General Public License v2.0
834 stars 202 forks source link

Problem using gmrender-resurrect with Java Cling: Incorrect namespace #42

Closed atschwarz closed 10 years ago

atschwarz commented 10 years ago

Hi,

I'm writing currently a Java application, based on the Java Cling library.

When I tried to subscribe my app for an Upnp event, everything works fine for events published by AVTransportService. But if I listen to events of the RenderingControlService, cling failed to parse the xml. The reason is, that you're using the wrong namespace for the special RenderingControlService. Your xml looks like this for both event types:

<Event xmlns="urn:schemas-upnp-org:metadata-1-0/AVT/">...</Event>

This is correct for AVTransportService-Events. But for RenderingControlService-Events, the right syntax would look like this:

<Event xmlns="urn:schemas-upnp-org:metadata-1-0/RCS/">...</Event>

Can you please fix this? Thank's in advance and best regards, Andreas

atschwarz commented 10 years ago

Hi again,

another issue on the same topic. After fixing the above error by correct the xml namespace, the XML Parser of cling again complains. The event xml looks like this:

<?xml version="1.0"?>
<Event xmlns="urn:schemas-upnp-org:metadata-1-0/RCS/">
    <InstanceID val="0">
        <GreenVideoGain val="0"/>
        <BlueVideoBlackLevel val="0"/>
        <VerticalKeystone val="0"/>
        <GreenVideoBlackLevel val="0"/>
        <Volume val="70"/>
        <Loudness val="0"/>
        <A_ARG_TYPE_InstanceID val="0"/>
        <RedVideoGain val="0"/>
        <ColorTemperature val="0"/>
        <Sharpness val="0"/>
        <A_ARG_TYPE_PresetName val=""/>
        <RedVideoBlackLevel val="0"/>
        <BlueVideoGain val="0"/>
        <Mute val="0"/>
        <A_ARG_TYPE_Channel val=""/>
        <HorizontalKeystone val="0"/>
        <VolumeDB val="-3072"/>
        <PresetNameList val=""/>
        <Contrast val="0"/>
        <Brightness val="0"/>
    </InstanceID>
</Event>

The error is the following:

Caused by: org.xml.sax.SAXException: cvc-complex-type.4: Attribute 'channel' must appear on element 'Volume'.
org.xml.sax.SAXParseException; lineNumber: 8; columnNumber: 18; cvc-complex-type.4: Attribute 'channel' must appear on element 'Volume'.

The underlying xml schema looks like this:

    <xsd:element name="Volume">
        <xsd:complexType>
            <xsd:attribute name="val" type="xsd:unsignedInt"
                           use="required"/>
            <xsd:attribute name="channel" type="xsd:string"
                           use="required"/>
        </xsd:complexType>
    </xsd:element>

You find the full schema at https://raw.github.com/4thline/cling/master/support/src/main/resources/org/fourthline/cling/support/renderingcontrol/metadata-1.0-rcs.xsd

The author also add a note at the beginning of the file, which explains the problem with the event namespaces:

<!--
TODO: UPNP VIOLATION: RenderingControl 1.0 specification schema says "/RCS/" but examples
in the spec say "/AVT_RCS". We had "/AVT_RCS", then "/RCS", now we have "/RCS/", let's
see who complains.
-->

Thanks and best regards, Andreas

hzeller commented 10 years ago

Thanks for the report. Good to have XML parsers that are a bit more strict to uncover these problems. I'll have a look.

hzeller commented 10 years ago

Please check it out, this should fix both these issues.

atschwarz commented 10 years ago

Thanks for the quick fix. But a small change is necessary, because you forgot the Loudness-Attribute.

     Loudness

    ============================================================-->
    <xsd:element name="Loudness">
        <xsd:complexType>
            <xsd:attribute name="val" type="xsd:boolean"
                           use="required"/>
            <xsd:attribute name="channel" type="xsd:string"
                           use="required"/>
        </xsd:complexType>
    </xsd:element>

So you have to change the if-condition inside variable_container.c to

if (strcmp(name, "Volume") == 0
            || strcmp(name, "VolumeDB") == 0
            || strcmp(name, "Mute") == 0
            || strcmp(name, "Loudness") == 0) {
                xmlelement_set_attribute(builder->change_event_doc,
                                         xml_value, "channel", "Master");
        }

I've already tested this small change on my local version and now the XML-Parser parses the event xml complaint-free ;-) Thanks again and best regards, Andreas

hzeller commented 10 years ago

Alright, should be working now. Thanks for the report!