Beispiel #1
0
        public Library(ISsdpNotifyProvider aListenerNotify)
        {
            // create discovery system

            iDeviceListContentDirectory = new DeviceListUpnp(ServiceContentDirectory.ServiceType(), aListenerNotify);
            iDeviceListContentDirectory.EventDeviceAdded   += ContentDirectoryAdded;
            iDeviceListContentDirectory.EventDeviceRemoved += ContentDirectoryRemoved;

            iMutex    = new Mutex();
            iJobList  = new List <IJob>();
            iJobReady = new ManualResetEvent(false);

            iCloudServers = new Dictionary <string, Device>();
            iMediaServers = new Dictionary <Device, MediaServer>();
            //iCloudServers.Add("http://89.238.133.245:26125/DeviceDescription.xml", new DeviceUpnp("http://89.238.133.245:26125/DeviceDescription.xml"));
        }
Beispiel #2
0
        public ModelMediaServer(MediaServer aMediaServer, IEventUpnpProvider aEventServer)
        {
            iMediaServer = aMediaServer;

            iServiceContentDirectory = new ServiceContentDirectory(iMediaServer.Device, aEventServer);

            iMetadata          = new container();
            iMetadata.ParentId = "Library";
            string title = iMediaServer.Name;

            if (title != null)
            {
                iMetadata.Title = title;
            }
            iMetadata.Id         = Udn;
            iMetadata.Restricted = true;

            if (title != null)
            {
                XmlDocument doc = new XmlDocument();
                doc.LoadXml(aMediaServer.Device.DeviceXml);

                XmlNamespaceManager nsm = new XmlNamespaceManager(doc.NameTable);
                nsm.AddNamespace("ns", "urn:schemas-upnp-org:device-1-0");

                XmlNodeList icons = doc.SelectNodes("/ns:root/ns:device/ns:iconList/ns:icon", nsm);

                string url    = string.Empty;
                int    width  = 0;
                int    height = 0;
                int    depth  = 0;
                foreach (XmlNode i in icons)
                {
                    // some servers do not implement this part of the XML correctly i.e. some of these
                    // elements are missing - given that this code is just to identify an icon to show
                    // for the server, it is a bit harsh to enforce the standard and forego the use of the
                    // server, so this incorrect XML is just accounted for here
                    XmlNode widthNode  = i.SelectSingleNode("ns:width", nsm);
                    XmlNode heightNode = i.SelectSingleNode("ns:height", nsm);
                    XmlNode depthNode  = i.SelectSingleNode("ns:depth", nsm);
                    XmlNode urlNode    = i.SelectSingleNode("ns:url", nsm);

                    try
                    {
                        int w = (widthNode != null) ? int.Parse(widthNode.InnerText, System.Globalization.CultureInfo.InvariantCulture) : 0;
                        int h = (heightNode != null) ? int.Parse(heightNode.InnerText, System.Globalization.CultureInfo.InvariantCulture) : 0;
                        int d = (depthNode != null) ? int.Parse(depthNode.InnerText, System.Globalization.CultureInfo.InvariantCulture) : 0;

                        if (urlNode != null && (w > width || h > height || d > depth))
                        {
                            width  = w;
                            height = h;
                            depth  = d;
                            url    = urlNode.InnerText;
                            if (url.StartsWith("/"))
                            {
                                url = url.Substring(1);
                            }
                        }
                    }
                    catch (FormatException) { }
                }

                if (url != string.Empty)
                {
                    Uri uri = new Uri(aMediaServer.Device.Location);
                    iMetadata.AlbumArtUri.Add(string.Format("http://{0}:{1}/{2}", aMediaServer.Device.IpAddress, uri.Port, url));
                }
            }
        }