diff --git a/MediaBrowser.Dlna/DlnaManager.cs b/MediaBrowser.Dlna/DlnaManager.cs index 872c079391..f0f295c831 100644 --- a/MediaBrowser.Dlna/DlnaManager.cs +++ b/MediaBrowser.Dlna/DlnaManager.cs @@ -1,6 +1,7 @@ using MediaBrowser.Common.Configuration; using MediaBrowser.Common.Extensions; using MediaBrowser.Common.IO; +using MediaBrowser.Controller; using MediaBrowser.Controller.Dlna; using MediaBrowser.Controller.Drawing; using MediaBrowser.Controller.Plugins; @@ -27,18 +28,20 @@ namespace MediaBrowser.Dlna private readonly IFileSystem _fileSystem; private readonly ILogger _logger; private readonly IJsonSerializer _jsonSerializer; + private readonly IServerApplicationHost _appHost; public DlnaManager(IXmlSerializer xmlSerializer, IFileSystem fileSystem, IApplicationPaths appPaths, ILogger logger, - IJsonSerializer jsonSerializer) + IJsonSerializer jsonSerializer, IServerApplicationHost appHost) { _xmlSerializer = xmlSerializer; _fileSystem = fileSystem; _appPaths = appPaths; _logger = logger; _jsonSerializer = jsonSerializer; + _appHost = appHost; } public IEnumerable GetProfiles() @@ -480,7 +483,7 @@ namespace MediaBrowser.Dlna var profile = GetProfile(headers) ?? GetDefaultProfile(); - return new DescriptionXmlBuilder(profile, serverUuId, serverAddress).GetXml(); + return new DescriptionXmlBuilder(profile, serverUuId, serverAddress, _appHost.FriendlyName).GetXml(); } public ImageStream GetIcon(string filename) diff --git a/MediaBrowser.Dlna/Profiles/Xbox360Profile.cs b/MediaBrowser.Dlna/Profiles/Xbox360Profile.cs index 7b04ae6d73..87a68df72f 100644 --- a/MediaBrowser.Dlna/Profiles/Xbox360Profile.cs +++ b/MediaBrowser.Dlna/Profiles/Xbox360Profile.cs @@ -4,6 +4,9 @@ using MediaBrowser.Model.Dlna.Profiles; namespace MediaBrowser.Dlna.Profiles { + /// + /// Good info on xbox 360 requirements: https://code.google.com/p/jems/wiki/XBox360Notes + /// [XmlRoot("Profile")] public class Xbox360Profile : DefaultProfile { @@ -11,8 +14,13 @@ namespace MediaBrowser.Dlna.Profiles { Name = "Xbox 360"; - ModelName = "Windows Media Player Sharing"; + // Required according to above + ModelName = "Windows Media Connect"; + ModelNumber = "12.0"; + + FriendlyName = "Media Browser on ${ServerName} : 1 : Windows Media Connect"; + ModelUrl = "http://www.microsoft.com/"; Manufacturer = "Microsoft Corporation"; ManufacturerUrl = "http://www.microsoft.com/"; diff --git a/MediaBrowser.Dlna/Profiles/Xml/Xbox 360.xml b/MediaBrowser.Dlna/Profiles/Xml/Xbox 360.xml index 17100466f8..588623708f 100644 --- a/MediaBrowser.Dlna/Profiles/Xml/Xbox 360.xml +++ b/MediaBrowser.Dlna/Profiles/Xml/Xbox 360.xml @@ -8,10 +8,10 @@ - Media Browser + Media Browser on ${ServerName} : 1 : Windows Media Connect Microsoft Corporation http://www.microsoft.com/ - Windows Media Player Sharing + Windows Media Connect Media Browser 12.0 http://www.microsoft.com/ diff --git a/MediaBrowser.Dlna/Server/DescriptionXmlBuilder.cs b/MediaBrowser.Dlna/Server/DescriptionXmlBuilder.cs index ae544cb6c7..824032689a 100644 --- a/MediaBrowser.Dlna/Server/DescriptionXmlBuilder.cs +++ b/MediaBrowser.Dlna/Server/DescriptionXmlBuilder.cs @@ -1,8 +1,10 @@ using MediaBrowser.Dlna.Common; using MediaBrowser.Model.Dlna; +using MediaBrowser.Model.Extensions; using System; using System.Collections.Generic; using System.Globalization; +using System.Linq; using System.Security; using System.Text; @@ -15,8 +17,9 @@ namespace MediaBrowser.Dlna.Server private readonly CultureInfo _usCulture = new CultureInfo("en-US"); private readonly string _serverUdn; private readonly string _serverAddress; + private readonly string _serverName; - public DescriptionXmlBuilder(DeviceProfile profile, string serverUdn, string serverAddress) + public DescriptionXmlBuilder(DeviceProfile profile, string serverUdn, string serverAddress, string serverName) { if (string.IsNullOrWhiteSpace(serverUdn)) { @@ -31,6 +34,7 @@ namespace MediaBrowser.Dlna.Server _profile = profile; _serverUdn = serverUdn; _serverAddress = serverAddress; + _serverName = serverName; } private bool EnableAbsoluteUrls @@ -81,7 +85,7 @@ namespace MediaBrowser.Dlna.Server builder.Append("M-DMS-1.50"); builder.Append("" + SecurityElement.Escape(_profile.XDlnaDoc ?? string.Empty) + ""); - builder.Append("" + SecurityElement.Escape(_profile.FriendlyName ?? string.Empty) + ""); + builder.Append("" + SecurityElement.Escape(GetFriendlyName()) + ""); builder.Append("urn:schemas-upnp-org:device:MediaServer:1"); builder.Append("" + SecurityElement.Escape(_profile.Manufacturer ?? string.Empty) + ""); builder.Append("" + SecurityElement.Escape(_profile.ManufacturerUrl ?? string.Empty) + ""); @@ -95,7 +99,7 @@ namespace MediaBrowser.Dlna.Server if (!EnableAbsoluteUrls) { - builder.Append("" + SecurityElement.Escape(_serverAddress) + ""); + //builder.Append("" + SecurityElement.Escape(_serverAddress) + ""); } if (!string.IsNullOrWhiteSpace(_profile.SonyAggregationFlags)) @@ -104,6 +108,19 @@ namespace MediaBrowser.Dlna.Server } } + private string GetFriendlyName() + { + var name = _profile.FriendlyName ?? string.Empty; + + var characters = _serverName.Where(c => (char.IsLetterOrDigit(c) || c == '-')).ToArray(); + + var serverName = new string(characters); + + name = name.Replace("${ServerName}", serverName, StringComparison.OrdinalIgnoreCase); + + return name; + } + private void AppendIconList(StringBuilder builder) { builder.Append("");