diff options
Diffstat (limited to 'MediaBrowser.Controller/MediaEncoding')
6 files changed, 118 insertions, 126 deletions
diff --git a/MediaBrowser.Controller/MediaEncoding/EncodingJobOptions.cs b/MediaBrowser.Controller/MediaEncoding/EncodingJobOptions.cs new file mode 100644 index 000000000..a988c2f97 --- /dev/null +++ b/MediaBrowser.Controller/MediaEncoding/EncodingJobOptions.cs @@ -0,0 +1,91 @@ +using MediaBrowser.Model.Dlna; + +namespace MediaBrowser.Controller.MediaEncoding +{ + public class EncodingJobOptions + { + public string OutputContainer { get; set; } + + public long? StartTimeTicks { get; set; } + public int? Width { get; set; } + public int? Height { get; set; } + public int? MaxWidth { get; set; } + public int? MaxHeight { get; set; } + public bool Static = false; + public float? Framerate { get; set; } + public float? MaxFramerate { get; set; } + public string Profile { get; set; } + public int? Level { get; set; } + + public string DeviceId { get; set; } + public string ItemId { get; set; } + public string MediaSourceId { get; set; } + public string AudioCodec { get; set; } + + public bool EnableAutoStreamCopy { get; set; } + + public int? MaxAudioChannels { get; set; } + public int? AudioChannels { get; set; } + public int? AudioBitRate { get; set; } + public int? AudioSampleRate { get; set; } + + public DeviceProfile DeviceProfile { get; set; } + public EncodingContext Context { get; set; } + + public string VideoCodec { get; set; } + + public int? VideoBitRate { get; set; } + public int? AudioStreamIndex { get; set; } + public int? VideoStreamIndex { get; set; } + public int? SubtitleStreamIndex { get; set; } + public int? MaxRefFrames { get; set; } + public int? MaxVideoBitDepth { get; set; } + public SubtitleDeliveryMethod SubtitleMethod { get; set; } + + /// <summary> + /// Gets a value indicating whether this instance has fixed resolution. + /// </summary> + /// <value><c>true</c> if this instance has fixed resolution; otherwise, <c>false</c>.</value> + public bool HasFixedResolution + { + get + { + return Width.HasValue || Height.HasValue; + } + } + + public bool? Cabac { get; set; } + + public EncodingJobOptions() + { + + } + + public EncodingJobOptions(StreamInfo info, DeviceProfile deviceProfile) + { + OutputContainer = info.Container; + StartTimeTicks = info.StartPositionTicks; + MaxWidth = info.MaxWidth; + MaxHeight = info.MaxHeight; + MaxFramerate = info.MaxFramerate; + Profile = info.VideoProfile; + Level = info.VideoLevel; + ItemId = info.ItemId; + MediaSourceId = info.MediaSourceId; + AudioCodec = info.AudioCodec; + MaxAudioChannels = info.MaxAudioChannels; + AudioBitRate = info.AudioBitrate; + AudioSampleRate = info.TargetAudioSampleRate; + DeviceProfile = deviceProfile; + VideoCodec = info.VideoCodec; + VideoBitRate = info.VideoBitrate; + AudioStreamIndex = info.AudioStreamIndex; + SubtitleStreamIndex = info.SubtitleStreamIndex; + MaxRefFrames = info.MaxRefFrames; + MaxVideoBitDepth = info.MaxVideoBitDepth; + SubtitleMethod = info.SubtitleDeliveryMethod; + Cabac = info.Cabac; + Context = info.Context; + } + } +} diff --git a/MediaBrowser.Controller/MediaEncoding/EncodingOptions.cs b/MediaBrowser.Controller/MediaEncoding/EncodingOptions.cs deleted file mode 100644 index 26182ebc4..000000000 --- a/MediaBrowser.Controller/MediaEncoding/EncodingOptions.cs +++ /dev/null @@ -1,80 +0,0 @@ -using MediaBrowser.Controller.Dlna; -using MediaBrowser.Model.Dlna; - -namespace MediaBrowser.Controller.MediaEncoding -{ - public class EncodingOptions - { - /// <summary> - /// Gets or sets the item identifier. - /// </summary> - /// <value>The item identifier.</value> - public string ItemId { get; set; } - - /// <summary> - /// Gets or sets the media source identifier. - /// </summary> - /// <value>The media source identifier.</value> - public string MediaSourceId { get; set; } - - /// <summary> - /// Gets or sets the device profile. - /// </summary> - /// <value>The device profile.</value> - public DeviceProfile DeviceProfile { get; set; } - - /// <summary> - /// Gets or sets the output path. - /// </summary> - /// <value>The output path.</value> - public string OutputPath { get; set; } - - /// <summary> - /// Gets or sets the container. - /// </summary> - /// <value>The container.</value> - public string Container { get; set; } - - /// <summary> - /// Gets or sets the audio codec. - /// </summary> - /// <value>The audio codec.</value> - public string AudioCodec { get; set; } - - /// <summary> - /// Gets or sets the start time ticks. - /// </summary> - /// <value>The start time ticks.</value> - public long? StartTimeTicks { get; set; } - - /// <summary> - /// Gets or sets the maximum channels. - /// </summary> - /// <value>The maximum channels.</value> - public int? MaxAudioChannels { get; set; } - - /// <summary> - /// Gets or sets the channels. - /// </summary> - /// <value>The channels.</value> - public int? AudioChannels { get; set; } - - /// <summary> - /// Gets or sets the sample rate. - /// </summary> - /// <value>The sample rate.</value> - public int? AudioSampleRate { get; set; } - - /// <summary> - /// Gets or sets the bit rate. - /// </summary> - /// <value>The bit rate.</value> - public int? AudioBitRate { get; set; } - - /// <summary> - /// Gets or sets the maximum audio bit rate. - /// </summary> - /// <value>The maximum audio bit rate.</value> - public int? MaxAudioBitRate { get; set; } - } -} diff --git a/MediaBrowser.Controller/MediaEncoding/EncodingResult.cs b/MediaBrowser.Controller/MediaEncoding/EncodingResult.cs deleted file mode 100644 index 75ee90e42..000000000 --- a/MediaBrowser.Controller/MediaEncoding/EncodingResult.cs +++ /dev/null @@ -1,13 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace MediaBrowser.Controller.MediaEncoding -{ - public class EncodingResult - { - public string OutputPath { get; set; } - } -} diff --git a/MediaBrowser.Controller/MediaEncoding/IMediaEncoder.cs b/MediaBrowser.Controller/MediaEncoding/IMediaEncoder.cs index 38c2c83c4..47544f972 100644 --- a/MediaBrowser.Controller/MediaEncoding/IMediaEncoder.cs +++ b/MediaBrowser.Controller/MediaEncoding/IMediaEncoder.cs @@ -96,5 +96,27 @@ namespace MediaBrowser.Controller.MediaEncoding /// <param name="ticks">The ticks.</param> /// <returns>System.String.</returns> string GetTimeParameter(long ticks); + + /// <summary> + /// Encodes the audio. + /// </summary> + /// <param name="options">The options.</param> + /// <param name="progress">The progress.</param> + /// <param name="cancellationToken">The cancellation token.</param> + /// <returns>Task.</returns> + Task<string> EncodeAudio(EncodingJobOptions options, + IProgress<double> progress, + CancellationToken cancellationToken); + + /// <summary> + /// Encodes the video. + /// </summary> + /// <param name="options">The options.</param> + /// <param name="progress">The progress.</param> + /// <param name="cancellationToken">The cancellation token.</param> + /// <returns>Task<System.String>.</returns> + Task<string> EncodeVideo(EncodingJobOptions options, + IProgress<double> progress, + CancellationToken cancellationToken); } } diff --git a/MediaBrowser.Controller/MediaEncoding/MediaStreamSelector.cs b/MediaBrowser.Controller/MediaEncoding/MediaStreamSelector.cs index 58a68c257..4a807df7a 100644 --- a/MediaBrowser.Controller/MediaEncoding/MediaStreamSelector.cs +++ b/MediaBrowser.Controller/MediaEncoding/MediaStreamSelector.cs @@ -34,15 +34,13 @@ namespace MediaBrowser.Controller.MediaEncoding } public static int? GetDefaultSubtitleStreamIndex(List<MediaStream> streams, - IEnumerable<string> preferredLanguages, + List<string> preferredLanguages, SubtitlePlaybackMode mode, string audioTrackLanguage) { - var languages = preferredLanguages.ToList(); - streams = GetSortedStreams(streams, MediaStreamType.Subtitle, languages).ToList(); + streams = GetSortedStreams(streams, MediaStreamType.Subtitle, preferredLanguages).ToList(); var full = streams.Where(s => !s.IsForced); - var forced = streams.Where(s => s.IsForced && string.Equals(s.Language, audioTrackLanguage, StringComparison.OrdinalIgnoreCase)); MediaStream stream = null; @@ -54,9 +52,9 @@ namespace MediaBrowser.Controller.MediaEncoding if (mode == SubtitlePlaybackMode.Default) { // if the audio language is not understood by the user, load their preferred subs, if there are any - if (!ContainsOrdinal(languages, audioTrackLanguage)) + if (!ContainsOrdinal(preferredLanguages, audioTrackLanguage)) { - stream = full.FirstOrDefault(s => ContainsOrdinal(languages, s.Language)); + stream = full.FirstOrDefault(s => ContainsOrdinal(preferredLanguages, s.Language)); } } else if (mode == SubtitlePlaybackMode.Always) @@ -66,7 +64,7 @@ namespace MediaBrowser.Controller.MediaEncoding } // load forced subs if we have found no suitable full subtitles - stream = stream ?? forced.FirstOrDefault(); + stream = stream ?? streams.FirstOrDefault(s => s.IsForced && string.Equals(s.Language, audioTrackLanguage, StringComparison.OrdinalIgnoreCase)); if (stream != null) { diff --git a/MediaBrowser.Controller/MediaEncoding/VideoEncodingOptions.cs b/MediaBrowser.Controller/MediaEncoding/VideoEncodingOptions.cs deleted file mode 100644 index 773f0ea46..000000000 --- a/MediaBrowser.Controller/MediaEncoding/VideoEncodingOptions.cs +++ /dev/null @@ -1,26 +0,0 @@ - -namespace MediaBrowser.Controller.MediaEncoding -{ - public class VideoEncodingOptions : EncodingOptions - { - public string VideoCodec { get; set; } - - public string VideoProfile { get; set; } - - public double? VideoLevel { get; set; } - - public int? VideoStreamIndex { get; set; } - - public int? AudioStreamIndex { get; set; } - - public int? SubtitleStreamIndex { get; set; } - - public int? MaxWidth { get; set; } - - public int? MaxHeight { get; set; } - - public int? Height { get; set; } - - public int? Width { get; set; } - } -} |
