diff options
author | sr55 <[email protected]> | 2015-01-17 19:39:49 +0000 |
---|---|---|
committer | sr55 <[email protected]> | 2015-01-17 19:39:49 +0000 |
commit | 34db38d676420cf1fc827f339f5c894d5b798762 (patch) | |
tree | 79573157c83eef41f0d66bb824258994219b88c2 /win/CS/HandBrake.ApplicationServices | |
parent | 5a74ccf9554940ae69e097b1abd6b1c5a556b4bc (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/CS/HandBrake.ApplicationServices')
9 files changed, 96 insertions, 104 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;
|