summaryrefslogtreecommitdiffstats
path: root/win/CS/HandBrake.Interop/Utilities
diff options
context:
space:
mode:
authorsr55 <[email protected]>2020-10-04 15:41:07 +0100
committersr55 <[email protected]>2020-10-04 15:41:15 +0100
commitde8f3c5586121dcdf2b3b415464d686b9e58e3d2 (patch)
tree24d5ad72d02c602f43280295f6d5d5b0e2b56678 /win/CS/HandBrake.Interop/Utilities
parent561977956f39858d81e4786565466e63f8ddd430 (diff)
HandBrake.Interop: Library cleanup.
- Remove HbFunctions provider class and interface. It's not needed. Interop library will direct call libhb though HBFunctions.cs - Remove HbFunctionsDirect. Any consumer of the HandBrake API should be using managed calls rather than having to deal with pointers. - Fix many stylecop warnings and update rulesets around this.
Diffstat (limited to 'win/CS/HandBrake.Interop/Utilities')
-rw-r--r--win/CS/HandBrake.Interop/Utilities/CharCodesUtilities.cs2
-rw-r--r--win/CS/HandBrake.Interop/Utilities/LanguageUtilities.cs6
-rw-r--r--win/CS/HandBrake.Interop/Utilities/SystemInfo.cs41
-rw-r--r--win/CS/HandBrake.Interop/Utilities/VersionHelper.cs61
4 files changed, 35 insertions, 75 deletions
diff --git a/win/CS/HandBrake.Interop/Utilities/CharCodesUtilities.cs b/win/CS/HandBrake.Interop/Utilities/CharCodesUtilities.cs
index ced240bb7..9d8d46ad4 100644
--- a/win/CS/HandBrake.Interop/Utilities/CharCodesUtilities.cs
+++ b/win/CS/HandBrake.Interop/Utilities/CharCodesUtilities.cs
@@ -1,5 +1,5 @@
// --------------------------------------------------------------------------------------------------------------------
-// <copyright file="CharCodesUtilities.cs" company="HandBrake Project (http://handbrake.fr)">
+// <copyright file="CharCodesUtilities.cs" company="HandBrake Project (https://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>
diff --git a/win/CS/HandBrake.Interop/Utilities/LanguageUtilities.cs b/win/CS/HandBrake.Interop/Utilities/LanguageUtilities.cs
index 106247577..fad0307b5 100644
--- a/win/CS/HandBrake.Interop/Utilities/LanguageUtilities.cs
+++ b/win/CS/HandBrake.Interop/Utilities/LanguageUtilities.cs
@@ -1,5 +1,5 @@
// --------------------------------------------------------------------------------------------------------------------
-// <copyright file="LanguageUtilities.cs" company="HandBrake Project (http://handbrake.fr)">
+// <copyright file="LanguageUtilities.cs" company="HandBrake Project (https://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>
@@ -10,17 +10,15 @@
namespace HandBrake.Interop.Utilities
{
using System.Collections.Generic;
- using System.ComponentModel;
using System.Linq;
- using HandBrake.Interop.Interop.HbLib;
-
/// <summary>
/// Language Utilities
/// </summary>
public class LanguageUtilities
{
public static string Any = "(Any)";
+
private static IDictionary<string, string> languageMap;
/// <summary>
diff --git a/win/CS/HandBrake.Interop/Utilities/SystemInfo.cs b/win/CS/HandBrake.Interop/Utilities/SystemInfo.cs
index 6a0c72283..952d0b1c5 100644
--- a/win/CS/HandBrake.Interop/Utilities/SystemInfo.cs
+++ b/win/CS/HandBrake.Interop/Utilities/SystemInfo.cs
@@ -1,5 +1,5 @@
// --------------------------------------------------------------------------------------------------------------------
-// <copyright file="SystemInfo.cs" company="HandBrake Project (http://handbrake.fr)">
+// <copyright file="SystemInfo.cs" company="HandBrake Project (https://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>
@@ -12,26 +12,13 @@ namespace HandBrake.Interop.Utilities
using System;
using System.Diagnostics;
- using HandBrake.Interop.Interop.HbLib.Wrappers.Interfaces;
- using HandBrake.Interop.Interop.Providers;
- using HandBrake.Interop.Interop.Providers.Interfaces;
-
using Interop.HbLib;
public class SystemInfo
{
- private static bool? isNvencH264Available; // Local cache to prevent log spam.
+ 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();
- }
-
-
/* QuickSync Support */
public static bool IsQsvAvailable
@@ -40,7 +27,7 @@ namespace HandBrake.Interop.Utilities
{
try
{
- return hbFunctions.hb_qsv_available() != 0;
+ return HBFunctions.hb_qsv_available() != 0;
}
catch (Exception)
{
@@ -56,7 +43,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)
{
@@ -72,7 +59,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)
{
@@ -88,8 +75,8 @@ namespace HandBrake.Interop.Utilities
{
try
{
- int cpu_platform = hbFunctions.hb_get_cpu_platform();
- int hardware = hbFunctions.qsv_hardware_generation(cpu_platform);
+ int cpu_platform = HBFunctions.hb_get_cpu_platform();
+ int hardware = HBFunctions.qsv_hardware_generation(cpu_platform);
return hardware;
}
catch (Exception exc)
@@ -101,14 +88,13 @@ namespace HandBrake.Interop.Utilities
}
}
-
public static bool IsQsvAvailableH26510bit
{
get
{
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)
{
@@ -117,8 +103,7 @@ namespace HandBrake.Interop.Utilities
}
}
}
-
-
+
/* AMD VCE Support */
public static bool IsVceH264Available
@@ -127,7 +112,7 @@ namespace HandBrake.Interop.Utilities
{
try
{
- return hbFunctions.hb_vce_h264_available() != 0;
+ return HBFunctions.hb_vce_h264_available() != 0;
}
catch (Exception)
{
@@ -143,7 +128,7 @@ namespace HandBrake.Interop.Utilities
{
try
{
- return hbFunctions.hb_vce_h265_available() != 0;
+ return HBFunctions.hb_vce_h265_available() != 0;
}
catch (Exception)
{
@@ -163,7 +148,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;
@@ -189,7 +174,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 36a04fc63..6b381a6ee 100644
--- a/win/CS/HandBrake.Interop/Utilities/VersionHelper.cs
+++ b/win/CS/HandBrake.Interop/Utilities/VersionHelper.cs
@@ -1,5 +1,5 @@
// --------------------------------------------------------------------------------------------------------------------
-// <copyright file="VersionHelper.cs" company="HandBrake Project (http://handbrake.fr)">
+// <copyright file="VersionHelper.cs" company="HandBrake Project (https://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>
@@ -13,48 +13,9 @@ 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;
public class VersionHelper
{
- private static IHbFunctions hbFunctions;
-
- static VersionHelper()
- {
- IHbFunctionsProvider hbFunctionsProvider = new HbFunctionsProvider();
- hbFunctions = hbFunctionsProvider.GetHbFunctionsWrapper();
- }
-
- /// <summary>
- /// The get build.
- /// </summary>
- /// <returns>
- /// The <see cref="int"/>.
- /// </returns>
- public static string GetVersion()
- {
- return IsNightly() ? string.Format("Nightly {0} ({1})", Version, Build) : string.Format("{0} ({1})", Version, Build);
- }
-
- public static string GetVersionShort()
- {
- return string.Format("{0} {1}", Version, Build);
- }
-
- /// <summary>
- /// The is nightly.
- /// </summary>
- /// <returns>
- /// The <see cref="string"/>.
- /// </returns>
- public static bool IsNightly()
- {
- // 01 = Unofficial Builds. 00 = Official Tagged Releases.
- return Build.ToString().EndsWith("01");
- }
-
/// <summary>
/// Gets the HandBrake version string.
/// </summary>
@@ -62,7 +23,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);
}
}
@@ -74,8 +35,24 @@ namespace HandBrake.Interop.Utilities
{
get
{
- return hbFunctions.hb_get_build(IntPtr.Zero);
+ return HBFunctions.hb_get_build(IntPtr.Zero);
}
}
+
+ public static string GetVersion()
+ {
+ return IsNightly() ? string.Format("Nightly {0} ({1})", Version, Build) : string.Format("{0} ({1})", Version, Build);
+ }
+
+ public static string GetVersionShort()
+ {
+ return string.Format("{0} {1}", Version, Build);
+ }
+
+ public static bool IsNightly()
+ {
+ // 01 = Unofficial Builds. 00 = Official Tagged Releases.
+ return Build.ToString().EndsWith("01");
+ }
}
}