\r
namespace Handbrake.CLI.Jobs\r
{\r
- public class Encode\r
+ public class Encode : Job\r
{\r
public override string ToString()\r
{\r
{\r
public class Job\r
{\r
- private string m_exec;\r
-\r
- private Process m_proc;\r
- /// <summary>\r
- /// The base process associated with this job\r
- /// </summary>\r
- public Process Process\r
- {\r
- get\r
- {\r
- return this.m_proc;\r
- }\r
- }\r
-\r
public Job()\r
{\r
}\r
\r
namespace Handbrake.CLI.Jobs\r
{\r
- public class ParseDVD\r
+ public class ParseDVD : Job\r
{\r
public override string ToString()\r
{\r
/// <param name="TitleCount">The total number of titiles to be processed</param>\r
public delegate void ScanProgressEventHandler(object Sender, int CurrentTitle, int TitleCount);\r
\r
+ /// <summary>\r
+ /// A delegate to handle encode progress updates\r
+ /// </summary>\r
+ /// <param name="Sender">The object which raised the event</param>\r
+ /// <param name="CurrentTask">The current task being processed from the queue</param>\r
+ /// <param name="TaskCount">The total number of tasks in queue</param>\r
+ /// <param name="PercentComplete">The percentage this task is complete</param>\r
+ /// <param name="CurrentFps">The current encoding fps</param>\r
+ /// <param name="AverageFps">The average encoding fps for this task</param>\r
+ /// <param name="TimeRemaining">The estimated time remaining for this task to complete</param>\r
+ public delegate void EncodeProgressEventHandler(object Sender, int CurrentTask, int TaskCount, float PercentComplete, float CurrentFps, float AverageFps, TimeSpan TimeRemaining);\r
+\r
/// <summary>\r
/// A simple wrapper around a StreamReader to keep track of the entire output from a cli process\r
/// </summary>\r
/// <summary>\r
/// Raised upon a new line being read from stdout/stderr\r
/// </summary>\r
- public static event DataReadEventHandler OnReadLine;\r
+ public event DataReadEventHandler OnReadLine;\r
\r
/// <summary>\r
/// Raised upon the entire stdout/stderr stream being read in a single call\r
/// </summary>\r
- public static event DataReadEventHandler OnReadToEnd;\r
+ public event DataReadEventHandler OnReadToEnd;\r
\r
/// <summary>\r
/// Raised upon the catching of a "Scanning title # of #..." in the stream\r
/// </summary>\r
- public static event ScanProgressEventHandler OnScanProgress;\r
+ public event ScanProgressEventHandler OnScanProgress;\r
+\r
+ public event EncodeProgressEventHandler OnEncodeProgress;\r
\r
/// <summary>\r
/// Default constructor for this object\r
{\r
OnScanProgress(this, int.Parse(m.Groups[1].Value), int.Parse(m.Groups[2].Value));\r
}\r
+ 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\))?");\r
+ if (m.Success && OnEncodeProgress != null)\r
+ {\r
+ int currentTask = int.Parse(m.Groups[1].Value);\r
+ int totalTasks = int.Parse(m.Groups[2].Value);\r
+ float percent = float.Parse(m.Groups[3].Value);\r
+ float currentFps = m.Groups[5].Value == string.Empty ? 0.0F : float.Parse(m.Groups[5].Value);\r
+ float avgFps = m.Groups[6].Value == string.Empty ? 0.0F : float.Parse(m.Groups[6].Value);\r
+ TimeSpan remaining = TimeSpan.Zero;\r
+ if (m.Groups[7].Value != string.Empty)\r
+ {\r
+ remaining = TimeSpan.Parse(m.Groups[7].Value + ":" + m.Groups[8].Value + ":" + m.Groups[9].Value);\r
+ }\r
+ OnEncodeProgress(this, currentTask, totalTasks, percent, currentFps, avgFps, remaining);\r
+ }\r
return tmp;\r
}\r
\r
public frmDvdInfo()\r
{\r
InitializeComponent();\r
- Parsing.Parser.OnReadLine += HandleParsedData;\r
- Parsing.Parser.OnReadToEnd += HandleParsedData;\r
this.rtf_dvdInfo.Text = string.Empty;\r
}\r
\r
- private void HandleParsedData(object Sender, string Data)\r
+ public void HandleParsedData(object Sender, string Data)\r
{\r
if (this.InvokeRequired)\r
{\r
this.btn_queue = new System.Windows.Forms.Button();\r
this.btn_encode = new System.Windows.Forms.Button();\r
this.Version = new System.Windows.Forms.Label();\r
+ this.tempEncodeLbl = new System.Windows.Forms.Label();\r
Label38 = new System.Windows.Forms.Label();\r
this.frmMainMenu.SuspendLayout();\r
this.GroupBox1.SuspendLayout();\r
this.slider_videoQuality.Location = new System.Drawing.Point(129, 90);\r
this.slider_videoQuality.Maximum = 100;\r
this.slider_videoQuality.Name = "slider_videoQuality";\r
- this.slider_videoQuality.Size = new System.Drawing.Size(167, 42);\r
+ this.slider_videoQuality.Size = new System.Drawing.Size(167, 45);\r
this.slider_videoQuality.TabIndex = 6;\r
this.slider_videoQuality.TickFrequency = 17;\r
this.slider_videoQuality.Scroll += new System.EventHandler(this.slider_videoQuality_Scroll);\r
this.Version.TabIndex = 415;\r
this.Version.Text = "Version 2.3";\r
// \r
+ // tempEncodeLbl\r
+ // \r
+ this.tempEncodeLbl.AutoSize = true;\r
+ this.tempEncodeLbl.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
+ this.tempEncodeLbl.Location = new System.Drawing.Point(370, 19);\r
+ this.tempEncodeLbl.Name = "tempEncodeLbl";\r
+ this.tempEncodeLbl.Size = new System.Drawing.Size(115, 13);\r
+ this.tempEncodeLbl.TabIndex = 418;\r
+ this.tempEncodeLbl.Text = "Encoding started...";\r
+ this.tempEncodeLbl.Visible = false;\r
+ // \r
// frmMain\r
// \r
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);\r
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;\r
this.ClientSize = new System.Drawing.Size(675, 621);\r
+ this.Controls.Add(this.tempEncodeLbl);\r
this.Controls.Add(this.lbl_update);\r
this.Controls.Add(this.btn_queue);\r
this.Controls.Add(this.btn_encode);\r
internal System.Windows.Forms.Label Version;\r
private System.Windows.Forms.Label lbl_chptWarn;\r
internal System.Windows.Forms.SaveFileDialog DVD_Save;\r
+ private System.Windows.Forms.Label tempEncodeLbl;\r
\r
}\r
}
\ No newline at end of file
private void btn_encode_Click(object sender, EventArgs e)\r
{\r
String query = "";\r
+ tempEncodeLbl.Visible = true;\r
\r
if (QueryEditorText.Text == "")\r
{\r
ThreadPool.QueueUserWorkItem(procMonitor, query);\r
}\r
\r
+ private void encode_OnEncodeProgress(object Sender, int CurrentTask, int TaskCount, float PercentComplete, float CurrentFps, float AverageFps, TimeSpan TimeRemaining)\r
+ {\r
+ if (this.InvokeRequired)\r
+ {\r
+ this.BeginInvoke(new Parsing.EncodeProgressEventHandler(encode_OnEncodeProgress),\r
+ new object[] { Sender, CurrentTask, TaskCount, PercentComplete, CurrentFps, AverageFps, TimeRemaining });\r
+ return;\r
+ }\r
+ tempEncodeLbl.Text = string.Format("Encode Progress: {0}%", PercentComplete);\r
+ }\r
+\r
private void procMonitor(object state)\r
{\r
Functions.CLI process = new Functions.CLI();\r
- hbProc = process.runCli(this, (string)state, false, false, false, false);\r
- MessageBox.Show("The encode process has now started.", "Status", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);\r
+ hbProc = process.runCli(this, (string)state, true, true, false, true);\r
+\r
+ Parsing.Parser encode = new Parsing.Parser(hbProc.StandardError.BaseStream);\r
+ //TODO: prevent this event from being subscribed more than once\r
+ encode.OnEncodeProgress += encode_OnEncodeProgress;\r
+ while (!encode.EndOfStream)\r
+ {\r
+ encode.ReadLine();\r
+ }\r
+\r
+ MessageBox.Show("The ncode process has now started.", "Status", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);\r
hbProc.WaitForExit();\r
hbProc.Close();\r
hbProc.Dispose();\r
this.inputFile = inputFile;\r
this.mainWindow = parent;\r
this.dvdInfo = dvdInfoWindow;\r
- Parsing.Parser.OnScanProgress += Parser_OnScanProgress;\r
}\r
\r
private void btn_ok_Click(object sender, EventArgs e)\r
hbProc = process.runCli(this, query, true, true, false, true);\r
\r
Parsing.Parser readData = new Parsing.Parser(hbProc.StandardError.BaseStream);\r
+ readData.OnScanProgress += Parser_OnScanProgress;\r
+ readData.OnReadLine += dvdInfo.HandleParsedData;\r
+ readData.OnReadToEnd += dvdInfo.HandleParsedData;\r
hbProc.Close();\r
\r
// Setup the parser\r