MediaStream.cs 7.8 KB

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