summaryrefslogtreecommitdiffstats
path: root/win/CS/HandBrakeWPF/Services
diff options
context:
space:
mode:
authorsr55 <[email protected]>2015-01-22 16:32:22 +0000
committersr55 <[email protected]>2015-01-22 16:32:22 +0000
commitacf831a1c78044a01e470102385334d183d1d5b1 (patch)
treef508c79182ff84f33617dcf826110bd21312adeb /win/CS/HandBrakeWPF/Services
parent1ccc7a6a3caedda77d6e62972129727fb1598f35 (diff)
WinGui: Initial re-factoring of the Video Tab. Replaces encoder specific preset/tune/profile/level options with generic versions. This will break all existing user presets so the version number for the presets has been bumped. This should trigger the old presets to be archived.
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@6789 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'win/CS/HandBrakeWPF/Services')
-rw-r--r--win/CS/HandBrakeWPF/Services/Presets/Factories/PlistFactory.cs30
-rw-r--r--win/CS/HandBrakeWPF/Services/Presets/Factories/PlistPresetFactory.cs59
-rw-r--r--win/CS/HandBrakeWPF/Services/Presets/Model/Preset.cs1
-rw-r--r--win/CS/HandBrakeWPF/Services/Presets/Model/PresetContainer.cs12
-rw-r--r--win/CS/HandBrakeWPF/Services/Presets/PresetService.cs28
5 files changed, 60 insertions, 70 deletions
diff --git a/win/CS/HandBrakeWPF/Services/Presets/Factories/PlistFactory.cs b/win/CS/HandBrakeWPF/Services/Presets/Factories/PlistFactory.cs
index 5cd4db148..5892978cd 100644
--- a/win/CS/HandBrakeWPF/Services/Presets/Factories/PlistFactory.cs
+++ b/win/CS/HandBrakeWPF/Services/Presets/Factories/PlistFactory.cs
@@ -1,5 +1,5 @@
// --------------------------------------------------------------------------------------------------------------------
-// <copyright file="PlistUtility.cs" company="HandBrake Project (http://handbrake.fr)">
+// <copyright file="PlistFactory.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>
@@ -9,10 +9,10 @@
namespace HandBrakeWPF.Services.Presets.Factories
{
+ using System.Linq;
using System.Text;
using System.Xml;
- using HandBrake.ApplicationServices.Model;
using HandBrake.ApplicationServices.Services.Encode.Model;
using HandBrake.ApplicationServices.Services.Encode.Model.Models;
using HandBrake.ApplicationServices.Utilities;
@@ -23,7 +23,7 @@ namespace HandBrakeWPF.Services.Presets.Factories
/// <summary>
/// Plist Preset Converter
/// </summary>
- public class PlistUtility
+ public class PlistFactory
{
#region Export
@@ -199,21 +199,19 @@ namespace HandBrakeWPF.Services.Presets.Factories
AddEncodeElement(xmlWriter, "VideoFramerateMode", "string", parsed.FramerateMode.ToString().ToLower());
AddBooleanElement(xmlWriter, "VideoGrayScale", parsed.Grayscale);
AddEncodeElement(xmlWriter, "VideoQualitySlider", "real", parsed.Quality.ToString());
- AddEncodeElement(xmlWriter, "h264Level", "string", parsed.H264Level);
- AddEncodeElement(xmlWriter, "x264OptionExtra", "string", parsed.AdvancedEncoderOptions);
- AddEncodeElement(xmlWriter, "x264Preset", "string", parsed.X264Preset.ToString().ToLower());
- AddEncodeElement(xmlWriter, "h264Profile", "string", parsed.H264Profile.ToString().ToLower());
- string tune = parsed.X264Tune.ToString().ToLower();
- if (parsed.FastDecode)
- {
- tune = tune == "none" ? "fastdecode" : tune + ",fastdecode";
- }
- AddEncodeElement(xmlWriter, "x264Tune", "string", tune);
+
+ if (parsed.VideoPreset != null)
+ AddEncodeElement(xmlWriter, "VideoPreset", "string", parsed.VideoPreset.ShortName);
+ if (parsed.VideoLevel != null)
+ AddEncodeElement(xmlWriter, "VideoLevel", "string", parsed.VideoLevel.ShortName);
+ if (parsed.VideoProfile != null)
+ AddEncodeElement(xmlWriter, "VideoProfile", "string", parsed.VideoProfile.ShortName);
+ if (parsed.VideoTunes != null)
+ AddEncodeElement(xmlWriter, "VideoTune", "string", parsed.VideoTunes.Aggregate(string.Empty, (current, item) => string.IsNullOrEmpty(current) ? item.ShortName : "," + item.ShortName));
+
+ AddEncodeElement(xmlWriter, "VideoOptionExtra", "string", parsed.ExtraAdvancedArguments);
AddEncodeElement(xmlWriter, "x264UseAdvancedOptions", "integer", parsed.ShowAdvancedTab ? "1" : "0");
- AddEncodeElement(xmlWriter, "h265Profile", "string", parsed.H265Profile.ToString().ToLower());
- AddEncodeElement(xmlWriter, "x265Preset", "string", parsed.X265Preset.ToString().ToLower());
- AddEncodeElement(xmlWriter, "x265Tune", "string", parsed.X265Tune.ToString().ToLower());
int videoQualityType = 0;
if (parsed.VideoBitrate != null) videoQualityType = 1;
diff --git a/win/CS/HandBrakeWPF/Services/Presets/Factories/PlistPresetFactory.cs b/win/CS/HandBrakeWPF/Services/Presets/Factories/PlistPresetFactory.cs
index 7a6e336e8..a98e63e6d 100644
--- a/win/CS/HandBrakeWPF/Services/Presets/Factories/PlistPresetFactory.cs
+++ b/win/CS/HandBrakeWPF/Services/Presets/Factories/PlistPresetFactory.cs
@@ -15,13 +15,11 @@ namespace HandBrakeWPF.Services.Presets.Factories
using System.Globalization;
using System.Linq;
- using HandBrake.ApplicationServices.Model;
using HandBrake.ApplicationServices.Services.Encode.Model;
using HandBrake.ApplicationServices.Services.Encode.Model.Models;
+ using HandBrake.ApplicationServices.Services.Encode.Model.Models.Video;
using HandBrake.ApplicationServices.Utilities;
using HandBrake.Interop.Model.Encoding;
- using HandBrake.Interop.Model.Encoding.x264;
- using HandBrake.Interop.Model.Encoding.x265;
using HandBrakeWPF.Model.Audio;
using HandBrakeWPF.Model.Subtitles;
@@ -249,38 +247,25 @@ namespace HandBrakeWPF.Services.Presets.Factories
case "VideoTwoPass":
preset.Task.TwoPass = kvp.Value == 1;
break;
- case "x264OptionExtra":
- preset.Task.AdvancedEncoderOptions = kvp.Value;
+
+ case "VideoOptionExtra":
+ preset.Task.ExtraAdvancedArguments = kvp.Value;
break;
- case "x264Preset":
- preset.Task.X264Preset = EnumHelper<x264Preset>.GetValue(kvp.Value, true);
+ case "VideoLevel":
+ preset.Task.VideoLevel = new VideoLevel(kvp.Value, kvp.Value);
break;
- case "h264Profile":
- preset.Task.H264Profile = EnumHelper<x264Profile>.GetValue(kvp.Value, true);
+ case "VideoProfile":
+ preset.Task.VideoProfile = new VideoProfile(kvp.Value, kvp.Value);
break;
- case "x264Tune":
- string value = kvp.Value;
- if (value.Contains("fastdecode"))
+ case "VideoPreset":
+ preset.Task.VideoPreset = new VideoPreset(kvp.Value, kvp.Value);
+ break;
+ case "VideoTune":
+ string[] split = kvp.Value.ToString().Split(',');
+ foreach (var item in split)
{
- preset.Task.FastDecode = true;
- value = value.Replace("fastdecode", string.Empty).Replace(",", string.Empty);
+ preset.Task.VideoTunes.Add(new VideoTune(item, item));
}
- preset.Task.X264Tune = EnumHelper<x264Tune>.GetValue(value, true);
- break;
- case "h264Level":
- preset.Task.H264Level = kvp.Value;
- break;
- case "QsvPreset":
- preset.Task.QsvPreset = EnumHelper<QsvPreset>.GetValue(kvp.Value, true);
- break;
- case "h265Profile":
- preset.Task.H265Profile = EnumHelper<x265Profile>.GetValue(kvp.Value, true);
- break;
- case "x265Tune":
- preset.Task.X265Tune = EnumHelper<x265Tune>.GetValue(kvp.Value, true);
- break;
- case "x265Preset":
- preset.Task.X265Preset = EnumHelper<x265Preset>.GetValue(kvp.Value, true);
break;
// Chapter Markers Tab
@@ -288,21 +273,13 @@ namespace HandBrakeWPF.Services.Presets.Factories
preset.Task.IncludeChapterMarkers = kvp.Value == true;
break;
- // Advanced x264 tab
+ // Advanced tab
case "x264Option":
- if (preset.Task.VideoEncoder == VideoEncoder.X264) // TODO Temp fix until a better solution is found.
- {
- preset.Task.AdvancedEncoderOptions = kvp.Value;
- }
- break;
-
case "lavcOption":
- if (preset.Task.VideoEncoder != VideoEncoder.X264) // TODO Temp fix until a better solution is found.
- {
- preset.Task.AdvancedEncoderOptions = kvp.Value;
- }
+ preset.Task.AdvancedEncoderOptions = kvp.Value;
break;
+
// Preset Information
case "PresetBuildNumber":
preset.Version = kvp.Value;
diff --git a/win/CS/HandBrakeWPF/Services/Presets/Model/Preset.cs b/win/CS/HandBrakeWPF/Services/Presets/Model/Preset.cs
index e1b3d0e4d..1ea596ef7 100644
--- a/win/CS/HandBrakeWPF/Services/Presets/Model/Preset.cs
+++ b/win/CS/HandBrakeWPF/Services/Presets/Model/Preset.cs
@@ -11,7 +11,6 @@ namespace HandBrakeWPF.Services.Presets.Model
{
using Caliburn.Micro;
- using HandBrake.ApplicationServices.Model;
using HandBrake.ApplicationServices.Services.Encode.Model;
using HandBrakeWPF.Model.Audio;
diff --git a/win/CS/HandBrakeWPF/Services/Presets/Model/PresetContainer.cs b/win/CS/HandBrakeWPF/Services/Presets/Model/PresetContainer.cs
index be7e4afdc..f84f88b67 100644
--- a/win/CS/HandBrakeWPF/Services/Presets/Model/PresetContainer.cs
+++ b/win/CS/HandBrakeWPF/Services/Presets/Model/PresetContainer.cs
@@ -9,8 +9,20 @@
namespace HandBrakeWPF.Services.Presets.Model
{
+ /// <summary>
+ /// The preset container.
+ /// </summary>
public class PresetContainer
{
+ /// <summary>
+ /// Initializes a new instance of the <see cref="PresetContainer"/> class.
+ /// </summary>
+ /// <param name="version">
+ /// The version.
+ /// </param>
+ /// <param name="presets">
+ /// The presets.
+ /// </param>
public PresetContainer(int version, string presets)
{
Version = version;
diff --git a/win/CS/HandBrakeWPF/Services/Presets/PresetService.cs b/win/CS/HandBrakeWPF/Services/Presets/PresetService.cs
index be8357f68..cb9e161b2 100644
--- a/win/CS/HandBrakeWPF/Services/Presets/PresetService.cs
+++ b/win/CS/HandBrakeWPF/Services/Presets/PresetService.cs
@@ -18,7 +18,6 @@ namespace HandBrakeWPF.Services.Presets
using System.Text;
using System.Text.RegularExpressions;
using System.Windows;
- using System.Windows.Forms;
using System.Xml.Serialization;
using HandBrake.ApplicationServices.Exceptions;
@@ -38,7 +37,7 @@ namespace HandBrakeWPF.Services.Presets
{
#region Private Variables
- private static readonly int CurrentPresetVersion = 1;
+ private static readonly int CurrentPresetVersion = 2;
/// <summary>
/// XML Serializer
@@ -310,12 +309,12 @@ namespace HandBrakeWPF.Services.Presets
Preset newPreset = new Preset
{
- Category = category,
- Name = presetName[0].Replace("+", string.Empty).Trim(),
- Version = VersionHelper.GetVersion(),
+ Category = category,
+ Name = presetName[0].Replace("+", string.Empty).Trim(),
+ Version = VersionHelper.GetVersion(),
Description = string.Empty, // Maybe one day we will populate this.
- IsBuildIn = true,
- UsePictureFilters = true,
+ IsBuildIn = true,
+ UsePictureFilters = true,
Task = QueryParserUtility.Parse(presetName[2])
};
@@ -374,8 +373,12 @@ namespace HandBrakeWPF.Services.Presets
/// <summary>
/// Check if the preset "name" exists in either Presets or UserPresets lists.
/// </summary>
- /// <param name="name">Name of the preset</param>
- /// <returns>True if found</returns>
+ /// <param name="name">
+ /// Name of the preset
+ /// </param>
+ /// <returns>
+ /// True if found
+ /// </returns>
public bool CheckIfPresetExists(string name)
{
return name == string.Empty || this.presets.Any(item => item.Name == name);
@@ -453,6 +456,7 @@ namespace HandBrakeWPF.Services.Presets
foreach (Preset preset in list)
{
preset.IsBuildIn = true;
+
// Older versions did not have this flag so explicitly make sure it is set.
this.presets.Add(preset);
}
@@ -519,9 +523,9 @@ namespace HandBrakeWPF.Services.Presets
string fileName = RecoverFromCorruptedPresetFile(this.userPresetFile);
this.errorService.ShowMessageBox(
"HandBrake is unable to load your user presets because they are from an older version of HandBrake. Your old presets file has been renamed so that it doesn't get loaded on next launch."
- + Environment.NewLine + Environment.NewLine + "Archived File: " + fileName,
- "Unable to load user presets.",
- MessageBoxButton.OK,
+ + Environment.NewLine + Environment.NewLine + "Archived File: " + fileName,
+ "Unable to load user presets.",
+ MessageBoxButton.OK,
MessageBoxImage.Exclamation);
return;
}