The Free Software Media System - Server Backend & API
update ssdp handler
Luke Pulverentif988413e4b3c
diff --git a/MediaBrowser.Dlna/Main/DlnaEntryPoint.cs b/MediaBrowser.Dlna/Main/DlnaEntryPoint.csindex a8aedaed87..f1eeb0a0a3 100644--- a/MediaBrowser.Dlna/Main/DlnaEntryPoint.cs+++ b/MediaBrowser.Dlna/Main/DlnaEntryPoint.cs@@ -19,6 +19,7 @@ using System.Net;using System.Threading.Tasks;using MediaBrowser.Controller.MediaEncoding;using Rssdp;+using Rssdp.Infrastructure;namespace MediaBrowser.Dlna.Main{@@ -154,8 +155,14 @@ namespace MediaBrowser.Dlna.Main}}+ private void LogMessage(string msg)+ {+ //_logger.Debug(msg);+ }+private void StartPublishing(){+ SsdpDevicePublisherBase.LogFunction = LogMessage;_Publisher = new SsdpDevicePublisher();}@@ -237,46 +244,64 @@ namespace MediaBrowser.Dlna.Mainvar udn = (addressString).GetMD5().ToString("N");- var services = new List<string>+ var fullService = "urn:schemas-upnp-org:device:MediaServer:1";++ _logger.Info("Registering publisher for {0} on {1}", fullService, addressString);++ var descriptorUri = "/dlna/" + udn + "/description.xml";+ var uri = new Uri(_appHost.GetLocalApiUrl(address) + descriptorUri);++ var device = new SsdpRootDevice+ {+ CacheLifetime = TimeSpan.FromSeconds(cacheLength), //How long SSDP clients can cache this info.+ Location = uri, // Must point to the URL that serves your devices UPnP description document.+ FriendlyName = "Emby Server",+ Manufacturer = "Emby",+ ModelName = "Emby Server",+ Uuid = udn+ // This must be a globally unique value that survives reboots etc. Get from storage or embedded hardware etc.+ };++ SetProperies(device, fullService);+ _Publisher.AddDevice(device);++ var embeddedDevices = new List<string>{- "urn:schemas-upnp-org:device:MediaServer:1","urn:schemas-upnp-org:service:ContentDirectory:1","urn:schemas-upnp-org:service:ConnectionManager:1","urn:microsoft.com:service:X_MS_MediaReceiverRegistrar:1"};- foreach (var fullService in services)+ foreach (var subDevice in embeddedDevices){- _logger.Info("Registering publisher for {0} on {1}", fullService, addressString);-- var descriptorURI = "/dlna/" + udn + "/description.xml";- var uri = new Uri(_appHost.GetLocalApiUrl(address) + descriptorURI);-- var service = fullService.Replace("urn:", string.Empty).Replace(":1", string.Empty);-- var serviceParts = service.Split(':');-- var deviceTypeNamespace = serviceParts[0].Replace('.', '-');-- var device = new SsdpRootDevice+ var embeddedDevice = new SsdpEmbeddedDevice{- CacheLifetime = TimeSpan.FromSeconds(cacheLength), //How long SSDP clients can cache this info.- Location = uri, // Must point to the URL that serves your devices UPnP description document.- DeviceTypeNamespace = deviceTypeNamespace,- DeviceClass = serviceParts[1],- DeviceType = serviceParts[2],- FriendlyName = "Emby Server",- Manufacturer = "Emby",- ModelName = "Emby Server",+ FriendlyName = device.FriendlyName,+ Manufacturer = device.Manufacturer,+ ModelName = device.ModelName,Uuid = udn// This must be a globally unique value that survives reboots etc. Get from storage or embedded hardware etc.};- _Publisher.AddDevice(device);+ SetProperies(embeddedDevice, subDevice);+ device.AddDevice(embeddedDevice);}}}+ private void SetProperies(SsdpDevice device, string fullDeviceType)+ {+ var service = fullDeviceType.Replace("urn:", string.Empty).Replace(":1", string.Empty);++ var serviceParts = service.Split(':');++ var deviceTypeNamespace = serviceParts[0].Replace('.', '-');++ device.DeviceTypeNamespace = deviceTypeNamespace;+ device.DeviceClass = serviceParts[1];+ device.DeviceType = serviceParts[2];+ }+private readonly object _syncLock = new object();private void StartPlayToManager(){diff --git a/MediaBrowser.WebDashboard/MediaBrowser.WebDashboard.csproj b/MediaBrowser.WebDashboard/MediaBrowser.WebDashboard.csprojindex 36dd12651c..a561a48afc 100644--- a/MediaBrowser.WebDashboard/MediaBrowser.WebDashboard.csproj+++ b/MediaBrowser.WebDashboard/MediaBrowser.WebDashboard.csproj@@ -986,9 +986,6 @@<Content Include="dashboard-ui\scripts\userparentalcontrol.js"><CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory></Content>- <Content Include="dashboard-ui\scripts\wizardservice.js">- <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>- </Content><Content Include="dashboard-ui\scripts\wizardsettings.js"><CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory></Content>@@ -1034,9 +1031,6 @@<Content Include="dashboard-ui\wizardlivetvtuner.html"><CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory></Content>- <Content Include="dashboard-ui\wizardservice.html">- <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>- </Content><Content Include="dashboard-ui\wizardsettings.html"><CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory></Content>