docs.unity3d.com
    Show / Hide Table of Contents

    Class TimedDataBuffer<T>

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

    Inheritance
    Object
    CircularBuffer<(, )<FrameTime, T>>
    TimedDataBuffer<T>
    Inherited Members
    CircularBuffer<(FrameTime frameTime, T value)>.Count
    CircularBuffer<(FrameTime frameTime, T value)>.Capacity
    CircularBuffer<(FrameTime frameTime, T value)>.PushBack((, )<FrameTime, T>)
    CircularBuffer<(FrameTime frameTime, T value)>.Add((, )<FrameTime, T>)
    CircularBuffer<(FrameTime frameTime, T value)>.PushFront((, )<FrameTime, T>)
    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(Int32)
    CircularBuffer<(FrameTime frameTime, T value)>.Item[Int32]
    CircularBuffer<(FrameTime frameTime, T value)>.GetEnumerator()
    Namespace: Unity.LiveCapture
    Syntax
    public class TimedDataBuffer<T> : CircularBuffer<(FrameTime frameTime, T value)>
    Type Parameters
    Name Description
    T

    The datatype of the samples.

    Constructors

    TimedDataBuffer(FrameRate, Int32)

    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.

    Int32 capacity

    The capacity of the buffer.

    Properties

    Boundary

    Defines the size of a "valid" readable boundary around the beginning and end of the buffer, in frames.

    Declaration
    public int Boundary { get; set; }
    Property Value
    Type Description
    Int32
    Remarks

    When attempting to retrieve a sample outside of this boundary, TryGetSample(Timecode, FrameRate, out T) will return DataMissing.

    FrameRate

    Gets the nominal frame rate of the buffered samples.

    Declaration
    public FrameRate FrameRate { get; }
    Property Value
    Type Description
    FrameRate

    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.

    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.

    TryGetSample(FrameTime, out T)

    Retrieve a sample from the buffer at the requested 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 nominal FrameRate.

    T sampleValue

    The retrieved sample, if successful.

    Returns
    Type Description
    TimedSampleStatus

    The status of the retrieved sample. See remarks.

    Remarks

    If a sample with the requested time could not be found, this method will perform the following: a) if the time is bounded by the oldest and newest samples contained in the buffer, set sampleValue to the nearest sample and return Ok. b) if the time is outside of the buffer and is within the valid region as defined by Boundary, set sampleValue to the newest or oldest (whichever is closer) sample in the buffer, and return Behind or Ahead respectively. c) else the return DataMissing and sampleValue is set to its default.

    TryGetSample(Timecode, FrameRate, out T)

    Retrieve a sample from the buffer at the 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. Could 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 a sample with the requested time could not be found, this method will perform the following: a) if the time is bounded by the oldest and newest samples contained in the buffer, set sampleValue to the nearest sample and return Ok. b) if the time is outside of the buffer and is within the valid region as defined by Boundary, set sampleValue to the newest or oldest (whichever is closer) sample in the buffer, and return Behind or Ahead respectively. c) else the return DataMissing and sampleValue is set to its default.

    See Also

    CircularBuffer<T>
    Back to top
    Terms of use
    Copyright © 2023 Unity Technologies — Terms of use
    • Legal
    • Privacy Policy
    • Cookies
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)
    "Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
    Generated by DocFX on 18 October 2023