-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbindings_recorder.cpp
More file actions
163 lines (138 loc) · 6.31 KB
/
Copy pathbindings_recorder.cpp
File metadata and controls
163 lines (138 loc) · 6.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
#include "bindings_common.h"
void register_recorder(py::module& m) {
// RecordingSummary structure
py::class_<ope::tools::Recorder::RecordingSummary>(m, "RecordingSummary")
.def(py::init<>())
.def_readonly("expected_buffers", &ope::tools::Recorder::RecordingSummary::expectedBuffers,
"Number of buffers requested to record")
.def_readonly("raw_recorded", &ope::tools::Recorder::RecordingSummary::rawRecorded,
"Number of raw buffers actually recorded")
.def_readonly("processed_recorded", &ope::tools::Recorder::RecordingSummary::processedRecorded,
"Number of processed buffers actually recorded")
.def_readonly("raw_buffer_ids", &ope::tools::Recorder::RecordingSummary::rawBufferIds,
"List of buffer IDs for recorded raw buffers")
.def_readonly("processed_buffer_ids", &ope::tools::Recorder::RecordingSummary::processedBufferIds,
"List of buffer IDs for recorded processed buffers")
.def_readonly("complete", &ope::tools::Recorder::RecordingSummary::complete,
"True if all requested buffers were recorded")
.def("__repr__", [](const ope::tools::Recorder::RecordingSummary& self) {
return "<RecordingSummary(expected=" + std::to_string(self.expectedBuffers) +
", raw=" + std::to_string(self.rawRecorded) +
", processed=" + std::to_string(self.processedRecorded) +
", complete=" + (self.complete ? "True" : "False") + ")>";
});
// Recorder class
py::class_<ope::tools::Recorder>(m, "Recorder")
.def(py::init<>(),
"Create a new Recorder instance\n\n"
"Must be attached to a Processor before use.")
// Configuration
.def("attach_to_processor", [](ope::tools::Recorder& self, ProcessorWrapper& wrapper) {
py::gil_scoped_release release;
self.attachToProcessor(&wrapper.processor);
}, py::arg("processor"), py::keep_alive<1, 2>(),
"Attach recorder to a processor\n\n"
"Args:\n"
" processor: Processor instance to attach to")
.def("set_mode", &ope::tools::Recorder::setMode, py::arg("mode"),
"Set recording mode\n\n"
"Args:\n"
" mode: RecorderMode (RAW_ONLY, PROCESSED_ONLY, or BOTH)")
.def("set_output_directory", &ope::tools::Recorder::setOutputDirectory, py::arg("directory"),
"Set output directory for recorded files\n\n"
"Args:\n"
" directory: Path to output directory")
.def("set_output_base_name", &ope::tools::Recorder::setOutputBaseName, py::arg("base_name"),
"Set base name for output files\n\n"
"Args:\n"
" base_name: Base name (files will be named <base_name>_raw.bin, etc.)")
.def("set_raw_format", &ope::tools::Recorder::setRawFormat, py::arg("format"),
"Set format for raw data files\n\n"
"Args:\n"
" format: RecorderFormat.RAW_BINARY")
.def("set_processed_format", &ope::tools::Recorder::setProcessedFormat, py::arg("format"),
"Set format for processed data files\n\n"
"Args:\n"
" format: RecorderFormat.RAW_BINARY")
.def("set_buffer_count", &ope::tools::Recorder::setBufferCount, py::arg("count"),
"Set number of buffers to record\n\n"
"Args:\n"
" count: Number of buffers to record")
.def("get_buffer_count", &ope::tools::Recorder::getBufferCount,
"Get number of buffers to record\n\n"
"Returns:\n"
" int: Number of buffers")
.def("set_write_metadata", &ope::tools::Recorder::setWriteMetadata, py::arg("enabled"),
"Enable/disable writing metadata files\n\n"
"Args:\n"
" enabled: True to write metadata")
.def("set_use_timestamp", &ope::tools::Recorder::setUseTimestamp, py::arg("enabled"),
"Enable/disable timestamps in filenames\n\n"
"Args:\n"
" enabled: True to add timestamps")
.def("set_manual_allocation", &ope::tools::Recorder::setManualAllocation, py::arg("manual"),
"Enable manual buffer allocation mode\n\n"
"If enabled, you must call allocate_buffers() before startRecording()\n\n"
"Args:\n"
" manual: True for manual allocation")
// Buffer management
.def("allocate_buffers", [](ope::tools::Recorder& self) {
py::gil_scoped_release release;
self.allocateBuffers();
},
"Allocate recording buffers\n\n"
"Only needed if set_manual_allocation(True) was called")
.def("free_buffers", &ope::tools::Recorder::freeBuffers,
"Free allocated recording buffers")
.def("is_allocated", &ope::tools::Recorder::isAllocated,
"Check if buffers are allocated\n\n"
"Returns:\n"
" bool: True if buffers allocated")
// Recording control
.def("start_recording", [](ope::tools::Recorder& self, bool wait_for_volume_start) {
py::gil_scoped_release release;
self.startRecording(wait_for_volume_start);
}, py::arg("wait_for_volume_start") = false,
"Start recording\n\n"
"Args:\n"
" wait_for_volume_start: If True, wait for volume boundary before recording")
.def("stop_recording", [](ope::tools::Recorder& self) {
py::gil_scoped_release release;
self.stopRecording();
},
"Stop recording and write files to disk\n\n"
"This will block until writing is complete")
.def("abort_recording", &ope::tools::Recorder::abortRecording,
"Abort recording without saving")
.def("is_recording", &ope::tools::Recorder::isRecording,
"Check if currently recording\n\n"
"Returns:\n"
" bool: True if recording")
.def("get_status", &ope::tools::Recorder::getStatus,
"Get current recorder status\n\n"
"Returns:\n"
" RecorderStatus: Current status")
// Results
.def("wait_for_completion", [](ope::tools::Recorder& self, int timeout_ms) {
py::gil_scoped_release release;
return self.waitForCompletion(timeout_ms);
}, py::arg("timeout_ms"),
"Wait for recording to complete\n\n"
"Args:\n"
" timeout_ms: Timeout in milliseconds\n\n"
"Returns:\n"
" bool: True if completed successfully, False if timed out or failed")
.def("get_last_recording_summary", &ope::tools::Recorder::getLastRecordingSummary,
"Get summary of last recording\n\n"
"Returns:\n"
" RecordingSummary: Summary with buffer counts and IDs")
.def("get_last_error", &ope::tools::Recorder::getLastError,
"Get last error message\n\n"
"Returns:\n"
" str: Error message or empty string if no error")
.def("__repr__", [](const ope::tools::Recorder& self) {
const char* status_str[] = {"IDLE", "READY", "RECORDING", "WRITING", "COMPLETED", "ERROR"};
int status_idx = static_cast<int>(self.getStatus());
return "<Recorder(status=" + std::string(status_str[status_idx]) + ")>";
});
}