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

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

Closed
atschwarz opened this issue Oct 11, 2013 · 5 comments
Closed

Comments

@atschwarz
Copy link

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
Copy link
Author

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
Copy link
Owner

hzeller commented Oct 12, 2013

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 added a commit that referenced this issue Oct 23, 2013
  Thanks to @astahlhofen to notice. This should fix the first part of
  bug #42.
@hzeller
Copy link
Owner

hzeller commented Oct 23, 2013

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

@atschwarz
Copy link
Author

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
Copy link
Owner

hzeller commented Oct 23, 2013

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

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

No branches or pull requests

2 participants