diff options
author | sr55 <[email protected]> | 2019-09-22 17:09:04 +0100 |
---|---|---|
committer | sr55 <[email protected]> | 2019-09-22 17:09:21 +0100 |
commit | 9552988c29ec0fff026528bb6501635783f5c22f (patch) | |
tree | 5c2eefeae4bd6fc5d04ff029b566a8ebbcee7cbc /win/CS/HandBrake.Interop/Utilities | |
parent | 63c732376f959699e0d199232dae8a08846f3595 (diff) |
WinGui:
- Add a non-static wrapper around HbFunctions.cs
- Add a Wrapper Provider that for now, returns only a direct in-process wrapper instance for libhb HbFunctions calls.
- Update all calls to use the new non-static wrapper provider / interface
Diffstat (limited to 'win/CS/HandBrake.Interop/Utilities')
-rw-r--r-- | win/CS/HandBrake.Interop/Utilities/SystemInfo.cs | 28 | ||||
-rw-r--r-- | win/CS/HandBrake.Interop/Utilities/VersionHelper.cs | 18 |
2 files changed, 33 insertions, 13 deletions
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); } } } |