Interface IBuffer
Defines the interface for buffer management, providing methods for accessing and manipulating data, managing reference counts, and handling buffer memory operations.
Namespace: FFmpeg.Collections
Assembly: FFmpeg.dll
Syntax
public interface IBuffer
Properties
View SourceData
Declaration
nint Data { get; }
Property Value
| Type | Description |
|---|---|
| nint |
IsNull
Gets a value indicating whether the buffer reference is null.
Declaration
bool IsNull { get; }
Property Value
| Type | Description |
|---|---|
| bool | true if the underlying FFmpeg.AutoGen._AVBufferRef pointer is null, indicating the absence of a valid buffer reference; otherwise, false. |
Remarks
This property helps in determining if the buffer has been allocated or assigned a valid reference. A null reference typically indicates that the buffer has not been initialized or has been released.
this[int]
Gets or sets the byte value at the specified index in the buffer.
Declaration
byte this[int index] { get; set; }
Parameters
| Type | Name | Description |
|---|---|---|
| int | index | The zero-based index of the byte to get or set. |
Property Value
| Type | Description |
|---|---|
| byte | The byte at the specified index. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentOutOfRangeException | Thrown when the index is out of bounds. |
| NullReferenceException | Thrown when the buffer is null. |
Length
Gets the length of the buffer in bytes.
Declaration
int Length { get; }
Property Value
| Type | Description |
|---|---|
| int | The number of bytes in the buffer. |
ReferenceCount
Gets the reference count of the buffer. Returns -1 if the buffer reference is null.
Declaration
int ReferenceCount { get; }
Property Value
| Type | Description |
|---|---|
| int | The number of references currently held to the buffer, or -1 if the reference is null. |
Methods
View SourceAsSpan()
Returns a span representing the buffer's byte data.
Declaration
Span<byte> AsSpan()
Returns
| Type | Description |
|---|---|
| Span<byte> | A Span<T> of bytes representing the buffer's data. |
Clone()
Clones the current buffer reference into a new buffer instance.
Declaration
AVBuffer Clone()
Returns
| Type | Description |
|---|---|
| AVBuffer | A new AVBuffer that shares the same data reference as the current buffer. |
Exceptions
| Type | Condition |
|---|---|
| NullReferenceException | Thrown when the buffer is null. |
Copy()
Creates a new copy of the current buffer with the same data.
Declaration
AVBuffer Copy()
Returns
| Type | Description |
|---|---|
| AVBuffer | A new instance of AVBuffer containing a copy of the buffer data. |
Exceptions
| Type | Condition |
|---|---|
| NullReferenceException | Thrown when the buffer is null. |
| OutOfMemoryException | Thrown when memory allocation fails during the copy. |
MakeWriteable()
Ensures that the buffer is writable, creating a copy if necessary.
Declaration
void MakeWriteable()
Exceptions
| Type | Condition |
|---|---|
| NullReferenceException | Thrown when the buffer is null. |
| OutOfMemoryException | Thrown when memory allocation fails during write preparation. |
ReplaceWith(IBuffer)
Replaces the current buffer with another buffer.
Declaration
void ReplaceWith(IBuffer src)
Parameters
| Type | Name | Description |
|---|---|---|
| IBuffer | src | The source buffer that will replace the current buffer. |
Exceptions
| Type | Condition |
|---|---|
| NullReferenceException | Thrown when the source buffer is null. |
| OutOfMemoryException | Thrown when memory allocation fails during the replacement. |
Resize(int)
Resizes the buffer to the specified size.
Declaration
void Resize(int size)
Parameters
| Type | Name | Description |
|---|---|---|
| int | size | The new size for the buffer in bytes. |
Exceptions
| Type | Condition |
|---|---|
| OutOfMemoryException | Thrown when memory allocation fails during resizing. |
TryMakeWriteable()
Attempts to make the buffer writable, and returns whether the operation was successful.
Declaration
bool TryMakeWriteable()
Returns
| Type | Description |
|---|---|
| bool | true if the buffer was successfully made writable; otherwise, false. |
TryReplaceWith(IBuffer)
Attempts to replace the current buffer with another buffer, and returns whether the operation was successful.
Declaration
bool TryReplaceWith(IBuffer src)
Parameters
| Type | Name | Description |
|---|---|---|
| IBuffer | src | The source buffer to replace the current one. |
Returns
| Type | Description |
|---|---|
| bool |
TryResize(int)
Attempts to resize the buffer to the specified size, and returns whether the operation was successful.
Declaration
bool TryResize(int size)
Parameters
| Type | Name | Description |
|---|---|---|
| int | size | The new size for the buffer in bytes. |
Returns
| Type | Description |
|---|---|
| bool |