Type Alias


A type that defines a release callback function.


typealias CVPixelBufferReleaseBytesCallback = (UnsafeMutableRawPointer?, UnsafeRawPointer?) -> Void



A pointer to application-defined data. This pointer is the same as that passed in the releaseRefCon parameter of CVPixelBufferCreateWithBytes(_:_:_:_:_:_:_:_:_:_:).


A pointer to the base address of the memory holding the pixels. This pointer is the same as that passed in the baseAddress parameter of CVPixelBufferCreateWithBytes(_:_:_:_:_:_:_:_:_:_:).


When you create a pixel buffer using CVPixelBufferCreateWithBytes(_:_:_:_:_:_:_:_:_:_:), you can optionally pass a callback function that's invoked when the system frees the pixel buffer. Use this callback function to release the pixel data and perform any other cleanup needed when the buffer is released.

You define a callback function as shown below:

// Define a function to call when the pixel buffer is freed.
let releaseCallback: CVPixelBufferReleaseBytesCallback = { releaseRefCon, baseAddress in
    guard let baseAddress = baseAddress else { return }
    free(UnsafeMutableRawPointer(mutating: baseAddress))
    // Perform additional cleanup as needed.

See Also


typealias CVPixelBufferReleasePlanarBytesCallback

Defines a pointer to a pixel buffer release callback function, which is called when a pixel buffer created by CVPixelBufferCreateWithPlanarBytes(_:_:_:_:_:_:_:_:_:_:_:_:_:_:_:) is released.