Table of Contents

Class PreEventRecordingBlock

Namespace
VisioForge.Core.MediaBlocks.Sinks
Assembly
VisioForge.Core.dll

Pre-event (circular buffer) recording block for Media Blocks SDK. Continuously buffers encoded video/audio in memory. On trigger, flushes buffered pre-event frames to a file, continues recording live frames for a configurable post-event duration, then returns to buffer-only mode.

public class PreEventRecordingBlock : MediaBlock, IMediaBlock, IDisposable, IMediaBlockInternals

Inheritance

Implements

Inherited Members

Extension Methods

Constructors

PreEventRecordingBlock(PreEventRecordingSettings, string)

Initializes a new instance of the VisioForge.Core.MediaBlocks.Sinks.PreEventRecordingBlock class.

public PreEventRecordingBlock(PreEventRecordingSettings settings, string muxFactoryName = "mp4mux")

Parameters

settings PreEventRecordingSettings

Pre-event recording configuration.

muxFactoryName string

GStreamer mux element factory name (e.g., "mp4mux", "matroskamux", "mpegtsmux"). Default: "mp4mux".

Properties

AudioEnabled

Gets or sets whether audio capture is enabled. Set to false before pipeline start when no audio source is connected. Default: true.

public bool AudioEnabled { get; set; }

Property Value

bool

AudioInput

Gets the audio input pad.

public MediaBlockPad AudioInput { get; }

Property Value

MediaBlockPad

BufferTotalBytes

Gets the total bytes currently stored in the ring buffer.

public long BufferTotalBytes { get; }

Property Value

long

BufferedDuration

Gets the current buffered duration.

public TimeSpan BufferedDuration { get; }

Property Value

TimeSpan

CurrentFilename

Gets the current recording filename.

public string CurrentFilename { get; }

Property Value

string

DebugLogPath

Gets or sets the debug log file path. When non-null, detailed timestamp debugging is written to this file.

public string DebugLogPath { get; set; }

Property Value

string

Input

Gets the primary input pad (video).

public override MediaBlockPad Input { get; }

Property Value

MediaBlockPad

Inputs

Gets all input pads.

public override MediaBlockPad[] Inputs { get; }

Property Value

MediaBlockPad[]

Output

Gets the primary output pad (none - this is a sink).

public override MediaBlockPad Output { get; }

Property Value

MediaBlockPad

Outputs

Gets all output pads (none - this is a sink).

public override MediaBlockPad[] Outputs { get; }

Property Value

MediaBlockPad[]

Settings

Gets the pre-event recording settings.

public PreEventRecordingSettings Settings { get; }

Property Value

PreEventRecordingSettings

State

Gets the current state of the pre-event recording system.

public PreEventRecordingState State { get; }

Property Value

PreEventRecordingState

Type

Gets the media block type.

public override MediaBlockType Type { get; }

Property Value

MediaBlockType

VideoInput

Gets the video input pad.

public MediaBlockPad VideoInput { get; }

Property Value

MediaBlockPad

Methods

Build()

Builds and initializes the pre-event recording block. Creates internal appsink elements for capturing encoded video/audio.

public override bool Build()

Returns

bool

true if built successfully; otherwise, false.

CleanUp()

Cleans up all resources associated with the pre-event recording block.

public void CleanUp()

Dispose(bool)

Releases resources.

protected override void Dispose(bool disposing)

Parameters

disposing bool

ExtendRecording()

Extends the current recording by resetting the post-event timer. Call this when the trigger condition is still active (e.g., motion continues).

public void ExtendRecording()

GetCore()

Gets the core element.

public BaseElement GetCore()

Returns

BaseElement

GetElement()

Gets the GStreamer element.

public Element GetElement()

Returns

Element

StartBuffering()

Starts or resumes buffering after being stopped.

public void StartBuffering()

StopBuffering()

Stops everything including buffering. Clears the buffer.

public void StopBuffering()

StopRecording()

Manually stops the current recording and returns to buffering mode.

public void StopRecording()

TriggerRecording(string)

Triggers recording: flushes the pre-event buffer to a file and continues recording live frames. If already recording, extends the current recording (resets the post-event timer).

public void TriggerRecording(string filename)

Parameters

filename string

The output filename for the recording.

IMediaBlockInternals.SetContext(MediaBlocksPipeline)

Sets the pipeline context.

void IMediaBlockInternals.SetContext(MediaBlocksPipeline pipeline)

Parameters

pipeline MediaBlocksPipeline

OnRecordingStarted

Occurs when recording starts (buffer flushed to file).

public event EventHandler<PreEventRecordingEventArgs> OnRecordingStarted

Event Type

EventHandler<PreEventRecordingEventArgs>

OnRecordingStopped

Occurs when recording stops (post-event timer expired or manual stop).

public event EventHandler<PreEventRecordingEventArgs> OnRecordingStopped

Event Type

EventHandler<PreEventRecordingEventArgs>

OnStateChanged

Occurs when the recording state changes.

public event EventHandler<PreEventRecordingEventArgs> OnStateChanged

Event Type

EventHandler<PreEventRecordingEventArgs>