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, IMediaBlockInternalsInheritance
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
settingsPreEventRecordingSettings-
Pre-event recording configuration.
muxFactoryNamestring-
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
AudioInput
Gets the audio input pad.
public MediaBlockPad AudioInput { get; }Property Value
BufferTotalBytes
Gets the total bytes currently stored in the ring buffer.
public long BufferTotalBytes { get; }Property Value
BufferedDuration
Gets the current buffered duration.
public TimeSpan BufferedDuration { get; }Property Value
CurrentFilename
Gets the current recording filename.
public string CurrentFilename { get; }Property Value
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
Input
Gets the primary input pad (video).
public override MediaBlockPad Input { get; }Property Value
Inputs
Gets all input pads.
public override MediaBlockPad[] Inputs { get; }Property Value
Output
Gets the primary output pad (none - this is a sink).
public override MediaBlockPad Output { get; }Property Value
Outputs
Gets all output pads (none - this is a sink).
public override MediaBlockPad[] Outputs { get; }Property Value
Settings
Gets the pre-event recording settings.
public PreEventRecordingSettings Settings { get; }Property Value
State
Gets the current state of the pre-event recording system.
public PreEventRecordingState State { get; }Property Value
Type
Gets the media block type.
public override MediaBlockType Type { get; }Property Value
VideoInput
Gets the video input pad.
public MediaBlockPad VideoInput { get; }Property Value
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
-
trueif 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
disposingbool
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
filenamestring-
The output filename for the recording.
IMediaBlockInternals.SetContext(MediaBlocksPipeline)
Sets the pipeline context.
void IMediaBlockInternals.SetContext(MediaBlocksPipeline pipeline)Parameters
pipelineMediaBlocksPipeline
OnRecordingStarted
Occurs when recording starts (buffer flushed to file).
public event EventHandler<PreEventRecordingEventArgs> OnRecordingStartedEvent Type
OnRecordingStopped
Occurs when recording stops (post-event timer expired or manual stop).
public event EventHandler<PreEventRecordingEventArgs> OnRecordingStoppedEvent Type
OnStateChanged
Occurs when the recording state changes.
public event EventHandler<PreEventRecordingEventArgs> OnStateChanged