DirectPlayProfile.cs 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Xml.Serialization;
  5. namespace MediaBrowser.Model.Dlna
  6. {
  7. public class DirectPlayProfile
  8. {
  9. [XmlAttribute("container")]
  10. public string Container { get; set; }
  11. [XmlAttribute("audioCodec")]
  12. public string AudioCodec { get; set; }
  13. [XmlAttribute("videoCodec")]
  14. public string VideoCodec { get; set; }
  15. [XmlAttribute("type")]
  16. public DlnaProfileType Type { get; set; }
  17. public List<string> GetContainers()
  18. {
  19. List<string> list = new List<string>();
  20. foreach (string i in (Container ?? string.Empty).Split(','))
  21. {
  22. if (!string.IsNullOrEmpty(i)) list.Add(i);
  23. }
  24. return list;
  25. }
  26. public bool SupportsContainer(string container)
  27. {
  28. var all = GetContainers();
  29. // Only allow unknown container if the profile is all inclusive
  30. if (string.IsNullOrWhiteSpace(container))
  31. {
  32. return all.Count == 0;
  33. }
  34. return all.Count == 0 || all.Contains(container, StringComparer.OrdinalIgnoreCase);
  35. }
  36. public List<string> GetAudioCodecs()
  37. {
  38. List<string> list = new List<string>();
  39. foreach (string i in (AudioCodec ?? string.Empty).Split(','))
  40. {
  41. if (!string.IsNullOrEmpty(i)) list.Add(i);
  42. }
  43. return list;
  44. }
  45. public List<string> GetVideoCodecs()
  46. {
  47. List<string> list = new List<string>();
  48. foreach (string i in (VideoCodec ?? string.Empty).Split(','))
  49. {
  50. if (!string.IsNullOrEmpty(i)) list.Add(i);
  51. }
  52. return list;
  53. }
  54. }
  55. }