MediaSourceInfo.cs 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  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 VideoType? VideoType { get; set; }
  21. public IsoType? IsoType { get; set; }
  22. public Video3DFormat? Video3DFormat { get; set; }
  23. public List<MediaStream> MediaStreams { get; set; }
  24. public List<string> PlayableStreamFileNames { get; set; }
  25. public List<string> Formats { get; set; }
  26. public int? Bitrate { get; set; }
  27. public TransportStreamTimestamp? Timestamp { get; set; }
  28. public Dictionary<string, string> RequiredHttpHeaders { get; set; }
  29. public MediaSourceInfo()
  30. {
  31. Formats = new List<string>();
  32. MediaStreams = new List<MediaStream>();
  33. RequiredHttpHeaders = new Dictionary<string, string>();
  34. PlayableStreamFileNames = new List<string>();
  35. SupportsTranscoding = true;
  36. }
  37. public int? DefaultAudioStreamIndex { get; set; }
  38. public int? DefaultSubtitleStreamIndex { get; set; }
  39. [IgnoreDataMember]
  40. public MediaStream DefaultAudioStream
  41. {
  42. get
  43. {
  44. if (DefaultAudioStreamIndex.HasValue)
  45. {
  46. var val = DefaultAudioStreamIndex.Value;
  47. foreach (MediaStream i in MediaStreams)
  48. {
  49. if (i.Type == MediaStreamType.Audio && i.Index == val)
  50. {
  51. return i;
  52. }
  53. }
  54. }
  55. foreach (MediaStream i in MediaStreams)
  56. {
  57. if (i.Type == MediaStreamType.Audio && i.IsDefault)
  58. {
  59. return i;
  60. }
  61. }
  62. foreach (MediaStream i in MediaStreams)
  63. {
  64. if (i.Type == MediaStreamType.Audio)
  65. {
  66. return i;
  67. }
  68. }
  69. return null;
  70. }
  71. }
  72. [IgnoreDataMember]
  73. public MediaStream VideoStream
  74. {
  75. get
  76. {
  77. foreach (MediaStream i in MediaStreams)
  78. {
  79. if (i.Type == MediaStreamType.Video && StringHelper.IndexOfIgnoreCase((i.Codec ?? string.Empty), "jpeg") == -1)
  80. {
  81. return i;
  82. }
  83. }
  84. return null;
  85. }
  86. }
  87. public MediaStream GetMediaStream(MediaStreamType type, int index)
  88. {
  89. foreach (MediaStream i in MediaStreams)
  90. {
  91. if (i.Type == type && i.Index == index)
  92. {
  93. return i;
  94. }
  95. }
  96. return null;
  97. }
  98. }
  99. }