summaryrefslogtreecommitdiffstats
path: root/win
diff options
context:
space:
mode:
authorsr55 <[email protected]>2012-10-27 19:54:23 +0000
committersr55 <[email protected]>2012-10-27 19:54:23 +0000
commitecc63f962529a9d85f619097e6658595997e33b3 (patch)
tree87ad6a8fccb0359855633e7b3311df7aed89de0f /win
parent8b7552139a158d00391d074d4e37d2e7c79961e2 (diff)
WinGui: Initial work to overhaul the plist import code.
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@5039 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'win')
-rw-r--r--win/CS/HandBrake.ApplicationServices/Factories/PlistPresetFactory.cs336
-rw-r--r--win/CS/HandBrake.ApplicationServices/HandBrake.ApplicationServices.csproj5
-rw-r--r--win/CS/HandBrake.ApplicationServices/Model/Preset.cs5
-rw-r--r--win/CS/HandBrake.ApplicationServices/Model/PresetPictureSettingsMode.cs6
-rw-r--r--win/CS/HandBrake.ApplicationServices/Utilities/PList.cs156
-rw-r--r--win/CS/HandBrake.ApplicationServices/Utilities/PlistUtility.cs450
-rw-r--r--win/CS/HandBrake.Interop/HandBrakeInterop/Model/Encoding/Anamorphic.cs6
-rw-r--r--win/CS/HandBrake.Interop/HandBrakeInterop/Model/Encoding/Decomb.cs8
-rw-r--r--win/CS/HandBrake.Interop/HandBrakeInterop/Model/Encoding/Deinterlace.cs15
-rw-r--r--win/CS/HandBrake.Interop/HandBrakeInterop/Model/Encoding/Denoise.cs8
-rw-r--r--win/CS/HandBrake.Interop/HandBrakeInterop/Model/Encoding/Detelecine.cs4
-rw-r--r--win/CS/HandBrake.Interop/HandBrakeInterop/Model/Encoding/VideoEncodeRateType.cs4
-rw-r--r--win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs5
-rw-r--r--win/CS/HandBrakeWPF/Views/MainView.xaml1
14 files changed, 533 insertions, 476 deletions
diff --git a/win/CS/HandBrake.ApplicationServices/Factories/PlistPresetFactory.cs b/win/CS/HandBrake.ApplicationServices/Factories/PlistPresetFactory.cs
new file mode 100644
index 000000000..f07f0aa01
--- /dev/null
+++ b/win/CS/HandBrake.ApplicationServices/Factories/PlistPresetFactory.cs
@@ -0,0 +1,336 @@
+// --------------------------------------------------------------------------------------------------------------------
+// <copyright file="PlistPresetFactory.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>
+// A Factory to translate a Plist object into a Preset.
+// </summary>
+// --------------------------------------------------------------------------------------------------------------------
+
+namespace HandBrake.ApplicationServices.Factories
+{
+ using System.Collections.Generic;
+ using System.Collections.ObjectModel;
+ using System.Globalization;
+ using System.Linq;
+
+ using HandBrake.ApplicationServices.Model;
+ using HandBrake.ApplicationServices.Model.Encoding;
+ using HandBrake.ApplicationServices.Services;
+ using HandBrake.ApplicationServices.Utilities;
+ using HandBrake.Interop.Model.Encoding;
+
+ /// <summary>
+ /// A Factory to translate a Plist object into a Preset.
+ /// </summary>
+ public class PlistPresetFactory
+ {
+ /// <summary>
+ /// The create preset.
+ /// </summary>
+ /// <param name="plist">
+ /// The plist.
+ /// </param>
+ /// <returns>
+ /// The <see cref="Preset"/>.
+ /// </returns>
+ public static Preset CreatePreset(PList plist)
+ {
+ Preset preset = new Preset { Task = new EncodeTask(), Category = PresetService.UserPresetCatgoryName };
+
+ // Parse the settings out.
+ foreach (var item in plist)
+ {
+ if (item.Key == "AudioList")
+ {
+ List<AudioTrack> tracks = ParseAudioTracks(item.Value);
+ preset.Task.AudioTracks = new ObservableCollection<AudioTrack>(tracks);
+ }
+ else
+ {
+ ParseSetting(item, preset);
+ }
+ }
+
+ // Handle the PictureDecombDeinterlace key
+ if (preset.UseDeinterlace)
+ {
+ preset.Task.Decomb = Decomb.Off;
+ preset.Task.CustomDecomb = string.Empty;
+ }
+
+ // Depending on the selected preset options, we may need to change some settings around.
+ // If the user chose not to use fitlers, remove them.
+ if (!preset.UsePictureFilters)
+ {
+ preset.Task.Detelecine = Detelecine.Off;
+ preset.Task.Denoise = Denoise.Off;
+ preset.Task.Deinterlace = Deinterlace.Off;
+ preset.Task.Decomb = Decomb.Off;
+ preset.Task.Deblock = 0;
+ preset.Task.Grayscale = false;
+ }
+
+ // IF we are using Source Max, Set the Max Width / Height values.
+ if (preset.PictureSettingsMode == PresetPictureSettingsMode.SourceMaximum)
+ {
+ preset.Task.MaxWidth = preset.Task.Height;
+ preset.Task.MaxHeight = preset.Task.Width;
+ }
+
+
+ return preset;
+ }
+
+ /// <summary>
+ /// Parse a setting and set it in the given preset.
+ /// </summary>
+ /// <param name="kvp">
+ /// The kvp setting pair.
+ /// </param>
+ /// <param name="preset">
+ /// The preset object.
+ /// </param>
+ private static void ParseSetting(KeyValuePair<string, dynamic> kvp, Preset preset)
+ {
+ switch (kvp.Key)
+ {
+ // Output Settings
+ case "FileFormat":
+ preset.Task.OutputFormat = Converters.GetFileFormat(kvp.Value.Replace("file", string.Empty).Trim());
+ break;
+ case "Mp4HttpOptimize":
+ preset.Task.OptimizeMP4 = kvp.Value == 1;
+ break;
+ case "Mp4LargeFile":
+ preset.Task.LargeFile = kvp.Value == 1;
+ break;
+ case "Mp4iPodCompatible":
+ preset.Task.IPod5GSupport = kvp.Value == 1;
+ break;
+
+ // Picture Settings
+ case "PictureAutoCrop":
+ preset.Task.HasCropping = kvp.Value != 1;
+ break;
+ case "PictureTopCrop":
+ preset.Task.Cropping.Top = kvp.Value;
+ break;
+ case "PictureBottomCrop":
+ preset.Task.Cropping.Bottom = kvp.Value;
+ break;
+ case "PictureLeftCrop":
+ preset.Task.Cropping.Left = kvp.Value;
+ break;
+ case "PictureRightCrop":
+ preset.Task.Cropping.Right = kvp.Value;
+ break;
+ case "PictureHeight":
+ preset.Task.Height = kvp.Value;
+ break;
+ case "PictureWidth":
+ preset.Task.Width = kvp.Value;
+ break;
+ case "PictureKeepRatio":
+ preset.Task.KeepDisplayAspect = kvp.Value == 1;
+ break;
+ case "PicturePAR":
+ preset.Task.Anamorphic = (Anamorphic)kvp.Value;
+ break;
+
+ // Filters
+ case "PictureDeblock":
+ preset.Task.Deblock = kvp.Value;
+ break;
+ case "PictureDecomb":
+ preset.Task.Decomb = (Decomb)kvp.Value;
+ break;
+ case "PictureDecombCustom":
+ preset.Task.CustomDecomb = kvp.Value;
+ break;
+ case "PictureDecombDeinterlace":
+ preset.UseDeinterlace = kvp.Value == 1;
+ break;
+ case "PictureDeinterlace":
+ preset.Task.Deinterlace = (Deinterlace)kvp.Value;
+ break;
+ case "PictureDeinterlaceCustom":
+ preset.Task.CustomDeinterlace = kvp.Value;
+ break;
+ case "PictureDenoise":
+ preset.Task.Denoise = (Denoise)kvp.Value;
+ break;
+ case "PictureDenoiseCustom":
+ preset.Task.CustomDenoise = kvp.Value;
+ break;
+ case "PictureDetelecine":
+ preset.Task.Detelecine = (Detelecine)kvp.Value;
+ break;
+ case "PictureDetelecineCustom":
+ preset.Task.CustomDetelecine = kvp.Value;
+ break;
+
+ // Video Tab
+ case "VideoAvgBitrate":
+ preset.Task.VideoBitrate = int.Parse(kvp.Value);
+ break;
+ case "VideoEncoder":
+ preset.Task.VideoEncoder = EnumHelper<VideoEncoder>.GetValue(kvp.Value);
+ break;
+ case "VideoFramerate":
+ preset.Task.Framerate = kvp.Value == "Same as source" ? null : double.Parse(kvp.Value, CultureInfo.InvariantCulture);
+ break;
+ case "VideoFramerateMode":
+ string parsedValue = kvp.Value;
+ switch (parsedValue)
+ {
+ case "vfr":
+ preset.Task.FramerateMode = FramerateMode.VFR;
+ break;
+ case "cfr":
+ preset.Task.FramerateMode = FramerateMode.CFR;
+ break;
+ default:
+ preset.Task.FramerateMode = FramerateMode.PFR;
+ break;
+ }
+ break;
+ case "VideoGrayScale":
+ preset.Task.Grayscale = kvp.Value == 1;
+ break;
+ case "VideoQualitySlider":
+ preset.Task.Quality = double.Parse(kvp.Value.ToString(), CultureInfo.InvariantCulture);
+ break;
+ case "VideoQualityType": // The Type of Quality Mode used
+ preset.Task.VideoEncodeRateType = (VideoEncodeRateType)kvp.Value;
+ break;
+ case "VideoTurboTwoPass":
+ preset.Task.TurboFirstPass = kvp.Value == 1;
+ break;
+ case "VideoTwoPass":
+ preset.Task.TwoPass = kvp.Value == 1;
+ break;
+
+ // Chapter Markers Tab
+ case "ChapterMarkers":
+ preset.Task.IncludeChapterMarkers = kvp.Value == 1;
+ break;
+
+ // Advanced x264 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;
+ }
+ break;
+
+ // Preset Information
+ case "PresetBuildNumber":
+ preset.Version = kvp.Value;
+ break;
+ case "PresetDescription":
+ preset.Description = kvp.Value;
+ break;
+ case "PresetName":
+ preset.Name = kvp.Value;
+ break;
+ case "Type":
+ //preset.Task.Type = kvp.Value; // TODO find out what this is
+ break;
+ case "UsesMaxPictureSettings":
+ // TODO Not sure if this is used now!?
+ break;
+ case "UsesPictureFilters":
+ preset.UsePictureFilters = kvp.Value == 1;
+ break;
+ case "UsesPictureSettings":
+ preset.PictureSettingsMode = (PresetPictureSettingsMode)kvp.Value;
+ break;
+
+ // Allowed Passthru
+ case "AudioAllowAACPass":
+ preset.Task.AllowedPassthruOptions.AudioAllowAACPass = kvp.Value == 1;
+ break;
+ case "AudioAllowAC3Pass":
+ preset.Task.AllowedPassthruOptions.AudioAllowAC3Pass = kvp.Value == 1;
+ break;
+ case "AudioAllowDTSHDPass":
+ preset.Task.AllowedPassthruOptions.AudioAllowDTSHDPass = kvp.Value == 1;
+ break;
+ case "AudioAllowDTSPass":
+ preset.Task.AllowedPassthruOptions.AudioAllowDTSPass = kvp.Value == 1;
+ break;
+ case "AudioAllowMP3Pass":
+ preset.Task.AllowedPassthruOptions.AudioAllowMP3Pass = kvp.Value == 1;
+ break;
+ case "AudioEncoderFallback":
+ preset.Task.AllowedPassthruOptions.AudioEncoderFallback = EnumHelper<AudioEncoder>.GetValue(kvp.Value);
+ break;
+ }
+ }
+
+ /// <summary>
+ /// Parse a number of audio tracks
+ /// </summary>
+ /// <param name="audioList">
+ /// The audio list.
+ /// </param>
+ /// <returns>
+ /// The <see cref="List"/> of audio tracks
+ /// </returns>
+ private static List<AudioTrack> ParseAudioTracks(IEnumerable<dynamic> audioList)
+ {
+ return audioList.Select(item => ParseAudioTrackParameters(item)).Cast<AudioTrack>().ToList();
+ }
+
+ /// <summary>
+ /// Parse an audio track's parameters.
+ /// </summary>
+ /// <param name="audioTrack">
+ /// The audio track params
+ /// </param>
+ /// <returns>
+ /// An <see cref="AudioTrack"/> Object
+ /// </returns>
+ private static AudioTrack ParseAudioTrackParameters(Dictionary<string, dynamic> audioTrack)
+ {
+ AudioTrack track = new AudioTrack();
+ foreach (var item in audioTrack)
+ {
+ switch (item.Key)
+ {
+ case "AudioBitrate":
+ track.Bitrate = int.Parse(item.Value);
+ break;
+ case "AudioEncoder":
+ track.Encoder = Converters.GetAudioEncoder(item.Value.Trim());
+ break;
+ case "AudioMixdown":
+ track.MixDown = Converters.GetAudioMixDown(item.Value.Trim());
+ break;
+ case "AudioSamplerate":
+ track.SampleRate = item.Value == "Auto" ? 0 : double.Parse(item.Value, CultureInfo.InvariantCulture);
+ break;
+ case "AudioTrack":
+ //track.SourceTrack = value; We don't do anything with this one.
+ break;
+ case "AudioTrackDRCSlider":
+ track.DRC = double.Parse(item.Value.ToString(), CultureInfo.InvariantCulture);
+ break;
+ case "AudioTrackGainSlider":
+ track.Gain = int.Parse(item.Value.ToString(), CultureInfo.InvariantCulture);
+ break;
+ }
+ }
+
+ return track;
+ }
+ }
+}
diff --git a/win/CS/HandBrake.ApplicationServices/HandBrake.ApplicationServices.csproj b/win/CS/HandBrake.ApplicationServices/HandBrake.ApplicationServices.csproj
index af024c7e8..6730e2d66 100644
--- a/win/CS/HandBrake.ApplicationServices/HandBrake.ApplicationServices.csproj
+++ b/win/CS/HandBrake.ApplicationServices/HandBrake.ApplicationServices.csproj
@@ -57,6 +57,7 @@
<SpecificVersion>False</SpecificVersion>
<HintPath>..\libraries\caliburn\Castle.Windsor.dll</HintPath>
</Reference>
+ <Reference Include="Microsoft.CSharp" />
<Reference Include="PresentationCore" />
<Reference Include="PresentationFramework" />
<Reference Include="System" />
@@ -89,6 +90,7 @@
<Compile Include="EventArgs\ScanCompletedEventArgs.cs" />
<Compile Include="EventArgs\ScanProgressEventArgs.cs" />
<Compile Include="Extensions\StringExtensions.cs" />
+ <Compile Include="Factories\PlistPresetFactory.cs" />
<Compile Include="Isolation\BackgroundServiceConnector.cs" />
<Compile Include="Isolation\IsolatedEncodeService.cs" />
<Compile Include="Isolation\IsolatedScanService.cs" />
@@ -100,6 +102,8 @@
<Compile Include="Utilities\Converters.cs" />
<Compile Include="Utilities\EnumHelper.cs" />
<Compile Include="Utilities\InteropModelCreator.cs" />
+ <Compile Include="Utilities\PList.cs" />
+ <Compile Include="Utilities\PlistUtility.cs" />
<Compile Include="Utilities\SystemInfo.cs" />
<Compile Include="Utilities\Win32.cs" />
<Compile Include="Utilities\Win7.cs" />
@@ -148,7 +152,6 @@
<Compile Include="Utilities\CharCodesUtilities.cs" />
<Compile Include="Utilities\GeneralUtilities.cs" />
<Compile Include="Utilities\LanguageUtilities.cs" />
- <Compile Include="Utilities\PlistUtility.cs" />
<Compile Include="Utilities\QueryGeneratorUtility.cs" />
<Compile Include="Utilities\QueryParserUtility.cs" />
</ItemGroup>
diff --git a/win/CS/HandBrake.ApplicationServices/Model/Preset.cs b/win/CS/HandBrake.ApplicationServices/Model/Preset.cs
index 128bf5c21..7003ca2c7 100644
--- a/win/CS/HandBrake.ApplicationServices/Model/Preset.cs
+++ b/win/CS/HandBrake.ApplicationServices/Model/Preset.cs
@@ -70,6 +70,11 @@ namespace HandBrake.ApplicationServices.Model
public PresetPictureSettingsMode PictureSettingsMode { get; set; }
/// <summary>
+ /// Gets or sets a value indicating whether use deinterlace.
+ /// </summary>
+ public bool UseDeinterlace { get; set; }
+
+ /// <summary>
/// Gets or sets task.
/// </summary>
public EncodeTask Task { get; set; }
diff --git a/win/CS/HandBrake.ApplicationServices/Model/PresetPictureSettingsMode.cs b/win/CS/HandBrake.ApplicationServices/Model/PresetPictureSettingsMode.cs
index a79f4b0e3..e670ccb7e 100644
--- a/win/CS/HandBrake.ApplicationServices/Model/PresetPictureSettingsMode.cs
+++ b/win/CS/HandBrake.ApplicationServices/Model/PresetPictureSettingsMode.cs
@@ -17,10 +17,10 @@ namespace HandBrake.ApplicationServices.Model
public enum PresetPictureSettingsMode
{
[Display(Name = "None")]
- None,
+ None = 0,
[Display(Name = "Custom")]
- Custom,
+ Custom = 1,
[Display(Name = "Source Maximum")]
- SourceMaximum,
+ SourceMaximum = 2,
}
} \ No newline at end of file
diff --git a/win/CS/HandBrake.ApplicationServices/Utilities/PList.cs b/win/CS/HandBrake.ApplicationServices/Utilities/PList.cs
new file mode 100644
index 000000000..48212b519
--- /dev/null
+++ b/win/CS/HandBrake.ApplicationServices/Utilities/PList.cs
@@ -0,0 +1,156 @@
+// --------------------------------------------------------------------------------------------------------------------
+// <copyright file="PList.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>
+// A Helper class to parse plist files.
+// </summary>
+// --------------------------------------------------------------------------------------------------------------------
+
+namespace HandBrake.ApplicationServices.Utilities
+{
+ using System;
+ using System.Collections.Generic;
+ using System.Linq;
+ using System.Xml.Linq;
+
+ /// <summary>
+ /// A Helper class to parse plist files.
+ /// </summary>
+ public class PList : Dictionary<string, dynamic>
+ {
+ #region Constructors and Destructors
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="PList"/> class.
+ /// </summary>
+ public PList()
+ {
+ }
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="PList"/> class.
+ /// </summary>
+ /// <param name="file">
+ /// The file.
+ /// </param>
+ public PList(string file)
+ {
+ this.Load(file);
+ }
+
+ #endregion
+
+ #region Public Methods
+
+
+ /// <summary>
+ /// Load a plist file.
+ /// </summary>
+ /// <param name="file">
+ /// The file name / path
+ /// </param>
+ /// <returns>
+ /// True if successful, false otherwise.
+ /// </returns>
+ public bool Load(string file)
+ {
+ this.Clear();
+
+ XDocument doc = XDocument.Load(file);
+ XElement plist = doc.Element("plist");
+ if (plist != null)
+ {
+ XElement array = plist.Element("array");
+ if (array != null)
+ {
+ XElement dict = array.Element("dict");
+
+ if (dict != null)
+ {
+ IEnumerable<XElement> dictElements = dict.Elements();
+ this.Parse(this, dictElements);
+ return true;
+ }
+ }
+ }
+
+ return false;
+ }
+
+ #endregion
+
+ #region Methods
+
+ /// <summary>
+ /// Parse a list of elements
+ /// </summary>
+ /// <param name="dict">
+ /// The dict.
+ /// </param>
+ /// <param name="elements">
+ /// The elements.
+ /// </param>
+ private void Parse(PList dict, IEnumerable<XElement> elements)
+ {
+ for (int i = 0; i < elements.Count(); i += 2)
+ {
+ XElement key = elements.ElementAt(i);
+ XElement val = elements.ElementAt(i + 1);
+
+ dict[key.Value] = this.ParseValue(val);
+ }
+ }
+
+ /// <summary>
+ /// The parse array.
+ /// </summary>
+ /// <param name="elements">
+ /// The elements.
+ /// </param>
+ /// <returns>
+ /// The <see cref="List"/>.
+ /// </returns>
+ private List<dynamic> ParseArray(IEnumerable<XElement> elements)
+ {
+ return elements.Select(e => this.ParseValue(e)).ToList();
+ }
+
+ /// <summary>
+ /// The parse value.
+ /// </summary>
+ /// <param name="val">
+ /// The XElement.
+ /// </param>
+ /// <returns>
+ /// The parsed value object.
+ /// </returns>
+ private dynamic ParseValue(XElement val)
+ {
+ switch (val.Name.ToString())
+ {
+ case "string":
+ return val.Value;
+ case "integer":
+ return int.Parse(val.Value);
+ case "real":
+ return float.Parse(val.Value);
+ case "true":
+ return true;
+ case "false":
+ return false;
+ case "dict":
+ var plist = new PList();
+ this.Parse(plist, val.Elements());
+ return plist;
+ case "array":
+ List<dynamic> list = this.ParseArray(val.Elements());
+ return list;
+ default:
+ throw new ArgumentException("This plist file is not supported.");
+ }
+ }
+
+ #endregion
+ }
+} \ No newline at end of file
diff --git a/win/CS/HandBrake.ApplicationServices/Utilities/PlistUtility.cs b/win/CS/HandBrake.ApplicationServices/Utilities/PlistUtility.cs
index 797c456f3..bea765e27 100644
--- a/win/CS/HandBrake.ApplicationServices/Utilities/PlistUtility.cs
+++ b/win/CS/HandBrake.ApplicationServices/Utilities/PlistUtility.cs
@@ -9,16 +9,11 @@
namespace HandBrake.ApplicationServices.Utilities
{
- using System;
- using System.Collections.ObjectModel;
- using System.IO;
using System.Text;
- using System.Windows.Forms;
using System.Xml;
using HandBrake.ApplicationServices.Model;
using HandBrake.ApplicationServices.Model.Encoding;
- using HandBrake.ApplicationServices.Services;
using HandBrake.Interop.Model.Encoding;
/// <summary>
@@ -26,451 +21,6 @@ namespace HandBrake.ApplicationServices.Utilities
/// </summary>
public class PlistUtility
{
- #region Import
-
- /// <summary>
- /// Import a Plist Preset
- /// </summary>
- /// <param name="filename">
- /// The filename.
- /// </param>
- /// <returns>
- /// A Preset Object
- /// </returns>
- public static Preset Import(string filename)
- {
- Preset preset = new Preset();
-
- XmlNode root = loadFile(filename);
- if (root == null) return null;
-
- // We'll query a query parser object and use it's public var structures to store all the data.
- // This will allow the preset loader logic to be used instead of writing custom logic just for this file.
- EncodeTask parsed = new EncodeTask();
- bool useFilters = false;
- PresetPictureSettingsMode pictureSettingsMode = PresetPictureSettingsMode.None;
- string qualityMode = string.Empty;
-
- #region Get a List of Audio Track Objects
-
- // This is the main <dict> with all the values
- XmlNode mainDict = root.ChildNodes[2].ChildNodes[0].FirstChild;
- XmlNode audioListDict = null;
- ObservableCollection<AudioTrack> audioTracks = new ObservableCollection<AudioTrack>();
-
- // Look for the AudioList key
- bool found = false;
- foreach (XmlNode node in mainDict.ChildNodes)
- {
- if (found)
- {
- audioListDict = node;
- break;
- }
-
- if (node.InnerText == "AudioList")
- {
- found = true; // We want the next node, as it is the value object.
- }
- }
-
- for (int i = 0; i < audioListDict.ChildNodes.Count; i++)
- {
- XmlNode audioChannel = audioListDict.ChildNodes[i];
- AudioTrack track = new AudioTrack();
-
- for (int subi = 0; subi < audioChannel.ChildNodes.Count; subi += 2)
- {
- // Audio Channel Information is here.
- string key = audioChannel.ChildNodes[subi].InnerText;
- string value = audioChannel.ChildNodes[subi + 1].InnerText;
- switch (key)
- {
- case "AudioBitrate":
- track.Bitrate = int.Parse(value);
- break;
- case "AudioEncoder":
- track.Encoder = Converters.GetAudioEncoder(value.Trim());
- break;
- case "AudioMixdown":
- track.MixDown = Converters.GetAudioMixDown(value.Trim());
- break;
- case "AudioSamplerate":
- track.SampleRate = value == "Auto" ? 0 : double.Parse(value);
- break;
- case "AudioTrack":
- //track.SourceTrack = value;
- break;
- case "AudioTrackDRCSlider":
- track.DRC = double.Parse(value);
- break;
- case "AudioTrackGainSlider":
- track.Gain = int.Parse(value.Replace("0.0", "0"));
- break;
- }
- }
- audioTracks.Add(track);
- parsed.AudioTracks = audioTracks;
- }
- #endregion
-
- #region Parse the reset of the plist keys into local variables
-
- XmlNode presetSettings = root.ChildNodes[2].ChildNodes[0].FirstChild;
-
- // Start from 2 to avoid the audio settings which we don't need.
- for (int i = 0; i < presetSettings.ChildNodes.Count; i += 2)
- {
- string key = presetSettings.ChildNodes[i].InnerText;
- string value = presetSettings.ChildNodes[i + 1].InnerText;
-
- switch (key)
- {
- // Output Settings
- case "FileFormat":
- parsed.OutputFormat = Converters.GetFileFormat(value.Replace("file", string.Empty).Trim());
- break;
- case "Mp4HttpOptimize":
- parsed.OptimizeMP4 = value == "1";
- break;
- case "Mp4LargeFile":
- parsed.LargeFile = value == "1";
- break;
- case "Mp4iPodCompatible":
- parsed.IPod5GSupport = value == "1";
- break;
-
- // Picture Settings
- case "PictureAutoCrop":
- parsed.HasCropping = value != "1";
- break;
- case "PictureTopCrop":
- parsed.Cropping.Top = int.Parse(value);
- break;
- case "PictureBottomCrop":
- parsed.Cropping.Bottom = int.Parse(value);
- break;
- case "PictureLeftCrop":
- parsed.Cropping.Left = int.Parse(value);
- break;
- case "PictureRightCrop":
- parsed.Cropping.Right = int.Parse(value);
- break;
- case "PictureHeight":
- parsed.Height = int.Parse(value);
- break;
- case "PictureWidth":
- parsed.Width = int.Parse(value);
- break;
- case "PictureKeepRatio":
- parsed.KeepDisplayAspect = value == "1";
- break;
- case "PicturePAR":
- switch (value)
- {
- case "0":
- parsed.Anamorphic = Anamorphic.None;
- break;
- default:
- parsed.Anamorphic = Anamorphic.Strict;
- break;
- case "2":
- parsed.Anamorphic = Anamorphic.Loose;
- break;
- case "3":
- parsed.Anamorphic = Anamorphic.Custom;
- break;
- }
- break;
-
- // Filters
- case "PictureDeblock":
- parsed.Deblock = int.Parse(value);
- break;
- case "PictureDecomb":
- parsed.Decomb = Decomb.Off;
- switch (value)
- {
- case "1":
- parsed.Decomb = Decomb.Custom;
- break;
- case "2":
- parsed.Decomb = Decomb.Default;
- break;
- case "3":
- parsed.Decomb = Decomb.Fast;
- break;
- }
- break;
- case "PictureDecombCustom":
- if (value != string.Empty)
- {
- parsed.CustomDecomb = value;
- }
- break;
- case "PictureDecombDeinterlace":
- // Not Used
- break;
- case "PictureDeinterlace":
- switch (value)
- {
- case "0":
- parsed.Deinterlace = Deinterlace.Off;
- break;
- case "1":
- parsed.Deinterlace = Deinterlace.Custom;
- break;
- case "2":
- parsed.Deinterlace = Deinterlace.Fast;
- break;
- case "3":
- parsed.Deinterlace = Deinterlace.Slow;
- break;
- case "4":
- parsed.Deinterlace = Deinterlace.Slower;
- break;
- }
- break;
- case "PictureDeinterlaceCustom":
- if (value != string.Empty)
- {
- parsed.CustomDeinterlace = value;
- }
- break;
- case "PictureDenoise":
- switch (value)
- {
- case "0":
- parsed.Denoise = Denoise.Off;
- break;
- case "1":
- parsed.Denoise = Denoise.Custom;
- break;
- case "2":
- parsed.Denoise = Denoise.Weak;
- break;
- case "3":
- parsed.Denoise = Denoise.Medium;
- break;
- case "4":
- parsed.Denoise = Denoise.Strong;
- break;
- }
-
- break;
- case "PictureDenoiseCustom":
- if (value != string.Empty)
- {
- parsed.CustomDenoise = value;
- }
- break;
- case "PictureDetelecine":
- parsed.Detelecine = Detelecine.Off;
- if (value == "1")
- {
- parsed.Detelecine = Detelecine.Custom;
- }
- if (value == "2")
- {
- parsed.Detelecine = Detelecine.Default;
- }
- break;
- case "PictureDetelecineCustom":
- if (value != string.Empty)
- {
- parsed.CustomDetelecine = value;
- }
- break;
-
- // Video Tab
- case "VideoAvgBitrate":
- if (!string.IsNullOrEmpty(value))
- {
- parsed.VideoBitrate = int.Parse(value);
- }
- break;
- case "VideoEncoder":
- parsed.VideoEncoder = EnumHelper<VideoEncoder>.GetValue(value);
- break;
- case "VideoFramerate":
-
- if (value == "Same as source")
- {
- parsed.Framerate = null;
- }
- else if (!string.IsNullOrEmpty(value))
- {
- parsed.Framerate = double.Parse(value);
- }
- break;
- case "VideoFramerateMode":
- switch (value)
- {
- case "vfr":
- parsed.FramerateMode = FramerateMode.VFR;
- break;
- case "cfr":
- parsed.FramerateMode = FramerateMode.CFR;
- break;
- default:
- parsed.FramerateMode = FramerateMode.PFR;
- break;
- }
- break;
- case "VideoGrayScale":
- parsed.Grayscale = value == "1";
- break;
- case "VideoQualitySlider":
- if (!string.IsNullOrEmpty(value))
- {
- parsed.Quality = double.Parse(value);
- }
- break;
- case "VideoQualityType": // The Type of Quality Mode used
- qualityMode = value;
- break;
- case "VideoTurboTwoPass":
- parsed.TurboFirstPass = value == "1";
- break;
- case "VideoTwoPass":
- parsed.TwoPass = value == "1";
- break;
-
- // Chapter Markers Tab
- case "ChapterMarkers":
- parsed.IncludeChapterMarkers = value == "1";
- break;
-
- // Advanced x264 tab
- case "x264Option":
- parsed.AdvancedEncoderOptions = value;
- break;
-
- // Preset Information
- case "PresetBuildNumber":
- preset.Version = value;
- break;
- case "PresetDescription":
- preset.Description = value;
- break;
- case "PresetName":
- preset.Name = value;
- break;
- case "Type":
- //parsed.Type = value; // TODO find out what this is
- break;
- case "UsesMaxPictureSettings":
- pictureSettingsMode = PresetPictureSettingsMode.SourceMaximum;
- break;
- case "UsesPictureFilters":
- useFilters = value == "1";
- break;
- case "UsesPictureSettings":
- pictureSettingsMode = PresetPictureSettingsMode.Custom;
- break;
-
- // Allowed Passthru
- case "AudioAllowAACPass":
- parsed.AllowedPassthruOptions.AudioAllowAACPass = value == "1";
- break;
- case "AudioAllowAC3Pass":
- parsed.AllowedPassthruOptions.AudioAllowAC3Pass = value == "1";
- break;
- case "AudioAllowDTSHDPass":
- parsed.AllowedPassthruOptions.AudioAllowDTSHDPass = value == "1";
- break;
- case "AudioAllowDTSPass":
- parsed.AllowedPassthruOptions.AudioAllowDTSPass = value == "1";
- break;
- case "AudioAllowMP3Pass":
- parsed.AllowedPassthruOptions.AudioAllowMP3Pass = value == "1";
- break;
- case "AudioEncoderFallback":
- parsed.AllowedPassthruOptions.AudioEncoderFallback = EnumHelper<AudioEncoder>.GetValue(value);
- break;
- }
- }
-
- // Kill any Quality values we don't need.
- switch (qualityMode)
- {
- case "1": // Avg Bitrate
- parsed.VideoEncodeRateType = VideoEncodeRateType.AverageBitrate;
- break;
- case "2": // CQ
- parsed.VideoEncodeRateType = VideoEncodeRateType.ConstantQuality;
- break;
- }
-
- // Default filters if we have to
- if (!useFilters)
- {
- parsed.Detelecine = Detelecine.Off;
- parsed.Denoise = Denoise.Off;
- parsed.Deinterlace = Deinterlace.Off;
- parsed.Decomb = Decomb.Off;
- parsed.Deblock = 0;
- parsed.Grayscale = false;
- }
-
- if (pictureSettingsMode == PresetPictureSettingsMode.SourceMaximum)
- {
- parsed.MaxWidth = parsed.Height;
- parsed.MaxHeight = parsed.Width;
- }
- #endregion
-
-
- preset.Task = parsed;
- preset.PictureSettingsMode = pictureSettingsMode;
- preset.UsePictureFilters = useFilters;
- preset.Category = PresetService.UserPresetCatgoryName;
-
- return preset;
- }
-
- private static XmlNode loadFile(string filename)
- {
- try
- {
- XmlNode root;
-
- if (!File.Exists(filename))
- return null;
-
- string fromfile = string.Empty;
- using (StreamReader sr = File.OpenText(filename))
- {
- int fileChar;
- while ((fileChar = sr.Read()) != -1) fromfile += Convert.ToChar(fileChar);
- }
-
- XmlDocument doc = new XmlDocument();
- doc.LoadXml(fromfile);
-
- root = doc;
- if (!root.HasChildNodes)
- {
- MessageBox.Show(
- "The Preset file you selected appears to be invlaid or from an older version of HandBrake",
- "Error",
- MessageBoxButtons.OK, MessageBoxIcon.Error);
- return null;
- }
-
- return root;
- }
- catch (Exception)
- {
- MessageBox.Show(
- "The Preset file you selected appears to be invlaid or from an older version of HandBrake.\n\n Please note, if you are exporting from the MacGui you may need to rebuild your preset so that it uses the current preset plist format.\n The MacGui does not currently update user presets automatically.",
- "Error",
- MessageBoxButtons.OK, MessageBoxIcon.Error);
- return null;
- }
- }
- #endregion
-
#region Export
/// <summary>
diff --git a/win/CS/HandBrake.Interop/HandBrakeInterop/Model/Encoding/Anamorphic.cs b/win/CS/HandBrake.Interop/HandBrakeInterop/Model/Encoding/Anamorphic.cs
index 2d20c4376..0c798457b 100644
--- a/win/CS/HandBrake.Interop/HandBrakeInterop/Model/Encoding/Anamorphic.cs
+++ b/win/CS/HandBrake.Interop/HandBrakeInterop/Model/Encoding/Anamorphic.cs
@@ -16,10 +16,10 @@ namespace HandBrake.Interop.Model.Encoding
[Display(Name = "None")]
None = 0,
[Display(Name = "Strict")]
- Strict,
+ Strict = 1,
[Display(Name = "Loose")]
- Loose,
+ Loose = 2,
[Display(Name = "Custom")]
- Custom
+ Custom = 3
}
}
diff --git a/win/CS/HandBrake.Interop/HandBrakeInterop/Model/Encoding/Decomb.cs b/win/CS/HandBrake.Interop/HandBrakeInterop/Model/Encoding/Decomb.cs
index 7b03410d0..a376ef893 100644
--- a/win/CS/HandBrake.Interop/HandBrakeInterop/Model/Encoding/Decomb.cs
+++ b/win/CS/HandBrake.Interop/HandBrakeInterop/Model/Encoding/Decomb.cs
@@ -12,9 +12,9 @@ namespace HandBrake.Interop.Model.Encoding
public enum Decomb
{
Off = 0,
- Default,
- Fast,
- Bob,
- Custom
+ Default = 2,
+ Fast = 3,
+ Bob = 4,
+ Custom = 1
}
}
diff --git a/win/CS/HandBrake.Interop/HandBrakeInterop/Model/Encoding/Deinterlace.cs b/win/CS/HandBrake.Interop/HandBrakeInterop/Model/Encoding/Deinterlace.cs
index 91d828576..8e16435ac 100644
--- a/win/CS/HandBrake.Interop/HandBrakeInterop/Model/Encoding/Deinterlace.cs
+++ b/win/CS/HandBrake.Interop/HandBrakeInterop/Model/Encoding/Deinterlace.cs
@@ -9,13 +9,16 @@
namespace HandBrake.Interop.Model.Encoding
{
- public enum Deinterlace
+ /// <summary>
+ /// The deinterlace.
+ /// </summary>
+ public enum Deinterlace
{
Off = 0,
- Fast,
- Slow,
- Slower,
- Bob,
- Custom
+ Fast = 2,
+ Slow = 3,
+ Slower = 4,
+ Bob = 5,
+ Custom = 1
}
}
diff --git a/win/CS/HandBrake.Interop/HandBrakeInterop/Model/Encoding/Denoise.cs b/win/CS/HandBrake.Interop/HandBrakeInterop/Model/Encoding/Denoise.cs
index 74c53e039..ec64d9e75 100644
--- a/win/CS/HandBrake.Interop/HandBrakeInterop/Model/Encoding/Denoise.cs
+++ b/win/CS/HandBrake.Interop/HandBrakeInterop/Model/Encoding/Denoise.cs
@@ -12,9 +12,9 @@ namespace HandBrake.Interop.Model.Encoding
public enum Denoise
{
Off = 0,
- Weak,
- Medium,
- Strong,
- Custom
+ Weak = 2,
+ Medium = 3,
+ Strong = 4,
+ Custom = 1
}
}
diff --git a/win/CS/HandBrake.Interop/HandBrakeInterop/Model/Encoding/Detelecine.cs b/win/CS/HandBrake.Interop/HandBrakeInterop/Model/Encoding/Detelecine.cs
index 189b7441f..af7930973 100644
--- a/win/CS/HandBrake.Interop/HandBrakeInterop/Model/Encoding/Detelecine.cs
+++ b/win/CS/HandBrake.Interop/HandBrakeInterop/Model/Encoding/Detelecine.cs
@@ -12,7 +12,7 @@ namespace HandBrake.Interop.Model.Encoding
public enum Detelecine
{
Off = 0,
- Default,
- Custom
+ Default = 2,
+ Custom = 1
}
}
diff --git a/win/CS/HandBrake.Interop/HandBrakeInterop/Model/Encoding/VideoEncodeRateType.cs b/win/CS/HandBrake.Interop/HandBrakeInterop/Model/Encoding/VideoEncodeRateType.cs
index b3374de36..7bf052efb 100644
--- a/win/CS/HandBrake.Interop/HandBrakeInterop/Model/Encoding/VideoEncodeRateType.cs
+++ b/win/CS/HandBrake.Interop/HandBrakeInterop/Model/Encoding/VideoEncodeRateType.cs
@@ -12,7 +12,7 @@ namespace HandBrake.Interop.Model.Encoding
public enum VideoEncodeRateType
{
TargetSize = 0,
- AverageBitrate,
- ConstantQuality
+ AverageBitrate = 1,
+ ConstantQuality = 2
}
}
diff --git a/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs
index 934a0b18d..b0ae80f93 100644
--- a/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs
+++ b/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs
@@ -22,6 +22,7 @@ namespace HandBrakeWPF.ViewModels
using Caliburn.Micro;
using HandBrake.ApplicationServices;
+ using HandBrake.ApplicationServices.Factories;
using HandBrake.ApplicationServices.Model;
using HandBrake.ApplicationServices.Model.Encoding;
using HandBrake.ApplicationServices.Parsing;
@@ -1353,7 +1354,9 @@ namespace HandBrakeWPF.ViewModels
if (!string.IsNullOrEmpty(filename))
{
- Preset preset = PlistUtility.Import(filename);
+ PList plist = new PList(filename);
+ Preset preset = PlistPresetFactory.CreatePreset(plist);
+
if (this.presetService.CheckIfPresetExists(preset.Name))
{
if (!presetService.CanUpdatePreset(preset.Name))
diff --git a/win/CS/HandBrakeWPF/Views/MainView.xaml b/win/CS/HandBrakeWPF/Views/MainView.xaml
index c051786af..77e76845c 100644
--- a/win/CS/HandBrakeWPF/Views/MainView.xaml
+++ b/win/CS/HandBrakeWPF/Views/MainView.xaml
@@ -134,6 +134,7 @@
<MenuItem Header="Debug" Visibility="{Binding ShowDebugMenu, Converter={StaticResource boolToVisConverter}}" >
<MenuItem Header="Show CLI Equiv" Micro:Message.Attach="[Event Click] = [Action ShowCliQuery]" />
<MenuItem Header="Debug Scan Log" Micro:Message.Attach="[Event Click] = [Action DebugScanLog]" />
+ <MenuItem Header="Debug Plist" Micro:Message.Attach="[Event Click] = [Action DebugPlist]" />
</MenuItem>
</Menu>