Voyant API 1.0.0
Loading...
Searching...
No Matches
voyant_data_recorder.hpp
Go to the documentation of this file.
1// Copyright (c) 2024-2025 Voyant Photonics, Inc.
2// All rights reserved.
3
4#pragma once
5
6#include <optional>
7#include <string>
8#include <voyant_frame.hpp>
10
23
30{
31
36 explicit VoyantRecorderConfig(const std::string& path)
37 : outputPath(path)
38 {
39 }
40
42 std::string outputPath;
43
45 bool timestampFilename = true;
46
48 bool overwrite = false;
49
51 uint32_t framesPerFile = 0;
52
54 uint64_t durationPerFile = 0;
55
57 uint64_t sizePerFileMb = 0;
58
60 uint32_t maxTotalFrames = 0;
61
63 uint64_t maxTotalDuration = 0;
64
66 uint64_t maxTotalSizeMb = 0;
67};
68
74{
75public:
80 explicit VoyantRecorder(const VoyantRecorderConfig& config);
81
86
90
101
106 bool finalize();
107
113 std::optional<size_t> getTotalFramesRecorded() const;
114
120 std::optional<size_t> getSplitCount() const;
121
126 bool isValid() const;
127
135 std::string getLastError() const;
136
144 std::string getCurrentFilePath() const;
145
146private:
149 std::string lastErrorMsg_;
150 // Captured before finalize() consumes the Rust recorder, so the counts survive it.
151 std::optional<size_t> finalFrames_;
152 std::optional<size_t> finalSplits_;
153 std::string finalPath_;
154};
A point-cloud frame: points plus the sensor/host state snapshots and frame metadata recorded with the...
Definition voyant_frame.hpp:68
VoyantRecorder & operator=(const VoyantRecorder &)=delete
std::optional< size_t > finalSplits_
Definition voyant_data_recorder.hpp:152
VoyantRecorder(const VoyantRecorderConfig &config)
Constructor that takes a configuration struct.
VoyantRecorderC * recorderHandle_
Definition voyant_data_recorder.hpp:147
std::string getCurrentFilePath() const
Path of the file being written, with timestamp and split naming resolved.
bool finalized_
Definition voyant_data_recorder.hpp:148
std::optional< size_t > getTotalFramesRecorded() const
Gets the total number of frames recorded.
std::optional< size_t > finalFrames_
Definition voyant_data_recorder.hpp:151
std::string getLastError() const
Why construction failed, or an empty string if it did not.
bool isValid() const
Checks if the recorder is valid.
std::string finalPath_
Definition voyant_data_recorder.hpp:153
~VoyantRecorder()
Destructor - automatically finalizes recording if needed.
std::string lastErrorMsg_
Definition voyant_data_recorder.hpp:149
bool finalize()
Finalizes the recording and closes all files.
VoyantRecorder(const VoyantRecorder &)=delete
Non-copyable.
std::optional< size_t > getSplitCount() const
Gets the number of files created.
RecordResult recordFrame(const VoyantFrame &frame)
Records a frame to the current file.
Definition voyant_recorder_ffi.hpp:21
Configuration settings for creating a VoyantRecorder instance.
Definition voyant_data_recorder.hpp:30
uint64_t maxTotalDuration
Max total duration in seconds across all files. Defaults to 0 (no limit).
Definition voyant_data_recorder.hpp:63
VoyantRecorderConfig(const std::string &path)
Constructs a configuration for the recorder.
Definition voyant_data_recorder.hpp:36
uint64_t durationPerFile
Max duration per file in seconds before splitting. Defaults to 0 (no limit).
Definition voyant_data_recorder.hpp:54
bool overwrite
If true, an existing output file is overwritten. Defaults to false (creation fails instead).
Definition voyant_data_recorder.hpp:48
uint32_t framesPerFile
Max frames per file before splitting. Defaults to 0 (no limit).
Definition voyant_data_recorder.hpp:51
bool timestampFilename
If true, appends a timestamp to the output filename. Defaults to true.
Definition voyant_data_recorder.hpp:45
std::string outputPath
Base path for output files (.vynt). This is a required field.
Definition voyant_data_recorder.hpp:42
uint64_t maxTotalSizeMb
Max total size in MB across all files. Defaults to 0 (no limit).
Definition voyant_data_recorder.hpp:66
uint32_t maxTotalFrames
Max total frames across all files. Defaults to 0 (no limit).
Definition voyant_data_recorder.hpp:60
uint64_t sizePerFileMb
Max size per file in MB before splitting. Defaults to 0 (no limit).
Definition voyant_data_recorder.hpp:57
RecordResult
Result of recording a frame.
Definition voyant_data_recorder.hpp:16
@ Unknown
Uninitialized or unexpected result.
Definition voyant_data_recorder.hpp:17
@ Split
Successfully recorded frame, file was split due to limits.
Definition voyant_data_recorder.hpp:19
@ Finished
Limits reached, this frame was not written - stop (not an error).
Definition voyant_data_recorder.hpp:20
@ Error
Failed to record frame (error occurred).
Definition voyant_data_recorder.hpp:21
@ Ok
Successfully recorded frame, continue recording.
Definition voyant_data_recorder.hpp:18