From cc98b04c5d773ba7df480136ab53f0fef67e09c7 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Tue, 16 Feb 2016 12:09:32 -0500 Subject: [PATCH] fix xbox one, ps4 not seeing dlna server --- MediaBrowser.Dlna/DlnaManager.cs | 4 +++- MediaBrowser.Dlna/Main/DlnaEntryPoint.cs | 12 ++++++------ MediaBrowser.Dlna/Server/DescriptionXmlBuilder.cs | 2 +- MediaBrowser.Dlna/Server/UpnpDevice.cs | 6 +++--- MediaBrowser.Dlna/Ssdp/SsdpHandler.cs | 6 +++--- .../HttpServer/ResponseFilter.cs | 1 + 6 files changed, 17 insertions(+), 14 deletions(-) diff --git a/MediaBrowser.Dlna/DlnaManager.cs b/MediaBrowser.Dlna/DlnaManager.cs index 63a36744f1..dd5c4b77e7 100644 --- a/MediaBrowser.Dlna/DlnaManager.cs +++ b/MediaBrowser.Dlna/DlnaManager.cs @@ -488,7 +488,9 @@ namespace MediaBrowser.Dlna var profile = GetProfile(headers) ?? GetDefaultProfile(); - return new DescriptionXmlBuilder(profile, serverUuId, serverAddress, _appHost.FriendlyName, serverUuId.GetMD5().ToString("N")).GetXml(); + var serverId = _appHost.SystemId; + + return new DescriptionXmlBuilder(profile, serverUuId, serverAddress, _appHost.FriendlyName, serverId).GetXml(); } public ImageStream GetIcon(string filename) diff --git a/MediaBrowser.Dlna/Main/DlnaEntryPoint.cs b/MediaBrowser.Dlna/Main/DlnaEntryPoint.cs index d79ef9eafa..2133888b61 100644 --- a/MediaBrowser.Dlna/Main/DlnaEntryPoint.cs +++ b/MediaBrowser.Dlna/Main/DlnaEntryPoint.cs @@ -157,9 +157,9 @@ namespace MediaBrowser.Dlna.Main //} var addressString = address.ToString(); - var guid = addressString.GetMD5(); + var udn = addressString.GetMD5().ToString("N"); - var descriptorURI = "/dlna/" + guid.ToString("N") + "/description.xml"; + var descriptorURI = "/dlna/" + udn + "/description.xml"; var uri = new Uri(_appHost.GetLocalApiUrl(addressString) + descriptorURI); @@ -170,12 +170,12 @@ namespace MediaBrowser.Dlna.Main "urn:schemas-upnp-org:service:ContentDirectory:1", "urn:schemas-upnp-org:service:ConnectionManager:1", "urn:microsoft.com:service:X_MS_MediaReceiverRegistrar:1", - "uuid:" + guid.ToString("N") + "uuid:" + udn }; - _ssdpHandler.RegisterNotification(guid, uri, address, services); + _ssdpHandler.RegisterNotification(udn, uri, address, services); - _registeredServerIds.Add(guid.ToString("N")); + _registeredServerIds.Add(udn); } } @@ -240,7 +240,7 @@ namespace MediaBrowser.Dlna.Main { try { - _ssdpHandler.UnregisterNotification(new Guid(id)); + _ssdpHandler.UnregisterNotification(id); } catch (Exception ex) { diff --git a/MediaBrowser.Dlna/Server/DescriptionXmlBuilder.cs b/MediaBrowser.Dlna/Server/DescriptionXmlBuilder.cs index 281dee3e07..386370596c 100644 --- a/MediaBrowser.Dlna/Server/DescriptionXmlBuilder.cs +++ b/MediaBrowser.Dlna/Server/DescriptionXmlBuilder.cs @@ -122,7 +122,7 @@ namespace MediaBrowser.Dlna.Server builder.Append("" + SecurityElement.Escape(_profile.SerialNumber) + ""); } - builder.Append("uuid:" + SecurityElement.Escape(_serverId) + ""); + builder.Append("uuid:" + SecurityElement.Escape(_serverUdn) + ""); builder.Append("" + SecurityElement.Escape(_serverAddress) + ""); if (!EnableAbsoluteUrls) diff --git a/MediaBrowser.Dlna/Server/UpnpDevice.cs b/MediaBrowser.Dlna/Server/UpnpDevice.cs index 870e3c24f9..10eaeb0535 100644 --- a/MediaBrowser.Dlna/Server/UpnpDevice.cs +++ b/MediaBrowser.Dlna/Server/UpnpDevice.cs @@ -8,10 +8,10 @@ namespace MediaBrowser.Dlna.Server public readonly Uri Descriptor; public readonly string Type; public readonly string USN; - public readonly Guid Uuid; + public readonly string Uuid; public readonly IPAddress Address; - public UpnpDevice(Guid aUuid, string aType, Uri aDescriptor, IPAddress address) + public UpnpDevice(string aUuid, string aType, Uri aDescriptor, IPAddress address) { Uuid = aUuid; Type = aType; @@ -25,7 +25,7 @@ namespace MediaBrowser.Dlna.Server } else { - USN = String.Format("uuid:{0}::{1}", Uuid.ToString("N"), Type); + USN = String.Format("uuid:{0}::{1}", Uuid, Type); } } } diff --git a/MediaBrowser.Dlna/Ssdp/SsdpHandler.cs b/MediaBrowser.Dlna/Ssdp/SsdpHandler.cs index 82fc5e4665..881f70165e 100644 --- a/MediaBrowser.Dlna/Ssdp/SsdpHandler.cs +++ b/MediaBrowser.Dlna/Ssdp/SsdpHandler.cs @@ -36,7 +36,7 @@ namespace MediaBrowser.Dlna.Ssdp private Timer _notificationTimer; private bool _isDisposed; - private readonly ConcurrentDictionary> _devices = new ConcurrentDictionary>(); + private readonly ConcurrentDictionary> _devices = new ConcurrentDictionary>(); private readonly IApplicationHost _appHost; @@ -451,7 +451,7 @@ namespace MediaBrowser.Dlna.Ssdp SendDatagram(msg, _ssdpEndp, new IPEndPoint(dev.Address, 0), true); } - public void RegisterNotification(Guid uuid, Uri descriptionUri, IPAddress address, IEnumerable services) + public void RegisterNotification(string uuid, Uri descriptionUri, IPAddress address, IEnumerable services) { var list = _devices.GetOrAdd(uuid, new List()); @@ -461,7 +461,7 @@ namespace MediaBrowser.Dlna.Ssdp _logger.Debug("Registered mount {0} at {1}", uuid, descriptionUri); } - public void UnregisterNotification(Guid uuid) + public void UnregisterNotification(string uuid) { List dl; if (_devices.TryRemove(uuid, out dl)) diff --git a/MediaBrowser.Server.Implementations/HttpServer/ResponseFilter.cs b/MediaBrowser.Server.Implementations/HttpServer/ResponseFilter.cs index 4ef9d52774..f993d4437a 100644 --- a/MediaBrowser.Server.Implementations/HttpServer/ResponseFilter.cs +++ b/MediaBrowser.Server.Implementations/HttpServer/ResponseFilter.cs @@ -61,6 +61,7 @@ namespace MediaBrowser.Server.Implementations.HttpServer if (!hasOptions.Options.ContainsKey("Server")) { hasOptions.Options["Server"] = "Mono-HTTPAPI/1.1, UPnP/1.0 DLNADOC/1.50"; + //hasOptions.Options["Server"] = "Mono-HTTPAPI/1.1"; } // Content length has to be explicitly set on on HttpListenerResponse or it won't be happy