Skip to content

Instantly share code, notes, and snippets.

@spouliot

spouliot/file.cs Secret

Created April 6, 2016 00:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save spouliot/a1e7d90015c22445afb205c74ceb5b0b to your computer and use it in GitHub Desktop.
Save spouliot/a1e7d90015c22445afb205c74ceb5b0b to your computer and use it in GitHub Desktop.
[DllImport(Constants.CoreMediaLibrary)]
extern static /* OSStatus */ CMBlockBufferError CMBlockBufferCreateWithMemoryBlock (
/* CFAllocatorRef */ IntPtr structureAllocator,
/* void * */ IntPtr memoryBlock,
/* size_t */ nuint blockLength,
/* CFAllocatorRef */ IntPtr blockAllocator,
/* CMBlockBufferCustomBlockSource* */ IntPtr customBlockSource, // Can be null
/* size_t */ nuint offsetToData,
/* size_t */ nuint dataLength,
CMBlockBufferFlags flags,
/* CMBlockBufferRef* */ out IntPtr newBlockBuffer);
public static CMBlockBuffer FromMemoryBlock (IntPtr memoryBlock, nuint blockLength, CMCustomBlockAllocator customBlockSource, nuint offsetToData, nuint dataLength, CMBlockBufferFlags flags, out CMBlockBufferError error)
{
var blockAllocator = memoryBlock == IntPtr.Zero ? IntPtr.Zero : CFAllocator.Null.Handle;
IntPtr buffer;
error = CMBlockBufferCreateWithMemoryBlock (IntPtr.Zero, memoryBlock, blockLength, blockAllocator, IntPtr.Zero, offsetToData, dataLength, flags, out buffer);
if (error != CMBlockBufferError.None)
return null;
return ObjCRuntime.Runtime.GetINativeObject<CMBlockBuffer> (buffer, true);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment