FixedClock

namespace VideoKit.Clocks {
    /// <summary>
    /// Clock that generates timestamps spaced at a fixed interval.
    /// </summary>
    class FixedClock : IClock { ... }
}

The FixedClock generates timestamps that advance in fixed intervals. This is useful for controlling the output frame rate for some recorders, and in offline recording.


Creating the Clock

/// <summary>
/// Create a fixed interval clock for a given framerate.
/// </summary>
/// <param name="frameRate">Desired framerate for clock's timestamps.</param>
/// <param name="autoTick">Optional. If true, the clock will tick when its `timestamp` is accessed.</param>
FixedIntervalClock (float frameRate, bool autoTick = true);

The frameRate parameter determines the frame rate which the generated timestamps should generate. The autoTick parameter determines whether the clock should automatically advance its timestamp when the timestamp property is accessed. In most use cases, this is best left as true.


Inspecting the Interval

/// <summary>
/// Interval between consecutive timestamps generated by the clock in seconds.
/// </summary>
double interval { get; }

The interval is the amount of time between consecutive timestamps in seconds.


Generating Timestamps

/// <summary>
/// Current timestamp in nanoseconds.
/// </summary>
long timestamp { get; }

The timestamp reports the clock's elapsed time in nanoseconds.


Advancing the Timestamp

/// <summary>
/// Advance the clock by its time interval.
/// </summary>
void Tick ();

When the clock is not set to autoTick, you must call Tick to advance its timestamp.


Was this page helpful?