EncodingJobInfo.cs 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Globalization;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7. using MediaBrowser.Controller.Entities;
  8. using MediaBrowser.Controller.MediaEncoding;
  9. using MediaBrowser.Model.Dlna;
  10. using MediaBrowser.Model.Dto;
  11. using MediaBrowser.Model.Entities;
  12. using MediaBrowser.Model.IO;
  13. using MediaBrowser.Model.Logging;
  14. using MediaBrowser.Model.MediaInfo;
  15. namespace MediaBrowser.MediaEncoding.Encoder
  16. {
  17. // For now, a common base class until the API and MediaEncoding classes are unified
  18. public class EncodingJobInfo
  19. {
  20. private readonly ILogger _logger;
  21. public MediaStream VideoStream { get; set; }
  22. public VideoType VideoType { get; set; }
  23. public Dictionary<string, string> RemoteHttpHeaders { get; set; }
  24. public string OutputVideoCodec { get; set; }
  25. public MediaProtocol InputProtocol { get; set; }
  26. public string MediaPath { get; set; }
  27. public bool IsInputVideo { get; set; }
  28. public IIsoMount IsoMount { get; set; }
  29. public List<string> PlayableStreamFileNames { get; set; }
  30. public string OutputAudioCodec { get; set; }
  31. public int? OutputVideoBitrate { get; set; }
  32. public MediaStream SubtitleStream { get; set; }
  33. public SubtitleDeliveryMethod SubtitleDeliveryMethod { get; set; }
  34. public int InternalSubtitleStreamOffset { get; set; }
  35. public MediaSourceInfo MediaSource { get; set; }
  36. public User User { get; set; }
  37. public long? RunTimeTicks { get; set; }
  38. public bool ReadInputAtNativeFramerate { get; set; }
  39. public string OutputContainer { get; set; }
  40. public string OutputVideoSync = "-1";
  41. public string OutputAudioSync = "1";
  42. public string InputAudioSync { get; set; }
  43. public string InputVideoSync { get; set; }
  44. public TransportStreamTimestamp InputTimestamp { get; set; }
  45. public MediaStream AudioStream { get; set; }
  46. public List<string> SupportedAudioCodecs { get; set; }
  47. public List<string> SupportedVideoCodecs { get; set; }
  48. public string InputContainer { get; set; }
  49. public IsoType? IsoType { get; set; }
  50. public BaseEncodingJobOptions BaseRequest { get; set; }
  51. public long? StartTimeTicks
  52. {
  53. get { return BaseRequest.StartTimeTicks; }
  54. }
  55. public bool CopyTimestamps
  56. {
  57. get { return BaseRequest.CopyTimestamps; }
  58. }
  59. public int? OutputAudioChannels;
  60. public int? OutputAudioSampleRate;
  61. public bool DeInterlace { get; set; }
  62. public bool IsVideoRequest { get; set; }
  63. public EncodingJobInfo(ILogger logger)
  64. {
  65. _logger = logger;
  66. RemoteHttpHeaders = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
  67. PlayableStreamFileNames = new List<string>();
  68. SupportedVideoCodecs = new List<string>();
  69. SupportedVideoCodecs = new List<string>();
  70. }
  71. /// <summary>
  72. /// Predicts the audio sample rate that will be in the output stream
  73. /// </summary>
  74. public double? TargetVideoLevel
  75. {
  76. get
  77. {
  78. var stream = VideoStream;
  79. var request = BaseRequest;
  80. return !string.IsNullOrEmpty(request.Level) && !request.Static
  81. ? double.Parse(request.Level, CultureInfo.InvariantCulture)
  82. : stream == null ? null : stream.Level;
  83. }
  84. }
  85. protected void DisposeIsoMount()
  86. {
  87. if (IsoMount != null)
  88. {
  89. try
  90. {
  91. IsoMount.Dispose();
  92. }
  93. catch (Exception ex)
  94. {
  95. _logger.ErrorException("Error disposing iso mount", ex);
  96. }
  97. IsoMount = null;
  98. }
  99. }
  100. }
  101. }