Show / Hide Table of Contents

Class AVBuffer

Represents a wrapper for an AVBufferRef in FFmpeg, which manages reference-counted buffers. Provides functionality for managing the lifetime, access, and manipulation of these buffers.

Inheritance
object
AVBuffer
Implements
IDisposable
IBuffer
IAVPointer<_AVBufferRef>
Inherited Members
object.GetType()
object.ToString()
object.Equals(object)
object.Equals(object, object)
object.ReferenceEquals(object, object)
object.GetHashCode()
Namespace: FFmpeg.Collections
Assembly: FFmpeg.dll
Syntax
public sealed class AVBuffer : IDisposable, IBuffer, IAVPointer<_AVBufferRef>

Properties

View Source

Data

Gets the pointer to the buffer's data. Returns Zero if the buffer reference is null.

Declaration
public nint Data { get; }
Property Value
Type Description
nint
View Source

IsNull

Gets a value indicating whether the buffer reference is null.

Declaration
public bool IsNull { get; }
Property Value
Type Description
bool
View Source

IsReadOnly

Gets a value indicating whether the buffer is read-only.

Declaration
public bool IsReadOnly { get; }
Property Value
Type Description
bool
Exceptions
Type Condition
NullReferenceException

Thrown when the buffer reference is null.

View Source

this[int]

Indexer to access or modify a byte at the specified index in the buffer.

Declaration
public byte this[int index] { get; set; }
Parameters
Type Name Description
int index

The index of the byte to access or modify.

Property Value
Type Description
byte
Exceptions
Type Condition
ArgumentOutOfRangeException

Thrown if the index is out of bounds.

View Source

Length

Gets the length of the buffer in bytes. Returns 0 if the buffer reference is null.

Declaration
public int Length { get; }
Property Value
Type Description
int
View Source

ReferenceCount

Gets the reference count of the buffer. Returns -1 if the buffer reference is null.

Declaration
public int ReferenceCount { get; }
Property Value
Type Description
int

Methods

View Source

Allocate(int)

Allocates a new buffer of the specified size.

Declaration
public static AVBuffer Allocate(int size)
Parameters
Type Name Description
int size

The size of the buffer to allocate in bytes.

Returns
Type Description
AVBuffer

A new AVBuffer instance.

Exceptions
Type Condition
OutOfMemoryException

Thrown when the buffer could not be allocated due to memory limitations.

View Source

AllocateZ(int)

Allocates a new zero-initialized buffer of the specified size.

Declaration
public static AVBuffer AllocateZ(int size)
Parameters
Type Name Description
int size

The size of the buffer to allocate in bytes.

Returns
Type Description
AVBuffer

A new AVBuffer instance with zeroed data.

Exceptions
Type Condition
OutOfMemoryException

Thrown when the buffer could not be allocated due to memory limitations.

View Source

AsSpan()

Returns a writable span of the buffer's data.

Declaration
public Span<byte> AsSpan()
Returns
Type Description
Span<byte>

A Span<T> representing the buffer's data. Returns an empty span if the buffer reference is null.

View Source

Clone()

Clones the buffer, creating a new buffer that references the same data.

Declaration
public AVBuffer Clone()
Returns
Type Description
AVBuffer

A new AVBuffer that references the same data as the original.

Exceptions
Type Condition
NullReferenceException

Thrown when the buffer reference is null.

View Source

Copy()

Copies the data from the current buffer into a new buffer.

Declaration
public AVBuffer Copy()
Returns
Type Description
AVBuffer

A new AVBuffer instance with copied data.

Exceptions
Type Condition
NullReferenceException

Thrown if the current buffer reference is null.

OutOfMemoryException

Thrown when the buffer could not be copied due to memory limitations.

View Source

Dispose()

Releases the unmanaged resources used by the AVBuffer.

Declaration
public void Dispose()
View Source

~AVBuffer()

Finalizer to ensure unmanaged resources are released when the object is garbage collected.

Declaration
protected ~AVBuffer()
View Source

FromExisting(AVBuffer)

Creates a new buffer that references the same data as an existing buffer.

Declaration
public static AVBuffer FromExisting(AVBuffer buffer)
Parameters
Type Name Description
AVBuffer buffer

The buffer to reference.

Returns
Type Description
AVBuffer

A new AVBuffer that references the same data as the input buffer.

Exceptions
Type Condition
OutOfMemoryException

Thrown when the new buffer could not be created due to memory limitations.

View Source

MakeWriteable()

Ensures the buffer is writable, throwing an exception if it cannot be made writable.

Declaration
public void MakeWriteable()
Exceptions
Type Condition
NullReferenceException

Thrown if the buffer reference is null.

OutOfMemoryException

Thrown when the buffer could not be made writable due to memory limitations.

View Source

ReplaceWith(AVBuffer)

Replaces the current buffer with another buffer, throwing an exception if replacement fails.

Declaration
public void ReplaceWith(AVBuffer src)
Parameters
Type Name Description
AVBuffer src

The source buffer to replace with.

Exceptions
Type Condition
OutOfMemoryException

Thrown when the buffer could not be replaced due to memory limitations.

View Source

ReplaceWith(IBuffer)

Replaces the current buffer with another buffer, which can be any object implementing IBuffer.

Declaration
public void ReplaceWith(IBuffer src)
Parameters
Type Name Description
IBuffer src

The source buffer implementing IBuffer.

Exceptions
Type Condition
NullReferenceException

Thrown when the source buffer is null.

OutOfMemoryException

Thrown if the replace operation fails.

View Source

Resize(int)

Resizes the buffer to the specified size, throwing an exception if resizing fails.

Declaration
public void Resize(int size)
Parameters
Type Name Description
int size

The new size of the buffer in bytes.

Exceptions
Type Condition
OutOfMemoryException

Thrown when the buffer could not be resized due to memory limitations.

View Source

TryMakeWriteable()

Tries to make the buffer writable, if it is not already.

Declaration
public bool TryMakeWriteable()
Returns
Type Description
bool

true if the buffer was successfully made writable; otherwise, false.

View Source

TryReplaceWith(AVBuffer)

Tries to replace the current buffer with another buffer.

Declaration
public bool TryReplaceWith(AVBuffer src)
Parameters
Type Name Description
AVBuffer src

The source buffer to replace with.

Returns
Type Description
bool

true if the buffer was successfully replaced; otherwise, false.

View Source

TryReplaceWith(IBuffer)

Tries to replace the current buffer with another buffer implementing IBuffer.

Declaration
public bool TryReplaceWith(IBuffer src)
Parameters
Type Name Description
IBuffer src

The source buffer implementing IBuffer.

Returns
Type Description
bool

true if the buffer was successfully replaced; otherwise, false.

View Source

TryResize(int)

Tries to resize the buffer to the specified size.

Declaration
public bool TryResize(int size)
Parameters
Type Name Description
int size

The new size of the buffer in bytes.

Returns
Type Description
bool

true if the buffer was successfully resized; otherwise, false.

Implements

IDisposable
IBuffer
IAVPointer<T>
  • View Source
In this article
Back to top Generated by DocFX