summaryrefslogtreecommitdiffstats
path: root/win
diff options
context:
space:
mode:
authorsr55 <[email protected]>2017-04-15 12:26:59 +0100
committersr55 <[email protected]>2017-04-15 12:27:19 +0100
commit52d4c21b22cfc91b63a680aa7e475cc0ca6012cb (patch)
treed742c17b8ddff744d10ec5ee79344355aa17a907 /win
parenta0fefdaf374c7e7b0bbf58482b86bac03d673a7c (diff)
WinGui: Handle HB_STATE_MUXING and HB_STATE_SEARCHING for better progress indication in the UI. #676
Diffstat (limited to 'win')
-rw-r--r--win/CS/HandBrake.ApplicationServices/Interop/EventArgs/EncodeProgressEventArgs.cs36
-rw-r--r--win/CS/HandBrake.ApplicationServices/Interop/HandBrakeInstance.cs6
-rw-r--r--win/CS/HandBrake.ApplicationServices/Interop/HbLib/NativeConstants.cs1
-rw-r--r--win/CS/HandBrakeWPF/Properties/ResourcesUI.Designer.cs27
-rw-r--r--win/CS/HandBrakeWPF/Properties/ResourcesUI.resx9
-rw-r--r--win/CS/HandBrakeWPF/Services/Encode/EventArgs/EncodeProgressEventArgs.cs35
-rw-r--r--win/CS/HandBrakeWPF/Services/Encode/LibEncode.cs4
-rw-r--r--win/CS/HandBrakeWPF/Services/Scan/EventArgs/ScanProgressEventArgs.cs5
-rw-r--r--win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs10
-rw-r--r--win/CS/HandBrakeWPF/ViewModels/QueueViewModel.cs42
10 files changed, 145 insertions, 30 deletions
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
/// <param name="passCount">
/// The pass count.
/// </param>
- public EncodeProgressEventArgs(double fractionComplete, double currentFrameRate, double averageFrameRate, TimeSpan estimatedTimeLeft, int passId, int pass, int passCount)
+ /// <param name="isMuxing">
+ /// A flag to indicate we are muxing.
+ /// </param>
+ /// <param name="isSearching">
+ /// Gets a value indicating that we are in the searching process.
+ /// </param>
+ 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;
}
/// <summary>
@@ -91,5 +99,31 @@ namespace HandBrake.ApplicationServices.Interop.EventArgs
/// Gets the pass count.
/// </summary>
public int PassCount { get; private set; }
+
+ /// <summary>
+ /// Gets a value indicating that we are in the muxing process.
+ /// </summary>
+ public bool IsMuxing { get; private set; }
+
+ /// <summary>
+ /// Gets a value indicating that we are in the searching process.
+ /// </summary>
+ public bool IsSearching { get; }
+
+ /// <summary>
+ /// Gets a value indicating that we are doing a subtitle scan pass.
+ /// </summary>
+ 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<JsonState>(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<JsonState>(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;
diff --git a/win/CS/HandBrakeWPF/Properties/ResourcesUI.Designer.cs b/win/CS/HandBrakeWPF/Properties/ResourcesUI.Designer.cs
index 0fee65fc9..c04e4e97e 100644
--- a/win/CS/HandBrakeWPF/Properties/ResourcesUI.Designer.cs
+++ b/win/CS/HandBrakeWPF/Properties/ResourcesUI.Designer.cs
@@ -754,6 +754,15 @@ namespace HandBrakeWPF.Properties {
}
/// <summary>
+ /// Looks up a localized string similar to Muxing: This may take a while....
+ /// </summary>
+ public static string MainView_Muxing {
+ get {
+ return ResourceManager.GetString("MainView_Muxing", resourceCulture);
+ }
+ }
+
+ /// <summary>
/// Looks up a localized string similar to Options.
/// </summary>
public static string MainView_Options {
@@ -817,6 +826,15 @@ namespace HandBrakeWPF.Properties {
}
/// <summary>
+ /// Looks up a localized string similar to Encoding: {0}, {1:00.00}%, Time Remaining: {2}, {3}.
+ /// </summary>
+ public static string MainView_ProgressStatusWithTask {
+ get {
+ return ResourceManager.GetString("MainView_ProgressStatusWithTask", resourceCulture);
+ }
+ }
+
+ /// <summary>
/// Looks up a localized string similar to Remove.
/// </summary>
public static string MainView_Remove {
@@ -835,6 +853,15 @@ namespace HandBrakeWPF.Properties {
}
/// <summary>
+ /// Looks up a localized string similar to Searching for start time.
+ /// </summary>
+ public static string MainView_Searching {
+ get {
+ return ResourceManager.GetString("MainView_Searching", resourceCulture);
+ }
+ }
+
+ /// <summary>
/// Looks up a localized string similar to Set Default.
/// </summary>
public static string MainView_SetDefault {
diff --git a/win/CS/HandBrakeWPF/Properties/ResourcesUI.resx b/win/CS/HandBrakeWPF/Properties/ResourcesUI.resx
index f6c92ea61..50a0c4bbd 100644
--- a/win/CS/HandBrakeWPF/Properties/ResourcesUI.resx
+++ b/win/CS/HandBrakeWPF/Properties/ResourcesUI.resx
@@ -899,4 +899,13 @@ This will not affect your current settings in the Subtitle tab.</value>
<data name="OptionsView_PlaySoundWhenDone" xml:space="preserve">
<value>Play a sound when the queue or single encode completes:</value>
</data>
+ <data name="MainView_Muxing" xml:space="preserve">
+ <value>Muxing: This may take a while...</value>
+ </data>
+ <data name="MainView_ProgressStatusWithTask" xml:space="preserve">
+ <value>Encoding: {0}, {1:00.00}%, Time Remaining: {2}, {3}</value>
+ </data>
+ <data name="MainView_Searching" xml:space="preserve">
+ <value>Searching for start time</value>
+ </data>
</root> \ No newline at end of file
diff --git a/win/CS/HandBrakeWPF/Services/Encode/EventArgs/EncodeProgressEventArgs.cs b/win/CS/HandBrakeWPF/Services/Encode/EventArgs/EncodeProgressEventArgs.cs
index 940be6568..784245af6 100644
--- a/win/CS/HandBrakeWPF/Services/Encode/EventArgs/EncodeProgressEventArgs.cs
+++ b/win/CS/HandBrakeWPF/Services/Encode/EventArgs/EncodeProgressEventArgs.cs
@@ -10,54 +10,45 @@
namespace HandBrakeWPF.Services.Encode.EventArgs
{
using System;
- using System.Runtime.Serialization;
/// <summary>
/// Encode Progress Event Args
/// </summary>
- [DataContract]
public class EncodeProgressEventArgs : EventArgs
{
/// <summary>
/// Gets or sets PercentComplete.
/// </summary>
- [DataMember]
public double PercentComplete { get; set; }
/// <summary>
/// Gets or sets CurrentFrameRate.
/// </summary>
- [DataMember]
public double CurrentFrameRate { get; set; }
/// <summary>
/// Gets or sets AverageFrameRate.
/// </summary>
- [DataMember]
public double AverageFrameRate { get; set; }
/// <summary>
/// Gets or sets EstimatedTimeLeft.
/// </summary>
- [DataMember]
public TimeSpan EstimatedTimeLeft { get; set; }
/// <summary>
/// Gets or sets Task.
/// </summary>
- [DataMember]
public int Task { get; set; }
/// <summary>
/// Gets or sets TaskCount.
/// </summary>
- [DataMember]
public int TaskCount { get; set; }
/// <summary>
/// Gets or sets ElapsedTime.
/// </summary>
- [DataMember]
public TimeSpan ElapsedTime { get; set; }
/// <summary>
@@ -70,5 +61,31 @@ namespace HandBrakeWPF.Services.Encode.EventArgs
/// 2: Encode second pass
/// </remarks>
public int PassId { get; set; }
+
+ /// <summary>
+ /// Gets a value indicating that we are in the muxing process.
+ /// </summary>
+ public bool IsMuxing { get; set; }
+
+ /// <summary>
+ /// Gets a value indicating that we are in the searching process.
+ /// </summary>
+ public bool IsSearching { get; set; }
+
+ /// <summary>
+ /// Gets a value indicating that we are doing a subtitle scan pass.
+ /// </summary>
+ public bool IsSubtitleScan
+ {
+ get
+ {
+ if (this.PassId == -1)
+ {
+ return true;
+ }
+
+ return false;
+ }
+ }
}
}
diff --git a/win/CS/HandBrakeWPF/Services/Encode/LibEncode.cs b/win/CS/HandBrakeWPF/Services/Encode/LibEncode.cs
index 03763d448..2ad5f0688 100644
--- a/win/CS/HandBrakeWPF/Services/Encode/LibEncode.cs
+++ b/win/CS/HandBrakeWPF/Services/Encode/LibEncode.cs
@@ -180,7 +180,9 @@ namespace HandBrakeWPF.Services.Encode
Task = e.Pass,
TaskCount = e.PassCount,
ElapsedTime = DateTime.Now - this.startTime,
- PassId = e.PassId
+ PassId = e.PassId,
+ IsMuxing = e.IsMuxing,
+ IsSearching = e.IsSearching
};
this.InvokeEncodeStatusChanged(args);
diff --git a/win/CS/HandBrakeWPF/Services/Scan/EventArgs/ScanProgressEventArgs.cs b/win/CS/HandBrakeWPF/Services/Scan/EventArgs/ScanProgressEventArgs.cs
index 8d815b746..113f7a923 100644
--- a/win/CS/HandBrakeWPF/Services/Scan/EventArgs/ScanProgressEventArgs.cs
+++ b/win/CS/HandBrakeWPF/Services/Scan/EventArgs/ScanProgressEventArgs.cs
@@ -10,30 +10,25 @@
namespace HandBrakeWPF.Services.Scan.EventArgs
{
using System;
- using System.Runtime.Serialization;
/// <summary>
/// Scan Progress Event Args
/// </summary>
- [DataContract]
public class ScanProgressEventArgs : EventArgs
{
/// <summary>
/// Gets or sets the title currently being scanned.
/// </summary>
- [DataMember]
public int CurrentTitle { get; set; }
/// <summary>
/// Gets or sets the total number of Titles.
/// </summary>
- [DataMember]
public int Titles { get; set; }
/// <summary>
/// Gets or sets the percentage.
/// </summary>
- [DataMember]
public decimal Percentage { get; set; }
}
}
diff --git a/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs
index 283111b11..9bb991efc 100644
--- a/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs
+++ b/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs
@@ -2420,7 +2420,7 @@ namespace HandBrakeWPF.ViewModels
if (this.queueProcessor.EncodeService.IsEncoding)
{
string jobsPending = string.Format(Resources.Main_JobsPending_addon, this.queueProcessor.Count);
- if (e.PassId == -1)
+ if (e.IsSubtitleScan)
{
this.ProgramStatusLabel = string.Format(Resources.MainViewModel_EncodeStatusChanged_SubScan_StatusLabel,
e.Task,
@@ -2430,6 +2430,14 @@ namespace HandBrakeWPF.ViewModels
e.ElapsedTime,
jobsPending);
}
+ else if (e.IsMuxing)
+ {
+ this.ProgramStatusLabel = ResourcesUI.MainView_Muxing;
+ }
+ else if (e.IsSearching)
+ {
+ this.ProgramStatusLabel = string.Format(ResourcesUI.MainView_ProgressStatusWithTask, ResourcesUI.MainView_Searching, e.PercentComplete, e.EstimatedTimeLeft, jobsPending);
+ }
else
{
this.ProgramStatusLabel =
diff --git a/win/CS/HandBrakeWPF/ViewModels/QueueViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/QueueViewModel.cs
index c5351d729..2267c1a44 100644
--- a/win/CS/HandBrakeWPF/ViewModels/QueueViewModel.cs
+++ b/win/CS/HandBrakeWPF/ViewModels/QueueViewModel.cs
@@ -519,16 +519,38 @@ namespace HandBrakeWPF.ViewModels
{
Execute.OnUIThread(() =>
{
- this.JobStatus =
- string.Format(
- Resources.QueueViewModel_QueueStatusDisplay,
- e.Task,
- e.TaskCount,
- e.PercentComplete,
- e.CurrentFrameRate,
- e.AverageFrameRate,
- e.EstimatedTimeLeft,
- e.ElapsedTime);
+ string jobsPending = string.Format(Resources.Main_JobsPending_addon, this.queueProcessor.Count);
+ if (e.IsSubtitleScan)
+ {
+ this.JobStatus = string.Format(Resources.MainViewModel_EncodeStatusChanged_SubScan_StatusLabel,
+ e.Task,
+ e.TaskCount,
+ e.PercentComplete,
+ e.EstimatedTimeLeft,
+ e.ElapsedTime,
+ jobsPending);
+ }
+ else if (e.IsMuxing)
+ {
+ this.JobStatus = ResourcesUI.MainView_Muxing;
+ }
+ else if (e.IsSearching)
+ {
+ this.JobStatus = string.Format(ResourcesUI.MainView_ProgressStatusWithTask, ResourcesUI.MainView_Searching, e.PercentComplete, e.EstimatedTimeLeft, jobsPending);
+ }
+ else
+ {
+ this.JobStatus =
+ string.Format(Resources.MainViewModel_EncodeStatusChanged_StatusLabel,
+ e.Task,
+ e.TaskCount,
+ e.PercentComplete,
+ e.CurrentFrameRate,
+ e.AverageFrameRate,
+ e.EstimatedTimeLeft,
+ e.ElapsedTime,
+ jobsPending);
+ }
});
}