docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Class TimedDataBuffer<T>

    A circular buffer of timed samples (data with an associated Timecode).

    Inheritance
    object
    CircularBuffer<(FrameTime frameTime, T value)>
    TimedDataBuffer<T>
    Inherited Members
    CircularBuffer<(FrameTime frameTime, T value)>.Count
    CircularBuffer<(FrameTime frameTime, T value)>.Capacity
    CircularBuffer<(FrameTime frameTime, T value)>.PushBack((FrameTime frameTime, T value))
    CircularBuffer<(FrameTime frameTime, T value)>.Add((FrameTime frameTime, T value))
    CircularBuffer<(FrameTime frameTime, T value)>.PushFront((FrameTime frameTime, T value))
    CircularBuffer<(FrameTime frameTime, T value)>.PopFront()
    CircularBuffer<(FrameTime frameTime, T value)>.PopBack()
    CircularBuffer<(FrameTime frameTime, T value)>.Front()
    CircularBuffer<(FrameTime frameTime, T value)>.Back()
    CircularBuffer<(FrameTime frameTime, T value)>.Clear()
    CircularBuffer<(FrameTime frameTime, T value)>.SetCapacity(int)
    CircularBuffer<(FrameTime frameTime, T value)>.this[int]
    CircularBuffer<(FrameTime frameTime, T value)>.GetEnumerator()
    Namespace: Unity.LiveCapture
    Assembly: Unity.LiveCapture.dll
    Syntax
    public class TimedDataBuffer<T> : CircularBuffer<(FrameTime frameTime, T value)>
    Type Parameters
    Name Description
    T

    The datatype of the samples.

    Constructors

    TimedDataBuffer(FrameRate, int)

    Creates a new TimedDataBuffer<T> instance.

    Declaration
    public TimedDataBuffer(FrameRate frameRate, int capacity = 5)
    Parameters
    Type Name Description
    FrameRate frameRate

    The nominal frame rate of the samples.

    int capacity

    The capacity of the buffer.

    See Also
    CircularBuffer<T>

    Properties

    FrameRate

    Gets the nominal frame rate of the buffered samples.

    Declaration
    public FrameRate FrameRate { get; }
    Property Value
    Type Description
    FrameRate
    See Also
    CircularBuffer<T>

    Methods

    Add(double, T)

    Add a new sample to the back of the buffer.

    Declaration
    public void Add(double time, T value)
    Parameters
    Type Name Description
    double time

    The time of the sample in seconds.

    T value

    The sample value.

    Remarks

    If the back of the buffer (the newest sample) is older than or has the sample time value as the new sample, the new sample will not be added. That is, out-of-order additions will be dropped.

    See Also
    CircularBuffer<T>

    Add(Timecode, FrameRate, T)

    Add a new sample to the back of the buffer.

    Declaration
    public void Add(Timecode timecode, FrameRate frameRate, T value)
    Parameters
    Type Name Description
    Timecode timecode

    The timecode of the sample.

    FrameRate frameRate

    The frame rate of the timecode.

    T value

    The sample value.

    Remarks

    If the back of the buffer (the newest sample) is older than or has the sample time value as the new sample, the new sample will not be added. That is, out-of-order additions will be dropped.

    See Also
    CircularBuffer<T>

    GetNewestSampleTime(FrameRate)

    Gets the frame time of the newest sample in the buffer.

    Declaration
    public FrameTime? GetNewestSampleTime(FrameRate frameRate)
    Parameters
    Type Name Description
    FrameRate frameRate

    The frame rate to use for the returned frame time.

    Returns
    Type Description
    FrameTime?

    The frame time of the newest sample or null if there are no samples in the buffer.

    See Also
    CircularBuffer<T>

    GetOldestSampleTime(FrameRate)

    Gets the frame time of the oldest sample in the buffer.

    Declaration
    public FrameTime? GetOldestSampleTime(FrameRate frameRate)
    Parameters
    Type Name Description
    FrameRate frameRate

    The frame rate to use for the returned frame time.

    Returns
    Type Description
    FrameTime?

    The frame time of the oldest sample or null if there are no samples in the buffer.

    See Also
    CircularBuffer<T>

    TryGetBufferRange(out FrameTime, out FrameTime)

    Gets the frame time of the newest and oldest samples in the buffer.

    Declaration
    public bool TryGetBufferRange(out FrameTime oldestSample, out FrameTime newestSample)
    Parameters
    Type Name Description
    FrameTime oldestSample

    The frame time of the oldest sample in the buffer, or default if there are no samples in the buffer.

    FrameTime newestSample

    The frame time of the newest sample in the buffer, or default if there are no samples in the buffer.

    Returns
    Type Description
    bool

    true if there are any samples in the buffer; otherwise, false.

    See Also
    CircularBuffer<T>

    TryGetSample(FrameTime, out T)

    Retrieves a sample from the buffer at the specified time, if available.

    Declaration
    public TimedSampleStatus TryGetSample(FrameTime frame, out T sampleValue)
    Parameters
    Type Name Description
    FrameTime frame

    The time to retrieve the sample data for, expressed relative to the FrameRate.

    T sampleValue

    The retrieved sample, if successful.

    Returns
    Type Description
    TimedSampleStatus

    The status of the retrieved sample. See remarks.

    Remarks

    If there isn't a sample at the specified time, the following occurs:

    a) if the time is bounded by the oldest and newest samples contained in the buffer, sampleValue is set to the nearest sample and returns Ok.
    b) if the time is outside of the buffer but there is at least one buffered sample, sampleValue is set to the newest or oldest buffered sample (whichever is closer) and returns Behind or Ahead respectively.
    c) otherwise, returns DataMissing and sets sampleValue to default.

    See Also
    CircularBuffer<T>

    TryGetSample(Timecode, FrameRate, out T)

    Retrieves a sample from the buffer at the specified time, if available.

    Declaration
    public TimedSampleStatus TryGetSample(Timecode timecode, FrameRate frameRate, out T sampleValue)
    Parameters
    Type Name Description
    Timecode timecode

    The time to retrieve the sample data for, expressed relative to the given frameRate.

    FrameRate frameRate

    The framerate of the timecode source. It might be different from the framerate of the data in the buffer.

    T sampleValue

    The retrieved sample, if successful.

    Returns
    Type Description
    TimedSampleStatus

    The status of the retrieved sample. See remarks.

    Remarks

    If there isn't a sample at the specified time, the following occurs:

    a) if the time is bounded by the oldest and newest samples contained in the buffer, sampleValue is set to the nearest sample and returns Ok.
    b) if the time is outside of the buffer but there is at least one buffered sample, sampleValue is set to the newest or oldest buffered sample (whichever is closer) and returns Behind or Ahead respectively.
    c) otherwise, returns DataMissing and sets sampleValue to default.

    See Also
    CircularBuffer<T>

    See Also

    CircularBuffer<T>
    In This Article
    Back to top
    Copyright © 2025 Unity Technologies — Trademarks and terms of use
    • Legal
    • Privacy Policy
    • Cookie Policy
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)