diff options
author | sr55 <[email protected]> | 2015-01-02 21:18:44 +0000 |
---|---|---|
committer | sr55 <[email protected]> | 2015-01-02 21:18:44 +0000 |
commit | 5381c32a099538cc0e63d5393f26c6aa607b5eee (patch) | |
tree | 1500398a8ce1a229ead477ccc83e95b657e7f2c8 /win/CS/HandBrake.ApplicationServices/Services/Encode/LibEncode.cs | |
parent | c919eaba0bdf52a41443e2845e445de9582c5de3 (diff) |
WinGui: Bug fixes to the libhb json encode factory and surrounding classes. Encoding is now working, but some settings are not fully honoured yet.
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@6681 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'win/CS/HandBrake.ApplicationServices/Services/Encode/LibEncode.cs')
-rw-r--r-- | win/CS/HandBrake.ApplicationServices/Services/Encode/LibEncode.cs | 48 |
1 files changed, 31 insertions, 17 deletions
diff --git a/win/CS/HandBrake.ApplicationServices/Services/Encode/LibEncode.cs b/win/CS/HandBrake.ApplicationServices/Services/Encode/LibEncode.cs index 8a046e0af..6ae5d1f60 100644 --- a/win/CS/HandBrake.ApplicationServices/Services/Encode/LibEncode.cs +++ b/win/CS/HandBrake.ApplicationServices/Services/Encode/LibEncode.cs @@ -11,18 +11,18 @@ namespace HandBrake.ApplicationServices.Services.Encode {
using System;
using System.Diagnostics;
+ using System.Linq;
using HandBrake.ApplicationServices.Model;
using HandBrake.ApplicationServices.Services.Encode.Interfaces;
+ using HandBrake.ApplicationServices.Services.Scan;
+ using HandBrake.ApplicationServices.Services.Scan.Model;
using HandBrake.ApplicationServices.Utilities;
using HandBrake.Interop;
using HandBrake.Interop.EventArgs;
using HandBrake.Interop.Interfaces;
using HandBrake.Interop.Model;
- using EncodeCompletedEventArgs = HandBrake.ApplicationServices.Services.Encode.EventArgs.EncodeCompletedEventArgs;
- using EncodeProgressEventArgs = HandBrake.ApplicationServices.Services.Encode.EventArgs.EncodeProgressEventArgs;
-
/// <summary>
/// LibHB Implementation of IEncode
/// </summary>
@@ -55,6 +55,8 @@ namespace HandBrake.ApplicationServices.Services.Encode /// </summary>
private QueueTask currentTask;
+ private Source scannedSource;
+
#endregion
/// <summary>
@@ -117,7 +119,7 @@ namespace HandBrake.ApplicationServices.Services.Encode {
try
{
- this.SetupLogging(job);
+ this.SetupLogging(job, true);
}
catch (Exception)
{
@@ -135,12 +137,14 @@ namespace HandBrake.ApplicationServices.Services.Encode this.instance.ScanCompleted += delegate
{
+ // Process into internal structures.
+ this.scannedSource = new Source { Titles = LibScan.ConvertTitles(this.instance.Titles, this.instance.FeatureTitle) }; // TODO work around the bad Internal API.
this.ScanCompleted(job, this.instance);
};
}
catch (Exception exc)
{
- this.InvokeEncodeCompleted(new EncodeCompletedEventArgs(false, exc, "An Error has occured.", this.currentTask.Task.Destination));
+ this.InvokeEncodeCompleted(new EventArgs.EncodeCompletedEventArgs(false, exc, "An Error has occured.", this.currentTask.Task.Destination));
}
}
@@ -207,7 +211,16 @@ namespace HandBrake.ApplicationServices.Services.Encode EncodeJob encodeJob = InteropModelCreator.GetEncodeJob(job);
// Start the Encode
- instance.StartEncode(encodeJob, job.Configuration.PreviewScanCount);
+ Title title = this.scannedSource.Titles.FirstOrDefault(t => t.TitleNumber == job.Task.Title);
+ if (title == null)
+ {
+ throw new Exception("Unable to get title for encoding. Encode Failed.");
+ }
+
+ Interop.Model.Scan.Title scannedTitle = new Interop.Model.Scan.Title { Resolution = new Size(title.Resolution.Width, title.Resolution.Height), ParVal = new Size(title.ParVal.Width, title.ParVal.Height) };
+
+ // TODO fix this tempory hack to pass in the required title information into the factory.
+ instance.StartEncode(encodeJob, scannedTitle, job.Configuration.PreviewScanCount);
// Fire the Encode Started Event
this.InvokeEncodeStarted(System.EventArgs.Empty);
@@ -237,6 +250,7 @@ namespace HandBrake.ApplicationServices.Services.Encode }
#region HandBrakeInstance Event Handlers.
+
/// <summary>
/// Log a message
/// </summary>
@@ -286,16 +300,16 @@ namespace HandBrake.ApplicationServices.Services.Encode /// <param name="e">
/// The Interop.EncodeProgressEventArgs.
/// </param>
- private void InstanceEncodeProgress(object sender, Interop.EventArgs.EncodeProgressEventArgs e)
+ private void InstanceEncodeProgress(object sender, EncodeProgressEventArgs e)
{
- EncodeProgressEventArgs args = new EncodeProgressEventArgs
+ EventArgs.EncodeProgressEventArgs args = new EventArgs.EncodeProgressEventArgs
{
- AverageFrameRate = e.AverageFrameRate,
- CurrentFrameRate = e.CurrentFrameRate,
- EstimatedTimeLeft = e.EstimatedTimeLeft,
- PercentComplete = e.FractionComplete * 100,
- Task = e.Pass,
- ElapsedTime = DateTime.Now - this.startTime,
+ AverageFrameRate = e.AverageFrameRate,
+ CurrentFrameRate = e.CurrentFrameRate,
+ EstimatedTimeLeft = e.EstimatedTimeLeft,
+ PercentComplete = e.FractionComplete * 100,
+ Task = e.Pass,
+ ElapsedTime = DateTime.Now - this.startTime,
};
this.InvokeEncodeStatusChanged(args);
@@ -310,14 +324,14 @@ namespace HandBrake.ApplicationServices.Services.Encode /// <param name="e">
/// The e.
/// </param>
- private void InstanceEncodeCompleted(object sender, Interop.EventArgs.EncodeCompletedEventArgs e)
+ private void InstanceEncodeCompleted(object sender, EncodeCompletedEventArgs e)
{
this.IsEncoding = false;
this.InvokeEncodeCompleted(
e.Error
- ? new EncodeCompletedEventArgs(false, null, string.Empty, this.currentTask.Task.Destination)
- : new EncodeCompletedEventArgs(true, null, string.Empty, this.currentTask.Task.Destination));
+ ? new EventArgs.EncodeCompletedEventArgs(false, null, string.Empty, this.currentTask.Task.Destination)
+ : new EventArgs.EncodeCompletedEventArgs(true, null, string.Empty, this.currentTask.Task.Destination));
this.ShutdownFileWriter();
}
|