Voyant API 0.2.1
Loading...
Searching...
No Matches
Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
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 filter_points=false)
 
 ~VoyantPlayback ()
 Destructor.
 
 VoyantPlayback (const VoyantPlayback &)=delete
 Non-copyable.
 
VoyantPlaybackoperator= (const VoyantPlayback &)=delete
 
bool openFile (const std::string &filePath)
 
bool nextFrame ()
 
const VoyantFrameWrappercurrentFrame () const
 
VoyantFrameWrappercurrentFrame ()
 
uint64_t currentFrameTimestamp ()
 
size_t currentFrameIndex ()
 
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
 
VoyantFrameWrapper currentFrameData
 
uint8_t * frameBuffer
 

Static Private Attributes

static constexpr size_t BUFFER_SIZE = 4 * 1024 * 1024
 

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  filter_points = false 
)

Constructor

Parameters
ratePlayback rate (1.0 = real-time, 0 = as fast as possible)
loopWhether to loop when reaching the end of file
filter_pointsWhether to filter out invalid points during playback. When true, invalid points will be removed from frames. When false, all points including invalid ones will be included.

◆ ~VoyantPlayback()

VoyantPlayback::~VoyantPlayback ( )

Destructor.

◆ VoyantPlayback() [2/2]

VoyantPlayback::VoyantPlayback ( const VoyantPlayback )
delete

Non-copyable.

Member Function Documentation

◆ applyTiming()

void VoyantPlayback::applyTiming ( uint64_t  currentTimestamp)
private

Applies timing based on the current frame and playback rate.

◆ currentFrame() [1/2]

VoyantFrameWrapper & VoyantPlayback::currentFrame ( )

Gets the current frame (mutable version)

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

◆ currentFrame() [2/2]

const VoyantFrameWrapper & 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)

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 parses the frame data into the pre-allocated frame wrapper

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

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

◆ operator=()

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

◆ parseCurrentFrame()

bool VoyantPlayback::parseCurrentFrame ( )
private

Parses the current frame from the C API

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

◆ BUFFER_SIZE

constexpr size_t VoyantPlayback::BUFFER_SIZE = 4 * 1024 * 1024
staticconstexprprivate

◆ currentFrameData

VoyantFrameWrapper VoyantPlayback::currentFrameData
private

◆ firstFrame

bool VoyantPlayback::firstFrame
private

◆ firstFrameTimestamp

uint64_t VoyantPlayback::firstFrameTimestamp
private

◆ frameBuffer

uint8_t* VoyantPlayback::frameBuffer
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: