Class ClockSyncBlock
- Namespace
- VisioForge.Core.MediaBlocks.Special
- Assembly
- VisioForge.Core.dll
Paces the buffers that pass through it to the pipeline clock at a chosen multiple of real time, without dropping or duplicating any of them. A file-to-file pipeline normally runs as fast as the machine allows; with this block it runs at VisioForge.Core.Types.X.Special.ClockSyncSettings.Rate times real time.
The rate paces the processing only: the timestamps and duration of the output are unchanged, so a file written at rate 2 still plays at normal speed. It is not a playback-speed control.
The rate is applied when the pipeline starts and stays fixed while it runs. To pace a stream with both audio and video, put one block with the same rate on each branch and leave VisioForge.Core.Types.X.Special.ClockSyncSettings.SyncToFirst off, so both branches are paced against the same running time.
The no-drop promise holds for a source that waits for the pipeline, such as a file, and for sinks
that do not sync to the clock, such as a file sink or a VisioForge.Core.MediaBlocks.Special.NullRendererBlock with
IsSync off. A live source (camera, network stream) keeps
producing in real time, so a rate below 1 backs it up and the frames are dropped upstream of this
block. A renderer downstream still plays at real time, because the block forwards the original
timestamps: above rate 1 it holds the frames back, below rate 1 it drops them as late.
The rate scales one continuous stream. A source that chains segments (a loop, a playlist, a non-flushing seek) is not paced correctly after its first segment: at rate 2 it waits about half of what has played before going on. The pipeline also behaves as a live one: it does not preroll, so a paused pipeline shows no frame, and at rate 1 the element answers the latency query as live, so a mixer downstream aggregates in live mode.
The element offers the system clock to the pipeline. Unless an element further upstream provides its own clock, the system clock becomes the pipeline clock, and an audio renderer in the same pipeline is slaved to it. Requires GStreamer 1.28 or newer (see VisioForge.Core.MediaBlocks.Special.ClockSyncBlock.IsAvailable).
Implements the VisioForge.Core.MediaBlocks.MediaBlock. Implements the VisioForge.Core.MediaBlocks.IMediaBlockInternals. Implements the IDisposable.
public class ClockSyncBlock : MediaBlock, IMediaBlock, IDisposable, IMediaBlockInternalsInheritance
Implements
Inherited Members
Extension Methods
Constructors
ClockSyncBlock(ClockSyncSettings)
Initializes a new instance of the VisioForge.Core.MediaBlocks.Special.ClockSyncBlock class.
public ClockSyncBlock(ClockSyncSettings settings)Parameters
settingsClockSyncSettings-
The settings.
Exceptions
- ArgumentNullException
-
settingsis null.
Properties
Input
Gets the input pad.
public override MediaBlockPad Input { get; }Property Value
Inputs
Gets the array of input pads. This block has a single input.
public override MediaBlockPad[] Inputs { get; }Property Value
Output
Gets the output pad.
public override MediaBlockPad Output { get; }Property Value
Outputs
Gets the array of output pads. This block has a single output.
public override MediaBlockPad[] Outputs { get; }Property Value
Settings
Gets the settings. They are applied when the pipeline starts.
public ClockSyncSettings Settings { get; }Property Value
Type
Gets the media block type identifier for this block.
public override MediaBlockType Type { get; }Property Value
Methods
Build()
Builds the block within the media pipeline and applies VisioForge.Core.MediaBlocks.Special.ClockSyncBlock.Settings. This method is called automatically during pipeline construction.
public override bool Build()Returns
- bool
-
trueif the block was successfully built; otherwise,false.
CleanUp()
Releases the GStreamer element.
public void CleanUp()Dispose(bool)
Releases unmanaged and - optionally - managed resources.
protected override void Dispose(bool disposing)Parameters
disposingbool-
trueto release both managed and unmanaged resources;falseto release only unmanaged resources.
GetCore()
Gets the core GStreamer element wrapper.
public BaseElement GetCore()Returns
- BaseElement
-
The BaseElement instance wrapping the clocksync element.
GetElement()
Gets the underlying GStreamer clocksync element.
public Element GetElement()Returns
- Element
-
The native GStreamer clocksync element.
IsAvailable()
Determines whether the block is available: the GStreamer clocksync element with rate support (GStreamer 1.28 or newer).
public static bool IsAvailable()Returns
- bool
-
trueif the element is available; otherwise,false.
Resync()
Recalculates the timestamp offset from the next incoming buffer without restarting the pipeline. Use it with VisioForge.Core.Types.X.Special.ClockSyncSettings.SyncToFirst after the flow was held up (for example, blocked by a pad probe), so the pacing restarts from the buffers that follow instead of rushing to catch up. The native action reports no offset, so none is returned.
public bool Resync()Returns
- bool
-
trueif the request reached the element;falseif the block is not built, or the element's sync-to-first is off, or its sync is off - where the native resync does nothing - or the call failed (logged as a warning).
IMediaBlockInternals.SetContext(MediaBlocksPipeline)
Sets the media pipeline context for this block.
void IMediaBlockInternals.SetContext(MediaBlocksPipeline pipeline)Parameters
pipelineMediaBlocksPipeline-
The parent MediaBlocksPipeline that contains this block.