diff options
author | sr55 <[email protected]> | 2013-08-24 16:40:26 +0000 |
---|---|---|
committer | sr55 <[email protected]> | 2013-08-24 16:40:26 +0000 |
commit | f8e7adc789a0a426907bad279c0c6741da32aba5 (patch) | |
tree | f1195bfc0e45a9056d7f29adc80b94db5d9fc860 /win | |
parent | 2526f515e8221cf8a955a3ea2dd405806d3aa259 (diff) |
WinGui: Additional fixes to libhb logging, libdvdnav option and min duration setting.
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@5745 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'win')
5 files changed, 97 insertions, 30 deletions
diff --git a/win/CS/HandBrake.ApplicationServices/Services/LibScan.cs b/win/CS/HandBrake.ApplicationServices/Services/LibScan.cs index a082bd2a4..d6f312e24 100644 --- a/win/CS/HandBrake.ApplicationServices/Services/LibScan.cs +++ b/win/CS/HandBrake.ApplicationServices/Services/LibScan.cs @@ -53,6 +53,11 @@ namespace HandBrake.ApplicationServices.Services private readonly IHandBrakeInstance instance;
/// <summary>
+ /// The user setting service.
+ /// </summary>
+ private readonly IUserSettingService userSettingService;
+
+ /// <summary>
/// Log data from HandBrakeInstance
/// </summary>
private readonly StringBuilder logging;
@@ -90,13 +95,17 @@ namespace HandBrake.ApplicationServices.Services /// <param name="handBrakeInstance">
/// The hand Brake Instance.
/// </param>
- public LibScan(IHandBrakeInstance handBrakeInstance)
+ /// <param name="userSettingService">
+ /// The user Setting Service.
+ /// </param>
+ public LibScan(IHandBrakeInstance handBrakeInstance, IUserSettingService userSettingService)
{
logging = new StringBuilder();
header = GeneralUtilities.CreateCliLogHeader();
instance = handBrakeInstance;
+ this.userSettingService = userSettingService;
instance.Initialize(1);
instance.ScanProgress += this.InstanceScanProgress;
instance.ScanCompleted += this.InstanceScanCompleted;
@@ -170,7 +179,28 @@ namespace HandBrake.ApplicationServices.Services /// </param>
public void Scan(string sourcePath, int title, int previewCount, Action<bool> postAction)
{
+ // Clear down the logging
this.logging.Clear();
+
+
+ try
+ {
+ // Make we don't pick up a stale last_scan_log_xyz.txt (and that we have rights to the file)
+ if (File.Exists(dvdInfoPath))
+ {
+ File.Delete(dvdInfoPath);
+ }
+ }
+ catch (Exception)
+ {
+ // Do nothing.
+ }
+
+ if (!Directory.Exists(Path.GetDirectoryName(dvdInfoPath)))
+ {
+ Directory.CreateDirectory(Path.GetDirectoryName(dvdInfoPath));
+ }
+
scanLog = new StreamWriter(dvdInfoPath);
Thread t = new Thread(unused => this.ScanSource(sourcePath, title, previewCount));
@@ -236,10 +266,13 @@ namespace HandBrake.ApplicationServices.Services if (this.ScanStared != null)
this.ScanStared(this, new EventArgs());
- if (title != 0)
- instance.StartScan(sourcePath.ToString(), previewCount, title);
- else
- instance.StartScan(sourcePath.ToString(), previewCount);
+ TimeSpan minDuration =
+ TimeSpan.FromSeconds(
+ this.userSettingService.GetUserSetting<int>(ASUserSettingConstants.MinScanDuration));
+
+ HandBrakeUtils.SetDvdNav(this.userSettingService.GetUserSetting<bool>(ASUserSettingConstants.DisableLibDvdNav));
+
+ this.instance.StartScan(sourcePath.ToString(), previewCount, minDuration, title != 0 ? title : 0);
}
catch (Exception exc)
{
diff --git a/win/CS/HandBrake.Interop/HandBrakeInterop/HandBrakeInstance.cs b/win/CS/HandBrake.Interop/HandBrakeInterop/HandBrakeInstance.cs index 7557ed94f..b76592d9a 100644 --- a/win/CS/HandBrake.Interop/HandBrakeInterop/HandBrakeInstance.cs +++ b/win/CS/HandBrake.Interop/HandBrakeInterop/HandBrakeInstance.cs @@ -188,7 +188,16 @@ namespace HandBrake.Interop this.StartScan(path, previewCount, minDuration, 0);
}
- public void StartScan(string path, int previewCount)
+ /// <summary>
+ /// The start scan.
+ /// </summary>
+ /// <param name="path">
+ /// The path.
+ /// </param>
+ /// <param name="previewCount">
+ /// The preview count.
+ /// </param>
+ public void StartScan(string path, int previewCount)
{
this.StartScan(path, previewCount, TimeSpan.FromSeconds(10), 0);
}
@@ -204,6 +213,29 @@ namespace HandBrake.Interop this.StartScan(path, previewCount, TimeSpan.Zero, titleIndex);
}
+ /// <summary>
+ /// Starts a scan of the given path.
+ /// </summary>
+ /// <param name="path">The path of the video to scan.</param>
+ /// <param name="previewCount">The number of previews to make on each title.</param>
+ /// <param name="minDuration">The minimum duration of a title to show up on the scan.</param>
+ /// <param name="titleIndex">The title index to scan (1-based, 0 for all titles).</param>
+ public void StartScan(string path, int previewCount, TimeSpan minDuration, int titleIndex)
+ {
+ this.previewCount = previewCount;
+ HBFunctions.hb_scan(this.hbHandle, path, titleIndex, previewCount, 1, (ulong)(minDuration.TotalSeconds * 90000));
+ this.scanPollTimer = new System.Timers.Timer();
+ this.scanPollTimer.Interval = ScanPollIntervalMs;
+
+ // Lambda notation used to make sure we can view any JIT exceptions the method throws
+ this.scanPollTimer.Elapsed += (o, e) =>
+ {
+ this.PollScanProgress();
+ };
+ this.scanPollTimer.Start();
+ }
+
+
/// <summary>
/// Stops an ongoing scan.
/// </summary>
@@ -722,28 +754,6 @@ namespace HandBrake.Interop }
/// <summary>
- /// Starts a scan of the given path.
- /// </summary>
- /// <param name="path">The path of the video to scan.</param>
- /// <param name="previewCount">The number of previews to make on each title.</param>
- /// <param name="minDuration">The minimum duration of a title to show up on the scan.</param>
- /// <param name="titleIndex">The title index to scan (1-based, 0 for all titles).</param>
- private void StartScan(string path, int previewCount, TimeSpan minDuration, int titleIndex)
- {
- this.previewCount = previewCount;
- HBFunctions.hb_scan(this.hbHandle, path, titleIndex, previewCount, 1, (ulong)(minDuration.TotalSeconds * 90000));
- this.scanPollTimer = new System.Timers.Timer();
- this.scanPollTimer.Interval = ScanPollIntervalMs;
-
- // Lambda notation used to make sure we can view any JIT exceptions the method throws
- this.scanPollTimer.Elapsed += (o, e) =>
- {
- this.PollScanProgress();
- };
- this.scanPollTimer.Start();
- }
-
- /// <summary>
/// Checks the status of the ongoing scan.
/// </summary>
private void PollScanProgress()
diff --git a/win/CS/HandBrake.Interop/HandBrakeInterop/HbLib/HbFunctions.cs b/win/CS/HandBrake.Interop/HandBrakeInterop/HbLib/HbFunctions.cs index 861fdb82a..68f7d0177 100644 --- a/win/CS/HandBrake.Interop/HandBrakeInterop/HbLib/HbFunctions.cs +++ b/win/CS/HandBrake.Interop/HandBrakeInterop/HbLib/HbFunctions.cs @@ -400,5 +400,8 @@ namespace HandBrake.Interop.HbLib [DllImport("hb.dll", EntryPoint = "hb_qsv_available", CallingConvention = CallingConvention.Cdecl)]
public static extern int hb_qsv_available();
+
+ [DllImport("hb.dll", EntryPoint = "hb_qsv_info_init", CallingConvention = CallingConvention.Cdecl)]
+ public static extern int hb_qsv_info_init();
}
}
diff --git a/win/CS/HandBrake.Interop/HandBrakeInterop/Interfaces/IHandBrakeInstance.cs b/win/CS/HandBrake.Interop/HandBrakeInterop/Interfaces/IHandBrakeInstance.cs index 1b0f8b354..874fd1e23 100644 --- a/win/CS/HandBrake.Interop/HandBrakeInterop/Interfaces/IHandBrakeInstance.cs +++ b/win/CS/HandBrake.Interop/HandBrakeInterop/Interfaces/IHandBrakeInstance.cs @@ -212,6 +212,24 @@ namespace HandBrake.Interop.Interfaces /// </param>
void StartScan(string path, int previewCount, int titleIndex);
+
+ /// <summary>
+ /// Starts a scan of the given path.
+ /// </summary>
+ /// <param name="path">
+ /// The path of the video to scan.
+ /// </param>
+ /// <param name="previewCount">
+ /// The number of previews to make on each title.
+ /// </param>
+ /// <param name="minDuration">
+ /// The min Duration.
+ /// </param>
+ /// <param name="titleIndex">
+ /// The title index to scan (1-based, 0 for all titles).
+ /// </param>
+ void StartScan(string path, int previewCount, TimeSpan minDuration, int titleIndex);
+
/// <summary>
/// Stops the current encode.
/// </summary>
diff --git a/win/CS/HandBrakeWPF/Services/ScanServiceWrapper.cs b/win/CS/HandBrakeWPF/Services/ScanServiceWrapper.cs index 701579d5b..073105694 100644 --- a/win/CS/HandBrakeWPF/Services/ScanServiceWrapper.cs +++ b/win/CS/HandBrakeWPF/Services/ScanServiceWrapper.cs @@ -45,10 +45,13 @@ namespace HandBrakeWPF.Services /// <summary>
/// Initializes a new instance of the <see cref="ScanServiceWrapper"/> class.
/// </summary>
- public ScanServiceWrapper()
+ /// <param name="userSettingService">
+ /// The user Setting Service.
+ /// </param>
+ public ScanServiceWrapper(IUserSettingService userSettingService)
{
HandbrakeInstance = new HandBrakeInstance();
- this.scanService = new LibScan(HandbrakeInstance);
+ this.scanService = new LibScan(HandbrakeInstance, userSettingService);
this.scanService.ScanCompleted += this.ScanServiceScanCompleted;
this.scanService.ScanStared += this.ScanServiceScanStared;
this.scanService.ScanStatusChanged += this.ScanServiceScanStatusChanged;
|