mirror of
https://github.com/cosyneco/MediaPipe.NET.git
synced 2025-08-25 01:00:27 +08:00

* Remove this bool marshal
* Literally remove all bool marshals
* Remove CharSet.Unicode warning
* Remove most FunctionPtr marshals
* Remove `[return: MarshalAs(...)]`
* Replace all `IntPtr`s with `void*`s
* Replace all `void*.Zero`s with `null`s
* Make native method classes unsafe
* U N S A F E
* Replace `PtrToStructure` with pointer arithmetic
* Run `dotnet format`
* Temp ugly Activator fix
* Remove `.ToPointer()`
* Use `byte` to return a `bool`
* Backwards compatibility with `Activator`
Yeah that sucks :(
* Replace `Marshal.Copy` by pointer arithmetic
* Replace `PtrToStringAnsi()` with `new string()`
* Remove unnecessary usings
* Explicitly type string pointers as `sbyte*`
* It actually doesn't hang?
* `MediaPipeException` -> `MediapipeException`
* Simplify `for` loops
* Remove unnecessary `float*` cast
* Some more explicit types for `ImageFrame`
* Remove unnecessary cast
* Looks like we forgor a `using` 💀
* Create `SafeArrayCopy` helper method
* Document `SafeArrayCopy`
71 lines
3.4 KiB
C#
71 lines
3.4 KiB
C#
// Copyright (c) homuler and Vignette
|
|
// This file is part of MediaPipe.NET.
|
|
// MediaPipe.NET is licensed under the MIT License. See LICENSE for details.
|
|
|
|
using System.Runtime.InteropServices;
|
|
using Mediapipe.Net.Framework.Format;
|
|
|
|
namespace Mediapipe.Net.Native
|
|
{
|
|
internal unsafe partial class UnsafeNativeMethods : NativeMethods
|
|
{
|
|
[DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
|
public static extern MpReturnCode mp_ImageFrame__(out void* imageFrame);
|
|
|
|
[DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
|
public static extern MpReturnCode mp_ImageFrame__ui_i_i_ui(
|
|
ImageFormat format, int width, int height, uint alignmentBoundary, out void* imageFrame);
|
|
|
|
[DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
|
public static extern MpReturnCode mp_ImageFrame__ui_i_i_i_Pui8_PF(
|
|
ImageFormat format, int width, int height, int widthStep, byte* pixelData,
|
|
ImageFrame.Deleter deleter, out void* imageFrame);
|
|
|
|
[DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
|
public static extern void mp_ImageFrame__delete(void* imageFrame);
|
|
|
|
[DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
|
public static extern MpReturnCode mp_ImageFrame__SetToZero(void* imageFrame);
|
|
|
|
[DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
|
public static extern MpReturnCode mp_ImageFrame__SetAlignmentPaddingAreas(void* imageFrame);
|
|
|
|
[DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
|
public static extern MpReturnCode mp_ImageFrame__CopyToBuffer__Pui8_i(void* imageFrame, byte* buffer, int bufferSize);
|
|
|
|
[DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
|
public static extern MpReturnCode mp_ImageFrame__CopyToBuffer__Pui16_i(void* imageFrame, ushort* buffer, int bufferSize);
|
|
|
|
[DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
|
public static extern MpReturnCode mp_ImageFrame__CopyToBuffer__Pf_i(void* imageFrame, float* buffer, int bufferSize);
|
|
|
|
#region StatusOr
|
|
[DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
|
public static extern void mp_StatusOrImageFrame__delete(void* statusOrImageFrame);
|
|
|
|
[DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
|
public static extern MpReturnCode mp_StatusOrImageFrame__status(void* statusOrImageFrame, out void* status);
|
|
|
|
[DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
|
public static extern MpReturnCode mp_StatusOrImageFrame__value(void* statusOrImageFrame, out void* imageFrame);
|
|
#endregion
|
|
|
|
#region Packet
|
|
[DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
|
public static extern MpReturnCode mp__MakeImageFramePacket__Pif(void* imageFrame, out void* packet);
|
|
|
|
[DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
|
public static extern MpReturnCode mp__MakeImageFramePacket_At__Pif_Rt(void* imageFrame, void* timestamp, out void* packet);
|
|
|
|
[DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
|
public static extern MpReturnCode mp_Packet__ConsumeImageFrame(void* packet, out void* statusOrImageFrame);
|
|
|
|
[DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
|
public static extern MpReturnCode mp_Packet__GetImageFrame(void* packet, out void* imageFrame);
|
|
|
|
[DllImport(MEDIAPIPE_LIBRARY, ExactSpelling = true)]
|
|
public static extern MpReturnCode mp_Packet__ValidateAsImageFrame(void* packet, out void* status);
|
|
#endregion
|
|
}
|
|
}
|