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
/// The response headers.
/// System.Object.
/// cacheKey
- protected object ToCachedResult(Guid cacheKey, DateTime lastDateModified, TimeSpan? cacheDuration, Func factoryFn, string contentType, IDictionary responseHeaders = null)
+ protected object ToCachedResult(Guid cacheKey, DateTime? lastDateModified, TimeSpan? cacheDuration, Func factoryFn, string contentType, IDictionary 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 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());
+ }
+ }
+ }
}
}
diff --git a/MediaBrowser.Controller/Dlna/DlnaIconResponse.cs b/MediaBrowser.Controller/Dlna/DlnaIconResponse.cs
new file mode 100644
index 0000000000..04d8e88b97
--- /dev/null
+++ b/MediaBrowser.Controller/Dlna/DlnaIconResponse.cs
@@ -0,0 +1,22 @@
+using MediaBrowser.Controller.Drawing;
+using System;
+using System.IO;
+
+namespace MediaBrowser.Controller.Dlna
+{
+ public class DlnaIconResponse : IDisposable
+ {
+ public Stream Stream { get; set; }
+
+ public ImageFormat Format { get; set; }
+
+ public void Dispose()
+ {
+ if (Stream != null)
+ {
+ Stream.Dispose();
+ Stream = null;
+ }
+ }
+ }
+}
diff --git a/MediaBrowser.Controller/Dlna/IDlnaManager.cs b/MediaBrowser.Controller/Dlna/IDlnaManager.cs
index bcccaaa2e9..e9e2aae54c 100644
--- a/MediaBrowser.Controller/Dlna/IDlnaManager.cs
+++ b/MediaBrowser.Controller/Dlna/IDlnaManager.cs
@@ -77,5 +77,12 @@ namespace MediaBrowser.Controller.Dlna
/// The request.
/// ControlResponse.
ControlResponse ProcessControlRequest(ControlRequest request);
+
+ ///
+ /// Gets the icon.
+ ///
+ /// The filename.
+ /// DlnaIconResponse.
+ DlnaIconResponse GetIcon(string filename);
}
}
diff --git a/MediaBrowser.Controller/MediaBrowser.Controller.csproj b/MediaBrowser.Controller/MediaBrowser.Controller.csproj
index 3852b5b7aa..235c3c1e58 100644
--- a/MediaBrowser.Controller/MediaBrowser.Controller.csproj
+++ b/MediaBrowser.Controller/MediaBrowser.Controller.csproj
@@ -79,6 +79,7 @@
+
diff --git a/MediaBrowser.Dlna/DlnaManager.cs b/MediaBrowser.Dlna/DlnaManager.cs
index 624f23f7f2..83e3df798b 100644
--- a/MediaBrowser.Dlna/DlnaManager.cs
+++ b/MediaBrowser.Dlna/DlnaManager.cs
@@ -2,6 +2,8 @@
using MediaBrowser.Common.Extensions;
using MediaBrowser.Common.IO;
using MediaBrowser.Controller.Dlna;
+using MediaBrowser.Controller.Drawing;
+using MediaBrowser.Controller.Library;
using MediaBrowser.Dlna.Profiles;
using MediaBrowser.Dlna.Server;
using MediaBrowser.Model.Dlna;
@@ -23,14 +25,18 @@ namespace MediaBrowser.Dlna
private readonly IFileSystem _fileSystem;
private readonly ILogger _logger;
private readonly IJsonSerializer _jsonSerializer;
+ private readonly IUserManager _userManager;
+ private readonly ILibraryManager _libraryManager;
- public DlnaManager(IXmlSerializer xmlSerializer, IFileSystem fileSystem, IApplicationPaths appPaths, ILogger logger, IJsonSerializer jsonSerializer)
+ public DlnaManager(IXmlSerializer xmlSerializer, IFileSystem fileSystem, IApplicationPaths appPaths, ILogger logger, IJsonSerializer jsonSerializer, IUserManager userManager, ILibraryManager libraryManager)
{
_xmlSerializer = xmlSerializer;
_fileSystem = fileSystem;
_appPaths = appPaths;
_logger = logger;
_jsonSerializer = jsonSerializer;
+ _userManager = userManager;
+ _libraryManager = libraryManager;
//DumpProfiles();
}
@@ -496,7 +502,21 @@ namespace MediaBrowser.Dlna
public ControlResponse ProcessControlRequest(ControlRequest request)
{
- return new ControlHandler(_logger).ProcessControlRequest(request);
+ return new ControlHandler(_logger, _userManager, _libraryManager)
+ .ProcessControlRequest(request);
+ }
+
+ public DlnaIconResponse GetIcon(string filename)
+ {
+ var format = filename.EndsWith(".png", StringComparison.OrdinalIgnoreCase)
+ ? ImageFormat.Png
+ : ImageFormat.Jpg;
+
+ return new DlnaIconResponse
+ {
+ Format = format,
+ Stream = GetType().Assembly.GetManifestResourceStream("MediaBrowser.Dlna.Images." + filename.ToLower())
+ };
}
}
}
\ No newline at end of file
diff --git a/MediaBrowser.Dlna/Images/logo-120.jpg b/MediaBrowser.Dlna/Images/logo120.jpg
similarity index 100%
rename from MediaBrowser.Dlna/Images/logo-120.jpg
rename to MediaBrowser.Dlna/Images/logo120.jpg
diff --git a/MediaBrowser.Dlna/Images/logo-120.png b/MediaBrowser.Dlna/Images/logo120.png
similarity index 100%
rename from MediaBrowser.Dlna/Images/logo-120.png
rename to MediaBrowser.Dlna/Images/logo120.png
diff --git a/MediaBrowser.Dlna/Images/logo-48.jpg b/MediaBrowser.Dlna/Images/logo48.jpg
similarity index 100%
rename from MediaBrowser.Dlna/Images/logo-48.jpg
rename to MediaBrowser.Dlna/Images/logo48.jpg
diff --git a/MediaBrowser.Dlna/Images/logo-48.png b/MediaBrowser.Dlna/Images/logo48.png
similarity index 100%
rename from MediaBrowser.Dlna/Images/logo-48.png
rename to MediaBrowser.Dlna/Images/logo48.png
diff --git a/MediaBrowser.Dlna/MediaBrowser.Dlna.csproj b/MediaBrowser.Dlna/MediaBrowser.Dlna.csproj
index 0980ee81db..bf38f19dcf 100644
--- a/MediaBrowser.Dlna/MediaBrowser.Dlna.csproj
+++ b/MediaBrowser.Dlna/MediaBrowser.Dlna.csproj
@@ -147,10 +147,10 @@
-
-
-
-
+
+
+
+