diff options
author | sr55 <[email protected]> | 2007-08-22 18:48:40 +0000 |
---|---|---|
committer | sr55 <[email protected]> | 2007-08-22 18:48:40 +0000 |
commit | 5b79c836c803fe8b7706bf06485656f889478f7f (patch) | |
tree | 9da98d6aae57ef1d3f9281a1c7b51352030e3606 | |
parent | 784d350cf62da4ee14042e573d42765db84ddf1f (diff) |
WinGui:
- Added some more exception handling.
- Added workaround for issue with scanning on French systems causing a crash.
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@850 b64f7644-9d1e-0410-96f1-a4d463321fa5
-rw-r--r-- | win/C#/Parsing/DVD.cs | 15 | ||||
-rw-r--r-- | win/C#/Parsing/Title.cs | 101 | ||||
-rw-r--r-- | win/C#/frmDebug.cs | 1 | ||||
-rw-r--r-- | win/C#/frmMain.cs | 3 | ||||
-rw-r--r-- | win/C#/frmReadDVD.cs | 18 |
5 files changed, 65 insertions, 73 deletions
diff --git a/win/C#/Parsing/DVD.cs b/win/C#/Parsing/DVD.cs index 3ba212022..3249a23aa 100644 --- a/win/C#/Parsing/DVD.cs +++ b/win/C#/Parsing/DVD.cs @@ -1,17 +1,23 @@ using System;
using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Drawing;
using System.Text;
-using System.IO;
-using System.Text.RegularExpressions;
using System.Windows.Forms;
+using System.IO;
+using System.Threading;
+using System.Diagnostics;
namespace Handbrake.Parsing
{
+
/// <summary>
/// An object representing a scanned DVD
/// </summary>
public class DVD
{
+
private List<Title> m_titles;
/// <summary>
/// Collection of Titles associated with this DVD
@@ -39,11 +45,12 @@ namespace Handbrake.Parsing {
if ((char)output.Peek() == '+')
{
- thisDVD.m_titles.AddRange(Title.ParseList(output.ReadToEnd()));
+ string testb = output.ReadToEnd();
+ thisDVD.m_titles.AddRange(Title.ParseList(testb));
}
else
{
- output.ReadLine();
+ string test = output.ReadLine();
}
}
return thisDVD;
diff --git a/win/C#/Parsing/Title.cs b/win/C#/Parsing/Title.cs index 933be6d2d..a78fef78a 100644 --- a/win/C#/Parsing/Title.cs +++ b/win/C#/Parsing/Title.cs @@ -85,11 +85,11 @@ namespace Handbrake.Parsing }
}
- private float m_aspectRatio;
+ private string m_aspectRatio;
/// <summary>
/// The aspect ratio of this Title
/// </summary>
- public float AspectRatio
+ public string AspectRatio
{
get
{
@@ -139,71 +139,48 @@ namespace Handbrake.Parsing Title thisTitle = new Title();
// Match track number for this title
- Match m = Regex.Match(output.ReadLine(), @"^\+ title ([0-9]*):");
- if (m.Success)
+ try
{
- thisTitle.m_titleNumber = int.Parse(m.Groups[1].Value);
- }
-
- output.ReadLine();
- /*
- // Match vts, ttn, cell range and block count
- m = Regex.Match(output.ReadLine(), @"^ \+ vts ([0-9]*), ttn ([0-9]*), cells ([0-9]*)->([0-9]*) \(([0-9]*) blocks\)");
- if (m.Success)
- {
- // We don't need any of those values right now, so we'll just ignore them
- // and read a line from the buffer to get it out of the way.
- }
- */
- // Get duration for this title
- m = Regex.Match(output.ReadLine(), @"^ \+ duration: ([0-9]{2}:[0-9]{2}:[0-9]{2})");
- if (m.Success)
- {
- thisTitle.m_duration = TimeSpan.Parse(m.Groups[1].Value);
+ Match m = Regex.Match(output.ReadLine(), @"^\+ title ([0-9]*):");
+ if (m.Success)
+ {
+ thisTitle.m_titleNumber = int.Parse(m.Groups[1].Value);
+ }
+ output.ReadLine();
+
+ // Get duration for this title
+ m = Regex.Match(output.ReadLine(), @"^ \+ duration: ([0-9]{2}:[0-9]{2}:[0-9]{2})");
+ if (m.Success)
+ {
+ thisTitle.m_duration = TimeSpan.Parse(m.Groups[1].Value);
+ }
+
+ // Get resolution, aspect ratio and FPS for this title
+ m = Regex.Match(output.ReadLine(), @"^ \+ size: ([0-9]*)x([0-9]*), aspect: ([0-9]*\.[0-9]*), ([0-9]*\.[0-9]*) fps");
+ if (m.Success)
+ {
+ thisTitle.m_resolution = new Size(int.Parse(m.Groups[1].Value), int.Parse(m.Groups[2].Value));
+ thisTitle.m_aspectRatio = m.Groups[3].ToString(); // Converted to a String for French Lanuage based systems. Some weird exception thrown
+ // when trying to parse it as a float
+ // we don't need FPS right now
+ }
+
+ // Get autocrop region for this title
+ m = Regex.Match(output.ReadLine(), @"^ \+ autocrop: ([0-9]*)/([0-9]*)/([0-9]*)/([0-9]*)");
+ if (m.Success)
+ {
+ thisTitle.m_autoCrop = new int[4] { int.Parse(m.Groups[1].Value), int.Parse(m.Groups[2].Value), int.Parse(m.Groups[3].Value), int.Parse(m.Groups[4].Value) };
+ }
+
+ thisTitle.m_chapters.AddRange(Chapter.ParseList(output));
+ thisTitle.m_audioTracks.AddRange(AudioTrack.ParseList(output));
+ thisTitle.m_subtitles.AddRange(Subtitle.ParseList(output));
}
-
- // Get resolution, aspect ratio and FPS for this title
- m = Regex.Match(output.ReadLine(), @"^ \+ size: ([0-9]*)x([0-9]*), aspect: ([0-9]*\.[0-9]*), ([0-9]*\.[0-9]*) fps");
- if (m.Success)
+ catch (Exception exc)
{
- thisTitle.m_resolution = new Size(int.Parse(m.Groups[1].Value), int.Parse(m.Groups[2].Value));
- thisTitle.m_aspectRatio = float.Parse(m.Groups[3].Value);
- // we don't need FPS right now
+ MessageBox.Show(exc.ToString());
}
-
- // Get autocrop region for this title
- m = Regex.Match(output.ReadLine(), @"^ \+ autocrop: ([0-9]*)/([0-9]*)/([0-9]*)/([0-9]*)");
- if (m.Success)
- {
- thisTitle.m_autoCrop = new int[4] { int.Parse(m.Groups[1].Value), int.Parse(m.Groups[2].Value), int.Parse(m.Groups[3].Value), int.Parse(m.Groups[4].Value) };
- }
-
- /*
- *
- * A Few Bugs that need fixed.
- *
- *
- * Problem 1
- * There is a small problem here... What happens if the DVD has no Subtitles? or Handbrake misses the Audio or Chapter track
- * data due to an error.
- *
- * hbcli will sit in a suspended state until it is forcefully closed.
- *
- * Problem 2
- * See AudioTrack.cs Line 80 for details
- *
- * Problem 3
- * Doesn't seem to support DVD's where the first track is 0 instead of 1, and only includes 1 title (TS/MPG files)
- * Simply Doesn't list any titles.
- *
- *
- */
-
- thisTitle.m_chapters.AddRange(Chapter.ParseList(output));
- thisTitle.m_audioTracks.AddRange(AudioTrack.ParseList(output));
- thisTitle.m_subtitles.AddRange(Subtitle.ParseList(output));
-
return thisTitle;
}
diff --git a/win/C#/frmDebug.cs b/win/C#/frmDebug.cs index 450bc088b..a6d05b197 100644 --- a/win/C#/frmDebug.cs +++ b/win/C#/frmDebug.cs @@ -19,5 +19,6 @@ namespace Handbrake {
this.Close();
}
+
}
}
\ No newline at end of file diff --git a/win/C#/frmMain.cs b/win/C#/frmMain.cs index c70b71c9f..d3873c407 100644 --- a/win/C#/frmMain.cs +++ b/win/C#/frmMain.cs @@ -1228,9 +1228,10 @@ namespace Handbrake }
}
}
- catch (Exception)
+ catch (Exception exc)
{
// No need to throw an error here.
+ // Note on non english systems, this will throw an error because of double.Parse(lbl_Aspect.Text); not working.
}
diff --git a/win/C#/frmReadDVD.cs b/win/C#/frmReadDVD.cs index ca6d23342..ad5551188 100644 --- a/win/C#/frmReadDVD.cs +++ b/win/C#/frmReadDVD.cs @@ -20,7 +20,7 @@ namespace Handbrake private Parsing.DVD thisDvd;
private Process hbProc;
private delegate void UpdateUIHandler();
- private int cancel = 0;
+ //private int cancel = 0;
public frmReadDVD(string inputFile, frmMain parent, frmDvdInfo dvdInfoWindow)
{
@@ -32,7 +32,7 @@ namespace Handbrake private void btn_ok_Click(object sender, EventArgs e)
{
-
+
try
{
btn_ok.Enabled = false;
@@ -90,22 +90,27 @@ namespace Handbrake string strCmdLine = "cmd /c " + '"' + '"' + appPath + "\\hbcli.exe" + '"' + " -i" + '"' + inputFile + '"' + " -t0 >" + '"'+ appPath + "\\dvdinfo.dat" + '"' + " 2>&1" + '"';
Process hbproc = Process.Start("CMD.exe", strCmdLine);
hbproc.WaitForExit();
+ hbproc.Dispose();
+ hbproc.Close();
StreamReader sr = new StreamReader(appPath + "dvdinfo.dat");
-
thisDvd = Parsing.DVD.Parse(sr);
sr.Close();
+
Console.ReadLine();
+
updateUIElements();
}
catch (Exception exc)
{
MessageBox.Show(exc.ToString());
}
- //*********************************************************************************************************************************************
+ }
+
+ //*********************************************************************************************************************************************
/*
* This has been temporily disabled due to the stderr issue
*
@@ -125,7 +130,8 @@ namespace Handbrake process.closeCLI();
}
*/
- }
+ //*********************************************************************************************************************************************
+
/*private void Parser_OnScanProgress(object Sender, int CurrentTitle, int TitleCount)
{
@@ -147,7 +153,7 @@ namespace Handbrake try
{
this.Close();
- cancel = 1;
+ //cancel = 1;
}
catch (Exception exc)
{
|