StreamRequest.cs 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  1. using ServiceStack;
  2. namespace MediaBrowser.Api.Playback
  3. {
  4. /// <summary>
  5. /// Class StreamRequest
  6. /// </summary>
  7. public class StreamRequest
  8. {
  9. /// <summary>
  10. /// Gets or sets the id.
  11. /// </summary>
  12. /// <value>The id.</value>
  13. [ApiMember(Name = "Id", Description = "Item Id", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "GET")]
  14. public string Id { get; set; }
  15. [ApiMember(Name = "MediaSourceId", Description = "The media version id, if playing an alternate version", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "GET")]
  16. public string MediaSourceId { get; set; }
  17. [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")]
  18. public string DeviceId { get; set; }
  19. /// <summary>
  20. /// Gets or sets the audio codec.
  21. /// </summary>
  22. /// <value>The audio codec.</value>
  23. [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")]
  24. public string AudioCodec { get; set; }
  25. /// <summary>
  26. /// Gets or sets the start time ticks.
  27. /// </summary>
  28. /// <value>The start time ticks.</value>
  29. [ApiMember(Name = "StartTimeTicks", Description = "Optional. Specify a starting offset, in ticks. 1 tick = 10000 ms", IsRequired = false, DataType = "int", ParameterType = "query", Verb = "GET")]
  30. public long? StartTimeTicks { get; set; }
  31. /// <summary>
  32. /// Gets or sets the audio bit rate.
  33. /// </summary>
  34. /// <value>The audio bit rate.</value>
  35. [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")]
  36. public int? AudioBitRate { get; set; }
  37. /// <summary>
  38. /// Gets or sets the audio channels.
  39. /// </summary>
  40. /// <value>The audio channels.</value>
  41. [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")]
  42. public int? AudioChannels { get; set; }
  43. [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")]
  44. public int? MaxAudioChannels { get; set; }
  45. /// <summary>
  46. /// Gets or sets the audio sample rate.
  47. /// </summary>
  48. /// <value>The audio sample rate.</value>
  49. [ApiMember(Name = "AudioSampleRate", Description = "Optional. Specify a specific audio sample rate, e.g. 44100", IsRequired = false, DataType = "int", ParameterType = "query", Verb = "GET")]
  50. public int? AudioSampleRate { get; set; }
  51. /// <summary>
  52. /// Gets or sets a value indicating whether this <see cref="StreamRequest" /> is static.
  53. /// </summary>
  54. /// <value><c>true</c> if static; otherwise, <c>false</c>.</value>
  55. [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")]
  56. public bool Static { get; set; }
  57. /// <summary>
  58. /// For testing purposes
  59. /// </summary>
  60. public bool ThrowDebugError { get; set; }
  61. public string Params { get; set; }
  62. }
  63. public class VideoStreamRequest : StreamRequest
  64. {
  65. /// <summary>
  66. /// Gets or sets the video codec.
  67. /// </summary>
  68. /// <value>The video codec.</value>
  69. [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")]
  70. public string VideoCodec { get; set; }
  71. /// <summary>
  72. /// Gets or sets the video bit rate.
  73. /// </summary>
  74. /// <value>The video bit rate.</value>
  75. [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")]
  76. public int? VideoBitRate { get; set; }
  77. /// <summary>
  78. /// Gets or sets the index of the audio stream.
  79. /// </summary>
  80. /// <value>The index of the audio stream.</value>
  81. [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")]
  82. public int? AudioStreamIndex { get; set; }
  83. /// <summary>
  84. /// Gets or sets the index of the video stream.
  85. /// </summary>
  86. /// <value>The index of the video stream.</value>
  87. [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")]
  88. public int? VideoStreamIndex { get; set; }
  89. /// <summary>
  90. /// Gets or sets the index of the subtitle stream.
  91. /// </summary>
  92. /// <value>The index of the subtitle stream.</value>
  93. [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")]
  94. public int? SubtitleStreamIndex { get; set; }
  95. /// <summary>
  96. /// Gets or sets the width.
  97. /// </summary>
  98. /// <value>The width.</value>
  99. [ApiMember(Name = "Width", Description = "Optional. The fixed horizontal resolution of the encoded video.", IsRequired = false, DataType = "int", ParameterType = "query", Verb = "GET")]
  100. public int? Width { get; set; }
  101. /// <summary>
  102. /// Gets or sets the height.
  103. /// </summary>
  104. /// <value>The height.</value>
  105. [ApiMember(Name = "Height", Description = "Optional. The fixed vertical resolution of the encoded video.", IsRequired = false, DataType = "int", ParameterType = "query", Verb = "GET")]
  106. public int? Height { get; set; }
  107. /// <summary>
  108. /// Gets or sets the width of the max.
  109. /// </summary>
  110. /// <value>The width of the max.</value>
  111. [ApiMember(Name = "MaxWidth", Description = "Optional. The maximum horizontal resolution of the encoded video.", IsRequired = false, DataType = "int", ParameterType = "query", Verb = "GET")]
  112. public int? MaxWidth { get; set; }
  113. /// <summary>
  114. /// Gets or sets the height of the max.
  115. /// </summary>
  116. /// <value>The height of the max.</value>
  117. [ApiMember(Name = "MaxHeight", Description = "Optional. The maximum vertical resolution of the encoded video.", IsRequired = false, DataType = "int", ParameterType = "query", Verb = "GET")]
  118. public int? MaxHeight { get; set; }
  119. /// <summary>
  120. /// Gets or sets the framerate.
  121. /// </summary>
  122. /// <value>The framerate.</value>
  123. [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")]
  124. public double? Framerate { get; set; }
  125. /// <summary>
  126. /// Gets or sets the profile.
  127. /// </summary>
  128. /// <value>The profile.</value>
  129. [ApiMember(Name = "Profile", Description = "Optional. Specify a specific h264 profile, e.g. main, baseline, high.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")]
  130. public string Profile { get; set; }
  131. /// <summary>
  132. /// Gets or sets the level.
  133. /// </summary>
  134. /// <value>The level.</value>
  135. [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")]
  136. public string Level { get; set; }
  137. /// <summary>
  138. /// Gets a value indicating whether this instance has fixed resolution.
  139. /// </summary>
  140. /// <value><c>true</c> if this instance has fixed resolution; otherwise, <c>false</c>.</value>
  141. public bool HasFixedResolution
  142. {
  143. get
  144. {
  145. return Width.HasValue || Height.HasValue;
  146. }
  147. }
  148. }
  149. }