summaryrefslogtreecommitdiffstats
path: root/win
diff options
context:
space:
mode:
authorsr55 <[email protected]>2020-04-11 11:11:40 +0100
committersr55 <[email protected]>2020-04-11 13:00:48 +0100
commitc3d62f1465fc9813d079bdf33f2e062a48ec8549 (patch)
tree9cdc71a68890a46a57c0982e563928fe40316e0d /win
parent30c15df16bc543f4d2ad828176c787cbc7b7c74e (diff)
WinGui: Stripping much of the remaining app config out of the Queue Jobs. Certain features such as QSV, while global options currently are not really global. I may move these out of perferences at a later point. Fixes #2753
Diffstat (limited to 'win')
-rw-r--r--win/CS/HandBrake.Interop/Interop/Json/Presets/HBPreset.cs3
-rw-r--r--win/CS/HandBrake.Interop/Model/HBConfiguration.cs64
-rw-r--r--win/CS/HandBrakeWPF/Factories/HBConfigurationFactory.cs22
-rw-r--r--win/CS/HandBrakeWPF/Instance/HandBrakeInstanceManager.cs25
-rw-r--r--win/CS/HandBrakeWPF/Instance/RemoteInstance.cs14
-rw-r--r--win/CS/HandBrakeWPF/Services/Encode/EncodeBase.cs12
-rw-r--r--win/CS/HandBrakeWPF/Services/Encode/Factories/QueueFactory.cs70
-rw-r--r--win/CS/HandBrakeWPF/Services/Encode/LibEncode.cs7
-rw-r--r--win/CS/HandBrakeWPF/Services/Presets/Factories/JsonPresetFactory.cs2
-rw-r--r--win/CS/HandBrakeWPF/Services/Queue/QueueService.cs40
-rw-r--r--win/CS/HandBrakeWPF/Services/Scan/Interfaces/IScan.cs12
-rw-r--r--win/CS/HandBrakeWPF/Services/Scan/LibScan.cs63
-rw-r--r--win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs4
-rw-r--r--win/CS/HandBrakeWPF/ViewModels/StaticPreviewViewModel.cs4
-rw-r--r--win/CS/HandBrakeWPF/ViewModels/SummaryViewModel.cs2
15 files changed, 100 insertions, 244 deletions
diff --git a/win/CS/HandBrake.Interop/Interop/Json/Presets/HBPreset.cs b/win/CS/HandBrake.Interop/Interop/Json/Presets/HBPreset.cs
index 3e0bed6ce..bf49020d4 100644
--- a/win/CS/HandBrake.Interop/Interop/Json/Presets/HBPreset.cs
+++ b/win/CS/HandBrake.Interop/Interop/Json/Presets/HBPreset.cs
@@ -168,8 +168,11 @@ namespace HandBrake.Interop.Interop.Json.Presets
public string PictureDenoiseTune { get; set; }
public string PictureSharpenCustom { get; set; }
+
public string PictureSharpenFilter { get; set; }
+
public string PictureSharpenPreset { get; set; }
+
public string PictureSharpenTune { get; set; }
/// <summary>
diff --git a/win/CS/HandBrake.Interop/Model/HBConfiguration.cs b/win/CS/HandBrake.Interop/Model/HBConfiguration.cs
index cf302bc82..837f0d94a 100644
--- a/win/CS/HandBrake.Interop/Model/HBConfiguration.cs
+++ b/win/CS/HandBrake.Interop/Model/HBConfiguration.cs
@@ -1,5 +1,5 @@
// --------------------------------------------------------------------------------------------------------------------
-// <copyright file="HBConfiguration.cs" company="HandBrake Project (http://handbrake.fr)">
+// <copyright file="HBConfiguration.cs" company="HandBrake Project (https://handbrake.fr)">
// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License.
// </copyright>
// <summary>
@@ -15,72 +15,12 @@ namespace HandBrake.Interop.Model
{
}
- /// <summary>
- /// Gets or sets a value indicating whether is dvd nav disabled.
- /// </summary>
- public bool IsDvdNavDisabled { get; set; }
+ public int PreviewScanCount { get; set; }
- /// <summary>
- /// Gets or sets a value indicating whether disable quick sync decoding.
- /// </summary>
public bool EnableQuickSyncDecoding { get; set; }
- /// <summary>
- /// Gets or sets a value indicating whether use qsv decode for non qsv enc.
- /// </summary>
public bool UseQSVDecodeForNonQSVEnc { get; set; }
- /// <summary>
- /// Gets or sets the scaling mode.
- /// </summary>
- public VideoScaler ScalingMode { get; set; }
-
- /// <summary>
- /// Gets or sets the preview scan count.
- /// </summary>
- public int PreviewScanCount { get; set; }
-
- /// <summary>
- /// Gets or sets the verbosity.
- /// </summary>
- public int Verbosity { get; set; }
-
- /// <summary>
- /// Gets or sets the min scan duration.
- /// </summary>
- public int MinScanDuration { get; set; }
-
- /// <summary>
- /// Gets or sets a value indicating whether save log to copy directory.
- /// </summary>
- public bool SaveLogToCopyDirectory { get; set; }
-
- /// <summary>
- /// Gets or sets a value indicating whether save log with video.
- /// </summary>
- public bool SaveLogWithVideo { get; set; }
-
- /// <summary>
- /// Gets or sets the save log copy directory.
- /// </summary>
- public string SaveLogCopyDirectory { get; set; }
-
- /// <summary>
- /// Gets or sets a value indicating whether we use in-process or out-of-process encoding.
- /// </summary>
- public bool RemoteServiceEnabled { get; set; }
-
- /// <summary>
- /// Gets or sets a value indicating what port the worker process is to use.
- /// </summary>
- public int RemoteServicePort { get; set; }
-
- public bool EnableVceEncoder { get; set; }
-
- public bool EnableNvencEncoder { get; set; }
-
- public bool EnableQsvEncoder { get; set; }
-
public bool EnableQsvLowPower { get; set; }
}
}
diff --git a/win/CS/HandBrakeWPF/Factories/HBConfigurationFactory.cs b/win/CS/HandBrakeWPF/Factories/HBConfigurationFactory.cs
index e8ec1fe1d..e2d4f448e 100644
--- a/win/CS/HandBrakeWPF/Factories/HBConfigurationFactory.cs
+++ b/win/CS/HandBrakeWPF/Factories/HBConfigurationFactory.cs
@@ -34,23 +34,11 @@ namespace HandBrakeWPF.Factories
public static HBConfiguration Create()
{
HBConfiguration config = new HBConfiguration
- {
- IsDvdNavDisabled = UserSettingService.GetUserSetting<bool>(UserSettingConstants.DisableLibDvdNav),
- ScalingMode = UserSettingService.GetUserSetting<VideoScaler>(UserSettingConstants.ScalingMode),
- PreviewScanCount = UserSettingService.GetUserSetting<int>(UserSettingConstants.PreviewScanCount),
- Verbosity = UserSettingService.GetUserSetting<int>(UserSettingConstants.Verbosity),
- MinScanDuration = UserSettingService.GetUserSetting<int>(UserSettingConstants.MinScanDuration),
- SaveLogToCopyDirectory = UserSettingService.GetUserSetting<bool>(UserSettingConstants.SaveLogToCopyDirectory),
- SaveLogWithVideo = UserSettingService.GetUserSetting<bool>(UserSettingConstants.SaveLogWithVideo),
- SaveLogCopyDirectory = UserSettingService.GetUserSetting<string>(UserSettingConstants.SaveLogCopyDirectory),
- RemoteServiceEnabled = UserSettingService.GetUserSetting<bool>(UserSettingConstants.RemoteServiceEnabled),
- RemoteServicePort = UserSettingService.GetUserSetting<int>(UserSettingConstants.RemoteServicePort),
- EnableVceEncoder = UserSettingService.GetUserSetting<bool>(UserSettingConstants.EnableVceEncoder),
- EnableNvencEncoder = UserSettingService.GetUserSetting<bool>(UserSettingConstants.EnableNvencEncoder),
- EnableQsvEncoder = UserSettingService.GetUserSetting<bool>(UserSettingConstants.EnableQuickSyncEncoding),
- EnableQuickSyncDecoding = UserSettingService.GetUserSetting<bool>(UserSettingConstants.EnableQuickSyncDecoding),
- UseQSVDecodeForNonQSVEnc = UserSettingService.GetUserSetting<bool>(UserSettingConstants.UseQSVDecodeForNonQSVEnc),
- EnableQsvLowPower = UserSettingService.GetUserSetting<bool>(UserSettingConstants.EnableQuickSyncLowPower)
+ {
+ PreviewScanCount = UserSettingService.GetUserSetting<int>(UserSettingConstants.PreviewScanCount),
+ EnableQuickSyncDecoding = UserSettingService.GetUserSetting<bool>(UserSettingConstants.EnableQuickSyncDecoding),
+ UseQSVDecodeForNonQSVEnc = UserSettingService.GetUserSetting<bool>(UserSettingConstants.UseQSVDecodeForNonQSVEnc),
+ EnableQsvLowPower = UserSettingService.GetUserSetting<bool>(UserSettingConstants.EnableQuickSyncLowPower)
};
return config;
diff --git a/win/CS/HandBrakeWPF/Instance/HandBrakeInstanceManager.cs b/win/CS/HandBrakeWPF/Instance/HandBrakeInstanceManager.cs
index f24ae527b..555a8290f 100644
--- a/win/CS/HandBrakeWPF/Instance/HandBrakeInstanceManager.cs
+++ b/win/CS/HandBrakeWPF/Instance/HandBrakeInstanceManager.cs
@@ -10,14 +10,12 @@
namespace HandBrakeWPF.Instance
{
using System;
- using System.Runtime.CompilerServices;
-
using HandBrake.Interop.Interop;
using HandBrake.Interop.Interop.Interfaces;
using HandBrake.Interop.Model;
- using HandBrakeWPF.Factories;
+ using HandBrakeWPF.Services.Interfaces;
using HandBrakeWPF.Services.Logging.Interfaces;
/// <summary>
@@ -38,7 +36,7 @@ namespace HandBrakeWPF.Instance
HandBrakeUtils.EnsureGlobalInit(noHardwareMode);
}
- public static IEncodeInstance GetEncodeInstance(int verbosity, HBConfiguration configuration, ILog logService)
+ public static IEncodeInstance GetEncodeInstance(int verbosity, HBConfiguration configuration, ILog logService, IUserSettingService userSettingService)
{
if (!HandBrakeUtils.IsInitialised())
{
@@ -53,9 +51,9 @@ namespace HandBrakeWPF.Instance
IEncodeInstance newInstance;
- if (configuration.RemoteServiceEnabled)
+ if (userSettingService.GetUserSetting<bool>(UserSettingConstants.RemoteServiceEnabled))
{
- newInstance = new RemoteInstance(configuration, logService);
+ newInstance = new RemoteInstance(configuration, logService, userSettingService);
}
else
{
@@ -66,7 +64,7 @@ namespace HandBrakeWPF.Instance
encodeInstance = newInstance;
- HandBrakeUtils.SetDvdNav(!configuration.IsDvdNavDisabled);
+ HandBrakeUtils.SetDvdNav(!userSettingService.GetUserSetting<bool>(UserSettingConstants.DisableLibDvdNav));
return encodeInstance;
}
@@ -77,13 +75,10 @@ namespace HandBrakeWPF.Instance
/// <param name="verbosity">
/// The verbosity.
/// </param>
- /// <param name="configuration">
- /// HandBrakes config
- /// </param>
/// <returns>
/// The <see cref="IHandBrakeInstance"/>.
/// </returns>
- public static IHandBrakeInstance GetScanInstance(int verbosity, HBConfiguration configuration)
+ public static IHandBrakeInstance GetScanInstance(int verbosity)
{
if (!HandBrakeUtils.IsInitialised())
{
@@ -109,13 +104,13 @@ namespace HandBrakeWPF.Instance
/// <param name="verbosity">
/// The verbosity.
/// </param>
- /// <param name="configuration">
- /// The configuration.
+ /// <param name="userSettingService">
+ /// The user Setting Service.
/// </param>
/// <returns>
/// The <see cref="IHandBrakeInstance"/>.
/// </returns>
- public static IHandBrakeInstance GetPreviewInstance(int verbosity, HBConfiguration configuration)
+ public static IHandBrakeInstance GetPreviewInstance(int verbosity, IUserSettingService userSettingService)
{
if (!HandBrakeUtils.IsInitialised())
{
@@ -132,7 +127,7 @@ namespace HandBrakeWPF.Instance
newInstance.Initialize(verbosity, noHardware);
previewInstance = newInstance;
- HandBrakeUtils.SetDvdNav(!configuration.IsDvdNavDisabled);
+ HandBrakeUtils.SetDvdNav(!userSettingService.GetUserSetting<bool>(UserSettingConstants.DisableLibDvdNav));
return previewInstance;
}
diff --git a/win/CS/HandBrakeWPF/Instance/RemoteInstance.cs b/win/CS/HandBrakeWPF/Instance/RemoteInstance.cs
index 1d11c1cce..87af203c8 100644
--- a/win/CS/HandBrakeWPF/Instance/RemoteInstance.cs
+++ b/win/CS/HandBrakeWPF/Instance/RemoteInstance.cs
@@ -30,6 +30,7 @@ namespace HandBrakeWPF.Instance
using HandBrake.Worker.Routing.Commands;
using HandBrakeWPF.Instance.Model;
+ using HandBrakeWPF.Services.Interfaces;
using HandBrakeWPF.Services.Logging.Interfaces;
using HandBrakeWPF.Utilities;
@@ -50,17 +51,20 @@ namespace HandBrakeWPF.Instance
private readonly ILog logService;
+ private readonly IUserSettingService userSettingService;
+
private const double EncodePollIntervalMs = 500;
private Process workerProcess;
private Timer encodePollTimer;
private int retryCount = 0;
- public RemoteInstance(HBConfiguration configuration, ILog logService)
+ public RemoteInstance(HBConfiguration configuration, ILog logService, IUserSettingService userSettingService)
{
this.configuration = configuration;
this.logService = logService;
- this.port = this.GetOpenPort(this.configuration.RemoteServicePort);
+ this.userSettingService = userSettingService;
+ this.port = this.GetOpenPort(userSettingService.GetUserSetting<int>(UserSettingConstants.RemoteServicePort));
this.serverUrl = string.Format("http://127.0.0.1:{0}/", this.port);
}
@@ -86,11 +90,11 @@ namespace HandBrakeWPF.Instance
{
EnableDiskLogging = true,
AllowDisconnectedWorker = false,
- DisableLibDvdNav = this.configuration.IsDvdNavDisabled,
+ DisableLibDvdNav = this.userSettingService.GetUserSetting<bool>(UserSettingConstants.DisableLibDvdNav),
EnableHardwareAcceleration = true,
LogDirectory = DirectoryUtilities.GetLogDirectory(),
- LogVerbosity = configuration.Verbosity
- };
+ LogVerbosity = this.userSettingService.GetUserSetting<int>(UserSettingConstants.Verbosity)
+ };
initCommand.LogFile = Path.Combine(initCommand.LogDirectory, string.Format("activity_log.worker.{0}.txt", GeneralUtilities.ProcessId));
diff --git a/win/CS/HandBrakeWPF/Services/Encode/EncodeBase.cs b/win/CS/HandBrakeWPF/Services/Encode/EncodeBase.cs
index 22249e5e6..6d34a2efd 100644
--- a/win/CS/HandBrakeWPF/Services/Encode/EncodeBase.cs
+++ b/win/CS/HandBrakeWPF/Services/Encode/EncodeBase.cs
@@ -18,6 +18,7 @@ namespace HandBrakeWPF.Services.Encode
using HandBrake.Interop.Model;
using HandBrakeWPF.Services.Encode.Interfaces;
+ using HandBrakeWPF.Services.Interfaces;
using HandBrakeWPF.Utilities;
using EncodeCompletedEventArgs = HandBrakeWPF.Services.Encode.EventArgs.EncodeCompletedEventArgs;
@@ -36,9 +37,12 @@ namespace HandBrakeWPF.Services.Encode
{
private readonly ILog logService;
- public EncodeBase(ILog logService)
+ private readonly IUserSettingService userSettingService;
+
+ public EncodeBase(ILog logService, IUserSettingService userSettingService)
{
this.logService = logService;
+ this.userSettingService = userSettingService;
}
#region Events
@@ -144,15 +148,15 @@ namespace HandBrakeWPF.Services.Encode
this.WriteFile(logContent, Path.Combine(logDir, encodeLogFile));
// Save a copy of the log file in the same location as the enocde.
- if (configuration.SaveLogWithVideo)
+ if (this.userSettingService.GetUserSetting<bool>(UserSettingConstants.SaveLogWithVideo))
{
this.WriteFile(logContent, Path.Combine(encodeDestinationPath, encodeLogFile));
}
// Save a copy of the log file to a user specified location
- if (Directory.Exists(configuration.SaveLogCopyDirectory) && configuration.SaveLogToCopyDirectory)
+ if (Directory.Exists(this.userSettingService.GetUserSetting<string>(UserSettingConstants.SaveLogCopyDirectory)) && this.userSettingService.GetUserSetting<bool>(UserSettingConstants.SaveLogToCopyDirectory))
{
- this.WriteFile(logContent, Path.Combine(configuration.SaveLogCopyDirectory, encodeLogFile));
+ this.WriteFile(logContent, Path.Combine(this.userSettingService.GetUserSetting<string>(UserSettingConstants.SaveLogCopyDirectory), encodeLogFile));
}
return Path.Combine(logDir, encodeLogFile);
diff --git a/win/CS/HandBrakeWPF/Services/Encode/Factories/QueueFactory.cs b/win/CS/HandBrakeWPF/Services/Encode/Factories/QueueFactory.cs
deleted file mode 100644
index b17385b47..000000000
--- a/win/CS/HandBrakeWPF/Services/Encode/Factories/QueueFactory.cs
+++ /dev/null
@@ -1,70 +0,0 @@
-// --------------------------------------------------------------------------------------------------------------------
-// <copyright file="QueueFactory.cs" company="HandBrake Project (http://handbrake.fr)">
-// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License.
-// </copyright>
-// <summary>
-// Defines the QueueFactory type.
-// </summary>
-// --------------------------------------------------------------------------------------------------------------------
-
-namespace HandBrakeWPF.Services.Encode.Factories
-{
- using System.Collections.Generic;
-
- using Caliburn.Micro;
-
- using HandBrake.Interop.Interop.HbLib.Wrappers.Interfaces;
- using HandBrake.Interop.Interop.Json.Queue;
- using HandBrake.Interop.Interop.Providers.Interfaces;
- using HandBrake.Interop.Model;
-
- using HandBrakeWPF.Services.Encode.Model;
- using HandBrakeWPF.Services.Interfaces;
-
- using Newtonsoft.Json;
-
- /// <summary>
- /// The queue factory.
- /// </summary>
- public class QueueFactory
- {
- /// <summary>
- /// For a givent set of tasks, return the Queue JSON that can be used for the CLI.
- /// </summary>
- /// <param name="tasks">
- /// The tasks.
- /// </param>
- /// <param name="configuration">
- /// The configuration.
- /// </param>
- /// <returns>
- /// The <see cref="string"/>.
- /// </returns>
- public static string GetQueueJson(List<EncodeTask> tasks, HBConfiguration configuration)
- {
- JsonSerializerSettings settings = new JsonSerializerSettings
- {
- NullValueHandling = NullValueHandling.Ignore,
- };
-
- IHbFunctionsProvider provider = IoC.Get<IHbFunctionsProvider>(); // TODO remove IoC call.
- IHbFunctions hbFunctions = provider.GetHbFunctionsWrapper();
-
- List<Task> queueJobs = new List<Task>();
- foreach (var item in tasks)
- {
- Task task = new Task { Job = EncodeTaskFactory.Create(item, configuration, hbFunctions) };
- queueJobs.Add(task);
- }
-
- return JsonConvert.SerializeObject(queueJobs, Formatting.Indented, settings);
- }
-
- public static List<Task> GetQueue(string content)
- {
- JsonSerializerSettings settings = new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore };
- List<Task> tasks = JsonConvert.DeserializeObject<List<Task>>(content, settings);
- return tasks;
- }
- }
-}
diff --git a/win/CS/HandBrakeWPF/Services/Encode/LibEncode.cs b/win/CS/HandBrakeWPF/Services/Encode/LibEncode.cs
index 02e5dc2c4..b71d06d3f 100644
--- a/win/CS/HandBrakeWPF/Services/Encode/LibEncode.cs
+++ b/win/CS/HandBrakeWPF/Services/Encode/LibEncode.cs
@@ -39,6 +39,7 @@ namespace HandBrakeWPF.Services.Encode
#region Private Variables
private readonly ILog log;
+ private readonly IUserSettingService userSettingService;
private readonly IHbFunctionsProvider hbFunctionsProvider;
private IEncodeInstance instance;
private DateTime startTime;
@@ -48,9 +49,10 @@ namespace HandBrakeWPF.Services.Encode
#endregion
- public LibEncode(IHbFunctionsProvider hbFunctionsProvider, ILog logService) : base(logService)
+ public LibEncode(IHbFunctionsProvider hbFunctionsProvider, ILog logService, IUserSettingService userSettingService) : base(logService, userSettingService)
{
this.log = logService;
+ this.userSettingService = userSettingService;
this.hbFunctionsProvider = hbFunctionsProvider;
}
@@ -109,7 +111,8 @@ namespace HandBrakeWPF.Services.Encode
this.TimedLogMessage(string.Format("base preset: {0}", basePresetName));
}
- this.instance = task.IsPreviewEncode ? HandBrakeInstanceManager.GetPreviewInstance(configuration.Verbosity, configuration) : HandBrakeInstanceManager.GetEncodeInstance(configuration.Verbosity, configuration, this.log);
+ int verbosity = this.userSettingService.GetUserSetting<int>(UserSettingConstants.Verbosity);
+ this.instance = task.IsPreviewEncode ? HandBrakeInstanceManager.GetPreviewInstance(verbosity, this.userSettingService) : HandBrakeInstanceManager.GetEncodeInstance(verbosity, configuration, this.log, userSettingService);
this.instance.EncodeCompleted += this.InstanceEncodeCompleted;
this.instance.EncodeProgress += this.InstanceEncodeProgress;
diff --git a/win/CS/HandBrakeWPF/Services/Presets/Factories/JsonPresetFactory.cs b/win/CS/HandBrakeWPF/Services/Presets/Factories/JsonPresetFactory.cs
index 3a3981f11..94c66adb1 100644
--- a/win/CS/HandBrakeWPF/Services/Presets/Factories/JsonPresetFactory.cs
+++ b/win/CS/HandBrakeWPF/Services/Presets/Factories/JsonPresetFactory.cs
@@ -658,7 +658,7 @@ namespace HandBrakeWPF.Services.Presets.Factories
preset.VideoQSVDecode = config.EnableQuickSyncDecoding;
preset.VideoQualitySlider = export.Task.Quality.HasValue ? export.Task.Quality.Value : 0;
preset.VideoQualityType = (int)export.Task.VideoEncodeRateType;
- preset.VideoScaler = EnumHelper<VideoScaler>.GetShortName(config.ScalingMode);
+ preset.VideoScaler = EnumHelper<VideoScaler>.GetShortName(VideoScaler.Lanczos);
preset.VideoTune = export.Task.VideoTunes.Aggregate(string.Empty, (current, item) => !string.IsNullOrEmpty(current) ? string.Format("{0}, {1}", current, item.ShortName) : item.ShortName);
preset.VideoAvgBitrate = export.Task.VideoBitrate ?? 0;
preset.VideoColorMatrixCode = 0; // TODO not supported.
diff --git a/win/CS/HandBrakeWPF/Services/Queue/QueueService.cs b/win/CS/HandBrakeWPF/Services/Queue/QueueService.cs
index 6cacd3331..9ebd4d33b 100644
--- a/win/CS/HandBrakeWPF/Services/Queue/QueueService.cs
+++ b/win/CS/HandBrakeWPF/Services/Queue/QueueService.cs
@@ -19,7 +19,11 @@ namespace HandBrakeWPF.Services.Queue
using System.Windows;
using System.Windows.Media.Imaging;
+ using Caliburn.Micro;
+
+ using HandBrake.Interop.Interop.HbLib.Wrappers.Interfaces;
using HandBrake.Interop.Interop.Json.Queue;
+ using HandBrake.Interop.Interop.Providers.Interfaces;
using HandBrake.Interop.Model;
using HandBrake.Interop.Utilities;
@@ -29,7 +33,6 @@ namespace HandBrakeWPF.Services.Queue
using HandBrakeWPF.Services.Encode.Factories;
using HandBrakeWPF.Services.Encode.Model;
using HandBrakeWPF.Services.Interfaces;
- using HandBrakeWPF.Services.Logging.Interfaces;
using HandBrakeWPF.Services.Queue.Model;
using HandBrakeWPF.Utilities;
@@ -39,6 +42,7 @@ namespace HandBrakeWPF.Services.Queue
using Execute = Caliburn.Micro.Execute;
using GeneralApplicationException = HandBrakeWPF.Exceptions.GeneralApplicationException;
using IEncode = HandBrakeWPF.Services.Encode.Interfaces.IEncode;
+ using ILog = HandBrakeWPF.Services.Logging.Interfaces.ILog;
using LogService = HandBrakeWPF.Services.Logging.LogService;
using QueueCompletedEventArgs = HandBrakeWPF.EventArgs.QueueCompletedEventArgs;
using QueueProgressEventArgs = HandBrakeWPF.EventArgs.QueueProgressEventArgs;
@@ -154,7 +158,7 @@ namespace HandBrakeWPF.Services.Queue
List<EncodeTask> workUnits = jobs.Select(job => job.Task).ToList();
HBConfiguration config = HBConfigurationFactory.Create(); // Default to current settings for now. These will hopefully go away in the future.
- string json = QueueFactory.GetQueueJson(workUnits, config);
+ string json = this.GetQueueJson(workUnits, config);
using (var strm = new StreamWriter(exportPath, false))
{
@@ -592,5 +596,37 @@ namespace HandBrakeWPF.Services.Queue
this.OnQueueCompleted(new QueueCompletedEventArgs(false));
}
}
+
+ /// <summary>
+ /// For a given set of tasks, return the Queue JSON that can be used for the CLI.
+ /// </summary>
+ /// <param name="tasks">
+ /// The tasks.
+ /// </param>
+ /// <param name="configuration">
+ /// The configuration.
+ /// </param>
+ /// <returns>
+ /// The <see cref="string"/>.
+ /// </returns>
+ private string GetQueueJson(List<EncodeTask> tasks, HBConfiguration configuration)
+ {
+ JsonSerializerSettings settings = new JsonSerializerSettings
+ {
+ NullValueHandling = NullValueHandling.Ignore,
+ };
+
+ IHbFunctionsProvider provider = IoC.Get<IHbFunctionsProvider>(); // TODO remove IoC call.
+ IHbFunctions hbFunctions = provider.GetHbFunctionsWrapper();
+
+ List<Task> queueJobs = new List<Task>();
+ foreach (var item in tasks)
+ {
+ Task task = new Task { Job = EncodeTaskFactory.Create(item, configuration, hbFunctions) };
+ queueJobs.Add(task);
+ }
+
+ return JsonConvert.SerializeObject(queueJobs, Formatting.Indented, settings);
+ }
}
} \ No newline at end of file
diff --git a/win/CS/HandBrakeWPF/Services/Scan/Interfaces/IScan.cs b/win/CS/HandBrakeWPF/Services/Scan/Interfaces/IScan.cs
index 61e34ddb4..09ef85cca 100644
--- a/win/CS/HandBrakeWPF/Services/Scan/Interfaces/IScan.cs
+++ b/win/CS/HandBrakeWPF/Services/Scan/Interfaces/IScan.cs
@@ -12,8 +12,6 @@ namespace HandBrakeWPF.Services.Scan.Interfaces
using System;
using System.Windows.Media.Imaging;
- using HandBrake.Interop.Model;
-
using HandBrakeWPF.Services.Encode.Model;
using HandBrakeWPF.Services.Scan.EventArgs;
using HandBrakeWPF.Services.Scan.Model;
@@ -78,10 +76,7 @@ namespace HandBrakeWPF.Services.Scan.Interfaces
/// <param name="postAction">
/// The post Action.
/// </param>
- /// <param name="configuration">
- /// The configuraiton.
- /// </param>
- void Scan(string sourcePath, int title, Action<bool, Source> postAction, HBConfiguration configuration);
+ void Scan(string sourcePath, int title, Action<bool, Source> postAction);
/// <summary>
/// Cancel the current scan.
@@ -97,13 +92,10 @@ namespace HandBrakeWPF.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, HBConfiguration configuration);
+ BitmapImage GetPreview(EncodeTask task, int preview);
/// <summary>
/// Kill the scan
diff --git a/win/CS/HandBrakeWPF/Services/Scan/LibScan.cs b/win/CS/HandBrakeWPF/Services/Scan/LibScan.cs
index 67f33ebbd..5cb336d46 100644
--- a/win/CS/HandBrakeWPF/Services/Scan/LibScan.cs
+++ b/win/CS/HandBrakeWPF/Services/Scan/LibScan.cs
@@ -24,6 +24,7 @@ namespace HandBrakeWPF.Services.Scan
using HandBrakeWPF.Instance;
using HandBrakeWPF.Services.Encode.Model;
+ using HandBrakeWPF.Services.Interfaces;
using HandBrakeWPF.Services.Scan.EventArgs;
using HandBrakeWPF.Services.Scan.Factories;
using HandBrakeWPF.Services.Scan.Interfaces;
@@ -40,53 +41,31 @@ namespace HandBrakeWPF.Services.Scan
/// </summary>
public class LibScan : IScan, IDisposable
{
- #region Private Variables
-
private readonly ILog log = null;
+ private readonly IUserSettingService userSettingService;
+
private TitleFactory titleFactory = new TitleFactory();
private string currentSourceScanPath;
private IHandBrakeInstance instance;
private Action<bool, Source> postScanOperation;
private bool isCancelled = false;
- #endregion
-
- public LibScan(ILog logService)
+ public LibScan(ILog logService, IUserSettingService userSettingService)
{
this.log = logService;
+ this.userSettingService = userSettingService;
this.IsScanning = false;
}
- #region Events
- /// <summary>
- /// Scan has Started
- /// </summary>
public event EventHandler ScanStarted;
- /// <summary>
- /// Scan has completed
- /// </summary>
public event ScanCompletedStatus ScanCompleted;
- /// <summary>
- /// Encode process has progressed
- /// </summary>
public event ScanProgessStatus ScanStatusChanged;
- #endregion
-
- #region Properties
-
- /// <summary>
- /// Gets a value indicating whether IsScanning.
- /// </summary>
public bool IsScanning { get; private set; }
- #endregion
-
- #region Public Methods
-
/// <summary>
/// Scan a Source Path.
/// Title 0: scan all
@@ -100,10 +79,7 @@ namespace HandBrakeWPF.Services.Scan
/// <param name="postAction">
/// The post Action.
/// </param>
- /// <param name="configuraiton">
- /// The configuraiton.
- /// </param>
- public void Scan(string sourcePath, int title, Action<bool, Source> postAction, HBConfiguration configuraiton)
+ public void Scan(string sourcePath, int title, Action<bool, Source> postAction)
{
// Try to cleanup any previous scan instances.
if (this.instance != null)
@@ -124,12 +100,12 @@ namespace HandBrakeWPF.Services.Scan
this.postScanOperation = postAction;
// Create a new HandBrake Instance.
- this.instance = HandBrakeInstanceManager.GetScanInstance(configuraiton.Verbosity, configuraiton);
+ this.instance = HandBrakeInstanceManager.GetScanInstance(this.userSettingService.GetUserSetting<int>(UserSettingConstants.Verbosity));
this.instance.ScanProgress += this.InstanceScanProgress;
this.instance.ScanCompleted += this.InstanceScanCompleted;
// Start the scan on a back
- this.ScanSource(sourcePath, title, configuraiton.PreviewScanCount, configuraiton);
+ this.ScanSource(sourcePath, title, this.userSettingService.GetUserSetting<int>(UserSettingConstants.PreviewScanCount));
}
/// <summary>
@@ -182,13 +158,10 @@ namespace HandBrakeWPF.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, HBConfiguration configuraiton)
+ public BitmapImage GetPreview(EncodeTask job, int preview)
{
if (this.instance == null)
{
@@ -224,10 +197,6 @@ namespace HandBrakeWPF.Services.Scan
return bitmapImage;
}
- #endregion
-
- #region Private Methods
-
/// <summary>
/// The service log message.
/// </summary>
@@ -251,10 +220,7 @@ namespace HandBrakeWPF.Services.Scan
/// <param name="previewCount">
/// The preview Count.
/// </param>
- /// <param name="configuraiton">
- /// The configuration.
- /// </param>
- private void ScanSource(object sourcePath, int title, int previewCount, HBConfiguration configuraiton)
+ private void ScanSource(object sourcePath, int title, int previewCount)
{
try
{
@@ -264,9 +230,9 @@ namespace HandBrakeWPF.Services.Scan
this.IsScanning = true;
- TimeSpan minDuration = TimeSpan.FromSeconds(configuraiton.MinScanDuration);
+ TimeSpan minDuration = TimeSpan.FromSeconds(this.userSettingService.GetUserSetting<int>(UserSettingConstants.MinScanDuration));
- HandBrakeUtils.SetDvdNav(!configuraiton.IsDvdNavDisabled);
+ HandBrakeUtils.SetDvdNav(!this.userSettingService.GetUserSetting<bool>(UserSettingConstants.DisableLibDvdNav));
this.ServiceLogMessage("Starting Scan ...");
this.instance.StartScan(sourcePath.ToString(), previewCount, minDuration, title != 0 ? title : 0);
@@ -279,10 +245,6 @@ namespace HandBrakeWPF.Services.Scan
this.Stop();
}
}
-
- #endregion
-
- #region HandBrakeInstance Event Handlers
/// <summary>
/// Scan Completed Event Handler
@@ -395,7 +357,6 @@ namespace HandBrakeWPF.Services.Scan
return titleList;
}
- #endregion
public void Dispose()
{
diff --git a/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs
index eab9a0fb7..7c8c28e6b 100644
--- a/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs
+++ b/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs
@@ -1650,7 +1650,7 @@ namespace HandBrakeWPF.ViewModels
EncodeTask task = queueTask.Task;
this.queueEditTask = queueTask;
- this.scanService.Scan(task.Source, task.Title, QueueEditAction, HBConfigurationFactory.Create());
+ this.scanService.Scan(task.Source, task.Title, QueueEditAction);
}
/// <summary>
@@ -2132,7 +2132,7 @@ namespace HandBrakeWPF.ViewModels
if (!string.IsNullOrEmpty(filename))
{
ShowSourceSelection = false;
- this.scanService.Scan(filename, title, null, HBConfigurationFactory.Create());
+ this.scanService.Scan(filename, title, null);
}
}
diff --git a/win/CS/HandBrakeWPF/ViewModels/StaticPreviewViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/StaticPreviewViewModel.cs
index 9cc5c70df..52b883c25 100644
--- a/win/CS/HandBrakeWPF/ViewModels/StaticPreviewViewModel.cs
+++ b/win/CS/HandBrakeWPF/ViewModels/StaticPreviewViewModel.cs
@@ -74,7 +74,7 @@ namespace HandBrakeWPF.ViewModels
// Live Preview
this.userSettingService = userSettingService;
this.errorService = errorService;
- this.encodeService = new LibEncode(hbFunctionsProvider, logService); // Preview needs a separate instance rather than the shared singleton. This could maybe do with being refactored at some point
+ this.encodeService = new LibEncode(hbFunctionsProvider, logService, userSettingService); // Preview needs a separate instance rather than the shared singleton. This could maybe do with being refactored at some point
this.Title = "Preview";
this.Percentage = "0.00%";
@@ -421,7 +421,7 @@ namespace HandBrakeWPF.ViewModels
BitmapSource image = null;
try
{
- image = this.scanService.GetPreview(this.Task, this.SelectedPreviewImage, HBConfigurationFactory.Create());
+ image = this.scanService.GetPreview(this.Task, this.SelectedPreviewImage);
}
catch (Exception exc)
{
diff --git a/win/CS/HandBrakeWPF/ViewModels/SummaryViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/SummaryViewModel.cs
index 161d403a5..1fcef8347 100644
--- a/win/CS/HandBrakeWPF/ViewModels/SummaryViewModel.cs
+++ b/win/CS/HandBrakeWPF/ViewModels/SummaryViewModel.cs
@@ -710,7 +710,7 @@ namespace HandBrakeWPF.ViewModels
BitmapSource image = null;
try
{
- image = this.scanService.GetPreview(this.Task, this.selectedPreview - 1, HBConfigurationFactory.Create());
+ image = this.scanService.GetPreview(this.Task, this.selectedPreview - 1);
}
catch (Exception exc)
{