Inserting extra XML in Device Description and Service SCPD XML

Discussion in 'Plugin Development' started by McGoober, January 16, 2012.

  1. McGoober
    • Team MediaPortal

    McGoober Retired Team Member

    Joined:
    August 13, 2006
    Messages:
    122
    Likes Received:
    103
    Gender:
    Male
    Occupation:
    Staff Software Developement Engineer
    Location:
    Cambridge, UK
    Ratings:
    +105 / 0
    Home Country:
    United Kingdom United Kingdom
    One of the requirements of DLNA is to add the following XML tag to UPNP device description and service SCPD XML.



    Code (Text):
    1. <dlna:X_DLNADOC xmlns:dlna="urn:schemas-dlna-org:device-1-0">DMR-1.50</dlna:X_DLNADOC>
    Currently there is no way for me to insert this XML tag into either of the xml documents.
    In order to make my UPNP device and services I subclass both DvDevice and DvService. I was wondering if a virtual method could be put into each of these classes, such that I could override them and insert whatever into the XML.

    Something like this...

    Code (Text):
    1.  
    2. class DvDevice {
    3.     (BLAH)
    4.  
    5.     internal void AddDeviceDescriptionsRecursive(XmlWriter writer, EndpointConfiguration config, CultureInfo culture)
    6.     {
    7.          (BLAH)
    8.          AddAdditionalDeviceDescriptions(writer, config, culture);
    9.          (BLAH)
    10.     }
    11.  
    12.  
    13.     protected virtual void AddAdditionalDeviceDescriptions(XmlWriter writer, EndpointConfiguration config, CultureInfo culture)
    14.     {
    15.         // Nothing to do here for DvDevice, but could be overriden by a subclass.
    16.     }
    17. }
    18.  

    I could then do the following...


    Code (Text):
    1.  
    2. class UPnPMediaServerDevice : DvDevice {
    3.       (BLAH)
    4.         protected override void AddAdditionalDeviceDescriptions(XmlWriter writer, EndpointConfiguration config, CultureInfo culture)
    5.         {
    6.             // Add DLNA specific Element.
    7.             writer.WriteElementString("dlna", "X_DLNADOC", "urn:schemas-dlna-org:device-1-0", "DMR-1.50");
    8.         }
    9.       (BLAH)
    10. }
    11.  
    Hope that makes sense. Any other ideas are of course welcome.
     
    • Like Like x 1
  2. Google AdSense Guest Advertisement



    to hide all adverts.
  3. Albert
    • Team MediaPortal

    Albert MP2 Developer

    Joined:
    February 18, 2008
    Messages:
    1,297
    Likes Received:
    1,125
    Gender:
    Male
    Occupation:
    Dipl.-Inform.
    Location:
    Freiburg im Breisgau, Germany
    Ratings:
    +1,130 / 1
    Home Country:
    Germany Germany
    AW: Inserting extra XML in Device Description and Service SCPD XML

    That absolutely makes sense. I'll have a look at it the next days.
     
  4. Albert
    • Team MediaPortal

    Albert MP2 Developer

    Joined:
    February 18, 2008
    Messages:
    1,297
    Likes Received:
    1,125
    Gender:
    Male
    Occupation:
    Dipl.-Inform.
    Location:
    Freiburg im Breisgau, Germany
    Ratings:
    +1,130 / 1
    Home Country:
    Germany Germany
    AW: Inserting extra XML in Device Description and Service SCPD XML

    McGoober, can you point me to a document which describes the place where to put that DLNA element in the device description and service SCPD documents? UPnP 1.1 lets me put new XML elements at the end of each complex standard element (see "UPnP-arch-DeviceArchitecture-v1 1-20081015.pdf", 2.7.1).
     
  5. McGoober
    • Team MediaPortal

    McGoober Retired Team Member

    Joined:
    August 13, 2006
    Messages:
    122
    Likes Received:
    103
    Gender:
    Male
    Occupation:
    Staff Software Developement Engineer
    Location:
    Cambridge, UK
    Ratings:
    +105 / 0
    Home Country:
    United Kingdom United Kingdom
    I've looked through the specs. DLNA is based on UPnP v1.0 and according to the spec can include vender XML anywhere in the doc so long as it is well formed. UPnP 1.1 seems more restrictive but does have a clause for UPnP 1.0 devices in UPNP device arch v1.1 part 2.7.1 under exception. I know it's not ideal.
    I'm happy with it just after the deviceList element.

    DLNA only requires the element in the device XML not the service scpd. I swear I read it needs to be in the service... Oh well.
     
  6. McGoober
    • Team MediaPortal

    McGoober Retired Team Member

    Joined:
    August 13, 2006
    Messages:
    122
    Likes Received:
    103
    Gender:
    Male
    Occupation:
    Staff Software Developement Engineer
    Location:
    Cambridge, UK
    Ratings:
    +105 / 0
    Home Country:
    United Kingdom United Kingdom
    I seem to be getting confused here. I was thinking that a complex type was an argument type from the service rather than a XML schema thing. Vendor XML can appear in any element so long as it's defined as a complex type in the schema. Therefore allowing extra under the root element.
    Did you want to allow the ability to insert XML anywhere in the document in accordance with the spec, or did you just want some arbitrary point for insertion? I guess if you desire an sdk like approach then spec conformance wins. I guess the question now is, how would one code this, given that currently XML is generated from a list of write element/attribute calls. Interesting.
     
  7. Albert
    • Team MediaPortal

    Albert MP2 Developer

    Joined:
    February 18, 2008
    Messages:
    1,297
    Likes Received:
    1,125
    Gender:
    Male
    Occupation:
    Dipl.-Inform.
    Location:
    Freiburg im Breisgau, Germany
    Ratings:
    +1,130 / 1
    Home Country:
    Germany Germany
    AW: Inserting extra XML in Device Description and Service SCPD XML

    Well, complex types can transfer their content via an XML structure, but they are used exactly like standard types.
    We use complex types for example for shares or for metadata extractor metadata structures. Such types are serialized and deserialized via extra classes, for example class Share.
    But I don't understand the connection to this thread, maybe that is what you want to say: Inserting extra XML is a new feature which needs to be coded somewhere. And yes, I also have my problems to find a way to let the user of the UPnP library insert extra XML at arbitrary positions. That's one reason why I asked you for the specs.
     
  8. McGoober
    • Team MediaPortal

    McGoober Retired Team Member

    Joined:
    August 13, 2006
    Messages:
    122
    Likes Received:
    103
    Gender:
    Male
    Occupation:
    Staff Software Developement Engineer
    Location:
    Cambridge, UK
    Ratings:
    +105 / 0
    Home Country:
    United Kingdom United Kingdom
    I just thought. What about instead of coding against a serialising XML writer, how about making a DOM object and passing that to the virtual method. That way the programmer can add whatever XML they wish to any part of the document then after they are done you can serialise it.
     
  9. Albert
    • Team MediaPortal

    Albert MP2 Developer

    Joined:
    February 18, 2008
    Messages:
    1,297
    Likes Received:
    1,125
    Gender:
    Male
    Occupation:
    Dipl.-Inform.
    Location:
    Freiburg im Breisgau, Germany
    Ratings:
    +1,130 / 1
    Home Country:
    Germany Germany
    AW: Inserting extra XML in Device Description and Service SCPD XML

    That would be possible, but expensive because we would need to build that DOM tree. If nothing else helps, we can do something like that. But I'm given to use something like the visitor pattern; the extension can inject a delegate which will be called at the end of each XML generate method, or something.
     
  10. McGoober
    • Team MediaPortal

    McGoober Retired Team Member

    Joined:
    August 13, 2006
    Messages:
    122
    Likes Received:
    103
    Gender:
    Male
    Occupation:
    Staff Software Developement Engineer
    Location:
    Cambridge, UK
    Ratings:
    +105 / 0
    Home Country:
    United Kingdom United Kingdom
    Oh, sounds interesting. Look forward to reading the code.
     
  11. Albert
    • Team MediaPortal

    Albert MP2 Developer

    Joined:
    February 18, 2008
    Messages:
    1,297
    Likes Received:
    1,125
    Gender:
    Male
    Occupation:
    Dipl.-Inform.
    Location:
    Freiburg im Breisgau, Germany
    Ratings:
    +1,130 / 1
    Home Country:
    Germany Germany
    AW: Inserting extra XML in Device Description and Service SCPD XML

    The code is pushed. See the new delegate which gets called when the device description is created.
     
    • Like Like x 2
Loading...

Users Viewing Thread (Users: 0, Guests: 0)

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice
  • About The Project

    The vision of the MediaPortal project is to create a free open source media centre application, which supports all advanced media centre functions, and is accessible to all Windows users.

    In reaching this goal we are working every day to make sure our software is one of the best.

             

  • Support MediaPortal!

    The team works very hard to make sure the community is running the best HTPC-software. We give away MediaPortal for free but hosting and software is not for us.

    Care to support our work with a few bucks? We'd really appreciate it!