MediaStream.cs 7.4 KB

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