From 0be4e18bacefa6b7bc63731b4a004a6ff772af20 Mon Sep 17 00:00:00 2001 From: sr55 Date: Sun, 3 May 2015 17:18:59 +0000 Subject: WinGui: Some Model Re-factoring by RandomEngy git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@7151 b64f7644-9d1e-0410-96f1-a4d463321fa5 --- .../HandBrake.ApplicationServices.csproj | 64 ++-- .../Interop/Factories/AnamorphicFactory.cs | 58 ++- .../Interop/HandBrakeEncoderHelpers.cs | 211 +++++++---- .../Interop/HandBrakeInstance.cs | 99 +++-- .../Interop/HandBrakeUtils.cs | 67 ++-- .../Interop/Json/Encode/Audio.cs | 2 +- .../Interop/Json/Encode/AudioList.cs | 77 ---- .../Interop/Json/Encode/AudioTrack.cs | 77 ++++ .../Interop/Json/Encode/Chapter.cs | 22 ++ .../Interop/Json/Encode/ChapterList.cs | 22 -- .../Interop/Json/Encode/Destination.cs | 2 +- .../Interop/Json/Encode/JsonEncodeObject.cs | 2 +- .../Interop/Json/Encode/MetaData.cs | 2 +- .../Interop/Json/Encode/SubtitleList.cs | 52 --- .../Interop/Json/Encode/SubtitleTrack.cs | 49 +++ .../Interop/Json/Encode/Subtitles.cs | 10 +- .../Interop/Json/Scan/AudioTrack.cs | 52 --- .../Interop/Json/Scan/ChapterTrack.cs | 27 -- .../Interop/Json/Scan/MetaData.cs | 18 - .../Interop/Json/Scan/SourceAudioTrack.cs | 49 +++ .../Interop/Json/Scan/SourceChapter.cs | 24 ++ .../Interop/Json/Scan/SourceMetadata.cs | 18 + .../Interop/Json/Scan/SourceSubtitleTrack.cs | 37 ++ .../Interop/Json/Scan/SourceTitle.cs | 52 +-- .../Interop/Json/Scan/SubtitleTrack.cs | 37 -- .../Interop/Model/Preview/PreviewSettings.cs | 73 ++-- .../Services/Encode/Factories/EncodeFactory.cs | 418 +++++++++++---------- .../Services/Scan/Interfaces/IScan.cs | 14 +- .../Services/Scan/LibScan.cs | 72 ++-- 29 files changed, 945 insertions(+), 762 deletions(-) delete mode 100644 win/CS/HandBrake.ApplicationServices/Interop/Json/Encode/AudioList.cs create mode 100644 win/CS/HandBrake.ApplicationServices/Interop/Json/Encode/AudioTrack.cs create mode 100644 win/CS/HandBrake.ApplicationServices/Interop/Json/Encode/Chapter.cs delete mode 100644 win/CS/HandBrake.ApplicationServices/Interop/Json/Encode/ChapterList.cs delete mode 100644 win/CS/HandBrake.ApplicationServices/Interop/Json/Encode/SubtitleList.cs create mode 100644 win/CS/HandBrake.ApplicationServices/Interop/Json/Encode/SubtitleTrack.cs delete mode 100644 win/CS/HandBrake.ApplicationServices/Interop/Json/Scan/AudioTrack.cs delete mode 100644 win/CS/HandBrake.ApplicationServices/Interop/Json/Scan/ChapterTrack.cs delete mode 100644 win/CS/HandBrake.ApplicationServices/Interop/Json/Scan/MetaData.cs create mode 100644 win/CS/HandBrake.ApplicationServices/Interop/Json/Scan/SourceAudioTrack.cs create mode 100644 win/CS/HandBrake.ApplicationServices/Interop/Json/Scan/SourceChapter.cs create mode 100644 win/CS/HandBrake.ApplicationServices/Interop/Json/Scan/SourceMetadata.cs create mode 100644 win/CS/HandBrake.ApplicationServices/Interop/Json/Scan/SourceSubtitleTrack.cs delete mode 100644 win/CS/HandBrake.ApplicationServices/Interop/Json/Scan/SubtitleTrack.cs (limited to 'win/CS/HandBrake.ApplicationServices') diff --git a/win/CS/HandBrake.ApplicationServices/HandBrake.ApplicationServices.csproj b/win/CS/HandBrake.ApplicationServices/HandBrake.ApplicationServices.csproj index c3995689c..bb6fef136 100644 --- a/win/CS/HandBrake.ApplicationServices/HandBrake.ApplicationServices.csproj +++ b/win/CS/HandBrake.ApplicationServices/HandBrake.ApplicationServices.csproj @@ -109,38 +109,38 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/win/CS/HandBrake.ApplicationServices/Interop/Factories/AnamorphicFactory.cs b/win/CS/HandBrake.ApplicationServices/Interop/Factories/AnamorphicFactory.cs index abaa0fc25..741723329 100644 --- a/win/CS/HandBrake.ApplicationServices/Interop/Factories/AnamorphicFactory.cs +++ b/win/CS/HandBrake.ApplicationServices/Interop/Factories/AnamorphicFactory.cs @@ -15,6 +15,7 @@ namespace HandBrake.ApplicationServices.Interop.Factories using HandBrake.ApplicationServices.Interop.Json.Shared; using HandBrake.ApplicationServices.Interop.Model; using HandBrake.ApplicationServices.Interop.Model.Encoding; + using HandBrake.ApplicationServices.Interop.Model.Preview; using HandBrake.ApplicationServices.Services.Encode.Model; /// @@ -51,10 +52,10 @@ namespace HandBrake.ApplicationServices.Interop.Factories { int settingMode = (int)keepWidthOrHeight + (job.KeepDisplayAspect ? 0x04 : 0); - // Sanatise the Geometry First. + // Sanitize the Geometry First. AnamorphicGeometry anamorphicGeometry = new AnamorphicGeometry { - SourceGeometry = new Geometry() + SourceGeometry = new Geometry { Width = title.Resolution.Width, Height = title.Resolution.Height, @@ -91,5 +92,58 @@ namespace HandBrake.ApplicationServices.Interop.Factories return HandBrakeUtils.GetAnamorphicSize(anamorphicGeometry); } + + /// + /// Finds output geometry for the given preview settings and title. + /// + /// The preview settings. + /// Information on the title to consider. + /// + public static Geometry CreateGeometry(PreviewSettings settings, SourceVideoInfo title) + { + int settingMode = settings.KeepDisplayAspect ? 0x04 : 0; + + // Sanitize the Geometry First. + AnamorphicGeometry anamorphicGeometry = new AnamorphicGeometry + { + SourceGeometry = new Geometry + { + Width = title.Resolution.Width, + Height = title.Resolution.Height, + PAR = new PAR { Num = title.ParVal.Width, Den = title.ParVal.Height } + }, + DestSettings = new DestSettings + { + AnamorphicMode = (int)settings.Anamorphic, + Geometry = + { + Width = settings.Width, + Height = settings.Height, + PAR = new PAR + { + Num = settings.Anamorphic != Anamorphic.Custom ? title.ParVal.Width : settings.PixelAspectX, + Den = settings.Anamorphic != Anamorphic.Custom ? title.ParVal.Height : settings.PixelAspectY, + } + }, + Keep = settingMode, + Crop = new List { settings.Cropping.Top, settings.Cropping.Bottom, settings.Cropping.Left, settings.Cropping.Right }, + Modulus = settings.Modulus ?? 16, + MaxWidth = settings.MaxWidth, + MaxHeight = settings.MaxHeight, + ItuPAR = false + } + }; + + if (settings.Anamorphic == Anamorphic.Custom) + { + anamorphicGeometry.DestSettings.Geometry.PAR = new PAR { Num = settings.PixelAspectX, Den = settings.PixelAspectY }; + } + else + { + anamorphicGeometry.DestSettings.Geometry.PAR = new PAR { Num = title.ParVal.Width, Den = title.ParVal.Height }; + } + + return HandBrakeUtils.GetAnamorphicSize(anamorphicGeometry); + } } } diff --git a/win/CS/HandBrake.ApplicationServices/Interop/HandBrakeEncoderHelpers.cs b/win/CS/HandBrake.ApplicationServices/Interop/HandBrakeEncoderHelpers.cs index 714de6547..69075a7f9 100644 --- a/win/CS/HandBrake.ApplicationServices/Interop/HandBrakeEncoderHelpers.cs +++ b/win/CS/HandBrake.ApplicationServices/Interop/HandBrakeEncoderHelpers.cs @@ -33,33 +33,33 @@ namespace HandBrake.ApplicationServices.Interop /// private static List videoEncoders; - /// - /// Video framerates in pts. - /// - private static List videoFramerates; - - /// - /// List of HandBrake mixdowns. + /// + /// Video framerates in pts. + /// + private static List videoFramerates; + + /// + /// List of HandBrake mixdowns. /// private static List mixdowns; - /// - /// List of HandBrake containers. - /// - private static List containers; - - /// - /// The audio bitrates. + /// + /// List of HandBrake containers. + /// + private static List containers; + + /// + /// The audio bitrates. /// private static List audioBitrates; - /// - /// Audio sample rates in Hz. - /// - private static List audioSampleRates; - - /// - /// Initializes static members of the HandBrakeEncoderHelpers class. + /// + /// Audio sample rates in Hz. + /// + private static List audioSampleRates; + + /// + /// Initializes static members of the HandBrakeEncoderHelpers class. /// static HandBrakeEncoderHelpers() { @@ -109,13 +109,13 @@ namespace HandBrake.ApplicationServices.Interop { videoFramerates = InteropUtilities.ToListFromIterator(HBFunctions.hb_video_framerate_get_next, HandBrakeUnitConversionHelpers.NativeToRate); } - - return videoFramerates; - } - } - - /// - /// Gets a list of supported mixdowns. + + return videoFramerates; + } + } + + /// + /// Gets a list of supported mixdowns. /// public static List Mixdowns { @@ -257,12 +257,73 @@ namespace HandBrake.ApplicationServices.Interop public static HBContainer GetContainer(string shortName) { return Containers.SingleOrDefault(c => c.ShortName == shortName); - } - - /// - /// Determines if the given encoder is compatible with the given track. - /// - /// + } + + /// + /// Returns true if the subtitle source type can be set to forced only. + /// + /// The subtitle source type (SSA, VobSub, etc) + /// True if the subtitle source type can be set to forced only. + public static bool SubtitleCanSetForcedOnly(int source) + { + return HBFunctions.hb_subtitle_can_force(source) > 0; + } + + /// + /// Returns true if the subtitle source type can be burned in. + /// + /// The subtitle source type (SSA, VobSub, etc) + /// True if the subtitle source type can be burned in. + public static bool SubtitleCanBurn(int source) + { + return HBFunctions.hb_subtitle_can_burn(source) > 0; + } + + /// + /// Returns true if the subtitle type can be passed through using the given muxer. + /// + /// The subtitle source type (SSA, VobSub, etc) + /// The ID of the muxer. + /// True if the subtitle type can be passed through with the given muxer. + public static bool SubtitleCanPassthrough(int subtitleSourceType, int muxer) + { + return HBFunctions.hb_subtitle_can_pass(subtitleSourceType, muxer) > 0; + } + + /// + /// Gets the subtitle source type's name. + /// + /// The subtitle source type (SSA, VobSub, etc). + /// The name of the subtitle source. + public static string GetSubtitleSourceName(int source) + { + switch ((hb_subtitle_s_subsource)source) + { + case hb_subtitle_s_subsource.CC608SUB: + return "CC608"; + case hb_subtitle_s_subsource.CC708SUB: + return "CC708"; + case hb_subtitle_s_subsource.SRTSUB: + return "SRT"; + case hb_subtitle_s_subsource.SSASUB: + return "SSA"; + case hb_subtitle_s_subsource.TX3GSUB: + return "TX3G"; + case hb_subtitle_s_subsource.UTF8SUB: + return "UTF8"; + case hb_subtitle_s_subsource.VOBSUB: + return "VobSub"; + case hb_subtitle_s_subsource.PGSSUB: + return "PGS"; + default: + return string.Empty; + } + } + + /// + /// Determines if the given encoder is compatible with the given track. + /// + /// /// The codec Id. /// /// @@ -307,13 +368,13 @@ namespace HandBrake.ApplicationServices.Interop /// /// /// True if the encoder supports the mixdown. - /// - public static bool MixdownHasCodecSupport(HBMixdown mixdown, HBAudioEncoder encoder) - { - return HBFunctions.hb_mixdown_has_codec_support(mixdown.Id, (uint) encoder.Id) > 0; - } - - /// + /// + public static bool MixdownHasCodecSupport(HBMixdown mixdown, HBAudioEncoder encoder) + { + return HBFunctions.hb_mixdown_has_codec_support(mixdown.Id, (uint)encoder.Id) > 0; + } + + /// /// Determines if DRC can be applied to the given track with the given encoder. /// /// @@ -428,15 +489,15 @@ namespace HandBrake.ApplicationServices.Interop int direction = 0; HBFunctions.hb_video_quality_get_limits((uint)encoder.Id, ref low, ref high, ref granularity, ref direction); - - return new VideoQualityLimits - { - Low = low, - High = high, - Granularity = granularity, - Ascending = direction == 0 - }; - } + + return new VideoQualityLimits + { + Low = low, + High = high, + Granularity = granularity, + Ascending = direction == 0 + }; + } /// /// Sanitizes an audio bitrate given the output codec, sample rate and mixdown. @@ -475,13 +536,13 @@ namespace HandBrake.ApplicationServices.Interop /// /// /// The default bitrate for these parameters. - /// - public static int GetDefaultBitrate(HBAudioEncoder encoder, int sampleRate, HBMixdown mixdown) - { - return HBFunctions.hb_audio_bitrate_get_default((uint) encoder.Id, sampleRate, mixdown.Id); - } - - /// + /// + public static int GetDefaultBitrate(HBAudioEncoder encoder, int sampleRate, HBMixdown mixdown) + { + return HBFunctions.hb_audio_bitrate_get_default((uint)encoder.Id, sampleRate, mixdown.Id); + } + + /// /// Gets limits on audio quality for a given encoder. /// /// @@ -495,15 +556,15 @@ namespace HandBrake.ApplicationServices.Interop float low = 0, high = 0, granularity = 0; int direction = 0; HBFunctions.hb_audio_quality_get_limits((uint)encoderId, ref low, ref high, ref granularity, ref direction); - - return new RangeLimits - { - Low = low, - High = high, - Granularity = granularity, - Ascending = direction == 0 - }; - } + + return new RangeLimits + { + Low = low, + High = high, + Granularity = granularity, + Ascending = direction == 0 + }; + } /// /// Gets limits on audio compression for a given encoder. @@ -519,14 +580,14 @@ namespace HandBrake.ApplicationServices.Interop float low = 0, high = 0, granularity = 0; int direction = 0; HBFunctions.hb_audio_compression_get_limits((uint)encoderId, ref low, ref high, ref granularity, ref direction); - - return new RangeLimits - { - Low = low, - High = high, - Granularity = granularity, - Ascending = direction == 0 - }; - } + + return new RangeLimits + { + Low = low, + High = high, + Granularity = granularity, + Ascending = direction == 0 + }; + } } } diff --git a/win/CS/HandBrake.ApplicationServices/Interop/HandBrakeInstance.cs b/win/CS/HandBrake.ApplicationServices/Interop/HandBrakeInstance.cs index 9e89190cd..8aafbc02d 100644 --- a/win/CS/HandBrake.ApplicationServices/Interop/HandBrakeInstance.cs +++ b/win/CS/HandBrake.ApplicationServices/Interop/HandBrakeInstance.cs @@ -60,6 +60,11 @@ namespace HandBrake.ApplicationServices.Interop /// private IntPtr hbHandle; + /// + /// The number of previews created during scan. + /// + private int previewCount; + /// /// The timer to poll for scan status. /// @@ -120,7 +125,18 @@ namespace HandBrake.ApplicationServices.Interop { get { - return this.Handle; + return this.hbHandle; + } + } + + /// + /// Gets the number of previews created during scan. + /// + public int PreviewCount + { + get + { + return this.previewCount; } } @@ -200,6 +216,8 @@ namespace HandBrake.ApplicationServices.Interop /// public void StartScan(string path, int previewCount, TimeSpan minDuration, int titleIndex) { + this.previewCount = previewCount; + IntPtr pathPtr = InteropUtilities.ToUtf8PtrFromString(path); HBFunctions.hb_scan(this.hbHandle, pathPtr, titleIndex, previewCount, 1, (ulong)(minDuration.TotalSeconds * 90000)); Marshal.FreeHGlobal(pathPtr); @@ -237,7 +255,7 @@ namespace HandBrake.ApplicationServices.Interop /// /// Only incorporates sizing and aspect ratio into preview image. /// - /// + /// /// The encode job to preview. /// /// @@ -247,41 +265,46 @@ namespace HandBrake.ApplicationServices.Interop /// An image with the requested preview. /// [HandleProcessCorruptedStateExceptions] - public BitmapImage GetPreview(PreviewSettings job, int previewNumber) + public BitmapImage GetPreview(PreviewSettings settings, int previewNumber) { - SourceTitle title = this.Titles.TitleList.FirstOrDefault(t => t.Index == job.Title); + SourceTitle title = this.Titles.TitleList.FirstOrDefault(t => t.Index == settings.TitleNumber); Validate.NotNull(title, "GetPreview: Title should not have been null. This is probably a bug."); - // Creat the Expected Output Geometry details for libhb. + // Create the Expected Output Geometry details for libhb. hb_geometry_settings_s uiGeometry = new hb_geometry_settings_s { - crop = new[] { job.Cropping.Top, job.Cropping.Bottom, job.Cropping.Left, job.Cropping.Right }, + crop = new[] { settings.Cropping.Top, settings.Cropping.Bottom, settings.Cropping.Left, settings.Cropping.Right }, itu_par = 0, - keep = (int)AnamorphicFactory.KeepSetting.HB_KEEP_WIDTH + (job.KeepDisplayAspect ? 0x04 : 0), // TODO Keep Width? - maxWidth = job.MaxWidth ?? 0, - maxHeight = job.MaxHeight ?? 0, - mode = (int)(hb_anamorphic_mode_t)job.Anamorphic, - modulus = job.Modulus ?? 16, + keep = settings.KeepDisplayAspect ? 0x04 : 0, + maxWidth = settings.MaxWidth, + maxHeight = settings.MaxHeight, + mode = (int)(hb_anamorphic_mode_t)settings.Anamorphic, + modulus = settings.Modulus ?? 16, geometry = new hb_geometry_s { - height = job.Height ?? 0, - width = job.Width ?? 0, - par = job.Anamorphic != Anamorphic.Custom + height = settings.Height, + width = settings.Width, + par = settings.Anamorphic != Anamorphic.Custom ? new hb_rational_t { den = title.Geometry.PAR.Den, num = title.Geometry.PAR.Num } - : new hb_rational_t { den = job.PixelAspectY, num = job.PixelAspectX } + : new hb_rational_t { den = settings.PixelAspectY, num = settings.PixelAspectX } } }; - // Sanatise the input. - Geometry resultGeometry = AnamorphicFactory.CreateGeometry(job, new SourceVideoInfo(new Size(title.Geometry.Width, title.Geometry.Height), new Size(title.Geometry.PAR.Num, title.Geometry.PAR.Den)), AnamorphicFactory.KeepSetting.HB_KEEP_WIDTH); // TODO this keep isn't right. - int width = resultGeometry.Width * resultGeometry.PAR.Num / resultGeometry.PAR.Den; + // Sanitize the input. + Geometry resultGeometry = AnamorphicFactory.CreateGeometry( + settings, + new SourceVideoInfo( + new Size(title.Geometry.Width, title.Geometry.Height), + new Size(title.Geometry.PAR.Num, title.Geometry.PAR.Den))); + int width = resultGeometry.Width; int height = resultGeometry.Height; - uiGeometry.geometry.height = resultGeometry.Height; // Prased the height now. - int outputWidth = width; - int outputHeight = height; - + uiGeometry.geometry.width = width; + uiGeometry.geometry.height = height; + uiGeometry.geometry.par.num = settings.PixelAspectX; + uiGeometry.geometry.par.den = settings.PixelAspectY; + // Fetch the image data from LibHb - IntPtr resultingImageStuct = HBFunctions.hb_get_preview2(this.hbHandle, job.Title, previewNumber, ref uiGeometry, 0); + IntPtr resultingImageStuct = HBFunctions.hb_get_preview2(this.hbHandle, settings.TitleNumber, previewNumber, ref uiGeometry, 0); hb_image_s image = InteropUtilities.ToStructureFromPtr(resultingImageStuct); // Copy the filled image buffer to a managed array. @@ -292,8 +315,8 @@ namespace HandBrake.ApplicationServices.Interop byte[] managedBuffer = new byte[imageBufferSize]; Marshal.Copy(image.plane[0].data, managedBuffer, 0, imageBufferSize); - var bitmap = new Bitmap(outputWidth, outputHeight); - BitmapData bitmapData = bitmap.LockBits(new Rectangle(0, 0, outputWidth, outputHeight), ImageLockMode.WriteOnly, PixelFormat.Format32bppRgb); + var bitmap = new Bitmap(width, height); + BitmapData bitmapData = bitmap.LockBits(new Rectangle(0, 0, width, height), ImageLockMode.WriteOnly, PixelFormat.Format32bppRgb); IntPtr ptr = bitmapData.Scan0; // Pointer to the first pixel. for (int i = 0; i < image.height; i++) @@ -301,7 +324,7 @@ namespace HandBrake.ApplicationServices.Interop try { Marshal.Copy(managedBuffer, i * stride_width, ptr, stride_width); - ptr = IntPtr.Add(ptr, outputWidth * 4); + ptr = IntPtr.Add(ptr, width * 4); } catch (Exception exc) { @@ -340,6 +363,18 @@ namespace HandBrake.ApplicationServices.Interop } } + /// + /// Determines if DRC can be applied to the given track with the given encoder. + /// + /// The track Number. + /// The encoder to use for DRC. + /// The title. + /// True if DRC can be applied to the track with the given encoder. + public bool CanApplyDrc(int trackNumber, HBAudioEncoder encoder, int title) + { + return HBFunctions.hb_audio_can_apply_drc2(this.hbHandle, title, trackNumber, encoder.Id) > 0; + } + /// /// Starts an encode with the given job. /// @@ -355,7 +390,6 @@ namespace HandBrake.ApplicationServices.Interop }; string encode = JsonConvert.SerializeObject(encodeObject, Formatting.Indented, settings); - LogHelper.LogMessage(new LogMessage(encode, LogMessageType.encodeJson, LogLevel.debug)); HBFunctions.hb_add_json(this.hbHandle, InteropUtilities.ToUtf8PtrFromString(encode)); HBFunctions.hb_start(this.hbHandle); @@ -431,6 +465,17 @@ namespace HandBrake.ApplicationServices.Interop GC.SuppressFinalize(this); } + /// + /// Gets a value indicating whether the object is disposed. + /// + public bool IsDisposed + { + get + { + return this.disposed; + } + } + /// /// Frees any resources associated with this object. /// diff --git a/win/CS/HandBrake.ApplicationServices/Interop/HandBrakeUtils.cs b/win/CS/HandBrake.ApplicationServices/Interop/HandBrakeUtils.cs index 7a00bb8e9..aad5df21c 100644 --- a/win/CS/HandBrake.ApplicationServices/Interop/HandBrakeUtils.cs +++ b/win/CS/HandBrake.ApplicationServices/Interop/HandBrakeUtils.cs @@ -20,23 +20,18 @@ namespace HandBrake.ApplicationServices.Interop using HandBrake.ApplicationServices.Interop.Json.Shared; using HandBrake.ApplicationServices.Services.Logging; using HandBrake.ApplicationServices.Services.Logging.Model; - - using Newtonsoft.Json; - - /// - /// HandBrake Interop Utilities - /// - public static class HandBrakeUtils - { - /// - /// Estimated overhead in bytes for each frame in output container. - /// - internal const int ContainerOverheadPerFrame = 6; - - /// - /// The callback for log messages from HandBrake. - /// - private static LoggingCallback loggingCallback; + + using Newtonsoft.Json; + + /// + /// HandBrake Interop Utilities + /// + public static class HandBrakeUtils + { + /// + /// The callback for log messages from HandBrake. + /// + private static LoggingCallback loggingCallback; /// /// The callback for error messages from HandBrake. @@ -294,25 +289,25 @@ namespace HandBrake.ApplicationServices.Interop string x264Settings = Marshal.PtrToStringAnsi(ptr); - return x264Settings; - } - - /// - /// Gets the final size and PAR of the video, given anamorphic inputs. - /// - /// Anamorphic inputs. - /// The final size and PAR of the video. - public static Geometry GetAnamorphicSize(AnamorphicGeometry anamorphicGeometry) - { - string encode = JsonConvert.SerializeObject(anamorphicGeometry, Formatting.Indented, new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore }); - LogHelper.LogMessage(new LogMessage(encode, LogMessageType.encodeJson, LogLevel.debug)); - IntPtr json = HBFunctions.hb_set_anamorphic_size_json(Marshal.StringToHGlobalAnsi(encode)); - string result = Marshal.PtrToStringAnsi(json); - return JsonConvert.DeserializeObject(result); - } - - /// - /// Sends the message logged event to any registered listeners. + return x264Settings; + } + + /// + /// Gets the final size and PAR of the video, given anamorphic inputs. + /// + /// Anamorphic inputs. + /// The final size and PAR of the video. + public static Geometry GetAnamorphicSize(AnamorphicGeometry anamorphicGeometry) + { + string encode = JsonConvert.SerializeObject(anamorphicGeometry, Formatting.Indented, new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore }); + LogHelper.LogMessage(new LogMessage(encode, LogMessageType.encodeJson, LogLevel.debug)); + IntPtr json = HBFunctions.hb_set_anamorphic_size_json(Marshal.StringToHGlobalAnsi(encode)); + string result = Marshal.PtrToStringAnsi(json); + return JsonConvert.DeserializeObject(result); + } + + /// + /// Sends the message logged event to any registered listeners. /// /// /// The message to send. diff --git a/win/CS/HandBrake.ApplicationServices/Interop/Json/Encode/Audio.cs b/win/CS/HandBrake.ApplicationServices/Interop/Json/Encode/Audio.cs index 2661a8f17..4e4b61d6b 100644 --- a/win/CS/HandBrake.ApplicationServices/Interop/Json/Encode/Audio.cs +++ b/win/CS/HandBrake.ApplicationServices/Interop/Json/Encode/Audio.cs @@ -19,7 +19,7 @@ namespace HandBrake.ApplicationServices.Interop.Json.Encode /// /// Gets or sets the audio list. /// - public List AudioList { get; set; } + public List AudioList { get; set; } /// /// Gets or sets the copy mask. diff --git a/win/CS/HandBrake.ApplicationServices/Interop/Json/Encode/AudioList.cs b/win/CS/HandBrake.ApplicationServices/Interop/Json/Encode/AudioList.cs deleted file mode 100644 index 2f79ec7e6..000000000 --- a/win/CS/HandBrake.ApplicationServices/Interop/Json/Encode/AudioList.cs +++ /dev/null @@ -1,77 +0,0 @@ -// -------------------------------------------------------------------------------------------------------------------- -// -// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License. -// -// -// The audio list. -// -// -------------------------------------------------------------------------------------------------------------------- - -namespace HandBrake.ApplicationServices.Interop.Json.Encode -{ - /// - /// The audio list. - /// - public class AudioList - { - /// - /// Gets or sets the bitrate. - /// - public int? Bitrate { get; set; } - - /// - /// Gets or sets the compression level. - /// - public double? CompressionLevel { get; set; } - - /// - /// Gets or sets the drc. - /// - public double DRC { get; set; } - - /// - /// Gets or sets the encoder. - /// - public int Encoder { get; set; } - - /// - /// Gets or sets the gain. - /// - public double Gain { get; set; } - - /// - /// Gets or sets the mixdown. - /// - public int Mixdown { get; set; } - - /// - /// Gets or sets a value indicating whether normalize mix level. - /// - public bool NormalizeMixLevel { get; set; } - - /// - /// Gets or sets the quality. - /// - public double? Quality { get; set; } - - /// - /// Gets or sets the samplerate. - /// - public int Samplerate { get; set; } - - /// - /// Gets or sets the Name of the audio track. - /// - public string Name { get; set; } - - /// - /// Gets or sets the track. - /// - public int Track { get; set; } - - /// - /// Gets or sets the dither method. - /// - public int DitherMethod { get; set; } - } -} \ No newline at end of file diff --git a/win/CS/HandBrake.ApplicationServices/Interop/Json/Encode/AudioTrack.cs b/win/CS/HandBrake.ApplicationServices/Interop/Json/Encode/AudioTrack.cs new file mode 100644 index 000000000..0c628fbb0 --- /dev/null +++ b/win/CS/HandBrake.ApplicationServices/Interop/Json/Encode/AudioTrack.cs @@ -0,0 +1,77 @@ +// -------------------------------------------------------------------------------------------------------------------- +// +// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License. +// +// +// Represents an audio track to encode. +// +// -------------------------------------------------------------------------------------------------------------------- + +namespace HandBrake.ApplicationServices.Interop.Json.Encode +{ + /// + /// Represents an audio track to encode. + /// + public class AudioTrack + { + /// + /// Gets or sets the bitrate. + /// + public int? Bitrate { get; set; } + + /// + /// Gets or sets the compression level. + /// + public double? CompressionLevel { get; set; } + + /// + /// Gets or sets the drc. + /// + public double DRC { get; set; } + + /// + /// Gets or sets the encoder. + /// + public int Encoder { get; set; } + + /// + /// Gets or sets the gain. + /// + public double Gain { get; set; } + + /// + /// Gets or sets the mixdown. + /// + public int Mixdown { get; set; } + + /// + /// Gets or sets a value indicating whether normalize mix level. + /// + public bool NormalizeMixLevel { get; set; } + + /// + /// Gets or sets the quality. + /// + public double? Quality { get; set; } + + /// + /// Gets or sets the samplerate. + /// + public int Samplerate { get; set; } + + /// + /// Gets or sets the Name of the audio track. + /// + public string Name { get; set; } + + /// + /// Gets or sets the track. + /// + public int Track { get; set; } + + /// + /// Gets or sets the dither method. + /// + public int DitherMethod { get; set; } + } +} \ No newline at end of file diff --git a/win/CS/HandBrake.ApplicationServices/Interop/Json/Encode/Chapter.cs b/win/CS/HandBrake.ApplicationServices/Interop/Json/Encode/Chapter.cs new file mode 100644 index 000000000..567d0e7a3 --- /dev/null +++ b/win/CS/HandBrake.ApplicationServices/Interop/Json/Encode/Chapter.cs @@ -0,0 +1,22 @@ +// -------------------------------------------------------------------------------------------------------------------- +// +// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License. +// +// +// Represents a chapter to encode. +// +// -------------------------------------------------------------------------------------------------------------------- + +namespace HandBrake.ApplicationServices.Interop.Json.Encode +{ + /// + /// Represents a chapter to encode. + /// + public class Chapter + { + /// + /// Gets or sets the name. + /// + public string Name { get; set; } + } +} \ No newline at end of file diff --git a/win/CS/HandBrake.ApplicationServices/Interop/Json/Encode/ChapterList.cs b/win/CS/HandBrake.ApplicationServices/Interop/Json/Encode/ChapterList.cs deleted file mode 100644 index d58146510..000000000 --- a/win/CS/HandBrake.ApplicationServices/Interop/Json/Encode/ChapterList.cs +++ /dev/null @@ -1,22 +0,0 @@ -// -------------------------------------------------------------------------------------------------------------------- -// -// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License. -// -// -// The chapter list. -// -// -------------------------------------------------------------------------------------------------------------------- - -namespace HandBrake.ApplicationServices.Interop.Json.Encode -{ - /// - /// The chapter list. - /// - public class ChapterList - { - /// - /// Gets or sets the name. - /// - public string Name { get; set; } - } -} \ No newline at end of file diff --git a/win/CS/HandBrake.ApplicationServices/Interop/Json/Encode/Destination.cs b/win/CS/HandBrake.ApplicationServices/Interop/Json/Encode/Destination.cs index 42b3eaa40..9d22fb98a 100644 --- a/win/CS/HandBrake.ApplicationServices/Interop/Json/Encode/Destination.cs +++ b/win/CS/HandBrake.ApplicationServices/Interop/Json/Encode/Destination.cs @@ -19,7 +19,7 @@ namespace HandBrake.ApplicationServices.Interop.Json.Encode /// /// Gets or sets the chapter list. /// - public List ChapterList { get; set; } + public List ChapterList { get; set; } /// /// Gets or sets a value indicating whether chapter markers. diff --git a/win/CS/HandBrake.ApplicationServices/Interop/Json/Encode/JsonEncodeObject.cs b/win/CS/HandBrake.ApplicationServices/Interop/Json/Encode/JsonEncodeObject.cs index 9de1b8341..68baffcb4 100644 --- a/win/CS/HandBrake.ApplicationServices/Interop/Json/Encode/JsonEncodeObject.cs +++ b/win/CS/HandBrake.ApplicationServices/Interop/Json/Encode/JsonEncodeObject.cs @@ -39,7 +39,7 @@ namespace HandBrake.ApplicationServices.Interop.Json.Encode /// /// Gets or sets the meta data. /// - public MetaData Metadata { get; set; } + public Metadata Metadata { get; set; } /// /// Gets or sets the sequence id. diff --git a/win/CS/HandBrake.ApplicationServices/Interop/Json/Encode/MetaData.cs b/win/CS/HandBrake.ApplicationServices/Interop/Json/Encode/MetaData.cs index 86f06b8cb..d840d5d7f 100644 --- a/win/CS/HandBrake.ApplicationServices/Interop/Json/Encode/MetaData.cs +++ b/win/CS/HandBrake.ApplicationServices/Interop/Json/Encode/MetaData.cs @@ -12,7 +12,7 @@ namespace HandBrake.ApplicationServices.Interop.Json.Encode /// /// The meta data. /// - public class MetaData + public class Metadata { /// /// Gets or sets the album artist. diff --git a/win/CS/HandBrake.ApplicationServices/Interop/Json/Encode/SubtitleList.cs b/win/CS/HandBrake.ApplicationServices/Interop/Json/Encode/SubtitleList.cs deleted file mode 100644 index 71814c9e1..000000000 --- a/win/CS/HandBrake.ApplicationServices/Interop/Json/Encode/SubtitleList.cs +++ /dev/null @@ -1,52 +0,0 @@ -// -------------------------------------------------------------------------------------------------------------------- -// -// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License. -// -// -// The subtitle list. -// -// -------------------------------------------------------------------------------------------------------------------- - -namespace HandBrake.ApplicationServices.Interop.Json.Encode -{ - /// - /// The subtitle list. - /// - public class SubtitleList - { - /// - /// Gets or sets a value indicating whether burn. - /// - public bool Burn { get; set; } - - /// - /// Gets or sets a value indicating whether default. - /// - public bool Default { get; set; } - - /// - /// Gets or sets a value indicating whether force. - /// - public bool Forced { get; set; } - - /// - /// Gets or sets the id. - /// - public int ID { get; set; } - - /// - /// Gets or sets the offset. - /// - public int Offset { get; set; } - - /// - /// Gets or sets the track. - /// - public int Track { get; set; } - - /// - /// Gets or sets the srt. - /// - public SRT SRT { get; set; } - } -} \ No newline at end of file diff --git a/win/CS/HandBrake.ApplicationServices/Interop/Json/Encode/SubtitleTrack.cs b/win/CS/HandBrake.ApplicationServices/Interop/Json/Encode/SubtitleTrack.cs new file mode 100644 index 000000000..3a8aedec7 --- /dev/null +++ b/win/CS/HandBrake.ApplicationServices/Interop/Json/Encode/SubtitleTrack.cs @@ -0,0 +1,49 @@ +// -------------------------------------------------------------------------------------------------------------------- +// +// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License. +// +// -------------------------------------------------------------------------------------------------------------------- + +namespace HandBrake.ApplicationServices.Interop.Json.Encode +{ + /// + /// Represents a subtitle track to encode. + /// + public class SubtitleTrack + { + /// + /// Gets or sets a value indicating whether burn. + /// + public bool Burn { get; set; } + + /// + /// Gets or sets a value indicating whether default. + /// + public bool Default { get; set; } + + /// + /// Gets or sets a value indicating whether force. + /// + public bool Forced { get; set; } + + /// + /// Gets or sets the id. + /// + public int ID { get; set; } + + /// + /// Gets or sets the offset. + /// + public int Offset { get; set; } + + /// + /// Gets or sets the track. + /// + public int Track { get; set; } + + /// + /// Gets or sets the srt. + /// + public SRT SRT { get; set; } + } +} \ No newline at end of file diff --git a/win/CS/HandBrake.ApplicationServices/Interop/Json/Encode/Subtitles.cs b/win/CS/HandBrake.ApplicationServices/Interop/Json/Encode/Subtitles.cs index 5d38ba51d..13439eaa7 100644 --- a/win/CS/HandBrake.ApplicationServices/Interop/Json/Encode/Subtitles.cs +++ b/win/CS/HandBrake.ApplicationServices/Interop/Json/Encode/Subtitles.cs @@ -21,9 +21,9 @@ namespace HandBrake.ApplicationServices.Interop.Json.Encode /// public SubtitleSearch Search { get; set; } - /// - /// Gets or sets the subtitle list. - /// - public List SubtitleList { get; set; } - } + /// + /// Gets or sets the subtitle list. + /// + public List SubtitleList { get; set; } + } } \ No newline at end of file diff --git a/win/CS/HandBrake.ApplicationServices/Interop/Json/Scan/AudioTrack.cs b/win/CS/HandBrake.ApplicationServices/Interop/Json/Scan/AudioTrack.cs deleted file mode 100644 index b0491c734..000000000 --- a/win/CS/HandBrake.ApplicationServices/Interop/Json/Scan/AudioTrack.cs +++ /dev/null @@ -1,52 +0,0 @@ -// -------------------------------------------------------------------------------------------------------------------- -// -// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License. -// -// -// The audio list. -// -// -------------------------------------------------------------------------------------------------------------------- - -namespace HandBrake.ApplicationServices.Interop.Json.Scan -{ - /// - /// The audio list. - /// - public class AudioTrack - { - /// - /// Gets or sets the bit rate. - /// - public int BitRate { get; set; } - - /// - /// Gets or sets the channel layout. - /// - public int ChannelLayout { get; set; } - - /// - /// Gets or sets the description. - /// - public string Description { get; set; } - - /// - /// Gets or sets the language. - /// - public string Language { get; set; } - - /// - /// Gets or sets the language code. - /// - public string LanguageCode { get; set; } - - /// - /// Gets or sets the sample rate. - /// - public int SampleRate { get; set; } - - /// - /// Gets or sets the codec. - /// - public int Codec { get; set; } - } -} \ No newline at end of file diff --git a/win/CS/HandBrake.ApplicationServices/Interop/Json/Scan/ChapterTrack.cs b/win/CS/HandBrake.ApplicationServices/Interop/Json/Scan/ChapterTrack.cs deleted file mode 100644 index dc50f2dc8..000000000 --- a/win/CS/HandBrake.ApplicationServices/Interop/Json/Scan/ChapterTrack.cs +++ /dev/null @@ -1,27 +0,0 @@ -// -------------------------------------------------------------------------------------------------------------------- -// -// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License. -// -// -// The chapter list. -// -// -------------------------------------------------------------------------------------------------------------------- - -namespace HandBrake.ApplicationServices.Interop.Json.Scan -{ - /// - /// The chapter list. - /// - public class ChapterTrack - { - /// - /// Gets or sets the duration. - /// - public Duration Duration { get; set; } - - /// - /// Gets or sets the name. - /// - public string Name { get; set; } - } -} \ No newline at end of file diff --git a/win/CS/HandBrake.ApplicationServices/Interop/Json/Scan/MetaData.cs b/win/CS/HandBrake.ApplicationServices/Interop/Json/Scan/MetaData.cs deleted file mode 100644 index ecd26bd8f..000000000 --- a/win/CS/HandBrake.ApplicationServices/Interop/Json/Scan/MetaData.cs +++ /dev/null @@ -1,18 +0,0 @@ -// -------------------------------------------------------------------------------------------------------------------- -// -// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License. -// -// -// The meta data. -// -// -------------------------------------------------------------------------------------------------------------------- - -namespace HandBrake.ApplicationServices.Interop.Json.Scan -{ - /// - /// The meta data. - /// - public class MetaData - { - } -} \ No newline at end of file diff --git a/win/CS/HandBrake.ApplicationServices/Interop/Json/Scan/SourceAudioTrack.cs b/win/CS/HandBrake.ApplicationServices/Interop/Json/Scan/SourceAudioTrack.cs new file mode 100644 index 000000000..091f9a4f8 --- /dev/null +++ b/win/CS/HandBrake.ApplicationServices/Interop/Json/Scan/SourceAudioTrack.cs @@ -0,0 +1,49 @@ +// -------------------------------------------------------------------------------------------------------------------- +// +// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License. +// +// -------------------------------------------------------------------------------------------------------------------- + +namespace HandBrake.ApplicationServices.Interop.Json.Scan +{ + /// + /// An audio track from the source video. + /// + public class SourceAudioTrack + { + /// + /// Gets or sets the bit rate. + /// + public int BitRate { get; set; } + + /// + /// Gets or sets the channel layout. + /// + public int ChannelLayout { get; set; } + + /// + /// Gets or sets the description. + /// + public string Description { get; set; } + + /// + /// Gets or sets the language. + /// + public string Language { get; set; } + + /// + /// Gets or sets the language code. + /// + public string LanguageCode { get; set; } + + /// + /// Gets or sets the sample rate. + /// + public int SampleRate { get; set; } + + /// + /// Gets or sets the codec. + /// + public int Codec { get; set; } + } +} \ No newline at end of file diff --git a/win/CS/HandBrake.ApplicationServices/Interop/Json/Scan/SourceChapter.cs b/win/CS/HandBrake.ApplicationServices/Interop/Json/Scan/SourceChapter.cs new file mode 100644 index 000000000..fce479ff1 --- /dev/null +++ b/win/CS/HandBrake.ApplicationServices/Interop/Json/Scan/SourceChapter.cs @@ -0,0 +1,24 @@ +// -------------------------------------------------------------------------------------------------------------------- +// +// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License. +// +// -------------------------------------------------------------------------------------------------------------------- + +namespace HandBrake.ApplicationServices.Interop.Json.Scan +{ + /// + /// The a chapter from a video source. + /// + public class SourceChapter + { + /// + /// Gets or sets the duration. + /// + public Duration Duration { get; set; } + + /// + /// Gets or sets the name. + /// + public string Name { get; set; } + } +} \ No newline at end of file diff --git a/win/CS/HandBrake.ApplicationServices/Interop/Json/Scan/SourceMetadata.cs b/win/CS/HandBrake.ApplicationServices/Interop/Json/Scan/SourceMetadata.cs new file mode 100644 index 000000000..f575dc637 --- /dev/null +++ b/win/CS/HandBrake.ApplicationServices/Interop/Json/Scan/SourceMetadata.cs @@ -0,0 +1,18 @@ +// -------------------------------------------------------------------------------------------------------------------- +// +// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License. +// +// +// The meta data. +// +// -------------------------------------------------------------------------------------------------------------------- + +namespace HandBrake.ApplicationServices.Interop.Json.Scan +{ + /// + /// The meta data. + /// + public class SourceMetadata + { + } +} \ No newline at end of file diff --git a/win/CS/HandBrake.ApplicationServices/Interop/Json/Scan/SourceSubtitleTrack.cs b/win/CS/HandBrake.ApplicationServices/Interop/Json/Scan/SourceSubtitleTrack.cs new file mode 100644 index 000000000..3f3594a39 --- /dev/null +++ b/win/CS/HandBrake.ApplicationServices/Interop/Json/Scan/SourceSubtitleTrack.cs @@ -0,0 +1,37 @@ +// -------------------------------------------------------------------------------------------------------------------- +// +// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License. +// +// +// The subtitle list. +// +// -------------------------------------------------------------------------------------------------------------------- + +namespace HandBrake.ApplicationServices.Interop.Json.Scan +{ + /// + /// The subtitle list. + /// + public class SourceSubtitleTrack + { + /// + /// Gets or sets the format. + /// + public int Format { get; set; } + + /// + /// Gets or sets the language. + /// + public string Language { get; set; } + + /// + /// Gets or sets the language code. + /// + public string LanguageCode { get; set; } + + /// + /// Gets or sets the source. + /// + public int Source { get; set; } + } +} \ No newline at end of file diff --git a/win/CS/HandBrake.ApplicationServices/Interop/Json/Scan/SourceTitle.cs b/win/CS/HandBrake.ApplicationServices/Interop/Json/Scan/SourceTitle.cs index f70a15584..4947bbadb 100644 --- a/win/CS/HandBrake.ApplicationServices/Interop/Json/Scan/SourceTitle.cs +++ b/win/CS/HandBrake.ApplicationServices/Interop/Json/Scan/SourceTitle.cs @@ -23,18 +23,18 @@ namespace HandBrake.ApplicationServices.Interop.Json.Scan /// public int AngleCount { get; set; } - /// - /// Gets or sets the audio list. - /// - public List AudioList { get; set; } - - /// - /// Gets or sets the chapter list. - /// - public List ChapterList { get; set; } - - /// - /// Gets or sets the color. + /// + /// Gets or sets the audio list. + /// + public List AudioList { get; set; } + + /// + /// Gets or sets the chapter list. + /// + public List ChapterList { get; set; } + + /// + /// Gets or sets the color. /// public Color Color { get; set; } @@ -68,13 +68,13 @@ namespace HandBrake.ApplicationServices.Interop.Json.Scan /// public bool InterlaceDetected { get; set; } - /// - /// Gets or sets the meta data. - /// - public MetaData MetaData { get; set; } - - /// - /// Gets or sets the name. + /// + /// Gets or sets the meta data. + /// + public SourceMetadata MetaData { get; set; } + + /// + /// Gets or sets the name. /// public string Name { get; set; } @@ -88,13 +88,13 @@ namespace HandBrake.ApplicationServices.Interop.Json.Scan /// public int Playlist { get; set; } - /// - /// Gets or sets the subtitle list. - /// - public List SubtitleList { get; set; } - - /// - /// Gets or sets the type. + /// + /// Gets or sets the subtitle list. + /// + public List SubtitleList { get; set; } + + /// + /// Gets or sets the type. /// HB_DVD_TYPE = 0, HB_BD_TYPE, HB_STREAM_TYPE, HB_FF_STREAM_TYPE /// public int Type { get; set; } diff --git a/win/CS/HandBrake.ApplicationServices/Interop/Json/Scan/SubtitleTrack.cs b/win/CS/HandBrake.ApplicationServices/Interop/Json/Scan/SubtitleTrack.cs deleted file mode 100644 index 247801468..000000000 --- a/win/CS/HandBrake.ApplicationServices/Interop/Json/Scan/SubtitleTrack.cs +++ /dev/null @@ -1,37 +0,0 @@ -// -------------------------------------------------------------------------------------------------------------------- -// -// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License. -// -// -// The subtitle list. -// -// -------------------------------------------------------------------------------------------------------------------- - -namespace HandBrake.ApplicationServices.Interop.Json.Scan -{ - /// - /// The subtitle list. - /// - public class SubtitleTrack - { - /// - /// Gets or sets the format. - /// - public int Format { get; set; } - - /// - /// Gets or sets the language. - /// - public string Language { get; set; } - - /// - /// Gets or sets the language code. - /// - public string LanguageCode { get; set; } - - /// - /// Gets or sets the source. - /// - public int Source { get; set; } - } -} \ No newline at end of file diff --git a/win/CS/HandBrake.ApplicationServices/Interop/Model/Preview/PreviewSettings.cs b/win/CS/HandBrake.ApplicationServices/Interop/Model/Preview/PreviewSettings.cs index e2a07d1cc..af1a166ce 100644 --- a/win/CS/HandBrake.ApplicationServices/Interop/Model/Preview/PreviewSettings.cs +++ b/win/CS/HandBrake.ApplicationServices/Interop/Model/Preview/PreviewSettings.cs @@ -6,27 +6,52 @@ // The preview settings. // // -------------------------------------------------------------------------------------------------------------------- - -namespace HandBrake.ApplicationServices.Interop.Model.Preview -{ - using HandBrake.ApplicationServices.Services.Encode.Model; - - /// - /// The preview settings. - /// - public class PreviewSettings : EncodeTask - { - /// - /// Initializes a new instance of the class. - /// - /// - /// The task. - /// - public PreviewSettings(EncodeTask task) - : base(task) - { - } - - // TODO flesh this out into a proper model. - } -} + +namespace HandBrake.ApplicationServices.Interop.Model.Preview +{ + using HandBrake.ApplicationServices.Interop.Model.Encoding; + using HandBrake.ApplicationServices.Services.Encode.Model; + + /// + /// The preview settings. + /// + public class PreviewSettings + { + /// + /// Initializes a new instance of the class. + /// + public PreviewSettings() + { + } + + /// + /// Initializes a new instance of the class. + /// + /// The task. + public PreviewSettings(EncodeTask task) + { + } + + public Cropping Cropping { get; set; } + + public int MaxWidth { get; set; } + + public int MaxHeight { get; set; } + + public bool KeepDisplayAspect { get; set; } + + public int TitleNumber { get; set; } + + public Anamorphic Anamorphic { get; set; } + + public int? Modulus { get; set; } + + public int Width { get; set; } + + public int Height { get; set; } + + public int PixelAspectX { get; set; } + + public int PixelAspectY { get; set; } + } +} diff --git a/win/CS/HandBrake.ApplicationServices/Services/Encode/Factories/EncodeFactory.cs b/win/CS/HandBrake.ApplicationServices/Services/Encode/Factories/EncodeFactory.cs index 875cdc938..54b80b28c 100644 --- a/win/CS/HandBrake.ApplicationServices/Services/Encode/Factories/EncodeFactory.cs +++ b/win/CS/HandBrake.ApplicationServices/Services/Encode/Factories/EncodeFactory.cs @@ -14,20 +14,24 @@ namespace HandBrake.ApplicationServices.Services.Encode.Factories using System.Linq; using System.Runtime.InteropServices; - using HandBrake.ApplicationServices.Interop; - using HandBrake.ApplicationServices.Interop.HbLib; - using HandBrake.ApplicationServices.Interop.Helpers; - using HandBrake.ApplicationServices.Interop.Json.Encode; - using HandBrake.ApplicationServices.Interop.Json.Shared; - using HandBrake.ApplicationServices.Interop.Model.Encoding; + using HandBrake.ApplicationServices.Interop; + using HandBrake.ApplicationServices.Interop.HbLib; + using HandBrake.ApplicationServices.Interop.Helpers; + using HandBrake.ApplicationServices.Interop.Json; + using HandBrake.ApplicationServices.Interop.Json.Anamorphic; + using HandBrake.ApplicationServices.Interop.Json.Encode; + using HandBrake.ApplicationServices.Interop.Json.Shared; + using HandBrake.ApplicationServices.Interop.Model.Encoding; using HandBrake.ApplicationServices.Model; using HandBrake.ApplicationServices.Services.Encode.Model; - using HandBrake.ApplicationServices.Services.Encode.Model.Models; - using HandBrake.ApplicationServices.Utilities; - - - /// - /// This factory takes the internal EncodeJob object and turns it into a set of JSON models + using HandBrake.ApplicationServices.Services.Encode.Model.Models; + using HandBrake.ApplicationServices.Utilities; + + using AudioTrack = HandBrake.ApplicationServices.Services.Encode.Model.Models.AudioTrack; + using Subtitle = HandBrake.ApplicationServices.Interop.Json.Encode.Subtitles; + + /// + /// This factory takes the internal EncodeJob object and turns it into a set of JSON models /// that can be deserialized by libhb. /// internal class EncodeFactory @@ -47,23 +51,23 @@ namespace HandBrake.ApplicationServices.Services.Encode.Factories /// /// The configuration. /// - /// - /// The . - /// - internal static JsonEncodeObject Create(EncodeTask job, HBConfiguration configuration) - { - JsonEncodeObject encode = new JsonEncodeObject - { - SequenceID = 0, - Audio = CreateAudio(job), - Destination = CreateDestination(job), - Filters = CreateFilter(job), - PAR = CreatePAR(job), - Metadata = CreateMetaData(job), - Source = CreateSource(job, configuration), - Subtitle = CreateSubtitle(job), - Video = CreateVideo(job, configuration) - }; + /// + /// The . + /// + internal static JsonEncodeObject Create(EncodeTask job, HBConfiguration configuration) + { + JsonEncodeObject encode = new JsonEncodeObject + { + SequenceID = 0, + Audio = CreateAudio(job), + Destination = CreateDestination(job), + Filters = CreateFilters(job), + PAR = CreatePAR(job), + Metadata = CreateMetadata(job), + Source = CreateSource(job, configuration), + Subtitle = CreateSubtitle(job), + Video = CreateVideo(job, configuration) + }; return encode; } @@ -84,36 +88,36 @@ namespace HandBrake.ApplicationServices.Services.Encode.Factories { Range range = new Range(); switch (job.PointToPointMode) - { - case PointToPointMode.Chapters: - range.Type = "chapter"; - range.End = job.EndPoint; - range.Start = job.StartPoint; - break; - case PointToPointMode.Seconds: - range.Type = "time"; - range.Start = job.StartPoint * 90000; - range.End = (job.EndPoint - job.StartPoint) * 90000; - break; - case PointToPointMode.Frames: - range.Type = "frame"; - range.Start = job.StartPoint; - range.End = job.EndPoint; - break; - case PointToPointMode.Preview: - range.Type = "preview"; - range.Start = job.PreviewEncodeStartAt; - range.SeekPoints = configuration.PreviewScanCount; - range.End = job.PreviewEncodeDuration * 90000; - break; - } - - Source source = new Source - { - Title = job.Title, - Range = range, - Angle = job.Angle, - Path = job.Source, + { + case PointToPointMode.Chapters: + range.Type = "chapter"; + range.Start = job.StartPoint; + range.End = job.EndPoint; + break; + case PointToPointMode.Seconds: + range.Type = "time"; + range.Start = job.StartPoint * 90000; + range.End = (job.EndPoint - job.StartPoint) * 90000; + break; + case PointToPointMode.Frames: + range.Type = "frame"; + range.Start = job.StartPoint; + range.End = job.EndPoint; + break; + case PointToPointMode.Preview: + range.Type = "preview"; + range.Start = job.PreviewEncodeStartAt; + range.SeekPoints = configuration.PreviewScanCount; + range.End = job.PreviewEncodeDuration * 90000; + break; + } + + Source source = new Source + { + Title = job.Title, + Range = range, + Angle = job.Angle, + Path = job.Source, }; return source; } @@ -128,28 +132,28 @@ namespace HandBrake.ApplicationServices.Services.Encode.Factories /// The . /// private static Destination CreateDestination(EncodeTask job) - { - Destination destination = new Destination - { - File = job.Destination, - Mp4Options = new Mp4Options - { - IpodAtom = job.IPod5GSupport, - Mp4Optimize = job.OptimizeMP4 - }, - ChapterMarkers = job.IncludeChapterMarkers, - Mux = HBFunctions.hb_container_get_from_name(job.OutputFormat == OutputFormat.Mp4 ? "av_mp4" : "av_mkv"), // TODO tidy up. - ChapterList = new List() - }; - - if (job.IncludeChapterMarkers) - { - foreach (ChapterMarker item in job.ChapterNames) - { - ChapterList chapter = new ChapterList { Name = item.ChapterName }; - destination.ChapterList.Add(chapter); - } - } + { + Destination destination = new Destination + { + File = job.Destination, + Mp4Options = new Mp4Options + { + IpodAtom = job.IPod5GSupport, + Mp4Optimize = job.OptimizeMP4 + }, + ChapterMarkers = job.IncludeChapterMarkers, + Mux = HBFunctions.hb_container_get_from_name(job.OutputFormat == OutputFormat.Mp4 ? "av_mp4" : "av_mkv"), // TODO tidy up. + ChapterList = new List() + }; + + if (job.IncludeChapterMarkers) + { + foreach (ChapterMarker item in job.ChapterNames) + { + Chapter chapter = new Chapter { Name = item.ChapterName }; + destination.ChapterList.Add(chapter); + } + } return destination; } @@ -174,28 +178,28 @@ namespace HandBrake.ApplicationServices.Services.Encode.Factories /// /// The job. /// - /// - /// The . - /// - private static Subtitles CreateSubtitle(EncodeTask job) - { - Subtitles subtitle = new Subtitles - { - Search = - new SubtitleSearch - { - Enable = false, - Default = false, - Burn = false, - Forced = false - }, - SubtitleList = new List() - }; - - foreach (SubtitleTrack item in job.SubtitleTracks) - { - if (!item.IsSrtSubtitle) - { + /// + /// The . + /// + private static Subtitle CreateSubtitle(EncodeTask job) + { + Subtitles subtitle = new Subtitles + { + Search = + new SubtitleSearch + { + Enable = false, + Default = false, + Burn = false, + Forced = false + }, + SubtitleList = new List() + }; + + foreach (HandBrake.ApplicationServices.Services.Encode.Model.Models.SubtitleTrack item in job.SubtitleTracks) + { + if (!item.IsSrtSubtitle) + { // Handle Foreign Audio Search if (item.SourceTrack.TrackNumber == 0) { @@ -203,19 +207,27 @@ namespace HandBrake.ApplicationServices.Services.Encode.Factories subtitle.Search.Burn = item.Burned; subtitle.Search.Default = item.Default; subtitle.Search.Forced = item.Forced; - } - else - { - SubtitleList track = new SubtitleList { Burn = item.Burned, Default = item.Default, Forced = item.Forced, ID = item.SourceTrack.TrackNumber, Track = (item.SourceTrack.TrackNumber - 1) }; - subtitle.SubtitleList.Add(track); - } - } - else - { - SubtitleList track = new SubtitleList - { - Track = -1, // Indicates SRT - Default = item.Default, + } + else + { + HandBrake.ApplicationServices.Interop.Json.Encode.SubtitleTrack track = new HandBrake.ApplicationServices.Interop.Json.Encode.SubtitleTrack + { + Burn = item.Burned, + Default = item.Default, + Forced = item.Forced, + ID = item.SourceTrack.TrackNumber, + Track = (item.SourceTrack.TrackNumber - 1) + }; + + subtitle.SubtitleList.Add(track); + } + } + else + { + HandBrake.ApplicationServices.Interop.Json.Encode.SubtitleTrack track = new HandBrake.ApplicationServices.Interop.Json.Encode.SubtitleTrack + { + Track = -1, // Indicates SRT + Default = item.Default, Offset = item.SrtOffset, Burn = item.Burned, SRT = @@ -225,13 +237,13 @@ namespace HandBrake.ApplicationServices.Services.Encode.Factories Codeset = item.SrtCharCode, Language = item.SrtLang } - }; - - subtitle.SubtitleList.Add(track); - } - } - - return subtitle; + }; + + subtitle.SubtitleList.Add(track); + } + } + + return subtitle; } /// @@ -303,42 +315,42 @@ namespace HandBrake.ApplicationServices.Services.Encode.Factories /// The . /// private static Audio CreateAudio(EncodeTask job) - { - Audio audio = new Audio(); - - List copyMaskList = new List(); - if (job.AllowedPassthruOptions.AudioAllowAACPass) copyMaskList.Add(NativeConstants.HB_ACODEC_AAC_PASS); - if (job.AllowedPassthruOptions.AudioAllowAC3Pass) copyMaskList.Add(NativeConstants.HB_ACODEC_AC3_PASS); - if (job.AllowedPassthruOptions.AudioAllowDTSHDPass) copyMaskList.Add(NativeConstants.HB_ACODEC_DCA_HD_PASS); + { + Audio audio = new Audio(); + + List copyMaskList = new List(); + if (job.AllowedPassthruOptions.AudioAllowAACPass) copyMaskList.Add(NativeConstants.HB_ACODEC_AAC_PASS); + if (job.AllowedPassthruOptions.AudioAllowAC3Pass) copyMaskList.Add(NativeConstants.HB_ACODEC_AC3_PASS); + if (job.AllowedPassthruOptions.AudioAllowDTSHDPass) copyMaskList.Add(NativeConstants.HB_ACODEC_DCA_HD_PASS); if (job.AllowedPassthruOptions.AudioAllowDTSPass) copyMaskList.Add(NativeConstants.HB_ACODEC_DCA_PASS); if (job.AllowedPassthruOptions.AudioAllowEAC3Pass) copyMaskList.Add(NativeConstants.HB_ACODEC_EAC3_PASS); - if (job.AllowedPassthruOptions.AudioAllowFlacPass) copyMaskList.Add(NativeConstants.HB_ACODEC_FLAC_PASS); - if (job.AllowedPassthruOptions.AudioAllowMP3Pass) copyMaskList.Add(NativeConstants.HB_ACODEC_MP3_PASS); - if (job.AllowedPassthruOptions.AudioAllowTrueHDPass) copyMaskList.Add(NativeConstants.HB_ACODEC_TRUEHD_PASS); - audio.CopyMask = copyMaskList.ToArray(); - - HBAudioEncoder audioEncoder = HandBrakeEncoderHelpers.GetAudioEncoder(EnumHelper.GetShortName(job.AllowedPassthruOptions.AudioEncoderFallback)); - audio.FallbackEncoder = audioEncoder.Id; - - audio.AudioList = new List(); - foreach (AudioTrack item in job.AudioTracks) - { - HBAudioEncoder encoder = HandBrakeEncoderHelpers.GetAudioEncoder(ApplicationServices.Utilities.Converters.GetCliAudioEncoder(item.Encoder) ); - Validate.NotNull(encoder, "Unrecognized audio encoder:" + item.Encoder); - - HBMixdown mixdown = HandBrakeEncoderHelpers.GetMixdown(ApplicationServices.Utilities.Converters.GetCliMixDown(item.MixDown)); - Validate.NotNull(mixdown, "Unrecognized audio mixdown:" + ApplicationServices.Utilities.Converters.GetCliMixDown(item.MixDown)); - - AudioList audioTrack = new AudioList - { - Track = (item.Track.HasValue ? item.Track.Value : 0) - 1, - DRC = item.DRC, - Encoder = encoder.Id, - Gain = item.Gain, - Mixdown = mixdown.Id, - NormalizeMixLevel = false, - Samplerate = GetSampleRateRaw(item.SampleRate), - Name = item.TrackName, + if (job.AllowedPassthruOptions.AudioAllowFlacPass) copyMaskList.Add(NativeConstants.HB_ACODEC_FLAC_PASS); + if (job.AllowedPassthruOptions.AudioAllowMP3Pass) copyMaskList.Add(NativeConstants.HB_ACODEC_MP3_PASS); + if (job.AllowedPassthruOptions.AudioAllowTrueHDPass) copyMaskList.Add(NativeConstants.HB_ACODEC_TRUEHD_PASS); + audio.CopyMask = copyMaskList.ToArray(); + + HBAudioEncoder audioEncoder = HandBrakeEncoderHelpers.GetAudioEncoder(EnumHelper.GetShortName(job.AllowedPassthruOptions.AudioEncoderFallback)); + audio.FallbackEncoder = audioEncoder.Id; + + audio.AudioList = new List(); + foreach (AudioTrack item in job.AudioTracks) + { + HBAudioEncoder encoder = HandBrakeEncoderHelpers.GetAudioEncoder(ApplicationServices.Utilities.Converters.GetCliAudioEncoder(item.Encoder)); + Validate.NotNull(encoder, "Unrecognized audio encoder:" + item.Encoder); + + HBMixdown mixdown = HandBrakeEncoderHelpers.GetMixdown(ApplicationServices.Utilities.Converters.GetCliMixDown(item.MixDown)); + Validate.NotNull(mixdown, "Unrecognized audio mixdown:" + ApplicationServices.Utilities.Converters.GetCliMixDown(item.MixDown)); + + HandBrake.ApplicationServices.Interop.Json.Encode.AudioTrack audioTrack = new HandBrake.ApplicationServices.Interop.Json.Encode.AudioTrack + { + Track = (item.Track.HasValue ? item.Track.Value : 0) - 1, + DRC = item.DRC, + Encoder = encoder.Id, + Gain = item.Gain, + Mixdown = mixdown.Id, + NormalizeMixLevel = false, + Samplerate = GetSampleRateRaw(item.SampleRate), + Name = item.TrackName, }; if (!item.IsPassthru) @@ -352,15 +364,15 @@ namespace HandBrake.ApplicationServices.Services.Encode.Factories //if (item.EncodeRateType == AudioEncodeRateType.Compression) //{ // audioTrack.CompressionLevel = item.Compression; - //} - - //if (item.EncodeRateType == AudioEncodeRateType.Bitrate) - // { - audioTrack.Bitrate = item.Bitrate; - // } - } - - audio.AudioList.Add(audioTrack); + //} + + //if (item.EncodeRateType == AudioEncodeRateType.Bitrate) + // { + audioTrack.Bitrate = item.Bitrate; + // } + } + + audio.AudioList.Add(audioTrack); } return audio; @@ -394,17 +406,17 @@ namespace HandBrake.ApplicationServices.Services.Encode.Factories /// /// The job. /// - /// - /// The . - /// - private static Filters CreateFilter(EncodeTask job) - { - Filters filter = new Filters - { - FilterList = new List(), - Grayscale = job.Grayscale - }; - + /// + /// The . + /// + private static Filters CreateFilters(EncodeTask job) + { + Filters filter = new Filters + { + FilterList = new List(), + Grayscale = job.Grayscale + }; + // Detelecine if (job.Detelecine != Detelecine.Off) { @@ -509,21 +521,21 @@ namespace HandBrake.ApplicationServices.Services.Encode.Factories filter.FilterList.Add(filterItem); } - // CropScale Filter - Filter cropScale = new Filter - { - ID = (int)hb_filter_ids.HB_FILTER_CROP_SCALE, - Settings = - string.Format( - "{0}:{1}:{2}:{3}:{4}:{5}", - job.Width, - job.Height, - job.Cropping.Top, - job.Cropping.Bottom, - job.Cropping.Left, - job.Cropping.Right) - }; - filter.FilterList.Add(cropScale); + // CropScale Filter + Filter cropScale = new Filter + { + ID = (int)hb_filter_ids.HB_FILTER_CROP_SCALE, + Settings = + string.Format( + "{0}:{1}:{2}:{3}:{4}:{5}", + job.Width, + job.Height, + job.Cropping.Top, + job.Cropping.Bottom, + job.Cropping.Left, + job.Cropping.Right) + }; + filter.FilterList.Add(cropScale); // Rotate /* TODO NOT SUPPORTED YET. */ @@ -535,17 +547,17 @@ namespace HandBrake.ApplicationServices.Services.Encode.Factories /// The create meta data. /// /// - /// The job. - /// - /// - /// The . - /// - private static MetaData CreateMetaData(EncodeTask job) - { - MetaData metaData = new MetaData(); - - /* TODO NOT SUPPORTED YET. */ - return metaData; + /// The job. + /// + /// + /// The . + /// + private static Metadata CreateMetadata(EncodeTask job) + { + Metadata metaData = new Metadata(); + + /* TODO NOT SUPPORTED YET. */ + return metaData; } } } diff --git a/win/CS/HandBrake.ApplicationServices/Services/Scan/Interfaces/IScan.cs b/win/CS/HandBrake.ApplicationServices/Services/Scan/Interfaces/IScan.cs index 0d4c6b3c2..09f52eb66 100644 --- a/win/CS/HandBrake.ApplicationServices/Services/Scan/Interfaces/IScan.cs +++ b/win/CS/HandBrake.ApplicationServices/Services/Scan/Interfaces/IScan.cs @@ -44,13 +44,13 @@ namespace HandBrake.ApplicationServices.Services.Scan.Interfaces /// public interface IScan { - /// - /// Scan has Started - /// - event EventHandler ScanStared; - - /// - /// Scan has completed + /// + /// Scan has Started + /// + event EventHandler ScanStarted; + + /// + /// Scan has completed /// event ScanCompletedStatus ScanCompleted; diff --git a/win/CS/HandBrake.ApplicationServices/Services/Scan/LibScan.cs b/win/CS/HandBrake.ApplicationServices/Services/Scan/LibScan.cs index 6e16fa937..5eab75520 100644 --- a/win/CS/HandBrake.ApplicationServices/Services/Scan/LibScan.cs +++ b/win/CS/HandBrake.ApplicationServices/Services/Scan/LibScan.cs @@ -102,13 +102,13 @@ namespace HandBrake.ApplicationServices.Services.Scan #region Events - /// - /// Scan has Started - /// - public event EventHandler ScanStared; - - /// - /// Scan has completed + /// + /// Scan has Started + /// + public event EventHandler ScanStarted; + + /// + /// Scan has completed /// public event ScanCompletedStatus ScanCompleted; @@ -318,14 +318,14 @@ namespace HandBrake.ApplicationServices.Services.Scan HandBrakeUtils.SetDvdNav(!configuraiton.IsDvdNavDisabled); - this.ServiceLogMessage("Starting Scan ..."); - this.instance.StartScan(sourcePath.ToString(), previewCount, minDuration, title != 0 ? title : 0); - - if (this.ScanStared != null) - this.ScanStared(this, System.EventArgs.Empty); - } - catch (Exception exc) - { + this.ServiceLogMessage("Starting Scan ..."); + this.instance.StartScan(sourcePath.ToString(), previewCount, minDuration, title != 0 ? title : 0); + + if (this.ScanStarted != null) + this.ScanStarted(this, System.EventArgs.Empty); + } + catch (Exception exc) + { this.ServiceLogMessage("Scan Failed ..." + Environment.NewLine + exc); this.Stop(); @@ -488,28 +488,28 @@ namespace HandBrake.ApplicationServices.Services.Scan Playlist = title.Type == 1 ? string.Format(" {0:d5}.MPLS", title.Playlist).Trim() : null, FramerateNumerator = title.FrameRate.Num, FramerateDenominator = title.FrameRate.Den - }; - - int currentTrack = 1; - foreach (ChapterTrack chapter in title.ChapterList) - { - string chapterName = !string.IsNullOrEmpty(chapter.Name) ? chapter.Name : string.Empty; - converted.Chapters.Add(new Chapter(currentTrack, chapterName, new TimeSpan(chapter.Duration.Hours, chapter.Duration.Minutes, chapter.Duration.Seconds))); + }; + + int currentTrack = 1; + foreach (SourceChapter chapter in title.ChapterList) + { + string chapterName = !string.IsNullOrEmpty(chapter.Name) ? chapter.Name : string.Empty; + converted.Chapters.Add(new Chapter(currentTrack, chapterName, new TimeSpan(chapter.Duration.Hours, chapter.Duration.Minutes, chapter.Duration.Seconds))); currentTrack++; - } - - int currentAudioTrack = 1; - foreach (AudioTrack track in title.AudioList) - { - converted.AudioTracks.Add(new Audio(currentAudioTrack, track.Language, track.LanguageCode, track.Description, string.Empty, track.SampleRate, track.BitRate)); - currentAudioTrack++; - } - - int currentSubtitleTrack = 1; - foreach (SubtitleTrack track in title.SubtitleList) - { - SubtitleType convertedType = new SubtitleType(); - + } + + int currentAudioTrack = 1; + foreach (SourceAudioTrack track in title.AudioList) + { + converted.AudioTracks.Add(new Audio(currentAudioTrack, track.Language, track.LanguageCode, track.Description, string.Empty, track.SampleRate, track.BitRate)); + currentAudioTrack++; + } + + int currentSubtitleTrack = 1; + foreach (SourceSubtitleTrack track in title.SubtitleList) + { + SubtitleType convertedType = new SubtitleType(); + switch (track.Source) { case 0: -- cgit v1.2.3