diff options
Diffstat (limited to 'MediaBrowser.Api')
| -rw-r--r-- | MediaBrowser.Api/MediaBrowser.Api.csproj | 4 | ||||
| -rw-r--r-- | MediaBrowser.Api/Playback/Hls/BaseHlsService.cs | 14 | ||||
| -rw-r--r-- | MediaBrowser.Api/Playback/Hls/DynamicHlsService.cs | 27 | ||||
| -rw-r--r-- | MediaBrowser.Api/Playback/Hls/VideoHlsService.cs | 15 | ||||
| -rw-r--r-- | MediaBrowser.Api/Playback/Progressive/AudioService.cs | 8 | ||||
| -rw-r--r-- | MediaBrowser.Api/Playback/Progressive/VideoService.cs | 25 | ||||
| -rw-r--r-- | MediaBrowser.Api/Playback/StreamRequest.cs | 153 | ||||
| -rw-r--r-- | MediaBrowser.Api/Playback/StreamState.cs | 107 |
8 files changed, 72 insertions, 281 deletions
diff --git a/MediaBrowser.Api/MediaBrowser.Api.csproj b/MediaBrowser.Api/MediaBrowser.Api.csproj index c1a7347b5..7be04d892 100644 --- a/MediaBrowser.Api/MediaBrowser.Api.csproj +++ b/MediaBrowser.Api/MediaBrowser.Api.csproj @@ -172,6 +172,10 @@ <Project>{17E1F4E6-8ABD-4FE5-9ECF-43D4B6087BA2}</Project> <Name>MediaBrowser.Controller</Name> </ProjectReference> + <ProjectReference Include="..\MediaBrowser.MediaEncoding\MediaBrowser.MediaEncoding.csproj"> + <Project>{0bd82fa6-eb8a-4452-8af5-74f9c3849451}</Project> + <Name>MediaBrowser.MediaEncoding</Name> + </ProjectReference> <ProjectReference Include="..\MediaBrowser.Model\MediaBrowser.Model.csproj"> <Project>{7EEEB4BB-F3E8-48FC-B4C5-70F0FFF8329B}</Project> <Name>MediaBrowser.Model</Name> diff --git a/MediaBrowser.Api/Playback/Hls/BaseHlsService.cs b/MediaBrowser.Api/Playback/Hls/BaseHlsService.cs index 41b58a611..cd6b9b625 100644 --- a/MediaBrowser.Api/Playback/Hls/BaseHlsService.cs +++ b/MediaBrowser.Api/Playback/Hls/BaseHlsService.cs @@ -237,13 +237,15 @@ namespace MediaBrowser.Api.Playback.Hls protected override string GetCommandLineArguments(string outputPath, StreamState state, bool isEncoding) { + var encodingOptions = ApiEntryPoint.Instance.GetEncodingOptions(); + var itsOffsetMs = 0; var itsOffset = itsOffsetMs == 0 ? string.Empty : string.Format("-itsoffset {0} ", TimeSpan.FromMilliseconds(itsOffsetMs).TotalSeconds.ToString(UsCulture)); - var threads = GetNumberOfThreads(state, false); + var threads = EncodingHelper.GetNumberOfThreads(state, encodingOptions, false); - var inputModifier = GetInputModifier(state, true); + var inputModifier = EncodingHelper.GetInputModifier(state, encodingOptions); // If isEncoding is true we're actually starting ffmpeg var startNumberParam = isEncoding ? GetStartNumber(state).ToString(UsCulture) : "0"; @@ -265,9 +267,9 @@ namespace MediaBrowser.Api.Playback.Hls return string.Format("{0} {1} -map_metadata -1 -map_chapters -1 -threads {2} {3} {4} {5} -f segment -max_delay 5000000 -avoid_negative_ts disabled -start_at_zero -segment_time {6} {10} -individual_header_trailer 0 -segment_format mpegts -segment_list_type m3u8 -segment_start_number {7} -segment_list \"{8}\" -y \"{9}\"", inputModifier, - GetInputArgument(state), + EncodingHelper.GetInputArgument(state, encodingOptions), threads, - GetMapArgs(state), + EncodingHelper.GetMapArgs(state), GetVideoArguments(state), GetAudioArguments(state), state.SegmentLength.ToString(UsCulture), @@ -284,9 +286,9 @@ namespace MediaBrowser.Api.Playback.Hls var args = string.Format("{0} {1} {2} -map_metadata -1 -map_chapters -1 -threads {3} {4} {5} -max_delay 5000000 -avoid_negative_ts disabled -start_at_zero {6} -hls_time {7} -individual_header_trailer 0 -start_number {8} -hls_list_size {9}{10} -y \"{11}\"", itsOffset, inputModifier, - GetInputArgument(state), + EncodingHelper.GetInputArgument(state, encodingOptions), threads, - GetMapArgs(state), + EncodingHelper.GetMapArgs(state), GetVideoArguments(state), GetAudioArguments(state), state.SegmentLength.ToString(UsCulture), diff --git a/MediaBrowser.Api/Playback/Hls/DynamicHlsService.cs b/MediaBrowser.Api/Playback/Hls/DynamicHlsService.cs index e922094ad..cfd7471c4 100644 --- a/MediaBrowser.Api/Playback/Hls/DynamicHlsService.cs +++ b/MediaBrowser.Api/Playback/Hls/DynamicHlsService.cs @@ -758,7 +758,7 @@ namespace MediaBrowser.Api.Playback.Hls protected override string GetAudioArguments(StreamState state) { - var codec = GetAudioEncoder(state); + var codec = EncodingHelper.GetAudioEncoder(state); if (!state.IsOutputVideo) { @@ -811,7 +811,7 @@ namespace MediaBrowser.Api.Playback.Hls args += " -ab " + bitrate.Value.ToString(UsCulture); } - args += " " + GetAudioFilterParam(state, true); + args += " " + EncodingHelper.GetAudioFilterParam(state, ApiEntryPoint.Instance.GetEncodingOptions(), true); return args; } @@ -823,7 +823,7 @@ namespace MediaBrowser.Api.Playback.Hls return string.Empty; } - var codec = GetVideoEncoder(state); + var codec = EncodingHelper.GetVideoEncoder(state, ApiEntryPoint.Instance.GetEncodingOptions()); var args = "-codec:v:0 " + codec; @@ -835,7 +835,7 @@ namespace MediaBrowser.Api.Playback.Hls // See if we can save come cpu cycles by avoiding encoding if (string.Equals(codec, "copy", StringComparison.OrdinalIgnoreCase)) { - if (state.VideoStream != null && IsH264(state.VideoStream) && !string.Equals(state.VideoStream.NalLengthSize, "0", StringComparison.OrdinalIgnoreCase)) + if (state.VideoStream != null && EncodingHelper.IsH264(state.VideoStream) && !string.Equals(state.VideoStream.NalLengthSize, "0", StringComparison.OrdinalIgnoreCase)) { args += " -bsf:v h264_mp4toannexb"; } @@ -849,20 +849,22 @@ namespace MediaBrowser.Api.Playback.Hls var hasGraphicalSubs = state.SubtitleStream != null && !state.SubtitleStream.IsTextSubtitleStream && state.VideoRequest.SubtitleMethod == SubtitleDeliveryMethod.Encode; - args += " " + GetVideoQualityParam(state, GetH264Encoder(state)) + keyFrameArg; + var encodingOptions = ApiEntryPoint.Instance.GetEncodingOptions(); + + args += " " + EncodingHelper.GetVideoQualityParam(state, EncodingHelper.GetH264Encoder(state, encodingOptions), encodingOptions, GetDefaultH264Preset()) + keyFrameArg; //args += " -mixed-refs 0 -refs 3 -x264opts b_pyramid=0:weightb=0:weightp=0"; // Add resolution params, if specified if (!hasGraphicalSubs) { - args += GetOutputSizeParam(state, codec, EnableCopyTs(state)); + args += EncodingHelper.GetOutputSizeParam(state, codec, EnableCopyTs(state)); } // This is for internal graphical subs if (hasGraphicalSubs) { - args += GetGraphicalSubtitleParam(state, codec); + args += EncodingHelper.GetGraphicalSubtitleParam(state, codec); } //args += " -flags -global_header"; @@ -884,15 +886,16 @@ namespace MediaBrowser.Api.Playback.Hls protected override string GetCommandLineArguments(string outputPath, StreamState state, bool isEncoding) { - var threads = GetNumberOfThreads(state, false); + var encodingOptions = ApiEntryPoint.Instance.GetEncodingOptions(); + var threads = EncodingHelper.GetNumberOfThreads(state, encodingOptions, false); - var inputModifier = GetInputModifier(state, false); + var inputModifier = EncodingHelper.GetInputModifier(state, encodingOptions); // If isEncoding is true we're actually starting ffmpeg var startNumber = GetStartNumber(state); var startNumberParam = isEncoding ? startNumber.ToString(UsCulture) : "0"; - var mapArgs = state.IsOutputVideo ? GetMapArgs(state) : string.Empty; + var mapArgs = state.IsOutputVideo ? EncodingHelper.GetMapArgs(state) : string.Empty; var useGenericSegmenter = true; if (useGenericSegmenter) @@ -909,7 +912,7 @@ namespace MediaBrowser.Api.Playback.Hls return string.Format("{0} {1} -map_metadata -1 -map_chapters -1 -threads {2} {3} {4} {5} -f segment -max_delay 5000000 -avoid_negative_ts disabled -start_at_zero -segment_time {6} {10} -individual_header_trailer 0 -segment_format mpegts -segment_list_type m3u8 -segment_start_number {7} -segment_list \"{8}\" -y \"{9}\"", inputModifier, - GetInputArgument(state), + EncodingHelper.GetInputArgument(state, encodingOptions), threads, mapArgs, GetVideoArguments(state), @@ -924,7 +927,7 @@ namespace MediaBrowser.Api.Playback.Hls return string.Format("{0} {1} -map_metadata -1 -map_chapters -1 -threads {2} {3} {4} {5} -max_delay 5000000 -avoid_negative_ts disabled -start_at_zero -hls_time {6} -individual_header_trailer 0 -start_number {7} -hls_list_size {8} -y \"{9}\"", inputModifier, - GetInputArgument(state), + EncodingHelper.GetInputArgument(state, encodingOptions), threads, mapArgs, GetVideoArguments(state), diff --git a/MediaBrowser.Api/Playback/Hls/VideoHlsService.cs b/MediaBrowser.Api/Playback/Hls/VideoHlsService.cs index 67edd3f00..c9c6acc1b 100644 --- a/MediaBrowser.Api/Playback/Hls/VideoHlsService.cs +++ b/MediaBrowser.Api/Playback/Hls/VideoHlsService.cs @@ -37,7 +37,7 @@ namespace MediaBrowser.Api.Playback.Hls /// <returns>System.String.</returns> protected override string GetAudioArguments(StreamState state) { - var codec = GetAudioEncoder(state); + var codec = EncodingHelper.GetAudioEncoder(state); if (string.Equals(codec, "copy", StringComparison.OrdinalIgnoreCase)) { @@ -60,7 +60,7 @@ namespace MediaBrowser.Api.Playback.Hls args += " -ab " + bitrate.Value.ToString(UsCulture); } - args += " " + GetAudioFilterParam(state, true); + args += " " + EncodingHelper.GetAudioFilterParam(state, ApiEntryPoint.Instance.GetEncodingOptions(), true); return args; } @@ -72,7 +72,7 @@ namespace MediaBrowser.Api.Playback.Hls /// <returns>System.String.</returns> protected override string GetVideoArguments(StreamState state) { - var codec = GetVideoEncoder(state); + var codec = EncodingHelper.GetVideoEncoder(state, ApiEntryPoint.Instance.GetEncodingOptions()); var args = "-codec:v:0 " + codec; @@ -85,7 +85,7 @@ namespace MediaBrowser.Api.Playback.Hls if (codec.Equals("copy", StringComparison.OrdinalIgnoreCase)) { // if h264_mp4toannexb is ever added, do not use it for live tv - if (state.VideoStream != null && IsH264(state.VideoStream) && !string.Equals(state.VideoStream.NalLengthSize, "0", StringComparison.OrdinalIgnoreCase)) + if (state.VideoStream != null && EncodingHelper.IsH264(state.VideoStream) && !string.Equals(state.VideoStream.NalLengthSize, "0", StringComparison.OrdinalIgnoreCase)) { args += " -bsf:v h264_mp4toannexb"; } @@ -98,18 +98,19 @@ namespace MediaBrowser.Api.Playback.Hls var hasGraphicalSubs = state.SubtitleStream != null && !state.SubtitleStream.IsTextSubtitleStream && state.VideoRequest.SubtitleMethod == SubtitleDeliveryMethod.Encode; - args += " " + GetVideoQualityParam(state, GetH264Encoder(state)) + keyFrameArg; + var encodingOptions = ApiEntryPoint.Instance.GetEncodingOptions(); + args += " " + EncodingHelper.GetVideoQualityParam(state, EncodingHelper.GetH264Encoder(state, encodingOptions), encodingOptions, GetDefaultH264Preset()) + keyFrameArg; // Add resolution params, if specified if (!hasGraphicalSubs) { - args += GetOutputSizeParam(state, codec); + args += EncodingHelper.GetOutputSizeParam(state, codec); } // This is for internal graphical subs if (hasGraphicalSubs) { - args += GetGraphicalSubtitleParam(state, codec); + args += EncodingHelper.GetGraphicalSubtitleParam(state, codec); } args += " -flags -global_header"; diff --git a/MediaBrowser.Api/Playback/Progressive/AudioService.cs b/MediaBrowser.Api/Playback/Progressive/AudioService.cs index 082d6b2f4..a0ab90664 100644 --- a/MediaBrowser.Api/Playback/Progressive/AudioService.cs +++ b/MediaBrowser.Api/Playback/Progressive/AudioService.cs @@ -57,6 +57,8 @@ namespace MediaBrowser.Api.Playback.Progressive protected override string GetCommandLineArguments(string outputPath, StreamState state, bool isEncoding) { + var encodingOptions = ApiEntryPoint.Instance.GetEncodingOptions(); + var audioTranscodeParams = new List<string>(); var bitrate = state.OutputAudioBitrate; @@ -82,13 +84,13 @@ namespace MediaBrowser.Api.Playback.Progressive const string vn = " -vn"; - var threads = GetNumberOfThreads(state, false); + var threads = EncodingHelper.GetNumberOfThreads(state, encodingOptions, false); - var inputModifier = GetInputModifier(state); + var inputModifier = EncodingHelper.GetInputModifier(state, encodingOptions); return string.Format("{0} {1} -threads {2}{3} {4} -id3v2_version 3 -write_id3v1 1 -y \"{5}\"", inputModifier, - GetInputArgument(state), + EncodingHelper.GetInputArgument(state, encodingOptions), threads, vn, string.Join(" ", audioTranscodeParams.ToArray()), diff --git a/MediaBrowser.Api/Playback/Progressive/VideoService.cs b/MediaBrowser.Api/Playback/Progressive/VideoService.cs index 47f5d95e0..3c614567b 100644 --- a/MediaBrowser.Api/Playback/Progressive/VideoService.cs +++ b/MediaBrowser.Api/Playback/Progressive/VideoService.cs @@ -96,8 +96,10 @@ namespace MediaBrowser.Api.Playback.Progressive protected override string GetCommandLineArguments(string outputPath, StreamState state, bool isEncoding) { + var encodingOptions = ApiEntryPoint.Instance.GetEncodingOptions(); + // Get the output codec name - var videoCodec = GetVideoEncoder(state); + var videoCodec = EncodingHelper.GetVideoEncoder(state, encodingOptions); var format = string.Empty; var keyFrame = string.Empty; @@ -108,9 +110,9 @@ namespace MediaBrowser.Api.Playback.Progressive format = " -f mp4 -movflags frag_keyframe+empty_moov"; } - var threads = GetNumberOfThreads(state, string.Equals(videoCodec, "libvpx", StringComparison.OrdinalIgnoreCase)); + var threads = EncodingHelper.GetNumberOfThreads(state, encodingOptions, string.Equals(videoCodec, "libvpx", StringComparison.OrdinalIgnoreCase)); - var inputModifier = GetInputModifier(state); + var inputModifier = EncodingHelper.GetInputModifier(state, encodingOptions); var subtitleArguments = state.SubtitleStream != null && state.SubtitleDeliveryMethod == SubtitleDeliveryMethod.Embed @@ -119,9 +121,9 @@ namespace MediaBrowser.Api.Playback.Progressive return string.Format("{0} {1}{2} {3} {4} -map_metadata -1 -map_chapters -1 -threads {5} {6}{7}{8} -y \"{9}\"", inputModifier, - GetInputArgument(state), + EncodingHelper.GetInputArgument(state, encodingOptions), keyFrame, - GetMapArgs(state), + EncodingHelper.GetMapArgs(state), GetVideoArguments(state, videoCodec), threads, GetAudioArguments(state), @@ -165,7 +167,7 @@ namespace MediaBrowser.Api.Playback.Progressive if (string.Equals(videoCodec, "copy", StringComparison.OrdinalIgnoreCase)) { - if (state.VideoStream != null && IsH264(state.VideoStream) && string.Equals(state.OutputContainer, "ts", StringComparison.OrdinalIgnoreCase) && !string.Equals(state.VideoStream.NalLengthSize, "0", StringComparison.OrdinalIgnoreCase)) + if (state.VideoStream != null && EncodingHelper.IsH264(state.VideoStream) && string.Equals(state.OutputContainer, "ts", StringComparison.OrdinalIgnoreCase) && !string.Equals(state.VideoStream.NalLengthSize, "0", StringComparison.OrdinalIgnoreCase)) { args += " -bsf:v h264_mp4toannexb"; } @@ -194,7 +196,7 @@ namespace MediaBrowser.Api.Playback.Progressive // Add resolution params, if specified if (!hasGraphicalSubs) { - var outputSizeParam = GetOutputSizeParam(state, videoCodec); + var outputSizeParam = EncodingHelper.GetOutputSizeParam(state, videoCodec); args += outputSizeParam; hasCopyTs = outputSizeParam.IndexOf("copyts", StringComparison.OrdinalIgnoreCase) != -1; } @@ -208,7 +210,8 @@ namespace MediaBrowser.Api.Playback.Progressive args += " -avoid_negative_ts disabled -start_at_zero"; } - var qualityParam = GetVideoQualityParam(state, videoCodec); + var encodingOptions = ApiEntryPoint.Instance.GetEncodingOptions(); + var qualityParam = EncodingHelper.GetVideoQualityParam(state, videoCodec, encodingOptions, GetDefaultH264Preset()); if (!string.IsNullOrEmpty(qualityParam)) { @@ -218,7 +221,7 @@ namespace MediaBrowser.Api.Playback.Progressive // This is for internal graphical subs if (hasGraphicalSubs) { - args += GetGraphicalSubtitleParam(state, videoCodec); + args += EncodingHelper.GetGraphicalSubtitleParam(state, videoCodec); } if (!state.RunTimeTicks.HasValue) @@ -243,7 +246,7 @@ namespace MediaBrowser.Api.Playback.Progressive } // Get the output codec name - var codec = GetAudioEncoder(state); + var codec = EncodingHelper.GetAudioEncoder(state); var args = "-codec:a:0 " + codec; @@ -267,7 +270,7 @@ namespace MediaBrowser.Api.Playback.Progressive args += " -ab " + bitrate.Value.ToString(UsCulture); } - args += " " + GetAudioFilterParam(state, false); + args += " " + EncodingHelper.GetAudioFilterParam(state, ApiEntryPoint.Instance.GetEncodingOptions(), false); return args; } diff --git a/MediaBrowser.Api/Playback/StreamRequest.cs b/MediaBrowser.Api/Playback/StreamRequest.cs index 3fcdea4ba..6bdb30890 100644 --- a/MediaBrowser.Api/Playback/StreamRequest.cs +++ b/MediaBrowser.Api/Playback/StreamRequest.cs @@ -1,4 +1,5 @@ -using MediaBrowser.Model.Dlna; +using MediaBrowser.Controller.MediaEncoding; +using MediaBrowser.Model.Dlna; using MediaBrowser.Model.Services; namespace MediaBrowser.Api.Playback @@ -6,7 +7,7 @@ namespace MediaBrowser.Api.Playback /// <summary> /// Class StreamRequest /// </summary> - public class StreamRequest + public class StreamRequest : BaseEncodingJobOptions { /// <summary> /// Gets or sets the id. @@ -30,46 +31,6 @@ namespace MediaBrowser.Api.Playback public string SubtitleCodec { get; set; } - /// <summary> - /// Gets or sets the start time ticks. - /// </summary> - /// <value>The start time ticks.</value> - [ApiMember(Name = "StartTimeTicks", Description = "Optional. Specify a starting offset, in ticks. 1 tick = 10000 ms", IsRequired = false, DataType = "int", ParameterType = "query", Verb = "GET")] - public long? StartTimeTicks { get; set; } - - /// <summary> - /// Gets or sets the audio bit rate. - /// </summary> - /// <value>The audio bit rate.</value> - [ApiMember(Name = "AudioBitRate", Description = "Optional. Specify an audio bitrate to encode to, e.g. 128000. If omitted this will be left to encoder defaults.", IsRequired = false, DataType = "int", ParameterType = "query", Verb = "GET")] - public int? AudioBitRate { get; set; } - - /// <summary> - /// Gets or sets the audio channels. - /// </summary> - /// <value>The audio channels.</value> - [ApiMember(Name = "AudioChannels", Description = "Optional. Specify a specific number of audio channels to encode to, e.g. 2", IsRequired = false, DataType = "int", ParameterType = "query", Verb = "GET")] - public int? AudioChannels { get; set; } - - [ApiMember(Name = "MaxAudioChannels", Description = "Optional. Specify a maximum number of audio channels to encode to, e.g. 2", IsRequired = false, DataType = "int", ParameterType = "query", Verb = "GET")] - public int? MaxAudioChannels { get; set; } - - public int? TranscodingMaxAudioChannels { get; set; } - - /// <summary> - /// Gets or sets the audio sample rate. - /// </summary> - /// <value>The audio sample rate.</value> - [ApiMember(Name = "AudioSampleRate", Description = "Optional. Specify a specific audio sample rate, e.g. 44100", IsRequired = false, DataType = "int", ParameterType = "query", Verb = "GET")] - public int? AudioSampleRate { get; set; } - - /// <summary> - /// Gets or sets a value indicating whether this <see cref="StreamRequest" /> is static. - /// </summary> - /// <value><c>true</c> if static; otherwise, <c>false</c>.</value> - [ApiMember(Name = "Static", Description = "Optional. If true, the original file will be streamed statically without any encoding. Use either no url extension or the original file extension. true/false", IsRequired = false, DataType = "bool", ParameterType = "query", Verb = "GET")] - public bool Static { get; set; } - [ApiMember(Name = "DeviceProfileId", Description = "Optional. The dlna device profile id to utilize.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")] public string DeviceProfileId { get; set; } @@ -82,102 +43,6 @@ namespace MediaBrowser.Api.Playback public class VideoStreamRequest : StreamRequest { /// <summary> - /// Gets or sets the video codec. - /// </summary> - /// <value>The video codec.</value> - [ApiMember(Name = "VideoCodec", Description = "Optional. Specify a video codec to encode to, e.g. h264. If omitted the server will auto-select using the url's extension. Options: h264, mpeg4, theora, vpx, wmv.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")] - public string VideoCodec { get; set; } - - /// <summary> - /// Gets or sets the video bit rate. - /// </summary> - /// <value>The video bit rate.</value> - [ApiMember(Name = "VideoBitRate", Description = "Optional. Specify a video bitrate to encode to, e.g. 500000. If omitted this will be left to encoder defaults.", IsRequired = false, DataType = "int", ParameterType = "query", Verb = "GET")] - public int? VideoBitRate { get; set; } - - /// <summary> - /// Gets or sets the index of the audio stream. - /// </summary> - /// <value>The index of the audio stream.</value> - [ApiMember(Name = "AudioStreamIndex", Description = "Optional. The index of the audio stream to use. If omitted the first audio stream will be used.", IsRequired = false, DataType = "int", ParameterType = "query", Verb = "GET")] - public int? AudioStreamIndex { get; set; } - - /// <summary> - /// Gets or sets the index of the video stream. - /// </summary> - /// <value>The index of the video stream.</value> - [ApiMember(Name = "VideoStreamIndex", Description = "Optional. The index of the video stream to use. If omitted the first video stream will be used.", IsRequired = false, DataType = "int", ParameterType = "query", Verb = "GET")] - public int? VideoStreamIndex { get; set; } - - /// <summary> - /// Gets or sets the index of the subtitle stream. - /// </summary> - /// <value>The index of the subtitle stream.</value> - [ApiMember(Name = "SubtitleStreamIndex", Description = "Optional. The index of the subtitle stream to use. If omitted no subtitles will be used.", IsRequired = false, DataType = "int", ParameterType = "query", Verb = "GET")] - public int? SubtitleStreamIndex { get; set; } - - /// <summary> - /// Gets or sets the width. - /// </summary> - /// <value>The width.</value> - [ApiMember(Name = "Width", Description = "Optional. The fixed horizontal resolution of the encoded video.", IsRequired = false, DataType = "int", ParameterType = "query", Verb = "GET")] - public int? Width { get; set; } - - /// <summary> - /// Gets or sets the height. - /// </summary> - /// <value>The height.</value> - [ApiMember(Name = "Height", Description = "Optional. The fixed vertical resolution of the encoded video.", IsRequired = false, DataType = "int", ParameterType = "query", Verb = "GET")] - public int? Height { get; set; } - - /// <summary> - /// Gets or sets the width of the max. - /// </summary> - /// <value>The width of the max.</value> - [ApiMember(Name = "MaxWidth", Description = "Optional. The maximum horizontal resolution of the encoded video.", IsRequired = false, DataType = "int", ParameterType = "query", Verb = "GET")] - public int? MaxWidth { get; set; } - - /// <summary> - /// Gets or sets the height of the max. - /// </summary> - /// <value>The height of the max.</value> - [ApiMember(Name = "MaxHeight", Description = "Optional. The maximum vertical resolution of the encoded video.", IsRequired = false, DataType = "int", ParameterType = "query", Verb = "GET")] - public int? MaxHeight { get; set; } - - [ApiMember(Name = "MaxRefFrames", Description = "Optional.", IsRequired = false, DataType = "int", ParameterType = "query", Verb = "GET")] - public int? MaxRefFrames { get; set; } - - [ApiMember(Name = "MaxVideoBitDepth", Description = "Optional.", IsRequired = false, DataType = "int", ParameterType = "query", Verb = "GET")] - public int? MaxVideoBitDepth { get; set; } - - /// <summary> - /// Gets or sets the framerate. - /// </summary> - /// <value>The framerate.</value> - [ApiMember(Name = "Framerate", Description = "Optional. A specific video framerate to encode to, e.g. 23.976. Generally this should be omitted unless the device has specific requirements.", IsRequired = false, DataType = "double", ParameterType = "query", Verb = "GET")] - public float? Framerate { get; set; } - - [ApiMember(Name = "MaxFramerate", Description = "Optional. A specific maximum video framerate to encode to, e.g. 23.976. Generally this should be omitted unless the device has specific requirements.", IsRequired = false, DataType = "double", ParameterType = "query", Verb = "GET")] - public float? MaxFramerate { get; set; } - - /// <summary> - /// Gets or sets the profile. - /// </summary> - /// <value>The profile.</value> - [ApiMember(Name = "Profile", Description = "Optional. Specify a specific h264 profile, e.g. main, baseline, high.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")] - public string Profile { get; set; } - - /// <summary> - /// Gets or sets the level. - /// </summary> - /// <value>The level.</value> - [ApiMember(Name = "Level", Description = "Optional. Specify a level for the h264 profile, e.g. 3, 3.1.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")] - public string Level { get; set; } - - [ApiMember(Name = "SubtitleDeliveryMethod", Description = "Optional. Specify the subtitle delivery method.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")] - 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> @@ -189,18 +54,6 @@ namespace MediaBrowser.Api.Playback } } - [ApiMember(Name = "EnableAutoStreamCopy", Description = "Whether or not to allow automatic stream copy if requested values match the original source. Defaults to true.", IsRequired = false, DataType = "bool", ParameterType = "query", Verb = "GET")] - public bool EnableAutoStreamCopy { get; set; } - - [ApiMember(Name = "CopyTimestamps", Description = "Whether or not to copy timestamps when transcoding with an offset. Defaults to false.", IsRequired = false, DataType = "bool", ParameterType = "query", Verb = "GET")] - public bool CopyTimestamps { get; set; } - public bool EnableSubtitlesInManifest { get; set; } - public bool RequireAvc { get; set; } - - public VideoStreamRequest() - { - EnableAutoStreamCopy = true; - } } } diff --git a/MediaBrowser.Api/Playback/StreamState.cs b/MediaBrowser.Api/Playback/StreamState.cs index 84a546d35..4fb936340 100644 --- a/MediaBrowser.Api/Playback/StreamState.cs +++ b/MediaBrowser.Api/Playback/StreamState.cs @@ -13,17 +13,28 @@ using System.Globalization; using System.IO; using System.Linq; using System.Threading; +using MediaBrowser.MediaEncoding.Encoder; namespace MediaBrowser.Api.Playback { - public class StreamState : IDisposable + public class StreamState : EncodingJobInfo, IDisposable { private readonly ILogger _logger; private readonly IMediaSourceManager _mediaSourceManager; public string RequestedUrl { get; set; } - public StreamRequest Request { get; set; } + public StreamRequest Request + { + get { return (StreamRequest)BaseRequest; } + set + { + BaseRequest = value; + + IsVideoRequest = VideoRequest != null; + } + } + public TranscodingThrottler TranscodingThrottler { get; set; } public VideoStreamRequest VideoRequest @@ -31,8 +42,6 @@ namespace MediaBrowser.Api.Playback get { return Request as VideoStreamRequest; } } - public Dictionary<string, string> RemoteHttpHeaders { get; set; } - /// <summary> /// Gets or sets the log file stream. /// </summary> @@ -40,36 +49,12 @@ namespace MediaBrowser.Api.Playback public Stream LogFileStream { get; set; } public IDirectStreamProvider DirectStreamProvider { 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 SubtitleDeliveryMethod SubtitleDeliveryMethod { get; set; } - - /// <summary> - /// Gets or sets the iso mount. - /// </summary> - /// <value>The iso mount.</value> - public IIsoMount IsoMount { get; set; } - - public string MediaPath { get; set; } public string WaitForPath { get; set; } - public MediaProtocol InputProtocol { get; set; } - public bool IsOutputVideo { get { return Request is VideoStreamRequest; } } - public bool IsInputVideo { get; set; } - - public VideoType VideoType { get; set; } - public IsoType? IsoType { get; set; } - - public List<string> PlayableStreamFileNames { get; set; } public int SegmentLength { @@ -117,41 +102,19 @@ namespace MediaBrowser.Api.Playback } } - public long? RunTimeTicks; - - public long? InputBitrate { get; set; } - public long? InputFileSize { get; set; } - - public string OutputAudioSync = "1"; - public string OutputVideoSync = "-1"; - public List<string> SupportedSubtitleCodecs { get; set; } - public List<string> SupportedAudioCodecs { get; set; } - public List<string> SupportedVideoCodecs { get; set; } public string UserAgent { get; set; } public TranscodingJobType TranscodingType { get; set; } - public StreamState(IMediaSourceManager mediaSourceManager, ILogger logger, TranscodingJobType transcodingType) + public StreamState(IMediaSourceManager mediaSourceManager, ILogger logger, TranscodingJobType transcodingType) + : base(logger) { _mediaSourceManager = mediaSourceManager; _logger = logger; SupportedSubtitleCodecs = new List<string>(); - SupportedAudioCodecs = new List<string>(); - SupportedVideoCodecs = new List<string>(); - PlayableStreamFileNames = new List<string>(); - RemoteHttpHeaders = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase); TranscodingType = transcodingType; } - public string InputAudioSync { get; set; } - public string InputVideoSync { get; set; } - - public bool DeInterlace { get; set; } - - public bool ReadInputAtNativeFramerate { get; set; } - - public TransportStreamTimestamp InputTimestamp { get; set; } - public string MimeType { get; set; } public bool EstimateContentLength { get; set; } @@ -212,23 +175,6 @@ namespace MediaBrowser.Api.Playback } } - 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 && string.IsNullOrWhiteSpace(Request.LiveStreamId) && !string.IsNullOrWhiteSpace(MediaSource.LiveStreamId)) @@ -244,15 +190,8 @@ namespace MediaBrowser.Api.Playback } } - 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 { @@ -298,8 +237,6 @@ namespace MediaBrowser.Api.Playback } } - public string OutputContainer { get; set; } - public DeviceProfile DeviceProfile { get; set; } public int? TotalOutputBitrate @@ -447,20 +384,6 @@ namespace MediaBrowser.Api.Playback } } - /// <summary> - /// Predicts the audio sample rate that will be in the output stream - /// </summary> - public double? TargetVideoLevel - { - get - { - var stream = VideoStream; - return !string.IsNullOrEmpty(VideoRequest.Level) && !Request.Static - ? double.Parse(VideoRequest.Level, CultureInfo.InvariantCulture) - : stream == null ? null : stream.Level; - } - } - public TransportStreamTimestamp TargetTimestamp { get |
