Voyant API 1.0.0
Loading...
Searching...
No Matches
VoyantPlayback Class Reference

C++ wrapper for the Voyant playback system with timing capabilities. More...

#include <voyant_playback.hpp>

Public Member Functions

 VoyantPlayback (double rate=1.0, bool loop=false, bool keep_invalid_points=false)
 ~VoyantPlayback ()
 Destructor.
 VoyantPlayback (const VoyantPlayback &)=delete
 Non-copyable.
VoyantPlaybackoperator= (const VoyantPlayback &)=delete
bool openFile (const std::string &filePath)
bool nextFrame ()
const VoyantFramecurrentFrame () const
VoyantFramecurrentFrame ()
uint64_t currentFrameTimestamp ()
size_t currentFrameIndex ()
std::string apiVersion ()
size_t getFramesProcessed () const
size_t getLoopsCompleted () const
bool isValid () const
std::string getLastError () const

Private Member Functions

void applyTiming (uint64_t currentTimestamp)
 Applies timing based on the current frame and playback rate.
void resetTiming ()
 Resets the timing when starting a new loop.
bool parseCurrentFrame ()
void setError (const std::string &message)
 Sets an error message and invalidates the frame.

Private Attributes

void * playbackHandle
double playbackRate
bool looping
uint64_t prevTimestamp
std::chrono::steady_clock::time_point startTime
uint64_t firstFrameTimestamp
bool firstFrame
size_t framesProcessed
size_t loopsCompleted
std::string lastErrorMsg
VoyantFrame currentFrameData

Detailed Description

C++ wrapper for the Voyant playback system with timing capabilities.

Constructor & Destructor Documentation

◆ VoyantPlayback() [1/2]

VoyantPlayback::VoyantPlayback ( double rate = 1.0,
bool loop = false,
bool keep_invalid_points = false )

Constructor

Parameters
ratePlayback rate (1.0 = real-time, 0 = as fast as possible). A rate too small to pace (below 0.001x) also plays as fast as possible.
loopWhether to loop when reaching the end of file
keep_invalid_pointsWhether frames keep their invalid points. When false (default), invalid points are removed as frames are read. Invalid points come from a capture made with the client's diagnostic mode enabled, or from frames constructed or edited by hand.

◆ ~VoyantPlayback()

VoyantPlayback::~VoyantPlayback ( )

Destructor.

◆ VoyantPlayback() [2/2]

VoyantPlayback::VoyantPlayback ( const VoyantPlayback & )
delete

Non-copyable.

Member Function Documentation

◆ apiVersion()

std::string VoyantPlayback::apiVersion ( )

Gets the version of the API that wrote the open recording, e.g. "1.0.0" or "1.0.0-alpha". A converted recording reports the version of the API that produced the original, not the one that converted it.

Returns
Version string, or empty string if no file is open

◆ applyTiming()

void VoyantPlayback::applyTiming ( uint64_t currentTimestamp)
private

Applies timing based on the current frame and playback rate.

◆ currentFrame() [1/2]

VoyantFrame & VoyantPlayback::currentFrame ( )

Gets the current frame (mutable version) — edit points and record the frame to save the result; see VoyantFrame

Returns
Mutable reference to the current frame
Warning
Only valid if nextFrame() returned true and no error occurred

◆ currentFrame() [2/2]

const VoyantFrame & VoyantPlayback::currentFrame ( ) const

Gets the current frame (const version)

Returns
Const reference to the current frame
Warning
Only valid if nextFrame() returned true and no error occurred

◆ currentFrameIndex()

size_t VoyantPlayback::currentFrameIndex ( )

Gets the current frame index (0-based position in the file; the device frame counter is currentFrame().frameIndex())

Returns
Current frame index, 0 if invalid
Warning
Only valid if nextFrame() returned true and no error occurred

◆ currentFrameTimestamp()

uint64_t VoyantPlayback::currentFrameTimestamp ( )

Gets the current frame timestamp in nanoseconds

Returns
Timestamp in nanoseconds, 0 if invalid
Warning
Only valid if nextFrame() returned true and no error occurred

◆ getFramesProcessed()

size_t VoyantPlayback::getFramesProcessed ( ) const

Gets the number of frames processed

Returns
Number of frames processed

◆ getLastError()

std::string VoyantPlayback::getLastError ( ) const

Gets the last error message

Returns
Last error message or empty string if no error

◆ getLoopsCompleted()

size_t VoyantPlayback::getLoopsCompleted ( ) const

Gets the number of loops completed

Returns
Number of loops completed

◆ isValid()

bool VoyantPlayback::isValid ( ) const

Checks if the playback handle is valid

Returns
true if valid, false otherwise

◆ nextFrame()

bool VoyantPlayback::nextFrame ( )

Reads the next frame, automatically applying timing and handling loopback, and copies the frame into currentFrame(). Loopback rewinds at most once per call, so a recording holding no frame ends playback instead of rewinding forever.

Returns
true if a frame was successfully read, false if at end of file or error

◆ openFile()

bool VoyantPlayback::openFile ( const std::string & filePath)

Opens a file for playback

Reads only native (v1.0.0+) recordings; a pre-v1.0.0 recording is rejected with an error naming the conversion tool, leaving any open file usable.

Parameters
filePathPath to the recording file
Returns
true if successful, false otherwise

◆ operator=()

VoyantPlayback & VoyantPlayback::operator= ( const VoyantPlayback & )
delete

◆ parseCurrentFrame()

bool VoyantPlayback::parseCurrentFrame ( )
private

Copies the current frame from the C API into currentFrameData

Returns
true if successful, false otherwise

◆ resetTiming()

void VoyantPlayback::resetTiming ( )
private

Resets the timing when starting a new loop.

◆ setError()

void VoyantPlayback::setError ( const std::string & message)
private

Sets an error message and invalidates the frame.

Member Data Documentation

◆ currentFrameData

VoyantFrame VoyantPlayback::currentFrameData
private

◆ firstFrame

bool VoyantPlayback::firstFrame
private

◆ firstFrameTimestamp

uint64_t VoyantPlayback::firstFrameTimestamp
private

◆ framesProcessed

size_t VoyantPlayback::framesProcessed
private

◆ lastErrorMsg

std::string VoyantPlayback::lastErrorMsg
private

◆ looping

bool VoyantPlayback::looping
private

◆ loopsCompleted

size_t VoyantPlayback::loopsCompleted
private

◆ playbackHandle

void* VoyantPlayback::playbackHandle
private

◆ playbackRate

double VoyantPlayback::playbackRate
private

◆ prevTimestamp

uint64_t VoyantPlayback::prevTimestamp
private

◆ startTime

std::chrono::steady_clock::time_point VoyantPlayback::startTime
private

The documentation for this class was generated from the following file: