CodecProfile.cs 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. #pragma warning disable CS1591
  2. using System;
  3. using System.Xml.Serialization;
  4. using MediaBrowser.Model.Extensions;
  5. namespace MediaBrowser.Model.Dlna
  6. {
  7. public class CodecProfile
  8. {
  9. [XmlAttribute("type")]
  10. public CodecType Type { get; set; }
  11. public ProfileCondition[] Conditions { get; set; }
  12. public ProfileCondition[] ApplyConditions { get; set; }
  13. [XmlAttribute("codec")]
  14. public string Codec { get; set; }
  15. [XmlAttribute("container")]
  16. public string Container { get; set; }
  17. public CodecProfile()
  18. {
  19. Conditions = Array.Empty<ProfileCondition>();
  20. ApplyConditions = Array.Empty<ProfileCondition>();
  21. }
  22. public string[] GetCodecs()
  23. {
  24. return ContainerProfile.SplitValue(Codec);
  25. }
  26. private bool ContainsContainer(string container)
  27. {
  28. return ContainerProfile.ContainsContainer(Container, container);
  29. }
  30. public bool ContainsAnyCodec(string codec, string container)
  31. {
  32. return ContainsAnyCodec(ContainerProfile.SplitValue(codec), container);
  33. }
  34. public bool ContainsAnyCodec(string[] codec, string container)
  35. {
  36. if (!ContainsContainer(container))
  37. {
  38. return false;
  39. }
  40. var codecs = GetCodecs();
  41. if (codecs.Length == 0)
  42. {
  43. return true;
  44. }
  45. foreach (var val in codec)
  46. {
  47. if (ListHelper.ContainsIgnoreCase(codecs, val))
  48. {
  49. return true;
  50. }
  51. }
  52. return false;
  53. }
  54. }
  55. }