[CoreVideo] Make P/Invokes in CVPixel related types have blittable signatures. (#20510)
Contributes towards #15684.
This commit is contained in:
Родитель
771453d8a4
Коммит
641475d328
|
@ -7,6 +7,7 @@
|
||||||
// Copyright 2011-2014 Xamarin Inc
|
// Copyright 2011-2014 Xamarin Inc
|
||||||
//
|
//
|
||||||
using System;
|
using System;
|
||||||
|
using System.Runtime.CompilerServices;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
using CoreFoundation;
|
using CoreFoundation;
|
||||||
using ObjCRuntime;
|
using ObjCRuntime;
|
||||||
|
@ -41,11 +42,11 @@ namespace CoreVideo {
|
||||||
|
|
||||||
#if !COREBUILD
|
#if !COREBUILD
|
||||||
[DllImport (Constants.CoreVideoLibrary)]
|
[DllImport (Constants.CoreVideoLibrary)]
|
||||||
extern static CVReturn CVPixelBufferCreate (
|
unsafe extern static CVReturn CVPixelBufferCreate (
|
||||||
/* CFAllocatorRef __nullable */ IntPtr allocator, /* size_t */ nint width, /* size_t */ nint height,
|
/* CFAllocatorRef __nullable */ IntPtr allocator, /* size_t */ nint width, /* size_t */ nint height,
|
||||||
/* OSType */ CVPixelFormatType pixelFormatType,
|
/* OSType */ CVPixelFormatType pixelFormatType,
|
||||||
/* CFDictionaryRef __nullable */ IntPtr pixelBufferAttributes,
|
/* CFDictionaryRef __nullable */ IntPtr pixelBufferAttributes,
|
||||||
/* CVPixelBufferRef __nullable * __nonnull */ out IntPtr pixelBufferOut);
|
/* CVPixelBufferRef __nullable * __nonnull */ IntPtr* pixelBufferOut);
|
||||||
|
|
||||||
public CVPixelBuffer (nint width, nint height, CVPixelFormatType pixelFormat)
|
public CVPixelBuffer (nint width, nint height, CVPixelFormatType pixelFormat)
|
||||||
: this (width, height, pixelFormat, (NSDictionary?) null)
|
: this (width, height, pixelFormat, (NSDictionary?) null)
|
||||||
|
@ -65,7 +66,11 @@ namespace CoreVideo {
|
||||||
if (height <= 0)
|
if (height <= 0)
|
||||||
throw new ArgumentOutOfRangeException (nameof (height));
|
throw new ArgumentOutOfRangeException (nameof (height));
|
||||||
|
|
||||||
var ret = CVPixelBufferCreate (IntPtr.Zero, width, height, pixelFormatType, pixelBufferAttributes.GetHandle (), out var handle);
|
CVReturn ret;
|
||||||
|
IntPtr handle;
|
||||||
|
unsafe {
|
||||||
|
ret = CVPixelBufferCreate (IntPtr.Zero, width, height, pixelFormatType, pixelBufferAttributes.GetHandle (), &handle);
|
||||||
|
}
|
||||||
|
|
||||||
if (ret != CVReturn.Success)
|
if (ret != CVReturn.Success)
|
||||||
throw new ArgumentException (ret.ToString ());
|
throw new ArgumentException (ret.ToString ());
|
||||||
|
@ -80,22 +85,20 @@ namespace CoreVideo {
|
||||||
}
|
}
|
||||||
|
|
||||||
[DllImport (Constants.CoreVideoLibrary)]
|
[DllImport (Constants.CoreVideoLibrary)]
|
||||||
extern static CVReturn CVPixelBufferCreateResolvedAttributesDictionary (
|
unsafe extern static CVReturn CVPixelBufferCreateResolvedAttributesDictionary (
|
||||||
/* CFAllocatorRef __nullable */ IntPtr allocator,
|
/* CFAllocatorRef __nullable */ IntPtr allocator,
|
||||||
/* CFArrayRef __nullable */ IntPtr attributes,
|
/* CFArrayRef __nullable */ IntPtr attributes,
|
||||||
/* CFDictionaryRef __nullable * __nonnull */ out IntPtr resolvedDictionaryOut);
|
/* CFDictionaryRef __nullable * __nonnull */ IntPtr* resolvedDictionaryOut);
|
||||||
|
|
||||||
public NSDictionary? GetAttributes (NSDictionary []? attributes)
|
public NSDictionary? GetAttributes (NSDictionary []? attributes)
|
||||||
{
|
{
|
||||||
CVReturn ret;
|
CVReturn ret;
|
||||||
IntPtr resolvedDictionaryOut;
|
IntPtr resolvedDictionaryOut;
|
||||||
if (attributes is null) {
|
var nsarray = NSArray.FromNSObjects (attributes);
|
||||||
ret = CVPixelBufferCreateResolvedAttributesDictionary (IntPtr.Zero, IntPtr.Zero, out resolvedDictionaryOut);
|
unsafe {
|
||||||
} else {
|
ret = CVPixelBufferCreateResolvedAttributesDictionary (IntPtr.Zero, nsarray.GetHandle (), &resolvedDictionaryOut);
|
||||||
using (var array = NSArray.FromNSObjects (attributes)) {
|
|
||||||
ret = CVPixelBufferCreateResolvedAttributesDictionary (IntPtr.Zero, array!.Handle, out resolvedDictionaryOut);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
GC.KeepAlive (nsarray);
|
||||||
if (ret != CVReturn.Success)
|
if (ret != CVReturn.Success)
|
||||||
throw new ArgumentException (ret.ToString ());
|
throw new ArgumentException (ret.ToString ());
|
||||||
return Runtime.GetNSObject<NSDictionary> (resolvedDictionaryOut);
|
return Runtime.GetNSObject<NSDictionary> (resolvedDictionaryOut);
|
||||||
|
@ -158,7 +161,6 @@ namespace CoreVideo {
|
||||||
handle.Free ();
|
handle.Free ();
|
||||||
}
|
}
|
||||||
|
|
||||||
#if NET
|
|
||||||
[DllImport (Constants.CoreVideoLibrary)]
|
[DllImport (Constants.CoreVideoLibrary)]
|
||||||
static unsafe extern CVReturn CVPixelBufferCreateWithBytes (
|
static unsafe extern CVReturn CVPixelBufferCreateWithBytes (
|
||||||
/* CFAllocatorRef CV_NULLABLE */ IntPtr allocator,
|
/* CFAllocatorRef CV_NULLABLE */ IntPtr allocator,
|
||||||
|
@ -167,24 +169,15 @@ namespace CoreVideo {
|
||||||
/* OSType */ CVPixelFormatType pixelFormatType,
|
/* OSType */ CVPixelFormatType pixelFormatType,
|
||||||
/* void * CV_NONNULL */ IntPtr baseAddress,
|
/* void * CV_NONNULL */ IntPtr baseAddress,
|
||||||
/* size_t */ nint bytesPerRow,
|
/* size_t */ nint bytesPerRow,
|
||||||
|
#if NET
|
||||||
delegate* unmanaged<IntPtr, IntPtr, void> releaseCallback,
|
delegate* unmanaged<IntPtr, IntPtr, void> releaseCallback,
|
||||||
/* void * CV_NULLABLE */ IntPtr releaseRefCon,
|
|
||||||
/* CFDictionaryRef CV_NULLABLE */ IntPtr pixelBufferAttributes,
|
|
||||||
/* CV_RETURNS_RETAINED_PARAMETER CVPixelBufferRef CV_NULLABLE * CV_NONNULL */ out IntPtr pixelBufferOut);// __OSX_AVAILABLE_STARTING(__MAC_10_4,__IPHONE_4_0);
|
|
||||||
#else
|
#else
|
||||||
[DllImport (Constants.CoreVideoLibrary)]
|
|
||||||
static extern CVReturn CVPixelBufferCreateWithBytes (
|
|
||||||
/* CFAllocatorRef CV_NULLABLE */ IntPtr allocator,
|
|
||||||
/* size_t */ nint width,
|
|
||||||
/* size_t */ nint height,
|
|
||||||
/* OSType */ CVPixelFormatType pixelFormatType,
|
|
||||||
/* void * CV_NONNULL */ IntPtr baseAddress,
|
|
||||||
/* size_t */ nint bytesPerRow,
|
|
||||||
CVPixelBufferReleaseBytesCallback /* CV_NULLABLE */ releaseCallback,
|
CVPixelBufferReleaseBytesCallback /* CV_NULLABLE */ releaseCallback,
|
||||||
|
#endif
|
||||||
/* void * CV_NULLABLE */ IntPtr releaseRefCon,
|
/* void * CV_NULLABLE */ IntPtr releaseRefCon,
|
||||||
/* CFDictionaryRef CV_NULLABLE */ IntPtr pixelBufferAttributes,
|
/* CFDictionaryRef CV_NULLABLE */ IntPtr pixelBufferAttributes,
|
||||||
/* CV_RETURNS_RETAINED_PARAMETER CVPixelBufferRef CV_NULLABLE * CV_NONNULL */ out IntPtr pixelBufferOut);// __OSX_AVAILABLE_STARTING(__MAC_10_4,__IPHONE_4_0);
|
/* CV_RETURNS_RETAINED_PARAMETER CVPixelBufferRef CV_NULLABLE * CV_NONNULL */ IntPtr* pixelBufferOut);// __OSX_AVAILABLE_STARTING(__MAC_10_4,__IPHONE_4_0);
|
||||||
#endif
|
|
||||||
public static CVPixelBuffer? Create (nint width, nint height, CVPixelFormatType pixelFormatType, byte [] data, nint bytesPerRow, CVPixelBufferAttributes pixelBufferAttributes)
|
public static CVPixelBuffer? Create (nint width, nint height, CVPixelFormatType pixelFormatType, byte [] data, nint bytesPerRow, CVPixelBufferAttributes pixelBufferAttributes)
|
||||||
{
|
{
|
||||||
CVReturn status;
|
CVReturn status;
|
||||||
|
@ -204,13 +197,22 @@ namespace CoreVideo {
|
||||||
|
|
||||||
gchandle = GCHandle.Alloc (data, GCHandleType.Pinned); // This requires a pinned GCHandle, because unsafe code is scoped to the current block, and the address of the byte array will be used after this function returns.
|
gchandle = GCHandle.Alloc (data, GCHandleType.Pinned); // This requires a pinned GCHandle, because unsafe code is scoped to the current block, and the address of the byte array will be used after this function returns.
|
||||||
|
|
||||||
#if NET
|
|
||||||
unsafe {
|
unsafe {
|
||||||
status = CVPixelBufferCreateWithBytes (IntPtr.Zero, width, height, pixelFormatType, gchandle.AddrOfPinnedObject (), bytesPerRow, &ReleaseBytesCallback, GCHandle.ToIntPtr (gchandle), DictionaryContainerHelper.GetHandle (pixelBufferAttributes), out handle);
|
status = CVPixelBufferCreateWithBytes (
|
||||||
}
|
IntPtr.Zero,
|
||||||
|
width, height,
|
||||||
|
pixelFormatType,
|
||||||
|
gchandle.AddrOfPinnedObject (),
|
||||||
|
bytesPerRow,
|
||||||
|
#if NET
|
||||||
|
&ReleaseBytesCallback,
|
||||||
#else
|
#else
|
||||||
status = CVPixelBufferCreateWithBytes (IntPtr.Zero, width, height, pixelFormatType, gchandle.AddrOfPinnedObject (), bytesPerRow, releaseBytesCallback, GCHandle.ToIntPtr (gchandle), DictionaryContainerHelper.GetHandle (pixelBufferAttributes), out handle);
|
releaseBytesCallback,
|
||||||
#endif
|
#endif
|
||||||
|
GCHandle.ToIntPtr (gchandle),
|
||||||
|
DictionaryContainerHelper.GetHandle (pixelBufferAttributes),
|
||||||
|
&handle);
|
||||||
|
}
|
||||||
|
|
||||||
if (status != CVReturn.Success) {
|
if (status != CVReturn.Success) {
|
||||||
gchandle.Free ();
|
gchandle.Free ();
|
||||||
|
@ -254,7 +256,6 @@ namespace CoreVideo {
|
||||||
ReleasePlanarBytesCallbackImpl (releaseRefCon, dataPtr, dataSize, numberOfPlanes, planeAddresses);
|
ReleasePlanarBytesCallbackImpl (releaseRefCon, dataPtr, dataSize, numberOfPlanes, planeAddresses);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if NET
|
|
||||||
[DllImport (Constants.CoreVideoLibrary)]
|
[DllImport (Constants.CoreVideoLibrary)]
|
||||||
static unsafe extern CVReturn CVPixelBufferCreateWithPlanarBytes (
|
static unsafe extern CVReturn CVPixelBufferCreateWithPlanarBytes (
|
||||||
/* CFAllocatorRef CV_NULLABLE */ IntPtr allocator,
|
/* CFAllocatorRef CV_NULLABLE */ IntPtr allocator,
|
||||||
|
@ -264,34 +265,18 @@ namespace CoreVideo {
|
||||||
/* void * CV_NULLABLE */ IntPtr dataPtr, /* pass a pointer to a plane descriptor block, or NULL /*
|
/* void * CV_NULLABLE */ IntPtr dataPtr, /* pass a pointer to a plane descriptor block, or NULL /*
|
||||||
/* size_t */ nint dataSize, /* pass size if planes are contiguous, NULL if not */
|
/* size_t */ nint dataSize, /* pass size if planes are contiguous, NULL if not */
|
||||||
/* size_t */ nint numberOfPlanes,
|
/* size_t */ nint numberOfPlanes,
|
||||||
/* void *[] CV_NULLABLE */ IntPtr[] planeBaseAddress,
|
/* void *[] CV_NULLABLE */ IntPtr* planeBaseAddress,
|
||||||
/* size_t[] */ nint [] planeWidth,
|
/* size_t[] */ nint* planeWidth,
|
||||||
/* size_t[] */ nint [] planeHeight,
|
/* size_t[] */ nint* planeHeight,
|
||||||
/* size_t[] */ nint [] planeBytesPerRow,
|
/* size_t[] */ nint* planeBytesPerRow,
|
||||||
|
#if NET
|
||||||
delegate* unmanaged<IntPtr, IntPtr, nint, nint, IntPtr, void>/* CV_NULLABLE */ releaseCallback,
|
delegate* unmanaged<IntPtr, IntPtr, nint, nint, IntPtr, void>/* CV_NULLABLE */ releaseCallback,
|
||||||
/* void * CV_NULLABLE */ IntPtr releaseRefCon,
|
|
||||||
/* CFDictionaryRef CV_NULLABLE */ IntPtr pixelBufferAttributes,
|
|
||||||
/* CV_RETURNS_RETAINED_PARAMETER CVPixelBufferRef CV_NULLABLE * CV_NONNULL */ out IntPtr pixelBufferOut); // __OSX_AVAILABLE_STARTING(__MAC_10_4,__IPHONE_4_0);
|
|
||||||
|
|
||||||
#else
|
#else
|
||||||
[DllImport (Constants.CoreVideoLibrary)]
|
|
||||||
static extern CVReturn CVPixelBufferCreateWithPlanarBytes (
|
|
||||||
/* CFAllocatorRef CV_NULLABLE */ IntPtr allocator,
|
|
||||||
/* size_t */ nint width,
|
|
||||||
/* size_t */ nint height,
|
|
||||||
/* OSType */ CVPixelFormatType pixelFormatType,
|
|
||||||
/* void * CV_NULLABLE */ IntPtr dataPtr, /* pass a pointer to a plane descriptor block, or NULL /*
|
|
||||||
/* size_t */ nint dataSize, /* pass size if planes are contiguous, NULL if not */
|
|
||||||
/* size_t */ nint numberOfPlanes,
|
|
||||||
/* void *[] CV_NULLABLE */ IntPtr [] planeBaseAddress,
|
|
||||||
/* size_t[] */ nint [] planeWidth,
|
|
||||||
/* size_t[] */ nint [] planeHeight,
|
|
||||||
/* size_t[] */ nint [] planeBytesPerRow,
|
|
||||||
CVPixelBufferReleasePlanarBytesCallback /* CV_NULLABLE */ releaseCallback,
|
CVPixelBufferReleasePlanarBytesCallback /* CV_NULLABLE */ releaseCallback,
|
||||||
|
#endif
|
||||||
/* void * CV_NULLABLE */ IntPtr releaseRefCon,
|
/* void * CV_NULLABLE */ IntPtr releaseRefCon,
|
||||||
/* CFDictionaryRef CV_NULLABLE */ IntPtr pixelBufferAttributes,
|
/* CFDictionaryRef CV_NULLABLE */ IntPtr pixelBufferAttributes,
|
||||||
/* CV_RETURNS_RETAINED_PARAMETER CVPixelBufferRef CV_NULLABLE * CV_NONNULL */ out IntPtr pixelBufferOut); // __OSX_AVAILABLE_STARTING(__MAC_10_4,__IPHONE_4_0);
|
/* CV_RETURNS_RETAINED_PARAMETER CVPixelBufferRef CV_NULLABLE * CV_NONNULL */ IntPtr* pixelBufferOut); // __OSX_AVAILABLE_STARTING(__MAC_10_4,__IPHONE_4_0);
|
||||||
#endif
|
|
||||||
|
|
||||||
public static CVPixelBuffer? Create (nint width, nint height, CVPixelFormatType pixelFormatType, byte [] [] planes, nint [] planeWidths, nint [] planeHeights, nint [] planeBytesPerRow, CVPixelBufferAttributes pixelBufferAttributes)
|
public static CVPixelBuffer? Create (nint width, nint height, CVPixelFormatType pixelFormatType, byte [] [] planes, nint [] planeWidths, nint [] planeHeights, nint [] planeBytesPerRow, CVPixelBufferAttributes pixelBufferAttributes)
|
||||||
{
|
{
|
||||||
|
@ -339,21 +324,32 @@ namespace CoreVideo {
|
||||||
data_handle = GCHandle.Alloc (data);
|
data_handle = GCHandle.Alloc (data);
|
||||||
|
|
||||||
IntPtr data_handle_ptr = GCHandle.ToIntPtr (data_handle);
|
IntPtr data_handle_ptr = GCHandle.ToIntPtr (data_handle);
|
||||||
#if NET
|
|
||||||
unsafe {
|
unsafe {
|
||||||
status = CVPixelBufferCreateWithPlanarBytes (IntPtr.Zero,
|
fixed (IntPtr* addressesPtr = addresses) {
|
||||||
width, height, pixelFormatType, IntPtr.Zero, 0,
|
fixed (nint* planeWidthsPtr = planeWidths) {
|
||||||
planeCount, addresses, planeWidths, planeHeights, planeBytesPerRow,
|
fixed (nint* planeHeightsPtr = planeHeights) {
|
||||||
&ReleasePlanarBytesCallback, data_handle_ptr,
|
fixed (nint* planeBytesPerRowPtr = planeBytesPerRow) {
|
||||||
DictionaryContainerHelper.GetHandle (pixelBufferAttributes), out handle);
|
status = CVPixelBufferCreateWithPlanarBytes (
|
||||||
}
|
IntPtr.Zero,
|
||||||
|
width, height, pixelFormatType, IntPtr.Zero, 0,
|
||||||
|
planeCount,
|
||||||
|
addressesPtr,
|
||||||
|
planeWidthsPtr,
|
||||||
|
planeHeightsPtr,
|
||||||
|
planeBytesPerRowPtr,
|
||||||
|
#if NET
|
||||||
|
&ReleasePlanarBytesCallback,
|
||||||
#else
|
#else
|
||||||
status = CVPixelBufferCreateWithPlanarBytes (IntPtr.Zero,
|
releasePlanarBytesCallback,
|
||||||
width, height, pixelFormatType, IntPtr.Zero, 0,
|
|
||||||
planeCount, addresses, planeWidths, planeHeights, planeBytesPerRow,
|
|
||||||
releasePlanarBytesCallback, data_handle_ptr,
|
|
||||||
DictionaryContainerHelper.GetHandle (pixelBufferAttributes), out handle);
|
|
||||||
#endif
|
#endif
|
||||||
|
data_handle_ptr,
|
||||||
|
DictionaryContainerHelper.GetHandle (pixelBufferAttributes),
|
||||||
|
&handle);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (status != CVReturn.Success) {
|
if (status != CVReturn.Success) {
|
||||||
ReleasePlanarBytesCallbackImpl (data_handle_ptr, IntPtr.Zero, 0, 0, IntPtr.Zero);
|
ReleasePlanarBytesCallbackImpl (data_handle_ptr, IntPtr.Zero, 0, 0, IntPtr.Zero);
|
||||||
|
@ -364,15 +360,20 @@ namespace CoreVideo {
|
||||||
}
|
}
|
||||||
|
|
||||||
[DllImport (Constants.CoreVideoLibrary)]
|
[DllImport (Constants.CoreVideoLibrary)]
|
||||||
static extern void CVPixelBufferGetExtendedPixels (/* CVPixelBufferRef __nonnull */ IntPtr pixelBuffer,
|
unsafe static extern void CVPixelBufferGetExtendedPixels (/* CVPixelBufferRef __nonnull */ IntPtr pixelBuffer,
|
||||||
/* size_t* */ ref nuint extraColumnsOnLeft, /* size_t* */ ref nuint extraColumnsOnRight,
|
/* size_t* */ nuint* extraColumnsOnLeft, /* size_t* */ nuint* extraColumnsOnRight,
|
||||||
/* size_t* */ ref nuint extraRowsOnTop, /* size_t* */ ref nuint extraRowsOnBottom);
|
/* size_t* */ nuint* extraRowsOnTop, /* size_t* */ nuint* extraRowsOnBottom);
|
||||||
|
|
||||||
public void GetExtendedPixels (ref nuint extraColumnsOnLeft, ref nuint extraColumnsOnRight,
|
public void GetExtendedPixels (ref nuint extraColumnsOnLeft, ref nuint extraColumnsOnRight,
|
||||||
ref nuint extraRowsOnTop, ref nuint extraRowsOnBottom)
|
ref nuint extraRowsOnTop, ref nuint extraRowsOnBottom)
|
||||||
{
|
{
|
||||||
CVPixelBufferGetExtendedPixels (Handle, ref extraColumnsOnLeft, ref extraColumnsOnRight,
|
unsafe {
|
||||||
ref extraRowsOnTop, ref extraRowsOnBottom);
|
CVPixelBufferGetExtendedPixels (Handle,
|
||||||
|
(nuint*) Unsafe.AsPointer<nuint> (ref extraColumnsOnLeft),
|
||||||
|
(nuint*) Unsafe.AsPointer<nuint> (ref extraColumnsOnRight),
|
||||||
|
(nuint*) Unsafe.AsPointer<nuint> (ref extraRowsOnTop),
|
||||||
|
(nuint*) Unsafe.AsPointer<nuint> (ref extraRowsOnBottom));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[DllImport (Constants.CoreVideoLibrary)]
|
[DllImport (Constants.CoreVideoLibrary)]
|
||||||
|
@ -442,12 +443,11 @@ namespace CoreVideo {
|
||||||
}
|
}
|
||||||
|
|
||||||
[DllImport (Constants.CoreVideoLibrary)]
|
[DllImport (Constants.CoreVideoLibrary)]
|
||||||
[return: MarshalAs (UnmanagedType.I1)]
|
extern static /* Boolean */ byte CVPixelBufferIsPlanar (/* CVPixelBufferRef __nonnull */ IntPtr pixelBuffer);
|
||||||
extern static /* Boolean */ bool CVPixelBufferIsPlanar (/* CVPixelBufferRef __nonnull */ IntPtr pixelBuffer);
|
|
||||||
|
|
||||||
public bool IsPlanar {
|
public bool IsPlanar {
|
||||||
get {
|
get {
|
||||||
return CVPixelBufferIsPlanar (Handle);
|
return CVPixelBufferIsPlanar (Handle) != 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -60,11 +60,11 @@ namespace CoreVideo {
|
||||||
[NoWatch]
|
[NoWatch]
|
||||||
#endif
|
#endif
|
||||||
[DllImport (Constants.CoreVideoLibrary)]
|
[DllImport (Constants.CoreVideoLibrary)]
|
||||||
extern static CVReturn /* IOSurfaceRef */ CVPixelBufferCreateWithIOSurface (
|
unsafe extern static CVReturn /* IOSurfaceRef */ CVPixelBufferCreateWithIOSurface (
|
||||||
/* CFAllocatorRef CV_NULLABLE */ IntPtr allocator,
|
/* CFAllocatorRef CV_NULLABLE */ IntPtr allocator,
|
||||||
/* IOSurfaceRef CV_NONNULL */ IntPtr surface,
|
/* IOSurfaceRef CV_NONNULL */ IntPtr surface,
|
||||||
/* CFDictionaryRef CV_NULLABLE */ IntPtr pixelBufferAttributes,
|
/* CFDictionaryRef CV_NULLABLE */ IntPtr pixelBufferAttributes,
|
||||||
/* CVPixelBufferRef CV_NULLABLE * CV_NONNULL */ out IntPtr pixelBufferOut
|
/* CVPixelBufferRef CV_NULLABLE * CV_NONNULL */ IntPtr* pixelBufferOut
|
||||||
);
|
);
|
||||||
|
|
||||||
#if NET
|
#if NET
|
||||||
|
@ -81,12 +81,14 @@ namespace CoreVideo {
|
||||||
ObjCRuntime.ThrowHelper.ThrowArgumentNullException (nameof (surface));
|
ObjCRuntime.ThrowHelper.ThrowArgumentNullException (nameof (surface));
|
||||||
|
|
||||||
IntPtr pixelBufferPtr;
|
IntPtr pixelBufferPtr;
|
||||||
result = CVPixelBufferCreateWithIOSurface (
|
unsafe {
|
||||||
allocator: IntPtr.Zero,
|
result = CVPixelBufferCreateWithIOSurface (
|
||||||
surface: surface.Handle,
|
allocator: IntPtr.Zero,
|
||||||
pixelBufferAttributes: pixelBufferAttributes?.Dictionary.Handle ?? IntPtr.Zero,
|
surface: surface.Handle,
|
||||||
pixelBufferOut: out pixelBufferPtr
|
pixelBufferAttributes: pixelBufferAttributes?.Dictionary.Handle ?? IntPtr.Zero,
|
||||||
);
|
pixelBufferOut: &pixelBufferPtr
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
if (result != CVReturn.Success)
|
if (result != CVReturn.Success)
|
||||||
return null;
|
return null;
|
||||||
|
|
|
@ -93,14 +93,18 @@ namespace CoreVideo {
|
||||||
}
|
}
|
||||||
|
|
||||||
[DllImport (Constants.CoreVideoLibrary)]
|
[DllImport (Constants.CoreVideoLibrary)]
|
||||||
extern static CVReturn CVPixelBufferPoolCreatePixelBuffer (
|
unsafe extern static CVReturn CVPixelBufferPoolCreatePixelBuffer (
|
||||||
/* CFAllocatorRef __nullable */ IntPtr allocator,
|
/* CFAllocatorRef __nullable */ IntPtr allocator,
|
||||||
/* CVPixelBufferPoolRef __nonnull */ IntPtr pixelBufferPool,
|
/* CVPixelBufferPoolRef __nonnull */ IntPtr pixelBufferPool,
|
||||||
/* CVPixelBufferRef __nullable * __nonnull */ out IntPtr pixelBufferOut);
|
/* CVPixelBufferRef __nullable * __nonnull */ IntPtr* pixelBufferOut);
|
||||||
|
|
||||||
public CVPixelBuffer CreatePixelBuffer ()
|
public CVPixelBuffer CreatePixelBuffer ()
|
||||||
{
|
{
|
||||||
var ret = CVPixelBufferPoolCreatePixelBuffer (IntPtr.Zero, Handle, out var pixelBufferOut);
|
CVReturn ret;
|
||||||
|
IntPtr pixelBufferOut;
|
||||||
|
unsafe {
|
||||||
|
ret = CVPixelBufferPoolCreatePixelBuffer (IntPtr.Zero, Handle, &pixelBufferOut);
|
||||||
|
}
|
||||||
|
|
||||||
if (ret != CVReturn.Success)
|
if (ret != CVReturn.Success)
|
||||||
throw new Exception ("CVPixelBufferPoolCreatePixelBuffer returned " + ret.ToString ());
|
throw new Exception ("CVPixelBufferPoolCreatePixelBuffer returned " + ret.ToString ());
|
||||||
|
@ -109,15 +113,18 @@ namespace CoreVideo {
|
||||||
}
|
}
|
||||||
|
|
||||||
[DllImport (Constants.CoreVideoLibrary)]
|
[DllImport (Constants.CoreVideoLibrary)]
|
||||||
extern static CVReturn CVPixelBufferPoolCreatePixelBufferWithAuxAttributes (
|
unsafe extern static CVReturn CVPixelBufferPoolCreatePixelBufferWithAuxAttributes (
|
||||||
/* CFAllocatorRef __nullable */ IntPtr allocator,
|
/* CFAllocatorRef __nullable */ IntPtr allocator,
|
||||||
/* CVPixelBufferPoolRef __nonnull */ IntPtr pixelBufferPool,
|
/* CVPixelBufferPoolRef __nonnull */ IntPtr pixelBufferPool,
|
||||||
/* CFDictionaryRef __nullable */ IntPtr auxAttributes,
|
/* CFDictionaryRef __nullable */ IntPtr auxAttributes,
|
||||||
/* CVPixelBufferRef __nullable * __nonnull */ out IntPtr pixelBufferOut);
|
/* CVPixelBufferRef __nullable * __nonnull */ IntPtr* pixelBufferOut);
|
||||||
|
|
||||||
public CVPixelBuffer? CreatePixelBuffer (CVPixelBufferPoolAllocationSettings? allocationSettings, out CVReturn error)
|
public CVPixelBuffer? CreatePixelBuffer (CVPixelBufferPoolAllocationSettings? allocationSettings, out CVReturn error)
|
||||||
{
|
{
|
||||||
error = CVPixelBufferPoolCreatePixelBufferWithAuxAttributes (IntPtr.Zero, Handle, allocationSettings.GetHandle (), out var pb);
|
IntPtr pb;
|
||||||
|
unsafe {
|
||||||
|
error = CVPixelBufferPoolCreatePixelBufferWithAuxAttributes (IntPtr.Zero, Handle, allocationSettings.GetHandle (), &pb);
|
||||||
|
}
|
||||||
if (error != CVReturn.Success)
|
if (error != CVReturn.Success)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
|
@ -125,14 +132,18 @@ namespace CoreVideo {
|
||||||
}
|
}
|
||||||
|
|
||||||
[DllImport (Constants.CoreVideoLibrary)]
|
[DllImport (Constants.CoreVideoLibrary)]
|
||||||
extern static CVReturn CVPixelBufferPoolCreate (/* CFAllocatorRef __nullable */ IntPtr allocator,
|
unsafe extern static CVReturn CVPixelBufferPoolCreate (/* CFAllocatorRef __nullable */ IntPtr allocator,
|
||||||
/* CFDictionaryRef __nullable */ IntPtr poolAttributes,
|
/* CFDictionaryRef __nullable */ IntPtr poolAttributes,
|
||||||
/* CFDictionaryRef __nullable */ IntPtr pixelBufferAttributes,
|
/* CFDictionaryRef __nullable */ IntPtr pixelBufferAttributes,
|
||||||
/* CVPixelBufferPoolRef __nullable * __nonnull */ out IntPtr poolOut);
|
/* CVPixelBufferPoolRef __nullable * __nonnull */ IntPtr* poolOut);
|
||||||
|
|
||||||
static IntPtr Create (NSDictionary? poolAttributes, NSDictionary? pixelBufferAttributes)
|
static IntPtr Create (NSDictionary? poolAttributes, NSDictionary? pixelBufferAttributes)
|
||||||
{
|
{
|
||||||
var ret = CVPixelBufferPoolCreate (IntPtr.Zero, poolAttributes.GetHandle (), pixelBufferAttributes.GetHandle (), out var handle);
|
CVReturn ret;
|
||||||
|
IntPtr handle;
|
||||||
|
unsafe {
|
||||||
|
ret = CVPixelBufferPoolCreate (IntPtr.Zero, poolAttributes.GetHandle (), pixelBufferAttributes.GetHandle (), &handle);
|
||||||
|
}
|
||||||
|
|
||||||
if (ret != CVReturn.Success)
|
if (ret != CVReturn.Success)
|
||||||
throw new Exception ("CVPixelBufferPoolCreate returned " + ret.ToString ());
|
throw new Exception ("CVPixelBufferPoolCreate returned " + ret.ToString ());
|
||||||
|
|
|
@ -146,8 +146,7 @@ namespace CoreVideo {
|
||||||
[MacCatalyst (15, 0)]
|
[MacCatalyst (15, 0)]
|
||||||
#endif
|
#endif
|
||||||
[DllImport (Constants.CoreVideoLibrary)]
|
[DllImport (Constants.CoreVideoLibrary)]
|
||||||
[return: MarshalAs (UnmanagedType.I1)]
|
static extern byte CVIsCompressedPixelFormatAvailable (uint pixelFormatType);
|
||||||
static extern bool CVIsCompressedPixelFormatAvailable (uint pixelFormatType);
|
|
||||||
|
|
||||||
#if NET
|
#if NET
|
||||||
[SupportedOSPlatform ("tvos15.0")]
|
[SupportedOSPlatform ("tvos15.0")]
|
||||||
|
@ -162,7 +161,7 @@ namespace CoreVideo {
|
||||||
[MacCatalyst (15, 0)]
|
[MacCatalyst (15, 0)]
|
||||||
#endif
|
#endif
|
||||||
public static bool IsCompressedPixelFormatAvailable (this CVPixelFormatType type)
|
public static bool IsCompressedPixelFormatAvailable (this CVPixelFormatType type)
|
||||||
=> CVIsCompressedPixelFormatAvailable ((uint) type);
|
=> CVIsCompressedPixelFormatAvailable ((uint) type) != 0;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
|
@ -64,14 +64,6 @@ namespace Cecil.Tests {
|
||||||
"AVFoundation.AVSampleCursorSyncInfo ObjCRuntime.Messaging::AVSampleCursorSyncInfo_objc_msgSend(System.IntPtr,System.IntPtr)",
|
"AVFoundation.AVSampleCursorSyncInfo ObjCRuntime.Messaging::AVSampleCursorSyncInfo_objc_msgSend(System.IntPtr,System.IntPtr)",
|
||||||
"AVFoundation.AVSampleCursorSyncInfo ObjCRuntime.Messaging::AVSampleCursorSyncInfo_objc_msgSendSuper_stret(System.IntPtr,System.IntPtr)",
|
"AVFoundation.AVSampleCursorSyncInfo ObjCRuntime.Messaging::AVSampleCursorSyncInfo_objc_msgSendSuper_stret(System.IntPtr,System.IntPtr)",
|
||||||
"AVFoundation.AVSampleCursorSyncInfo ObjCRuntime.Messaging::AVSampleCursorSyncInfo_objc_msgSendSuper(System.IntPtr,System.IntPtr)",
|
"AVFoundation.AVSampleCursorSyncInfo ObjCRuntime.Messaging::AVSampleCursorSyncInfo_objc_msgSendSuper(System.IntPtr,System.IntPtr)",
|
||||||
"CoreVideo.CVReturn CoreVideo.CVPixelBuffer::CVPixelBufferCreate(System.IntPtr,System.IntPtr,System.IntPtr,CoreVideo.CVPixelFormatType,System.IntPtr,System.IntPtr&)",
|
|
||||||
"CoreVideo.CVReturn CoreVideo.CVPixelBuffer::CVPixelBufferCreateResolvedAttributesDictionary(System.IntPtr,System.IntPtr,System.IntPtr&)",
|
|
||||||
"CoreVideo.CVReturn CoreVideo.CVPixelBuffer::CVPixelBufferCreateWithBytes(System.IntPtr,System.IntPtr,System.IntPtr,CoreVideo.CVPixelFormatType,System.IntPtr,System.IntPtr,method System.Void *(System.IntPtr,System.IntPtr),System.IntPtr,System.IntPtr,System.IntPtr&)",
|
|
||||||
"CoreVideo.CVReturn CoreVideo.CVPixelBuffer::CVPixelBufferCreateWithIOSurface(System.IntPtr,System.IntPtr,System.IntPtr,System.IntPtr&)",
|
|
||||||
"CoreVideo.CVReturn CoreVideo.CVPixelBuffer::CVPixelBufferCreateWithPlanarBytes(System.IntPtr,System.IntPtr,System.IntPtr,CoreVideo.CVPixelFormatType,System.IntPtr,System.IntPtr,System.IntPtr,System.IntPtr[],System.IntPtr[],System.IntPtr[],System.IntPtr[],method System.Void *(System.IntPtr,System.IntPtr,System.IntPtr,System.IntPtr,System.IntPtr),System.IntPtr,System.IntPtr,System.IntPtr&)",
|
|
||||||
"CoreVideo.CVReturn CoreVideo.CVPixelBufferPool::CVPixelBufferPoolCreate(System.IntPtr,System.IntPtr,System.IntPtr,System.IntPtr&)",
|
|
||||||
"CoreVideo.CVReturn CoreVideo.CVPixelBufferPool::CVPixelBufferPoolCreatePixelBuffer(System.IntPtr,System.IntPtr,System.IntPtr&)",
|
|
||||||
"CoreVideo.CVReturn CoreVideo.CVPixelBufferPool::CVPixelBufferPoolCreatePixelBufferWithAuxAttributes(System.IntPtr,System.IntPtr,System.IntPtr,System.IntPtr&)",
|
|
||||||
"GLKit.GLKVertexAttributeParameters GLKit.GLKVertexAttributeParameters::FromVertexFormat_(System.UIntPtr)",
|
"GLKit.GLKVertexAttributeParameters GLKit.GLKVertexAttributeParameters::FromVertexFormat_(System.UIntPtr)",
|
||||||
"MediaToolbox.MTAudioProcessingTapError MediaToolbox.MTAudioProcessingTap::MTAudioProcessingTapCreate(System.IntPtr,MediaToolbox.MTAudioProcessingTap/Callbacks&,MediaToolbox.MTAudioProcessingTapCreationFlags,System.IntPtr&)",
|
"MediaToolbox.MTAudioProcessingTapError MediaToolbox.MTAudioProcessingTap::MTAudioProcessingTapCreate(System.IntPtr,MediaToolbox.MTAudioProcessingTap/Callbacks&,MediaToolbox.MTAudioProcessingTapCreationFlags,System.IntPtr&)",
|
||||||
"MediaToolbox.MTAudioProcessingTapError MediaToolbox.MTAudioProcessingTap::MTAudioProcessingTapGetSourceAudio(System.IntPtr,System.IntPtr,System.IntPtr,MediaToolbox.MTAudioProcessingTapFlags&,CoreMedia.CMTimeRange&,System.IntPtr&)",
|
"MediaToolbox.MTAudioProcessingTapError MediaToolbox.MTAudioProcessingTap::MTAudioProcessingTapGetSourceAudio(System.IntPtr,System.IntPtr,System.IntPtr,MediaToolbox.MTAudioProcessingTapFlags&,CoreMedia.CMTimeRange&,System.IntPtr&)",
|
||||||
|
@ -152,8 +144,6 @@ namespace Cecil.Tests {
|
||||||
"Security.SslStatus Security.SslContext::SSLRead(System.IntPtr,System.Byte*,System.IntPtr,System.IntPtr&)",
|
"Security.SslStatus Security.SslContext::SSLRead(System.IntPtr,System.Byte*,System.IntPtr,System.IntPtr&)",
|
||||||
"Security.SslStatus Security.SslContext::SSLSetSessionOption(System.IntPtr,Security.SslSessionOption,System.Boolean)",
|
"Security.SslStatus Security.SslContext::SSLSetSessionOption(System.IntPtr,Security.SslSessionOption,System.Boolean)",
|
||||||
"Security.SslStatus Security.SslContext::SSLWrite(System.IntPtr,System.Byte*,System.IntPtr,System.IntPtr&)",
|
"Security.SslStatus Security.SslContext::SSLWrite(System.IntPtr,System.Byte*,System.IntPtr,System.IntPtr&)",
|
||||||
"System.Boolean CoreVideo.CVPixelBuffer::CVPixelBufferIsPlanar(System.IntPtr)",
|
|
||||||
"System.Boolean CoreVideo.CVPixelFormatTypeExtensions::CVIsCompressedPixelFormatAvailable(System.UInt32)",
|
|
||||||
"System.Boolean Foundation.NSObject::xamarin_set_gchandle_with_flags_safe(System.IntPtr,System.IntPtr,Foundation.NSObject/XamarinGCHandleFlags)",
|
"System.Boolean Foundation.NSObject::xamarin_set_gchandle_with_flags_safe(System.IntPtr,System.IntPtr,Foundation.NSObject/XamarinGCHandleFlags)",
|
||||||
"System.Boolean GameController.GCExtendedGamepadSnapshot::GCExtendedGamepadSnapshotDataFromNSData(GameController.GCExtendedGamepadSnapshotData&,System.IntPtr)",
|
"System.Boolean GameController.GCExtendedGamepadSnapshot::GCExtendedGamepadSnapshotDataFromNSData(GameController.GCExtendedGamepadSnapshotData&,System.IntPtr)",
|
||||||
"System.Boolean GameController.GCExtendedGamepadSnapshot::GCExtendedGamepadSnapShotDataV100FromNSData(GameController.GCExtendedGamepadSnapShotDataV100&,System.IntPtr)",
|
"System.Boolean GameController.GCExtendedGamepadSnapshot::GCExtendedGamepadSnapShotDataV100FromNSData(GameController.GCExtendedGamepadSnapShotDataV100&,System.IntPtr)",
|
||||||
|
@ -254,7 +244,6 @@ namespace Cecil.Tests {
|
||||||
"System.IntPtr Security.SecKey::SecKeyCreateSignature(System.IntPtr,System.IntPtr,System.IntPtr,System.IntPtr&)",
|
"System.IntPtr Security.SecKey::SecKeyCreateSignature(System.IntPtr,System.IntPtr,System.IntPtr,System.IntPtr&)",
|
||||||
"System.IntPtr Security.SecKey::SecKeyCreateWithData(System.IntPtr,System.IntPtr,System.IntPtr&)",
|
"System.IntPtr Security.SecKey::SecKeyCreateWithData(System.IntPtr,System.IntPtr,System.IntPtr&)",
|
||||||
"System.IntPtr Security.SecPolicy::SecPolicyCreateSSL(System.Boolean,System.IntPtr)",
|
"System.IntPtr Security.SecPolicy::SecPolicyCreateSSL(System.Boolean,System.IntPtr)",
|
||||||
"System.Void CoreVideo.CVPixelBuffer::CVPixelBufferGetExtendedPixels(System.IntPtr,System.UIntPtr&,System.UIntPtr&,System.UIntPtr&,System.UIntPtr&)",
|
|
||||||
"System.Void Foundation.NSObject::xamarin_release_managed_ref(System.IntPtr,System.Boolean)",
|
"System.Void Foundation.NSObject::xamarin_release_managed_ref(System.IntPtr,System.Boolean)",
|
||||||
"System.Void Network.NWAdvertiseDescriptor::nw_advertise_descriptor_set_no_auto_rename(System.IntPtr,System.Boolean)",
|
"System.Void Network.NWAdvertiseDescriptor::nw_advertise_descriptor_set_no_auto_rename(System.IntPtr,System.Boolean)",
|
||||||
"System.Void Network.NWBrowserDescriptor::nw_browse_descriptor_set_include_txt_record(System.IntPtr,System.Boolean)",
|
"System.Void Network.NWBrowserDescriptor::nw_browse_descriptor_set_include_txt_record(System.IntPtr,System.Boolean)",
|
||||||
|
|
Загрузка…
Ссылка в новой задаче