diff options
Diffstat (limited to 'win/CS/HandBrakeWPF/Services')
7 files changed, 66 insertions, 140 deletions
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() { |