Table of Contents

Class DataFrame

Namespace
VisioForge.Core.Types
Assembly
VisioForge.Core.dll

Represents a generic frame of data, which can be used for various media types, not limited to audio or video. This class provides a buffer for raw data along with timing and format information. It includes methods for manual memory management of the underlying data buffer.

public class DataFrame

Inheritance

Inherited Members

Examples

// Create and populate a data frame
var dataFrame = new DataFrame();
try
{
    byte[] myData = new byte[] { 0x01, 0x02, 0x03, 0x04 };
    dataFrame.Alloc(myData.Length);
    System.Runtime.InteropServices.Marshal.Copy(myData, 0, dataFrame.Data, myData.Length);

    dataFrame.Timestamp = TimeSpan.FromSeconds(5);
    dataFrame.DataType = "CustomMetadata";

    // Use the frame
    ProcessCustomData(dataFrame);
}
finally
{
    // Ensure memory is always freed
    dataFrame.Free();
}

Remarks

This class is particularly useful for handling custom data streams or metadata. The consumer of this class is responsible for allocating and freeing the memory for the data buffer using the VisioForge.Core.Types.DataFrame.Alloc(System.Int32) and VisioForge.Core.Types.DataFrame.Free methods.

Properties

Caps

Gets or sets a GStreamer-style caps string describing the data format.

public string Caps { get; set; }

Property Value

string

Remarks

Example: "application/x-custom, format=binary".

Data

Gets or sets a pointer to the raw data buffer.

public nint Data { get; set; }

Property Value

nint

Remarks

This buffer must be managed manually using VisioForge.Core.Types.DataFrame.Alloc(System.Int32) and VisioForge.Core.Types.DataFrame.Free.

DataSize

Gets or sets the size of the data buffer in bytes.

public int DataSize { get; set; }

Property Value

int

DataType

Gets or sets a string identifying the type of data in the frame.

public string DataType { get; set; }

Property Value

string

Examples

"Klv", "JsonMetadata"

Duration

Gets or sets the duration of the data frame.

public TimeSpan Duration { get; set; }

Property Value

TimeSpan

Timestamp

Gets or sets the presentation timestamp of the frame.

public TimeSpan Timestamp { get; set; }

Property Value

TimeSpan

Methods

Alloc(int)

Allocates a block of unmanaged memory of a specified size for the data buffer.

public void Alloc(int size)

Parameters

size int

The number of bytes to allocate.

Free()

Frees the unmanaged memory previously allocated for the data buffer.

public void Free()

ToArray()

Copies the data from the unmanaged buffer into a new managed byte array.

public byte[] ToArray()

Returns

byte[]

A byte array containing the frame's data.