summaryrefslogtreecommitdiffstats
path: root/win/CS/HandBrakeWPF/Services
diff options
context:
space:
mode:
authorsr55 <[email protected]>2015-07-05 12:12:01 +0000
committersr55 <[email protected]>2015-07-05 12:12:01 +0000
commite32a4681e63cfb7842488842047da1b8f14c72c5 (patch)
tree54314f5debe1d73237d31b24d1e23609c436f946 /win/CS/HandBrakeWPF/Services
parent32363c86e5b1847289d9cc0dc741a5f536176225 (diff)
WinGui: Initial Implementation of the json preset export code.
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@7347 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'win/CS/HandBrakeWPF/Services')
-rw-r--r--win/CS/HandBrakeWPF/Services/Presets/Factories/JsonPresetFactory.cs160
-rw-r--r--win/CS/HandBrakeWPF/Services/Presets/Factories/PlistFactory.cs320
-rw-r--r--win/CS/HandBrakeWPF/Services/Presets/Interfaces/IPresetService.cs17
-rw-r--r--win/CS/HandBrakeWPF/Services/Presets/Model/Preset.cs5
-rw-r--r--win/CS/HandBrakeWPF/Services/Presets/PresetService.cs26
5 files changed, 190 insertions, 338 deletions
diff --git a/win/CS/HandBrakeWPF/Services/Presets/Factories/JsonPresetFactory.cs b/win/CS/HandBrakeWPF/Services/Presets/Factories/JsonPresetFactory.cs
index acc63874f..4dedd9660 100644
--- a/win/CS/HandBrakeWPF/Services/Presets/Factories/JsonPresetFactory.cs
+++ b/win/CS/HandBrakeWPF/Services/Presets/Factories/JsonPresetFactory.cs
@@ -9,13 +9,15 @@
namespace HandBrakeWPF.Services.Presets.Factories
{
- using System;
+ using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Globalization;
+ using System.Linq;
using HandBrake.ApplicationServices.Interop.Json.Presets;
using HandBrake.ApplicationServices.Interop.Model;
using HandBrake.ApplicationServices.Interop.Model.Encoding;
+ 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;
@@ -46,7 +48,6 @@ namespace HandBrakeWPF.Services.Presets.Factories
preset.Name = importedPreset.PresetName;
preset.Description = importedPreset.PresetDescription;
preset.UsePictureFilters = importedPreset.UsesPictureFilters;
- preset.UseDeinterlace = !importedPreset.PictureDecombDeinterlace;
preset.Task = new EncodeTask();
// Step 1, Create the EncodeTask Object that can be loaded into the UI.
@@ -106,6 +107,11 @@ namespace HandBrakeWPF.Services.Presets.Factories
preset.Task.CustomDecomb = importedPreset.PictureDecombCustom;
+ if (!importedPreset.PictureDecombDeinterlace)
+ {
+ preset.Task.Decomb = Decomb.Off;
+ }
+
switch (importedPreset.PictureDeinterlace)
{
case "custom":
@@ -367,16 +373,158 @@ namespace HandBrakeWPF.Services.Presets.Factories
/// <param name="export">
/// The export.
/// </param>
+ /// <param name="config">
+ /// HandBrakes configuration options.
+ /// </param>
/// <returns>
/// The <see cref="Preset"/>.
/// </returns>
- public HandBrake.ApplicationServices.Interop.Json.Presets.HBPreset ExportPreset(Preset export)
+ public static PresetTransportContainer ExportPreset(Preset export, HBConfiguration config)
{
- HandBrake.ApplicationServices.Interop.Json.Presets.HBPreset preset = new HandBrake.ApplicationServices.Interop.Json.Presets.HBPreset();
+ PresetTransportContainer container = new PresetTransportContainer();
+ container.VersionMajor = "0";
+ container.VersionMinor = "10";
+ container.VersionMicro = "2";
+ container.PresetList = new List<HBPreset> { CreateHbPreset(export, config) };
+
+ return container;
+ }
+
+ /// <summary>
+ /// The create hb preset.
+ /// </summary>
+ /// <param name="export">
+ /// The export.
+ /// </param>
+ /// <param name="config">HandBrakes current configuration</param>
+ /// <returns>
+ /// The <see cref="HBPreset"/>.
+ /// </returns>
+ private static HBPreset CreateHbPreset(Preset export, HBConfiguration config)
+ {
+ HBPreset preset = new HBPreset();
+
+ // Preset
+ preset.PresetDescription = export.Description;
+ preset.PresetName = export.Name;
+ preset.Type = 1; // User Preset
+ preset.UsesPictureFilters = export.UsePictureFilters;
+ preset.UsesPictureSettings = (int)export.PictureSettingsMode;
+ preset.Default = false; // TODO Can other GUI's handle this?
+
+ // Audio
+ preset.AudioCopyMask = export.Task.AllowedPassthruOptions.AllowedPassthruOptions.Select(EnumHelper<AudioEncoder>.GetShortName).ToList();
+ preset.AudioEncoderFallback = EnumHelper<AudioEncoder>.GetShortName(export.Task.AllowedPassthruOptions.AudioEncoderFallback);
+ preset.AudioLanguageList = LanguageUtilities.GetLanguageCodes(export.AudioTrackBehaviours.SelectedLangauges);
+ preset.AudioTrackSelectionBehavior = EnumHelper<AudioBehaviourModes>.GetShortName(export.AudioTrackBehaviours.SelectedBehaviour);
+ preset.AudioSecondaryEncoderMode = false; // TODO -> Check what this is.
+ preset.AudioList = new List<AudioList>();
+ foreach (var item in export.Task.AudioTracks)
+ {
+ AudioList track = new AudioList
+ {
+ AudioBitrate = item.Bitrate,
+ AudioCompressionLevel = 0, // TODO
+ AudioDitherMethod = null, // TODO
+ AudioEncoder = EnumHelper<AudioEncoder>.GetShortName(item.Encoder),
+ AudioMixdown = EnumHelper<Mixdown>.GetShortName(item.MixDown),
+ AudioNormalizeMixLevel = false, // TODO
+ AudioSamplerate = item.SampleRate == 0 ? "auto" : item.SampleRate.ToString(), // TODO check formatting.
+ AudioTrackDRCSlider = item.DRC,
+ AudioTrackGainSlider = item.Gain,
+ AudioTrackQuality = item.Quality ?? 0,
+ AudioTrackQualityEnable = item.Quality.HasValue && item.IsQualityVisible
+ };
+
+ preset.AudioList.Add(track);
+ }
+
+
+ // Subtitles
+ preset.SubtitleAddCC = export.SubtitleTrackBehaviours.AddClosedCaptions;
+ preset.SubtitleAddForeignAudioSearch = export.SubtitleTrackBehaviours.AddForeignAudioScanTrack;
+ preset.SubtitleBurnBDSub = false; // TODO not supported yet.
+ preset.SubtitleBurnDVDSub = false; // TODO not supported yet.
+ preset.SubtitleBurnBehavior = EnumHelper<SubtitleBurnInBehaviourModes>.GetShortName(export.SubtitleTrackBehaviours.SelectedBurnInBehaviour);
+ preset.SubtitleLanguageList = LanguageUtilities.GetLanguageCodes(export.SubtitleTrackBehaviours.SelectedLangauges);
+ preset.SubtitleTrackSelectionBehavior = EnumHelper<SubtitleBehaviourModes>.GetShortName(export.SubtitleTrackBehaviours.SelectedBehaviour);
+
+ // Chapters
+ preset.ChapterMarkers = export.Task.IncludeChapterMarkers;
+
+ // Output Settings
+ preset.FileFormat = EnumHelper<OutputFormat>.GetShortName(export.Task.OutputFormat);
+ preset.Mp4HttpOptimize = export.Task.OptimizeMP4;
+ preset.Mp4iPodCompatible = export.Task.IPod5GSupport;
+
+ // Picture Settings
+ preset.PictureForceHeight = 0; // TODO
+ preset.PictureForceWidth = 0; // TODO
+ preset.PictureHeight = preset.UsesPictureSettings >= 1 ? export.Task.MaxHeight : 0; // TODO; // TODO
+ preset.PictureItuPAR = false; // TODO Not supported Yet
+ preset.PictureKeepRatio = export.Task.KeepDisplayAspect;
+ preset.PictureLeftCrop = export.Task.Cropping.Left;
+ preset.PictureLooseCrop = false; // TODO Not Supported Yet
+ preset.PictureModulus = export.Task.Modulus ?? 16;
+ preset.PicturePAR = EnumHelper<Anamorphic>.GetShortName(export.Task.Anamorphic);
+ preset.PicturePARHeight = export.Task.PixelAspectY;
+ preset.PicturePARWidth = export.Task.PixelAspectX;
+ preset.PictureRightCrop = export.Task.Cropping.Right;
+ preset.PictureRotate = 0; // TODO Not supported yet.
+ preset.PictureTopCrop = export.Task.Cropping.Top;
+ preset.PictureWidth = preset.UsesPictureSettings >= 1 ? export.Task.MaxWidth : 0; // TODO
+ preset.PictureDARWidth = export.Task.DisplayWidth.HasValue ? (int)export.Task.DisplayWidth.Value : 0;
+ preset.PictureAutoCrop = export.Task.HasCropping;
+ preset.PictureBottomCrop = export.Task.Cropping.Bottom;
+
+ // Filters
+ preset.PictureDeblock = export.Task.Deblock;
+ preset.PictureDecomb = EnumHelper<Decomb>.GetShortName(export.Task.Decomb);
+ preset.PictureDecombCustom = export.Task.CustomDecomb;
+ preset.PictureDecombDeinterlace = export.Task.Decomb != Decomb.Off;
+ preset.PictureDeinterlace = EnumHelper<Deinterlace>.GetShortName(export.Task.Deinterlace);
+ preset.PictureDeinterlaceCustom = export.Task.CustomDeinterlace;
+ preset.PictureDenoiseCustom = export.Task.CustomDenoise;
+ preset.PictureDenoiseFilter = EnumHelper<Denoise>.GetShortName(export.Task.Denoise);
+ preset.PictureDenoisePreset = EnumHelper<DenoisePreset>.GetShortName(export.Task.DenoisePreset);
+ preset.PictureDenoiseTune = EnumHelper<DenoiseTune>.GetShortName(export.Task.DenoiseTune);
+ preset.PictureDetelecine = EnumHelper<Detelecine>.GetShortName(export.Task.Detelecine);
+ preset.PictureDetelecineCustom = export.Task.CustomDetelecine;
+
+ // Video
+ preset.VideoEncoder = EnumHelper<VideoEncoder>.GetShortName(export.Task.VideoEncoder);
+ preset.VideoFramerate = export.Task.Framerate.ToString();
+ preset.VideoFramerateMode = EnumHelper<FramerateMode>.GetShortName(export.Task.FramerateMode);
+ preset.VideoGrayScale = export.Task.Grayscale;
+ preset.VideoHWDecode = false;
+ preset.VideoLevel = export.Task.VideoLevel.ShortName;
+ preset.VideoOptionExtra = export.Task.ExtraAdvancedArguments;
+ preset.VideoPreset = export.Task.VideoPreset.ShortName;
+ preset.VideoProfile = export.Task.VideoProfile.ShortName;
+ preset.VideoQSVAsyncDepth = 4; // Defaulted to 4 for now.
+ preset.VideoQSVDecode = !config.DisableQuickSyncDecoding;
+ 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.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.
+ preset.VideoTurboTwoPass = export.Task.TurboFirstPass;
+ preset.VideoTwoPass = export.Task.TwoPass;
+
+ // Advanced
+ preset.x264Option = export.Task.AdvancedEncoderOptions;
+ preset.x264UseAdvancedOptions = export.Task.ShowAdvancedTab;
+
+ // Unknown
+ preset.ChildrenArray = new List<object>(); // TODO
+ preset.Folder = false; // TODO
+ preset.FolderOpen = false; // TODO
return preset;
}
+
/// <summary>
/// Get the OutputFormat Enum for a given string
/// </summary>
@@ -385,8 +533,8 @@ namespace HandBrakeWPF.Services.Presets.Factories
/// </param>
/// <returns>
/// An OutputFormat Enum
- /// </returns>
- public static OutputFormat GetFileFormat(string format)
+ /// </returns>
+ private static OutputFormat GetFileFormat(string format)
{
switch (format.ToLower())
{
diff --git a/win/CS/HandBrakeWPF/Services/Presets/Factories/PlistFactory.cs b/win/CS/HandBrakeWPF/Services/Presets/Factories/PlistFactory.cs
deleted file mode 100644
index d50f23be9..000000000
--- a/win/CS/HandBrakeWPF/Services/Presets/Factories/PlistFactory.cs
+++ /dev/null
@@ -1,320 +0,0 @@
-// --------------------------------------------------------------------------------------------------------------------
-// <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>
-// Plist Preset Converter
-// </summary>
-// --------------------------------------------------------------------------------------------------------------------
-
-namespace HandBrakeWPF.Services.Presets.Factories
-{
- using System.Linq;
- using System.Text;
- using System.Xml;
-
- using HandBrake.ApplicationServices.Services.Encode.Model;
- using HandBrake.ApplicationServices.Services.Encode.Model.Models;
- using HandBrake.ApplicationServices.Utilities;
- using HandBrake.ApplicationServices.Interop.Model.Encoding;
-
- using HandBrakeWPF.Services.Presets.Model;
-
- /// <summary>
- /// Plist Preset Converter
- /// </summary>
- public class PlistFactory
- {
- #region Export
-
- /// <summary>
- /// Export a MacGui style plist preset.
- /// </summary>
- /// <param name="path">
- /// The path.
- /// </param>
- /// <param name="preset">
- /// The preset.
- /// </param>
- /// <param name="build">
- /// The build.PictureModulusPictureModulus
- /// </param>
- public static void Export(string path, Preset preset, string build)
- {
- if (string.IsNullOrEmpty(path))
- {
- return;
- }
-
- EncodeTask parsed = new EncodeTask(preset.Task);
- using (XmlTextWriter xmlWriter = new XmlTextWriter(path, Encoding.UTF8) { Formatting = Formatting.Indented })
- {
- // Header
- xmlWriter.WriteStartDocument();
- xmlWriter.WriteDocType(
- "plist", "-//Apple//DTD PLIST 1.0//EN", @"http://www.apple.com/DTDs/PropertyList-1.0.dtd", null);
-
- xmlWriter.WriteStartElement("plist");
- xmlWriter.WriteStartElement("array");
-
- // Add New Preset Here. Can write multiple presets here if required in future.
- WritePreset(xmlWriter, parsed, preset, build);
-
- // Footer
- xmlWriter.WriteEndElement();
- xmlWriter.WriteEndElement();
-
- xmlWriter.WriteEndDocument();
-
- // Closeout
- xmlWriter.Close();
- }
- }
-
- /// <summary>
- /// Write the Preset to a file
- /// </summary>
- /// <param name="xmlWriter">
- /// The xml writer.
- /// </param>
- /// <param name="parsed">
- /// The parsed.
- /// </param>
- /// <param name="preset">
- /// The preset.
- /// </param>
- /// <param name="build">
- /// The build.
- /// </param>
- private static void WritePreset(XmlTextWriter xmlWriter, EncodeTask parsed, Preset preset, string build)
- {
- xmlWriter.WriteStartElement("dict");
- AudioListArrayDict(xmlWriter, parsed);
- AddEncodeSettings(xmlWriter, parsed, preset, build);
-
- xmlWriter.WriteEndElement();
- }
-
- /// <summary>
- /// Add the encode settings to the preset
- /// </summary>
- /// <param name="xmlWriter">
- /// The xml writer.
- /// </param>
- /// <param name="parsed">
- /// The parsed.
- /// </param>
- /// <param name="preset">
- /// The preset.
- /// </param>
- /// <param name="build">
- /// The build.
- /// </param>
- private static void AddEncodeSettings(XmlTextWriter xmlWriter, EncodeTask parsed, Preset preset, string build)
- {
- AddBooleanElement(xmlWriter, "AudioAllowAACPass", parsed.AllowedPassthruOptions.AudioAllowAACPass);
- AddBooleanElement(xmlWriter, "AudioAllowAC3Pass", parsed.AllowedPassthruOptions.AudioAllowAC3Pass);
- AddBooleanElement(xmlWriter, "AudioAllowDTSHDPass", parsed.AllowedPassthruOptions.AudioAllowDTSHDPass);
- AddBooleanElement(xmlWriter, "AudioAllowDTSPass", parsed.AllowedPassthruOptions.AudioAllowDTSPass);
- AddBooleanElement(xmlWriter, "AudioAllowMP3Pass", parsed.AllowedPassthruOptions.AudioAllowMP3Pass);
-
- // TODO Update
- AddEncodeElement(xmlWriter, "AudioEncoderFallback", "string", EnumHelper<AudioEncoder>.GetDisplay(parsed.AllowedPassthruOptions.AudioEncoderFallback));
-
- AddBooleanElement(xmlWriter, "ChapterMarkers", parsed.IncludeChapterMarkers);
- AddEncodeElement(xmlWriter, "Default", "integer", "0");
- AddEncodeElement(xmlWriter, "FileFormat", "string", (parsed.OutputFormat == OutputFormat.Mp4) ? "MP4 file" : "MKV file"); // TODO
- AddBooleanElement(xmlWriter, "Folder", false);
- AddEncodeElement(xmlWriter, "Mp4HttpOptimize", "integer", parsed.OptimizeMP4 ? "1" : "0");
- AddEncodeElement(xmlWriter, "Mp4iPodCompatible", "integer", parsed.IPod5GSupport ? "1" : "0");
- AddEncodeElement(xmlWriter, "PictureAutoCrop", "integer", "1");
-
- // Filters
- AddEncodeElement(xmlWriter, "PictureDeblock", "integer", parsed.Deblock.ToString());
-
- AddBooleanElement(xmlWriter, "PictureDecombDeinterlace", parsed.Decomb != Decomb.Off);
- AddEncodeElement(xmlWriter, "PictureDecombCustom", "string", parsed.Decomb == Decomb.Custom ? parsed.CustomDecomb : string.Empty);
- AddEncodeElement(xmlWriter, "PictureDecomb", "integer", ((int)parsed.Decomb).ToString());
- AddEncodeElement(xmlWriter, "PictureDeinterlaceCustom", "string", parsed.Deinterlace == Deinterlace.Custom ? parsed.CustomDeinterlace : string.Empty);
- AddEncodeElement(xmlWriter, "PictureDeinterlace", "integer", ((int)parsed.Deinterlace).ToString());
-
- AddEncodeElement(xmlWriter, "PictureDenoiseFilter", "string", parsed.Denoise.ToString().ToLower());
- AddEncodeElement(xmlWriter, "PictureDenoiseCustom", "string", parsed.DenoisePreset == DenoisePreset.Custom ? parsed.CustomDenoise : string.Empty);
- AddEncodeElement(xmlWriter, "PictureDenoisePreset", "string", parsed.DenoisePreset.ToString().ToLower());
- if (parsed.Denoise == Denoise.NLMeans)
- {
- AddEncodeElement(xmlWriter, "PictureDenoiseTune", "string", parsed.DenoiseTune.ToString().ToLower());
- }
-
- AddEncodeElement(xmlWriter, "PictureDetelecine", "integer", ((int)parsed.Detelecine).ToString());
- AddEncodeElement(xmlWriter, "PictureDetelecineCustom", "string", parsed.Detelecine == Detelecine.Custom ? parsed.CustomDecomb : string.Empty);
-
- // Picture Settings
- AddEncodeElement(xmlWriter, "PictureHeight", "integer", parsed.MaxHeight.HasValue ? parsed.MaxHeight.Value.ToString() : parsed.Height.HasValue ? parsed.Height.Value.ToString() : "0");
- AddEncodeElement(xmlWriter, "PictureKeepRatio", "integer", parsed.KeepDisplayAspect ? "1" : "0");
- AddEncodeElement(xmlWriter, "PictureModulus", "integer", parsed.Modulus.ToString());
- AddEncodeElement(xmlWriter, "PicturePAR", "integer", ((int)parsed.Anamorphic).ToString());
- AddEncodeElement(xmlWriter, "PictureLeftCrop", "integer", parsed.Cropping.Left.ToString());
- AddEncodeElement(xmlWriter, "PictureRightCrop", "integer", parsed.Cropping.Right.ToString());
- AddEncodeElement(xmlWriter, "PictureTopCrop", "integer", parsed.Cropping.Top.ToString());
- AddEncodeElement(xmlWriter, "PictureBottomCrop", "integer", parsed.Cropping.Bottom.ToString());
- AddEncodeElement(xmlWriter, "PictureWidth", "integer", parsed.MaxWidth.HasValue ? parsed.MaxWidth.Value.ToString() : parsed.Width.HasValue ? parsed.Width.Value.ToString() : "0");
-
- // Preset Information
- AddEncodeElement(xmlWriter, "PresetBuildNumber", "string", build);
- AddEncodeElement(xmlWriter, "PresetDescription", "string", "No Description");
- AddEncodeElement(xmlWriter, "PresetName", "string", preset.Name);
- AddEncodeElement(xmlWriter, "Type", "integer", "1"); // 1 is user preset, 0 is built in
-
- // Preset Settings
- AddEncodeElement(xmlWriter, "UsesMaxPictureSettings", "integer", (parsed.MaxWidth != 0 || parsed.MaxHeight != 0) ? "1" : "0");
- AddEncodeElement(xmlWriter, "UsesPictureFilters", "integer", "1");
- AddEncodeElement(xmlWriter, "UsesPictureSettings", "integer", "1");
-
- // Video Settings
- AddEncodeElement(xmlWriter, "VideoAvgBitrate", "string", parsed.VideoBitrate.ToString());
- AddEncodeElement(xmlWriter, "VideoEncoder", "string", EnumHelper<VideoEncoder>.GetDisplay(parsed.VideoEncoder));
- AddEncodeElement(xmlWriter, "VideoFramerate", "string", parsed.Framerate == null ? "Same as source" : parsed.Framerate.ToString());
- AddEncodeElement(xmlWriter, "VideoFramerateMode", "string", parsed.FramerateMode.ToString().ToLower());
- AddBooleanElement(xmlWriter, "VideoGrayScale", parsed.Grayscale);
- AddEncodeElement(xmlWriter, "VideoQualitySlider", "real", parsed.Quality.ToString());
-
- 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");
-
- int videoQualityType = 0;
- if (parsed.VideoBitrate != null) videoQualityType = 1;
- else if (parsed.Quality != null) videoQualityType = 2;
-
- AddEncodeElement(xmlWriter, "VideoQualityType", "integer", videoQualityType.ToString());
- AddEncodeElement(xmlWriter, "VideoTargetSize", "string", string.Empty);
- AddEncodeElement(xmlWriter, "VideoTurboTwoPass", "integer", parsed.TurboFirstPass ? "1" : "0");
- AddEncodeElement(xmlWriter, "VideoTwoPass", "integer", parsed.TwoPass ? "1" : "0");
-
- // x264 string
- AddEncodeElement(xmlWriter, "x264Option", "string", parsed.AdvancedEncoderOptions);
- }
-
- /// <summary>
- /// Add a boolean element
- /// </summary>
- /// <param name="xmlWriter">
- /// The xml writer.
- /// </param>
- /// <param name="keyName">
- /// The key name.
- /// </param>
- /// <param name="value">
- /// The value.
- /// </param>
- private static void AddBooleanElement(XmlTextWriter xmlWriter, string keyName, bool? value)
- {
- xmlWriter.WriteStartElement("key");
- xmlWriter.WriteString(keyName);
- xmlWriter.WriteEndElement();
- xmlWriter.WriteStartElement(value.HasValue ? value.Value ? "true" : "false" : "false");
- xmlWriter.WriteEndElement();
- }
-
- /// <summary>
- /// Add an encode setting element
- /// </summary>
- /// <param name="xmlWriter">
- /// The xml writer.
- /// </param>
- /// <param name="keyName">
- /// The key name.
- /// </param>
- /// <param name="type">
- /// The type.
- /// </param>
- /// <param name="value">
- /// The value.
- /// </param>
- private static void AddEncodeElement(XmlTextWriter xmlWriter, string keyName, string type, string value)
- {
- xmlWriter.WriteElementString("key", keyName);
-
- // This is a hack for Apples XML parser. It doesn't understand <integer /> so instead, always set a default value
- // of 0 if the value is empty.
- if (type == "integer" && string.IsNullOrEmpty(value))
- {
- value = "0";
- }
- xmlWriter.WriteElementString(type, value);
- }
-
- /// <summary>
- /// Add an Audio Track Array Dict
- /// </summary>
- /// <param name="xmlWriter">
- /// The xml writer.
- /// </param>
- /// <param name="parsed">
- /// The parsed.
- /// </param>
- private static void AudioListArrayDict(XmlTextWriter xmlWriter, EncodeTask parsed)
- {
- xmlWriter.WriteStartElement("key");
- xmlWriter.WriteString("AudioList");
- xmlWriter.WriteEndElement();
-
- xmlWriter.WriteStartElement("array");
- foreach (AudioTrack track in parsed.AudioTracks)
- {
- AddAudioItem(xmlWriter, track);
- }
- xmlWriter.WriteEndElement();
- }
-
- /// <summary>
- /// Add an audio track
- /// </summary>
- /// <param name="xmlWriter">
- /// The xml writer.
- /// </param>
- /// <param name="audioTrack">
- /// The audio track.
- /// </param>
- private static void AddAudioItem(XmlTextWriter xmlWriter, AudioTrack audioTrack)
- {
- xmlWriter.WriteStartElement("dict");
-
- xmlWriter.WriteElementString("key", "AudioBitrate");
- xmlWriter.WriteElementString("string", audioTrack.Bitrate.ToString());
-
- xmlWriter.WriteElementString("key", "AudioEncoder");
- xmlWriter.WriteElementString("string", EnumHelper<AudioEncoder>.GetDisplay(audioTrack.Encoder));
-
- xmlWriter.WriteElementString("key", "AudioMixdown");
- xmlWriter.WriteElementString("string", EnumHelper<Mixdown>.GetDisplay(audioTrack.MixDown));
-
- xmlWriter.WriteElementString("key", "AudioSamplerate");
- xmlWriter.WriteElementString("string", audioTrack.SampleRate.ToString().Replace("0", "Auto"));
-
- xmlWriter.WriteElementString("key", "AudioTrack");
- xmlWriter.WriteElementString("integer", audioTrack.Track.ToString());
-
- xmlWriter.WriteElementString("key", "AudioTrackDRCSlider");
- xmlWriter.WriteElementString("real", audioTrack.DRC.ToString());
-
- xmlWriter.WriteElementString("key", "AudioTrackDescription");
- xmlWriter.WriteElementString("string", "Unknown");
-
- xmlWriter.WriteElementString("key", "AudioTrackGainSlider");
- xmlWriter.WriteElementString("real", audioTrack.Gain.ToString());
-
- xmlWriter.WriteEndElement();
- }
- #endregion
- }
-} \ No newline at end of file
diff --git a/win/CS/HandBrakeWPF/Services/Presets/Interfaces/IPresetService.cs b/win/CS/HandBrakeWPF/Services/Presets/Interfaces/IPresetService.cs
index de76a1af3..4f30c0aa3 100644
--- a/win/CS/HandBrakeWPF/Services/Presets/Interfaces/IPresetService.cs
+++ b/win/CS/HandBrakeWPF/Services/Presets/Interfaces/IPresetService.cs
@@ -11,6 +11,8 @@ namespace HandBrakeWPF.Services.Presets.Interfaces
{
using System.Collections.ObjectModel;
+ using HandBrake.ApplicationServices.Model;
+
using HandBrakeWPF.Services.Presets.Model;
/// <summary>
@@ -53,6 +55,21 @@ namespace HandBrakeWPF.Services.Presets.Interfaces
/// </param>
void Import(string filename);
+
+ /// <summary>
+ /// The export.
+ /// </summary>
+ /// <param name="filename">
+ /// The filename.
+ /// </param>
+ /// <param name="preset">
+ /// The preset.
+ /// </param>
+ /// <param name="configuration">
+ /// The configuration.
+ /// </param>
+ void Export(string filename, Preset preset, HBConfiguration configuration);
+
/// <summary>
/// Update a preset
/// </summary>
diff --git a/win/CS/HandBrakeWPF/Services/Presets/Model/Preset.cs b/win/CS/HandBrakeWPF/Services/Presets/Model/Preset.cs
index 6f1da9c99..8e43dc4bb 100644
--- a/win/CS/HandBrakeWPF/Services/Presets/Model/Preset.cs
+++ b/win/CS/HandBrakeWPF/Services/Presets/Model/Preset.cs
@@ -77,11 +77,6 @@ namespace HandBrakeWPF.Services.Presets.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/HandBrakeWPF/Services/Presets/PresetService.cs b/win/CS/HandBrakeWPF/Services/Presets/PresetService.cs
index e3aee79bf..c47b101a1 100644
--- a/win/CS/HandBrakeWPF/Services/Presets/PresetService.cs
+++ b/win/CS/HandBrakeWPF/Services/Presets/PresetService.cs
@@ -22,6 +22,7 @@ namespace HandBrakeWPF.Services.Presets
using HandBrake.ApplicationServices.Interop;
using HandBrake.ApplicationServices.Interop.Json.Presets;
using HandBrake.ApplicationServices.Interop.Model.Encoding;
+ using HandBrake.ApplicationServices.Model;
using HandBrake.ApplicationServices.Services.Encode.Model.Models;
using HandBrake.ApplicationServices.Utilities;
@@ -193,13 +194,6 @@ namespace HandBrakeWPF.Services.Presets
preset = JsonPresetFactory.ImportPreset(hbPreset);
preset.Category = UserPresetCatgoryName;
- // 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)
@@ -254,6 +248,24 @@ namespace HandBrakeWPF.Services.Presets
}
/// <summary>
+ /// The export.
+ /// </summary>
+ /// <param name="filename">
+ /// The filename.
+ /// </param>
+ /// <param name="preset">
+ /// The preset.
+ /// </param>
+ /// <param name="configuration">
+ /// The configuration.
+ /// </param>
+ public void Export(string filename, Preset preset, HBConfiguration configuration)
+ {
+ PresetTransportContainer container = JsonPresetFactory.ExportPreset(preset, configuration);
+ HandBrakePresetService.ExportPreset(filename, container);
+ }
+
+ /// <summary>
/// Update a preset
/// </summary>
/// <param name="update">