MediaStream.cs 7.5 KB

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