CodecProfile.cs 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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. PacketLength,
  65. VideoBitDepth,
  66. VideoBitrate,
  67. VideoFramerate,
  68. VideoLevel,
  69. VideoProfile,
  70. VideoTimestamp
  71. }
  72. }