2020-01-22 13:00:07 -07:00
|
|
|
#pragma warning disable CS1591
|
|
|
|
|
2019-01-13 12:54:44 -07:00
|
|
|
using System;
|
2019-01-13 12:16:19 -07:00
|
|
|
using System.Collections.Generic;
|
2020-01-22 13:00:07 -07:00
|
|
|
using System.Xml;
|
2016-10-29 15:34:54 -07:00
|
|
|
using Emby.Dlna.Service;
|
2019-01-13 12:16:19 -07:00
|
|
|
using MediaBrowser.Common.Extensions;
|
|
|
|
using MediaBrowser.Controller.Configuration;
|
2016-10-29 15:22:20 -07:00
|
|
|
using MediaBrowser.Model.Dlna;
|
2019-01-13 12:16:19 -07:00
|
|
|
using Microsoft.Extensions.Logging;
|
2016-10-29 15:22:20 -07:00
|
|
|
|
2016-10-29 15:34:54 -07:00
|
|
|
namespace Emby.Dlna.ConnectionManager
|
2016-10-29 15:22:20 -07:00
|
|
|
{
|
2020-09-13 06:18:15 -07:00
|
|
|
/// <summary>
|
|
|
|
/// Defines the <see cref="ControlHandler" />.
|
|
|
|
/// </summary>
|
2016-10-29 15:22:20 -07:00
|
|
|
public class ControlHandler : BaseControlHandler
|
|
|
|
{
|
|
|
|
private readonly DeviceProfile _profile;
|
|
|
|
|
2020-09-13 06:18:15 -07:00
|
|
|
/// <summary>
|
|
|
|
/// Initializes a new instance of the <see cref="ControlHandler"/> class.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="config">The <see cref="IServerConfigurationManager"/> for use with the <see cref="ControlHandler"/> instance.</param>
|
|
|
|
/// <param name="logger">The <see cref="ILogger"/> for use with the <see cref="ControlHandler"/> instance.</param>
|
|
|
|
/// <param name="profile">The <see cref="DeviceProfile"/> for use with the <see cref="ControlHandler"/> instance.</param>
|
2020-01-22 13:00:07 -07:00
|
|
|
public ControlHandler(IServerConfigurationManager config, ILogger logger, DeviceProfile profile)
|
|
|
|
: base(config, logger)
|
|
|
|
{
|
|
|
|
_profile = profile;
|
|
|
|
}
|
|
|
|
|
|
|
|
/// <inheritdoc />
|
2021-04-01 10:16:00 -07:00
|
|
|
protected override void WriteResult(string methodName, IReadOnlyDictionary<string, string> methodParams, XmlWriter xmlWriter)
|
2016-10-29 15:22:20 -07:00
|
|
|
{
|
|
|
|
if (string.Equals(methodName, "GetProtocolInfo", StringComparison.OrdinalIgnoreCase))
|
|
|
|
{
|
2020-01-22 13:00:07 -07:00
|
|
|
HandleGetProtocolInfo(xmlWriter);
|
2020-01-26 09:41:34 -07:00
|
|
|
return;
|
2016-10-29 15:22:20 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
throw new ResourceNotFoundException("Unexpected control request name: " + methodName);
|
|
|
|
}
|
|
|
|
|
2020-09-13 06:18:15 -07:00
|
|
|
/// <summary>
|
|
|
|
/// Builds the response to the GetProtocolInfo request.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="xmlWriter">The <see cref="XmlWriter"/>.</param>
|
2020-01-22 13:00:07 -07:00
|
|
|
private void HandleGetProtocolInfo(XmlWriter xmlWriter)
|
2016-10-29 15:22:20 -07:00
|
|
|
{
|
2020-01-22 13:00:07 -07:00
|
|
|
xmlWriter.WriteElementString("Source", _profile.ProtocolInfo);
|
|
|
|
xmlWriter.WriteElementString("Sink", string.Empty);
|
2016-11-04 01:31:05 -07:00
|
|
|
}
|
2016-10-29 15:22:20 -07:00
|
|
|
}
|
|
|
|
}
|