summaryrefslogtreecommitdiffstats
path: root/win/CS/HandBrakeWPF/Services
diff options
context:
space:
mode:
authorsr55 <[email protected]>2020-04-11 16:17:06 +0100
committersr55 <[email protected]>2020-04-11 16:17:06 +0100
commitfa81cfaf559d8a53a86a9958025e2d4674887910 (patch)
tree2c145318a2e67ecdc9db43d81e818f753c2f2d6a /win/CS/HandBrakeWPF/Services
parenta06bd83f2d1b1e9edc190fa09bdb7f0752783a7f (diff)
WinGui: If selecting a preset that uses an video encoder that's not in use, warn the user and don't select the preset. #2631
Diffstat (limited to 'win/CS/HandBrakeWPF/Services')
-rw-r--r--win/CS/HandBrakeWPF/Services/Presets/Model/Preset.cs2
-rw-r--r--win/CS/HandBrakeWPF/Services/Presets/PresetService.cs45
2 files changed, 47 insertions, 0 deletions
diff --git a/win/CS/HandBrakeWPF/Services/Presets/Model/Preset.cs b/win/CS/HandBrakeWPF/Services/Presets/Model/Preset.cs
index ca747c341..df21ccf9b 100644
--- a/win/CS/HandBrakeWPF/Services/Presets/Model/Preset.cs
+++ b/win/CS/HandBrakeWPF/Services/Presets/Model/Preset.cs
@@ -146,6 +146,8 @@ namespace HandBrakeWPF.Services.Presets.Model
/// </summary>
public SubtitleBehaviours SubtitleTrackBehaviours { get; set; }
+ public bool IsPresetDisabled { get; set; }
+
#endregion
#region Public Methods
diff --git a/win/CS/HandBrakeWPF/Services/Presets/PresetService.cs b/win/CS/HandBrakeWPF/Services/Presets/PresetService.cs
index 6c715fa8f..0879c67d8 100644
--- a/win/CS/HandBrakeWPF/Services/Presets/PresetService.cs
+++ b/win/CS/HandBrakeWPF/Services/Presets/PresetService.cs
@@ -23,6 +23,7 @@ namespace HandBrakeWPF.Services.Presets
using HandBrake.Interop.Interop;
using HandBrake.Interop.Interop.Json.Presets;
using HandBrake.Interop.Interop.Model;
+ using HandBrake.Interop.Interop.Model.Encoding;
using HandBrake.Interop.Model;
using HandBrake.Interop.Utilities;
@@ -41,6 +42,7 @@ namespace HandBrakeWPF.Services.Presets
using Newtonsoft.Json;
using GeneralApplicationException = HandBrakeWPF.Exceptions.GeneralApplicationException;
+ using SystemInfo = HandBrake.Interop.Utilities.SystemInfo;
/// <summary>
/// The preset service manages HandBrake's presets
@@ -192,6 +194,7 @@ namespace HandBrakeWPF.Services.Presets
foreach (HBPreset hbPreset in category.ChildrenArray)
{
Preset preset = this.ConvertHbPreset(hbPreset);
+ preset.IsPresetDisabled = this.IsPresetDisabled(preset);
if (preset != null && !preset.IsBuildIn)
{
this.AddOrUpdateImportedPreset(preset);
@@ -208,6 +211,7 @@ namespace HandBrakeWPF.Services.Presets
if (hbPreset != null)
{
Preset preset = this.ConvertHbPreset(hbPreset);
+ preset.IsPresetDisabled = this.IsPresetDisabled(preset);
if (preset != null && !preset.IsBuildIn)
{
this.AddOrUpdateImportedPreset(preset);
@@ -751,6 +755,7 @@ namespace HandBrakeWPF.Services.Presets
// Migration
preset.Category = category.PresetName == "User Presets" ? UserPresetCatgoryName : category.PresetName;
preset.IsBuildIn = hbpreset.Type == 0;
+ preset.IsPresetDisabled = this.IsPresetDisabled(preset);
// IF we are using Source Max, Set the Max Width / Height values.
if (preset.PictureSettingsMode == PresetPictureSettingsMode.SourceMaximum)
@@ -906,6 +911,46 @@ namespace HandBrakeWPF.Services.Presets
}
}
+ private bool IsPresetDisabled(Preset preset)
+ {
+ if (preset.Task.VideoEncoder == VideoEncoder.QuickSync && !SystemInfo.IsQsvAvailable)
+ {
+ return true;
+ }
+
+ if (preset.Task.VideoEncoder == VideoEncoder.QuickSyncH265 && !SystemInfo.IsQsvAvailableH265)
+ {
+ return true;
+ }
+
+ if (preset.Task.VideoEncoder == VideoEncoder.QuickSyncH26510b && !SystemInfo.IsQsvAvailableH265)
+ {
+ return true;
+ }
+
+ if (preset.Task.VideoEncoder == VideoEncoder.VceH264 && !SystemInfo.IsVceH264Available)
+ {
+ return true;
+ }
+
+ if (preset.Task.VideoEncoder == VideoEncoder.VceH265 && !SystemInfo.IsVceH265Available)
+ {
+ return true;
+ }
+
+ if (preset.Task.VideoEncoder == VideoEncoder.NvencH264 && !SystemInfo.IsNVEncH264Available)
+ {
+ return true;
+ }
+
+ if (preset.Task.VideoEncoder == VideoEncoder.NvencH265 && !SystemInfo.IsNVEncH265Available)
+ {
+ return true;
+ }
+
+ return false;
+ }
+
protected void ServiceLogMessage(string message)
{
this.log.LogMessage(string.Format("Preset Service: {0}{1}{0}", Environment.NewLine, message));