CodecProfile.cs 1.6 KB

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