CodecProfile.cs 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Xml.Serialization;
  5. namespace MediaBrowser.Controller.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.IsNullOrWhiteSpace(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. Filesize,
  62. Width,
  63. Height,
  64. Has64BitOffsets,
  65. VideoBitDepth,
  66. VideoBitrate,
  67. VideoFramerate,
  68. VideoLevel,
  69. VideoProfile
  70. }
  71. }