Voyant API 0.8.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 <memory>
7#include <optional>
8#include <string>
9#include <vector>
12
17enum class RecordResult
18{
19 Unknown = 0,
20 Ok,
21 Split,
22 Finished,
23 Error
24};
25
32{
33
38 explicit VoyantRecorderConfig(const std::string& path)
39 : outputPath(path)
40 {
41 }
42
44 std::string outputPath;
45
47 bool timestampFilename = true;
48
50 uint32_t framesPerFile = 0;
51
53 uint64_t durationPerFile = 0;
54
56 uint64_t sizePerFileMb = 0;
57
59 uint32_t maxTotalFrames = 0;
60
62 uint64_t maxTotalDuration = 0;
63
65 uint64_t maxTotalSizeMb = 0;
66
68 uint64_t bufferSizeMb = 4;
69};
70
76{
77public:
82 explicit VoyantRecorder(const VoyantRecorderConfig& config);
83
88
92
99
104 bool finalize();
105
110 std::optional<size_t> getTotalFramesRecorded() const;
111
116 std::optional<size_t> getSplitCount() const;
117
122 bool isValid() const;
123
124private:
127 std::string lastErrorMsg_;
128
129 std::vector<uint8_t> buffer_;
130};
Wrapper for VoyantFrame messages.
Definition voyant_frame_wrapper.hpp:19
Class for recording Voyant frames to binary files with automatic splitting.
Definition voyant_data_recorder.hpp:76
VoyantRecorder & operator=(const VoyantRecorder &)=delete
VoyantRecorder(const VoyantRecorderConfig &config)
Constructor that takes a configuration struct.
VoyantRecorderC * recorderHandle_
Definition voyant_data_recorder.hpp:125
RecordResult recordFrame(const VoyantFrameWrapper &frame)
Records a frame to the current file.
std::vector< uint8_t > buffer_
Definition voyant_data_recorder.hpp:129
bool finalized_
Definition voyant_data_recorder.hpp:126
std::optional< size_t > getTotalFramesRecorded() const
Gets the total number of frames recorded.
bool isValid() const
Checks if the recorder is valid.
~VoyantRecorder()
Destructor - automatically finalizes recording if needed.
std::string lastErrorMsg_
Definition voyant_data_recorder.hpp:127
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 file splits that have occurred.
Definition voyant_recorder_ffi.hpp:20
Configuration settings for creating a VoyantRecorder instance.
Definition voyant_data_recorder.hpp:32
uint64_t maxTotalDuration
Max total duration in seconds across all files. Defaults to 0 (no limit).
Definition voyant_data_recorder.hpp:62
VoyantRecorderConfig(const std::string &path)
Constructs a configuration for the recorder.
Definition voyant_data_recorder.hpp:38
uint64_t durationPerFile
Max duration per file in seconds before splitting. Defaults to 0 (no limit).
Definition voyant_data_recorder.hpp:53
uint32_t framesPerFile
Max frames per file before splitting. Defaults to 0 (no limit).
Definition voyant_data_recorder.hpp:50
bool timestampFilename
If true, appends a timestamp to the output filename. Defaults to true.
Definition voyant_data_recorder.hpp:47
std::string outputPath
Base path for output files. This is a required field.
Definition voyant_data_recorder.hpp:44
uint64_t bufferSizeMb
Frame buffer size in MB for writing. Defaults to 4MB. For advanced users.
Definition voyant_data_recorder.hpp:68
uint64_t maxTotalSizeMb
Max total size in MB across all files. Defaults to 0 (no limit).
Definition voyant_data_recorder.hpp:65
uint32_t maxTotalFrames
Max total frames across all files. Defaults to 0 (no limit).
Definition voyant_data_recorder.hpp:59
uint64_t sizePerFileMb
Max size per file in MB before splitting. Defaults to 0 (no limit).
Definition voyant_data_recorder.hpp:56
RecordResult
Result of recording a frame.
Definition voyant_data_recorder.hpp:18
@ Unknown
Uninitialized or unexpected result.
@ Split
Successfully recorded frame, file was split due to limits.
@ Finished
Limits reached - recording should stop (not an error)
@ Error
Failed to record frame (error occurred)
@ Ok
Successfully recorded frame, continue recording.