CodecProfile.cs 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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 CodecProfile
  8. {
  9. [XmlAttribute("type")]
  10. public CodecType Type { get; set; }
  11. public ProfileCondition[] Conditions { get; set; }
  12. [XmlAttribute("codec")]
  13. public string Codec { get; set; }
  14. public CodecProfile()
  15. {
  16. Conditions = new ProfileCondition[] {};
  17. }
  18. public List<string> GetCodecs()
  19. {
  20. return (Codec ?? string.Empty).Split(',').Where(i => !string.IsNullOrEmpty(i)).ToList();
  21. }
  22. public bool ContainsCodec(string codec)
  23. {
  24. var codecs = GetCodecs();
  25. return codecs.Count == 0 || codecs.Contains(codec, StringComparer.OrdinalIgnoreCase);
  26. }
  27. }
  28. public enum CodecType
  29. {
  30. Video = 0,
  31. VideoAudio = 1,
  32. Audio = 2
  33. }
  34. public class ProfileCondition
  35. {
  36. [XmlAttribute("condition")]
  37. public ProfileConditionType Condition { get; set; }
  38. [XmlAttribute("property")]
  39. public ProfileConditionValue Property { get; set; }
  40. [XmlAttribute("value")]
  41. public string Value { get; set; }
  42. [XmlAttribute("isRequired")]
  43. public bool IsRequired { get; set; }
  44. public ProfileCondition()
  45. {
  46. IsRequired = true;
  47. }
  48. }
  49. public enum ProfileConditionType
  50. {
  51. Equals = 0,
  52. NotEquals = 1,
  53. LessThanEqual = 2,
  54. GreaterThanEqual = 3
  55. }
  56. public enum ProfileConditionValue
  57. {
  58. AudioChannels,
  59. AudioBitrate,
  60. AudioProfile,
  61. Width,
  62. Height,
  63. Has64BitOffsets,
  64. VideoBitDepth,
  65. VideoBitrate,
  66. VideoFramerate,
  67. VideoLevel,
  68. VideoProfile
  69. }
  70. }