diff options
| author | Luke Pulverenti <luke.pulverenti@gmail.com> | 2015-01-30 16:14:08 -0500 |
|---|---|---|
| committer | Luke Pulverenti <luke.pulverenti@gmail.com> | 2015-01-30 16:14:08 -0500 |
| commit | 54c5e88b87c52cc82cf521a94742003455e43033 (patch) | |
| tree | 96930588865c5798e2a16889934cd2d6487017e7 | |
| parent | 6eeb5f25f48953c7f4699b17d0c1f4dc6266a2f7 (diff) | |
dlna fixes
| -rw-r--r-- | MediaBrowser.Api/Dlna/DlnaServerService.cs | 38 | ||||
| -rw-r--r-- | MediaBrowser.Controller/Dlna/IDlnaManager.cs | 3 | ||||
| -rw-r--r-- | MediaBrowser.Dlna/DlnaManager.cs | 4 | ||||
| -rw-r--r-- | MediaBrowser.Dlna/MediaReceiverRegistrar/ServiceActionListBuilder.cs | 10 | ||||
| -rw-r--r-- | MediaBrowser.Dlna/Server/DescriptionXmlBuilder.cs | 62 |
5 files changed, 75 insertions, 42 deletions
diff --git a/MediaBrowser.Api/Dlna/DlnaServerService.cs b/MediaBrowser.Api/Dlna/DlnaServerService.cs index 038f1d6c1..24a6c52d0 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 34464f6a2..2f64cd194 100644 --- a/MediaBrowser.Controller/Dlna/IDlnaManager.cs +++ b/MediaBrowser.Controller/Dlna/IDlnaManager.cs @@ -62,8 +62,9 @@ namespace MediaBrowser.Controller.Dlna /// </summary> /// <param name="headers">The headers.</param> /// <param name="serverUuId">The server uu identifier.</param> + /// <param name="serverAddress">The server address.</param> /// <returns>System.String.</returns> - string GetServerDescriptionXml(IDictionary<string, string> headers, string serverUuId); + string GetServerDescriptionXml(IDictionary<string, string> headers, string serverUuId, string serverAddress); /// <summary> /// Gets the icon. diff --git a/MediaBrowser.Dlna/DlnaManager.cs b/MediaBrowser.Dlna/DlnaManager.cs index 2c22abd4d..872c07939 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<string, string> headers, string serverUuId) + public string GetServerDescriptionXml(IDictionary<string, string> 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 40fc954f7..7e19805db 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 186c7e10b..de6b82183 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("<modelURL>" + SecurityElement.Escape(_profile.ModelUrl ?? string.Empty) + "</modelURL>"); builder.Append("<serialNumber>" + SecurityElement.Escape(_profile.SerialNumber ?? string.Empty) + "</serialNumber>"); - //builder.Append("<URLBase>" + SecurityElement.Escape(_serverAddress) + "</URLBase>"); - + builder.Append("<URLBase>" + SecurityElement.Escape(_serverAddress) + "</URLBase>"); + if (!string.IsNullOrWhiteSpace(_profile.SonyAggregationFlags)) { builder.Append("<av:aggregationFlags xmlns:av=\"urn:schemas-sony-com:av\">" + SecurityElement.Escape(_profile.SonyAggregationFlags) + "</av:aggregationFlags>"); @@ -101,7 +106,7 @@ namespace MediaBrowser.Dlna.Server builder.Append("<width>" + SecurityElement.Escape(icon.Width.ToString(_usCulture)) + "</width>"); builder.Append("<height>" + SecurityElement.Escape(icon.Height.ToString(_usCulture)) + "</height>"); builder.Append("<depth>" + SecurityElement.Escape(icon.Depth ?? string.Empty) + "</depth>"); - builder.Append("<url>" + SecurityElement.Escape(icon.Url ?? string.Empty) + "</url>"); + builder.Append("<url>" + BuildUrl(icon.Url) + "</url>"); builder.Append("</icon>"); } @@ -119,9 +124,9 @@ namespace MediaBrowser.Dlna.Server builder.Append("<serviceType>" + SecurityElement.Escape(service.ServiceType ?? string.Empty) + "</serviceType>"); builder.Append("<serviceId>" + SecurityElement.Escape(service.ServiceId ?? string.Empty) + "</serviceId>"); - builder.Append("<SCPDURL>" + SecurityElement.Escape(service.ScpdUrl ?? string.Empty) + "</SCPDURL>"); - builder.Append("<controlURL>" + SecurityElement.Escape(service.ControlUrl ?? string.Empty) + "</controlURL>"); - builder.Append("<eventSubURL>" + SecurityElement.Escape(service.EventSubUrl ?? string.Empty) + "</eventSubURL>"); + builder.Append("<SCPDURL>" + BuildUrl(service.ScpdUrl) + "</SCPDURL>"); + builder.Append("<controlURL>" + BuildUrl(service.ControlUrl) + "</controlURL>"); + builder.Append("<eventSubURL>" + BuildUrl(service.EventSubUrl) + "</eventSubURL>"); builder.Append("</service>"); } @@ -129,6 +134,21 @@ namespace MediaBrowser.Dlna.Server builder.Append("</serviceList>"); } + 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<DeviceIcon> GetIcons() { var list = new List<DeviceIcon>(); @@ -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; |
