diff options
author | sr55 <[email protected]> | 2015-06-26 20:14:25 +0000 |
---|---|---|
committer | sr55 <[email protected]> | 2015-06-26 20:14:25 +0000 |
commit | fe53ec37cbb0da69f4ef0b924303378397d49fc6 (patch) | |
tree | 0b5ff181a06b39e4661232fb376b1cc138ff2cc4 /win/CS/HandBrake.ApplicationServices/Interop | |
parent | f5bbd0ac20d3b8e548c1a31fd2d065c68dbe03cf (diff) |
WinGui: Completely replace the plist preset import code with the functionality built into libhb. This now allows the new json preset format to be imported, as well as the legacy plist format.
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@7318 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'win/CS/HandBrake.ApplicationServices/Interop')
3 files changed, 66 insertions, 3 deletions
diff --git a/win/CS/HandBrake.ApplicationServices/Interop/HandBrakePresetService.cs b/win/CS/HandBrake.ApplicationServices/Interop/HandBrakePresetService.cs index e2610905d..8d4f34e9e 100644 --- a/win/CS/HandBrake.ApplicationServices/Interop/HandBrakePresetService.cs +++ b/win/CS/HandBrake.ApplicationServices/Interop/HandBrakePresetService.cs @@ -14,6 +14,7 @@ namespace HandBrake.ApplicationServices.Interop using System.Runtime.InteropServices;
using HandBrake.ApplicationServices.Interop.HbLib;
+ using HandBrake.ApplicationServices.Interop.Helpers;
using HandBrake.ApplicationServices.Interop.Json.Presets;
using HandBrake.ApplicationServices.Services.Logging;
using HandBrake.ApplicationServices.Services.Logging.Model;
@@ -43,5 +44,26 @@ namespace HandBrake.ApplicationServices.Interop return presetList;
}
+
+ /// <summary>
+ /// The get preset from file.
+ /// </summary>
+ /// <param name="filename">
+ /// The filename.
+ /// </param>
+ /// <returns>
+ /// The <see cref="PresetCategory"/>.
+ /// </returns>
+ public static PresetTransportContainer GetPresetFromFile(string filename)
+ {
+ IntPtr presetStringPointer = HBFunctions.hb_presets_read_file_json(InteropUtilities.ToUtf8PtrFromString(filename));
+ string presetJson = Marshal.PtrToStringAnsi(presetStringPointer);
+
+ LogHelper.LogMessage(new LogMessage(presetJson, LogMessageType.libhb, LogLevel.debug));
+
+ PresetTransportContainer preset = JsonConvert.DeserializeObject<PresetTransportContainer>(presetJson);
+
+ return preset;
+ }
}
}
diff --git a/win/CS/HandBrake.ApplicationServices/Interop/HbLib/HbFunctions.cs b/win/CS/HandBrake.ApplicationServices/Interop/HbLib/HbFunctions.cs index 1b68df438..d8d8289f1 100644 --- a/win/CS/HandBrake.ApplicationServices/Interop/HbLib/HbFunctions.cs +++ b/win/CS/HandBrake.ApplicationServices/Interop/HbLib/HbFunctions.cs @@ -440,8 +440,8 @@ namespace HandBrake.ApplicationServices.Interop.HbLib [DllImport("hb.dll", EntryPoint = "hb_presets_builtin_get_json", CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr hb_presets_builtin_get_json();
- // hb_value_t * hb_plist_parse_file(const char *filename);
- [DllImport("hb.dll", EntryPoint = "hb_plist_parse_file", CallingConvention = CallingConvention.Cdecl)]
- public static extern IntPtr hb_plist_parse_file(IntPtr filename);
+ // char * hb_presets_read_file_json(const char *filename);
+ [DllImport("hb.dll", EntryPoint = "hb_presets_read_file_json", CallingConvention = CallingConvention.Cdecl)]
+ public static extern IntPtr hb_presets_read_file_json(IntPtr filename);
}
}
diff --git a/win/CS/HandBrake.ApplicationServices/Interop/Json/Presets/PresetTransportContainer.cs b/win/CS/HandBrake.ApplicationServices/Interop/Json/Presets/PresetTransportContainer.cs new file mode 100644 index 000000000..8f1dd9e78 --- /dev/null +++ b/win/CS/HandBrake.ApplicationServices/Interop/Json/Presets/PresetTransportContainer.cs @@ -0,0 +1,41 @@ +// --------------------------------------------------------------------------------------------------------------------
+// <copyright file="PresetTransportContainer.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>
+// The preset transport container.
+// This is a model for importing the JSON / Plist presets into the GUI.
+// </summary>
+// --------------------------------------------------------------------------------------------------------------------
+
+namespace HandBrake.ApplicationServices.Interop.Json.Presets
+{
+ using System.Collections.Generic;
+
+ /// <summary>
+ /// The preset transport container.
+ /// This is a model for importing the JSON / Plist presets into the GUI.
+ /// </summary>
+ public class PresetTransportContainer
+ {
+ /// <summary>
+ /// Gets or sets the children array.
+ /// </summary>
+ public List<HBPreset> PresetList { get; set; }
+
+ /// <summary>
+ /// Gets or sets the version major.
+ /// </summary>
+ public string VersionMajor { get; set; }
+
+ /// <summary>
+ /// Gets or sets the version micro.
+ /// </summary>
+ public string VersionMicro { get; set; }
+
+ /// <summary>
+ /// Gets or sets the version minor.
+ /// </summary>
+ public string VersionMinor { get; set; }
+ }
+}
|