xbox 360 dlna fixes

This commit is contained in:
Luke Pulverenti 2015-02-01 16:32:01 -05:00
parent 49df4a31b1
commit b2c703949c
4 changed files with 36 additions and 8 deletions

View File

@ -1,6 +1,7 @@
using MediaBrowser.Common.Configuration; using MediaBrowser.Common.Configuration;
using MediaBrowser.Common.Extensions; using MediaBrowser.Common.Extensions;
using MediaBrowser.Common.IO; using MediaBrowser.Common.IO;
using MediaBrowser.Controller;
using MediaBrowser.Controller.Dlna; using MediaBrowser.Controller.Dlna;
using MediaBrowser.Controller.Drawing; using MediaBrowser.Controller.Drawing;
using MediaBrowser.Controller.Plugins; using MediaBrowser.Controller.Plugins;
@ -27,18 +28,20 @@ namespace MediaBrowser.Dlna
private readonly IFileSystem _fileSystem; private readonly IFileSystem _fileSystem;
private readonly ILogger _logger; private readonly ILogger _logger;
private readonly IJsonSerializer _jsonSerializer; private readonly IJsonSerializer _jsonSerializer;
private readonly IServerApplicationHost _appHost;
public DlnaManager(IXmlSerializer xmlSerializer, public DlnaManager(IXmlSerializer xmlSerializer,
IFileSystem fileSystem, IFileSystem fileSystem,
IApplicationPaths appPaths, IApplicationPaths appPaths,
ILogger logger, ILogger logger,
IJsonSerializer jsonSerializer) IJsonSerializer jsonSerializer, IServerApplicationHost appHost)
{ {
_xmlSerializer = xmlSerializer; _xmlSerializer = xmlSerializer;
_fileSystem = fileSystem; _fileSystem = fileSystem;
_appPaths = appPaths; _appPaths = appPaths;
_logger = logger; _logger = logger;
_jsonSerializer = jsonSerializer; _jsonSerializer = jsonSerializer;
_appHost = appHost;
} }
public IEnumerable<DeviceProfile> GetProfiles() public IEnumerable<DeviceProfile> GetProfiles()
@ -480,7 +483,7 @@ namespace MediaBrowser.Dlna
var profile = GetProfile(headers) ?? var profile = GetProfile(headers) ??
GetDefaultProfile(); GetDefaultProfile();
return new DescriptionXmlBuilder(profile, serverUuId, serverAddress).GetXml(); return new DescriptionXmlBuilder(profile, serverUuId, serverAddress, _appHost.FriendlyName).GetXml();
} }
public ImageStream GetIcon(string filename) public ImageStream GetIcon(string filename)

View File

@ -4,6 +4,9 @@ using MediaBrowser.Model.Dlna.Profiles;
namespace MediaBrowser.Dlna.Profiles namespace MediaBrowser.Dlna.Profiles
{ {
/// <summary>
/// Good info on xbox 360 requirements: https://code.google.com/p/jems/wiki/XBox360Notes
/// </summary>
[XmlRoot("Profile")] [XmlRoot("Profile")]
public class Xbox360Profile : DefaultProfile public class Xbox360Profile : DefaultProfile
{ {
@ -11,8 +14,13 @@ namespace MediaBrowser.Dlna.Profiles
{ {
Name = "Xbox 360"; Name = "Xbox 360";
ModelName = "Windows Media Player Sharing"; // Required according to above
ModelName = "Windows Media Connect";
ModelNumber = "12.0"; ModelNumber = "12.0";
FriendlyName = "Media Browser on ${ServerName} : 1 : Windows Media Connect";
ModelUrl = "http://www.microsoft.com/"; ModelUrl = "http://www.microsoft.com/";
Manufacturer = "Microsoft Corporation"; Manufacturer = "Microsoft Corporation";
ManufacturerUrl = "http://www.microsoft.com/"; ManufacturerUrl = "http://www.microsoft.com/";

View File

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

View File

@ -1,8 +1,10 @@
using MediaBrowser.Dlna.Common; using MediaBrowser.Dlna.Common;
using MediaBrowser.Model.Dlna; using MediaBrowser.Model.Dlna;
using MediaBrowser.Model.Extensions;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Globalization; using System.Globalization;
using System.Linq;
using System.Security; using System.Security;
using System.Text; using System.Text;
@ -15,8 +17,9 @@ namespace MediaBrowser.Dlna.Server
private readonly CultureInfo _usCulture = new CultureInfo("en-US"); private readonly CultureInfo _usCulture = new CultureInfo("en-US");
private readonly string _serverUdn; private readonly string _serverUdn;
private readonly string _serverAddress; 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)) if (string.IsNullOrWhiteSpace(serverUdn))
{ {
@ -31,6 +34,7 @@ namespace MediaBrowser.Dlna.Server
_profile = profile; _profile = profile;
_serverUdn = serverUdn; _serverUdn = serverUdn;
_serverAddress = serverAddress; _serverAddress = serverAddress;
_serverName = serverName;
} }
private bool EnableAbsoluteUrls 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\">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("<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("<deviceType>urn:schemas-upnp-org:device:MediaServer:1</deviceType>");
builder.Append("<manufacturer>" + SecurityElement.Escape(_profile.Manufacturer ?? string.Empty) + "</manufacturer>"); builder.Append("<manufacturer>" + SecurityElement.Escape(_profile.Manufacturer ?? string.Empty) + "</manufacturer>");
builder.Append("<manufacturerURL>" + SecurityElement.Escape(_profile.ManufacturerUrl ?? string.Empty) + "</manufacturerURL>"); builder.Append("<manufacturerURL>" + SecurityElement.Escape(_profile.ManufacturerUrl ?? string.Empty) + "</manufacturerURL>");
@ -95,7 +99,7 @@ namespace MediaBrowser.Dlna.Server
if (!EnableAbsoluteUrls) if (!EnableAbsoluteUrls)
{ {
builder.Append("<URLBase>" + SecurityElement.Escape(_serverAddress) + "</URLBase>"); //builder.Append("<URLBase>" + SecurityElement.Escape(_serverAddress) + "</URLBase>");
} }
if (!string.IsNullOrWhiteSpace(_profile.SonyAggregationFlags)) 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) private void AppendIconList(StringBuilder builder)
{ {
builder.Append("<iconList>"); builder.Append("<iconList>");