diff options
Diffstat (limited to 'win/CS/HandBrake.Interop/HandBrakeInterop')
7 files changed, 111 insertions, 23 deletions
diff --git a/win/CS/HandBrake.Interop/HandBrakeInterop/HandBrakeInstance.cs b/win/CS/HandBrake.Interop/HandBrakeInterop/HandBrakeInstance.cs index cdb368c9a..a36e672ca 100644 --- a/win/CS/HandBrake.Interop/HandBrakeInterop/HandBrakeInstance.cs +++ b/win/CS/HandBrake.Interop/HandBrakeInterop/HandBrakeInstance.cs @@ -389,6 +389,7 @@ namespace HandBrake.Interop /// <param name="scanPreviewCount">
/// The scan Preview Count.
/// </param>
+ [HandleProcessCorruptedStateExceptions]
public void StartEncode(EncodeJob jobToStart, Title title, int scanPreviewCount)
{
this.StartEncode(jobToStart, title, false, 0, 0, 0, scanPreviewCount);
@@ -418,13 +419,14 @@ namespace HandBrake.Interop /// <param name="scanPreviewCount">
/// Number of previews
/// </param>
+ [HandleProcessCorruptedStateExceptions]
public void StartEncode(EncodeJob job, Title title, bool preview, int previewNumber, int previewSeconds, double overallSelectedLengthSeconds, int scanPreviewCount)
{
JsonEncodeObject encodeObject = EncodeFactory.Create(job, title);
JsonSerializerSettings settings = new JsonSerializerSettings
{
- NullValueHandling = NullValueHandling.Ignore
+ NullValueHandling = NullValueHandling.Ignore,
};
string encode = JsonConvert.SerializeObject(encodeObject, Formatting.Indented, settings);
@@ -444,6 +446,7 @@ namespace HandBrake.Interop /// <summary>
/// Pauses the current encode.
/// </summary>
+ [HandleProcessCorruptedStateExceptions]
public void PauseEncode()
{
HBFunctions.hb_pause(this.hbHandle);
@@ -452,6 +455,7 @@ namespace HandBrake.Interop /// <summary>
/// Resumes a paused encode.
/// </summary>
+ [HandleProcessCorruptedStateExceptions]
public void ResumeEncode()
{
HBFunctions.hb_resume(this.hbHandle);
@@ -460,6 +464,7 @@ namespace HandBrake.Interop /// <summary>
/// Stops the current encode.
/// </summary>
+ [HandleProcessCorruptedStateExceptions]
public void StopEncode()
{
HBFunctions.hb_stop(this.hbHandle);
diff --git a/win/CS/HandBrake.Interop/HandBrakeInterop/HandBrakeInstanceManager.cs b/win/CS/HandBrake.Interop/HandBrakeInterop/HandBrakeInstanceManager.cs index 1ef749bd8..b1a889db0 100644 --- a/win/CS/HandBrake.Interop/HandBrakeInterop/HandBrakeInstanceManager.cs +++ b/win/CS/HandBrake.Interop/HandBrakeInterop/HandBrakeInstanceManager.cs @@ -20,6 +20,7 @@ namespace HandBrake.Interop public static class HandBrakeInstanceManager
{
private static HandBrakeInstance scanInstance;
+ private static HandBrakeInstance encodeInstance;
/// <summary>
/// Gets the scanInstance.
@@ -46,6 +47,30 @@ namespace HandBrake.Interop }
/// <summary>
+ /// The get encode instance.
+ /// </summary>
+ /// <param name="verbosity">
+ /// The verbosity.
+ /// </param>
+ /// <returns>
+ /// The <see cref="IHandBrakeInstance"/>.
+ /// </returns>
+ public static IHandBrakeInstance GetEncodeInstance(int verbosity)
+ {
+ if (encodeInstance != null)
+ {
+ encodeInstance.Dispose();
+ encodeInstance = null;
+ }
+
+ HandBrakeInstance newInstance = new HandBrakeInstance();
+ newInstance.Initialize(verbosity);
+ encodeInstance = newInstance;
+
+ return encodeInstance;
+ }
+
+ /// <summary>
/// Gets the last scan scan instance.
/// </summary>
public static IHandBrakeInstance LastScanScanInstance
@@ -66,5 +91,27 @@ namespace HandBrake.Interop return scanInstance.Handle;
}
}
+
+ /// <summary>
+ /// Gets the last encode scan instance.
+ /// </summary>
+ public static IHandBrakeInstance LastEncodeScanInstance
+ {
+ get
+ {
+ return encodeInstance;
+ }
+ }
+
+ /// <summary>
+ /// Gets the encode handle.
+ /// </summary>
+ internal static IntPtr LastEncodeHandle
+ {
+ get
+ {
+ return encodeInstance.Handle;
+ }
+ }
}
}
diff --git a/win/CS/HandBrake.Interop/HandBrakeInterop/HandBrakeUtils.cs b/win/CS/HandBrake.Interop/HandBrakeInterop/HandBrakeUtils.cs index 4cb51886d..abb67a074 100644 --- a/win/CS/HandBrake.Interop/HandBrakeInterop/HandBrakeUtils.cs +++ b/win/CS/HandBrake.Interop/HandBrakeInterop/HandBrakeUtils.cs @@ -310,8 +310,8 @@ namespace HandBrake.Interop {
switch (job.RangeType)
{
- case VideoRangeType.All:
- return title.Duration.TotalSeconds;
+ // case VideoRangeType.All:
+ // return title.Duration.TotalSeconds;
case VideoRangeType.Chapters:
TimeSpan duration = TimeSpan.Zero;
for (int i = job.ChapterStart; i <= job.ChapterEnd; i++)
diff --git a/win/CS/HandBrake.Interop/HandBrakeInterop/Json/Encode/Range.cs b/win/CS/HandBrake.Interop/HandBrakeInterop/Json/Encode/Range.cs index 2d9a45ee1..2538f93f5 100644 --- a/win/CS/HandBrake.Interop/HandBrakeInterop/Json/Encode/Range.cs +++ b/win/CS/HandBrake.Interop/HandBrakeInterop/Json/Encode/Range.cs @@ -17,36 +17,41 @@ namespace HandBrake.Interop.Json.Encode /// <summary>
/// Gets or sets the chapter end.
/// </summary>
- public int ChapterEnd { get; set; }
+ public int? ChapterEnd { get; set; }
/// <summary>
/// Gets or sets the chapter start.
/// </summary>
- public int ChapterStart { get; set; }
+ public int? ChapterStart { get; set; }
/// <summary>
/// Gets or sets the frame to start.
/// </summary>
- public int FrameToStart { get; set; }
+ public int? FrameToStart { get; set; }
/// <summary>
/// Gets or sets the frame to stop.
/// </summary>
- public int FrameToStop { get; set; }
+ public int? FrameToStop { get; set; }
/// <summary>
/// Gets or sets the pts to start.
/// </summary>
- public int PtsToStart { get; set; }
+ public int? PtsToStart { get; set; }
/// <summary>
/// Gets or sets the pts to stop.
/// </summary>
- public int PtsToStop { get; set; }
+ public int? PtsToStop { get; set; }
/// <summary>
/// Gets or sets the start at preview.
/// </summary>
- public int StartAtPreview { get; set; }
+ public int? StartAtPreview { get; set; }
+
+ /// <summary>
+ /// Gets or sets the seek points.
+ /// </summary>
+ public int? SeekPoints { get; set; }
}
}
\ No newline at end of file diff --git a/win/CS/HandBrake.Interop/HandBrakeInterop/Json/Factories/EncodeFactory.cs b/win/CS/HandBrake.Interop/HandBrakeInterop/Json/Factories/EncodeFactory.cs index 060821341..6d10b64eb 100644 --- a/win/CS/HandBrake.Interop/HandBrakeInterop/Json/Factories/EncodeFactory.cs +++ b/win/CS/HandBrake.Interop/HandBrakeInterop/Json/Factories/EncodeFactory.cs @@ -14,6 +14,7 @@ namespace HandBrake.Interop.Json.Factories using System.Globalization;
using System.Linq;
using System.Runtime.InteropServices;
+ using System.Windows.Media.Animation;
using HandBrake.Interop.HbLib;
using HandBrake.Interop.Helpers;
@@ -31,6 +32,12 @@ namespace HandBrake.Interop.Json.Factories /// </summary>
internal class EncodeFactory
{
+ /*
+ * TODO:
+ * 1. OpenCL and HWD Support
+ * 2. Rotate Support
+ */
+
/// <summary>
/// The create.
/// </summary>
@@ -72,19 +79,32 @@ namespace HandBrake.Interop.Json.Factories /// </returns>
private static Source CreateSource(EncodeJob job)
{
+ Range range = new Range();
+ switch (job.RangeType)
+ {
+ case VideoRangeType.Chapters:
+ range.ChapterEnd = job.ChapterEnd;
+ range.ChapterStart = job.ChapterStart;
+ break;
+ case VideoRangeType.Seconds:
+ range.PtsToStart = (int)(job.SecondsStart * 90000);
+ range.PtsToStop = (int)((job.SecondsEnd - job.SecondsStart) * 90000);
+ break;
+ case VideoRangeType.Frames:
+ range.FrameToStart = job.FramesStart;
+ range.FrameToStop = job.FramesEnd;
+ break;
+ case VideoRangeType.Preview:
+ range.StartAtPreview = job.StartAtPreview;
+ range.SeekPoints = job.SeekPoints;
+ range.PtsToStop = job.SecondsEnd * 90000;
+ break;
+ }
+
Source source = new Source
{
Title = job.Title,
- Range =
- new Range
- {
- ChapterEnd = job.ChapterEnd,
- ChapterStart = job.ChapterStart,
- FrameToStart = job.FramesStart,
- FrameToStop = job.FramesEnd,
- PtsToStart = (int)(job.SecondsStart * 90000),
- PtsToStop = (int)((job.SecondsEnd - job.SecondsStart) * 90000),
- },
+ Range = range,
Angle = job.Angle
};
return source;
diff --git a/win/CS/HandBrake.Interop/HandBrakeInterop/Model/EncodeJob.cs b/win/CS/HandBrake.Interop/HandBrakeInterop/Model/EncodeJob.cs index 1f857a94f..cd54342a7 100644 --- a/win/CS/HandBrake.Interop/HandBrakeInterop/Model/EncodeJob.cs +++ b/win/CS/HandBrake.Interop/HandBrakeInterop/Model/EncodeJob.cs @@ -78,10 +78,21 @@ namespace HandBrake.Interop.Model /// </summary>
public VideoRangeType RangeType { get; set; }
+ /// <summary>
+ /// Gets or sets the seek points.
+ /// This is the number of preview points.
+ /// </summary>
+ public int SeekPoints { get; set; }
+
+ /// <summary>
+ /// Gets or sets the start at preview.
+ /// </summary>
+ public int StartAtPreview { get; set; }
+
/// <summary>
/// Gets or sets the seconds end.
/// </summary>
- public double SecondsEnd { get; set; }
+ public int SecondsEnd { get; set; }
/// <summary>
/// Gets or sets the seconds start.
diff --git a/win/CS/HandBrake.Interop/HandBrakeInterop/Model/VideoRangeType.cs b/win/CS/HandBrake.Interop/HandBrakeInterop/Model/VideoRangeType.cs index afde441e5..6ffabf99f 100644 --- a/win/CS/HandBrake.Interop/HandBrakeInterop/Model/VideoRangeType.cs +++ b/win/CS/HandBrake.Interop/HandBrakeInterop/Model/VideoRangeType.cs @@ -19,8 +19,8 @@ namespace HandBrake.Interop.Model /// <summary>
/// The entire title.
/// </summary>
- [Display(Name = "All")]
- All,
+ [Display(Name = "Preview")]
+ Preview,
/// <summary>
/// A chapter range.
|