StreamRequest.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  1. using MediaBrowser.Model.Dlna;
  2. using ServiceStack;
  3. namespace MediaBrowser.Api.Playback
  4. {
  5. /// <summary>
  6. /// Class StreamRequest
  7. /// </summary>
  8. public class StreamRequest
  9. {
  10. /// <summary>
  11. /// Gets or sets the id.
  12. /// </summary>
  13. /// <value>The id.</value>
  14. [ApiMember(Name = "Id", Description = "Item Id", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "GET")]
  15. public string Id { get; set; }
  16. [ApiMember(Name = "MediaSourceId", Description = "The media version id, if playing an alternate version", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "GET")]
  17. public string MediaSourceId { get; set; }
  18. [ApiMember(Name = "DeviceId", Description = "The device id of the client requesting. Used to stop encoding processes when needed.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")]
  19. public string DeviceId { get; set; }
  20. /// <summary>
  21. /// Gets or sets the audio codec.
  22. /// </summary>
  23. /// <value>The audio codec.</value>
  24. [ApiMember(Name = "AudioCodec", Description = "Optional. Specify a audio codec to encode to, e.g. mp3. If omitted the server will auto-select using the url's extension. Options: aac, mp3, vorbis, wma.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")]
  25. public string AudioCodec { get; set; }
  26. /// <summary>
  27. /// Gets or sets the start time ticks.
  28. /// </summary>
  29. /// <value>The start time ticks.</value>
  30. [ApiMember(Name = "StartTimeTicks", Description = "Optional. Specify a starting offset, in ticks. 1 tick = 10000 ms", IsRequired = false, DataType = "int", ParameterType = "query", Verb = "GET")]
  31. public long? StartTimeTicks { get; set; }
  32. /// <summary>
  33. /// Gets or sets the audio bit rate.
  34. /// </summary>
  35. /// <value>The audio bit rate.</value>
  36. [ApiMember(Name = "AudioBitRate", Description = "Optional. Specify an audio bitrate to encode to, e.g. 128000. If omitted this will be left to encoder defaults.", IsRequired = false, DataType = "int", ParameterType = "query", Verb = "GET")]
  37. public int? AudioBitRate { get; set; }
  38. /// <summary>
  39. /// Gets or sets the audio channels.
  40. /// </summary>
  41. /// <value>The audio channels.</value>
  42. [ApiMember(Name = "AudioChannels", Description = "Optional. Specify a specific number of audio channels to encode to, e.g. 2", IsRequired = false, DataType = "int", ParameterType = "query", Verb = "GET")]
  43. public int? AudioChannels { get; set; }
  44. [ApiMember(Name = "MaxAudioChannels", Description = "Optional. Specify a maximum number of audio channels to encode to, e.g. 2", IsRequired = false, DataType = "int", ParameterType = "query", Verb = "GET")]
  45. public int? MaxAudioChannels { get; set; }
  46. public int? TranscodingMaxAudioChannels { get; set; }
  47. /// <summary>
  48. /// Gets or sets the audio sample rate.
  49. /// </summary>
  50. /// <value>The audio sample rate.</value>
  51. [ApiMember(Name = "AudioSampleRate", Description = "Optional. Specify a specific audio sample rate, e.g. 44100", IsRequired = false, DataType = "int", ParameterType = "query", Verb = "GET")]
  52. public int? AudioSampleRate { get; set; }
  53. /// <summary>
  54. /// Gets or sets a value indicating whether this <see cref="StreamRequest" /> is static.
  55. /// </summary>
  56. /// <value><c>true</c> if static; otherwise, <c>false</c>.</value>
  57. [ApiMember(Name = "Static", Description = "Optional. If true, the original file will be streamed statically without any encoding. Use either no url extension or the original file extension. true/false", IsRequired = false, DataType = "bool", ParameterType = "query", Verb = "GET")]
  58. public bool Static { get; set; }
  59. [ApiMember(Name = "DeviceProfileId", Description = "Optional. The dlna device profile id to utilize.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")]
  60. public string DeviceProfileId { get; set; }
  61. public string Params { get; set; }
  62. public string PlaySessionId { get; set; }
  63. public string LiveStreamId { get; set; }
  64. public string Tag { get; set; }
  65. }
  66. public class VideoStreamRequest : StreamRequest
  67. {
  68. /// <summary>
  69. /// Gets or sets the video codec.
  70. /// </summary>
  71. /// <value>The video codec.</value>
  72. [ApiMember(Name = "VideoCodec", Description = "Optional. Specify a video codec to encode to, e.g. h264. If omitted the server will auto-select using the url's extension. Options: h264, mpeg4, theora, vpx, wmv.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")]
  73. public string VideoCodec { get; set; }
  74. /// <summary>
  75. /// Gets or sets the video bit rate.
  76. /// </summary>
  77. /// <value>The video bit rate.</value>
  78. [ApiMember(Name = "VideoBitRate", Description = "Optional. Specify a video bitrate to encode to, e.g. 500000. If omitted this will be left to encoder defaults.", IsRequired = false, DataType = "int", ParameterType = "query", Verb = "GET")]
  79. public int? VideoBitRate { get; set; }
  80. /// <summary>
  81. /// Gets or sets the index of the audio stream.
  82. /// </summary>
  83. /// <value>The index of the audio stream.</value>
  84. [ApiMember(Name = "AudioStreamIndex", Description = "Optional. The index of the audio stream to use. If omitted the first audio stream will be used.", IsRequired = false, DataType = "int", ParameterType = "query", Verb = "GET")]
  85. public int? AudioStreamIndex { get; set; }
  86. /// <summary>
  87. /// Gets or sets the index of the video stream.
  88. /// </summary>
  89. /// <value>The index of the video stream.</value>
  90. [ApiMember(Name = "VideoStreamIndex", Description = "Optional. The index of the video stream to use. If omitted the first video stream will be used.", IsRequired = false, DataType = "int", ParameterType = "query", Verb = "GET")]
  91. public int? VideoStreamIndex { get; set; }
  92. /// <summary>
  93. /// Gets or sets the index of the subtitle stream.
  94. /// </summary>
  95. /// <value>The index of the subtitle stream.</value>
  96. [ApiMember(Name = "SubtitleStreamIndex", Description = "Optional. The index of the subtitle stream to use. If omitted no subtitles will be used.", IsRequired = false, DataType = "int", ParameterType = "query", Verb = "GET")]
  97. public int? SubtitleStreamIndex { get; set; }
  98. /// <summary>
  99. /// Gets or sets the width.
  100. /// </summary>
  101. /// <value>The width.</value>
  102. [ApiMember(Name = "Width", Description = "Optional. The fixed horizontal resolution of the encoded video.", IsRequired = false, DataType = "int", ParameterType = "query", Verb = "GET")]
  103. public int? Width { get; set; }
  104. /// <summary>
  105. /// Gets or sets the height.
  106. /// </summary>
  107. /// <value>The height.</value>
  108. [ApiMember(Name = "Height", Description = "Optional. The fixed vertical resolution of the encoded video.", IsRequired = false, DataType = "int", ParameterType = "query", Verb = "GET")]
  109. public int? Height { get; set; }
  110. /// <summary>
  111. /// Gets or sets the width of the max.
  112. /// </summary>
  113. /// <value>The width of the max.</value>
  114. [ApiMember(Name = "MaxWidth", Description = "Optional. The maximum horizontal resolution of the encoded video.", IsRequired = false, DataType = "int", ParameterType = "query", Verb = "GET")]
  115. public int? MaxWidth { get; set; }
  116. /// <summary>
  117. /// Gets or sets the height of the max.
  118. /// </summary>
  119. /// <value>The height of the max.</value>
  120. [ApiMember(Name = "MaxHeight", Description = "Optional. The maximum vertical resolution of the encoded video.", IsRequired = false, DataType = "int", ParameterType = "query", Verb = "GET")]
  121. public int? MaxHeight { get; set; }
  122. [ApiMember(Name = "MaxRefFrames", Description = "Optional.", IsRequired = false, DataType = "int", ParameterType = "query", Verb = "GET")]
  123. public int? MaxRefFrames { get; set; }
  124. [ApiMember(Name = "MaxVideoBitDepth", Description = "Optional.", IsRequired = false, DataType = "int", ParameterType = "query", Verb = "GET")]
  125. public int? MaxVideoBitDepth { get; set; }
  126. /// <summary>
  127. /// Gets or sets the framerate.
  128. /// </summary>
  129. /// <value>The framerate.</value>
  130. [ApiMember(Name = "Framerate", Description = "Optional. A specific video framerate to encode to, e.g. 23.976. Generally this should be omitted unless the device has specific requirements.", IsRequired = false, DataType = "double", ParameterType = "query", Verb = "GET")]
  131. public float? Framerate { get; set; }
  132. [ApiMember(Name = "MaxFramerate", Description = "Optional. A specific maximum video framerate to encode to, e.g. 23.976. Generally this should be omitted unless the device has specific requirements.", IsRequired = false, DataType = "double", ParameterType = "query", Verb = "GET")]
  133. public float? MaxFramerate { get; set; }
  134. /// <summary>
  135. /// Gets or sets the profile.
  136. /// </summary>
  137. /// <value>The profile.</value>
  138. [ApiMember(Name = "Profile", Description = "Optional. Specify a specific h264 profile, e.g. main, baseline, high.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")]
  139. public string Profile { get; set; }
  140. /// <summary>
  141. /// Gets or sets the level.
  142. /// </summary>
  143. /// <value>The level.</value>
  144. [ApiMember(Name = "Level", Description = "Optional. Specify a level for the h264 profile, e.g. 3, 3.1.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")]
  145. public string Level { get; set; }
  146. [ApiMember(Name = "SubtitleDeliveryMethod", Description = "Optional. Specify the subtitle delivery method.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")]
  147. public SubtitleDeliveryMethod SubtitleMethod { get; set; }
  148. /// <summary>
  149. /// Gets a value indicating whether this instance has fixed resolution.
  150. /// </summary>
  151. /// <value><c>true</c> if this instance has fixed resolution; otherwise, <c>false</c>.</value>
  152. public bool HasFixedResolution
  153. {
  154. get
  155. {
  156. return Width.HasValue || Height.HasValue;
  157. }
  158. }
  159. [ApiMember(Name = "EnableAutoStreamCopy", Description = "Whether or not to allow automatic stream copy if requested values match the original source. Defaults to true.", IsRequired = false, DataType = "bool", ParameterType = "query", Verb = "GET")]
  160. public bool EnableAutoStreamCopy { get; set; }
  161. [ApiMember(Name = "CopyTimestamps", Description = "Whether or not to copy timestamps when transcoding with an offset. Defaults to false.", IsRequired = false, DataType = "bool", ParameterType = "query", Verb = "GET")]
  162. public bool CopyTimestamps { get; set; }
  163. public bool ForceLiveStream { get; set; }
  164. public bool EnableSubtitlesInManifest { get; set; }
  165. public VideoStreamRequest()
  166. {
  167. EnableAutoStreamCopy = true;
  168. }
  169. }
  170. }