summaryrefslogtreecommitdiffstats
path: root/win
diff options
context:
space:
mode:
authorsr55 <[email protected]>2015-01-17 19:39:49 +0000
committersr55 <[email protected]>2015-01-17 19:39:49 +0000
commit34db38d676420cf1fc827f339f5c894d5b798762 (patch)
tree79573157c83eef41f0d66bb824258994219b88c2 /win
parent5a74ccf9554940ae69e097b1abd6b1c5a556b4bc (diff)
WinGui:
- Numerous fixes to the JSON api code. Live preview should now work again. Possible fix for issue where queued jobs where stopping at a random point and not continuing. - Fix Clear button on the audio tab. git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@6760 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'win')
-rw-r--r--win/CS/HandBrake.ApplicationServices/Model/HBConfiguration.cs5
-rw-r--r--win/CS/HandBrake.ApplicationServices/Services/Encode/EncodeBase.cs14
-rw-r--r--win/CS/HandBrake.ApplicationServices/Services/Encode/EncodeService.cs26
-rw-r--r--win/CS/HandBrake.ApplicationServices/Services/Encode/LibEncode.cs56
-rw-r--r--win/CS/HandBrake.ApplicationServices/Services/Encode/Model/EncodeTask.cs2
-rw-r--r--win/CS/HandBrake.ApplicationServices/Services/Scan/Interfaces/IScan.cs5
-rw-r--r--win/CS/HandBrake.ApplicationServices/Services/Scan/LibScan.cs7
-rw-r--r--win/CS/HandBrake.ApplicationServices/Utilities/InteropModelCreator.cs79
-rw-r--r--win/CS/HandBrake.ApplicationServices/Utilities/QueryGeneratorUtility.cs6
-rw-r--r--win/CS/HandBrake.Interop/HandBrakeInterop/HandBrakeInstance.cs7
-rw-r--r--win/CS/HandBrake.Interop/HandBrakeInterop/HandBrakeInstanceManager.cs47
-rw-r--r--win/CS/HandBrake.Interop/HandBrakeInterop/HandBrakeUtils.cs4
-rw-r--r--win/CS/HandBrake.Interop/HandBrakeInterop/Json/Encode/Range.cs19
-rw-r--r--win/CS/HandBrake.Interop/HandBrakeInterop/Json/Factories/EncodeFactory.cs40
-rw-r--r--win/CS/HandBrake.Interop/HandBrakeInterop/Model/EncodeJob.cs13
-rw-r--r--win/CS/HandBrake.Interop/HandBrakeInterop/Model/VideoRangeType.cs4
-rw-r--r--win/CS/HandBrakeWPF/Factories/HBConfigurationFactory.cs40
-rw-r--r--win/CS/HandBrakeWPF/ViewModels/PreviewViewModel.cs4
-rw-r--r--win/CS/HandBrakeWPF/ViewModels/StaticPreviewViewModel.cs3
-rw-r--r--win/CS/HandBrakeWPF/Views/AudioView.xaml2
20 files changed, 224 insertions, 159 deletions
diff --git a/win/CS/HandBrake.ApplicationServices/Model/HBConfiguration.cs b/win/CS/HandBrake.ApplicationServices/Model/HBConfiguration.cs
index 04b6efab6..ecb82ba85 100644
--- a/win/CS/HandBrake.ApplicationServices/Model/HBConfiguration.cs
+++ b/win/CS/HandBrake.ApplicationServices/Model/HBConfiguration.cs
@@ -15,11 +15,6 @@ namespace HandBrake.ApplicationServices.Model
public class HBConfiguration
{
/// <summary>
- /// Gets or sets a value indicating whether is logging enabled.
- /// </summary>
- public bool IsLoggingEnabled { get; set; }
-
- /// <summary>
/// Gets or sets a value indicating whether is dvd nav disabled.
/// </summary>
public bool IsDvdNavDisabled { get; set; }
diff --git a/win/CS/HandBrake.ApplicationServices/Services/Encode/EncodeBase.cs b/win/CS/HandBrake.ApplicationServices/Services/Encode/EncodeBase.cs
index a86f20978..65ef02ed3 100644
--- a/win/CS/HandBrake.ApplicationServices/Services/Encode/EncodeBase.cs
+++ b/win/CS/HandBrake.ApplicationServices/Services/Encode/EncodeBase.cs
@@ -338,10 +338,16 @@ namespace HandBrake.ApplicationServices.Services.Encode
File.Delete(logFile2);
}
- this.fileWriter = new StreamWriter(logFile) { AutoFlush = true };
- this.fileWriter.WriteLine(this.header);
- this.fileWriter.WriteLine(string.Format("CLI Query: {0}", query));
- this.fileWriter.WriteLine();
+ lock (FileWriterLock)
+ {
+ this.fileWriter = new StreamWriter(logFile) { AutoFlush = true };
+ this.fileWriter.WriteLine(this.header);
+ if (!isLibhb)
+ {
+ this.fileWriter.WriteLine(string.Format("CLI Query: {0}", query));
+ }
+ this.fileWriter.WriteLine();
+ }
}
catch (Exception)
{
diff --git a/win/CS/HandBrake.ApplicationServices/Services/Encode/EncodeService.cs b/win/CS/HandBrake.ApplicationServices/Services/Encode/EncodeService.cs
index 841e049de..2253d96e8 100644
--- a/win/CS/HandBrake.ApplicationServices/Services/Encode/EncodeService.cs
+++ b/win/CS/HandBrake.ApplicationServices/Services/Encode/EncodeService.cs
@@ -96,17 +96,14 @@ namespace HandBrake.ApplicationServices.Services.Encode
this.IsEncoding = true;
this.currentTask = encodeQueueTask;
- if (encodeQueueTask.Configuration.IsLoggingEnabled)
+ try
{
- try
- {
- this.SetupLogging(this.currentTask, false);
- }
- catch (Exception)
- {
- this.IsEncoding = false;
- throw;
- }
+ this.SetupLogging(this.currentTask, false);
+ }
+ catch (Exception)
+ {
+ this.IsEncoding = false;
+ throw;
}
// Make sure the path exists, attempt to create it if it doesn't
@@ -126,7 +123,7 @@ namespace HandBrake.ApplicationServices.Services.Encode
ProcessStartInfo cliStart = new ProcessStartInfo(handbrakeCLIPath, query)
{
RedirectStandardOutput = true,
- RedirectStandardError = encodeQueueTask.Configuration.IsLoggingEnabled,
+ RedirectStandardError = true,
UseShellExecute = false,
CreateNoWindow = true
};
@@ -137,11 +134,8 @@ namespace HandBrake.ApplicationServices.Services.Encode
this.startTime = DateTime.Now;
- if (encodeQueueTask.Configuration.IsLoggingEnabled)
- {
- this.HbProcess.ErrorDataReceived += this.HbProcErrorDataReceived;
- this.HbProcess.BeginErrorReadLine();
- }
+ this.HbProcess.ErrorDataReceived += this.HbProcErrorDataReceived;
+ this.HbProcess.BeginErrorReadLine();
this.HbProcess.OutputDataReceived += this.HbProcess_OutputDataReceived;
this.HbProcess.BeginOutputReadLine();
diff --git a/win/CS/HandBrake.ApplicationServices/Services/Encode/LibEncode.cs b/win/CS/HandBrake.ApplicationServices/Services/Encode/LibEncode.cs
index 0da939e19..0fbc7dbfe 100644
--- a/win/CS/HandBrake.ApplicationServices/Services/Encode/LibEncode.cs
+++ b/win/CS/HandBrake.ApplicationServices/Services/Encode/LibEncode.cs
@@ -46,15 +46,13 @@ namespace HandBrake.ApplicationServices.Services.Encode
private DateTime startTime;
/// <summary>
- /// A flag to indicate if logging is enabled or not.
- /// </summary>
- private bool loggingEnabled;
-
- /// <summary>
/// The Current Task
/// </summary>
private QueueTask currentTask;
+ /// <summary>
+ /// A local instance of the scanned source.
+ /// </summary>
private Source scannedSource;
#endregion
@@ -94,13 +92,11 @@ namespace HandBrake.ApplicationServices.Services.Encode
{
// Setup
this.startTime = DateTime.Now;
- this.loggingEnabled = job.Configuration.IsLoggingEnabled;
this.currentTask = job;
// Create a new HandBrake instance
// Setup the HandBrake Instance
- this.instance = new HandBrakeInstance();
- this.instance.Initialize(1);
+ this.instance = HandBrakeInstanceManager.GetEncodeInstance(job.Configuration.Verbosity);
this.instance.EncodeCompleted += this.InstanceEncodeCompleted;
this.instance.EncodeProgress += this.InstanceEncodeProgress;
@@ -115,17 +111,14 @@ namespace HandBrake.ApplicationServices.Services.Encode
this.IsEncoding = true;
// Enable logging if required.
- if (job.Configuration.IsLoggingEnabled)
+ try
+ {
+ this.SetupLogging(job, true);
+ }
+ catch (Exception)
{
- try
- {
- this.SetupLogging(job, true);
- }
- catch (Exception)
- {
- this.IsEncoding = false;
- throw;
- }
+ this.IsEncoding = false;
+ throw;
}
// Verify the Destination Path Exists, and if not, create it.
@@ -133,14 +126,15 @@ namespace HandBrake.ApplicationServices.Services.Encode
// We have to scan the source again but only the title so the HandBrake instance is initialised correctly.
// Since the UI sends the crop params down, we don't have to do all the previews.
- this.instance.StartScan(job.Task.Source, job.Configuration.PreviewScanCount, job.Task.Title);
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);
- };
+ {
+ // 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);
+ };
+
+ this.instance.StartScan(job.Task.Source, job.Configuration.PreviewScanCount, job.Task.Title);
}
catch (Exception exc)
{
@@ -268,12 +262,9 @@ namespace HandBrake.ApplicationServices.Services.Encode
/// </param>
private void HandBrakeInstanceErrorLogged(object sender, MessageLoggedEventArgs e)
{
- if (this.loggingEnabled)
+ lock (LogLock)
{
- lock (LogLock)
- {
- this.ProcessLogMessage(e.Message);
- }
+ this.ProcessLogMessage(e.Message);
}
}
@@ -288,12 +279,9 @@ namespace HandBrake.ApplicationServices.Services.Encode
/// </param>
private void HandBrakeInstanceMessageLogged(object sender, MessageLoggedEventArgs e)
{
- if (this.loggingEnabled)
+ lock (LogLock)
{
- lock (LogLock)
- {
- this.ProcessLogMessage(e.Message);
- }
+ this.ProcessLogMessage(e.Message);
}
}
diff --git a/win/CS/HandBrake.ApplicationServices/Services/Encode/Model/EncodeTask.cs b/win/CS/HandBrake.ApplicationServices/Services/Encode/Model/EncodeTask.cs
index 991d60a76..86b0d06ec 100644
--- a/win/CS/HandBrake.ApplicationServices/Services/Encode/Model/EncodeTask.cs
+++ b/win/CS/HandBrake.ApplicationServices/Services/Encode/Model/EncodeTask.cs
@@ -555,7 +555,7 @@ namespace HandBrake.ApplicationServices.Services.Encode.Model
/// <summary>
/// Gets or sets PreviewEncodeStartAt.
/// </summary>
- public string PreviewEncodeStartAt { get; set; }
+ public int PreviewEncodeStartAt { get; set; }
/// <summary>
/// Gets or sets a value indicating whether advanced panel enabled.
diff --git a/win/CS/HandBrake.ApplicationServices/Services/Scan/Interfaces/IScan.cs b/win/CS/HandBrake.ApplicationServices/Services/Scan/Interfaces/IScan.cs
index 4d61d6078..086a97487 100644
--- a/win/CS/HandBrake.ApplicationServices/Services/Scan/Interfaces/IScan.cs
+++ b/win/CS/HandBrake.ApplicationServices/Services/Scan/Interfaces/IScan.cs
@@ -101,10 +101,13 @@ namespace HandBrake.ApplicationServices.Services.Scan.Interfaces
/// <param name="preview">
/// The preview.
/// </param>
+ /// <param name="configuration">
+ /// The configuration.
+ /// </param>
/// <returns>
/// The <see cref="BitmapImage"/>.
/// </returns>
- BitmapImage GetPreview(EncodeTask task, int preview);
+ BitmapImage GetPreview(EncodeTask task, int preview, HBConfiguration configuration);
/// <summary>
/// Kill the scan
diff --git a/win/CS/HandBrake.ApplicationServices/Services/Scan/LibScan.cs b/win/CS/HandBrake.ApplicationServices/Services/Scan/LibScan.cs
index 6d1dcb104..650b07516 100644
--- a/win/CS/HandBrake.ApplicationServices/Services/Scan/LibScan.cs
+++ b/win/CS/HandBrake.ApplicationServices/Services/Scan/LibScan.cs
@@ -264,17 +264,20 @@ namespace HandBrake.ApplicationServices.Services.Scan
/// <param name="preview">
/// The preview.
/// </param>
+ /// <param name="configuraiton">
+ /// The configuraiton.
+ /// </param>
/// <returns>
/// The <see cref="BitmapImage"/>.
/// </returns>
- public BitmapImage GetPreview(EncodeTask job, int preview)
+ public BitmapImage GetPreview(EncodeTask job, int preview, HBConfiguration configuraiton)
{
if (this.instance == null)
{
return null;
}
- EncodeJob encodeJob = InteropModelCreator.GetEncodeJob(job);
+ EncodeJob encodeJob = InteropModelCreator.GetEncodeJob(job, configuraiton);
BitmapImage bitmapImage = null;
try
diff --git a/win/CS/HandBrake.ApplicationServices/Utilities/InteropModelCreator.cs b/win/CS/HandBrake.ApplicationServices/Utilities/InteropModelCreator.cs
index edea7fb9d..ec5194e95 100644
--- a/win/CS/HandBrake.ApplicationServices/Utilities/InteropModelCreator.cs
+++ b/win/CS/HandBrake.ApplicationServices/Utilities/InteropModelCreator.cs
@@ -12,6 +12,7 @@ namespace HandBrake.ApplicationServices.Utilities
using System;
using System.Collections.Generic;
using System.Linq;
+ using System.Windows.Media.Animation;
using HandBrake.ApplicationServices.Model;
using HandBrake.ApplicationServices.Services.Encode.Model;
@@ -39,12 +40,12 @@ namespace HandBrake.ApplicationServices.Utilities
public static EncodeJob GetEncodeJob(QueueTask task)
{
// Sanity Checking
- if (task == null || task.Task == null)
+ if (task == null || task.Task == null || task.Configuration == null)
{
return null;
}
- return GetEncodeJob(task.Task);
+ return GetEncodeJob(task.Task, task.Configuration);
}
/// <summary>
@@ -53,10 +54,13 @@ namespace HandBrake.ApplicationServices.Utilities
/// <param name="task">
/// The task.
/// </param>
+ /// <param name="configuration">
+ /// The configuration.
+ /// </param>
/// <returns>
/// An Interop.EncodeJob model.
/// </returns>
- public static EncodeJob GetEncodeJob(EncodeTask task)
+ public static EncodeJob GetEncodeJob(EncodeTask task, HBConfiguration configuration)
{
// The current Job Configuration
EncodeTask work = task;
@@ -72,17 +76,17 @@ namespace HandBrake.ApplicationServices.Utilities
foreach (AudioTrack track in work.AudioTracks)
{
AudioEncoding newTrack = new AudioEncoding
- {
- Bitrate = track.Bitrate,
- Drc = track.DRC,
- Gain = track.Gain,
- Encoder = Converters.GetCliAudioEncoder(track.Encoder),
- InputNumber = track.Track.HasValue ? track.Track.Value : 0,
- Mixdown = Converters.GetCliMixDown(track.MixDown),
- SampleRateRaw = GetSampleRateRaw(track.SampleRate),
- EncodeRateType = AudioEncodeRateType.Bitrate,
- Name = track.TrackName
- };
+ {
+ Bitrate = track.Bitrate,
+ Drc = track.DRC,
+ Gain = track.Gain,
+ Encoder = Converters.GetCliAudioEncoder(track.Encoder),
+ InputNumber = track.Track.HasValue ? track.Track.Value : 0,
+ Mixdown = Converters.GetCliMixDown(track.MixDown),
+ SampleRateRaw = GetSampleRateRaw(track.SampleRate),
+ EncodeRateType = AudioEncodeRateType.Bitrate,
+ Name = track.TrackName
+ };
profile.AudioEncodings.Add(newTrack);
if (track.Track != null)
@@ -95,6 +99,7 @@ namespace HandBrake.ApplicationServices.Utilities
job.OutputPath = work.Destination;
job.SourcePath = work.Source;
job.Title = work.Title;
+
// job.SourceType = work.Type;
switch (work.PointToPointMode)
{
@@ -107,6 +112,9 @@ namespace HandBrake.ApplicationServices.Utilities
case PointToPointMode.Frames:
job.RangeType = VideoRangeType.Frames;
break;
+ case PointToPointMode.Preview:
+ job.RangeType = VideoRangeType.Preview;
+ break;
}
if (work.PointToPointMode == PointToPointMode.Seconds)
@@ -125,6 +133,13 @@ namespace HandBrake.ApplicationServices.Utilities
job.FramesStart = work.StartPoint;
}
+ if (work.PointToPointMode == PointToPointMode.Preview)
+ {
+ job.StartAtPreview = work.PreviewStartAt.HasValue ? work.PreviewStartAt.Value : 1;
+ job.SecondsEnd = work.PreviewDuration.HasValue ? work.PreviewEncodeDuration : 30;
+ job.SeekPoints = configuration.PreviewScanCount;
+ }
+
job.Angle = work.Angle;
job.EncodingProfile = profile;
@@ -143,17 +158,9 @@ namespace HandBrake.ApplicationServices.Utilities
// Picture Settings
profile.Anamorphic = work.Anamorphic;
- profile.Cropping = new Cropping
- {
- Top = work.Cropping.Top,
- Bottom = work.Cropping.Bottom,
- Left = work.Cropping.Left,
- Right = work.Cropping.Right
- };
+ profile.Cropping = new Cropping { Top = work.Cropping.Top, Bottom = work.Cropping.Bottom, Left = work.Cropping.Left, Right = work.Cropping.Right };
profile.CroppingType = CroppingType.Custom; // TODO deal with this better
- profile.DisplayWidth = work.DisplayWidth.HasValue
- ? int.Parse(Math.Round(work.DisplayWidth.Value, 0).ToString())
- : 0;
+ profile.DisplayWidth = work.DisplayWidth.HasValue ? int.Parse(Math.Round(work.DisplayWidth.Value, 0).ToString()) : 0;
profile.PixelAspectX = work.PixelAspectX;
profile.PixelAspectY = work.PixelAspectY;
profile.Height = work.Height.HasValue ? work.Height.Value : 0;
@@ -172,7 +179,9 @@ namespace HandBrake.ApplicationServices.Utilities
profile.DenoiseTune = work.DenoiseTune.ToString().ToLower().Replace(" ", string.Empty);
profile.CustomDetelecine = work.CustomDetelecine;
if (work.Deblock > 4)
+ {
profile.Deblock = work.Deblock;
+ }
profile.Decomb = work.Decomb;
profile.Deinterlace = work.Deinterlace;
profile.Denoise = work.Denoise;
@@ -209,7 +218,7 @@ namespace HandBrake.ApplicationServices.Utilities
profile.VideoLevel = work.H264Level;
}
else if (work.VideoEncoder == VideoEncoder.X265)
- {
+ {
profile.VideoPreset = work.X265Preset.ToString().ToLower().Replace(" ", string.Empty);
if (work.H265Profile != x265Profile.None)
@@ -229,7 +238,7 @@ namespace HandBrake.ApplicationServices.Utilities
profile.VideoProfile = work.H264Profile.ToString().ToLower().Replace(" ", string.Empty);
profile.VideoLevel = work.H264Level;
}
-
+
// Chapter Markers
profile.IncludeChapterMarkers = work.IncludeChapterMarkers;
job.CustomChapterNames = work.ChapterNames.Select(item => item.ChapterName).ToList();
@@ -247,11 +256,11 @@ namespace HandBrake.ApplicationServices.Utilities
job.Subtitles.SrtSubtitles.Add(
new SrtSubtitle
{
- CharacterCode = track.SrtCharCode,
- Default = track.Default,
- FileName = track.SrtFileName,
- LanguageCode = track.SrtLang,
- Offset = track.SrtOffset,
+ CharacterCode = track.SrtCharCode,
+ Default = track.Default,
+ FileName = track.SrtFileName,
+ LanguageCode = track.SrtLang,
+ Offset = track.SrtOffset,
BurnedIn = track.Burned
});
}
@@ -260,13 +269,7 @@ namespace HandBrake.ApplicationServices.Utilities
if (track.SourceTrack != null)
{
job.Subtitles.SourceSubtitles.Add(
- new SourceSubtitle
- {
- BurnedIn = track.Burned,
- Default = track.Default,
- Forced = track.Forced,
- TrackNumber = track.SourceTrack.TrackNumber
- });
+ new SourceSubtitle { BurnedIn = track.Burned, Default = track.Default, Forced = track.Forced, TrackNumber = track.SourceTrack.TrackNumber });
}
}
}
diff --git a/win/CS/HandBrake.ApplicationServices/Utilities/QueryGeneratorUtility.cs b/win/CS/HandBrake.ApplicationServices/Utilities/QueryGeneratorUtility.cs
index 653732d2b..4c0eddac1 100644
--- a/win/CS/HandBrake.ApplicationServices/Utilities/QueryGeneratorUtility.cs
+++ b/win/CS/HandBrake.ApplicationServices/Utilities/QueryGeneratorUtility.cs
@@ -47,7 +47,7 @@ namespace HandBrake.ApplicationServices.Utilities
}
string query = string.Empty;
- query += SourceQuery(task, null, null, configuration.PreviewScanCount);
+ query += SourceQuery(task, null, -1, configuration.PreviewScanCount);
query += DestinationQuery(task);
query += GenerateTabbedComponentsQuery(task, true, configuration.Verbosity, configuration.IsDvdNavDisabled, configuration.DisableQuickSyncDecoding, configuration.EnableDxva, configuration.ScalingMode == VideoScaler.BicubicCl);
@@ -72,7 +72,7 @@ namespace HandBrake.ApplicationServices.Utilities
/// <returns>
/// A Cli query suitable for generating a preview video.
/// </returns>
- public static string GeneratePreviewQuery(EncodeTask task, HBConfiguration configuration, int duration, string startAtPreview)
+ public static string GeneratePreviewQuery(EncodeTask task, HBConfiguration configuration, int duration, int startAtPreview)
{
string query = string.Empty;
query += SourceQuery(task, duration, startAtPreview, configuration.PreviewScanCount);
@@ -164,7 +164,7 @@ namespace HandBrake.ApplicationServices.Utilities
/// <returns>
/// A Cli Query as a string
/// </returns>
- private static string SourceQuery(EncodeTask task, int? duration, string preview, int previewScanCount)
+ private static string SourceQuery(EncodeTask task, int? duration, int preview, int previewScanCount)
{
string query = string.Empty;
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.
diff --git a/win/CS/HandBrakeWPF/Factories/HBConfigurationFactory.cs b/win/CS/HandBrakeWPF/Factories/HBConfigurationFactory.cs
index 8be9bcd41..c0ba00633 100644
--- a/win/CS/HandBrakeWPF/Factories/HBConfigurationFactory.cs
+++ b/win/CS/HandBrakeWPF/Factories/HBConfigurationFactory.cs
@@ -12,7 +12,6 @@ namespace HandBrakeWPF.Factories
using Caliburn.Micro;
using HandBrake.ApplicationServices.Model;
- using HandBrake.ApplicationServices.Services.Interfaces;
using HandBrakeWPF.Services.Interfaces;
@@ -29,42 +28,27 @@ namespace HandBrakeWPF.Factories
/// <summary>
/// The create.
/// </summary>
- /// <param name="isLoggingEnabled">
- /// The is logging enabled.
- /// </param>
/// <returns>
/// The <see cref="HBConfiguration"/>.
/// </returns>
- public static HBConfiguration Create(bool isLoggingEnabled)
+ public static HBConfiguration Create()
{
HBConfiguration config = new HBConfiguration
{
- IsDvdNavDisabled = UserSettingService.GetUserSetting<bool>(UserSettingConstants.DisableLibDvdNav),
- IsLoggingEnabled = isLoggingEnabled,
- DisableQuickSyncDecoding = UserSettingService.GetUserSetting<bool>(UserSettingConstants.DisableQuickSyncDecoding),
- EnableDxva = UserSettingService.GetUserSetting<bool>(UserSettingConstants.EnableDxva),
- ScalingMode = UserSettingService.GetUserSetting<VideoScaler>(UserSettingConstants.ScalingMode),
- PreviewScanCount = UserSettingService.GetUserSetting<int>(UserSettingConstants.PreviewScanCount),
- Verbosity = UserSettingService.GetUserSetting<int>(UserSettingConstants.Verbosity),
- MinScanDuration = UserSettingService.GetUserSetting<int>(UserSettingConstants.MinScanDuration),
- ProcessPriority = UserSettingService.GetUserSetting<string>(UserSettingConstants.ProcessPriority),
- SaveLogToCopyDirectory = UserSettingService.GetUserSetting<bool>(UserSettingConstants.SaveLogToCopyDirectory),
- SaveLogWithVideo = UserSettingService.GetUserSetting<bool>(UserSettingConstants.SaveLogWithVideo),
- SaveLogCopyDirectory = UserSettingService.GetUserSetting<string>(UserSettingConstants.SaveLogCopyDirectory),
+ IsDvdNavDisabled = UserSettingService.GetUserSetting<bool>(UserSettingConstants.DisableLibDvdNav),
+ DisableQuickSyncDecoding = UserSettingService.GetUserSetting<bool>(UserSettingConstants.DisableQuickSyncDecoding),
+ EnableDxva = UserSettingService.GetUserSetting<bool>(UserSettingConstants.EnableDxva),
+ ScalingMode = UserSettingService.GetUserSetting<VideoScaler>(UserSettingConstants.ScalingMode),
+ PreviewScanCount = UserSettingService.GetUserSetting<int>(UserSettingConstants.PreviewScanCount),
+ Verbosity = UserSettingService.GetUserSetting<int>(UserSettingConstants.Verbosity),
+ MinScanDuration = UserSettingService.GetUserSetting<int>(UserSettingConstants.MinScanDuration),
+ ProcessPriority = UserSettingService.GetUserSetting<string>(UserSettingConstants.ProcessPriority),
+ SaveLogToCopyDirectory = UserSettingService.GetUserSetting<bool>(UserSettingConstants.SaveLogToCopyDirectory),
+ SaveLogWithVideo = UserSettingService.GetUserSetting<bool>(UserSettingConstants.SaveLogWithVideo),
+ SaveLogCopyDirectory = UserSettingService.GetUserSetting<string>(UserSettingConstants.SaveLogCopyDirectory),
};
return config;
}
-
- /// <summary>
- /// The create.
- /// </summary>
- /// <returns>
- /// The <see cref="HBConfiguration"/>.
- /// </returns>
- public static HBConfiguration Create()
- {
- return Create(true);
- }
}
}
diff --git a/win/CS/HandBrakeWPF/ViewModels/PreviewViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/PreviewViewModel.cs
index 693d7a459..f117b9ef5 100644
--- a/win/CS/HandBrakeWPF/ViewModels/PreviewViewModel.cs
+++ b/win/CS/HandBrakeWPF/ViewModels/PreviewViewModel.cs
@@ -302,9 +302,9 @@ namespace HandBrakeWPF.ViewModels
// Setup the encode task as a preview encode
encodeTask.IsPreviewEncode = true;
- encodeTask.PreviewEncodeStartAt = this.StartAt.ToString(CultureInfo.InvariantCulture);
+ encodeTask.PreviewEncodeStartAt = this.StartAt;
encodeTask.PreviewEncodeDuration = this.Duration;
- QueueTask task = new QueueTask(encodeTask, HBConfigurationFactory.Create(false));
+ QueueTask task = new QueueTask(encodeTask, HBConfigurationFactory.Create());
ThreadPool.QueueUserWorkItem(this.CreatePreview, task);
}
diff --git a/win/CS/HandBrakeWPF/ViewModels/StaticPreviewViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/StaticPreviewViewModel.cs
index a910c272b..7f94f5d4c 100644
--- a/win/CS/HandBrakeWPF/ViewModels/StaticPreviewViewModel.cs
+++ b/win/CS/HandBrakeWPF/ViewModels/StaticPreviewViewModel.cs
@@ -20,6 +20,7 @@ namespace HandBrakeWPF.ViewModels
using HandBrake.ApplicationServices.Services.Scan.Interfaces;
using HandBrake.Interop.Model.Encoding;
+ using HandBrakeWPF.Factories;
using HandBrakeWPF.ViewModels.Interfaces;
/// <summary>
@@ -250,7 +251,7 @@ namespace HandBrakeWPF.ViewModels
BitmapImage image = null;
try
{
- image = this.scanService.GetPreview(this.Task, this.SelectedPreviewImage);
+ image = this.scanService.GetPreview(this.Task, this.SelectedPreviewImage, HBConfigurationFactory.Create());
}
catch (Exception exc)
{
diff --git a/win/CS/HandBrakeWPF/Views/AudioView.xaml b/win/CS/HandBrakeWPF/Views/AudioView.xaml
index ab2db0dbd..21a3dd59d 100644
--- a/win/CS/HandBrakeWPF/Views/AudioView.xaml
+++ b/win/CS/HandBrakeWPF/Views/AudioView.xaml
@@ -82,7 +82,7 @@
<Button MinWidth="65"
Margin="0,0,10,0"
- cal:Message.Attach="[Event Click] = [Action ShowAudioDefaults]"
+ cal:Message.Attach="[Event Click] = [Action Clear]"
Content="Clear" />
<Button MinWidth="65"