diff options
Diffstat (limited to 'win/CS/HandBrakeWPF')
10 files changed, 209 insertions, 345 deletions
diff --git a/win/CS/HandBrakeWPF/HandBrakeWPF.csproj b/win/CS/HandBrakeWPF/HandBrakeWPF.csproj index c7ebecb48..096fdd379 100644 --- a/win/CS/HandBrakeWPF/HandBrakeWPF.csproj +++ b/win/CS/HandBrakeWPF/HandBrakeWPF.csproj @@ -171,7 +171,6 @@ <DesignTime>True</DesignTime>
</Compile>
<Compile Include="Services\Presets\Factories\JsonPresetFactory.cs" />
- <Compile Include="Services\Presets\Factories\PlistFactory.cs" />
<Compile Include="Services\Queue\Interfaces\IQueueProcessor.cs" />
<Compile Include="Helpers\FileHelper.cs" />
<Compile Include="Services\Presets\Model\Preset.cs" />
diff --git a/win/CS/HandBrakeWPF/Model/Audio/AudioBehaviourModes.cs b/win/CS/HandBrakeWPF/Model/Audio/AudioBehaviourModes.cs index 11f19f2e4..63d88cf21 100644 --- a/win/CS/HandBrakeWPF/Model/Audio/AudioBehaviourModes.cs +++ b/win/CS/HandBrakeWPF/Model/Audio/AudioBehaviourModes.cs @@ -11,18 +11,23 @@ namespace HandBrakeWPF.Model.Audio {
using System.ComponentModel.DataAnnotations;
+ using HandBrake.ApplicationServices.Attributes;
+
/// <summary>
/// The audio behaviours.
/// </summary>
public enum AudioBehaviourModes
{
[Display(Name = "No Audio")]
+ [ShortName("none")]
None = 0,
[Display(Name = "First Matching Selected Language")]
+ [ShortName("first")]
FirstMatch,
[Display(Name = "All Matching Selected Languages")]
+ [ShortName("all")]
AllMatching,
}
}
diff --git a/win/CS/HandBrakeWPF/Model/Subtitles/SubtitleBehaviourModes.cs b/win/CS/HandBrakeWPF/Model/Subtitles/SubtitleBehaviourModes.cs index 004190a5f..ed3e8ed5a 100644 --- a/win/CS/HandBrakeWPF/Model/Subtitles/SubtitleBehaviourModes.cs +++ b/win/CS/HandBrakeWPF/Model/Subtitles/SubtitleBehaviourModes.cs @@ -11,18 +11,23 @@ namespace HandBrakeWPF.Model.Subtitles {
using System.ComponentModel.DataAnnotations;
+ using HandBrake.ApplicationServices.Attributes;
+
/// <summary>
/// The subtitle behaviours modes.
/// </summary>
public enum SubtitleBehaviourModes
{
[Display(Name = "None")]
+ [ShortName("none")]
None = 0,
[Display(Name = "First Matching Selected Language")]
+ [ShortName("first")]
FirstMatch,
[Display(Name = "All Matching Selected Languages")]
+ [ShortName("all")]
AllMatching,
}
}
diff --git a/win/CS/HandBrakeWPF/Model/Subtitles/SubtitleBurnInBehaviourModes.cs b/win/CS/HandBrakeWPF/Model/Subtitles/SubtitleBurnInBehaviourModes.cs index 174b4a5e8..193fc2a45 100644 --- a/win/CS/HandBrakeWPF/Model/Subtitles/SubtitleBurnInBehaviourModes.cs +++ b/win/CS/HandBrakeWPF/Model/Subtitles/SubtitleBurnInBehaviourModes.cs @@ -11,21 +11,27 @@ namespace HandBrakeWPF.Model.Subtitles {
using System.ComponentModel.DataAnnotations;
+ using HandBrake.ApplicationServices.Attributes;
+
/// <summary>
/// The subtitle behaviours modes.
/// </summary>
public enum SubtitleBurnInBehaviourModes
{
[Display(Name = "None")]
+ [ShortName("none")]
None = 0,
[Display(Name = "Foreign Audio Track")]
+ [ShortName("foreign")]
ForeignAudio,
[Display(Name = "First Track")]
+ [ShortName("first")]
FirstTrack,
[Display(Name = "Foreign Audio Preferred, else First")]
+ [ShortName("foreign_first")]
ForeignAudioPreferred,
}
}
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">
diff --git a/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs index 60b0c74a5..4f4fbaf2d 100644 --- a/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs +++ b/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs @@ -1827,10 +1827,10 @@ namespace HandBrakeWPF.ViewModels {
SaveFileDialog savefiledialog = new SaveFileDialog
{
- Filter = "plist|*.plist",
+ Filter = "json|*.json",
CheckPathExists = true,
AddExtension = true,
- DefaultExt = ".plist",
+ DefaultExt = ".json",
OverwritePrompt = true,
FilterIndex = 0
};
@@ -1841,10 +1841,7 @@ namespace HandBrakeWPF.ViewModels if (!string.IsNullOrEmpty(filename))
{
- PlistFactory.Export(
- savefiledialog.FileName,
- this.selectedPreset,
- HandBrakeUtils.Build.ToString(CultureInfo.InvariantCulture));
+ this.presetService.Export(savefiledialog.FileName, this.selectedPreset, HBConfigurationFactory.Create());
}
}
else
|