diff options
Diffstat (limited to 'MediaBrowser.Controller/MediaEncoding/EncodingJobInfo.cs')
| -rw-r--r-- | MediaBrowser.Controller/MediaEncoding/EncodingJobInfo.cs | 172 |
1 files changed, 73 insertions, 99 deletions
diff --git a/MediaBrowser.Controller/MediaEncoding/EncodingJobInfo.cs b/MediaBrowser.Controller/MediaEncoding/EncodingJobInfo.cs index 3f6da59d8..6651a6d70 100644 --- a/MediaBrowser.Controller/MediaEncoding/EncodingJobInfo.cs +++ b/MediaBrowser.Controller/MediaEncoding/EncodingJobInfo.cs @@ -1,24 +1,27 @@ -using System; +using System; using System.Collections.Generic; using System.Globalization; using System.Linq; using MediaBrowser.Controller.Entities; -using MediaBrowser.Controller.Library; using MediaBrowser.Model.Dlna; +using MediaBrowser.Model.Drawing; using MediaBrowser.Model.Dto; using MediaBrowser.Model.Entities; using MediaBrowser.Model.IO; using MediaBrowser.Model.MediaInfo; -using MediaBrowser.Model.Drawing; using MediaBrowser.Model.Session; using Microsoft.Extensions.Logging; +using System.IO; +using MediaBrowser.Model.Net; +using MediaBrowser.Controller.Library; +using System.Threading.Tasks; namespace MediaBrowser.Controller.MediaEncoding { // For now, a common base class until the API and MediaEncoding classes are unified - public abstract class EncodingJobInfo + public class EncodingJobInfo { - private readonly ILogger _logger; + protected readonly IMediaSourceManager MediaSourceManager; public MediaStream VideoStream { get; set; } public VideoType VideoType { get; set; } @@ -43,6 +46,21 @@ namespace MediaBrowser.Controller.MediaEncoding public bool ReadInputAtNativeFramerate { get; set; } + public string OutputFilePath { get; set; } + + public string MimeType { get; set; } + public long? EncodingDurationTicks { get; set; } + + public string GetMimeType(string outputPath, bool enableStreamDefault = true) + { + if (!string.IsNullOrEmpty(MimeType)) + { + return MimeType; + } + + return MimeTypes.GetMimeType(outputPath, enableStreamDefault); + } + private TranscodeReason[] _transcodeReasons = null; public TranscodeReason[] TranscodeReasons { @@ -61,53 +79,17 @@ namespace MediaBrowser.Controller.MediaEncoding } } - public bool IgnoreInputDts - { - get - { - return MediaSource.IgnoreDts; - } - } + public bool IgnoreInputDts => MediaSource.IgnoreDts; - public bool IgnoreInputIndex - { - get - { - return MediaSource.IgnoreIndex; - } - } + public bool IgnoreInputIndex => MediaSource.IgnoreIndex; - public bool GenPtsInput - { - get - { - return MediaSource.GenPtsInput; - } - } + public bool GenPtsInput => MediaSource.GenPtsInput; - public bool DiscardCorruptFramesInput - { - get - { - return false; - } - } + public bool DiscardCorruptFramesInput => false; - public bool EnableFastSeekInput - { - get - { - return false; - } - } + public bool EnableFastSeekInput => false; - public bool GenPtsOutput - { - get - { - return false; - } - } + public bool GenPtsOutput => false; public string OutputContainer { get; set; } @@ -142,15 +124,9 @@ namespace MediaBrowser.Controller.MediaEncoding public BaseEncodingJobOptions BaseRequest { get; set; } - public long? StartTimeTicks - { - get { return BaseRequest.StartTimeTicks; } - } + public long? StartTimeTicks => BaseRequest.StartTimeTicks; - public bool CopyTimestamps - { - get { return BaseRequest.CopyTimestamps; } - } + public bool CopyTimestamps => BaseRequest.CopyTimestamps; public int? OutputAudioBitrate; public int? OutputAudioChannels; @@ -235,8 +211,7 @@ namespace MediaBrowser.Controller.MediaEncoding if (!string.IsNullOrEmpty(codec)) { var value = BaseRequest.GetOption(codec, "maxrefframes"); - int result; - if (!string.IsNullOrEmpty(value) && int.TryParse(value, NumberStyles.Any, CultureInfo.InvariantCulture, out result)) + if (!string.IsNullOrEmpty(value) && int.TryParse(value, NumberStyles.Any, CultureInfo.InvariantCulture, out var result)) { return result; } @@ -255,8 +230,7 @@ namespace MediaBrowser.Controller.MediaEncoding if (!string.IsNullOrEmpty(codec)) { var value = BaseRequest.GetOption(codec, "videobitdepth"); - int result; - if (!string.IsNullOrEmpty(value) && int.TryParse(value, NumberStyles.Any, CultureInfo.InvariantCulture, out result)) + if (!string.IsNullOrEmpty(value) && int.TryParse(value, NumberStyles.Any, CultureInfo.InvariantCulture, out var result)) { return result; } @@ -275,8 +249,7 @@ namespace MediaBrowser.Controller.MediaEncoding if (!string.IsNullOrEmpty(codec)) { var value = BaseRequest.GetOption(codec, "audiobitdepth"); - int result; - if (!string.IsNullOrEmpty(value) && int.TryParse(value, NumberStyles.Any, CultureInfo.InvariantCulture, out result)) + if (!string.IsNullOrEmpty(value) && int.TryParse(value, NumberStyles.Any, CultureInfo.InvariantCulture, out var result)) { return result; } @@ -299,8 +272,7 @@ namespace MediaBrowser.Controller.MediaEncoding if (!string.IsNullOrEmpty(codec)) { var value = BaseRequest.GetOption(codec, "audiochannels"); - int result; - if (!string.IsNullOrEmpty(value) && int.TryParse(value, NumberStyles.Any, CultureInfo.InvariantCulture, out result)) + if (!string.IsNullOrEmpty(value) && int.TryParse(value, NumberStyles.Any, CultureInfo.InvariantCulture, out var result)) { return result; } @@ -312,9 +284,8 @@ namespace MediaBrowser.Controller.MediaEncoding public bool IsVideoRequest { get; set; } public TranscodingJobType TranscodingType { get; set; } - public EncodingJobInfo(ILogger logger, IMediaSourceManager unused, TranscodingJobType jobType) + public EncodingJobInfo(TranscodingJobType jobType) { - _logger = logger; TranscodingType = jobType; RemoteHttpHeaders = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase); PlayableStreamFileNames = Array.Empty<string>(); @@ -323,13 +294,7 @@ namespace MediaBrowser.Controller.MediaEncoding SupportedSubtitleCodecs = Array.Empty<string>(); } - public bool IsSegmentedLiveStream - { - get - { - return TranscodingType != TranscodingJobType.Progressive && !RunTimeTicks.HasValue; - } - } + public bool IsSegmentedLiveStream => TranscodingType != TranscodingJobType.Progressive && !RunTimeTicks.HasValue; public bool EnableBreakOnNonKeyFrames(string videoCodec) { @@ -346,13 +311,7 @@ namespace MediaBrowser.Controller.MediaEncoding return false; } - public int? TotalOutputBitrate - { - get - { - return (OutputAudioBitrate ?? 0) + (OutputVideoBitrate ?? 0); - } - } + public int? TotalOutputBitrate => (OutputAudioBitrate ?? 0) + (OutputVideoBitrate ?? 0); public int? OutputWidth { @@ -473,8 +432,7 @@ namespace MediaBrowser.Controller.MediaEncoding } var level = GetRequestedLevel(ActualOutputVideoCodec); - double result; - if (!string.IsNullOrEmpty(level) && double.TryParse(level, NumberStyles.Any, CultureInfo.InvariantCulture, out result)) + if (!string.IsNullOrEmpty(level) && double.TryParse(level, NumberStyles.Any, CultureInfo.InvariantCulture, out var result)) { return result; } @@ -661,6 +619,28 @@ namespace MediaBrowser.Controller.MediaEncoding } } + public string ActualOutputAudioCodec + { + get + { + var codec = OutputAudioCodec; + + if (string.Equals(codec, "copy", StringComparison.OrdinalIgnoreCase)) + { + var stream = AudioStream; + + if (stream != null) + { + return stream.Codec; + } + + return null; + } + + return codec; + } + } + public bool? IsTargetInterlaced { get @@ -716,6 +696,14 @@ namespace MediaBrowser.Controller.MediaEncoding } } + public int HlsListSize + { + get + { + return 0; + } + } + private int? GetMediaStreamCount(MediaStreamType type, int limit) { var count = MediaSource.GetStreamCount(type); @@ -727,29 +715,15 @@ namespace MediaBrowser.Controller.MediaEncoding return count; } - protected void DisposeIsoMount() - { - if (IsoMount != null) - { - try - { - IsoMount.Dispose(); - } - catch (Exception ex) - { - _logger.LogError(ex, "Error disposing iso mount"); - } - - IsoMount = null; - } - } public IProgress<double> Progress { get; set; } - public virtual void ReportTranscodingProgress(TimeSpan? transcodingPosition, float framerate, double? percentComplete, long bytesTranscoded, int? bitRate) { + public virtual void ReportTranscodingProgress(TimeSpan? transcodingPosition, float framerate, double? percentComplete, long bytesTranscoded, int? bitRate) + { Progress.Report(percentComplete.Value); } - public virtual void Dispose () { + public virtual void Dispose() + { } } |
