MediaStream.cs 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236
  1. using System.Collections.Generic;
  2. using MediaBrowser.Model.Dlna;
  3. using MediaBrowser.Model.Extensions;
  4. using System.Diagnostics;
  5. namespace MediaBrowser.Model.Entities
  6. {
  7. /// <summary>
  8. /// Class MediaStream
  9. /// </summary>
  10. [DebuggerDisplay("StreamType = {Type}")]
  11. public class MediaStream
  12. {
  13. /// <summary>
  14. /// Gets or sets the codec.
  15. /// </summary>
  16. /// <value>The codec.</value>
  17. public string Codec { get; set; }
  18. /// <summary>
  19. /// Gets or sets the language.
  20. /// </summary>
  21. /// <value>The language.</value>
  22. public string Language { get; set; }
  23. /// <summary>
  24. /// Gets or sets a value indicating whether this instance is interlaced.
  25. /// </summary>
  26. /// <value><c>true</c> if this instance is interlaced; otherwise, <c>false</c>.</value>
  27. public bool IsInterlaced { get; set; }
  28. /// <summary>
  29. /// Gets or sets the channel layout.
  30. /// </summary>
  31. /// <value>The channel layout.</value>
  32. public string ChannelLayout { get; set; }
  33. /// <summary>
  34. /// Gets or sets the bit rate.
  35. /// </summary>
  36. /// <value>The bit rate.</value>
  37. public int? BitRate { get; set; }
  38. /// <summary>
  39. /// Gets or sets the bit depth.
  40. /// </summary>
  41. /// <value>The bit depth.</value>
  42. public int? BitDepth { get; set; }
  43. /// <summary>
  44. /// Gets or sets the reference frames.
  45. /// </summary>
  46. /// <value>The reference frames.</value>
  47. public int? RefFrames { get; set; }
  48. /// <summary>
  49. /// Gets or sets the length of the packet.
  50. /// </summary>
  51. /// <value>The length of the packet.</value>
  52. public int? PacketLength { get; set; }
  53. /// <summary>
  54. /// Gets or sets the key frames.
  55. /// </summary>
  56. /// <value>The key frames.</value>
  57. public List<int> KeyFrames { get; set; }
  58. /// <summary>
  59. /// Gets or sets the channels.
  60. /// </summary>
  61. /// <value>The channels.</value>
  62. public int? Channels { get; set; }
  63. /// <summary>
  64. /// Gets or sets the sample rate.
  65. /// </summary>
  66. /// <value>The sample rate.</value>
  67. public int? SampleRate { get; set; }
  68. /// <summary>
  69. /// Gets or sets a value indicating whether this instance is default.
  70. /// </summary>
  71. /// <value><c>true</c> if this instance is default; otherwise, <c>false</c>.</value>
  72. public bool IsDefault { get; set; }
  73. /// <summary>
  74. /// Gets or sets a value indicating whether this instance is forced.
  75. /// </summary>
  76. /// <value><c>true</c> if this instance is forced; otherwise, <c>false</c>.</value>
  77. public bool IsForced { get; set; }
  78. /// <summary>
  79. /// Gets or sets the height.
  80. /// </summary>
  81. /// <value>The height.</value>
  82. public int? Height { get; set; }
  83. /// <summary>
  84. /// Gets or sets the width.
  85. /// </summary>
  86. /// <value>The width.</value>
  87. public int? Width { get; set; }
  88. /// <summary>
  89. /// Gets or sets the average frame rate.
  90. /// </summary>
  91. /// <value>The average frame rate.</value>
  92. public float? AverageFrameRate { get; set; }
  93. /// <summary>
  94. /// Gets or sets the real frame rate.
  95. /// </summary>
  96. /// <value>The real frame rate.</value>
  97. public float? RealFrameRate { get; set; }
  98. /// <summary>
  99. /// Gets or sets the profile.
  100. /// </summary>
  101. /// <value>The profile.</value>
  102. public string Profile { get; set; }
  103. /// <summary>
  104. /// Gets or sets the type.
  105. /// </summary>
  106. /// <value>The type.</value>
  107. public MediaStreamType Type { get; set; }
  108. /// <summary>
  109. /// Gets or sets the aspect ratio.
  110. /// </summary>
  111. /// <value>The aspect ratio.</value>
  112. public string AspectRatio { get; set; }
  113. /// <summary>
  114. /// Gets or sets the index.
  115. /// </summary>
  116. /// <value>The index.</value>
  117. public int Index { get; set; }
  118. /// <summary>
  119. /// Gets or sets the score.
  120. /// </summary>
  121. /// <value>The score.</value>
  122. public int? Score { get; set; }
  123. /// <summary>
  124. /// Gets or sets a value indicating whether this instance is external.
  125. /// </summary>
  126. /// <value><c>true</c> if this instance is external; otherwise, <c>false</c>.</value>
  127. public bool IsExternal { get; set; }
  128. /// <summary>
  129. /// Gets or sets the method.
  130. /// </summary>
  131. /// <value>The method.</value>
  132. public SubtitleDeliveryMethod? DeliveryMethod { get; set; }
  133. /// <summary>
  134. /// Gets or sets the delivery URL.
  135. /// </summary>
  136. /// <value>The delivery URL.</value>
  137. public string DeliveryUrl { get; set; }
  138. /// <summary>
  139. /// Gets or sets a value indicating whether this instance is external URL.
  140. /// </summary>
  141. /// <value><c>null</c> if [is external URL] contains no value, <c>true</c> if [is external URL]; otherwise, <c>false</c>.</value>
  142. public bool? IsExternalUrl { get; set; }
  143. public bool IsTextSubtitleStream
  144. {
  145. get
  146. {
  147. if (Type != MediaStreamType.Subtitle) return false;
  148. if (string.IsNullOrEmpty(Codec) && !IsExternal)
  149. {
  150. return false;
  151. }
  152. return IsTextFormat(Codec);
  153. }
  154. }
  155. public static bool IsTextFormat(string format)
  156. {
  157. string codec = format ?? string.Empty;
  158. // sub = external .sub file
  159. return StringHelper.IndexOfIgnoreCase(codec, "pgs") == -1 &&
  160. StringHelper.IndexOfIgnoreCase(codec, "dvd") == -1 &&
  161. !StringHelper.EqualsIgnoreCase(codec, "sub");
  162. }
  163. /// <summary>
  164. /// Gets or sets a value indicating whether [supports external stream].
  165. /// </summary>
  166. /// <value><c>true</c> if [supports external stream]; otherwise, <c>false</c>.</value>
  167. public bool SupportsExternalStream { get; set; }
  168. /// <summary>
  169. /// Gets or sets the filename.
  170. /// </summary>
  171. /// <value>The filename.</value>
  172. public string Path { get; set; }
  173. /// <summary>
  174. /// Gets or sets the external identifier.
  175. /// </summary>
  176. /// <value>The external identifier.</value>
  177. public string ExternalId { get; set; }
  178. /// <summary>
  179. /// Gets or sets the pixel format.
  180. /// </summary>
  181. /// <value>The pixel format.</value>
  182. public string PixelFormat { get; set; }
  183. /// <summary>
  184. /// Gets or sets the level.
  185. /// </summary>
  186. /// <value>The level.</value>
  187. public double? Level { get; set; }
  188. /// <summary>
  189. /// Gets a value indicating whether this instance is anamorphic.
  190. /// </summary>
  191. /// <value><c>true</c> if this instance is anamorphic; otherwise, <c>false</c>.</value>
  192. public bool? IsAnamorphic { get; set; }
  193. /// <summary>
  194. /// Gets or sets a value indicating whether this instance is cabac.
  195. /// </summary>
  196. /// <value><c>null</c> if [is cabac] contains no value, <c>true</c> if [is cabac]; otherwise, <c>false</c>.</value>
  197. public bool? IsCabac { get; set; }
  198. }
  199. }