Class DataFrameEventArgs
- Namespace
- VisioForge.Core.Types.Events
- Assembly
- VisioForge.Core.dll
Provides data for events that deliver generic data frames. This class encapsulates a VisioForge.Core.Types.DataFrame, allowing it to be passed as an argument in event handlers.
public class DataFrameEventArgs : EventArgsInheritance
Inherited Members
Examples
// Assume an event handler is registered for a data frame event.
public void OnDataFrameReceived(object sender, DataFrameEventArgs e)
{
DataFrame dataFrame = e.Frame;
// Access data and information
Console.WriteLine($"Data frame received: Size = {dataFrame.DataSize} bytes, Type = {dataFrame.DataType}");
// Convert data to a byte array for processing
byte[] dataBytes = dataFrame.ToArray();
// Process dataBytes based on dataFrame.DataType
if (dataFrame.DataType == "CustomMetadata")
{
// Parse custom metadata
}
}
Remarks
This event argument is typically used in scenarios where an application needs to process arbitrary data streams, such as metadata, custom protocols, or other non-audio/video data. DataFrame encapsulates raw data buffers with associated metadata like data type, size, and timestamps. Common use cases include processing subtitle streams, closed captions, timecode data, or custom application protocols. The Frame.Data property provides a pointer to the raw data buffer for direct memory access. Frame.DataSize indicates the buffer size in bytes for safe data access and copying. Frame.DataType identifies the data format, enabling appropriate parsing and handling logic. Applications should validate data type and size before processing to ensure correct interpretation. Data frames may contain text, binary, JSON, XML, or any custom format depending on the source. Memory management is important - data buffers may be reused by the framework, so copy data if needed beyond event scope. Consider using Frame.ToArray() to create a managed byte array copy for asynchronous or deferred processing. Events are raised on background processing threads, requiring thread-safe handling and UI marshaling.
Constructors
DataFrameEventArgs(nint, int)
Initializes a new instance of the VisioForge.Core.Types.Events.DataFrameEventArgs class with a pointer to the data and its size. A new VisioForge.Core.Types.DataFrame instance is created internally.
public DataFrameEventArgs(nint data, int dataSize)Parameters
DataFrameEventArgs(DataFrame)
Initializes a new instance of the VisioForge.Core.Types.Events.DataFrameEventArgs class with an existing VisioForge.Core.Types.DataFrame object.
public DataFrameEventArgs(DataFrame frame)Parameters
frameDataFrame-
The VisioForge.Core.Types.DataFrame to be encapsulated by these event arguments.
Properties
Frame
Gets the VisioForge.Core.Types.DataFrame associated with this event. This frame contains the generic data and its metadata.
public DataFrame Frame { get; }