Table of Contents

Class VideoFrameBufferEventArgs

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

Provides data for events that deliver video frame buffers. This class encapsulates a VisioForge.Core.Types.VideoFrame and additional metadata, allowing it to be passed as an argument in event handlers.

public class VideoFrameBufferEventArgs : EventArgs

Inheritance

Inherited Members

Examples

// Assume an event handler is registered for a video frame buffer event.
public void OnVideoFrameBufferReceived(object sender, VideoFrameBufferEventArgs e)
{
    VideoFrame videoFrame = e.Frame;

    // Access video data and information
    Console.WriteLine($"Video frame received: {videoFrame.Info.Width}x{videoFrame.Info.Height}, Timestamp = {videoFrame.Timestamp}, Stream Type = {e.SourceStream}");

    // If you modify the frame data (e.g., draw on it), set UpdateData to true.
    // e.UpdateData = true;

    // Important: If the VideoFrame.Data was allocated by a native component,
    // ensure it is freed when no longer needed, typically by the component that allocated it.
}

Remarks

This event argument is typically used in scenarios where an application needs to process video data directly, such as for custom video analysis, rendering, or real-time effects. The VisioForge.Core.Types.Events.VideoFrameBufferEventArgs.UpdateData property allows the event handler to signal if the frame data has been modified and needs to be saved or re-rendered. Frame property provides access to raw video data buffer, dimensions, color space, and timestamp. FrameArray provides an optional managed byte array copy of the frame data for easier manipulation. FrameRate indicates the video stream's frame rate, important for proper timing and playback. UpdateData should be set to true if you modify the frame buffer and want changes reflected in output. SourceStream identifies which video source the frame came from in multi-stream scenarios. SourceName and FourCC provide additional metadata about the video source and format. Applications can implement custom video processing: overlays, filters, color corrections, analysis, or computer vision. Frame data is typically in raw format (RGB, YUV, etc.) requiring appropriate color space handling. Memory management is critical - frame buffers are often reused, so copy data if needed beyond event scope. High-resolution or high-framerate video generates frequent events, so handlers must be optimized for performance. Consider offloading heavy processing to background threads while ensuring thread-safe buffer access. Events are raised on processing threads, requiring careful synchronization for UI updates or shared resource access.

Constructors

VideoFrameBufferEventArgs(nint, int, int, int, int, RAWVideoColorSpace, VideoFrameRate, TimeSpan, ref bool, VideoStreamType)

Initializes a new instance of the VisioForge.Core.Types.Events.VideoFrameBufferEventArgs class with raw video data parameters.

public VideoFrameBufferEventArgs(nint data, int dataSize, int width, int height, int stride, RAWVideoColorSpace colorSpace, VideoFrameRate frameRate, TimeSpan timestamp, ref bool updateData, VideoStreamType sourceStream)

Parameters

data nint

A pointer to the raw video data buffer.

dataSize int

The size of the video data buffer in bytes.

width int

The width of the video frame.

height int

The height of the video frame.

stride int

The stride (bytes per row) of the video frame. If 0, it will be calculated based on color space and width.

colorSpace RAWVideoColorSpace

The color space of the video frame.

frameRate VideoFrameRate

The frame rate of the video stream.

timestamp TimeSpan

The timestamp of the video frame.

updateData bool

A reference to a boolean flag indicating if the data has been updated.

sourceStream VideoStreamType

The type of the source video stream.

VideoFrameBufferEventArgs(ref RAWVideoFrame, VideoFrameRate, ref bool, VideoStreamType)

Initializes a new instance of the VisioForge.Core.Types.Events.VideoFrameBufferEventArgs class with a VisioForge.Core.Types.RAWVideoFrame.

public VideoFrameBufferEventArgs(ref RAWVideoFrame frame, VideoFrameRate frameRate, ref bool updateData, VideoStreamType sourceStream = VideoStreamType.Main)

Parameters

frame RAWVideoFrame

The VisioForge.Core.Types.RAWVideoFrame to be encapsulated by these event arguments.

frameRate VideoFrameRate

The frame rate of the video stream.

updateData bool

A reference to a boolean flag indicating if the data has been updated.

sourceStream VideoStreamType

The type of the source video stream (defaults to VisioForge.Core.Types.VideoStreamType.Main).

VideoFrameBufferEventArgs(VideoFrame, VideoFrameRate, ref bool, VideoStreamType)

Initializes a new instance of the VisioForge.Core.Types.Events.VideoFrameBufferEventArgs class with an existing VisioForge.Core.Types.VideoFrame.

public VideoFrameBufferEventArgs(VideoFrame frame, VideoFrameRate frameRate, ref bool updateData, VideoStreamType sourceStream = VideoStreamType.Main)

Parameters

frame VideoFrame

The VisioForge.Core.Types.VideoFrame to be encapsulated by these event arguments.

frameRate VideoFrameRate

The frame rate of the video stream.

updateData bool

A reference to a boolean flag indicating if the data has been updated.

sourceStream VideoStreamType

The type of the source video stream (defaults to VisioForge.Core.Types.VideoStreamType.Main).

Properties

FourCC

Gets or sets the FourCC code of the video format (optional).

public string FourCC { get; set; }

Property Value

string

Frame

Gets the VisioForge.Core.Types.VideoFrame associated with this event. This frame contains the video data and its metadata.

public VideoFrame Frame { get; }

Property Value

VideoFrame

FrameArray

Gets the video frame data as a byte array. This property can be null if the data is not directly copied to a managed array.

public byte[] FrameArray { get; }

Property Value

byte[]

FrameRate

Gets the frame rate of the video stream.

public VideoFrameRate FrameRate { get; }

Property Value

VideoFrameRate

SourceName

Gets or sets the name of the source from which the frame originated (optional).

public string SourceName { get; set; }

Property Value

string

SourceStream

Gets or sets the type of the source video stream from which the frame originated.

public VideoStreamType SourceStream { get; set; }

Property Value

VideoStreamType

UpdateData

Set this to true if you modify the VisioForge.Core.Types.VideoFrame.Data and want the changes to be reflected (e.g., saved to a file or re-rendered).

public bool UpdateData { get; set; }

Property Value

bool