diff options
| author | Luke Pulverenti <luke.pulverenti@gmail.com> | 2014-04-16 01:08:12 -0400 |
|---|---|---|
| committer | Luke Pulverenti <luke.pulverenti@gmail.com> | 2014-04-16 01:08:12 -0400 |
| commit | ea182931dbe3370225d85a10870ae57330461a40 (patch) | |
| tree | be381dee25ca8dcb104721f0d578cbe6b2180a7b /MediaBrowser.Api | |
| parent | 2ce9e05d2fc818b031f2ab12bc50ffae035033ed (diff) | |
handle dlna browse requests
Diffstat (limited to 'MediaBrowser.Api')
| -rw-r--r-- | MediaBrowser.Api/BaseApiService.cs | 2 | ||||
| -rw-r--r-- | MediaBrowser.Api/Dlna/DlnaServerService.cs | 35 |
2 files changed, 27 insertions, 10 deletions
diff --git a/MediaBrowser.Api/BaseApiService.cs b/MediaBrowser.Api/BaseApiService.cs index 707cfb4572..ba42f3030d 100644 --- a/MediaBrowser.Api/BaseApiService.cs +++ b/MediaBrowser.Api/BaseApiService.cs @@ -105,7 +105,7 @@ namespace MediaBrowser.Api /// <param name="responseHeaders">The response headers.</param> /// <returns>System.Object.</returns> /// <exception cref="System.ArgumentNullException">cacheKey</exception> - protected object ToCachedResult<T>(Guid cacheKey, DateTime lastDateModified, TimeSpan? cacheDuration, Func<T> factoryFn, string contentType, IDictionary<string,string> responseHeaders = null) + protected object ToCachedResult<T>(Guid cacheKey, DateTime? lastDateModified, TimeSpan? cacheDuration, Func<T> factoryFn, string contentType, IDictionary<string,string> responseHeaders = null) where T : class { return ResultFactory.GetCachedResult(Request, cacheKey, lastDateModified, cacheDuration, factoryFn, contentType, responseHeaders); diff --git a/MediaBrowser.Api/Dlna/DlnaServerService.cs b/MediaBrowser.Api/Dlna/DlnaServerService.cs index 922c67aa2d..097552ab41 100644 --- a/MediaBrowser.Api/Dlna/DlnaServerService.cs +++ b/MediaBrowser.Api/Dlna/DlnaServerService.cs @@ -15,23 +15,25 @@ namespace MediaBrowser.Api.Dlna public string UuId { get; set; } } - [Route("/Dlna/{UuId}/contentdirectory.xml", "GET", Summary = "Gets dlna content directory xml")] - [Route("/Dlna/{UuId}/contentdirectory", "GET", Summary = "Gets the content directory xml")] + [Route("/Dlna/contentdirectory.xml", "GET", Summary = "Gets dlna content directory xml")] + [Route("/Dlna/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/{UuId}/control", "POST", Summary = "Processes a control request")] + [Route("/Dlna/control", "POST", Summary = "Processes a control request")] public class ProcessControlRequest : IRequiresRequestStream { - [ApiMember(Name = "UuId", Description = "Server UuId", IsRequired = false, DataType = "string", ParameterType = "path", Verb = "GET")] - public string UuId { get; set; } - public Stream RequestStream { get; set; } } + [Route("/Dlna/icons/{Filename}", "GET", Summary = "Gets a server icon")] + public class GetIcon + { + [ApiMember(Name = "Filename", Description = "The icon filename", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "GET")] + public string Filename { get; set; } + } + public class DlnaServerService : BaseApiService { private readonly IDlnaManager _dlnaManager; @@ -72,7 +74,7 @@ namespace MediaBrowser.Api.Dlna InputXml = await reader.ReadToEndAsync().ConfigureAwait(false) }); } - } + } private IDictionary<string, string> GetRequestHeaders() { @@ -85,5 +87,20 @@ namespace MediaBrowser.Api.Dlna return headers; } + + public object Get(GetIcon request) + { + using (var response = _dlnaManager.GetIcon(request.Filename)) + { + using (var ms = new MemoryStream()) + { + response.Stream.CopyTo(ms); + + ms.Position = 0; + var bytes = ms.ToArray(); + return ResultFactory.GetResult(bytes, "image/" + response.Format.ToString().ToLower()); + } + } + } } } |
