Show / Hide Table of Contents

Struct AVBuffer_ref

Represents a reference to an AVBuffer, providing a set of operations for handling buffer memory and metadata in a safe manner, while leveraging the underlying AVBufferRef structure.

Implements
IBuffer
IEquatable<AVBuffer_ref>
IReference<AVBuffer>
IAVPointer<_AVBufferRef>
Inherited Members
ValueType.ToString()
object.GetType()
object.Equals(object, object)
object.ReferenceEquals(object, object)
Namespace: FFmpeg.Collections
Assembly: FFmpeg.dll
Syntax
public readonly struct AVBuffer_ref : IBuffer, IEquatable<AVBuffer_ref>, IReference<AVBuffer>, IAVPointer<_AVBufferRef>

Properties

View Source

Data

Gets the pointer to the buffer's data.

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

IsNull

Gets a value indicating whether the buffer is uninitialized (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
View Source

this[int]

Provides indexed access to the buffer's byte data.

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

The zero-based index into the buffer.

Property Value
Type Description
byte

The byte value at the specified index.

Exceptions
Type Condition
NullReferenceException

Thrown when the buffer is uninitialized.

ArgumentOutOfRangeException

Thrown when the index is out of bounds.

View Source

Length

Gets the size of the buffer's data in bytes.

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

LongLength

Gets the size of the buffer's data in long format.

Declaration
public long LongLength { get; }
Property Value
Type Description
long
View Source

ReferenceCount

Gets the reference count of the buffer.

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

Number of references held to the buffer, or -1 if the buffer is null.

Methods

View Source

AsSpan()

Returns the buffer's data as a span of bytes.

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

A Span<T> representing the buffer's data.

Exceptions
Type Condition
NullReferenceException

Thrown when the buffer is uninitialized.

View Source

Clone()

Clones the current buffer reference into a new AVBuffer instance.

Declaration
public AVBuffer Clone()
Returns
Type Description
AVBuffer

A cloned instance of the buffer.

Exceptions
Type Condition
NullReferenceException

Thrown when the buffer is uninitialized.

View Source

Copy()

Copies the buffer data to a new AVBuffer instance.

Declaration
public AVBuffer Copy()
Returns
Type Description
AVBuffer

A new AVBuffer containing the copied data.

Exceptions
Type Condition
NullReferenceException

Thrown when the buffer is uninitialized.

OutOfMemoryException

Thrown when memory allocation fails.

View Source

Equals(AVBuffer_ref)

Declaration
public bool Equals(AVBuffer_ref other)
Parameters
Type Name Description
AVBuffer_ref other
Returns
Type Description
bool
View Source

Equals(object?)

Declaration
public override bool Equals(object? obj)
Parameters
Type Name Description
object obj
Returns
Type Description
bool
Overrides
ValueType.Equals(object)
View Source

GetHashCode()

Declaration
public override int GetHashCode()
Returns
Type Description
int
Overrides
ValueType.GetHashCode()
View Source

GetReferencedObject()

Retrieves the AVBuffer object currently referenced by this AVBuffer_ref.

Declaration
public AVBuffer? GetReferencedObject()
Returns
Type Description
AVBuffer

The AVBuffer if the buffer reference is valid; otherwise, null if the reference is null or uninitialized.

Remarks

This method provides a safe way to access the buffer being referenced without exposing the underlying unmanaged pointer. If the reference is null (i.e., IsNull is true), it returns null.

View Source

MakeWriteable()

Makes the buffer writable by ensuring a unique copy is made if necessary.

Declaration
public void MakeWriteable()
Exceptions
Type Condition
NullReferenceException

Thrown when the buffer is uninitialized.

OutOfMemoryException

Thrown when memory allocation fails during write preparation.

View Source

ReplaceWith(IBuffer)

Replaces the current buffer with another buffer.

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

The source buffer to replace with.

Exceptions
Type Condition
OutOfMemoryException

Thrown when memory allocation fails during the replacement.

View Source

Resize(int)

Resizes the buffer to the specified size.

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

The new size for the buffer.

Exceptions
Type Condition
OutOfMemoryException

Thrown when memory allocation fails during resizing.

View Source

SetReferencedObject(AVBuffer?)

Sets the reference to a new AVBuffer object or unlinks the current reference.

Declaration
public void SetReferencedObject(AVBuffer? buffer)
Parameters
Type Name Description
AVBuffer buffer

The new AVBuffer object to reference, or null to release the current reference.

Remarks

This method updates the underlying FFmpeg.AutoGen._AVBufferRef pointer to reference a new buffer object. If buffer is null, the current reference is unlinked using ffmpeg.av_buffer_unref. If a new object is provided, the reference is updated with ffmpeg.av_buffer_ref, and an OutOfMemoryException is thrown if the allocation fails.

Exceptions
Type Condition
OutOfMemoryException

Thrown if the system cannot allocate enough memory to create a new buffer reference when setting a non-null object.

View Source

TryMakeWriteable()

Attempts to make the buffer writable. Returns true if successful.

Declaration
public bool TryMakeWriteable()
Returns
Type Description
bool
View Source

TryReplaceWith(IBuffer)

Attempts to replace the current buffer with another buffer. Returns true if successful.

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

TryResize(int)

Attempts to resize the buffer to the specified size. Returns true if successful.

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

Operators

View Source

operator ==(AVBuffer_ref, AVBuffer_ref)

Determines if two AVBuffer_ref instances are equal.

Declaration
public static bool operator ==(AVBuffer_ref left, AVBuffer_ref right)
Parameters
Type Name Description
AVBuffer_ref left
AVBuffer_ref right
Returns
Type Description
bool
View Source

operator !=(AVBuffer_ref, AVBuffer_ref)

Determines if two AVBuffer_ref instances are not equal.

Declaration
public static bool operator !=(AVBuffer_ref left, AVBuffer_ref right)
Parameters
Type Name Description
AVBuffer_ref left
AVBuffer_ref right
Returns
Type Description
bool

Implements

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