diff --git a/MediaBrowser.Api/Dlna/DlnaServerService.cs b/MediaBrowser.Api/Dlna/DlnaServerService.cs index 038f1d6c19..24a6c52d02 100644 --- a/MediaBrowser.Api/Dlna/DlnaServerService.cs +++ b/MediaBrowser.Api/Dlna/DlnaServerService.cs @@ -18,25 +18,31 @@ namespace MediaBrowser.Api.Dlna public string UuId { get; set; } } - [Route("/Dlna/contentdirectory/contentdirectory.xml", "GET", Summary = "Gets dlna content directory xml")] - [Route("/Dlna/contentdirectory/contentdirectory", "GET", Summary = "Gets dlna content directory xml")] + [Route("/Dlna/{UuId}/contentdirectory/contentdirectory.xml", "GET", Summary = "Gets dlna content directory xml")] + [Route("/Dlna/{UuId}/contentdirectory/contentdirectory", "GET", Summary = "Gets dlna content directory xml")] public class GetContentDirectory { + [ApiMember(Name = "UuId", Description = "Server UuId", IsRequired = false, DataType = "string", ParameterType = "path", Verb = "GET")] + public string UuId { get; set; } } - [Route("/Dlna/connectionmanager/connectionmanager.xml", "GET", Summary = "Gets dlna connection manager xml")] - [Route("/Dlna/connectionmanager/connectionmanager", "GET", Summary = "Gets dlna connection manager xml")] + [Route("/Dlna/{UuId}/connectionmanager/connectionmanager.xml", "GET", Summary = "Gets dlna connection manager xml")] + [Route("/Dlna/{UuId}/connectionmanager/connectionmanager", "GET", Summary = "Gets dlna connection manager xml")] public class GetConnnectionManager { + [ApiMember(Name = "UuId", Description = "Server UuId", IsRequired = false, DataType = "string", ParameterType = "path", Verb = "GET")] + public string UuId { get; set; } } - [Route("/Dlna/mediareceiverregistrar/mediareceiverregistrar.xml", "GET", Summary = "Gets dlna mediareceiverregistrar xml")] - [Route("/Dlna/mediareceiverregistrar/mediareceiverregistrar", "GET", Summary = "Gets dlna mediareceiverregistrar xml")] + [Route("/Dlna/{UuId}/mediareceiverregistrar/mediareceiverregistrar.xml", "GET", Summary = "Gets dlna mediareceiverregistrar xml")] + [Route("/Dlna/{UuId}/mediareceiverregistrar/mediareceiverregistrar", "GET", Summary = "Gets dlna mediareceiverregistrar xml")] public class GetMediaReceiverRegistrar { + [ApiMember(Name = "UuId", Description = "Server UuId", IsRequired = false, DataType = "string", ParameterType = "path", Verb = "GET")] + public string UuId { get; set; } } - [Route("/Dlna/contentdirectory/{UuId}/control", "POST", Summary = "Processes a control request")] + [Route("/Dlna/{UuId}/contentdirectory/control", "POST", Summary = "Processes a control request")] public class ProcessContentDirectoryControlRequest : IRequiresRequestStream { [ApiMember(Name = "UuId", Description = "Server UuId", IsRequired = false, DataType = "string", ParameterType = "path", Verb = "GET")] @@ -45,7 +51,7 @@ namespace MediaBrowser.Api.Dlna public Stream RequestStream { get; set; } } - [Route("/Dlna/connectionmanager/{UuId}/control", "POST", Summary = "Processes a control request")] + [Route("/Dlna/{UuId}/connectionmanager/control", "POST", Summary = "Processes a control request")] public class ProcessConnectionManagerControlRequest : IRequiresRequestStream { [ApiMember(Name = "UuId", Description = "Server UuId", IsRequired = false, DataType = "string", ParameterType = "path", Verb = "GET")] @@ -54,7 +60,7 @@ namespace MediaBrowser.Api.Dlna public Stream RequestStream { get; set; } } - [Route("/Dlna/mediareceiverregistrar/{UuId}/control", "POST", Summary = "Processes a control request")] + [Route("/Dlna/{UuId}/mediareceiverregistrar/control", "POST", Summary = "Processes a control request")] public class ProcessMediaReceiverRegistrarControlRequest : IRequiresRequestStream { [ApiMember(Name = "UuId", Description = "Server UuId", IsRequired = false, DataType = "string", ParameterType = "path", Verb = "GET")] @@ -63,30 +69,34 @@ namespace MediaBrowser.Api.Dlna public Stream RequestStream { get; set; } } - [Route("/Dlna/mediareceiverregistrar/{UuId}/events", Summary = "Processes an event subscription request")] + [Route("/Dlna/{UuId}/mediareceiverregistrar/events", Summary = "Processes an event subscription request")] public class ProcessMediaReceiverRegistrarEventRequest { [ApiMember(Name = "UuId", Description = "Server UuId", IsRequired = false, DataType = "string", ParameterType = "path", Verb = "GET")] public string UuId { get; set; } } - [Route("/Dlna/contentdirectory/{UuId}/events", Summary = "Processes an event subscription request")] + [Route("/Dlna/{UuId}/contentdirectory/events", Summary = "Processes an event subscription request")] public class ProcessContentDirectoryEventRequest { [ApiMember(Name = "UuId", Description = "Server UuId", IsRequired = false, DataType = "string", ParameterType = "path", Verb = "GET")] public string UuId { get; set; } } - [Route("/Dlna/connectionmanager/{UuId}/events", Summary = "Processes an event subscription request")] + [Route("/Dlna/{UuId}/connectionmanager/events", Summary = "Processes an event subscription request")] public class ProcessConnectionManagerEventRequest { [ApiMember(Name = "UuId", Description = "Server UuId", IsRequired = false, DataType = "string", ParameterType = "path", Verb = "GET")] public string UuId { get; set; } } + [Route("/Dlna/{UuId}/icons/{Filename}", "GET", Summary = "Gets a server icon")] [Route("/Dlna/icons/{Filename}", "GET", Summary = "Gets a server icon")] public class GetIcon { + [ApiMember(Name = "UuId", Description = "Server UuId", IsRequired = false, DataType = "string", ParameterType = "path", Verb = "GET")] + public string UuId { get; set; } + [ApiMember(Name = "Filename", Description = "The icon filename", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "GET")] public string Filename { get; set; } } @@ -108,7 +118,9 @@ namespace MediaBrowser.Api.Dlna public object Get(GetDescriptionXml request) { - var xml = _dlnaManager.GetServerDescriptionXml(GetRequestHeaders(), request.UuId); + var url = Request.AbsoluteUri; + var serverAddress = url.Substring(0, url.IndexOf("/dlna/", StringComparison.OrdinalIgnoreCase)); + var xml = _dlnaManager.GetServerDescriptionXml(GetRequestHeaders(), request.UuId, serverAddress); return ResultFactory.GetResult(xml, "text/xml"); } diff --git a/MediaBrowser.Controller/Dlna/IDlnaManager.cs b/MediaBrowser.Controller/Dlna/IDlnaManager.cs index 34464f6a2d..2f64cd1946 100644 --- a/MediaBrowser.Controller/Dlna/IDlnaManager.cs +++ b/MediaBrowser.Controller/Dlna/IDlnaManager.cs @@ -62,8 +62,9 @@ namespace MediaBrowser.Controller.Dlna /// /// The headers. /// The server uu identifier. + /// The server address. /// System.String. - string GetServerDescriptionXml(IDictionary headers, string serverUuId); + string GetServerDescriptionXml(IDictionary headers, string serverUuId, string serverAddress); /// /// Gets the icon. diff --git a/MediaBrowser.Dlna/DlnaManager.cs b/MediaBrowser.Dlna/DlnaManager.cs index 2c22abd4d9..872c079391 100644 --- a/MediaBrowser.Dlna/DlnaManager.cs +++ b/MediaBrowser.Dlna/DlnaManager.cs @@ -475,12 +475,12 @@ namespace MediaBrowser.Dlna internal string Path { get; set; } } - public string GetServerDescriptionXml(IDictionary headers, string serverUuId) + public string GetServerDescriptionXml(IDictionary headers, string serverUuId, string serverAddress) { var profile = GetProfile(headers) ?? GetDefaultProfile(); - return new DescriptionXmlBuilder(profile, serverUuId, "").GetXml(); + return new DescriptionXmlBuilder(profile, serverUuId, serverAddress).GetXml(); } public ImageStream GetIcon(string filename) diff --git a/MediaBrowser.Dlna/MediaReceiverRegistrar/ServiceActionListBuilder.cs b/MediaBrowser.Dlna/MediaReceiverRegistrar/ServiceActionListBuilder.cs index 40fc954f7c..7e19805db3 100644 --- a/MediaBrowser.Dlna/MediaReceiverRegistrar/ServiceActionListBuilder.cs +++ b/MediaBrowser.Dlna/MediaReceiverRegistrar/ServiceActionListBuilder.cs @@ -11,11 +11,11 @@ namespace MediaBrowser.Dlna.MediaReceiverRegistrar { GetIsValidated(), GetIsAuthorized(), - //GetRegisterDevice(), - //GetGetAuthorizationDeniedUpdateID(), - //GetGetAuthorizationGrantedUpdateID(), - //GetGetValidationRevokedUpdateID(), - //GetGetValidationSucceededUpdateID() + GetRegisterDevice(), + GetGetAuthorizationDeniedUpdateID(), + GetGetAuthorizationGrantedUpdateID(), + GetGetValidationRevokedUpdateID(), + GetGetValidationSucceededUpdateID() }; return list; diff --git a/MediaBrowser.Dlna/Server/DescriptionXmlBuilder.cs b/MediaBrowser.Dlna/Server/DescriptionXmlBuilder.cs index 186c7e10b3..de6b821836 100644 --- a/MediaBrowser.Dlna/Server/DescriptionXmlBuilder.cs +++ b/MediaBrowser.Dlna/Server/DescriptionXmlBuilder.cs @@ -23,6 +23,11 @@ namespace MediaBrowser.Dlna.Server throw new ArgumentNullException("serverUdn"); } + if (string.IsNullOrWhiteSpace(serverAddress)) + { + throw new ArgumentNullException("serverAddress"); + } + _profile = profile; _serverUdn = serverUdn; _serverAddress = serverAddress; @@ -81,8 +86,8 @@ namespace MediaBrowser.Dlna.Server builder.Append("" + SecurityElement.Escape(_profile.ModelUrl ?? string.Empty) + ""); builder.Append("" + SecurityElement.Escape(_profile.SerialNumber ?? string.Empty) + ""); - //builder.Append("" + SecurityElement.Escape(_serverAddress) + ""); - + builder.Append("" + SecurityElement.Escape(_serverAddress) + ""); + if (!string.IsNullOrWhiteSpace(_profile.SonyAggregationFlags)) { builder.Append("" + SecurityElement.Escape(_profile.SonyAggregationFlags) + ""); @@ -101,7 +106,7 @@ namespace MediaBrowser.Dlna.Server builder.Append("" + SecurityElement.Escape(icon.Width.ToString(_usCulture)) + ""); builder.Append("" + SecurityElement.Escape(icon.Height.ToString(_usCulture)) + ""); builder.Append("" + SecurityElement.Escape(icon.Depth ?? string.Empty) + ""); - builder.Append("" + SecurityElement.Escape(icon.Url ?? string.Empty) + ""); + builder.Append("" + BuildUrl(icon.Url) + ""); builder.Append(""); } @@ -119,9 +124,9 @@ namespace MediaBrowser.Dlna.Server builder.Append("" + SecurityElement.Escape(service.ServiceType ?? string.Empty) + ""); builder.Append("" + SecurityElement.Escape(service.ServiceId ?? string.Empty) + ""); - builder.Append("" + SecurityElement.Escape(service.ScpdUrl ?? string.Empty) + ""); - builder.Append("" + SecurityElement.Escape(service.ControlUrl ?? string.Empty) + ""); - builder.Append("" + SecurityElement.Escape(service.EventSubUrl ?? string.Empty) + ""); + builder.Append("" + BuildUrl(service.ScpdUrl) + ""); + builder.Append("" + BuildUrl(service.ControlUrl) + ""); + builder.Append("" + BuildUrl(service.EventSubUrl) + ""); builder.Append(""); } @@ -129,6 +134,21 @@ namespace MediaBrowser.Dlna.Server builder.Append(""); } + private string BuildUrl(string url) + { + if (string.IsNullOrWhiteSpace(url)) + { + return string.Empty; + } + + url = url.TrimStart('/'); + + url = "/dlna/" + _serverUdn + "/" + url; + //url = _serverAddress.TrimEnd('/') + url; + + return SecurityElement.Escape(url); + } + private IEnumerable GetIcons() { var list = new List(); @@ -139,7 +159,7 @@ namespace MediaBrowser.Dlna.Server Depth = "24", Width = 240, Height = 240, - Url = "/dlna/icons/logo240.png" + Url = "icons/logo240.png" }); list.Add(new DeviceIcon @@ -148,7 +168,7 @@ namespace MediaBrowser.Dlna.Server Depth = "24", Width = 240, Height = 240, - Url = "/dlna/icons/logo240.jpg" + Url = "icons/logo240.jpg" }); list.Add(new DeviceIcon @@ -157,7 +177,7 @@ namespace MediaBrowser.Dlna.Server Depth = "24", Width = 120, Height = 120, - Url = "/dlna/icons/logo120.png" + Url = "icons/logo120.png" }); list.Add(new DeviceIcon @@ -166,7 +186,7 @@ namespace MediaBrowser.Dlna.Server Depth = "24", Width = 120, Height = 120, - Url = "/dlna/icons/logo120.jpg" + Url = "icons/logo120.jpg" }); list.Add(new DeviceIcon @@ -175,7 +195,7 @@ namespace MediaBrowser.Dlna.Server Depth = "24", Width = 48, Height = 48, - Url = "/dlna/icons/logo48.png" + Url = "icons/logo48.png" }); list.Add(new DeviceIcon @@ -184,7 +204,7 @@ namespace MediaBrowser.Dlna.Server Depth = "24", Width = 48, Height = 48, - Url = "/dlna/icons/logo48.jpg" + Url = "icons/logo48.jpg" }); return list; @@ -198,27 +218,27 @@ namespace MediaBrowser.Dlna.Server { ServiceType = "urn:schemas-upnp-org:service:ContentDirectory:1", ServiceId = "urn:upnp-org:serviceId:ContentDirectory", - ScpdUrl = "/dlna/contentdirectory/contentdirectory.xml", - ControlUrl = "/dlna/contentdirectory/" + _serverUdn + "/control", - EventSubUrl = "/dlna/contentdirectory/" + _serverUdn + "/events" + ScpdUrl = "contentdirectory/contentdirectory.xml", + ControlUrl = "contentdirectory/control", + EventSubUrl = "contentdirectory/events" }); list.Add(new DeviceService { ServiceType = "urn:schemas-upnp-org:service:ConnectionManager:1", ServiceId = "urn:upnp-org:serviceId:ConnectionManager", - ScpdUrl = "/dlna/connectionmanager/connectionmanager.xml", - ControlUrl = "/dlna/connectionmanager/" + _serverUdn + "/control", - EventSubUrl = "/dlna/connectionmanager/" + _serverUdn + "/events" + ScpdUrl = "connectionmanager/connectionmanager.xml", + ControlUrl = "connectionmanager/control", + EventSubUrl = "connectionmanager/events" }); list.Add(new DeviceService { ServiceType = "urn:microsoft.com:service:X_MS_MediaReceiverRegistrar:1", ServiceId = "urn:microsoft.com:serviceId:X_MS_MediaReceiverRegistrar", - ScpdUrl = "/dlna/mediareceiverregistrar/mediareceiverregistrar.xml", - ControlUrl = "/dlna/mediareceiverregistrar/" + _serverUdn + "/control", - EventSubUrl = "/dlna/mediareceiverregistrar/" + _serverUdn + "/events" + ScpdUrl = "mediareceiverregistrar/mediareceiverregistrar.xml", + ControlUrl = "mediareceiverregistrar/control", + EventSubUrl = "mediareceiverregistrar/events" }); return list;