summaryrefslogtreecommitdiffstats
path: root/win/C#/Parsing
diff options
context:
space:
mode:
authorsr55 <[email protected]>2009-05-13 19:50:47 +0000
committersr55 <[email protected]>2009-05-13 19:50:47 +0000
commit43b29fa60d2d30aa1802a7b913436f86cfe3d73f (patch)
tree80770c72e687ccebbf3cbe23679ab715c814cbce /win/C#/Parsing
parent78db7280456c556a3015f93ec54d579e2935085a (diff)
WinGui:
- The CLI status information can now optionally be displayed in the encode status bar in the GUI. - Fixed Scan and Encode cancel functions with a hack. It was killing CMD.exe, not HandBrakeCLI.exe git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@2416 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'win/C#/Parsing')
-rw-r--r--win/C#/Parsing/Parser.cs49
1 files changed, 47 insertions, 2 deletions
diff --git a/win/C#/Parsing/Parser.cs b/win/C#/Parsing/Parser.cs
index c15275030..9b0e6459e 100644
--- a/win/C#/Parsing/Parser.cs
+++ b/win/C#/Parsing/Parser.cs
@@ -6,6 +6,8 @@
using System.IO;
using System.Text.RegularExpressions;
+using System;
+using System.Globalization;
namespace Handbrake.Parsing
{
@@ -25,6 +27,19 @@ namespace Handbrake.Parsing
public delegate void ScanProgressEventHandler(object Sender, int CurrentTitle, int TitleCount);
/// <summary>
+ /// A delegate to handle encode progress updates // EXPERIMENTAL
+ /// </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
@@ -56,13 +71,18 @@ namespace Handbrake.Parsing
/// </summary>
public event ScanProgressEventHandler OnScanProgress;
+ #region Experimetnal Code
+ /// <summary>
+ /// Raised upon the catching of a "Scanning title # of #..." in the stream
+ /// </summary>
+ public event EncodeProgressEventHandler OnEncodeProgress;
+ #endregion
/// <summary>
/// Default constructor for this object
/// </summary>
/// <param name="baseStream">The stream to parse from</param>
- public Parser(Stream baseStream)
- : base(baseStream)
+ public Parser(Stream baseStream) : base(baseStream)
{
m_buffer = string.Empty;
}
@@ -92,5 +112,30 @@ namespace Handbrake.Parsing
return tmp;
}
+
+ /// <summary>
+ /// Pase the CLI status output (from standard output)
+ /// </summary>
+ public void readEncodeStatus()
+ {
+ CultureInfo culture = CultureInfo.CreateSpecificCulture("en-US");
+ string tmp = base.ReadLine();
+
+ Match 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, culture);
+ float currentFps = m.Groups[5].Value == string.Empty ? 0.0F : float.Parse(m.Groups[5].Value, culture);
+ float avgFps = m.Groups[6].Value == string.Empty ? 0.0F : float.Parse(m.Groups[6].Value, culture);
+ 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);
+ }
+ }
}
}