MediaStream.cs 7.3 KB

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