Browse Source

xbox 360 dlna fixes

Luke Pulverenti 10 years ago
parent
commit
b2c703949c

+ 5 - 2
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<DeviceProfile> 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)

+ 9 - 1
MediaBrowser.Dlna/Profiles/Xbox360Profile.cs

@@ -4,6 +4,9 @@ using MediaBrowser.Model.Dlna.Profiles;
 
 namespace MediaBrowser.Dlna.Profiles
 {
+    /// <summary>
+    /// Good info on xbox 360 requirements: https://code.google.com/p/jems/wiki/XBox360Notes
+    /// </summary>
     [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/";

+ 2 - 2
MediaBrowser.Dlna/Profiles/Xml/Xbox 360.xml

@@ -8,10 +8,10 @@
       <HttpHeaderInfo name="User-Agent" value="Xenon" match="Substring" />
     </Headers>
   </Identification>
-  <FriendlyName>Media Browser</FriendlyName>
+  <FriendlyName>Media Browser on ${ServerName} : 1 : Windows Media Connect</FriendlyName>
   <Manufacturer>Microsoft Corporation</Manufacturer>
   <ManufacturerUrl>http://www.microsoft.com/</ManufacturerUrl>
-  <ModelName>Windows Media Player Sharing</ModelName>
+  <ModelName>Windows Media Connect</ModelName>
   <ModelDescription>Media Browser</ModelDescription>
   <ModelNumber>12.0</ModelNumber>
   <ModelUrl>http://www.microsoft.com/</ModelUrl>

+ 20 - 3
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("<dlna:X_DLNADOC xmlns:dlna=\"urn:schemas-dlna-org:device-1-0\">M-DMS-1.50</dlna:X_DLNADOC>");
             builder.Append("<dlna:X_DLNADOC xmlns:dlna=\"urn:schemas-dlna-org:device-1-0\">" + SecurityElement.Escape(_profile.XDlnaDoc ?? string.Empty) + "</dlna:X_DLNADOC>");
 
-            builder.Append("<friendlyName>" + SecurityElement.Escape(_profile.FriendlyName ?? string.Empty) + "</friendlyName>");
+            builder.Append("<friendlyName>" + SecurityElement.Escape(GetFriendlyName()) + "</friendlyName>");
             builder.Append("<deviceType>urn:schemas-upnp-org:device:MediaServer:1</deviceType>");
             builder.Append("<manufacturer>" + SecurityElement.Escape(_profile.Manufacturer ?? string.Empty) + "</manufacturer>");
             builder.Append("<manufacturerURL>" + SecurityElement.Escape(_profile.ManufacturerUrl ?? string.Empty) + "</manufacturerURL>");
@@ -95,7 +99,7 @@ namespace MediaBrowser.Dlna.Server
 
             if (!EnableAbsoluteUrls)
             {
-                builder.Append("<URLBase>" + SecurityElement.Escape(_serverAddress) + "</URLBase>");
+                //builder.Append("<URLBase>" + SecurityElement.Escape(_serverAddress) + "</URLBase>");
             }
 
             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("<iconList>");