docs.unity.cn
    Show / Hide Table of Contents

    Class TimedDataSource

    A base class that implements the default behaviour for a ITimedDataSource.

    Inheritance
    Object
    TimedDataSource
    Namespace: Unity.LiveCapture
    Syntax
    [Serializable]
    public class TimedDataSource : ITimedDataSource, IRegistrable

    Properties

    BufferSize

    The current buffer size.

    Declaration
    public int BufferSize { get; set; }
    Property Value
    Type Description
    Int32
    Implements
    ITimedDataSource.BufferSize

    Enabled

    Is the data source ready to buffer samples.

    Declaration
    public bool Enabled { get; }
    Property Value
    Type Description
    Boolean

    FrameRate

    The number of data samples per second.

    Declaration
    public FrameRate FrameRate { get; set; }
    Property Value
    Type Description
    FrameRate
    Implements
    ITimedDataSource.FrameRate

    IsSynchronized

    Signal to the data source whether it is being synchronized via PresentAt(FrameTimeWithRate).

    Declaration
    public bool IsSynchronized { get; set; }
    Property Value
    Type Description
    Boolean
    Implements
    ITimedDataSource.IsSynchronized
    Remarks

    When true, the data source should disable its own update mechanism.

    MaxBufferSize

    The maximum size of the sample buffer, if limited.

    Declaration
    public int? MaxBufferSize { get; set; }
    Property Value
    Type Description
    Nullable<Int32>
    Implements
    ITimedDataSource.MaxBufferSize

    MinBufferSize

    The minimum size of the sample buffer, if limited.

    Declaration
    public int? MinBufferSize { get; set; }
    Property Value
    Type Description
    Nullable<Int32>
    Implements
    ITimedDataSource.MinBufferSize

    Offset

    The time offset applied to sample timecodes, in frames.

    Declaration
    public FrameTime Offset { get; set; }
    Property Value
    Type Description
    FrameTime
    Implements
    ITimedDataSource.Offset
    Remarks

    The frame duration corresponds to the FrameRate of this source. This value should typically match the time delay between timecode generation and data sampling.

    SourceObject

    The object that owns this data source.

    Declaration
    public Object SourceObject { get; set; }
    Property Value
    Type Description
    Object

    Synchronizer

    The ISynchronizer controlling this source.

    Declaration
    public ISynchronizer Synchronizer { get; set; }
    Property Value
    Type Description
    ISynchronizer
    Implements
    ITimedDataSource.Synchronizer
    Remarks

    In most cases you can simply implement this as an auto-property. The default synchronizer implementation automatically assigns this property when you call AddDataSource(ITimedDataSource).

    Methods

    AddSample<T>(in T, in FrameTimeWithRate)

    Adds a new data sample to the buffer.

    Declaration
    public void AddSample<T>(in T value, in FrameTimeWithRate time)
    Parameters
    Type Name Description
    T value

    The sample value to add.

    FrameTimeWithRate time

    The time of the sample.

    Type Parameters
    Name Description
    T

    The datatype of the sample.

    See Also
    AddSampleWithGeneratedTime<T>(in T)

    AddSampleWithGeneratedTime<T>(in T)

    Adds a new data sample to the buffer.

    Declaration
    public FrameTimeWithRate AddSampleWithGeneratedTime<T>(in T value)
    Parameters
    Type Name Description
    T value

    The sample value to add.

    Returns
    Type Description
    FrameTimeWithRate

    The generated sample time.

    Type Parameters
    Name Description
    T

    The datatype of the sample.

    Remarks

    Use this when a device does not provide timecode information with the samples, and instead relies on genlock to facilitate synchronization. When this data source is assigned to a synchronizer, a timecode will be generated using the synchronizer's presentation time. This should usually be called once per frame. When called multiple times in a single frame, the new value will overwrite any previous values submitted for the current frame.

    See Also
    AddSample<T>(in T, in FrameTimeWithRate)

    ClearBuffer()

    Removes all frames from the data buffer.

    Declaration
    public void ClearBuffer()

    Disable()

    Deactivates the data source.

    Declaration
    public void Disable()

    Enable(ITimedDataBuffer)

    Activates the data source.

    Declaration
    public void Enable(ITimedDataBuffer buffer)
    Parameters
    Type Name Description
    ITimedDataBuffer buffer

    The buffer to use for storing frame samples.

    GenerateFrameTime(in FrameRate)

    Gets a time based on the current engine time.

    Declaration
    public static FrameTimeWithRate GenerateFrameTime(in FrameRate frameRate)
    Parameters
    Type Name Description
    FrameRate frameRate

    The frame rate of the frame sequence.

    Returns
    Type Description
    FrameTimeWithRate

    The generated time.

    GetSamplesInRange<T>(FrameTime, FrameTime)

    Declaration
    public IEnumerable<(FrameTime time, T value)> GetSamplesInRange<T>(FrameTime from, FrameTime to)
    Parameters
    Type Name Description
    FrameTime from
    FrameTime to
    Returns
    Type Description
    IEnumerable<(T1, T2)<FrameTime, T>>
    Type Parameters
    Name Description
    T

    TryGetBufferRange(out FrameTime, out FrameTime)

    Gets the frame time of the newest and oldest samples buffered by the data source.

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

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

    FrameTime newestSample

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

    Returns
    Type Description
    Boolean

    true if there are any buffered samples; otherwise, false.

    Implements
    ITimedDataSource.TryGetBufferRange(out FrameTime, out FrameTime)
    Remarks

    The frame duration corresponds to the FrameRate of this source.

    TryGetSample<T>(FrameTime, out T)

    Declaration
    public TimedSampleStatus TryGetSample<T>(FrameTime frame, out T value)
    Parameters
    Type Name Description
    FrameTime frame
    T value
    Returns
    Type Description
    TimedSampleStatus
    Type Parameters
    Name Description
    T

    Events

    FramePresented

    An event invoked when this source presents a synchronized frame.

    Declaration
    public event Action<FrameTimeWithRate> FramePresented
    Event Type
    Type Description
    Action<FrameTimeWithRate>
    Remarks

    This method is only invoked when IsSynchronized is true.

    • The parameter is the sample time for the presented frame.

    Explicit Interface Implementations

    IRegistrable.FriendlyName

    Get a human-readable name for the instance.

    Declaration
    string IRegistrable.FriendlyName { get; }
    Returns
    Type Description
    String
    Implements
    IRegistrable.FriendlyName

    IRegistrable.Id

    Get the unique identifier for this instance.

    Declaration
    string IRegistrable.Id { get; }
    Returns
    Type Description
    String
    Implements
    IRegistrable.Id
    Remarks

    The ID should not be null or empty, and is expected to remain constant for the life of the instance.

    ITimedDataSource.PresentAt(FrameTimeWithRate)

    Applies the data for a given timecode to the scene.

    Declaration
    TimedSampleStatus ITimedDataSource.PresentAt(FrameTimeWithRate presentTime)
    Parameters
    Type Name Description
    FrameTimeWithRate presentTime

    The timecode to present.

    Returns
    Type Description
    TimedSampleStatus

    A status representing the ability of the source to present at the requested timecode.

    Implements
    ITimedDataSource.PresentAt(FrameTimeWithRate)

    ITimedDataSource.UndoTarget

    The object to record to the undo stack when the user modifies the properties of this data source.

    Declaration
    Object ITimedDataSource.UndoTarget { get; }
    Returns
    Type Description
    Object
    Implements
    ITimedDataSource.UndoTarget
    Remarks

    To enable undo when using the synchronization windows, this must be the object that stores the serialized state for this data source. When null, this data source will not support undo operations.

    Back to top Copyright © 2023 Unity Technologies — Terms of use
    Generated by DocFX
    on Wednesday, May 17, 2023