/// <summary> /// Creates a new UPnP device instance at the server (device) side. /// </summary> /// <param name="deviceType">Type of the new device instance, in the format "schemas-upnp-org:device:[device-type]" or /// "vendor-domain:device:[device-type]". Note that in vendor-defined types, all dots in the vendors domain must /// be replaced by hyphens.</param> /// <param name="deviceTypeVersion">Version of the implemented device type.</param> /// <param name="uuid">Globally unique id for the new device. Vendor-defined. Should be a GUID string. That ID should /// be the same over time for a specific device instance, i.e. must survive reboots. No "uuid:" prefix.</param> /// <param name="descriptor">Data structure containing informational data about the new UPnP device.</param> public DvDevice(string deviceType, int deviceTypeVersion, string uuid, ILocalizedDeviceInformation descriptor) { _deviceType = deviceType; _deviceTypeVersion = deviceTypeVersion; _uuid = uuid; _deviceInformation = descriptor; }
/// <summary> /// Creates a new UPnP device instance at the server (device) side. /// </summary> /// <param name="deviceType">Type of the new device instance, in the format "schemas-upnp-org:device:[device-type]" or /// "vendor-domain:device:[device-type]". Note that in vendor-defined types, all dots in the vendors domain must /// be replaced by hyphens.</param> /// <param name="deviceTypeVersion">Version of the implemented device type.</param> /// <param name="uuid">Globally unique id for the new device. Vendor-defined. Should be a GUID string. That ID should /// be the same over time for a specific device instance, i.e. must survive reboots. No "uuid:" prefix.</param> /// <param name="descriptor">Data structure containing informational data about the new UPnP device.</param> public DvDevice(string deviceType, int deviceTypeVersion, string uuid, ILocalizedDeviceInformation descriptor) { _deviceType = deviceType; _deviceTypeVersion = deviceTypeVersion; _uuid = uuid; _deviceInformation = descriptor; }
public MediaServerUpnPDeviceInformation(ILocalizedDeviceInformation copyDevice) { FriendlyName = copyDevice.GetFriendlyName(CultureInfo.InvariantCulture); Manufacturer = copyDevice.GetManufacturer(CultureInfo.InvariantCulture); ManufacturerURL = copyDevice.GetManufacturerURL(CultureInfo.InvariantCulture); ModelDescription = copyDevice.GetModelDescription(CultureInfo.InvariantCulture); ModelName = copyDevice.GetModelName(CultureInfo.InvariantCulture); ModelNumber = copyDevice.GetModelNumber(CultureInfo.InvariantCulture); ModelURL = copyDevice.GetModelURL(CultureInfo.InvariantCulture); SerialNumber = copyDevice.GetSerialNumber(CultureInfo.InvariantCulture); UPC = copyDevice.GetUPC(); Icons = GetIcons(CultureInfo.InvariantCulture); }
/// <summary> /// Creates the UPnP device description XML fragment for this device, all embedded devices and all services. /// </summary> /// <param name="writer">Result XML writer to add the device descriptions fragment to.</param> /// <param name="config">UPnP endpoint which will be used to create the endpoint specific information.</param> /// <param name="culture">Culture to create the culture specific information.</param> internal void AddDeviceDescriptionsRecursive(XmlWriter writer, EndpointConfiguration config, CultureInfo culture) { GenerateDescriptionDlgt dgh = DescriptionGenerateHook; ILocalizedDeviceInformation deviceInformation = _deviceInformation; writer.WriteStartElement("device"); if (dgh != null) { dgh(writer, this, GenerationPosition.DeviceStart, config, culture); } writer.WriteElementString("deviceType", DeviceTypeVersion_URN); writer.WriteElementString("friendlyName", deviceInformation.GetFriendlyName(culture)); writer.WriteElementString("manufacturer", deviceInformation.GetManufacturer(culture)); string manufacturerURL = deviceInformation.GetManufacturerURL(culture); if (!string.IsNullOrEmpty(manufacturerURL)) { writer.WriteElementString("manufacturerURL", manufacturerURL); } string modelDescription = deviceInformation.GetModelDescription(culture); if (!string.IsNullOrEmpty(modelDescription)) { writer.WriteElementString("modelDescription", modelDescription); } writer.WriteElementString("modelName", deviceInformation.GetModelName(culture)); string modelNumber = deviceInformation.GetModelNumber(culture); if (!string.IsNullOrEmpty(modelNumber)) { writer.WriteElementString("modelNumber", modelNumber); } string modelURL = deviceInformation.GetModelURL(culture); if (!string.IsNullOrEmpty(modelURL)) { writer.WriteElementString("modelURL", modelURL); } string serialNumber = deviceInformation.GetSerialNumber(culture); if (!string.IsNullOrEmpty(serialNumber)) { writer.WriteElementString("serialNumber", serialNumber); } writer.WriteElementString("UDN", UDN); string upc = deviceInformation.GetUPC(); if (!string.IsNullOrEmpty(upc)) { writer.WriteElementString("UPC", upc); } ICollection <IconDescriptor> icons = deviceInformation.GetIcons(culture); if (icons != null && icons.Count > 0) { writer.WriteStartElement("iconList"); foreach (IconDescriptor icon in icons) { writer.WriteStartElement("icon"); writer.WriteElementString("mimetype", icon.MimeType); writer.WriteElementString("width", icon.Width.ToString()); writer.WriteElementString("height", icon.Height.ToString()); writer.WriteElementString("depth", icon.ColorDepth.ToString()); writer.WriteElementString("url", icon.GetIconURLDelegate(config.EndPointIPAddress, culture)); writer.WriteEndElement(); // icon } writer.WriteEndElement(); // iconList } ICollection <DvService> services = _services; if (services.Count > 0) { writer.WriteStartElement("serviceList"); foreach (DvService service in services) { service.AddDeviceDescriptionForService(writer, config); } writer.WriteEndElement(); // serviceList } ICollection <DvDevice> embeddedDevices = _embeddedDevices; if (embeddedDevices.Count > 0) { writer.WriteStartElement("deviceList"); foreach (DvDevice embeddedDevice in embeddedDevices) { embeddedDevice.AddDeviceDescriptionsRecursive(writer, config, culture); } writer.WriteEndElement(); // deviceList } if (dgh != null) { dgh(writer, this, GenerationPosition.AfterDeviceList, config, culture); } GetURLForEndpointDlgt presentationURLGetter = GetPresentationURLDelegate; string presentationURL = null; if (presentationURLGetter != null) { presentationURL = presentationURLGetter(config.EndPointIPAddress, culture); } if (!string.IsNullOrEmpty(presentationURL)) { writer.WriteElementString("presentationURL", presentationURL); } if (dgh != null) { dgh(writer, this, GenerationPosition.DeviceEnd, config, culture); } writer.WriteEndElement(); // device }
private static void DeviceInfoFunc(IOwinRequest request, ILocalizedDeviceInformation deviceInfo, ref ILocalizedDeviceInformation overriddenDeviceInfo) { if (request == null) return; string clientID = request.RemoteIpAddress; EndPointSettings client = ProfileManager.DetectProfileAsync(request).Result; if (client != null && client.Profile != null) { if (_customDeviceCache.ContainsKey(client.Profile.ID) == false) { MediaServerUpnPDeviceInformation dev = null; if (client.Profile.UpnpDevice.DeviceInformation.FriendlyName != null) { if (dev == null) dev = new MediaServerUpnPDeviceInformation(deviceInfo); dev.FriendlyName = client.Profile.UpnpDevice.DeviceInformation.FriendlyName; } if (client.Profile.UpnpDevice.DeviceInformation.Manufacturer != null) { if (dev == null) dev = new MediaServerUpnPDeviceInformation(deviceInfo); dev.Manufacturer = client.Profile.UpnpDevice.DeviceInformation.Manufacturer; } if (client.Profile.UpnpDevice.DeviceInformation.ManufacturerURL != null) { if (dev == null) dev = new MediaServerUpnPDeviceInformation(deviceInfo); dev.ManufacturerURL = client.Profile.UpnpDevice.DeviceInformation.ManufacturerURL; } if (client.Profile.UpnpDevice.DeviceInformation.ModelDescription != null) { if (dev == null) dev = new MediaServerUpnPDeviceInformation(deviceInfo); dev.ModelDescription = client.Profile.UpnpDevice.DeviceInformation.ModelDescription; } if (client.Profile.UpnpDevice.DeviceInformation.ModelName != null) { if (dev == null) dev = new MediaServerUpnPDeviceInformation(deviceInfo); dev.ModelName = client.Profile.UpnpDevice.DeviceInformation.ModelName; } if (client.Profile.UpnpDevice.DeviceInformation.ModelNumber != null) { if (dev == null) dev = new MediaServerUpnPDeviceInformation(deviceInfo); dev.ModelNumber = client.Profile.UpnpDevice.DeviceInformation.ModelNumber; } if (client.Profile.UpnpDevice.DeviceInformation.ModelURL != null) { if (dev == null) dev = new MediaServerUpnPDeviceInformation(deviceInfo); dev.ModelURL = client.Profile.UpnpDevice.DeviceInformation.ModelURL; } if (client.Profile.UpnpDevice.DeviceInformation.SerialNumber != null) { if (dev == null) dev = new MediaServerUpnPDeviceInformation(deviceInfo); dev.SerialNumber = client.Profile.UpnpDevice.DeviceInformation.SerialNumber; } if (client.Profile.UpnpDevice.DeviceInformation.UPC != null) { if (dev == null) dev = new MediaServerUpnPDeviceInformation(deviceInfo); dev.UPC = client.Profile.UpnpDevice.DeviceInformation.UPC; } if (dev != null) { overriddenDeviceInfo = dev; } _customDeviceCache.Add(client.Profile.ID, dev); } else { overriddenDeviceInfo = _customDeviceCache[client.Profile.ID]; } } else { Logger.Debug("MediaServerPlugin: No profile found for {0}", clientID); } }