summaryrefslogtreecommitdiffstats
path: root/win/C#/Parsing/Parser.cs
diff options
context:
space:
mode:
authorbrianmario <[email protected]>2007-07-19 05:13:50 +0000
committerbrianmario <[email protected]>2007-07-19 05:13:50 +0000
commite4adf35f39f2108514495b1e8be3f49b98edb6b9 (patch)
tree099709921187c04703c22d2ca30a986a38fd5227 /win/C#/Parsing/Parser.cs
parent5a4f0a4e0089f3418df1e09eace439703bad9bb8 (diff)
WinGui:
updated parsing code events to not be static anymore added encode parsing to catch encode progress added OnEncodeProgress event git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@717 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'win/C#/Parsing/Parser.cs')
-rw-r--r--win/C#/Parsing/Parser.cs35
1 files changed, 32 insertions, 3 deletions
diff --git a/win/C#/Parsing/Parser.cs b/win/C#/Parsing/Parser.cs
index afd5471d0..f56999a0d 100644
--- a/win/C#/Parsing/Parser.cs
+++ b/win/C#/Parsing/Parser.cs
@@ -22,6 +22,18 @@ namespace Handbrake.Parsing
public delegate void ScanProgressEventHandler(object Sender, int CurrentTitle, int TitleCount);
/// <summary>
+ /// A delegate to handle encode progress updates
+ /// </summary>
+ /// <param name="Sender">The object which raised the event</param>
+ /// <param name="CurrentTask">The current task being processed from the queue</param>
+ /// <param name="TaskCount">The total number of tasks in queue</param>
+ /// <param name="PercentComplete">The percentage this task is complete</param>
+ /// <param name="CurrentFps">The current encoding fps</param>
+ /// <param name="AverageFps">The average encoding fps for this task</param>
+ /// <param name="TimeRemaining">The estimated time remaining for this task to complete</param>
+ public delegate void EncodeProgressEventHandler(object Sender, int CurrentTask, int TaskCount, float PercentComplete, float CurrentFps, float AverageFps, TimeSpan TimeRemaining);
+
+ /// <summary>
/// A simple wrapper around a StreamReader to keep track of the entire output from a cli process
/// </summary>
internal class Parser : StreamReader
@@ -41,17 +53,19 @@ namespace Handbrake.Parsing
/// <summary>
/// Raised upon a new line being read from stdout/stderr
/// </summary>
- public static event DataReadEventHandler OnReadLine;
+ public event DataReadEventHandler OnReadLine;
/// <summary>
/// Raised upon the entire stdout/stderr stream being read in a single call
/// </summary>
- public static event DataReadEventHandler OnReadToEnd;
+ public event DataReadEventHandler OnReadToEnd;
/// <summary>
/// Raised upon the catching of a "Scanning title # of #..." in the stream
/// </summary>
- public static event ScanProgressEventHandler OnScanProgress;
+ public event ScanProgressEventHandler OnScanProgress;
+
+ public event EncodeProgressEventHandler OnEncodeProgress;
/// <summary>
/// Default constructor for this object
@@ -75,6 +89,21 @@ namespace Handbrake.Parsing
{
OnScanProgress(this, int.Parse(m.Groups[1].Value), int.Parse(m.Groups[2].Value));
}
+ m = Regex.Match(tmp, @"^Encoding: task ([0-9]*) of ([0-9]*), ([0-9]*\.[0-9]*) %( \(([0-9]*\.[0-9]*) fps, avg ([0-9]*\.[0-9]*) fps, ETA ([0-9]{2})h([0-9]{2})m([0-9]{2})s\))?");
+ if (m.Success && OnEncodeProgress != null)
+ {
+ int currentTask = int.Parse(m.Groups[1].Value);
+ int totalTasks = int.Parse(m.Groups[2].Value);
+ float percent = float.Parse(m.Groups[3].Value);
+ float currentFps = m.Groups[5].Value == string.Empty ? 0.0F : float.Parse(m.Groups[5].Value);
+ float avgFps = m.Groups[6].Value == string.Empty ? 0.0F : float.Parse(m.Groups[6].Value);
+ TimeSpan remaining = TimeSpan.Zero;
+ if (m.Groups[7].Value != string.Empty)
+ {
+ remaining = TimeSpan.Parse(m.Groups[7].Value + ":" + m.Groups[8].Value + ":" + m.Groups[9].Value);
+ }
+ OnEncodeProgress(this, currentTask, totalTasks, percent, currentFps, avgFps, remaining);
+ }
return tmp;
}