ControlHandler.cs 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. using System;
  2. using System.Collections.Generic;
  3. using Emby.Dlna.Service;
  4. using MediaBrowser.Common.Extensions;
  5. using MediaBrowser.Controller.Configuration;
  6. using MediaBrowser.Model.Dlna;
  7. using MediaBrowser.Model.Xml;
  8. using Microsoft.Extensions.Logging;
  9. namespace Emby.Dlna.ConnectionManager
  10. {
  11. public class ControlHandler : BaseControlHandler
  12. {
  13. private readonly DeviceProfile _profile;
  14. protected override IEnumerable<KeyValuePair<string, string>> GetResult(string methodName, IDictionary<string, string> methodParams)
  15. {
  16. if (string.Equals(methodName, "GetProtocolInfo", StringComparison.OrdinalIgnoreCase))
  17. {
  18. return HandleGetProtocolInfo();
  19. }
  20. throw new ResourceNotFoundException("Unexpected control request name: " + methodName);
  21. }
  22. private IEnumerable<KeyValuePair<string, string>> HandleGetProtocolInfo()
  23. {
  24. return new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase)
  25. {
  26. { "Source", _profile.ProtocolInfo },
  27. { "Sink", "" }
  28. };
  29. }
  30. public ControlHandler(IServerConfigurationManager config, ILogger logger, IXmlReaderSettingsFactory xmlReaderSettingsFactory, DeviceProfile profile) : base(config, logger, xmlReaderSettingsFactory)
  31. {
  32. _profile = profile;
  33. }
  34. }
  35. }