summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--win/CS/HandBrake.Interop/HandBrake.Interop.csproj5
-rw-r--r--win/CS/HandBrake.Interop/Interop/HandBrakeEncoderHelpers.cs61
-rw-r--r--win/CS/HandBrake.Interop/Interop/HandBrakeFilterHelpers.cs19
-rw-r--r--win/CS/HandBrake.Interop/Interop/HandBrakeInstance.cs49
-rw-r--r--win/CS/HandBrake.Interop/Interop/HandBrakeLanguagesHelper.cs20
-rw-r--r--win/CS/HandBrake.Interop/Interop/HandBrakePresetService.cs17
-rw-r--r--win/CS/HandBrake.Interop/Interop/HandBrakeUnitConversionHelpers.cs12
-rw-r--r--win/CS/HandBrake.Interop/Interop/HandBrakeUtils.cs33
-rw-r--r--win/CS/HandBrake.Interop/Interop/HbLib/HbFunctions.cs201
-rw-r--r--win/CS/HandBrake.Interop/Interop/HbLib/Wrappers/HbFunctionsDirect.cs501
-rw-r--r--win/CS/HandBrake.Interop/Interop/HbLib/Wrappers/Interfaces/IHbFunctions.cs215
-rw-r--r--win/CS/HandBrake.Interop/Interop/Helpers/InteropUtilities.cs13
-rw-r--r--win/CS/HandBrake.Interop/Interop/Helpers/NativeList.cs24
-rw-r--r--win/CS/HandBrake.Interop/Interop/Model/Encoding/HBVideoEncoder.cs16
-rw-r--r--win/CS/HandBrake.Interop/Interop/Providers/HbFunctionsProvider.cs30
-rw-r--r--win/CS/HandBrake.Interop/Interop/Providers/Interfaces/IHbFunctionsProvider.cs18
-rw-r--r--win/CS/HandBrake.Interop/Utilities/SystemInfo.cs28
-rw-r--r--win/CS/HandBrake.Interop/Utilities/VersionHelper.cs18
-rw-r--r--win/CS/HandBrakeWPF/Helpers/PictureSize.cs11
-rw-r--r--win/CS/HandBrakeWPF/Services/Encode/Factories/EncodeTaskFactory.cs33
-rw-r--r--win/CS/HandBrakeWPF/Services/Encode/Factories/QueueFactory.cs10
-rw-r--r--win/CS/HandBrakeWPF/Services/Encode/LibEncode.cs10
-rw-r--r--win/CS/HandBrakeWPF/Services/PowerService.cs5
-rw-r--r--win/CS/HandBrakeWPF/Services/Scan/Factories/TitleFactory.cs12
-rw-r--r--win/CS/HandBrakeWPF/Startup/AppBootstrapper.cs4
-rw-r--r--win/CS/HandBrakeWPF/ViewModels/StaticPreviewViewModel.cs17
-rw-r--r--win/CS/HandBrakeWPF/Views/VideoView.xaml5
27 files changed, 1063 insertions, 324 deletions
diff --git a/win/CS/HandBrake.Interop/HandBrake.Interop.csproj b/win/CS/HandBrake.Interop/HandBrake.Interop.csproj
index 733c81248..e6f5b4769 100644
--- a/win/CS/HandBrake.Interop/HandBrake.Interop.csproj
+++ b/win/CS/HandBrake.Interop/HandBrake.Interop.csproj
@@ -80,6 +80,8 @@
<Compile Include="Interop\HbLib\hb_subtitle.cs" />
<Compile Include="Interop\HbLib\iso639_lang_t.cs" />
<Compile Include="Interop\HbLib\NativeConstants.cs" />
+ <Compile Include="Interop\HbLib\Wrappers\HbFunctionsDirect.cs" />
+ <Compile Include="Interop\HbLib\Wrappers\Interfaces\IHbFunctions.cs" />
<Compile Include="Interop\Helpers\InteropUtilities.cs" />
<Compile Include="Interop\Helpers\NativeList.cs" />
<Compile Include="Interop\Helpers\Utilities.cs" />
@@ -123,6 +125,8 @@
<Compile Include="Interop\Model\Encoding\Sharpen.cs" />
<Compile Include="Interop\Model\PresetVersion.cs" />
<Compile Include="Interop\Model\Preview\RawPreviewData.cs" />
+ <Compile Include="Interop\Providers\HbFunctionsProvider.cs" />
+ <Compile Include="Interop\Providers\Interfaces\IHbFunctionsProvider.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Interop\Json\Scan\SourceAudioTrack.cs" />
<Compile Include="Interop\Json\Scan\SourceChapter.cs" />
@@ -186,6 +190,7 @@
<SubType>Designer</SubType>
</EmbeddedResource>
</ItemGroup>
+ <ItemGroup />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
<TargetFrameworkSDKToolsDirectory Condition=" '$(Platform)' == 'x64'">$(TargetFrameworkSDKToolsDirectory)$(Platform)\</TargetFrameworkSDKToolsDirectory>
diff --git a/win/CS/HandBrake.Interop/Interop/HandBrakeEncoderHelpers.cs b/win/CS/HandBrake.Interop/Interop/HandBrakeEncoderHelpers.cs
index 4d1dcea2e..d728809e3 100644
--- a/win/CS/HandBrake.Interop/Interop/HandBrakeEncoderHelpers.cs
+++ b/win/CS/HandBrake.Interop/Interop/HandBrakeEncoderHelpers.cs
@@ -14,15 +14,19 @@ namespace HandBrake.Interop.Interop
using System.Linq;
using HandBrake.Interop.Interop.HbLib;
+ using HandBrake.Interop.Interop.HbLib.Wrappers.Interfaces;
using HandBrake.Interop.Interop.Helpers;
using HandBrake.Interop.Interop.Model;
using HandBrake.Interop.Interop.Model.Encoding;
+ using HandBrake.Interop.Interop.Providers;
+ using HandBrake.Interop.Interop.Providers.Interfaces;
/// <summary>
/// The encoders.
/// </summary>
public static class HandBrakeEncoderHelpers
{
+ private static IHbFunctions hbFunctions;
private static List<HBAudioEncoder> audioEncoders;
private static List<HBVideoEncoder> videoEncoders;
private static List<HBRate> videoFramerates;
@@ -36,6 +40,9 @@ namespace HandBrake.Interop.Interop
/// </summary>
static HandBrakeEncoderHelpers()
{
+ IHbFunctionsProvider hbFunctionsProvider = new HbFunctionsProvider();
+ hbFunctions = hbFunctionsProvider.GetHbFunctionsWrapper();
+
if (!HandBrakeUtils.IsInitialised())
{
throw new Exception("Please Initialise with HandBrakeUtils.EnsureGlobalInit before using!");
@@ -51,7 +58,7 @@ namespace HandBrake.Interop.Interop
{
if (audioEncoders == null)
{
- audioEncoders = InteropUtilities.ToListFromIterator<hb_encoder_s, HBAudioEncoder>(HBFunctions.hb_audio_encoder_get_next, HandBrakeUnitConversionHelpers.NativeToAudioEncoder);
+ audioEncoders = InteropUtilities.ToListFromIterator<hb_encoder_s, HBAudioEncoder>(hbFunctions.hb_audio_encoder_get_next, HandBrakeUnitConversionHelpers.NativeToAudioEncoder);
}
return audioEncoders;
@@ -67,7 +74,7 @@ namespace HandBrake.Interop.Interop
{
if (videoEncoders == null)
{
- videoEncoders = InteropUtilities.ToListFromIterator<hb_encoder_s, HBVideoEncoder>(HBFunctions.hb_video_encoder_get_next, HandBrakeUnitConversionHelpers.NativeToVideoEncoder);
+ videoEncoders = InteropUtilities.ToListFromIterator<hb_encoder_s, HBVideoEncoder>(hbFunctions.hb_video_encoder_get_next, HandBrakeUnitConversionHelpers.NativeToVideoEncoder);
}
return videoEncoders;
@@ -83,7 +90,7 @@ namespace HandBrake.Interop.Interop
{
if (videoFramerates == null)
{
- videoFramerates = InteropUtilities.ToListFromIterator<hb_rate_s, HBRate>(HBFunctions.hb_video_framerate_get_next, HandBrakeUnitConversionHelpers.NativeToRate);
+ videoFramerates = InteropUtilities.ToListFromIterator<hb_rate_s, HBRate>(hbFunctions.hb_video_framerate_get_next, HandBrakeUnitConversionHelpers.NativeToRate);
}
return videoFramerates;
@@ -99,7 +106,7 @@ namespace HandBrake.Interop.Interop
{
if (mixdowns == null)
{
- mixdowns = InteropUtilities.ToListFromIterator<hb_mixdown_s, HBMixdown>(HBFunctions.hb_mixdown_get_next, HandBrakeUnitConversionHelpers.NativeToMixdown);
+ mixdowns = InteropUtilities.ToListFromIterator<hb_mixdown_s, HBMixdown>(hbFunctions.hb_mixdown_get_next, HandBrakeUnitConversionHelpers.NativeToMixdown);
}
return mixdowns;
@@ -115,7 +122,7 @@ namespace HandBrake.Interop.Interop
{
if (audioBitrates == null)
{
- audioBitrates = InteropUtilities.ToListFromIterator<hb_rate_s, int>(HBFunctions.hb_audio_bitrate_get_next, b => b.rate);
+ audioBitrates = InteropUtilities.ToListFromIterator<hb_rate_s, int>(hbFunctions.hb_audio_bitrate_get_next, b => b.rate);
}
return audioBitrates;
@@ -131,7 +138,7 @@ namespace HandBrake.Interop.Interop
{
if (audioSampleRates == null)
{
- audioSampleRates = InteropUtilities.ToListFromIterator<hb_rate_s, HBRate>(HBFunctions.hb_audio_samplerate_get_next, HandBrakeUnitConversionHelpers.NativeToRate);
+ audioSampleRates = InteropUtilities.ToListFromIterator<hb_rate_s, HBRate>(hbFunctions.hb_audio_samplerate_get_next, HandBrakeUnitConversionHelpers.NativeToRate);
}
return audioSampleRates;
@@ -147,7 +154,7 @@ namespace HandBrake.Interop.Interop
{
if (containers == null)
{
- containers = InteropUtilities.ToListFromIterator<hb_container_s, HBContainer>(HBFunctions.hb_container_get_next, HandBrakeUnitConversionHelpers.NativeToContainer);
+ containers = InteropUtilities.ToListFromIterator<hb_container_s, HBContainer>(hbFunctions.hb_container_get_next, HandBrakeUnitConversionHelpers.NativeToContainer);
}
return containers;
@@ -161,7 +168,7 @@ namespace HandBrake.Interop.Interop
{
get
{
- return HBFunctions.hb_subtitle_can_burn((int)hb_subtitle_s_subsource.IMPORTSRT) > 0;
+ return hbFunctions.hb_subtitle_can_burn((int)hb_subtitle_s_subsource.IMPORTSRT) > 0;
}
}
@@ -172,7 +179,7 @@ namespace HandBrake.Interop.Interop
{
get
{
- return HBFunctions.hb_subtitle_can_burn((int)hb_subtitle_s_subsource.IMPORTSSA) > 0;
+ return hbFunctions.hb_subtitle_can_burn((int)hb_subtitle_s_subsource.IMPORTSSA) > 0;
}
}
@@ -267,7 +274,7 @@ namespace HandBrake.Interop.Interop
/// </returns>
public static bool SubtitleCanSetForcedOnly(int source)
{
- return HBFunctions.hb_subtitle_can_force(source) > 0;
+ return hbFunctions.hb_subtitle_can_force(source) > 0;
}
/// <summary>
@@ -281,7 +288,7 @@ namespace HandBrake.Interop.Interop
/// </returns>
public static bool SubtitleCanBurn(int source)
{
- return HBFunctions.hb_subtitle_can_burn(source) > 0;
+ return hbFunctions.hb_subtitle_can_burn(source) > 0;
}
/// <summary>
@@ -298,7 +305,7 @@ namespace HandBrake.Interop.Interop
/// </returns>
public static bool SubtitleCanPassthrough(int subtitleSourceType, int muxer)
{
- return HBFunctions.hb_subtitle_can_pass(subtitleSourceType, muxer) > 0;
+ return hbFunctions.hb_subtitle_can_pass(subtitleSourceType, muxer) > 0;
}
/// <summary>
@@ -370,7 +377,7 @@ namespace HandBrake.Interop.Interop
/// </returns>
public static bool MixdownHasRemixSupport(HBMixdown mixdown, ulong layout)
{
- return HBFunctions.hb_mixdown_has_remix_support(mixdown.Id, layout) > 0;
+ return hbFunctions.hb_mixdown_has_remix_support(mixdown.Id, layout) > 0;
}
/// <summary>
@@ -387,7 +394,7 @@ namespace HandBrake.Interop.Interop
/// </returns>
public static bool MixdownHasCodecSupport(HBMixdown mixdown, HBAudioEncoder encoder)
{
- return HBFunctions.hb_mixdown_has_codec_support(mixdown.Id, (uint)encoder.Id) > 0;
+ return hbFunctions.hb_mixdown_has_codec_support(mixdown.Id, (uint)encoder.Id) > 0;
}
/// <summary>
@@ -403,7 +410,7 @@ namespace HandBrake.Interop.Interop
/// <returns>True if available.</returns>
public static bool MixdownIsSupported(HBMixdown mixdown, HBAudioEncoder encoder, long channelLayout)
{
- return HBFunctions.hb_mixdown_is_supported(mixdown.Id, (uint)encoder.Id, (uint)channelLayout) > 0;
+ return hbFunctions.hb_mixdown_is_supported(mixdown.Id, (uint)encoder.Id, (uint)channelLayout) > 0;
}
/// <summary>
@@ -423,7 +430,7 @@ namespace HandBrake.Interop.Interop
/// </returns>
public static bool CanApplyDrc(IntPtr handle, int trackNumber, HBAudioEncoder encoder, int title)
{
- return HBFunctions.hb_audio_can_apply_drc2(handle, title, trackNumber, encoder.Id) > 0;
+ return hbFunctions.hb_audio_can_apply_drc2(handle, title, trackNumber, encoder.Id) > 0;
}
/// <summary>
@@ -462,7 +469,7 @@ namespace HandBrake.Interop.Interop
return null;
}
- int sanitizedMixdown = HBFunctions.hb_mixdown_get_best((uint)encoder.Id, layout, mixdown.Id);
+ int sanitizedMixdown = hbFunctions.hb_mixdown_get_best((uint)encoder.Id, layout, mixdown.Id);
if (sanitizedMixdown != -1)
{
return Mixdowns.Single(m => m.Id == sanitizedMixdown);
@@ -485,7 +492,7 @@ namespace HandBrake.Interop.Interop
/// </returns>
public static HBMixdown GetDefaultMixdown(HBAudioEncoder encoder, ulong layout)
{
- int defaultMixdown = HBFunctions.hb_mixdown_get_default((uint)encoder.Id, layout);
+ int defaultMixdown = hbFunctions.hb_mixdown_get_default((uint)encoder.Id, layout);
return Mixdowns.Single(m => m.Id == defaultMixdown);
}
@@ -497,7 +504,7 @@ namespace HandBrake.Interop.Interop
/// <returns>The sanitized sample rate.</returns>
public static int SanitizeSampleRate(HBAudioEncoder encoder, int sampleRate)
{
- return HBFunctions.hb_audio_samplerate_find_closest(sampleRate, (uint)encoder.Id);
+ return hbFunctions.hb_audio_samplerate_find_closest(sampleRate, (uint)encoder.Id);
}
/// <summary>
@@ -520,7 +527,7 @@ namespace HandBrake.Interop.Interop
int low = 0;
int high = 0;
- HBFunctions.hb_audio_bitrate_get_limits((uint)encoder.Id, sampleRate, mixdown.Id, ref low, ref high);
+ hbFunctions.hb_audio_bitrate_get_limits((uint)encoder.Id, sampleRate, mixdown.Id, ref low, ref high);
return new BitrateLimits(low, high);
}
@@ -541,7 +548,7 @@ namespace HandBrake.Interop.Interop
float granularity = 0;
int direction = 0;
- HBFunctions.hb_video_quality_get_limits((uint)encoder.Id, ref low, ref high, ref granularity, ref direction);
+ hbFunctions.hb_video_quality_get_limits((uint)encoder.Id, ref low, ref high, ref granularity, ref direction);
return new VideoQualityLimits(low, high, granularity, direction == 0);
}
@@ -566,7 +573,7 @@ namespace HandBrake.Interop.Interop
/// </returns>
public static int SanitizeAudioBitrate(int audioBitrate, HBAudioEncoder encoder, int sampleRate, HBMixdown mixdown)
{
- return HBFunctions.hb_audio_bitrate_get_best((uint)encoder.Id, audioBitrate, sampleRate, mixdown.Id);
+ return hbFunctions.hb_audio_bitrate_get_best((uint)encoder.Id, audioBitrate, sampleRate, mixdown.Id);
}
/// <summary>
@@ -586,7 +593,7 @@ namespace HandBrake.Interop.Interop
/// </returns>
public static int GetDefaultBitrate(HBAudioEncoder encoder, int sampleRate, HBMixdown mixdown)
{
- return HBFunctions.hb_audio_bitrate_get_default((uint)encoder.Id, sampleRate, mixdown.Id);
+ return hbFunctions.hb_audio_bitrate_get_default((uint)encoder.Id, sampleRate, mixdown.Id);
}
/// <summary>
@@ -602,7 +609,7 @@ namespace HandBrake.Interop.Interop
{
float low = 0, high = 0, granularity = 0;
int direction = 0;
- HBFunctions.hb_audio_quality_get_limits((uint)encoderId, ref low, ref high, ref granularity, ref direction);
+ hbFunctions.hb_audio_quality_get_limits((uint)encoderId, ref low, ref high, ref granularity, ref direction);
return new RangeLimits(direction == 0, granularity, high, low);
}
@@ -620,7 +627,7 @@ namespace HandBrake.Interop.Interop
{
float low = 0, high = 0, granularity = 0;
int direction = 0;
- HBFunctions.hb_audio_compression_get_limits((uint)encoderId, ref low, ref high, ref granularity, ref direction);
+ hbFunctions.hb_audio_compression_get_limits((uint)encoderId, ref low, ref high, ref granularity, ref direction);
return new RangeLimits(direction == 0, granularity, high, low);
}
@@ -636,7 +643,7 @@ namespace HandBrake.Interop.Interop
/// </returns>
public static double GetDefaultQuality(HBAudioEncoder encoder)
{
- return HBFunctions.hb_audio_quality_get_default((uint)encoder.Id);
+ return hbFunctions.hb_audio_quality_get_default((uint)encoder.Id);
}
/// <summary>
@@ -650,7 +657,7 @@ namespace HandBrake.Interop.Interop
/// </returns>
public static double GetDefaultAudioCompression(HBAudioEncoder encoder)
{
- return HBFunctions.hb_audio_compression_get_default((uint)encoder.Id);
+ return hbFunctions.hb_audio_compression_get_default((uint)encoder.Id);
}
}
}
diff --git a/win/CS/HandBrake.Interop/Interop/HandBrakeFilterHelpers.cs b/win/CS/HandBrake.Interop/Interop/HandBrakeFilterHelpers.cs
index e8d7f5f31..c398f2f0a 100644
--- a/win/CS/HandBrake.Interop/Interop/HandBrakeFilterHelpers.cs
+++ b/win/CS/HandBrake.Interop/Interop/HandBrakeFilterHelpers.cs
@@ -15,9 +15,12 @@ namespace HandBrake.Interop.Interop
using System.Runtime.InteropServices;
using HandBrake.Interop.Interop.HbLib;
+ using HandBrake.Interop.Interop.HbLib.Wrappers.Interfaces;
using HandBrake.Interop.Interop.Helpers;
using HandBrake.Interop.Interop.Json.Filters;
using HandBrake.Interop.Interop.Model.Encoding;
+ using HandBrake.Interop.Interop.Providers;
+ using HandBrake.Interop.Interop.Providers.Interfaces;
using Newtonsoft.Json;
@@ -26,6 +29,14 @@ namespace HandBrake.Interop.Interop
/// </summary>
public class HandBrakeFilterHelpers
{
+ private static IHbFunctions hbFunctions;
+
+ static HandBrakeFilterHelpers()
+ {
+ IHbFunctionsProvider hbFunctionsProvider = new HbFunctionsProvider();
+ hbFunctions = hbFunctionsProvider.GetHbFunctionsWrapper();
+ }
+
/// <summary>
/// The get filter presets.
/// </summary>
@@ -37,7 +48,7 @@ namespace HandBrake.Interop.Interop
/// </returns>
public static List<HBPresetTune> GetFilterPresets(int filter)
{
- IntPtr ptr = HBFunctions.hb_filter_get_presets_json(filter);
+ IntPtr ptr = hbFunctions.hb_filter_get_presets_json(filter);
string result = Marshal.PtrToStringAnsi(ptr);
List<PresetTune> list = JsonConvert.DeserializeObject<List<PresetTune>>(result);
@@ -55,7 +66,7 @@ namespace HandBrake.Interop.Interop
/// </returns>
public static List<HBPresetTune> GetFilterTunes(int filter)
{
- IntPtr ptr = HBFunctions.hb_filter_get_tunes_json(filter);
+ IntPtr ptr = hbFunctions.hb_filter_get_tunes_json(filter);
string result = Marshal.PtrToStringAnsi(ptr);
List<PresetTune> list = JsonConvert.DeserializeObject<List<PresetTune>>(result);
@@ -69,7 +80,7 @@ namespace HandBrake.Interop.Interop
/// <returns>The list of keys for custom settings for the filter.</returns>
public static List<string> GetFilterKeys(int filter)
{
- IntPtr ptr = HBFunctions.hb_filter_get_keys(filter);
+ IntPtr ptr = hbFunctions.hb_filter_get_keys(filter);
return InteropUtilities.ToStringListFromArrayPtr(ptr);
}
@@ -96,7 +107,7 @@ namespace HandBrake.Interop.Interop
return new Dictionary<string, string>();
}
- IntPtr ptr = HBFunctions.hb_generate_filter_settings_json(filter, presetName, null, null);
+ IntPtr ptr = hbFunctions.hb_generate_filter_settings_json(filter, presetName, null, null);
string result = Marshal.PtrToStringAnsi(ptr);
return JsonConvert.DeserializeObject<Dictionary<string, string>>(result);
}
diff --git a/win/CS/HandBrake.Interop/Interop/HandBrakeInstance.cs b/win/CS/HandBrake.Interop/Interop/HandBrakeInstance.cs
index 275f7ca29..69bf56155 100644
--- a/win/CS/HandBrake.Interop/Interop/HandBrakeInstance.cs
+++ b/win/CS/HandBrake.Interop/Interop/HandBrakeInstance.cs
@@ -20,6 +20,7 @@ namespace HandBrake.Interop.Interop
using HandBrake.Interop.Interop.EventArgs;
using HandBrake.Interop.Interop.Factories;
using HandBrake.Interop.Interop.HbLib;
+ using HandBrake.Interop.Interop.HbLib.Wrappers.Interfaces;
using HandBrake.Interop.Interop.Helpers;
using HandBrake.Interop.Interop.Interfaces;
using HandBrake.Interop.Interop.Json.Encode;
@@ -27,11 +28,14 @@ namespace HandBrake.Interop.Interop
using HandBrake.Interop.Interop.Json.State;
using HandBrake.Interop.Interop.Model.Encoding;
using HandBrake.Interop.Interop.Model.Preview;
+ using HandBrake.Interop.Interop.Providers;
+ using HandBrake.Interop.Interop.Providers.Interfaces;
using Newtonsoft.Json;
public class HandBrakeInstance : IHandBrakeInstance, IDisposable
{
+ private IHbFunctions hbFunctions;
private const double ScanPollIntervalMs = 250;
private const double EncodePollIntervalMs = 250;
private Timer scanPollTimer;
@@ -97,12 +101,12 @@ namespace HandBrake.Interop.Interop
/// <summary>
/// Gets the HandBrake version string.
/// </summary>
- public string Version => Marshal.PtrToStringAnsi(HBFunctions.hb_get_version(this.Handle));
+ public string Version => Marshal.PtrToStringAnsi(hbFunctions.hb_get_version(this.Handle));
/// <summary>
/// Gets the HandBrake build number.
/// </summary>
- public int Build => HBFunctions.hb_get_build(this.Handle);
+ public int Build => hbFunctions.hb_get_build(this.Handle);
/// <summary>
/// Initializes this instance.
@@ -115,10 +119,13 @@ namespace HandBrake.Interop.Interop
/// </param>
public void Initialize(int verbosity, bool noHardware)
{
+ IHbFunctionsProvider hbFunctionsProvider = new HbFunctionsProvider();
+ hbFunctions = hbFunctionsProvider.GetHbFunctionsWrapper();
+
HandBrakeUtils.EnsureGlobalInit(noHardware);
HandBrakeUtils.RegisterLogger();
- this.Handle = HBFunctions.hb_init(verbosity, update_check: 0);
+ this.Handle = hbFunctions.hb_init(verbosity, update_check: 0);
}
/// <summary>
@@ -141,7 +148,7 @@ namespace HandBrake.Interop.Interop
this.PreviewCount = previewCount;
IntPtr pathPtr = InteropUtilities.ToUtf8PtrFromString(path);
- HBFunctions.hb_scan(this.Handle, pathPtr, titleIndex, previewCount, 1, (ulong)(minDuration.TotalSeconds * 90000));
+ hbFunctions.hb_scan(this.Handle, pathPtr, titleIndex, previewCount, 1, (ulong)(minDuration.TotalSeconds * 90000));
Marshal.FreeHGlobal(pathPtr);
this.scanPollTimer = new Timer();
@@ -170,7 +177,7 @@ namespace HandBrake.Interop.Interop
public void StopScan()
{
this.scanPollTimer.Stop();
- HBFunctions.hb_scan_stop(this.Handle);
+ hbFunctions.hb_scan_stop(this.Handle);
}
/// <summary>
@@ -217,7 +224,7 @@ namespace HandBrake.Interop.Interop
};
// Fetch the image data from LibHb
- IntPtr resultingImageStuct = HBFunctions.hb_get_preview2(this.Handle, settings.TitleNumber, previewNumber, ref uiGeometry, deinterlace ? 1 : 0);
+ IntPtr resultingImageStuct = hbFunctions.hb_get_preview2(this.Handle, settings.TitleNumber, previewNumber, ref uiGeometry, deinterlace ? 1 : 0);
hb_image_s image = InteropUtilities.ToStructureFromPtr<hb_image_s>(resultingImageStuct);
// Copy the filled image buffer to a managed array.
@@ -233,7 +240,7 @@ namespace HandBrake.Interop.Interop
// Close the image so we don't leak memory.
IntPtr nativeJobPtrPtr = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(IntPtr)));
Marshal.WriteIntPtr(nativeJobPtrPtr, resultingImageStuct);
- HBFunctions.hb_image_close(nativeJobPtrPtr);
+ hbFunctions.hb_image_close(nativeJobPtrPtr);
Marshal.FreeHGlobal(nativeJobPtrPtr);
return preview;
@@ -248,7 +255,7 @@ namespace HandBrake.Interop.Interop
/// <returns>True if DRC can be applied to the track with the given encoder.</returns>
public bool CanApplyDrc(int trackNumber, HBAudioEncoder encoder, int title)
{
- return HBFunctions.hb_audio_can_apply_drc2(this.Handle, title, trackNumber, encoder.Id) > 0;
+ return hbFunctions.hb_audio_can_apply_drc2(this.Handle, title, trackNumber, encoder.Id) > 0;
}
/// <summary>
@@ -276,8 +283,8 @@ namespace HandBrake.Interop.Interop
[HandleProcessCorruptedStateExceptions]
public void StartEncode(string encodeJson)
{
- HBFunctions.hb_add_json(this.Handle, InteropUtilities.ToUtf8PtrFromString(encodeJson));
- HBFunctions.hb_start(this.Handle);
+ hbFunctions.hb_add_json(this.Handle, InteropUtilities.ToUtf8PtrFromString(encodeJson));
+ hbFunctions.hb_start(this.Handle);
this.encodePollTimer = new Timer();
this.encodePollTimer.Interval = EncodePollIntervalMs;
@@ -302,7 +309,7 @@ namespace HandBrake.Interop.Interop
[HandleProcessCorruptedStateExceptions]
public void PauseEncode()
{
- HBFunctions.hb_pause(this.Handle);
+ hbFunctions.hb_pause(this.Handle);
}
/// <summary>
@@ -311,7 +318,7 @@ namespace HandBrake.Interop.Interop
[HandleProcessCorruptedStateExceptions]
public void ResumeEncode()
{
- HBFunctions.hb_resume(this.Handle);
+ hbFunctions.hb_resume(this.Handle);
}
/// <summary>
@@ -320,20 +327,20 @@ namespace HandBrake.Interop.Interop
[HandleProcessCorruptedStateExceptions]
public void StopEncode()
{
- HBFunctions.hb_stop(this.Handle);
+ hbFunctions.hb_stop(this.Handle);
// Also remove all jobs from the queue (in case we stopped a 2-pass encode)
var currentJobs = new List<IntPtr>();
- int jobs = HBFunctions.hb_count(this.Handle);
+ int jobs = hbFunctions.hb_count(this.Handle);
for (int i = 0; i < jobs; i++)
{
- currentJobs.Add(HBFunctions.hb_job(this.Handle, 0));
+ currentJobs.Add(hbFunctions.hb_job(this.Handle, 0));
}
foreach (IntPtr job in currentJobs)
{
- HBFunctions.hb_rem(this.Handle, job);
+ hbFunctions.hb_rem(this.Handle, job);
}
}
@@ -346,7 +353,7 @@ namespace HandBrake.Interop.Interop
[HandleProcessCorruptedStateExceptions]
public JsonState GetEncodeProgress()
{
- IntPtr json = HBFunctions.hb_get_state_json(this.Handle);
+ IntPtr json = hbFunctions.hb_get_state_json(this.Handle);
string statusJson = Marshal.PtrToStringAnsi(json);
JsonState state = JsonConvert.DeserializeObject<JsonState>(statusJson);
@@ -394,7 +401,7 @@ namespace HandBrake.Interop.Interop
// Free unmanaged objects.
IntPtr handlePtr = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(IntPtr)));
Marshal.WriteIntPtr(handlePtr, this.Handle);
- HBFunctions.hb_close(handlePtr);
+ hbFunctions.hb_close(handlePtr);
Marshal.FreeHGlobal(handlePtr);
this.disposed = true;
@@ -406,7 +413,7 @@ namespace HandBrake.Interop.Interop
[HandleProcessCorruptedStateExceptions]
private void PollScanProgress()
{
- IntPtr json = HBFunctions.hb_get_state_json(this.Handle);
+ IntPtr json = hbFunctions.hb_get_state_json(this.Handle);
string statusJson = Marshal.PtrToStringAnsi(json);
JsonState state = null;
if (!string.IsNullOrEmpty(statusJson))
@@ -427,7 +434,7 @@ namespace HandBrake.Interop.Interop
{
this.scanPollTimer.Stop();
- var jsonMsg = HBFunctions.hb_get_title_set_json(this.Handle);
+ var jsonMsg = hbFunctions.hb_get_title_set_json(this.Handle);
this.TitlesJson = InteropUtilities.ToStringFromUtf8Ptr(jsonMsg);
if (!string.IsNullOrEmpty(this.TitlesJson))
@@ -452,7 +459,7 @@ namespace HandBrake.Interop.Interop
[HandleProcessCorruptedStateExceptions]
private void PollEncodeProgress()
{
- IntPtr json = HBFunctions.hb_get_state_json(this.Handle);
+ IntPtr json = hbFunctions.hb_get_state_json(this.Handle);
string statusJson = Marshal.PtrToStringAnsi(json);
JsonState state = JsonConvert.DeserializeObject<JsonState>(statusJson);
diff --git a/win/CS/HandBrake.Interop/Interop/HandBrakeLanguagesHelper.cs b/win/CS/HandBrake.Interop/Interop/HandBrakeLanguagesHelper.cs
index 36b7a19e1..b96a38c72 100644
--- a/win/CS/HandBrake.Interop/Interop/HandBrakeLanguagesHelper.cs
+++ b/win/CS/HandBrake.Interop/Interop/HandBrakeLanguagesHelper.cs
@@ -12,18 +12,26 @@ namespace HandBrake.Interop.Interop
using System.Collections.Generic;
using HandBrake.Interop.Interop.HbLib;
+ using HandBrake.Interop.Interop.HbLib.Wrappers.Interfaces;
using HandBrake.Interop.Interop.Helpers;
using HandBrake.Interop.Interop.Model;
+ using HandBrake.Interop.Interop.Providers;
+ using HandBrake.Interop.Interop.Providers.Interfaces;
/// <summary>
/// Contains utilities for converting language codes.
/// </summary>
public static class HandBrakeLanguagesHelper
{
- /// <summary>
- /// The list of all languages.
- /// </summary>
- private static IList<Language> allLanguages;
+ private static IList<Language> allLanguages;
+
+ private static IHbFunctions hbFunctions;
+
+ static HandBrakeLanguagesHelper()
+ {
+ IHbFunctionsProvider hbFunctionsProvider = new HbFunctionsProvider();
+ hbFunctions = hbFunctionsProvider.GetHbFunctionsWrapper();
+ }
/// <summary>
/// Gets a list of all languages.
@@ -34,7 +42,7 @@ namespace HandBrake.Interop.Interop
{
return allLanguages
?? (allLanguages =
- InteropUtilities.ToListFromIterator<iso639_lang_t, Language>(HBFunctions.lang_get_next, HandBrakeUnitConversionHelpers.NativeToLanguage));
+ InteropUtilities.ToListFromIterator<iso639_lang_t, Language>(hbFunctions.lang_get_next, HandBrakeUnitConversionHelpers.NativeToLanguage));
}
}
@@ -45,7 +53,7 @@ namespace HandBrake.Interop.Interop
/// <returns>Object that describes the language.</returns>
public static Language Get(string code)
{
- iso639_lang_t language = InteropUtilities.ToStructureFromPtr<iso639_lang_t>(HBFunctions.lang_for_code2(code));
+ iso639_lang_t language = InteropUtilities.ToStructureFromPtr<iso639_lang_t>(hbFunctions.lang_for_code2(code));
return HandBrakeUnitConversionHelpers.NativeToLanguage(language);
}
}
diff --git a/win/CS/HandBrake.Interop/Interop/HandBrakePresetService.cs b/win/CS/HandBrake.Interop/Interop/HandBrakePresetService.cs
index 98eb6071b..72352478c 100644
--- a/win/CS/HandBrake.Interop/Interop/HandBrakePresetService.cs
+++ b/win/CS/HandBrake.Interop/Interop/HandBrakePresetService.cs
@@ -15,9 +15,12 @@ namespace HandBrake.Interop.Interop
using System.Runtime.InteropServices;
using HandBrake.Interop.Interop.HbLib;
+ using HandBrake.Interop.Interop.HbLib.Wrappers.Interfaces;
using HandBrake.Interop.Interop.Helpers;
using HandBrake.Interop.Interop.Json.Presets;
using HandBrake.Interop.Interop.Model;
+ using HandBrake.Interop.Interop.Providers;
+ using HandBrake.Interop.Interop.Providers.Interfaces;
using Newtonsoft.Json;
@@ -26,6 +29,14 @@ namespace HandBrake.Interop.Interop
/// </summary>
public class HandBrakePresetService
{
+ private static IHbFunctions hbFunctions;
+
+ static HandBrakePresetService()
+ {
+ IHbFunctionsProvider hbFunctionsProvider = new HbFunctionsProvider();
+ hbFunctions = hbFunctionsProvider.GetHbFunctionsWrapper();
+ }
+
/// <summary>
/// The get built in presets.
/// Requires an hb_init to have been invoked.
@@ -35,7 +46,7 @@ namespace HandBrake.Interop.Interop
/// </returns>
public static IList<PresetCategory> GetBuiltInPresets()
{
- IntPtr presets = HBFunctions.hb_presets_builtin_get_json();
+ IntPtr presets = hbFunctions.hb_presets_builtin_get_json();
string presetJson = Marshal.PtrToStringAnsi(presets);
IList<PresetCategory> presetList = JsonConvert.DeserializeObject<IList<PresetCategory>>(presetJson);
@@ -53,7 +64,7 @@ namespace HandBrake.Interop.Interop
/// </returns>
public static PresetTransportContainer GetPresetsFromFile(string filename)
{
- IntPtr presetStringPointer = HBFunctions.hb_presets_read_file_json(InteropUtilities.ToUtf8PtrFromString(filename));
+ IntPtr presetStringPointer = hbFunctions.hb_presets_read_file_json(InteropUtilities.ToUtf8PtrFromString(filename));
string presetJson = Marshal.PtrToStringAnsi(presetStringPointer);
if (!string.IsNullOrEmpty(presetJson))
@@ -96,7 +107,7 @@ namespace HandBrake.Interop.Interop
IntPtr minor = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(int)));
IntPtr micro = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(int)));
- HBFunctions.hb_presets_current_version(major, minor, micro);
+ hbFunctions.hb_presets_current_version(major, minor, micro);
int majorVersion = Marshal.ReadInt32(major);
int minorVersion = Marshal.ReadInt32(minor);
diff --git a/win/CS/HandBrake.Interop/Interop/HandBrakeUnitConversionHelpers.cs b/win/CS/HandBrake.Interop/Interop/HandBrakeUnitConversionHelpers.cs
index fd9da07a0..db2ea9990 100644
--- a/win/CS/HandBrake.Interop/Interop/HandBrakeUnitConversionHelpers.cs
+++ b/win/CS/HandBrake.Interop/Interop/HandBrakeUnitConversionHelpers.cs
@@ -14,15 +14,20 @@ namespace HandBrake.Interop.Interop
using System.Globalization;
using HandBrake.Interop.Interop.HbLib;
+ using HandBrake.Interop.Interop.HbLib.Wrappers.Interfaces;
using HandBrake.Interop.Interop.Helpers;
using HandBrake.Interop.Interop.Model;
using HandBrake.Interop.Interop.Model.Encoding;
+ using HandBrake.Interop.Interop.Providers;
+ using HandBrake.Interop.Interop.Providers.Interfaces;
/// <summary>
/// Converters for various encoding values.
/// </summary>
public static class HandBrakeUnitConversionHelpers
{
+ private static IHbFunctions hbFunctions;
+
/// <summary>
/// Video Frame Rates
/// </summary>
@@ -33,6 +38,9 @@ namespace HandBrake.Interop.Interop
/// </summary>
static HandBrakeUnitConversionHelpers()
{
+ IHbFunctionsProvider hbFunctionsProvider = new HbFunctionsProvider();
+ hbFunctions = hbFunctionsProvider.GetHbFunctionsWrapper();
+
if (!HandBrakeUtils.IsInitialised())
{
throw new Exception("Please Initialise with HandBrakeUtils.EnsureGlobalInit before using!");
@@ -95,8 +103,8 @@ namespace HandBrake.Interop.Interop
var result = new HBAudioEncoder(
encoder.muxers,
HandBrakeEncoderHelpers.GetAudioCompressionLimits(encoder.codec),
- HBFunctions.hb_audio_compression_get_default((uint)encoder.codec),
- HBFunctions.hb_audio_quality_get_default((uint)encoder.codec),
+ hbFunctions.hb_audio_compression_get_default((uint)encoder.codec),
+ hbFunctions.hb_audio_quality_get_default((uint)encoder.codec),
encoder.name,
encoder.codec,
HandBrakeEncoderHelpers.GetAudioQualityLimits(encoder.codec),
diff --git a/win/CS/HandBrake.Interop/Interop/HandBrakeUtils.cs b/win/CS/HandBrake.Interop/Interop/HandBrakeUtils.cs
index 6752cdb7a..2b97ce1b2 100644
--- a/win/CS/HandBrake.Interop/Interop/HandBrakeUtils.cs
+++ b/win/CS/HandBrake.Interop/Interop/HandBrakeUtils.cs
@@ -18,8 +18,11 @@ namespace HandBrake.Interop.Interop
using HandBrake.Interop.Interop.EventArgs;
using HandBrake.Interop.Interop.HbLib;
+ using HandBrake.Interop.Interop.HbLib.Wrappers.Interfaces;
using HandBrake.Interop.Interop.Json.Anamorphic;
using HandBrake.Interop.Interop.Json.Shared;
+ using HandBrake.Interop.Interop.Providers;
+ using HandBrake.Interop.Interop.Providers.Interfaces;
using Newtonsoft.Json;
@@ -56,6 +59,14 @@ namespace HandBrake.Interop.Interop
/// </summary>
public static event EventHandler<MessageLoggedEventArgs> ErrorLogged;
+ private static IHbFunctions hbFunctions;
+
+ static HandBrakeUtils()
+ {
+ IHbFunctionsProvider hbFunctionsProvider = new HbFunctionsProvider();
+ hbFunctions = hbFunctionsProvider.GetHbFunctionsWrapper();
+ }
+
/// <summary>
/// Ensures the HB global initialize method has been called.
/// </summary>
@@ -68,7 +79,7 @@ namespace HandBrake.Interop.Interop
if (initNoHardwareMode)
{
initNoHardware = true;
- if (HBFunctions.hb_global_init_no_hardware() == -1)
+ if (hbFunctions.hb_global_init_no_hardware() == -1)
{
throw new InvalidOperationException("HB global init failed.");
}
@@ -88,7 +99,7 @@ namespace HandBrake.Interop.Interop
// Try without Hardware support. Bad drivers can sometimes cause issues.
if (!initSuccess)
{
- if (HBFunctions.hb_global_init_no_hardware() == -1)
+ if (hbFunctions.hb_global_init_no_hardware() == -1)
{
throw new InvalidOperationException("HB global init failed.");
}
@@ -106,7 +117,7 @@ namespace HandBrake.Interop.Interop
/// </param>
public static void SetDvdNav(bool enableDvdNav)
{
- HBFunctions.hb_dvd_set_dvdnav(enableDvdNav ? 1 : 0);
+ hbFunctions.hb_dvd_set_dvdnav(enableDvdNav ? 1 : 0);
}
/// <summary>
@@ -114,7 +125,7 @@ namespace HandBrake.Interop.Interop
/// </summary>
public static void DisposeGlobal()
{
- HBFunctions.hb_global_close();
+ hbFunctions.hb_global_close();
}
/// <summary>
@@ -128,8 +139,8 @@ namespace HandBrake.Interop.Interop
// Keep the callback as a member to prevent it from being garbage collected.
loggingCallback = LoggingHandler;
errorCallback = ErrorHandler;
- HBFunctions.hb_register_logger(loggingCallback);
- HBFunctions.hb_register_error_handler(errorCallback);
+ hbFunctions.hb_register_logger(loggingCallback);
+ hbFunctions.hb_register_error_handler(errorCallback);
}
}
@@ -181,7 +192,7 @@ namespace HandBrake.Interop.Interop
public static string SanitizeX264OptName(string name)
{
IntPtr namePtr = Marshal.StringToHGlobalAnsi(name);
- string sanitizedName = Marshal.PtrToStringAnsi(HBFunctions.hb_x264_encopt_name(namePtr));
+ string sanitizedName = Marshal.PtrToStringAnsi(hbFunctions.hb_x264_encopt_name(namePtr));
Marshal.FreeHGlobal(namePtr);
return sanitizedName;
}
@@ -215,7 +226,7 @@ namespace HandBrake.Interop.Interop
/// </returns>
public static bool IsH264LevelValid(string level, int width, int height, int fpsNumerator, int fpsDenominator, bool interlaced, bool fakeInterlaced)
{
- return HBFunctions.hb_check_h264_level(
+ return hbFunctions.hb_check_h264_level(
level,
width,
height,
@@ -271,7 +282,7 @@ namespace HandBrake.Interop.Interop
throw new ArgumentException("height must be positive.");
}
- IntPtr ptr = HBFunctions.hb_x264_param_unparse(
+ IntPtr ptr = hbFunctions.hb_x264_param_unparse(
8,
preset,
string.Join(",", tunes),
@@ -294,7 +305,7 @@ namespace HandBrake.Interop.Interop
public static Geometry GetAnamorphicSize(AnamorphicGeometry anamorphicGeometry)
{
string encode = JsonConvert.SerializeObject(anamorphicGeometry, Formatting.Indented, new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore });
- IntPtr json = HBFunctions.hb_set_anamorphic_size_json(Marshal.StringToHGlobalAnsi(encode));
+ IntPtr json = hbFunctions.hb_set_anamorphic_size_json(Marshal.StringToHGlobalAnsi(encode));
string result = Marshal.PtrToStringAnsi(json);
return JsonConvert.DeserializeObject<Geometry>(result);
}
@@ -359,7 +370,7 @@ namespace HandBrake.Interop.Interop
{
try
{
- if (HBFunctions.hb_global_init() == -1)
+ if (hbFunctions.hb_global_init() == -1)
{
throw new InvalidOperationException("HB global init failed.");
}
diff --git a/win/CS/HandBrake.Interop/Interop/HbLib/HbFunctions.cs b/win/CS/HandBrake.Interop/Interop/HbLib/HbFunctions.cs
index dabf3b75d..26dfd3d8d 100644
--- a/win/CS/HandBrake.Interop/Interop/HbLib/HbFunctions.cs
+++ b/win/CS/HandBrake.Interop/Interop/HbLib/HbFunctions.cs
@@ -16,7 +16,7 @@ namespace HandBrake.Interop.Interop.HbLib
/// <summary>
/// Contains p-invoke function declarations to hblib.
/// </summary>
- public static class HBFunctions
+ internal static class HBFunctions
{
[DllImport("hb", EntryPoint = "hb_register_logger", CallingConvention = CallingConvention.Cdecl)]
public static extern void hb_register_logger(LoggingCallback callback);
@@ -30,140 +30,81 @@ namespace HandBrake.Interop.Interop.HbLib
[DllImport("hb", EntryPoint = "hb_global_init_no_hardware", CallingConvention = CallingConvention.Cdecl)]
public static extern int hb_global_init_no_hardware();
- /// Return Type: hb_handle_t*
- ///verbose: int
- ///update_check: int
[DllImport("hb", EntryPoint = "hb_init", CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr hb_init(int verbose, int update_check);
-
- /// Return Type: hb_handle_t*
- ///verbose: int
- ///update_check: int
[DllImport("hb", EntryPoint = "hb_init_dl", CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr hb_init_dl(int verbose, int update_check);
-
- /// Return Type: char*
- ///param0: hb_handle_t*
[DllImport("hb", EntryPoint = "hb_get_version", CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr hb_get_version(IntPtr hbHandle);
-
- /// Return Type: int
- ///param0: hb_handle_t*
[DllImport("hb", EntryPoint = "hb_get_build", CallingConvention = CallingConvention.Cdecl)]
public static extern int hb_get_build(IntPtr hbHandle);
-
- /// Return Type: char*
- ///path: char*
[DllImport("hb", EntryPoint = "hb_dvd_name", CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr hb_dvd_name(IntPtr path);
-
- /// Return Type: void
- ///enable: int
[DllImport("hb", EntryPoint = "hb_dvd_set_dvdnav", CallingConvention = CallingConvention.Cdecl)]
public static extern void hb_dvd_set_dvdnav(int enable);
- /// Return Type: void
- ///param0: hb_handle_t*
- ///path: char*
- ///title_index: int
- ///preview_count: int
- ///store_previews: int
[DllImport("hb", EntryPoint = "hb_scan", CallingConvention = CallingConvention.Cdecl)]
public static extern void hb_scan(IntPtr hbHandle, IntPtr path, int title_index, int preview_count, int store_previews, ulong min_duration);
[DllImport("hb", EntryPoint = "hb_scan_stop", CallingConvention = CallingConvention.Cdecl)]
public static extern void hb_scan_stop(IntPtr hbHandle);
- /// Return Type: hb_list_t*
- ///param0: hb_handle_t*
[DllImport("hb", EntryPoint = "hb_get_titles", CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr hb_get_titles(IntPtr hbHandle);
[DllImport("hb", EntryPoint = "hb_set_anamorphic_size2", CallingConvention = CallingConvention.Cdecl)]
public static extern void hb_set_anamorphic_size2(ref hb_geometry_s sourceGeometry, ref hb_geometry_settings_s uiGeometry, ref hb_geometry_s result);
-
- /// Return Type: int
- ///param0: hb_handle_t*
[DllImport("hb", EntryPoint = "hb_count", CallingConvention = CallingConvention.Cdecl)]
public static extern int hb_count(IntPtr hbHandle);
-
- /// Return Type: hb_job_t*
- ///param0: hb_handle_t*
- ///param1: int
[DllImport("hb", EntryPoint = "hb_job", CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr hb_job(IntPtr hbHandle, int jobIndex);
- /// Return Type: void
- ///param0: hb_handle_t*
- ///param1: hb_job_t*
[DllImport("hb", EntryPoint = "hb_rem", CallingConvention = CallingConvention.Cdecl)]
public static extern void hb_rem(IntPtr hbHandle, IntPtr job);
-
- /// Return Type: void
- ///param0: hb_handle_t*
[DllImport("hb", EntryPoint = "hb_start", CallingConvention = CallingConvention.Cdecl)]
public static extern void hb_start(IntPtr hbHandle);
-
- /// Return Type: void
- ///param0: hb_handle_t*
[DllImport("hb", EntryPoint = "hb_pause", CallingConvention = CallingConvention.Cdecl)]
public static extern void hb_pause(IntPtr hbHandle);
-
- /// Return Type: void
- ///param0: hb_handle_t*
[DllImport("hb", EntryPoint = "hb_resume", CallingConvention = CallingConvention.Cdecl)]
public static extern void hb_resume(IntPtr hbHandle);
-
- /// Return Type: void
- ///param0: hb_handle_t*
[DllImport("hb", EntryPoint = "hb_stop", CallingConvention = CallingConvention.Cdecl)]
public static extern void hb_stop(IntPtr hbHandle);
-
- /// Return Type: void
- ///param0: hb_handle_t**
[DllImport("hb", EntryPoint = "hb_close", CallingConvention = CallingConvention.Cdecl)]
public static extern void hb_close(IntPtr hbHandle);
[DllImport("hb", EntryPoint = "hb_global_close", CallingConvention = CallingConvention.Cdecl)]
public static extern void hb_global_close();
- //hb_list_t * hb_list_init();
[DllImport("hb", EntryPoint = "hb_list_init", CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr hb_list_init();
- //int hb_list_count( const hb_list_t * );
[DllImport("hb", EntryPoint = "hb_list_count", CallingConvention = CallingConvention.Cdecl)]
public static extern int hb_list_count(IntPtr listPtr);
- //void hb_list_add( hb_list_t *, void * );
[DllImport("hb", EntryPoint = "hb_list_add", CallingConvention = CallingConvention.Cdecl)]
public static extern void hb_list_add(IntPtr listPtr, IntPtr item);
- //void hb_list_insert( hb_list_t * l, int pos, void * p );
[DllImport("hb", EntryPoint = "hb_list_insert", CallingConvention = CallingConvention.Cdecl)]
public static extern void hb_list_insert(IntPtr listPtr, int pos, IntPtr item);
- //void hb_list_rem( hb_list_t *, void * );
[DllImport("hb", EntryPoint = "hb_list_rem", CallingConvention = CallingConvention.Cdecl)]
public static extern void hb_list_rem(IntPtr listPtr, IntPtr item);
- //void * hb_list_item( const hb_list_t *, int );
[DllImport("hb", EntryPoint = "hb_list_item", CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr hb_list_item(IntPtr listPtr, int itemIndex);
- //void hb_list_close( hb_list_t ** );
[DllImport("hb", EntryPoint = "hb_list_close", CallingConvention = CallingConvention.Cdecl)]
public static extern void hb_list_close(IntPtr listPtrPtr);
@@ -176,29 +117,17 @@ namespace HandBrake.Interop.Interop.HbLib
[DllImport("hb", EntryPoint = "hb_subtitle_can_pass", CallingConvention = CallingConvention.Cdecl)]
public static extern int hb_subtitle_can_pass(int source, int mux);
-
- // int hb_video_framerate_get_from_name(const char *name)
[DllImport("hb", EntryPoint = "hb_video_framerate_get_from_name", CallingConvention = CallingConvention.Cdecl)]
public static extern int hb_video_framerate_get_from_name(IntPtr name);
-//const char* hb_video_framerate_get_name(int framerate);
-//const char* hb_video_framerate_sanitize_name(const char *name);
-
- // returns hb_rate_s
[DllImport("hb", EntryPoint = "hb_video_framerate_get_next", CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr hb_video_framerate_get_next(IntPtr last);
-
-//int hb_audio_samplerate_get_best(uint32_t codec, int samplerate, int *sr_shift);
-//int hb_audio_samplerate_get_from_name(const char *name);
-//const char* hb_audio_samplerate_get_name(int samplerate);
-
- // returns hb_rate_s
[DllImport("hb", EntryPoint = "hb_audio_samplerate_get_next", CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr hb_audio_samplerate_get_next(IntPtr last);
[DllImport("hb", EntryPoint = "hb_audio_samplerate_find_closest", CallingConvention = CallingConvention.Cdecl)]
- public static extern int hb_audio_samplerate_find_closest(int samplerate, uint codec);
+ public static extern int hb_audio_samplerate_find_closest(int samplerate, uint codec);
[DllImport("hb", EntryPoint = "hb_audio_bitrate_get_best", CallingConvention = CallingConvention.Cdecl)]
public static extern int hb_audio_bitrate_get_best(uint codec, int bitrate, int samplerate, int mixdown);
@@ -221,29 +150,15 @@ namespace HandBrake.Interop.Interop.HbLib
[DllImport("hb", EntryPoint = "hb_audio_quality_get_limits", CallingConvention = CallingConvention.Cdecl)]
public static extern void hb_audio_quality_get_limits(uint codec, ref float low, ref float high, ref float granularity, ref int direction);
-//float hb_audio_quality_get_best(uint32_t codec, float quality);
-
[DllImport("hb", EntryPoint = "hb_audio_quality_get_default", CallingConvention = CallingConvention.Cdecl)]
public static extern float hb_audio_quality_get_default(uint codec);
-
[DllImport("hb", EntryPoint = "hb_audio_compression_get_limits", CallingConvention = CallingConvention.Cdecl)]
public static extern void hb_audio_compression_get_limits(uint codec, ref float low, ref float high, ref float granularity, ref int direction);
-//float hb_audio_compression_get_best(uint32_t codec, float compression);
-
[DllImport("hb", EntryPoint = "hb_audio_compression_get_default", CallingConvention = CallingConvention.Cdecl)]
public static extern float hb_audio_compression_get_default(uint codec);
-
-//int hb_audio_dither_get_default();
-//int hb_audio_dither_get_default_method(); // default method, if enabled && supported
-//int hb_audio_dither_is_supported(uint32_t codec);
-//int hb_audio_dither_get_from_name(const char *name);
-//const char* hb_audio_dither_get_description(int method);
-//const hb_dither_t* hb_audio_dither_get_next(const hb_dither_t *last);
-
- // hb_audio_can_apply_drc2(hb_handle_t *h, int title_idx, int audio_idx, int encoder)
[DllImport("hb", EntryPoint = "hb_audio_can_apply_drc2", CallingConvention = CallingConvention.Cdecl)]
public static extern int hb_audio_can_apply_drc2(IntPtr handle, int title_index, int audio_index, int encoder);
@@ -256,62 +171,21 @@ namespace HandBrake.Interop.Interop.HbLib
[DllImport("hb", EntryPoint = "hb_mixdown_has_remix_support", CallingConvention = CallingConvention.Cdecl)]
public static extern int hb_mixdown_has_remix_support(int mixdown, ulong layout);
-//int hb_mixdown_get_discrete_channel_count(int mixdown);
-//int hb_mixdown_get_low_freq_channel_count(int mixdown);
-
[DllImport("hb", EntryPoint = "hb_mixdown_get_best", CallingConvention = CallingConvention.Cdecl)]
public static extern int hb_mixdown_get_best(uint codec, ulong layout, int mixdown);
[DllImport("hb", EntryPoint = "hb_mixdown_get_default", CallingConvention = CallingConvention.Cdecl)]
public static extern int hb_mixdown_get_default(uint codec, ulong layout);
-//int hb_mixdown_get_from_name(const char *name);
-//const char* hb_mixdown_get_name(int mixdown);
-//const char* hb_mixdown_get_short_name(int mixdown);
-//const char* hb_mixdown_sanitize_name(const char *name);
-
[DllImport("hb", EntryPoint = "hb_mixdown_get_next", CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr hb_mixdown_get_next(IntPtr last);
-//int hb_video_encoder_get_default(int muxer);
-//int hb_video_encoder_get_from_name(const char *name);
-//const char* hb_video_encoder_get_name(int encoder);
-//const char* hb_video_encoder_get_short_name(int encoder);
-//const char* hb_video_encoder_get_long_name(int encoder);
-//const char* hb_video_encoder_sanitize_name(const char *name);
-
[DllImport("hb", EntryPoint = "hb_video_encoder_get_next", CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr hb_video_encoder_get_next(IntPtr last);
-/*
- * hb_audio_encoder_get_fallback_for_passthru() will sanitize a passthru codec
- * to the matching audio encoder (if any is available).
- *
- * hb_audio_encoder_get_from_name(), hb_audio_encoder_sanitize_name() will
- * sanitize legacy encoder names, but won't convert passthru to an encoder.
- */
-//int hb_audio_encoder_get_fallback_for_passthru(int passthru);
-//int hb_audio_encoder_get_default(int muxer);
-//int hb_audio_encoder_get_from_name(const char *name);
-//const char* hb_audio_encoder_get_name(int encoder);
-//const char* hb_audio_encoder_get_short_name(int encoder);
-//const char* hb_audio_encoder_get_long_name(int encoder);
-//const char* hb_audio_encoder_sanitize_name(const char *name);
-
[DllImport("hb", EntryPoint = "hb_audio_encoder_get_next", CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr hb_audio_encoder_get_next(IntPtr last);
-//int hb_container_get_from_name(const char *name);
-//int hb_container_get_from_extension(const char *extension); // not really a container name
-//const char* hb_container_get_name(int format);
-//const char* hb_container_get_short_name(int format);
-//const char* hb_container_get_long_name(int format);
-//const char* hb_container_get_default_extension(int format);
-//const char* hb_container_sanitize_name(const char *name);
-
- [DllImport("hb", EntryPoint = "hb_container_get_from_name", CallingConvention = CallingConvention.Cdecl)]
- public static extern int hb_container_get_from_name([In] [MarshalAs(UnmanagedType.LPStr)] string name);
-
[DllImport("hb", EntryPoint = "hb_container_get_next", CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr hb_container_get_next(IntPtr last);
@@ -327,54 +201,15 @@ namespace HandBrake.Interop.Interop.HbLib
[DllImport("hb", EntryPoint = "hb_video_encoder_get_levels", CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr hb_video_encoder_get_levels(int encoder);
-
[DllImport("hb", EntryPoint = "lang_get_next", CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr lang_get_next(IntPtr last);
[DllImport("hb", EntryPoint = "lang_for_code2", CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr lang_for_code2([In] [MarshalAs(UnmanagedType.LPStr)] string code2);
-
- ///hb_title_set_t * hb_get_title_set( hb_handle_t * );
- [DllImport("hb", EntryPoint = "hb_get_title_set", CallingConvention = CallingConvention.Cdecl)]
- public static extern IntPtr hb_get_title_set(IntPtr hbHandle);
-
- ///hb_job_t * hb_job_init_by_index( hb_handle_t *h, int title_index );
- [DllImport("hb", EntryPoint = "hb_job_init_by_index", CallingConvention = CallingConvention.Cdecl)]
- public static extern IntPtr hb_job_init_by_index(IntPtr hbHandle, int title_index);
-
- ///void hb_job_close( hb_job_t ** job );
[DllImport("hb", EntryPoint = "hb_job_close", CallingConvention = CallingConvention.Cdecl)]
public static extern void hb_job_close(IntPtr job);
- ///void hb_chapter_set_title(hb_chapter_t *chapter, const char *title);
- [DllImport("hb", EntryPoint = "hb_chapter_set_title", CallingConvention = CallingConvention.Cdecl)]
- public static extern void hb_chapter_set_title(IntPtr chapter, [In] [MarshalAs(UnmanagedType.LPStr)] string title);
-
- ///void hb_chapter_set_title(hb_chapter_t *chapter, const char *title);
- [DllImport("hb", EntryPoint = "hb_chapter_set_title", CallingConvention = CallingConvention.Cdecl)]
- public static extern void hb_chapter_set_title__ptr(IntPtr chapter, IntPtr title);
-
- /// hb_filter_object_t * hb_filter_init( int filter_id );
- [DllImport("hb", EntryPoint = "hb_filter_init", CallingConvention = CallingConvention.Cdecl)]
- public static extern IntPtr hb_filter_init(int filter_id);
-
- [DllImport("hb", 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 custom);
-
- /// char* hb_filter_get_presets_json(int filter_id);
- [DllImport("hb", 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", EntryPoint = "hb_filter_get_tunes_json", CallingConvention = CallingConvention.Cdecl)]
- public static extern IntPtr hb_filter_get_tunes_json(int filter_id);
-
- // char ** hb_filter_get_keys(int filter_id);
[DllImport("hb", EntryPoint = "hb_filter_get_keys", CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr hb_filter_get_keys(int filter_id);
@@ -397,9 +232,6 @@ namespace HandBrake.Interop.Interop.HbLib
[DllImport("hb", EntryPoint = "hb_qsv_available", CallingConvention = CallingConvention.Cdecl)]
public static extern int hb_qsv_available();
-
- [DllImport("hb", EntryPoint = "hb_qsv_info_init", CallingConvention = CallingConvention.Cdecl)]
- public static extern int hb_qsv_info_init();
[DllImport("hb", EntryPoint = "hb_vce_h264_available", CallingConvention = CallingConvention.Cdecl)]
public static extern int hb_vce_h264_available();
@@ -413,57 +245,58 @@ namespace HandBrake.Interop.Interop.HbLib
[DllImport("hb", EntryPoint = "hb_nvenc_h265_available", CallingConvention = CallingConvention.Cdecl)]
public static extern int hb_nvenc_h265_available();
- // hb_image_t* hb_get_preview2(hb_handle_t* h, int title_idx, int picture, hb_geometry_settings_t* geo, int deinterlace);
[DllImport("hb", EntryPoint = "hb_get_preview2", CallingConvention = CallingConvention.Cdecl)]
- public static extern IntPtr hb_get_preview2(IntPtr hbHandle, int title_idx, int preview_idx, ref hb_geometry_settings_s geo, int deinterlace);
+ public static extern IntPtr hb_get_preview2(IntPtr hbHandle, int title_idx, int preview_idx, ref hb_geometry_settings_s geo, int deinterlace);
- // void hb_image_close(hb_image_t **_image);
[DllImport("hb", EntryPoint = "hb_image_close", CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr hb_image_close(IntPtr image);
/* JSON API */
- // char * hb_get_title_set_json(hb_handle_t * h);
[DllImport("hb", EntryPoint = "hb_get_title_set_json", CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr hb_get_title_set_json(IntPtr hbHandle);
- // char * hb_job_init_json(hb_handle_t *h, int title_index);
[DllImport("hb", EntryPoint = "hb_job_init_json", CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr hb_job_init_json(IntPtr hbHandle, int title_index);
- // hb_job_t * hb_json_to_job(hb_handle_t * h, const char * json_job);
[DllImport("hb", EntryPoint = "hb_json_to_job", CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr hb_json_to_job(IntPtr hbHandle, IntPtr json_job);
- // int hb_add_json( hb_handle_t *, const char * )
[DllImport("hb", EntryPoint = "hb_add_json", CallingConvention = CallingConvention.Cdecl)]
public static extern int hb_add_json(IntPtr hbHandle, IntPtr json_job);
- //char * hb_set_anamorphic_size_json(const char * json_param);
[DllImport("hb", EntryPoint = "hb_set_anamorphic_size_json", CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr hb_set_anamorphic_size_json(IntPtr json_param);
- // char * hb_get_state_json(hb_handle_t * h);
[DllImport("hb", EntryPoint = "hb_get_state_json", CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr hb_get_state_json(IntPtr hbHandle);
- // char* hb_get_preview_params_json(int title_idx, int preview_idx, int deinterlace, hb_geometry_settings_t *settings)
[DllImport("hb", EntryPoint = "hb_get_preview_params_json", CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr hb_get_preview_params_json(int title_idx, int preview_idx, int deinterlace, ref hb_geometry_settings_s settings);
-
- //void hb_presets_builtin_init(void);
+
[DllImport("hb", EntryPoint = "hb_presets_builtin_init", CallingConvention = CallingConvention.Cdecl)]
public static extern void hb_presets_builtin_init();
- // char * hb_presets_builtin_get_json(void); // Get list of HandBrake builtin presets as json string
[DllImport("hb", EntryPoint = "hb_presets_builtin_get_json", CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr hb_presets_builtin_get_json();
- // char * hb_presets_read_file_json(const char *filename);
[DllImport("hb", EntryPoint = "hb_presets_read_file_json", CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr hb_presets_read_file_json(IntPtr filename);
[DllImport("hb", EntryPoint = "hb_presets_current_version", CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr hb_presets_current_version(IntPtr major, IntPtr minor, IntPtr micro);
+
+ [DllImport("hb", 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 custom);
+
+ [DllImport("hb", EntryPoint = "hb_filter_get_presets_json", CallingConvention = CallingConvention.Cdecl)]
+ public static extern IntPtr hb_filter_get_presets_json(int filter_id);
+
+ [DllImport("hb", EntryPoint = "hb_filter_get_tunes_json", CallingConvention = CallingConvention.Cdecl)]
+ public static extern IntPtr hb_filter_get_tunes_json(int filter_id);
}
}
diff --git a/win/CS/HandBrake.Interop/Interop/HbLib/Wrappers/HbFunctionsDirect.cs b/win/CS/HandBrake.Interop/Interop/HbLib/Wrappers/HbFunctionsDirect.cs
new file mode 100644
index 000000000..3bb0530a0
--- /dev/null
+++ b/win/CS/HandBrake.Interop/Interop/HbLib/Wrappers/HbFunctionsDirect.cs
@@ -0,0 +1,501 @@
+// --------------------------------------------------------------------------------------------------------------------
+// <copyright file="IHbFunctions.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>
+// An interface to access the native libhb functions without using static methods.
+// </summary>
+// <auto-generated> Disable Stylecop Warnings for this file </auto-generated>
+// --------------------------------------------------------------------------------------------------------------------
+
+namespace HandBrake.Interop.Interop.HbLib.Wrappers
+{
+ using System;
+ using System.Runtime.InteropServices;
+
+ using HandBrake.Interop.Interop.HbLib.Wrappers.Interfaces;
+
+ public class HbFunctionsDirect : IHbFunctions
+ {
+ public void hb_register_logger(LoggingCallback callback)
+ {
+ HBFunctions.hb_register_logger(callback);
+ }
+
+ public void hb_register_error_handler(LoggingCallback callback)
+ {
+ HBFunctions.hb_register_error_handler(callback);
+ }
+
+ public int hb_global_init()
+ {
+ return HBFunctions.hb_global_init();
+ }
+
+ public int hb_global_init_no_hardware()
+ {
+ return HBFunctions.hb_global_init_no_hardware();
+ }
+
+ public IntPtr hb_init(int verbose, int update_check)
+ {
+ return HBFunctions.hb_init(verbose, update_check);
+ }
+
+ public IntPtr hb_init_dl(int verbose, int update_check)
+ {
+ return HBFunctions.hb_init_dl(verbose, update_check);
+ }
+
+ public IntPtr hb_get_version(IntPtr hbHandle)
+ {
+ return HBFunctions.hb_get_version(hbHandle);
+ }
+
+ public int hb_get_build(IntPtr hbHandle)
+ {
+ return HBFunctions.hb_get_build(hbHandle);
+ }
+
+ public IntPtr hb_dvd_name(IntPtr path)
+ {
+ return HBFunctions.hb_dvd_name(path);
+ }
+
+ public void hb_dvd_set_dvdnav(int enable)
+ {
+ HBFunctions.hb_dvd_set_dvdnav(enable);
+ }
+
+ public void hb_scan(IntPtr hbHandle, IntPtr path, int title_index, int preview_count, int store_previews, ulong min_duration)
+ {
+ HBFunctions.hb_scan(hbHandle, path, title_index, preview_count, store_previews, min_duration);
+ }
+
+ public void hb_scan_stop(IntPtr hbHandle)
+ {
+ HBFunctions.hb_scan_stop(hbHandle);
+ }
+
+ public IntPtr hb_get_titles(IntPtr hbHandle)
+ {
+ return HBFunctions.hb_get_titles(hbHandle);
+ }
+
+ public void hb_set_anamorphic_size2(ref hb_geometry_s sourceGeometry, ref hb_geometry_settings_s uiGeometry, ref hb_geometry_s result)
+ {
+ HBFunctions.hb_set_anamorphic_size2(ref sourceGeometry, ref uiGeometry, ref result);
+ }
+
+ public int hb_count(IntPtr hbHandle)
+ {
+ return HBFunctions.hb_count(hbHandle);
+ }
+
+ public IntPtr hb_job(IntPtr hbHandle, int jobIndex)
+ {
+ return HBFunctions.hb_job(hbHandle, jobIndex);
+ }
+
+ public void hb_rem(IntPtr hbHandle, IntPtr job)
+ {
+ HBFunctions.hb_rem(hbHandle, job);
+ }
+
+ public void hb_start(IntPtr hbHandle)
+ {
+ HBFunctions.hb_start(hbHandle);
+ }
+
+ public void hb_pause(IntPtr hbHandle)
+ {
+ HBFunctions.hb_pause(hbHandle);
+ }
+
+ public void hb_resume(IntPtr hbHandle)
+ {
+ HBFunctions.hb_resume(hbHandle);
+ }
+
+ public void hb_stop(IntPtr hbHandle)
+ {
+ HBFunctions.hb_stop(hbHandle);
+ }
+
+ public void hb_close(IntPtr hbHandle)
+ {
+ HBFunctions.hb_close(hbHandle);
+ }
+
+ public void hb_global_close()
+ {
+ HBFunctions.hb_global_close();
+ }
+
+ public IntPtr hb_list_init()
+ {
+ return HBFunctions.hb_list_init();
+ }
+
+ public int hb_list_count(IntPtr listPtr)
+ {
+ return HBFunctions.hb_list_count(listPtr);
+ }
+
+ public void hb_list_add(IntPtr listPtr, IntPtr item)
+ {
+ HBFunctions.hb_list_add(listPtr, item);
+ }
+
+ public void hb_list_insert(IntPtr listPtr, int pos, IntPtr item)
+ {
+ HBFunctions.hb_list_insert(listPtr, pos, item);
+ }
+
+ public void hb_list_rem(IntPtr listPtr, IntPtr item)
+ {
+ HBFunctions.hb_list_rem(listPtr, item);
+ }
+
+ public IntPtr hb_list_item(IntPtr listPtr, int itemIndex)
+ {
+ return HBFunctions.hb_list_item(listPtr, itemIndex);
+ }
+
+ public void hb_list_close(IntPtr listPtrPtr)
+ {
+ HBFunctions.hb_list_close(listPtrPtr);
+ }
+
+ public int hb_subtitle_can_force(int source)
+ {
+ return HBFunctions.hb_subtitle_can_force(source);
+ }
+
+ public int hb_subtitle_can_burn(int source)
+ {
+ return HBFunctions.hb_subtitle_can_burn(source);
+ }
+
+ public int hb_subtitle_can_pass(int source, int mux)
+ {
+ return HBFunctions.hb_subtitle_can_pass(source, mux);
+ }
+
+ public int hb_video_framerate_get_from_name(IntPtr name)
+ {
+ return HBFunctions.hb_video_framerate_get_from_name(name);
+ }
+
+ public IntPtr hb_video_framerate_get_next(IntPtr last)
+ {
+ return HBFunctions.hb_video_framerate_get_next(last);
+ }
+
+ public IntPtr hb_audio_samplerate_get_next(IntPtr last)
+ {
+ return HBFunctions.hb_audio_samplerate_get_next(last);
+ }
+
+ public int hb_audio_samplerate_find_closest(int samplerate, uint codec)
+ {
+ return HBFunctions.hb_audio_samplerate_find_closest(samplerate, codec);
+ }
+
+ public int hb_audio_bitrate_get_best(uint codec, int bitrate, int samplerate, int mixdown)
+ {
+ return HBFunctions.hb_audio_bitrate_get_best(codec, bitrate, samplerate, mixdown);
+ }
+
+ public int hb_audio_bitrate_get_default(uint codec, int samplerate, int mixdown)
+ {
+ return HBFunctions.hb_audio_bitrate_get_default(codec, samplerate, mixdown);
+ }
+
+ public int hb_audio_bitrate_get_limits(uint codec, int samplerate, int mixdown, ref int low, ref int high)
+ {
+ return HBFunctions.hb_audio_bitrate_get_limits(codec, samplerate, mixdown, ref low, ref high);
+ }
+
+ public IntPtr hb_audio_bitrate_get_next(IntPtr last)
+ {
+ return HBFunctions.hb_audio_bitrate_get_next(last);
+ }
+
+ public void hb_video_quality_get_limits(uint codec, ref float low, ref float high, ref float granularity, ref int direction)
+ {
+ HBFunctions.hb_video_quality_get_limits(codec, ref low, ref high, ref granularity, ref direction);
+ }
+
+ public IntPtr hb_video_quality_get_name(uint codec)
+ {
+ return HBFunctions.hb_video_quality_get_name(codec);
+ }
+
+ public void hb_audio_quality_get_limits(uint codec, ref float low, ref float high, ref float granularity, ref int direction)
+ {
+ HBFunctions.hb_audio_quality_get_limits(codec, ref low, ref high, ref granularity, ref direction);
+ }
+
+ public float hb_audio_quality_get_default(uint codec)
+ {
+ return HBFunctions.hb_audio_quality_get_default(codec);
+ }
+
+ public void hb_audio_compression_get_limits(uint codec, ref float low, ref float high, ref float granularity, ref int direction)
+ {
+ HBFunctions.hb_audio_compression_get_limits(codec, ref low, ref high, ref granularity, ref direction);
+ }
+
+ public float hb_audio_compression_get_default(uint codec)
+ {
+ return HBFunctions.hb_audio_compression_get_default(codec);
+ }
+
+ public int hb_audio_can_apply_drc2(IntPtr handle, int title_index, int audio_index, int encoder)
+ {
+ return HBFunctions.hb_audio_can_apply_drc2(handle, title_index, audio_index, encoder);
+ }
+
+ public int hb_mixdown_is_supported(int mixdown, uint codec, ulong layout)
+ {
+ return HBFunctions.hb_mixdown_is_supported(mixdown, codec, layout);
+ }
+
+ public int hb_mixdown_has_codec_support(int mixdown, uint codec)
+ {
+ return HBFunctions.hb_mixdown_has_codec_support(mixdown, codec);
+ }
+
+ public int hb_mixdown_has_remix_support(int mixdown, ulong layout)
+ {
+ return HBFunctions.hb_mixdown_has_remix_support(mixdown, layout);
+ }
+
+ public int hb_mixdown_get_best(uint codec, ulong layout, int mixdown)
+ {
+ return HBFunctions.hb_mixdown_get_best(codec, layout, mixdown);
+ }
+
+ public int hb_mixdown_get_default(uint codec, ulong layout)
+ {
+ return HBFunctions.hb_mixdown_get_default(codec, layout);
+ }
+
+ public IntPtr hb_mixdown_get_next(IntPtr last)
+ {
+ return HBFunctions.hb_mixdown_get_next(last);
+ }
+
+ public IntPtr hb_video_encoder_get_next(IntPtr last)
+ {
+ return HBFunctions.hb_video_encoder_get_next(last);
+ }
+
+ public IntPtr hb_audio_encoder_get_next(IntPtr last)
+ {
+ return HBFunctions.hb_audio_encoder_get_next(last);
+ }
+
+ public IntPtr hb_container_get_next(IntPtr last)
+ {
+ return HBFunctions.hb_container_get_next(last);
+ }
+
+ public IntPtr hb_video_encoder_get_presets(int encoder)
+ {
+ return HBFunctions.hb_video_encoder_get_presets(encoder);
+ }
+
+ public IntPtr hb_video_encoder_get_tunes(int encoder)
+ {
+ return HBFunctions.hb_video_encoder_get_tunes(encoder);
+ }
+
+ public IntPtr hb_video_encoder_get_profiles(int encoder)
+ {
+ return HBFunctions.hb_video_encoder_get_profiles(encoder);
+ }
+
+ public IntPtr hb_video_encoder_get_levels(int encoder)
+ {
+ return HBFunctions.hb_video_encoder_get_levels(encoder);
+ }
+
+ public IntPtr lang_get_next(IntPtr last)
+ {
+ return HBFunctions.lang_get_next(last);
+ }
+
+ public IntPtr lang_for_code2([In] [MarshalAs(UnmanagedType.LPStr)] string code2)
+ {
+ return HBFunctions.lang_for_code2(code2);
+ }
+
+ public void hb_job_close(IntPtr job)
+ {
+ HBFunctions.hb_job_close(job);
+ }
+
+ public IntPtr hb_filter_get_keys(int filter_id)
+ {
+ return HBFunctions.hb_filter_get_keys(filter_id);
+ }
+
+ public IntPtr hb_x264_encopt_name(IntPtr name)
+ {
+ return HBFunctions.hb_x264_encopt_name(name);
+ }
+
+ public int hb_check_h264_level(
+ [In] [MarshalAs(UnmanagedType.LPStr)] string level,
+ int width,
+ int height,
+ int fps_num,
+ int fps_den,
+ int interlaced,
+ int fake_interlaced)
+ {
+ return HBFunctions.hb_check_h264_level(
+ level,
+ width,
+ height,
+ fps_num,
+ fps_den,
+ interlaced,
+ fake_interlaced);
+ }
+
+ public IntPtr hb_x264_param_unparse(
+ int bit_depth,
+ [In] [MarshalAs(UnmanagedType.LPStr)] string x264_preset,
+ [In] [MarshalAs(UnmanagedType.LPStr)] string x264_tune,
+ [In] [MarshalAs(UnmanagedType.LPStr)] string x264_encopts,
+ [In] [MarshalAs(UnmanagedType.LPStr)] string x264_profile,
+ [In] [MarshalAs(UnmanagedType.LPStr)] string h264_level,
+ int width,
+ int height)
+ {
+ return HBFunctions.hb_x264_param_unparse(
+ bit_depth,
+ x264_preset,
+ x264_tune,
+ x264_encopts,
+ x264_profile,
+ h264_level,
+ width,
+ height);
+ }
+
+ public int hb_qsv_available()
+ {
+ return HBFunctions.hb_qsv_available();
+ }
+
+ public int hb_vce_h264_available()
+ {
+ return HBFunctions.hb_vce_h264_available();
+ }
+
+ public int hb_vce_h265_available()
+ {
+ return HBFunctions.hb_vce_h265_available();
+ }
+
+ public int hb_nvenc_h264_available()
+ {
+ return HBFunctions.hb_nvenc_h264_available();
+ }
+
+ public int hb_nvenc_h265_available()
+ {
+ return HBFunctions.hb_nvenc_h265_available();
+ }
+
+ public IntPtr hb_get_preview2(IntPtr hbHandle, int title_idx, int preview_idx, ref hb_geometry_settings_s geo, int deinterlace)
+ {
+ return HBFunctions.hb_get_preview2(hbHandle, title_idx, preview_idx, ref geo, deinterlace);
+ }
+
+ public IntPtr hb_image_close(IntPtr image)
+ {
+ return HBFunctions.hb_image_close(image);
+ }
+
+ /* JSON API */
+
+ public IntPtr hb_get_title_set_json(IntPtr hbHandle)
+ {
+ return HBFunctions.hb_get_title_set_json(hbHandle);
+ }
+
+ public IntPtr hb_job_init_json(IntPtr hbHandle, int title_index)
+ {
+ return HBFunctions.hb_job_init_json(hbHandle, title_index);
+ }
+
+ public IntPtr hb_json_to_job(IntPtr hbHandle, IntPtr json_job)
+ {
+ return HBFunctions.hb_json_to_job(hbHandle, json_job);
+ }
+
+ public int hb_add_json(IntPtr hbHandle, IntPtr json_job)
+ {
+ return HBFunctions.hb_add_json(hbHandle, json_job);
+ }
+
+ public IntPtr hb_set_anamorphic_size_json(IntPtr json_param)
+ {
+ return HBFunctions.hb_set_anamorphic_size_json(json_param);
+ }
+
+ public IntPtr hb_get_state_json(IntPtr hbHandle)
+ {
+ return HBFunctions.hb_get_state_json(hbHandle);
+ }
+
+ public IntPtr hb_get_preview_params_json(int title_idx, int preview_idx, int deinterlace, ref hb_geometry_settings_s settings)
+ {
+ return HBFunctions.hb_get_preview_params_json(title_idx, preview_idx, deinterlace, ref settings);
+ }
+
+ public void hb_presets_builtin_init()
+ {
+ HBFunctions.hb_presets_builtin_init();
+ }
+
+ public IntPtr hb_presets_builtin_get_json()
+ {
+ return HBFunctions.hb_presets_builtin_get_json();
+ }
+
+ public IntPtr hb_presets_read_file_json(IntPtr filename)
+ {
+ return HBFunctions.hb_presets_read_file_json(filename);
+ }
+
+ public IntPtr hb_presets_current_version(IntPtr major, IntPtr minor, IntPtr micro)
+ {
+ return HBFunctions.hb_presets_current_version(major, minor, micro);
+ }
+
+ public 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 custom)
+ {
+ return this.hb_generate_filter_settings_json(filter_id, preset, tune, custom);
+ }
+
+ public IntPtr hb_filter_get_presets_json(int filter_id)
+ {
+ return HBFunctions.hb_filter_get_presets_json(filter_id);
+ }
+
+ public IntPtr hb_filter_get_tunes_json(int filter_id)
+ {
+ return HBFunctions.hb_filter_get_tunes_json(filter_id);
+ }
+ }
+}
diff --git a/win/CS/HandBrake.Interop/Interop/HbLib/Wrappers/Interfaces/IHbFunctions.cs b/win/CS/HandBrake.Interop/Interop/HbLib/Wrappers/Interfaces/IHbFunctions.cs
new file mode 100644
index 000000000..b876c9f16
--- /dev/null
+++ b/win/CS/HandBrake.Interop/Interop/HbLib/Wrappers/Interfaces/IHbFunctions.cs
@@ -0,0 +1,215 @@
+// --------------------------------------------------------------------------------------------------------------------
+// <copyright file="IHbFunctions.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>
+// An interface to access the native libhb functions without using static methods.
+// </summary>
+// <auto-generated> Disable Stylecop Warnings for this file </auto-generated>
+// --------------------------------------------------------------------------------------------------------------------
+
+namespace HandBrake.Interop.Interop.HbLib.Wrappers.Interfaces
+{
+ using System;
+ using System.Runtime.InteropServices;
+
+ public interface IHbFunctions
+ {
+ void hb_register_logger(LoggingCallback callback);
+
+ void hb_register_error_handler(LoggingCallback callback);
+
+ int hb_global_init();
+
+ int hb_global_init_no_hardware();
+
+ IntPtr hb_init(int verbose, int update_check);
+
+ IntPtr hb_init_dl(int verbose, int update_check);
+
+ IntPtr hb_get_version(IntPtr hbHandle);
+
+ int hb_get_build(IntPtr hbHandle);
+
+ IntPtr hb_dvd_name(IntPtr path);
+
+ void hb_dvd_set_dvdnav(int enable);
+
+ void hb_scan(IntPtr hbHandle, IntPtr path, int title_index, int preview_count, int store_previews, ulong min_duration);
+
+ void hb_scan_stop(IntPtr hbHandle);
+
+ IntPtr hb_get_titles(IntPtr hbHandle);
+
+ void hb_set_anamorphic_size2(ref hb_geometry_s sourceGeometry, ref hb_geometry_settings_s uiGeometry, ref hb_geometry_s result);
+
+ int hb_count(IntPtr hbHandle);
+
+ IntPtr hb_job(IntPtr hbHandle, int jobIndex);
+
+ void hb_rem(IntPtr hbHandle, IntPtr job);
+
+ void hb_start(IntPtr hbHandle);
+
+ void hb_pause(IntPtr hbHandle);
+
+ void hb_resume(IntPtr hbHandle);
+
+ void hb_stop(IntPtr hbHandle);
+
+ void hb_close(IntPtr hbHandle);
+
+ void hb_global_close();
+
+ IntPtr hb_list_init();
+
+ int hb_list_count(IntPtr listPtr);
+
+ void hb_list_add(IntPtr listPtr, IntPtr item);
+
+ void hb_list_insert(IntPtr listPtr, int pos, IntPtr item);
+
+ void hb_list_rem(IntPtr listPtr, IntPtr item);
+
+ IntPtr hb_list_item(IntPtr listPtr, int itemIndex);
+
+ void hb_list_close(IntPtr listPtrPtr);
+
+ int hb_subtitle_can_force(int source);
+
+ int hb_subtitle_can_burn(int source);
+
+ int hb_subtitle_can_pass(int source, int mux);
+
+ int hb_video_framerate_get_from_name(IntPtr name);
+
+ IntPtr hb_video_framerate_get_next(IntPtr last);
+
+ IntPtr hb_audio_samplerate_get_next(IntPtr last);
+
+ int hb_audio_samplerate_find_closest(int samplerate, uint codec);
+
+ int hb_audio_bitrate_get_best(uint codec, int bitrate, int samplerate, int mixdown);
+
+ int hb_audio_bitrate_get_default(uint codec, int samplerate, int mixdown);
+
+ int hb_audio_bitrate_get_limits(uint codec, int samplerate, int mixdown, ref int low, ref int high);
+
+ IntPtr hb_audio_bitrate_get_next(IntPtr last);
+
+ void hb_video_quality_get_limits(uint codec, ref float low, ref float high, ref float granularity, ref int direction);
+
+ IntPtr hb_video_quality_get_name(uint codec);
+
+ void hb_audio_quality_get_limits(uint codec, ref float low, ref float high, ref float granularity, ref int direction);
+
+ float hb_audio_quality_get_default(uint codec);
+
+ void hb_audio_compression_get_limits(uint codec, ref float low, ref float high, ref float granularity, ref int direction);
+
+ float hb_audio_compression_get_default(uint codec);
+
+ int hb_audio_can_apply_drc2(IntPtr handle, int title_index, int audio_index, int encoder);
+
+ int hb_mixdown_is_supported(int mixdown, uint codec, ulong layout);
+
+ int hb_mixdown_has_codec_support(int mixdown, uint codec);
+
+ int hb_mixdown_has_remix_support(int mixdown, ulong layout);
+
+ int hb_mixdown_get_best(uint codec, ulong layout, int mixdown);
+
+ int hb_mixdown_get_default(uint codec, ulong layout);
+
+ IntPtr hb_mixdown_get_next(IntPtr last);
+
+ IntPtr hb_video_encoder_get_next(IntPtr last);
+
+ IntPtr hb_audio_encoder_get_next(IntPtr last);
+
+ IntPtr hb_container_get_next(IntPtr last);
+
+ IntPtr hb_video_encoder_get_presets(int encoder);
+
+ IntPtr hb_video_encoder_get_tunes(int encoder);
+
+ IntPtr hb_video_encoder_get_profiles(int encoder);
+
+ IntPtr hb_video_encoder_get_levels(int encoder);
+
+ IntPtr lang_get_next(IntPtr last);
+
+ IntPtr lang_for_code2([In] [MarshalAs(UnmanagedType.LPStr)] string code2);
+
+ void hb_job_close(IntPtr job);
+
+ IntPtr hb_filter_get_keys(int filter_id);
+
+ IntPtr hb_x264_encopt_name(IntPtr name);
+
+ int hb_check_h264_level(
+ [In] [MarshalAs(UnmanagedType.LPStr)] string level,
+ int width,
+ int height,
+ int fps_num,
+ int fps_den,
+ int interlaced,
+ int fake_interlaced);
+
+ IntPtr hb_x264_param_unparse(
+ int bit_depth,
+ [In] [MarshalAs(UnmanagedType.LPStr)] string x264_preset,
+ [In] [MarshalAs(UnmanagedType.LPStr)] string x264_tune,
+ [In] [MarshalAs(UnmanagedType.LPStr)] string x264_encopts,
+ [In] [MarshalAs(UnmanagedType.LPStr)] string x264_profile,
+ [In] [MarshalAs(UnmanagedType.LPStr)] string h264_level,
+ int width,
+ int height);
+
+ int hb_qsv_available();
+
+ int hb_vce_h264_available();
+
+ int hb_vce_h265_available();
+
+ int hb_nvenc_h264_available();
+
+ int hb_nvenc_h265_available();
+
+ IntPtr hb_get_preview2(IntPtr hbHandle, int title_idx, int preview_idx, ref hb_geometry_settings_s geo, int deinterlace);
+
+ IntPtr hb_image_close(IntPtr image);
+
+ IntPtr hb_get_title_set_json(IntPtr hbHandle);
+
+ IntPtr hb_job_init_json(IntPtr hbHandle, int title_index);
+
+ IntPtr hb_json_to_job(IntPtr hbHandle, IntPtr json_job);
+
+ int hb_add_json(IntPtr hbHandle, IntPtr json_job);
+
+ IntPtr hb_set_anamorphic_size_json(IntPtr json_param);
+
+ IntPtr hb_get_state_json(IntPtr hbHandle);
+
+ IntPtr hb_get_preview_params_json(int title_idx, int preview_idx, int deinterlace, ref hb_geometry_settings_s settings);
+
+ void hb_presets_builtin_init();
+
+ IntPtr hb_presets_builtin_get_json();
+
+ IntPtr hb_presets_read_file_json(IntPtr filename);
+
+ IntPtr hb_presets_current_version(IntPtr major, IntPtr minor, IntPtr micro);
+
+ 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 custom);
+
+ IntPtr hb_filter_get_presets_json(int filter_id);
+
+ IntPtr hb_filter_get_tunes_json(int filter_id);
+ }
+}
diff --git a/win/CS/HandBrake.Interop/Interop/Helpers/InteropUtilities.cs b/win/CS/HandBrake.Interop/Interop/Helpers/InteropUtilities.cs
index c63fde326..7ff81d407 100644
--- a/win/CS/HandBrake.Interop/Interop/Helpers/InteropUtilities.cs
+++ b/win/CS/HandBrake.Interop/Interop/Helpers/InteropUtilities.cs
@@ -16,12 +16,23 @@ namespace HandBrake.Interop.Interop.Helpers
using System.Text;
using HandBrake.Interop.Interop.HbLib;
+ using HandBrake.Interop.Interop.HbLib.Wrappers.Interfaces;
+ using HandBrake.Interop.Interop.Providers;
+ using HandBrake.Interop.Interop.Providers.Interfaces;
/// <summary>
/// Helper utilities for native interop.
/// </summary>
internal static class InteropUtilities
{
+ private static IHbFunctions hbFunctions;
+
+ static InteropUtilities()
+ {
+ IHbFunctionsProvider hbFunctionsProvider = new HbFunctionsProvider();
+ hbFunctions = hbFunctionsProvider.GetHbFunctionsWrapper();
+ }
+
/// <summary>
/// Reads the given native structure pointer.
/// </summary>
@@ -262,7 +273,7 @@ namespace HandBrake.Interop.Interop.Helpers
// Assign the new pointer to the job pointer and tell HB to clean the job up.
Marshal.WriteIntPtr(nativeJobPtrPtr, nativeJobPtr);
- HBFunctions.hb_job_close(nativeJobPtrPtr);
+ hbFunctions.hb_job_close(nativeJobPtrPtr);
// Free the pointer we used.
Marshal.FreeHGlobal(nativeJobPtrPtr);
diff --git a/win/CS/HandBrake.Interop/Interop/Helpers/NativeList.cs b/win/CS/HandBrake.Interop/Interop/Helpers/NativeList.cs
index dc0f9c3db..b63789943 100644
--- a/win/CS/HandBrake.Interop/Interop/Helpers/NativeList.cs
+++ b/win/CS/HandBrake.Interop/Interop/Helpers/NativeList.cs
@@ -15,12 +15,17 @@ namespace HandBrake.Interop.Interop.Helpers
using System.Runtime.InteropServices;
using HandBrake.Interop.Interop.HbLib;
+ using HandBrake.Interop.Interop.HbLib.Wrappers.Interfaces;
+ using HandBrake.Interop.Interop.Providers;
+ using HandBrake.Interop.Interop.Providers.Interfaces;
/// <summary>
/// Represents a HandBrake style native list.
/// </summary>
internal class NativeList : IDisposable
{
+ private static IHbFunctions hbFunctions;
+
/// <summary>
/// Initializes a new instance of the NativeList class.
/// </summary>
@@ -28,8 +33,10 @@ namespace HandBrake.Interop.Interop.Helpers
public NativeList(IntPtr listPtr)
{
this.Ptr = listPtr;
+ IHbFunctionsProvider hbFunctionsProvider = new HbFunctionsProvider();
+ hbFunctions = hbFunctionsProvider.GetHbFunctionsWrapper();
}
-
+
/// <summary>
/// The list of native memory locations allocated for this list.
/// </summary>
@@ -48,7 +55,7 @@ namespace HandBrake.Interop.Interop.Helpers
get
{
Debug.WriteLine("Got a Zero Pointer in the NativeList");
- return this.Ptr == IntPtr.Zero ? 0 : HBFunctions.hb_list_count(this.Ptr);
+ return this.Ptr == IntPtr.Zero ? 0 : hbFunctions.hb_list_count(this.Ptr);
}
}
@@ -69,7 +76,7 @@ namespace HandBrake.Interop.Interop.Helpers
/// <param name="item">The item to add.</param>
public void Add(IntPtr item)
{
- HBFunctions.hb_list_add(this.Ptr, item);
+ hbFunctions.hb_list_add(this.Ptr, item);
}
/// <summary>
@@ -79,7 +86,7 @@ namespace HandBrake.Interop.Interop.Helpers
/// <param name="item">The item to insert.</param>
public void Insert(int position, IntPtr item)
{
- HBFunctions.hb_list_insert(this.Ptr, position, item);
+ hbFunctions.hb_list_insert(this.Ptr, position, item);
}
/// <summary>
@@ -88,7 +95,7 @@ namespace HandBrake.Interop.Interop.Helpers
/// <param name="item">The item to remove.</param>
public void Remove(IntPtr item)
{
- HBFunctions.hb_list_rem(this.Ptr, item);
+ hbFunctions.hb_list_rem(this.Ptr, item);
}
/// <summary>
@@ -100,7 +107,7 @@ namespace HandBrake.Interop.Interop.Helpers
{
get
{
- return HBFunctions.hb_list_item(this.Ptr, i);
+ return hbFunctions.hb_list_item(this.Ptr, i);
}
}
@@ -111,7 +118,7 @@ namespace HandBrake.Interop.Interop.Helpers
{
IntPtr listPtrPtr = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(IntPtr)));
Marshal.WriteIntPtr(listPtrPtr, this.Ptr);
- HBFunctions.hb_list_close(listPtrPtr);
+ hbFunctions.hb_list_close(listPtrPtr);
Marshal.FreeHGlobal(listPtrPtr);
}
@@ -121,7 +128,8 @@ namespace HandBrake.Interop.Interop.Helpers
/// <returns>The created list.</returns>
public static NativeList CreateList()
{
- return new NativeList(HBFunctions.hb_list_init());
+ IHbFunctionsProvider hbFunctionsProvider = new HbFunctionsProvider();
+ return new NativeList(hbFunctionsProvider.GetHbFunctionsWrapper().hb_list_init());
}
}
}
diff --git a/win/CS/HandBrake.Interop/Interop/Model/Encoding/HBVideoEncoder.cs b/win/CS/HandBrake.Interop/Interop/Model/Encoding/HBVideoEncoder.cs
index 2c064b2be..e60ed2668 100644
--- a/win/CS/HandBrake.Interop/Interop/Model/Encoding/HBVideoEncoder.cs
+++ b/win/CS/HandBrake.Interop/Interop/Model/Encoding/HBVideoEncoder.cs
@@ -12,13 +12,18 @@ namespace HandBrake.Interop.Interop.Model.Encoding
using System.Collections.Generic;
using HandBrake.Interop.Interop.HbLib;
+ using HandBrake.Interop.Interop.HbLib.Wrappers.Interfaces;
using HandBrake.Interop.Interop.Helpers;
+ using HandBrake.Interop.Interop.Providers;
+ using HandBrake.Interop.Interop.Providers.Interfaces;
/// <summary>
/// The hb video encoder.
/// </summary>
public class HBVideoEncoder
{
+ private IHbFunctions hbFunctions;
+
/// <summary>
/// Initializes a new instance of the <see cref="HBVideoEncoder"/> class.
/// </summary>
@@ -36,6 +41,9 @@ namespace HandBrake.Interop.Interop.Model.Encoding
/// </param>
public HBVideoEncoder(int compatibleContainers, string displayName, int id, string shortName)
{
+ IHbFunctionsProvider hbFunctionsProvider = new HbFunctionsProvider();
+ hbFunctions = hbFunctionsProvider.GetHbFunctionsWrapper();
+
this.CompatibleContainers = compatibleContainers;
this.DisplayName = displayName;
this.Id = id;
@@ -69,7 +77,7 @@ namespace HandBrake.Interop.Interop.Model.Encoding
{
get
{
- return InteropUtilities.ToStringListFromArrayPtr(HBFunctions.hb_video_encoder_get_presets(this.Id));
+ return InteropUtilities.ToStringListFromArrayPtr(hbFunctions.hb_video_encoder_get_presets(this.Id));
}
}
@@ -80,7 +88,7 @@ namespace HandBrake.Interop.Interop.Model.Encoding
{
get
{
- return InteropUtilities.ToStringListFromArrayPtr(HBFunctions.hb_video_encoder_get_tunes(this.Id));
+ return InteropUtilities.ToStringListFromArrayPtr(hbFunctions.hb_video_encoder_get_tunes(this.Id));
}
}
@@ -91,7 +99,7 @@ namespace HandBrake.Interop.Interop.Model.Encoding
{
get
{
- return InteropUtilities.ToStringListFromArrayPtr(HBFunctions.hb_video_encoder_get_profiles(this.Id));
+ return InteropUtilities.ToStringListFromArrayPtr(hbFunctions.hb_video_encoder_get_profiles(this.Id));
}
}
@@ -102,7 +110,7 @@ namespace HandBrake.Interop.Interop.Model.Encoding
{
get
{
- return InteropUtilities.ToStringListFromArrayPtr(HBFunctions.hb_video_encoder_get_levels(this.Id));
+ return InteropUtilities.ToStringListFromArrayPtr(hbFunctions.hb_video_encoder_get_levels(this.Id));
}
}
}
diff --git a/win/CS/HandBrake.Interop/Interop/Providers/HbFunctionsProvider.cs b/win/CS/HandBrake.Interop/Interop/Providers/HbFunctionsProvider.cs
new file mode 100644
index 000000000..3b964ff8c
--- /dev/null
+++ b/win/CS/HandBrake.Interop/Interop/Providers/HbFunctionsProvider.cs
@@ -0,0 +1,30 @@
+// --------------------------------------------------------------------------------------------------------------------
+// <copyright file="HbFunctionsProvider.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>
+// Provides an instance of IHbFunctions for use by the GUI.
+// </summary>
+// --------------------------------------------------------------------------------------------------------------------
+
+namespace HandBrake.Interop.Interop.Providers
+{
+ using HandBrake.Interop.Interop.HbLib.Wrappers;
+ using HandBrake.Interop.Interop.HbLib.Wrappers.Interfaces;
+ using HandBrake.Interop.Interop.Providers.Interfaces;
+
+ public class HbFunctionsProvider : IHbFunctionsProvider
+ {
+ private static IHbFunctions hbFunctions;
+
+ public IHbFunctions GetHbFunctionsWrapper()
+ {
+ if (hbFunctions == null)
+ {
+ hbFunctions = new HbFunctionsDirect();
+ }
+
+ return hbFunctions;
+ }
+ }
+}
diff --git a/win/CS/HandBrake.Interop/Interop/Providers/Interfaces/IHbFunctionsProvider.cs b/win/CS/HandBrake.Interop/Interop/Providers/Interfaces/IHbFunctionsProvider.cs
new file mode 100644
index 000000000..f64f54594
--- /dev/null
+++ b/win/CS/HandBrake.Interop/Interop/Providers/Interfaces/IHbFunctionsProvider.cs
@@ -0,0 +1,18 @@
+// --------------------------------------------------------------------------------------------------------------------
+// <copyright file="IHbFunctionsProvider.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>
+// Provides an instance of IHbFunctions for use by the GUI.
+// </summary>
+// --------------------------------------------------------------------------------------------------------------------
+
+namespace HandBrake.Interop.Interop.Providers.Interfaces
+{
+ using HandBrake.Interop.Interop.HbLib.Wrappers.Interfaces;
+
+ public interface IHbFunctionsProvider
+ {
+ IHbFunctions GetHbFunctionsWrapper();
+ }
+} \ No newline at end of file
diff --git a/win/CS/HandBrake.Interop/Utilities/SystemInfo.cs b/win/CS/HandBrake.Interop/Utilities/SystemInfo.cs
index 454132b53..b22e16d6c 100644
--- a/win/CS/HandBrake.Interop/Utilities/SystemInfo.cs
+++ b/win/CS/HandBrake.Interop/Utilities/SystemInfo.cs
@@ -11,6 +11,10 @@ namespace HandBrake.Interop.Utilities
{
using System;
+ using HandBrake.Interop.Interop.HbLib.Wrappers.Interfaces;
+ using HandBrake.Interop.Interop.Providers;
+ using HandBrake.Interop.Interop.Providers.Interfaces;
+
using Interop.HbLib;
/// <summary>
@@ -21,6 +25,14 @@ namespace HandBrake.Interop.Utilities
private static bool? isNvencH264Available; // Local cache to prevent log spam.
private static bool? isNvencH265Available;
+ private static IHbFunctions hbFunctions;
+
+ static SystemInfo()
+ {
+ IHbFunctionsProvider hbFunctionsProvider = new HbFunctionsProvider();
+ hbFunctions = hbFunctionsProvider.GetHbFunctionsWrapper();
+ }
+
/// <summary>
/// Gets a value indicating whether is qsv available.
/// </summary>
@@ -30,7 +42,7 @@ namespace HandBrake.Interop.Utilities
{
try
{
- return HBFunctions.hb_qsv_available() != 0;
+ return hbFunctions.hb_qsv_available() != 0;
}
catch (Exception)
{
@@ -49,7 +61,7 @@ namespace HandBrake.Interop.Utilities
{
try
{
- return (HBFunctions.hb_qsv_available() & NativeConstants.HB_VCODEC_QSV_H264) != 0;
+ return (hbFunctions.hb_qsv_available() & NativeConstants.HB_VCODEC_QSV_H264) != 0;
}
catch (Exception)
{
@@ -68,7 +80,7 @@ namespace HandBrake.Interop.Utilities
{
try
{
- return (HBFunctions.hb_qsv_available() & NativeConstants.HB_VCODEC_QSV_H265) != 0;
+ return (hbFunctions.hb_qsv_available() & NativeConstants.HB_VCODEC_QSV_H265) != 0;
}
catch (Exception)
{
@@ -84,7 +96,7 @@ namespace HandBrake.Interop.Utilities
{
try
{
- return (HBFunctions.hb_qsv_available() & NativeConstants.HB_VCODEC_QSV_H265_10BIT) != 0;
+ return (hbFunctions.hb_qsv_available() & NativeConstants.HB_VCODEC_QSV_H265_10BIT) != 0;
}
catch (Exception)
{
@@ -100,7 +112,7 @@ namespace HandBrake.Interop.Utilities
{
try
{
- return HBFunctions.hb_vce_h264_available() != 0;
+ return hbFunctions.hb_vce_h264_available() != 0;
}
catch (Exception)
{
@@ -116,7 +128,7 @@ namespace HandBrake.Interop.Utilities
{
try
{
- return HBFunctions.hb_vce_h265_available() != 0;
+ return hbFunctions.hb_vce_h265_available() != 0;
}
catch (Exception)
{
@@ -134,7 +146,7 @@ namespace HandBrake.Interop.Utilities
{
if (isNvencH264Available == null)
{
- isNvencH264Available = HBFunctions.hb_nvenc_h264_available() != 0;
+ isNvencH264Available = hbFunctions.hb_nvenc_h264_available() != 0;
}
return isNvencH264Available.Value;
@@ -160,7 +172,7 @@ namespace HandBrake.Interop.Utilities
if (isNvencH265Available == null)
{
- isNvencH265Available = HBFunctions.hb_nvenc_h265_available() != 0;
+ isNvencH265Available = hbFunctions.hb_nvenc_h265_available() != 0;
}
return isNvencH265Available.Value;
diff --git a/win/CS/HandBrake.Interop/Utilities/VersionHelper.cs b/win/CS/HandBrake.Interop/Utilities/VersionHelper.cs
index 08c4c95af..36a04fc63 100644
--- a/win/CS/HandBrake.Interop/Utilities/VersionHelper.cs
+++ b/win/CS/HandBrake.Interop/Utilities/VersionHelper.cs
@@ -13,12 +13,20 @@ namespace HandBrake.Interop.Utilities
using System.Runtime.InteropServices;
using HandBrake.Interop.Interop.HbLib;
+ using HandBrake.Interop.Interop.HbLib.Wrappers.Interfaces;
+ using HandBrake.Interop.Interop.Providers;
+ using HandBrake.Interop.Interop.Providers.Interfaces;
- /// <summary>
- /// Version Utility
- /// </summary>
public class VersionHelper
{
+ private static IHbFunctions hbFunctions;
+
+ static VersionHelper()
+ {
+ IHbFunctionsProvider hbFunctionsProvider = new HbFunctionsProvider();
+ hbFunctions = hbFunctionsProvider.GetHbFunctionsWrapper();
+ }
+
/// <summary>
/// The get build.
/// </summary>
@@ -54,7 +62,7 @@ namespace HandBrake.Interop.Utilities
{
get
{
- var versionPtr = HBFunctions.hb_get_version(IntPtr.Zero); // Pointer isn't actually used.
+ var versionPtr = hbFunctions.hb_get_version(IntPtr.Zero); // Pointer isn't actually used.
return Marshal.PtrToStringAnsi(versionPtr);
}
}
@@ -66,7 +74,7 @@ namespace HandBrake.Interop.Utilities
{
get
{
- return HBFunctions.hb_get_build(IntPtr.Zero);
+ return hbFunctions.hb_get_build(IntPtr.Zero);
}
}
}
diff --git a/win/CS/HandBrakeWPF/Helpers/PictureSize.cs b/win/CS/HandBrakeWPF/Helpers/PictureSize.cs
index 8361e35d5..553978e50 100644
--- a/win/CS/HandBrakeWPF/Helpers/PictureSize.cs
+++ b/win/CS/HandBrakeWPF/Helpers/PictureSize.cs
@@ -9,9 +9,15 @@
namespace HandBrakeWPF.Helpers
{
+ using Caliburn.Micro;
+
using HandBrake.Interop.Interop.HbLib;
+ using HandBrake.Interop.Interop.HbLib.Wrappers.Interfaces;
using HandBrake.Interop.Interop.Model;
using HandBrake.Interop.Interop.Model.Encoding;
+ using HandBrake.Interop.Interop.Providers.Interfaces;
+
+ using HandBrakeWPF.Services.Interfaces;
/// <summary>
/// The picture size Helpers
@@ -196,7 +202,10 @@ namespace HandBrakeWPF.Helpers
hb_geometry_s result = new hb_geometry_s();
- HBFunctions.hb_set_anamorphic_size2(ref sourceGeometry, ref uiGeometry, ref result);
+ IHbFunctionsProvider provider = IoC.Get<IHbFunctionsProvider>(); // TODO make this method non static and remove IoC call.
+ IHbFunctions hbFunctions = provider.GetHbFunctionsWrapper();
+
+ hbFunctions.hb_set_anamorphic_size2(ref sourceGeometry, ref uiGeometry, ref result);
int outputWidth = result.width;
int outputHeight = result.height;
diff --git a/win/CS/HandBrakeWPF/Services/Encode/Factories/EncodeTaskFactory.cs b/win/CS/HandBrakeWPF/Services/Encode/Factories/EncodeTaskFactory.cs
index f5de098ac..003f13f17 100644
--- a/win/CS/HandBrakeWPF/Services/Encode/Factories/EncodeTaskFactory.cs
+++ b/win/CS/HandBrakeWPF/Services/Encode/Factories/EncodeTaskFactory.cs
@@ -17,6 +17,7 @@ namespace HandBrakeWPF.Services.Encode.Factories
using HandBrake.Interop.Interop;
using HandBrake.Interop.Interop.HbLib;
+ using HandBrake.Interop.Interop.HbLib.Wrappers.Interfaces;
using HandBrake.Interop.Interop.Json.Encode;
using HandBrake.Interop.Interop.Json.Shared;
using HandBrake.Interop.Interop.Model.Encoding;
@@ -45,6 +46,9 @@ namespace HandBrakeWPF.Services.Encode.Factories
/// </summary>
internal class EncodeTaskFactory
{
+ // TODO make this non-static
+ private static IHbFunctions hbFunctions;
+
/// <summary>
/// The create.
/// </summary>
@@ -54,11 +58,16 @@ namespace HandBrakeWPF.Services.Encode.Factories
/// <param name="configuration">
/// The configuration.
/// </param>
+ /// <param name="hbFunctionsWrapper">
+ /// An instance of IHbFunctions
+ /// </param>
/// <returns>
/// The <see cref="JsonEncodeObject"/>.
/// </returns>
- internal static JsonEncodeObject Create(EncodeTask job, HBConfiguration configuration)
+ internal static JsonEncodeObject Create(EncodeTask job, HBConfiguration configuration, IHbFunctions hbFunctionsWrapper)
{
+ hbFunctions = hbFunctionsWrapper;
+
JsonEncodeObject encode = new JsonEncodeObject
{
SequenceID = 0,
@@ -407,7 +416,7 @@ namespace HandBrakeWPF.Services.Encode.Factories
// Detelecine
if (job.Detelecine != Detelecine.Off)
{
- IntPtr settingsPtr = HBFunctions.hb_generate_filter_settings_json((int)hb_filter_ids.HB_FILTER_DETELECINE, null, null, job.CustomDetelecine);
+ IntPtr settingsPtr = hbFunctions.hb_generate_filter_settings_json((int)hb_filter_ids.HB_FILTER_DETELECINE, null, null, job.CustomDetelecine);
string unparsedJson = Marshal.PtrToStringAnsi(settingsPtr);
if (!string.IsNullOrEmpty(unparsedJson))
{
@@ -421,7 +430,7 @@ namespace HandBrakeWPF.Services.Encode.Factories
// Deinterlace
if (job.DeinterlaceFilter == DeinterlaceFilter.Yadif)
{
- IntPtr settingsPtr = HBFunctions.hb_generate_filter_settings_json((int)hb_filter_ids.HB_FILTER_DEINTERLACE, job.DeinterlacePreset?.ShortName, null, job.CustomDeinterlaceSettings);
+ IntPtr settingsPtr = hbFunctions.hb_generate_filter_settings_json((int)hb_filter_ids.HB_FILTER_DEINTERLACE, job.DeinterlacePreset?.ShortName, null, job.CustomDeinterlaceSettings);
string unparsedJson = Marshal.PtrToStringAnsi(settingsPtr);
if (!string.IsNullOrEmpty(unparsedJson))
{
@@ -435,7 +444,7 @@ namespace HandBrakeWPF.Services.Encode.Factories
// Decomb
if (job.DeinterlaceFilter == DeinterlaceFilter.Decomb)
{
- IntPtr settingsPtr = HBFunctions.hb_generate_filter_settings_json((int)hb_filter_ids.HB_FILTER_DECOMB, job.DeinterlacePreset?.ShortName, null, job.CustomDeinterlaceSettings);
+ IntPtr settingsPtr = hbFunctions.hb_generate_filter_settings_json((int)hb_filter_ids.HB_FILTER_DECOMB, job.DeinterlacePreset?.ShortName, null, job.CustomDeinterlaceSettings);
string unparsedJson = Marshal.PtrToStringAnsi(settingsPtr);
if (!string.IsNullOrEmpty(unparsedJson))
{
@@ -450,7 +459,7 @@ namespace HandBrakeWPF.Services.Encode.Factories
{
if (job.CombDetect != CombDetect.Off)
{
- IntPtr settingsPtr = HBFunctions.hb_generate_filter_settings_json((int)hb_filter_ids.HB_FILTER_COMB_DETECT, EnumHelper<CombDetect>.GetShortName(job.CombDetect), null, job.CustomCombDetect);
+ IntPtr settingsPtr = hbFunctions.hb_generate_filter_settings_json((int)hb_filter_ids.HB_FILTER_COMB_DETECT, EnumHelper<CombDetect>.GetShortName(job.CombDetect), null, job.CustomCombDetect);
string unparsedJson = Marshal.PtrToStringAnsi(settingsPtr);
if (!string.IsNullOrEmpty(unparsedJson))
{
@@ -473,7 +482,7 @@ namespace HandBrakeWPF.Services.Encode.Factories
? hb_filter_ids.HB_FILTER_HQDN3D
: hb_filter_ids.HB_FILTER_NLMEANS;
- IntPtr settingsPtr = HBFunctions.hb_generate_filter_settings_json((int)id, job.DenoisePreset.ToString().ToLower().Replace(" ", string.Empty), job.DenoiseTune.ToString().ToLower().Replace(" ", string.Empty), job.CustomDenoise);
+ IntPtr settingsPtr = hbFunctions.hb_generate_filter_settings_json((int)id, job.DenoisePreset.ToString().ToLower().Replace(" ", string.Empty), job.DenoiseTune.ToString().ToLower().Replace(" ", string.Empty), job.CustomDenoise);
string unparsedJson = Marshal.PtrToStringAnsi(settingsPtr);
if (!string.IsNullOrEmpty(unparsedJson))
@@ -492,7 +501,7 @@ namespace HandBrakeWPF.Services.Encode.Factories
? hb_filter_ids.HB_FILTER_LAPSHARP
: hb_filter_ids.HB_FILTER_UNSHARP;
- IntPtr settingsPtr = HBFunctions.hb_generate_filter_settings_json((int)id, job.SharpenPreset.Key, job.SharpenTune.Key, job.SharpenCustom);
+ IntPtr settingsPtr = hbFunctions.hb_generate_filter_settings_json((int)id, job.SharpenPreset.Key, job.SharpenTune.Key, job.SharpenCustom);
string unparsedJson = Marshal.PtrToStringAnsi(settingsPtr);
if (!string.IsNullOrEmpty(unparsedJson))
@@ -507,7 +516,7 @@ namespace HandBrakeWPF.Services.Encode.Factories
// Deblock
if (job.DeblockPreset != null && job.DeblockPreset.Key != "off")
{
- IntPtr settingsPtr = HBFunctions.hb_generate_filter_settings_json((int)hb_filter_ids.HB_FILTER_DEBLOCK, job.DeblockPreset.Key, job.DeblockTune.Key, job.CustomDeblock);
+ IntPtr settingsPtr = hbFunctions.hb_generate_filter_settings_json((int)hb_filter_ids.HB_FILTER_DEBLOCK, job.DeblockPreset.Key, job.DeblockTune.Key, job.CustomDeblock);
string unparsedJson = Marshal.PtrToStringAnsi(settingsPtr);
if (!string.IsNullOrEmpty(unparsedJson))
{
@@ -520,7 +529,7 @@ namespace HandBrakeWPF.Services.Encode.Factories
// CropScale Filter
string cropSettings = string.Format("width={0}:height={1}:crop-top={2}:crop-bottom={3}:crop-left={4}:crop-right={5}", job.Width, job.Height, job.Cropping.Top, job.Cropping.Bottom, job.Cropping.Left, job.Cropping.Right);
- IntPtr cropSettingsPtr = HBFunctions.hb_generate_filter_settings_json((int)hb_filter_ids.HB_FILTER_CROP_SCALE, null, null, cropSettings);
+ IntPtr cropSettingsPtr = hbFunctions.hb_generate_filter_settings_json((int)hb_filter_ids.HB_FILTER_CROP_SCALE, null, null, cropSettings);
string unparsedCropSettingsJson = Marshal.PtrToStringAnsi(cropSettingsPtr);
if (!string.IsNullOrEmpty(unparsedCropSettingsJson))
{
@@ -545,7 +554,7 @@ namespace HandBrakeWPF.Services.Encode.Factories
if (job.Rotation != 0 || job.FlipVideo)
{
string rotateSettings = string.Format("angle={0}:hflip={1}", job.Rotation, job.FlipVideo ? "1" : "0");
- IntPtr settingsPtr = HBFunctions.hb_generate_filter_settings_json((int)hb_filter_ids.HB_FILTER_ROTATE, null, null, rotateSettings);
+ IntPtr settingsPtr = hbFunctions.hb_generate_filter_settings_json((int)hb_filter_ids.HB_FILTER_ROTATE, null, null, rotateSettings);
string unparsedJson = Marshal.PtrToStringAnsi(settingsPtr);
if (!string.IsNullOrEmpty(unparsedJson))
{
@@ -562,7 +571,7 @@ namespace HandBrakeWPF.Services.Encode.Factories
if (job.Framerate != null)
{
IntPtr frameratePrt = Marshal.StringToHGlobalAnsi(job.Framerate.Value.ToString(CultureInfo.InvariantCulture));
- int vrate = HBFunctions.hb_video_framerate_get_from_name(frameratePrt);
+ int vrate = hbFunctions.hb_video_framerate_get_from_name(frameratePrt);
if (vrate > 0)
{
@@ -572,7 +581,7 @@ namespace HandBrakeWPF.Services.Encode.Factories
}
string framerateString = num.HasValue ? string.Format("mode={0}:rate={1}/{2}", fm, num, den) : string.Format("mode={0}", fm); // filter_cfr, filter_vrate.num, filter_vrate.den
- IntPtr framerateSettingsPtr = HBFunctions.hb_generate_filter_settings_json((int)hb_filter_ids.HB_FILTER_VFR, null, null, framerateString);
+ IntPtr framerateSettingsPtr = hbFunctions.hb_generate_filter_settings_json((int)hb_filter_ids.HB_FILTER_VFR, null, null, framerateString);
string unparsedFramerateJson = Marshal.PtrToStringAnsi(framerateSettingsPtr);
if (!string.IsNullOrEmpty(unparsedFramerateJson))
{
diff --git a/win/CS/HandBrakeWPF/Services/Encode/Factories/QueueFactory.cs b/win/CS/HandBrakeWPF/Services/Encode/Factories/QueueFactory.cs
index bb7f9ac62..b17385b47 100644
--- a/win/CS/HandBrakeWPF/Services/Encode/Factories/QueueFactory.cs
+++ b/win/CS/HandBrakeWPF/Services/Encode/Factories/QueueFactory.cs
@@ -11,10 +11,15 @@ namespace HandBrakeWPF.Services.Encode.Factories
{
using System.Collections.Generic;
+ using Caliburn.Micro;
+
+ using HandBrake.Interop.Interop.HbLib.Wrappers.Interfaces;
using HandBrake.Interop.Interop.Json.Queue;
+ using HandBrake.Interop.Interop.Providers.Interfaces;
using HandBrake.Interop.Model;
using HandBrakeWPF.Services.Encode.Model;
+ using HandBrakeWPF.Services.Interfaces;
using Newtonsoft.Json;
@@ -42,10 +47,13 @@ namespace HandBrakeWPF.Services.Encode.Factories
NullValueHandling = NullValueHandling.Ignore,
};
+ IHbFunctionsProvider provider = IoC.Get<IHbFunctionsProvider>(); // TODO remove IoC call.
+ IHbFunctions hbFunctions = provider.GetHbFunctionsWrapper();
+
List<Task> queueJobs = new List<Task>();
foreach (var item in tasks)
{
- Task task = new Task { Job = EncodeTaskFactory.Create(item, configuration) };
+ Task task = new Task { Job = EncodeTaskFactory.Create(item, configuration, hbFunctions) };
queueJobs.Add(task);
}
diff --git a/win/CS/HandBrakeWPF/Services/Encode/LibEncode.cs b/win/CS/HandBrakeWPF/Services/Encode/LibEncode.cs
index 188e6bb35..5c147aa4e 100644
--- a/win/CS/HandBrakeWPF/Services/Encode/LibEncode.cs
+++ b/win/CS/HandBrakeWPF/Services/Encode/LibEncode.cs
@@ -16,11 +16,13 @@ namespace HandBrakeWPF.Services.Encode
using HandBrake.Interop.Interop.EventArgs;
using HandBrake.Interop.Interop.Interfaces;
using HandBrake.Interop.Interop.Json.State;
+ using HandBrake.Interop.Interop.Providers.Interfaces;
using HandBrake.Interop.Model;
using HandBrakeWPF.Exceptions;
using HandBrakeWPF.Properties;
using HandBrakeWPF.Services.Encode.Factories;
+ using HandBrakeWPF.Services.Interfaces;
using EncodeTask = Model.EncodeTask;
using HandBrakeInstanceManager = Instance.HandBrakeInstanceManager;
@@ -38,6 +40,7 @@ namespace HandBrakeWPF.Services.Encode
#region Private Variables
private ILog log = LogService.GetLogger();
+ private readonly IHbFunctionsProvider hbFunctionsProvider;
private IEncodeInstance instance;
private DateTime startTime;
private EncodeTask currentTask;
@@ -46,6 +49,11 @@ namespace HandBrakeWPF.Services.Encode
#endregion
+ public LibEncode(IHbFunctionsProvider hbFunctionsProvider)
+ {
+ this.hbFunctionsProvider = hbFunctionsProvider;
+ }
+
/// <summary>
/// Gets a value indicating whether is pasued.
/// </summary>
@@ -113,7 +121,7 @@ namespace HandBrakeWPF.Services.Encode
this.VerifyEncodeDestinationPath(task);
// Get an EncodeJob object for the Interop Library
- this.instance.StartEncode(EncodeTaskFactory.Create(task, configuration));
+ this.instance.StartEncode(EncodeTaskFactory.Create(task, configuration, hbFunctionsProvider.GetHbFunctionsWrapper()));
// Fire the Encode Started Event
this.InvokeEncodeStarted(System.EventArgs.Empty);
diff --git a/win/CS/HandBrakeWPF/Services/PowerService.cs b/win/CS/HandBrakeWPF/Services/PowerService.cs
index 9239a2cd2..e73027f57 100644
--- a/win/CS/HandBrakeWPF/Services/PowerService.cs
+++ b/win/CS/HandBrakeWPF/Services/PowerService.cs
@@ -3,11 +3,10 @@
// 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 Error Service
+// The Power Service
// </summary>
// --------------------------------------------------------------------------------------------------------------------
-
namespace HandBrakeWPF.Services
{
using System;
@@ -17,7 +16,6 @@ namespace HandBrakeWPF.Services
{
private void GetPowerState()
{
-
System.Management.ObjectQuery query = new ObjectQuery("Select * FROM Win32_Battery");
ManagementObjectSearcher searcher = new ManagementObjectSearcher(query);
@@ -30,7 +28,6 @@ namespace HandBrakeWPF.Services
Console.WriteLine("Property {0}: Value is {1}", property.Name, property.Value);
}
}
-
}
}
}
diff --git a/win/CS/HandBrakeWPF/Services/Scan/Factories/TitleFactory.cs b/win/CS/HandBrakeWPF/Services/Scan/Factories/TitleFactory.cs
index dc787b5c9..9b96771aa 100644
--- a/win/CS/HandBrakeWPF/Services/Scan/Factories/TitleFactory.cs
+++ b/win/CS/HandBrakeWPF/Services/Scan/Factories/TitleFactory.cs
@@ -11,11 +11,16 @@ namespace HandBrakeWPF.Services.Scan.Factories
{
using System;
+ using Caliburn.Micro;
+
using HandBrake.Interop.Interop.HbLib;
+ using HandBrake.Interop.Interop.HbLib.Wrappers.Interfaces;
using HandBrake.Interop.Interop.Json.Scan;
using HandBrake.Interop.Interop.Model;
+ using HandBrake.Interop.Interop.Providers.Interfaces;
using HandBrakeWPF.Services.Encode.Model.Models;
+ using HandBrakeWPF.Services.Interfaces;
using HandBrakeWPF.Services.Scan.Model;
public class TitleFactory
@@ -93,8 +98,11 @@ namespace HandBrakeWPF.Services.Scan.Factories
break;
}
- bool canBurn = HBFunctions.hb_subtitle_can_burn(track.Source) > 0;
- bool canSetForcedOnly = HBFunctions.hb_subtitle_can_force(track.Source) > 0;
+ IHbFunctionsProvider provider = IoC.Get<IHbFunctionsProvider>(); // TODO remove IoC call
+ IHbFunctions hbFunctions = provider.GetHbFunctionsWrapper();
+
+ bool canBurn = hbFunctions.hb_subtitle_can_burn(track.Source) > 0;
+ bool canSetForcedOnly = hbFunctions.hb_subtitle_can_force(track.Source) > 0;
converted.Subtitles.Add(new Subtitle(track.Source, currentSubtitleTrack, track.Language, track.LanguageCode, convertedType, canBurn, canSetForcedOnly, track.Name));
currentSubtitleTrack++;
diff --git a/win/CS/HandBrakeWPF/Startup/AppBootstrapper.cs b/win/CS/HandBrakeWPF/Startup/AppBootstrapper.cs
index 69be73360..bc4613278 100644
--- a/win/CS/HandBrakeWPF/Startup/AppBootstrapper.cs
+++ b/win/CS/HandBrakeWPF/Startup/AppBootstrapper.cs
@@ -14,6 +14,9 @@ namespace HandBrakeWPF.Startup
using Caliburn.Micro;
+ using HandBrake.Interop.Interop.Providers;
+ using HandBrake.Interop.Interop.Providers.Interfaces;
+
using HandBrakeWPF.Services;
using HandBrakeWPF.Services.Interfaces;
using HandBrakeWPF.Services.Presets;
@@ -80,6 +83,7 @@ namespace HandBrakeWPF.Startup
this.container.Singleton<IMiniViewModel, MiniViewModel>();
this.container.Singleton<IStaticPreviewViewModel, StaticPreviewViewModel>();
this.container.Singleton<ISystemService, SystemService>();
+ this.container.Singleton<IHbFunctionsProvider, HbFunctionsProvider>();
// Tab Components
this.container.Singleton<IAudioViewModel, AudioViewModel>();
diff --git a/win/CS/HandBrakeWPF/ViewModels/StaticPreviewViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/StaticPreviewViewModel.cs
index 41b4fe84e..72a36aa9a 100644
--- a/win/CS/HandBrakeWPF/ViewModels/StaticPreviewViewModel.cs
+++ b/win/CS/HandBrakeWPF/ViewModels/StaticPreviewViewModel.cs
@@ -21,6 +21,7 @@ namespace HandBrakeWPF.ViewModels
using System.Windows.Media.Imaging;
using HandBrake.Interop.Interop.Model.Encoding;
+ using HandBrake.Interop.Interop.Providers.Interfaces;
using HandBrakeWPF.Factories;
using HandBrakeWPF.Properties;
@@ -120,19 +121,7 @@ namespace HandBrakeWPF.ViewModels
#region Constructors and Destructors
- /// <summary>
- /// Initializes a new instance of the <see cref="StaticPreviewViewModel"/> class.
- /// </summary>
- /// <param name="scanService">
- /// The scan service.
- /// </param>
- /// <param name="userSettingService">
- /// The user Setting Service.
- /// </param>
- /// <param name="errorService">
- /// The error Service.
- /// </param>
- public StaticPreviewViewModel(IScan scanService, IUserSettingService userSettingService, IErrorService errorService)
+ public StaticPreviewViewModel(IScan scanService, IUserSettingService userSettingService, IErrorService errorService, IHbFunctionsProvider hbFunctionsProvider)
{
this.scanService = scanService;
this.selectedPreviewImage = 1;
@@ -142,7 +131,7 @@ namespace HandBrakeWPF.ViewModels
// Live Preview
this.userSettingService = userSettingService;
this.errorService = errorService;
- this.encodeService = new LibEncode(); // Preview needs a separate instance rather than the shared singleton. This could maybe do with being refactored at some point
+ this.encodeService = new LibEncode(hbFunctionsProvider); // Preview needs a separate instance rather than the shared singleton. This could maybe do with being refactored at some point
this.Title = "Preview";
this.Percentage = "0.00%";
diff --git a/win/CS/HandBrakeWPF/Views/VideoView.xaml b/win/CS/HandBrakeWPF/Views/VideoView.xaml
index eb0e3ff3d..92f15f06e 100644
--- a/win/CS/HandBrakeWPF/Views/VideoView.xaml
+++ b/win/CS/HandBrakeWPF/Views/VideoView.xaml
@@ -186,13 +186,8 @@
</ContextMenu>
</TextBox.ContextMenu>
</TextBox>
-
-
</Grid>
</Grid>
-
-
</Grid>
-
</Grid>
</UserControl>