summaryrefslogtreecommitdiffstats
path: root/win/CS/HandBrake.Interop/HandBrakeInterop/InteropUtilities.cs
diff options
context:
space:
mode:
Diffstat (limited to 'win/CS/HandBrake.Interop/HandBrakeInterop/InteropUtilities.cs')
-rw-r--r--win/CS/HandBrake.Interop/HandBrakeInterop/InteropUtilities.cs21
1 files changed, 20 insertions, 1 deletions
diff --git a/win/CS/HandBrake.Interop/HandBrakeInterop/InteropUtilities.cs b/win/CS/HandBrake.Interop/HandBrakeInterop/InteropUtilities.cs
index db72feac5..de73dd607 100644
--- a/win/CS/HandBrake.Interop/HandBrakeInterop/InteropUtilities.cs
+++ b/win/CS/HandBrake.Interop/HandBrakeInterop/InteropUtilities.cs
@@ -37,7 +37,7 @@ namespace HandBrake.Interop
/// <typeparam name="T">The type of structure in the list.</typeparam>
/// <param name="listPtr">The pointer to the native list.</param>
/// <returns>The converted managed list.</returns>
- public static List<T> ConvertList<T>(IntPtr listPtr)
+ public static List<T> ToList<T>(this IntPtr listPtr)
{
List<T> returnList = new List<T>();
hb_list_s itemList = ReadStructure<hb_list_s>(listPtr);
@@ -52,6 +52,25 @@ namespace HandBrake.Interop
}
/// <summary>
+ /// Converts the HB list to a managed list of pointers.
+ /// </summary>
+ /// <param name="listPtr">The list to convert.</param>
+ /// <returns>The managed list of pointers.</returns>
+ public static List<IntPtr> ToIntPtrList(this IntPtr listPtr)
+ {
+ var returnList = new List<IntPtr>();
+ hb_list_s itemList = ReadStructure<hb_list_s>(listPtr);
+
+ for (int i = 0; i < itemList.items_count; i++)
+ {
+ IntPtr itemPtr = Marshal.ReadIntPtr(itemList.items, i * Marshal.SizeOf(typeof(IntPtr)));
+ returnList.Add(itemPtr);
+ }
+
+ return returnList;
+ }
+
+ /// <summary>
/// Converts the given native array to a managed collection.
/// </summary>
/// <typeparam name="T">The type of item in the list.</typeparam>