CodecProfile.cs 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. namespace MediaBrowser.Controller.Dlna
  5. {
  6. public class CodecProfile
  7. {
  8. public CodecType Type { get; set; }
  9. public ProfileCondition[] Conditions { get; set; }
  10. public string Codec { get; set; }
  11. public CodecProfile()
  12. {
  13. Conditions = new ProfileCondition[] {};
  14. }
  15. public List<string> GetCodecs()
  16. {
  17. return (Codec ?? string.Empty).Split(',').Where(i => !string.IsNullOrWhiteSpace(i)).ToList();
  18. }
  19. public bool ContainsCodec(string codec)
  20. {
  21. var codecs = GetCodecs();
  22. return codecs.Count == 0 || codecs.Contains(codec, StringComparer.OrdinalIgnoreCase);
  23. }
  24. }
  25. public enum CodecType
  26. {
  27. VideoCodec = 0,
  28. VideoAudioCodec = 1,
  29. AudioCodec = 2
  30. }
  31. public class ProfileCondition
  32. {
  33. public ProfileConditionType Condition { get; set; }
  34. public ProfileConditionValue Property { get; set; }
  35. public string Value { get; set; }
  36. public bool IsRequired { get; set; }
  37. public ProfileCondition()
  38. {
  39. IsRequired = true;
  40. }
  41. }
  42. public enum ProfileConditionType
  43. {
  44. Equals = 0,
  45. NotEquals = 1,
  46. LessThanEqual = 2,
  47. GreaterThanEqual = 3
  48. }
  49. public enum ProfileConditionValue
  50. {
  51. AudioChannels,
  52. AudioBitrate,
  53. AudioProfile,
  54. Filesize,
  55. Width,
  56. Height,
  57. Has64BitOffsets,
  58. VideoBitDepth,
  59. VideoBitrate,
  60. VideoFramerate,
  61. VideoLevel,
  62. VideoPacketLength,
  63. VideoProfile,
  64. VideoTimestamp
  65. }
  66. }