EncodingJobOptions.cs 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  1. #nullable disable
  2. #pragma warning disable CS1591
  3. using System;
  4. using System.Collections.Generic;
  5. using MediaBrowser.Model.Dlna;
  6. namespace MediaBrowser.Controller.MediaEncoding
  7. {
  8. // For now until api and media encoding layers are unified
  9. public class BaseEncodingJobOptions
  10. {
  11. /// <summary>
  12. /// Gets or sets the id.
  13. /// </summary>
  14. /// <value>The id.</value>
  15. public Guid Id { get; set; }
  16. public string MediaSourceId { get; set; }
  17. public string DeviceId { get; set; }
  18. public string Container { get; set; }
  19. /// <summary>
  20. /// Gets or sets the audio codec.
  21. /// </summary>
  22. /// <value>The audio codec.</value>
  23. public string AudioCodec { get; set; }
  24. public bool EnableAutoStreamCopy { get; set; }
  25. public bool AllowVideoStreamCopy { get; set; }
  26. public bool AllowAudioStreamCopy { get; set; }
  27. public bool BreakOnNonKeyFrames { get; set; }
  28. /// <summary>
  29. /// Gets or sets the audio sample rate.
  30. /// </summary>
  31. /// <value>The audio sample rate.</value>
  32. public int? AudioSampleRate { get; set; }
  33. public int? MaxAudioBitDepth { get; set; }
  34. /// <summary>
  35. /// Gets or sets the audio bit rate.
  36. /// </summary>
  37. /// <value>The audio bit rate.</value>
  38. public int? AudioBitRate { get; set; }
  39. /// <summary>
  40. /// Gets or sets the audio channels.
  41. /// </summary>
  42. /// <value>The audio channels.</value>
  43. public int? AudioChannels { get; set; }
  44. public int? MaxAudioChannels { get; set; }
  45. public bool Static { get; set; }
  46. /// <summary>
  47. /// Gets or sets the profile.
  48. /// </summary>
  49. /// <value>The profile.</value>
  50. public string Profile { get; set; }
  51. /// <summary>
  52. /// Gets or sets the level.
  53. /// </summary>
  54. /// <value>The level.</value>
  55. public string Level { get; set; }
  56. /// <summary>
  57. /// Gets or sets the framerate.
  58. /// </summary>
  59. /// <value>The framerate.</value>
  60. public float? Framerate { get; set; }
  61. public float? MaxFramerate { get; set; }
  62. public bool CopyTimestamps { get; set; }
  63. /// <summary>
  64. /// Gets or sets the start time ticks.
  65. /// </summary>
  66. /// <value>The start time ticks.</value>
  67. public long? StartTimeTicks { get; set; }
  68. /// <summary>
  69. /// Gets or sets the width.
  70. /// </summary>
  71. /// <value>The width.</value>
  72. public int? Width { get; set; }
  73. /// <summary>
  74. /// Gets or sets the height.
  75. /// </summary>
  76. /// <value>The height.</value>
  77. public int? Height { get; set; }
  78. /// <summary>
  79. /// Gets or sets the width of the max.
  80. /// </summary>
  81. /// <value>The width of the max.</value>
  82. public int? MaxWidth { get; set; }
  83. /// <summary>
  84. /// Gets or sets the height of the max.
  85. /// </summary>
  86. /// <value>The height of the max.</value>
  87. public int? MaxHeight { get; set; }
  88. /// <summary>
  89. /// Gets or sets the video bit rate.
  90. /// </summary>
  91. /// <value>The video bit rate.</value>
  92. public int? VideoBitRate { get; set; }
  93. /// <summary>
  94. /// Gets or sets the index of the subtitle stream.
  95. /// </summary>
  96. /// <value>The index of the subtitle stream.</value>
  97. public int? SubtitleStreamIndex { get; set; }
  98. public SubtitleDeliveryMethod SubtitleMethod { get; set; }
  99. public int? MaxRefFrames { get; set; }
  100. public int? MaxVideoBitDepth { get; set; }
  101. public bool RequireAvc { get; set; }
  102. public bool DeInterlace { get; set; }
  103. public bool RequireNonAnamorphic { get; set; }
  104. public int? TranscodingMaxAudioChannels { get; set; }
  105. public int? CpuCoreLimit { get; set; }
  106. public string LiveStreamId { get; set; }
  107. public bool EnableMpegtsM2TsMode { get; set; }
  108. /// <summary>
  109. /// Gets or sets the video codec.
  110. /// </summary>
  111. /// <value>The video codec.</value>
  112. public string VideoCodec { get; set; }
  113. public string SubtitleCodec { get; set; }
  114. public string TranscodeReasons { get; set; }
  115. /// <summary>
  116. /// Gets or sets the index of the audio stream.
  117. /// </summary>
  118. /// <value>The index of the audio stream.</value>
  119. public int? AudioStreamIndex { get; set; }
  120. /// <summary>
  121. /// Gets or sets the index of the video stream.
  122. /// </summary>
  123. /// <value>The index of the video stream.</value>
  124. public int? VideoStreamIndex { get; set; }
  125. public EncodingContext Context { get; set; }
  126. public Dictionary<string, string> StreamOptions { get; set; }
  127. public string GetOption(string qualifier, string name)
  128. {
  129. var value = GetOption(qualifier + "-" + name);
  130. if (string.IsNullOrEmpty(value))
  131. {
  132. value = GetOption(name);
  133. }
  134. return value;
  135. }
  136. public string GetOption(string name)
  137. {
  138. if (StreamOptions.TryGetValue(name, out var value))
  139. {
  140. return value;
  141. }
  142. return null;
  143. }
  144. public BaseEncodingJobOptions()
  145. {
  146. EnableAutoStreamCopy = true;
  147. AllowVideoStreamCopy = true;
  148. AllowAudioStreamCopy = true;
  149. Context = EncodingContext.Streaming;
  150. StreamOptions = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
  151. }
  152. }
  153. }