2020-04-22 01:15:27 +00:00
|
|
|
using System;
|
2020-09-05 23:11:44 +00:00
|
|
|
using System.ComponentModel.DataAnnotations;
|
2020-07-31 17:01:30 +00:00
|
|
|
using System.Diagnostics.CodeAnalysis;
|
2020-04-22 01:15:27 +00:00
|
|
|
using System.IO;
|
2020-09-01 23:26:49 +00:00
|
|
|
using System.Net.Mime;
|
2020-04-22 01:15:27 +00:00
|
|
|
using System.Threading.Tasks;
|
|
|
|
using Emby.Dlna;
|
|
|
|
using Emby.Dlna.Main;
|
|
|
|
using Jellyfin.Api.Attributes;
|
2021-09-10 09:44:50 +00:00
|
|
|
using Jellyfin.Api.Constants;
|
2020-04-22 01:15:27 +00:00
|
|
|
using MediaBrowser.Controller.Dlna;
|
2022-01-04 09:40:16 +00:00
|
|
|
using MediaBrowser.Model.Net;
|
2021-09-10 09:44:50 +00:00
|
|
|
using Microsoft.AspNetCore.Authorization;
|
2020-04-22 01:15:27 +00:00
|
|
|
using Microsoft.AspNetCore.Http;
|
|
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
|
|
|
|
namespace Jellyfin.Api.Controllers
|
|
|
|
{
|
|
|
|
/// <summary>
|
|
|
|
/// Dlna Server Controller.
|
|
|
|
/// </summary>
|
|
|
|
[Route("Dlna")]
|
2022-06-11 01:59:21 +00:00
|
|
|
[DlnaEnabled]
|
2021-09-10 09:44:50 +00:00
|
|
|
[Authorize(Policy = Policies.AnonymousLanAccessPolicy)]
|
2020-04-22 01:15:27 +00:00
|
|
|
public class DlnaServerController : BaseJellyfinApiController
|
|
|
|
{
|
|
|
|
private readonly IDlnaManager _dlnaManager;
|
|
|
|
private readonly IContentDirectory _contentDirectory;
|
|
|
|
private readonly IConnectionManager _connectionManager;
|
|
|
|
private readonly IMediaReceiverRegistrar _mediaReceiverRegistrar;
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Initializes a new instance of the <see cref="DlnaServerController"/> class.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="dlnaManager">Instance of the <see cref="IDlnaManager"/> interface.</param>
|
|
|
|
public DlnaServerController(IDlnaManager dlnaManager)
|
|
|
|
{
|
|
|
|
_dlnaManager = dlnaManager;
|
|
|
|
_contentDirectory = DlnaEntryPoint.Current.ContentDirectory;
|
|
|
|
_connectionManager = DlnaEntryPoint.Current.ConnectionManager;
|
|
|
|
_mediaReceiverRegistrar = DlnaEntryPoint.Current.MediaReceiverRegistrar;
|
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Get Description Xml.
|
|
|
|
/// </summary>
|
2020-07-31 17:01:30 +00:00
|
|
|
/// <param name="serverId">Server UUID.</param>
|
|
|
|
/// <response code="200">Description xml returned.</response>
|
2020-12-22 15:33:25 +00:00
|
|
|
/// <response code="503">DLNA is disabled.</response>
|
2020-07-31 17:01:30 +00:00
|
|
|
/// <returns>An <see cref="OkResult"/> containing the description xml.</returns>
|
|
|
|
[HttpGet("{serverId}/description")]
|
2020-08-03 20:38:51 +00:00
|
|
|
[HttpGet("{serverId}/description.xml", Name = "GetDescriptionXml_2")]
|
2020-09-03 19:48:48 +00:00
|
|
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
2020-12-22 15:23:55 +00:00
|
|
|
[ProducesResponseType(StatusCodes.Status503ServiceUnavailable)]
|
2020-09-01 23:26:49 +00:00
|
|
|
[Produces(MediaTypeNames.Text.Xml)]
|
|
|
|
[ProducesFile(MediaTypeNames.Text.Xml)]
|
2020-09-06 15:07:27 +00:00
|
|
|
public ActionResult GetDescriptionXml([FromRoute, Required] string serverId)
|
2020-04-22 01:15:27 +00:00
|
|
|
{
|
2022-06-11 01:59:21 +00:00
|
|
|
var url = GetAbsoluteUri();
|
|
|
|
var serverAddress = url.Substring(0, url.IndexOf("/dlna/", StringComparison.OrdinalIgnoreCase));
|
|
|
|
var xml = _dlnaManager.GetServerDescriptionXml(Request.Headers, serverId, serverAddress);
|
|
|
|
return Ok(xml);
|
2020-04-22 01:15:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Gets Dlna content directory xml.
|
|
|
|
/// </summary>
|
2020-07-31 17:01:30 +00:00
|
|
|
/// <param name="serverId">Server UUID.</param>
|
|
|
|
/// <response code="200">Dlna content directory returned.</response>
|
2020-12-22 15:33:25 +00:00
|
|
|
/// <response code="503">DLNA is disabled.</response>
|
2020-07-31 17:01:30 +00:00
|
|
|
/// <returns>An <see cref="OkResult"/> containing the dlna content directory xml.</returns>
|
2020-08-16 14:32:13 +00:00
|
|
|
[HttpGet("{serverId}/ContentDirectory")]
|
2020-08-16 16:53:57 +00:00
|
|
|
[HttpGet("{serverId}/ContentDirectory/ContentDirectory", Name = "GetContentDirectory_2")]
|
|
|
|
[HttpGet("{serverId}/ContentDirectory/ContentDirectory.xml", Name = "GetContentDirectory_3")]
|
2020-04-22 01:15:27 +00:00
|
|
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
2020-12-22 15:23:55 +00:00
|
|
|
[ProducesResponseType(StatusCodes.Status503ServiceUnavailable)]
|
2020-09-03 19:48:48 +00:00
|
|
|
[Produces(MediaTypeNames.Text.Xml)]
|
|
|
|
[ProducesFile(MediaTypeNames.Text.Xml)]
|
2020-07-31 17:01:30 +00:00
|
|
|
[SuppressMessage("Microsoft.Performance", "CA1801:ReviewUnusedParameters", MessageId = "serverId", Justification = "Required for DLNA")]
|
2020-09-06 15:07:27 +00:00
|
|
|
public ActionResult GetContentDirectory([FromRoute, Required] string serverId)
|
2020-04-22 01:15:27 +00:00
|
|
|
{
|
2022-06-11 01:59:21 +00:00
|
|
|
return Ok(_contentDirectory.GetServiceXml());
|
2020-04-22 01:15:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Gets Dlna media receiver registrar xml.
|
|
|
|
/// </summary>
|
2020-07-31 17:01:30 +00:00
|
|
|
/// <param name="serverId">Server UUID.</param>
|
2020-11-08 00:30:56 +00:00
|
|
|
/// <response code="200">Dlna media receiver registrar xml returned.</response>
|
2020-12-22 15:33:25 +00:00
|
|
|
/// <response code="503">DLNA is disabled.</response>
|
2020-04-22 01:15:27 +00:00
|
|
|
/// <returns>Dlna media receiver registrar xml.</returns>
|
2020-09-03 19:50:02 +00:00
|
|
|
[HttpGet("{serverId}/MediaReceiverRegistrar")]
|
2020-08-16 16:53:57 +00:00
|
|
|
[HttpGet("{serverId}/MediaReceiverRegistrar/MediaReceiverRegistrar", Name = "GetMediaReceiverRegistrar_2")]
|
|
|
|
[HttpGet("{serverId}/MediaReceiverRegistrar/MediaReceiverRegistrar.xml", Name = "GetMediaReceiverRegistrar_3")]
|
2020-09-03 19:48:48 +00:00
|
|
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
2020-12-22 15:23:55 +00:00
|
|
|
[ProducesResponseType(StatusCodes.Status503ServiceUnavailable)]
|
2020-09-01 23:26:49 +00:00
|
|
|
[Produces(MediaTypeNames.Text.Xml)]
|
|
|
|
[ProducesFile(MediaTypeNames.Text.Xml)]
|
2020-07-31 17:01:30 +00:00
|
|
|
[SuppressMessage("Microsoft.Performance", "CA1801:ReviewUnusedParameters", MessageId = "serverId", Justification = "Required for DLNA")]
|
2020-09-06 15:07:27 +00:00
|
|
|
public ActionResult GetMediaReceiverRegistrar([FromRoute, Required] string serverId)
|
2020-04-22 01:15:27 +00:00
|
|
|
{
|
2022-06-11 01:59:21 +00:00
|
|
|
return Ok(_mediaReceiverRegistrar.GetServiceXml());
|
2020-04-22 01:15:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Gets Dlna media receiver registrar xml.
|
|
|
|
/// </summary>
|
2020-07-31 17:01:30 +00:00
|
|
|
/// <param name="serverId">Server UUID.</param>
|
2020-11-08 00:30:56 +00:00
|
|
|
/// <response code="200">Dlna media receiver registrar xml returned.</response>
|
2020-12-22 15:33:25 +00:00
|
|
|
/// <response code="503">DLNA is disabled.</response>
|
2020-04-22 01:15:27 +00:00
|
|
|
/// <returns>Dlna media receiver registrar xml.</returns>
|
2020-08-16 14:32:13 +00:00
|
|
|
[HttpGet("{serverId}/ConnectionManager")]
|
2020-08-16 16:53:57 +00:00
|
|
|
[HttpGet("{serverId}/ConnectionManager/ConnectionManager", Name = "GetConnectionManager_2")]
|
|
|
|
[HttpGet("{serverId}/ConnectionManager/ConnectionManager.xml", Name = "GetConnectionManager_3")]
|
2020-09-03 19:48:48 +00:00
|
|
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
2020-12-22 15:23:55 +00:00
|
|
|
[ProducesResponseType(StatusCodes.Status503ServiceUnavailable)]
|
2020-09-01 23:26:49 +00:00
|
|
|
[Produces(MediaTypeNames.Text.Xml)]
|
|
|
|
[ProducesFile(MediaTypeNames.Text.Xml)]
|
2020-07-31 17:01:30 +00:00
|
|
|
[SuppressMessage("Microsoft.Performance", "CA1801:ReviewUnusedParameters", MessageId = "serverId", Justification = "Required for DLNA")]
|
2020-09-06 15:07:27 +00:00
|
|
|
public ActionResult GetConnectionManager([FromRoute, Required] string serverId)
|
2020-04-22 01:15:27 +00:00
|
|
|
{
|
2022-06-11 01:59:21 +00:00
|
|
|
return Ok(_connectionManager.GetServiceXml());
|
2020-04-22 01:15:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Process a content directory control request.
|
|
|
|
/// </summary>
|
2020-07-31 17:01:30 +00:00
|
|
|
/// <param name="serverId">Server UUID.</param>
|
2020-11-08 00:30:56 +00:00
|
|
|
/// <response code="200">Request processed.</response>
|
2020-12-22 15:33:25 +00:00
|
|
|
/// <response code="503">DLNA is disabled.</response>
|
2020-04-22 01:15:27 +00:00
|
|
|
/// <returns>Control response.</returns>
|
2020-07-31 17:01:30 +00:00
|
|
|
[HttpPost("{serverId}/ContentDirectory/Control")]
|
2020-11-08 00:30:56 +00:00
|
|
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
2020-12-22 15:23:55 +00:00
|
|
|
[ProducesResponseType(StatusCodes.Status503ServiceUnavailable)]
|
2020-11-08 00:30:56 +00:00
|
|
|
[Produces(MediaTypeNames.Text.Xml)]
|
|
|
|
[ProducesFile(MediaTypeNames.Text.Xml)]
|
2020-09-06 15:07:27 +00:00
|
|
|
public async Task<ActionResult<ControlResponse>> ProcessContentDirectoryControlRequest([FromRoute, Required] string serverId)
|
2020-04-22 01:15:27 +00:00
|
|
|
{
|
2022-06-11 01:59:21 +00:00
|
|
|
return await ProcessControlRequestInternalAsync(serverId, Request.Body, _contentDirectory).ConfigureAwait(false);
|
2020-04-22 01:15:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Process a connection manager control request.
|
|
|
|
/// </summary>
|
2020-07-31 17:01:30 +00:00
|
|
|
/// <param name="serverId">Server UUID.</param>
|
2020-11-08 00:30:56 +00:00
|
|
|
/// <response code="200">Request processed.</response>
|
2020-12-22 15:33:25 +00:00
|
|
|
/// <response code="503">DLNA is disabled.</response>
|
2020-04-22 01:15:27 +00:00
|
|
|
/// <returns>Control response.</returns>
|
2020-07-31 17:01:30 +00:00
|
|
|
[HttpPost("{serverId}/ConnectionManager/Control")]
|
2020-11-08 00:30:56 +00:00
|
|
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
2020-12-22 15:23:55 +00:00
|
|
|
[ProducesResponseType(StatusCodes.Status503ServiceUnavailable)]
|
2020-11-08 00:30:56 +00:00
|
|
|
[Produces(MediaTypeNames.Text.Xml)]
|
|
|
|
[ProducesFile(MediaTypeNames.Text.Xml)]
|
2020-09-06 15:07:27 +00:00
|
|
|
public async Task<ActionResult<ControlResponse>> ProcessConnectionManagerControlRequest([FromRoute, Required] string serverId)
|
2020-04-22 01:15:27 +00:00
|
|
|
{
|
2022-06-11 01:59:21 +00:00
|
|
|
return await ProcessControlRequestInternalAsync(serverId, Request.Body, _connectionManager).ConfigureAwait(false);
|
2020-04-22 01:15:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Process a media receiver registrar control request.
|
|
|
|
/// </summary>
|
2020-07-31 17:01:30 +00:00
|
|
|
/// <param name="serverId">Server UUID.</param>
|
2020-11-08 00:30:56 +00:00
|
|
|
/// <response code="200">Request processed.</response>
|
2020-12-22 15:33:25 +00:00
|
|
|
/// <response code="503">DLNA is disabled.</response>
|
2020-04-22 01:15:27 +00:00
|
|
|
/// <returns>Control response.</returns>
|
2020-07-31 17:01:30 +00:00
|
|
|
[HttpPost("{serverId}/MediaReceiverRegistrar/Control")]
|
2020-11-08 00:30:56 +00:00
|
|
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
2020-12-22 15:23:55 +00:00
|
|
|
[ProducesResponseType(StatusCodes.Status503ServiceUnavailable)]
|
2020-11-08 00:30:56 +00:00
|
|
|
[Produces(MediaTypeNames.Text.Xml)]
|
|
|
|
[ProducesFile(MediaTypeNames.Text.Xml)]
|
2020-09-06 15:07:27 +00:00
|
|
|
public async Task<ActionResult<ControlResponse>> ProcessMediaReceiverRegistrarControlRequest([FromRoute, Required] string serverId)
|
2020-04-22 01:15:27 +00:00
|
|
|
{
|
2022-06-11 01:59:21 +00:00
|
|
|
return await ProcessControlRequestInternalAsync(serverId, Request.Body, _mediaReceiverRegistrar).ConfigureAwait(false);
|
2020-04-22 01:15:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Processes an event subscription request.
|
|
|
|
/// </summary>
|
2020-07-31 17:01:30 +00:00
|
|
|
/// <param name="serverId">Server UUID.</param>
|
2020-11-08 00:30:56 +00:00
|
|
|
/// <response code="200">Request processed.</response>
|
2020-12-22 15:33:25 +00:00
|
|
|
/// <response code="503">DLNA is disabled.</response>
|
2020-04-22 01:15:27 +00:00
|
|
|
/// <returns>Event subscription response.</returns>
|
2020-07-31 17:01:30 +00:00
|
|
|
[HttpSubscribe("{serverId}/MediaReceiverRegistrar/Events")]
|
|
|
|
[HttpUnsubscribe("{serverId}/MediaReceiverRegistrar/Events")]
|
|
|
|
[ApiExplorerSettings(IgnoreApi = true)] // Ignore in openapi docs
|
|
|
|
[SuppressMessage("Microsoft.Performance", "CA1801:ReviewUnusedParameters", MessageId = "serverId", Justification = "Required for DLNA")]
|
2020-11-08 00:30:56 +00:00
|
|
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
2020-12-22 15:23:55 +00:00
|
|
|
[ProducesResponseType(StatusCodes.Status503ServiceUnavailable)]
|
2020-11-08 00:30:56 +00:00
|
|
|
[Produces(MediaTypeNames.Text.Xml)]
|
|
|
|
[ProducesFile(MediaTypeNames.Text.Xml)]
|
2020-07-31 17:01:30 +00:00
|
|
|
public ActionResult<EventSubscriptionResponse> ProcessMediaReceiverRegistrarEventRequest(string serverId)
|
2020-04-22 01:15:27 +00:00
|
|
|
{
|
2022-06-11 01:59:21 +00:00
|
|
|
return ProcessEventRequest(_mediaReceiverRegistrar);
|
2020-04-22 01:15:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Processes an event subscription request.
|
|
|
|
/// </summary>
|
2020-07-31 17:01:30 +00:00
|
|
|
/// <param name="serverId">Server UUID.</param>
|
2020-11-08 00:30:56 +00:00
|
|
|
/// <response code="200">Request processed.</response>
|
2020-12-22 15:33:25 +00:00
|
|
|
/// <response code="503">DLNA is disabled.</response>
|
2020-04-22 01:15:27 +00:00
|
|
|
/// <returns>Event subscription response.</returns>
|
2020-07-31 17:01:30 +00:00
|
|
|
[HttpSubscribe("{serverId}/ContentDirectory/Events")]
|
|
|
|
[HttpUnsubscribe("{serverId}/ContentDirectory/Events")]
|
|
|
|
[ApiExplorerSettings(IgnoreApi = true)] // Ignore in openapi docs
|
|
|
|
[SuppressMessage("Microsoft.Performance", "CA1801:ReviewUnusedParameters", MessageId = "serverId", Justification = "Required for DLNA")]
|
2020-11-08 00:30:56 +00:00
|
|
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
2020-12-22 15:23:55 +00:00
|
|
|
[ProducesResponseType(StatusCodes.Status503ServiceUnavailable)]
|
2020-11-08 00:30:56 +00:00
|
|
|
[Produces(MediaTypeNames.Text.Xml)]
|
|
|
|
[ProducesFile(MediaTypeNames.Text.Xml)]
|
2020-07-31 17:01:30 +00:00
|
|
|
public ActionResult<EventSubscriptionResponse> ProcessContentDirectoryEventRequest(string serverId)
|
2020-04-22 01:15:27 +00:00
|
|
|
{
|
2022-06-11 01:59:21 +00:00
|
|
|
return ProcessEventRequest(_contentDirectory);
|
2020-04-22 01:15:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Processes an event subscription request.
|
|
|
|
/// </summary>
|
2020-07-31 17:01:30 +00:00
|
|
|
/// <param name="serverId">Server UUID.</param>
|
2020-11-08 00:30:56 +00:00
|
|
|
/// <response code="200">Request processed.</response>
|
2020-12-22 15:33:25 +00:00
|
|
|
/// <response code="503">DLNA is disabled.</response>
|
2020-04-22 01:15:27 +00:00
|
|
|
/// <returns>Event subscription response.</returns>
|
2020-07-31 17:01:30 +00:00
|
|
|
[HttpSubscribe("{serverId}/ConnectionManager/Events")]
|
|
|
|
[HttpUnsubscribe("{serverId}/ConnectionManager/Events")]
|
|
|
|
[ApiExplorerSettings(IgnoreApi = true)] // Ignore in openapi docs
|
|
|
|
[SuppressMessage("Microsoft.Performance", "CA1801:ReviewUnusedParameters", MessageId = "serverId", Justification = "Required for DLNA")]
|
2020-11-08 00:30:56 +00:00
|
|
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
2020-12-22 15:23:55 +00:00
|
|
|
[ProducesResponseType(StatusCodes.Status503ServiceUnavailable)]
|
2020-11-08 00:30:56 +00:00
|
|
|
[Produces(MediaTypeNames.Text.Xml)]
|
|
|
|
[ProducesFile(MediaTypeNames.Text.Xml)]
|
2020-07-31 17:01:30 +00:00
|
|
|
public ActionResult<EventSubscriptionResponse> ProcessConnectionManagerEventRequest(string serverId)
|
2020-04-22 01:15:27 +00:00
|
|
|
{
|
2022-06-11 01:59:21 +00:00
|
|
|
return ProcessEventRequest(_connectionManager);
|
2020-04-22 01:15:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Gets a server icon.
|
|
|
|
/// </summary>
|
2020-07-31 17:01:30 +00:00
|
|
|
/// <param name="serverId">Server UUID.</param>
|
2020-04-22 01:15:27 +00:00
|
|
|
/// <param name="fileName">The icon filename.</param>
|
2020-12-22 15:23:55 +00:00
|
|
|
/// <response code="200">Request processed.</response>
|
|
|
|
/// <response code="404">Not Found.</response>
|
2020-12-22 15:33:25 +00:00
|
|
|
/// <response code="503">DLNA is disabled.</response>
|
2020-04-22 01:15:27 +00:00
|
|
|
/// <returns>Icon stream.</returns>
|
2020-08-03 20:38:51 +00:00
|
|
|
[HttpGet("{serverId}/icons/{fileName}")]
|
2020-07-31 17:01:30 +00:00
|
|
|
[SuppressMessage("Microsoft.Performance", "CA1801:ReviewUnusedParameters", MessageId = "serverId", Justification = "Required for DLNA")]
|
2020-09-01 23:26:49 +00:00
|
|
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
2020-12-19 09:34:04 +00:00
|
|
|
[ProducesResponseType(StatusCodes.Status404NotFound)]
|
2020-12-22 15:23:55 +00:00
|
|
|
[ProducesResponseType(StatusCodes.Status503ServiceUnavailable)]
|
2020-09-01 23:26:49 +00:00
|
|
|
[ProducesImageFile]
|
2020-09-06 15:07:27 +00:00
|
|
|
public ActionResult GetIconId([FromRoute, Required] string serverId, [FromRoute, Required] string fileName)
|
2020-04-22 01:15:27 +00:00
|
|
|
{
|
2022-06-11 01:59:21 +00:00
|
|
|
return GetIconInternal(fileName);
|
2020-04-22 01:15:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Gets a server icon.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="fileName">The icon filename.</param>
|
|
|
|
/// <returns>Icon stream.</returns>
|
2020-12-22 15:23:55 +00:00
|
|
|
/// <response code="200">Request processed.</response>
|
|
|
|
/// <response code="404">Not Found.</response>
|
2020-12-22 15:33:25 +00:00
|
|
|
/// <response code="503">DLNA is disabled.</response>
|
2020-08-03 20:38:51 +00:00
|
|
|
[HttpGet("icons/{fileName}")]
|
2020-12-22 15:23:55 +00:00
|
|
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
2020-12-19 09:34:04 +00:00
|
|
|
[ProducesResponseType(StatusCodes.Status404NotFound)]
|
2020-12-22 15:23:55 +00:00
|
|
|
[ProducesResponseType(StatusCodes.Status503ServiceUnavailable)]
|
2020-09-01 23:26:49 +00:00
|
|
|
[ProducesImageFile]
|
2020-09-06 15:07:27 +00:00
|
|
|
public ActionResult GetIcon([FromRoute, Required] string fileName)
|
2020-04-22 01:15:27 +00:00
|
|
|
{
|
2022-06-11 01:59:21 +00:00
|
|
|
return GetIconInternal(fileName);
|
2020-04-22 01:15:27 +00:00
|
|
|
}
|
|
|
|
|
2020-09-02 21:06:13 +00:00
|
|
|
private ActionResult GetIconInternal(string fileName)
|
2020-04-22 01:15:27 +00:00
|
|
|
{
|
|
|
|
var icon = _dlnaManager.GetIcon(fileName);
|
|
|
|
if (icon == null)
|
|
|
|
{
|
|
|
|
return NotFound();
|
|
|
|
}
|
|
|
|
|
2022-01-04 09:40:16 +00:00
|
|
|
return File(icon.Stream, MimeTypes.GetMimeType(fileName));
|
2020-04-22 01:15:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
private string GetAbsoluteUri()
|
|
|
|
{
|
2020-11-21 19:50:40 +00:00
|
|
|
return $"{Request.Scheme}://{Request.Host}{Request.PathBase}{Request.Path}";
|
2020-04-22 01:15:27 +00:00
|
|
|
}
|
|
|
|
|
2020-07-31 17:01:30 +00:00
|
|
|
private Task<ControlResponse> ProcessControlRequestInternalAsync(string id, Stream requestStream, IUpnpService service)
|
2020-04-22 01:15:27 +00:00
|
|
|
{
|
2020-08-20 19:04:57 +00:00
|
|
|
return service.ProcessControlRequestAsync(new ControlRequest(Request.Headers)
|
2020-04-22 01:15:27 +00:00
|
|
|
{
|
|
|
|
InputXml = requestStream,
|
|
|
|
TargetServerUuId = id,
|
|
|
|
RequestedUrl = GetAbsoluteUri()
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2020-08-13 19:47:31 +00:00
|
|
|
private EventSubscriptionResponse ProcessEventRequest(IDlnaEventManager dlnaEventManager)
|
2020-04-22 01:15:27 +00:00
|
|
|
{
|
|
|
|
var subscriptionId = Request.Headers["SID"];
|
|
|
|
if (string.Equals(Request.Method, "subscribe", StringComparison.OrdinalIgnoreCase))
|
|
|
|
{
|
|
|
|
var notificationType = Request.Headers["NT"];
|
|
|
|
var callback = Request.Headers["CALLBACK"];
|
|
|
|
var timeoutString = Request.Headers["TIMEOUT"];
|
|
|
|
|
|
|
|
if (string.IsNullOrEmpty(notificationType))
|
|
|
|
{
|
2020-08-13 19:47:31 +00:00
|
|
|
return dlnaEventManager.RenewEventSubscription(
|
2020-04-22 01:15:27 +00:00
|
|
|
subscriptionId,
|
|
|
|
notificationType,
|
|
|
|
timeoutString,
|
|
|
|
callback);
|
|
|
|
}
|
|
|
|
|
2020-08-13 19:47:31 +00:00
|
|
|
return dlnaEventManager.CreateEventSubscription(notificationType, timeoutString, callback);
|
2020-04-22 01:15:27 +00:00
|
|
|
}
|
|
|
|
|
2020-08-13 19:47:31 +00:00
|
|
|
return dlnaEventManager.CancelEventSubscription(subscriptionId);
|
2020-04-22 01:15:27 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|