EncodingJobInfo.cs 3.8 KB

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