Setting of URLBase

2004-03-09
2004-03-11
  • Oliver Newell

    Oliver Newell - 2004-03-09

    Hi - I have seen CLink's (v1.2) control point get confused occasionally when a device doesn't specify a URLBase in it's description file.  I see a bunch of code at various places that deals with a missing URLBase, but it doesn't handle every case (Intel's Media Renderer seems to cause it difficulty).  Below is
    a patch I put in upnp/ControlPoint.java to set the URLBase immediately after the description is read if the description doesn't have a URLBase element.  It seems to work with
    the URLBase 'ideosyncracies' of the UPNP devices I have tested so far (documented below)

    This issue may already have been addressed with v1.3.2 -
    if so I'm too late! (Note that the patch below was made to
    the 1.3.2 code which I just downloaded)

    -Oliver

    ------------------------------------------------------------------------------------------
        private synchronized void addDevice(SSDPPacket ssdpPacket)

        {
            if (ssdpPacket.isRootDevice() == false)
                return;
               
            String usn = ssdpPacket.getUSN();

            String udn = USN.getUDN(usn);

            Device dev = getDevice(udn);

            if (dev != null) {
                dev.setSSDPPacket(ssdpPacket);
                return;

            }
           
            String location = ssdpPacket.getLocation();

            try {   

                Parser parser = UPnP.getXMLParser();
                Node rootNode = parser.parse(location);

                Device rootDev = getDevice(rootNode);
                if (rootDev == null)
                    return;

          //
          // If no URLBase element was found in description, create one
          // based on the location, as per the UPNP spec. Use the entire
          // string preceding the description file as the URLBase. Most
          // commonly, the location will look something like:
          //
          //   http://192.168.1.10:49152/description.xml
          //
          // and the URLBase would be 'http://192.168.1.10:49152'
          //
          // In some cases (Sony UPNP servers), I have seen locations like:
          //
          //   http://192.168.1.10:49152/PhotoServer/description.xml
          //
          // In this case, the URLBase is 'http://192.168.1.10:49152/PhotoServer'
          //
          // Lastly, another somewhat special case is where there is no
          // XML description file specified explicitly in the location string:
          // (The Intel Media Renderer is set up this way)
          //
          //   http://192.168.1.10:49152/
          //
          // In this case, the URLBase is 'http://192.168.1.10:49152'
          //
          //

          String urlBase = rootDev.getURLBase();
          //System.out.println("URLBase from description file is: " + urlBase );
          if( urlBase == null || urlBase == "" )
          {
            // Look for last trailing '/' after the double 'http://' string.
            // Everything up to and including the trailing '/' is the URLBase
            int index = location.lastIndexOf('/');
            if( index < 8 )
            {
              // No trailing slash present - use entire location string as URLBase
              urlBase = location;
            }
            else
            {
              urlBase = location.substring( 0, index );
            }
           
            //System.out.println("Setting URLBase to: " + urlBase );
            rootDev.setURLBase( urlBase );
          }

          // (End of OJN additions)

                rootDev.setSSDPPacket(ssdpPacket);
                addDevice(rootNode);
            }

            catch (ParserException e) {

                Debug.warning(ssdpPacket.toString());
                Debug.warning(e);

            }

        }

     
    • Satoshi Konno

      Satoshi Konno - 2004-03-11

      Hi Oliver,

      Thanks for your useful report :-)

      As you saying, I seem that the latest CyberLink can connect with Sony Cocoon and Intel Media Server cerrently, but I will check your URL base problem with some UPnP devices in more detail.

       

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks