summaryrefslogtreecommitdiffstats
path: root/win/CS/HandBrake.ApplicationServices/Interop
diff options
context:
space:
mode:
Diffstat (limited to 'win/CS/HandBrake.ApplicationServices/Interop')
-rw-r--r--win/CS/HandBrake.ApplicationServices/Interop/HandBrakePresetService.cs22
-rw-r--r--win/CS/HandBrake.ApplicationServices/Interop/HbLib/HbFunctions.cs6
-rw-r--r--win/CS/HandBrake.ApplicationServices/Interop/Json/Presets/PresetTransportContainer.cs41
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; }
+ }
+}