summaryrefslogtreecommitdiffstats
path: root/win/CS/HandBrake.Interop/HandBrakeInterop/InteropUtilities.cs
diff options
context:
space:
mode:
authorsr55 <[email protected]>2011-10-30 17:58:53 +0000
committersr55 <[email protected]>2011-10-30 17:58:53 +0000
commit8b8ebd1f417c6ef65ab431a36fad0bbf0e2daf58 (patch)
tree37637e767ceac63a4bb48b8a99c17b196128b846 /win/CS/HandBrake.Interop/HandBrakeInterop/InteropUtilities.cs
parent2f0f372b09897e703a8d01fe9774aa59c936a013 (diff)
Interop: Updates to the Interop Library to use the new methods to get at the Audio/Video encoder information from libhb. Patch by RandomEngy.
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@4329 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'win/CS/HandBrake.Interop/HandBrakeInterop/InteropUtilities.cs')
-rw-r--r--win/CS/HandBrake.Interop/HandBrakeInterop/InteropUtilities.cs49
1 files changed, 36 insertions, 13 deletions
diff --git a/win/CS/HandBrake.Interop/HandBrakeInterop/InteropUtilities.cs b/win/CS/HandBrake.Interop/HandBrakeInterop/InteropUtilities.cs
index 40c2571a9..3a36ddfc9 100644
--- a/win/CS/HandBrake.Interop/HandBrakeInterop/InteropUtilities.cs
+++ b/win/CS/HandBrake.Interop/HandBrakeInterop/InteropUtilities.cs
@@ -12,13 +12,13 @@ namespace HandBrake.Interop
using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;
-
- using HandBrake.Interop.HbLib;
-
- /// <summary>
- /// Helper utilities for native interop.
- /// </summary>
- public static class InteropUtilities
+
+ using HandBrake.Interop.HbLib;
+
+ /// <summary>
+ /// Helper utilities for native interop.
+ /// </summary>
+ public static class InteropUtilities
{
/// <summary>
/// Reads the given native structure pointer.
@@ -49,12 +49,35 @@ namespace HandBrake.Interop
}
return returnList;
- }
-
- /// <summary>
- /// Creats a new, empty native HandBrake list.
- /// </summary>
- /// <param name="capacity">The capacity of the new list.</param>
+ }
+
+ /// <summary>
+ /// Converts the given native array to a managed collection.
+ /// </summary>
+ /// <typeparam name="T">The type of item in the list.</typeparam>
+ /// <param name="arrayPtr">The pointer to the array.</param>
+ /// <param name="count">The number of items in the array.</param>
+ /// <returns>The converted collection.</returns>
+ public static IEnumerable<T> ConvertArray<T>(IntPtr arrayPtr, int count)
+ {
+ IntPtr currentItem = arrayPtr;
+
+ var result = new List<T>();
+ for (int i = 0; i < count; i++)
+ {
+ T nativeEncoder = ReadStructure<T>(currentItem);
+ result.Add(nativeEncoder);
+
+ currentItem = IntPtr.Add(currentItem, Marshal.SizeOf(typeof(T)));
+ }
+
+ return result;
+ }
+
+ /// <summary>
+ /// Creats a new, empty native HandBrake list.
+ /// </summary>
+ /// <param name="capacity">The capacity of the new list.</param>
/// <returns>The new native list.</returns>
public static NativeList CreateNativeList(int capacity)
{