From 52d4c21b22cfc91b63a680aa7e475cc0ca6012cb Mon Sep 17 00:00:00 2001 From: sr55 Date: Sat, 15 Apr 2017 12:26:59 +0100 Subject: WinGui: Handle HB_STATE_MUXING and HB_STATE_SEARCHING for better progress indication in the UI. #676 --- .../Interop/EventArgs/EncodeProgressEventArgs.cs | 36 +++++++++++++++++++++- .../Interop/HandBrakeInstance.cs | 6 ++-- .../Interop/HbLib/NativeConstants.cs | 1 + 3 files changed, 39 insertions(+), 4 deletions(-) (limited to 'win/CS/HandBrake.ApplicationServices/Interop') diff --git a/win/CS/HandBrake.ApplicationServices/Interop/EventArgs/EncodeProgressEventArgs.cs b/win/CS/HandBrake.ApplicationServices/Interop/EventArgs/EncodeProgressEventArgs.cs index 5fad3248c..0da2fd178 100644 --- a/win/CS/HandBrake.ApplicationServices/Interop/EventArgs/EncodeProgressEventArgs.cs +++ b/win/CS/HandBrake.ApplicationServices/Interop/EventArgs/EncodeProgressEventArgs.cs @@ -40,7 +40,13 @@ namespace HandBrake.ApplicationServices.Interop.EventArgs /// /// The pass count. /// - public EncodeProgressEventArgs(double fractionComplete, double currentFrameRate, double averageFrameRate, TimeSpan estimatedTimeLeft, int passId, int pass, int passCount) + /// + /// A flag to indicate we are muxing. + /// + /// + /// Gets a value indicating that we are in the searching process. + /// + public EncodeProgressEventArgs(double fractionComplete, double currentFrameRate, double averageFrameRate, TimeSpan estimatedTimeLeft, int passId, int pass, int passCount, bool isMuxing, bool isSearching) { this.FractionComplete = fractionComplete; this.CurrentFrameRate = currentFrameRate; @@ -49,6 +55,8 @@ namespace HandBrake.ApplicationServices.Interop.EventArgs this.PassId = passId; this.Pass = pass; this.PassCount = passCount; + this.IsMuxing = isMuxing; + this.IsSearching = isSearching; } /// @@ -91,5 +99,31 @@ namespace HandBrake.ApplicationServices.Interop.EventArgs /// Gets the pass count. /// public int PassCount { get; private set; } + + /// + /// Gets a value indicating that we are in the muxing process. + /// + public bool IsMuxing { get; private set; } + + /// + /// Gets a value indicating that we are in the searching process. + /// + public bool IsSearching { get; } + + /// + /// Gets a value indicating that we are doing a subtitle scan pass. + /// + public bool IsSubtitleScan + { + get + { + if (this.PassId == -1) + { + return true; + } + + return false; + } + } } } diff --git a/win/CS/HandBrake.ApplicationServices/Interop/HandBrakeInstance.cs b/win/CS/HandBrake.ApplicationServices/Interop/HandBrakeInstance.cs index de0f0b2bc..861a5edaf 100644 --- a/win/CS/HandBrake.ApplicationServices/Interop/HandBrakeInstance.cs +++ b/win/CS/HandBrake.ApplicationServices/Interop/HandBrakeInstance.cs @@ -492,7 +492,7 @@ namespace HandBrake.ApplicationServices.Interop this.log.LogMessage(statusJson, LogMessageType.Progress, LogLevel.Trace); JsonState state = JsonConvert.DeserializeObject(statusJson); - if (state != null && state.State == NativeConstants.HB_STATE_SCANNING) + if (state != null && (state.State == NativeConstants.HB_STATE_SCANNING || state.State == NativeConstants.HB_STATE_SEARCHING)) { if (this.ScanProgress != null) { @@ -529,12 +529,12 @@ namespace HandBrake.ApplicationServices.Interop JsonState state = JsonConvert.DeserializeObject(statusJson); - if (state != null && state.State == NativeConstants.HB_STATE_WORKING) + if (state != null && (state.State == NativeConstants.HB_STATE_WORKING || state.State == NativeConstants.HB_STATE_MUXING || state.State == NativeConstants.HB_STATE_SEARCHING)) { if (this.EncodeProgress != null) { var progressEventArgs = new EncodeProgressEventArgs(state.Working.Progress, state.Working.Rate, state.Working.RateAvg, new TimeSpan(state.Working.Hours, state.Working.Minutes, state.Working.Seconds), - state.Working.PassID, state.Working.Pass, state.Working.PassCount); + state.Working.PassID, state.Working.Pass, state.Working.PassCount, state.State == NativeConstants.HB_STATE_MUXING, state.State == NativeConstants.HB_STATE_SEARCHING); this.EncodeProgress(this, progressEventArgs); } diff --git a/win/CS/HandBrake.ApplicationServices/Interop/HbLib/NativeConstants.cs b/win/CS/HandBrake.ApplicationServices/Interop/HbLib/NativeConstants.cs index bc593539f..9f4615bbf 100644 --- a/win/CS/HandBrake.ApplicationServices/Interop/HbLib/NativeConstants.cs +++ b/win/CS/HandBrake.ApplicationServices/Interop/HbLib/NativeConstants.cs @@ -59,6 +59,7 @@ namespace HandBrake.ApplicationServices.Interop.HbLib public const int HB_STATE_PAUSED = 16; public const int HB_STATE_WORKDONE = 32; public const int HB_STATE_MUXING = 64; + public const int HB_STATE_SEARCHING = 128; // Keep aspect ratio values public const int HB_KEEP_WIDTH = 0x01; -- cgit v1.2.3