diff options
author | sr55 <[email protected]> | 2016-03-05 21:52:37 +0000 |
---|---|---|
committer | John Stebbins <[email protected]> | 2016-03-09 13:10:10 -0700 |
commit | 0205f13f2d3226343b3d27eb06170679fd292593 (patch) | |
tree | 4d783d2e24f44f635fb6ceaef46e8ee6fd7daeb5 /win/CS/HandBrake.ApplicationServices | |
parent | b7f4685f8d765d7a5c1335bf4ddc957bf9417433 (diff) |
WinGui: Initial support for dict based filter options.
Diffstat (limited to 'win/CS/HandBrake.ApplicationServices')
6 files changed, 151 insertions, 4 deletions
diff --git a/win/CS/HandBrake.ApplicationServices/HandBrake.ApplicationServices.csproj b/win/CS/HandBrake.ApplicationServices/HandBrake.ApplicationServices.csproj index 16afa531b..60f7a7b9d 100644 --- a/win/CS/HandBrake.ApplicationServices/HandBrake.ApplicationServices.csproj +++ b/win/CS/HandBrake.ApplicationServices/HandBrake.ApplicationServices.csproj @@ -86,6 +86,7 @@ <Compile Include="Interop\EventArgs\MessageLoggedEventArgs.cs" />
<Compile Include="Interop\EventArgs\ScanProgressEventArgs.cs" />
<Compile Include="Interop\HandBrakeEncoderHelpers.cs" />
+ <Compile Include="Interop\HandBrakeFilterHelpers.cs" />
<Compile Include="Interop\HandBrakeInstance.cs" />
<Compile Include="Interop\HandBrakeInstanceManager.cs" />
<Compile Include="Interop\HandBrakeLanguagesHelper.cs" />
@@ -113,6 +114,7 @@ <Compile Include="Interop\Json\Anamorphic\AnamorphicGeometry.cs" />
<Compile Include="Interop\Json\Anamorphic\DestSettings.cs" />
<Compile Include="Interop\Json\Encode\QSV.cs" />
+ <Compile Include="Interop\Json\Filters\PresetTune.cs" />
<Compile Include="Interop\Json\Presets\AudioList.cs" />
<Compile Include="Interop\Json\Presets\HBPreset.cs" />
<Compile Include="Interop\Json\Presets\PresetCategory.cs" />
@@ -136,6 +138,7 @@ <Compile Include="Interop\Json\Encode\Video.cs" />
<Compile Include="Interop\Factories\AnamorphicFactory.cs" />
<Compile Include="Interop\Model\Encoding\DeinterlaceFilter.cs" />
+ <Compile Include="Interop\Model\Encoding\HBPresetTune.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Interop\Json\Scan\SourceAudioTrack.cs" />
<Compile Include="Interop\Json\Scan\SourceChapter.cs" />
diff --git a/win/CS/HandBrake.ApplicationServices/Interop/HandBrakeFilterHelpers.cs b/win/CS/HandBrake.ApplicationServices/Interop/HandBrakeFilterHelpers.cs new file mode 100644 index 000000000..d398ffff9 --- /dev/null +++ b/win/CS/HandBrake.ApplicationServices/Interop/HandBrakeFilterHelpers.cs @@ -0,0 +1,64 @@ +// -------------------------------------------------------------------------------------------------------------------- +// <copyright file="HandBrakeFilterHelpers.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> +// Defines the HandBrakeFilterHelpers type. +// </summary> +// -------------------------------------------------------------------------------------------------------------------- + +namespace HandBrake.ApplicationServices.Interop +{ + using System; + using System.Collections.Generic; + using System.Linq; + using System.Runtime.InteropServices; + + using HandBrake.ApplicationServices.Interop.HbLib; + using HandBrake.ApplicationServices.Interop.Json.Filters; + using HandBrake.ApplicationServices.Interop.Model.Encoding; + + using Newtonsoft.Json; + + /// <summary> + /// The hand brake filter helpers. + /// </summary> + public class HandBrakeFilterHelpers + { + /// <summary> + /// The get filter presets. + /// </summary> + /// <param name="filter"> + /// The filter. + /// </param> + /// <returns> + /// The <see cref="List"/>. + /// </returns> + public static List<HBPresetTune> GetFilterPresets(int filter) + { + IntPtr ptr = HBFunctions.hb_filter_get_presets_json(filter); + string result = Marshal.PtrToStringAnsi(ptr); + List<PresetTune> list = JsonConvert.DeserializeObject<List<PresetTune>>(result); + + return list.Select(item => new HBPresetTune(item.Name, item.Short_Name)).ToList(); + } + + /// <summary> + /// The get filter tunes. + /// </summary> + /// <param name="filter"> + /// The filter. + /// </param> + /// <returns> + /// The <see cref="List"/>. + /// </returns> + public static List<HBPresetTune> GetFilterTunes(int filter) + { + IntPtr ptr = HBFunctions.hb_filter_get_tunes_json(filter); + string result = Marshal.PtrToStringAnsi(ptr); + List<PresetTune> list = JsonConvert.DeserializeObject<List<PresetTune>>(result); + + return list.Select(item => new HBPresetTune(item.Name, item.Short_Name)).ToList(); + } + } +} diff --git a/win/CS/HandBrake.ApplicationServices/Interop/HbLib/HbFunctions.cs b/win/CS/HandBrake.ApplicationServices/Interop/HbLib/HbFunctions.cs index 03606e587..6a7dd6637 100644 --- a/win/CS/HandBrake.ApplicationServices/Interop/HbLib/HbFunctions.cs +++ b/win/CS/HandBrake.ApplicationServices/Interop/HbLib/HbFunctions.cs @@ -362,11 +362,20 @@ namespace HandBrake.ApplicationServices.Interop.HbLib [DllImport("hb.dll", EntryPoint = "hb_filter_init", CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr hb_filter_init(int filter_id);
- [DllImport("hb.dll", EntryPoint = "hb_generate_filter_settings", CallingConvention = CallingConvention.Cdecl)]
- public static extern IntPtr hb_generate_filter_settings(
+ [DllImport("hb.dll", EntryPoint = "hb_generate_filter_settings_json", CallingConvention = CallingConvention.Cdecl)]
+ public static extern IntPtr hb_generate_filter_settings_json(
int filter_id,
[In] [MarshalAs(UnmanagedType.LPStr)] string preset,
- [In] [MarshalAs(UnmanagedType.LPStr)] string tune);
+ [In] [MarshalAs(UnmanagedType.LPStr)] string tune,
+ [In] [MarshalAs(UnmanagedType.LPStr)] string custom);
+
+ /// char* hb_filter_get_presets_json(int filter_id);
+ [DllImport("hb.dll", EntryPoint = "hb_filter_get_presets_json", CallingConvention = CallingConvention.Cdecl)]
+ public static extern IntPtr hb_filter_get_presets_json(int filter_id);
+
+ /// char* hb_filter_get_tuness_json(int filter_id);
+ [DllImport("hb.dll", EntryPoint = "hb_filter_get_tunes_json", CallingConvention = CallingConvention.Cdecl)]
+ public static extern IntPtr hb_filter_get_tunes_json(int filter_id);
[DllImport("hb.dll", EntryPoint = "hb_x264_encopt_name", CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr hb_x264_encopt_name(IntPtr name);
diff --git a/win/CS/HandBrake.ApplicationServices/Interop/Json/Encode/Filter.cs b/win/CS/HandBrake.ApplicationServices/Interop/Json/Encode/Filter.cs index 87bb43190..4479f5d77 100644 --- a/win/CS/HandBrake.ApplicationServices/Interop/Json/Encode/Filter.cs +++ b/win/CS/HandBrake.ApplicationServices/Interop/Json/Encode/Filter.cs @@ -9,6 +9,8 @@ namespace HandBrake.ApplicationServices.Interop.Json.Encode
{
+ using Newtonsoft.Json.Linq;
+
/// <summary>
/// The filter list.
/// </summary>
@@ -22,6 +24,6 @@ namespace HandBrake.ApplicationServices.Interop.Json.Encode /// <summary>
/// Gets or sets the settings.
/// </summary>
- public string Settings { get; set; }
+ public JToken Settings { get; set; }
}
}
\ No newline at end of file diff --git a/win/CS/HandBrake.ApplicationServices/Interop/Json/Filters/PresetTune.cs b/win/CS/HandBrake.ApplicationServices/Interop/Json/Filters/PresetTune.cs new file mode 100644 index 000000000..f69cec099 --- /dev/null +++ b/win/CS/HandBrake.ApplicationServices/Interop/Json/Filters/PresetTune.cs @@ -0,0 +1,27 @@ +// -------------------------------------------------------------------------------------------------------------------- +// <copyright file="PresetTune.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> +// Defines the PresetTune type. +// </summary> +// -------------------------------------------------------------------------------------------------------------------- + +namespace HandBrake.ApplicationServices.Interop.Json.Filters +{ + /// <summary> + /// The preset tune. + /// </summary> + public class PresetTune + { + /// <summary> + /// Gets or sets the name. + /// </summary> + public string Name { get; set; } + + /// <summary> + /// Gets or sets the short name. + /// </summary> + public string Short_Name { get; set; } + } +} diff --git a/win/CS/HandBrake.ApplicationServices/Interop/Model/Encoding/HBPresetTune.cs b/win/CS/HandBrake.ApplicationServices/Interop/Model/Encoding/HBPresetTune.cs new file mode 100644 index 000000000..e5c914fb1 --- /dev/null +++ b/win/CS/HandBrake.ApplicationServices/Interop/Model/Encoding/HBPresetTune.cs @@ -0,0 +1,42 @@ +// -------------------------------------------------------------------------------------------------------------------- +// <copyright file="HBPresetTune.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> +// Defines the HBPresetTune type. +// </summary> +// -------------------------------------------------------------------------------------------------------------------- + +namespace HandBrake.ApplicationServices.Interop.Model.Encoding +{ + /// <summary> + /// The hb preset tune. + /// </summary> + public class HBPresetTune + { + /// <summary> + /// Initializes a new instance of the <see cref="T:System.Object"/> class. + /// </summary> + /// <param name="name"> + /// The name. + /// </param> + /// <param name="shortName"> + /// The short Name. + /// </param> + public HBPresetTune(string name, string shortName) + { + this.Name = name; + this.ShortName = shortName; + } + + /// <summary> + /// Gets the name. + /// </summary> + public string Name { get; private set; } + + /// <summary> + /// Gets the short name. + /// </summary> + public string ShortName { get; private set; } + } +} |