ControlHandler.cs 1.3 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 Microsoft.Extensions.Logging;
  8. namespace Emby.Dlna.ConnectionManager
  9. {
  10. public class ControlHandler : BaseControlHandler
  11. {
  12. private readonly DeviceProfile _profile;
  13. protected override IEnumerable<KeyValuePair<string, string>> GetResult(string methodName, IDictionary<string, string> methodParams)
  14. {
  15. if (string.Equals(methodName, "GetProtocolInfo", StringComparison.OrdinalIgnoreCase))
  16. {
  17. return HandleGetProtocolInfo();
  18. }
  19. throw new ResourceNotFoundException("Unexpected control request name: " + methodName);
  20. }
  21. private IEnumerable<KeyValuePair<string, string>> HandleGetProtocolInfo()
  22. {
  23. return new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase)
  24. {
  25. { "Source", _profile.ProtocolInfo },
  26. { "Sink", "" }
  27. };
  28. }
  29. public ControlHandler(IServerConfigurationManager config, ILogger logger, DeviceProfile profile)
  30. : base(config, logger)
  31. {
  32. _profile = profile;
  33. }
  34. }
  35. }