CodecProfile.cs 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. using MediaBrowser.Model.Extensions;
  2. using System.Collections.Generic;
  3. using System.Xml.Serialization;
  4. using MediaBrowser.Model.Dlna;
  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 = new ProfileCondition[] {};
  20. ApplyConditions = new 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. }