MediaSourceInfo.cs 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. using MediaBrowser.Model.Entities;
  2. using MediaBrowser.Model.Extensions;
  3. using MediaBrowser.Model.MediaInfo;
  4. using System.Collections.Generic;
  5. using System.Runtime.Serialization;
  6. namespace MediaBrowser.Model.Dto
  7. {
  8. public class MediaSourceInfo
  9. {
  10. public MediaProtocol Protocol { get; set; }
  11. public string Id { get; set; }
  12. public string Path { get; set; }
  13. public MediaSourceType Type { get; set; }
  14. public string Container { get; set; }
  15. public long? Size { get; set; }
  16. public string Name { get; set; }
  17. public long? RunTimeTicks { get; set; }
  18. public bool ReadAtNativeFramerate { get; set; }
  19. public bool SupportsTranscoding { get; set; }
  20. public bool SupportsDirectStream { get; set; }
  21. public VideoType? VideoType { get; set; }
  22. public IsoType? IsoType { get; set; }
  23. public Video3DFormat? Video3DFormat { get; set; }
  24. public List<MediaStream> MediaStreams { get; set; }
  25. public List<string> PlayableStreamFileNames { get; set; }
  26. public List<string> Formats { get; set; }
  27. public int? Bitrate { get; set; }
  28. public TransportStreamTimestamp? Timestamp { get; set; }
  29. public Dictionary<string, string> RequiredHttpHeaders { get; set; }
  30. public MediaSourceInfo()
  31. {
  32. Formats = new List<string>();
  33. MediaStreams = new List<MediaStream>();
  34. RequiredHttpHeaders = new Dictionary<string, string>();
  35. PlayableStreamFileNames = new List<string>();
  36. SupportsTranscoding = true;
  37. SupportsDirectStream = true;
  38. }
  39. public int? DefaultAudioStreamIndex { get; set; }
  40. public int? DefaultSubtitleStreamIndex { get; set; }
  41. [IgnoreDataMember]
  42. public MediaStream DefaultAudioStream
  43. {
  44. get
  45. {
  46. if (DefaultAudioStreamIndex.HasValue)
  47. {
  48. var val = DefaultAudioStreamIndex.Value;
  49. foreach (MediaStream i in MediaStreams)
  50. {
  51. if (i.Type == MediaStreamType.Audio && i.Index == val)
  52. {
  53. return i;
  54. }
  55. }
  56. }
  57. foreach (MediaStream i in MediaStreams)
  58. {
  59. if (i.Type == MediaStreamType.Audio && i.IsDefault)
  60. {
  61. return i;
  62. }
  63. }
  64. foreach (MediaStream i in MediaStreams)
  65. {
  66. if (i.Type == MediaStreamType.Audio)
  67. {
  68. return i;
  69. }
  70. }
  71. return null;
  72. }
  73. }
  74. [IgnoreDataMember]
  75. public MediaStream VideoStream
  76. {
  77. get
  78. {
  79. foreach (MediaStream i in MediaStreams)
  80. {
  81. if (i.Type == MediaStreamType.Video && StringHelper.IndexOfIgnoreCase((i.Codec ?? string.Empty), "jpeg") == -1)
  82. {
  83. return i;
  84. }
  85. }
  86. return null;
  87. }
  88. }
  89. public MediaStream GetMediaStream(MediaStreamType type, int index)
  90. {
  91. foreach (MediaStream i in MediaStreams)
  92. {
  93. if (i.Type == type && i.Index == index)
  94. {
  95. return i;
  96. }
  97. }
  98. return null;
  99. }
  100. }
  101. }