#pragma warning disable CS1591 using System; using System.Collections.Generic; using System.Linq; using MediaBrowser.Model.Dlna; namespace MediaBrowser.Controller.MediaEncoding { public class EncodingJobOptions : BaseEncodingJobOptions { public string OutputDirectory { get; set; } public string ItemId { get; set; } public string TempDirectory { get; set; } public bool ReadInputAtNativeFramerate { get; set; } /// /// Gets a value indicating whether this instance has fixed resolution. /// /// true if this instance has fixed resolution; otherwise, false. public bool HasFixedResolution => Width.HasValue || Height.HasValue; public DeviceProfile DeviceProfile { get; set; } public EncodingJobOptions(StreamInfo info, DeviceProfile deviceProfile) { Container = info.Container; StartTimeTicks = info.StartPositionTicks; MaxWidth = info.MaxWidth; MaxHeight = info.MaxHeight; MaxFramerate = info.MaxFramerate; Id = info.ItemId; MediaSourceId = info.MediaSourceId; AudioCodec = info.TargetAudioCodec.FirstOrDefault(); MaxAudioChannels = info.GlobalMaxAudioChannels; AudioBitRate = info.AudioBitrate; AudioSampleRate = info.TargetAudioSampleRate; DeviceProfile = deviceProfile; VideoCodec = info.TargetVideoCodec.FirstOrDefault(); VideoBitRate = info.VideoBitrate; AudioStreamIndex = info.AudioStreamIndex; SubtitleMethod = info.SubtitleDeliveryMethod; Context = info.Context; TranscodingMaxAudioChannels = info.TranscodingMaxAudioChannels; if (info.SubtitleDeliveryMethod != SubtitleDeliveryMethod.External) { SubtitleStreamIndex = info.SubtitleStreamIndex; } StreamOptions = info.StreamOptions; } } // For now until api and media encoding layers are unified public class BaseEncodingJobOptions { /// /// Gets or sets the id. /// /// The id. public Guid Id { get; set; } public string MediaSourceId { get; set; } public string DeviceId { get; set; } public string Container { get; set; } /// /// Gets or sets the audio codec. /// /// The audio codec. public string AudioCodec { get; set; } public bool EnableAutoStreamCopy { get; set; } public bool AllowVideoStreamCopy { get; set; } public bool AllowAudioStreamCopy { get; set; } public bool BreakOnNonKeyFrames { get; set; } /// /// Gets or sets the audio sample rate. /// /// The audio sample rate. public int? AudioSampleRate { get; set; } public int? MaxAudioBitDepth { get; set; } /// /// Gets or sets the audio bit rate. /// /// The audio bit rate. public int? AudioBitRate { get; set; } /// /// Gets or sets the audio channels. /// /// The audio channels. public int? AudioChannels { get; set; } public int? MaxAudioChannels { get; set; } public bool Static { get; set; } /// /// Gets or sets the profile. /// /// The profile. public string Profile { get; set; } /// /// Gets or sets the level. /// /// The level. public string Level { get; set; } /// /// Gets or sets the framerate. /// /// The framerate. public float? Framerate { get; set; } public float? MaxFramerate { get; set; } public bool CopyTimestamps { get; set; } /// /// Gets or sets the start time ticks. /// /// The start time ticks. public long? StartTimeTicks { get; set; } /// /// Gets or sets the width. /// /// The width. public int? Width { get; set; } /// /// Gets or sets the height. /// /// The height. public int? Height { get; set; } /// /// Gets or sets the width of the max. /// /// The width of the max. public int? MaxWidth { get; set; } /// /// Gets or sets the height of the max. /// /// The height of the max. public int? MaxHeight { get; set; } /// /// Gets or sets the video bit rate. /// /// The video bit rate. public int? VideoBitRate { get; set; } /// /// Gets or sets the index of the subtitle stream. /// /// The index of the subtitle stream. public int? SubtitleStreamIndex { get; set; } public SubtitleDeliveryMethod SubtitleMethod { get; set; } public int? MaxRefFrames { get; set; } public int? MaxVideoBitDepth { get; set; } public bool RequireAvc { get; set; } public bool DeInterlace { get; set; } public bool RequireNonAnamorphic { get; set; } public int? TranscodingMaxAudioChannels { get; set; } public int? CpuCoreLimit { get; set; } public string LiveStreamId { get; set; } public bool EnableMpegtsM2TsMode { get; set; } /// /// Gets or sets the video codec. /// /// The video codec. public string VideoCodec { get; set; } public string SubtitleCodec { get; set; } public string TranscodeReasons { get; set; } /// /// Gets or sets the index of the audio stream. /// /// The index of the audio stream. public int? AudioStreamIndex { get; set; } /// /// Gets or sets the index of the video stream. /// /// The index of the video stream. public int? VideoStreamIndex { get; set; } public EncodingContext Context { get; set; } public Dictionary StreamOptions { get; set; } public string GetOption(string qualifier, string name) { var value = GetOption(qualifier + "-" + name); if (string.IsNullOrEmpty(value)) { value = GetOption(name); } return value; } public string GetOption(string name) { if (StreamOptions.TryGetValue(name, out var value)) { return value; } return null; } public BaseEncodingJobOptions() { EnableAutoStreamCopy = true; AllowVideoStreamCopy = true; AllowAudioStreamCopy = true; Context = EncodingContext.Streaming; StreamOptions = new Dictionary(StringComparer.OrdinalIgnoreCase); } } }