mirror of
https://github.com/jellyfin/jellyfin.git
synced 2025-12-17 22:43:07 +03:00
move encoding methods to shared classes
This commit is contained in:
@@ -17,7 +17,7 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace MediaBrowser.MediaEncoding.Encoder
|
||||
{
|
||||
public class EncodingJob : IDisposable
|
||||
public class EncodingJob : EncodingJobInfo, IDisposable
|
||||
{
|
||||
public bool HasExited { get; internal set; }
|
||||
public bool IsCancelled { get; internal set; }
|
||||
@@ -25,46 +25,24 @@ namespace MediaBrowser.MediaEncoding.Encoder
|
||||
public Stream LogFileStream { get; set; }
|
||||
public IProgress<double> Progress { get; set; }
|
||||
public TaskCompletionSource<bool> TaskCompletionSource;
|
||||
public EncodingJobOptions Options { get; set; }
|
||||
public string InputContainer { get; set; }
|
||||
public MediaSourceInfo MediaSource { get; set; }
|
||||
public MediaStream AudioStream { get; set; }
|
||||
public MediaStream VideoStream { get; set; }
|
||||
public MediaStream SubtitleStream { get; set; }
|
||||
public IIsoMount IsoMount { get; set; }
|
||||
|
||||
public bool ReadInputAtNativeFramerate { get; set; }
|
||||
public bool IsVideoRequest { get; set; }
|
||||
public string InputAudioSync { get; set; }
|
||||
public string InputVideoSync { get; set; }
|
||||
public EncodingJobOptions Options
|
||||
{
|
||||
get { return (EncodingJobOptions) BaseRequest; }
|
||||
set { BaseRequest = value; }
|
||||
}
|
||||
|
||||
public string Id { get; set; }
|
||||
|
||||
public string MediaPath { get; set; }
|
||||
public MediaProtocol InputProtocol { get; set; }
|
||||
public bool IsInputVideo { get; set; }
|
||||
public VideoType VideoType { get; set; }
|
||||
public IsoType? IsoType { get; set; }
|
||||
public List<string> PlayableStreamFileNames { get; set; }
|
||||
|
||||
public List<string> SupportedAudioCodecs { get; set; }
|
||||
public Dictionary<string, string> RemoteHttpHeaders { get; set; }
|
||||
public TransportStreamTimestamp InputTimestamp { get; set; }
|
||||
|
||||
public bool DeInterlace { get; set; }
|
||||
public string MimeType { get; set; }
|
||||
public bool EstimateContentLength { get; set; }
|
||||
public bool EnableMpegtsM2TsMode { get; set; }
|
||||
public TranscodeSeekInfo TranscodeSeekInfo { get; set; }
|
||||
public long? EncodingDurationTicks { get; set; }
|
||||
public string LiveStreamId { get; set; }
|
||||
public long? RunTimeTicks;
|
||||
|
||||
public string ItemType { get; set; }
|
||||
|
||||
public long? InputBitrate { get; set; }
|
||||
public long? InputFileSize { get; set; }
|
||||
public string OutputAudioSync = "1";
|
||||
public string OutputVideoSync = "vfr";
|
||||
public string AlbumCoverPath { get; set; }
|
||||
|
||||
public string GetMimeType(string outputPath)
|
||||
@@ -80,17 +58,14 @@ namespace MediaBrowser.MediaEncoding.Encoder
|
||||
private readonly ILogger _logger;
|
||||
private readonly IMediaSourceManager _mediaSourceManager;
|
||||
|
||||
public EncodingJob(ILogger logger, IMediaSourceManager mediaSourceManager)
|
||||
public EncodingJob(ILogger logger, IMediaSourceManager mediaSourceManager) :
|
||||
base(logger)
|
||||
{
|
||||
_logger = logger;
|
||||
_mediaSourceManager = mediaSourceManager;
|
||||
Id = Guid.NewGuid().ToString("N");
|
||||
|
||||
RemoteHttpHeaders = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
|
||||
_logger = logger;
|
||||
SupportedAudioCodecs = new List<string>();
|
||||
PlayableStreamFileNames = new List<string>();
|
||||
RemoteHttpHeaders = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
|
||||
TaskCompletionSource = new TaskCompletionSource<bool>();
|
||||
}
|
||||
|
||||
@@ -118,23 +93,6 @@ namespace MediaBrowser.MediaEncoding.Encoder
|
||||
}
|
||||
}
|
||||
|
||||
private void DisposeIsoMount()
|
||||
{
|
||||
if (IsoMount != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
IsoMount.Dispose();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.ErrorException("Error disposing iso mount", ex);
|
||||
}
|
||||
|
||||
IsoMount = null;
|
||||
}
|
||||
}
|
||||
|
||||
private async void DisposeLiveStream()
|
||||
{
|
||||
if (MediaSource.RequiresClosing)
|
||||
@@ -150,15 +108,8 @@ namespace MediaBrowser.MediaEncoding.Encoder
|
||||
}
|
||||
}
|
||||
|
||||
public int InternalSubtitleStreamOffset { get; set; }
|
||||
|
||||
public string OutputFilePath { get; set; }
|
||||
public string OutputVideoCodec { get; set; }
|
||||
public string OutputAudioCodec { get; set; }
|
||||
public int? OutputAudioChannels;
|
||||
public int? OutputAudioSampleRate;
|
||||
public int? OutputAudioBitrate;
|
||||
public int? OutputVideoBitrate;
|
||||
|
||||
public string ActualOutputVideoCodec
|
||||
{
|
||||
@@ -313,25 +264,11 @@ namespace MediaBrowser.MediaEncoding.Encoder
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Predicts the audio sample rate that will be in the output stream
|
||||
/// </summary>
|
||||
public double? TargetVideoLevel
|
||||
{
|
||||
get
|
||||
{
|
||||
var stream = VideoStream;
|
||||
return Options.Level.HasValue && !Options.Static
|
||||
? Options.Level.Value
|
||||
: stream == null ? null : stream.Level;
|
||||
}
|
||||
}
|
||||
|
||||
public TransportStreamTimestamp TargetTimestamp
|
||||
{
|
||||
get
|
||||
{
|
||||
var defaultValue = string.Equals(Options.OutputContainer, "m2ts", StringComparison.OrdinalIgnoreCase) ?
|
||||
var defaultValue = string.Equals(OutputContainer, "m2ts", StringComparison.OrdinalIgnoreCase) ?
|
||||
TransportStreamTimestamp.Valid :
|
||||
TransportStreamTimestamp.None;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user