ConnectionManagerService.cs 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. #pragma warning disable CS1591
  2. using System.Net.Http;
  3. using System.Threading.Tasks;
  4. using Emby.Dlna.Service;
  5. using MediaBrowser.Controller.Configuration;
  6. using MediaBrowser.Controller.Dlna;
  7. using Microsoft.Extensions.Logging;
  8. namespace Emby.Dlna.ConnectionManager
  9. {
  10. /// <summary>
  11. /// Defines the <see cref="ConnectionManagerService" />.
  12. /// </summary>
  13. public class ConnectionManagerService : BaseService, IConnectionManager
  14. {
  15. private readonly IDlnaManager _dlna;
  16. private readonly IServerConfigurationManager _config;
  17. /// <summary>
  18. /// Initializes a new instance of the <see cref="ConnectionManagerService"/> class.
  19. /// </summary>
  20. /// <param name="dlna">The <see cref="IDlnaManager"/> for use with the <see cref="ConnectionManagerService"/> instance.</param>
  21. /// <param name="config">The <see cref="IServerConfigurationManager"/> for use with the <see cref="ConnectionManagerService"/> instance.</param>
  22. /// <param name="logger">The <see cref="ILogger{ConnectionManagerService}"/> for use with the <see cref="ConnectionManagerService"/> instance..</param>
  23. /// <param name="httpClientFactory">The <see cref="IHttpClientFactory"/> for use with the <see cref="ConnectionManagerService"/> instance..</param>
  24. public ConnectionManagerService(
  25. IDlnaManager dlna,
  26. IServerConfigurationManager config,
  27. ILogger<ConnectionManagerService> logger,
  28. IHttpClientFactory httpClientFactory)
  29. : base(logger, httpClientFactory)
  30. {
  31. _dlna = dlna;
  32. _config = config;
  33. }
  34. /// <inheritdoc />
  35. public string GetServiceXml()
  36. {
  37. return ConnectionManagerXmlBuilder.GetXml();
  38. }
  39. /// <inheritdoc />
  40. public Task<ControlResponse> ProcessControlRequestAsync(ControlRequest request)
  41. {
  42. var profile = _dlna.GetProfile(request.Headers) ??
  43. _dlna.GetDefaultProfile();
  44. return new ControlHandler(_config, Logger, profile).ProcessControlRequestAsync(request);
  45. }
  46. }
  47. }