10 #include <k4arecord/record.h> 36 other.m_handle =
nullptr;
56 m_handle = other.m_handle;
57 other.m_handle =
nullptr;
65 explicit operator bool() const noexcept
74 return m_handle !=
nullptr;
85 k4a_record_close(m_handle);
102 throw error(
"Failed to flush!");
112 void add_tag(
const char *name,
const char *value)
114 k4a_result_t result = k4a_record_add_tag(m_handle, name, value);
118 throw error(
"Failed to add tag!");
129 k4a_result_t result = k4a_record_add_imu_track(m_handle);
133 throw error(
"Failed to add imu_track!");
142 void add_attachment(
const char *attachment_name,
const uint8_t *buffer,
size_t buffer_size)
144 k4a_result_t result = k4a_record_add_attachment(m_handle, attachment_name, buffer, buffer_size);
148 throw error(
"Failed to add attachment!");
158 const char *codec_id,
159 const uint8_t *codec_context,
160 size_t codec_context_size,
163 k4a_result_t result = k4a_record_add_custom_video_track(m_handle,
172 throw error(
"Failed to add custom video track!");
182 const char *codec_id,
183 const uint8_t *codec_context,
184 size_t codec_context_size,
187 k4a_result_t result = k4a_record_add_custom_subtitle_track(m_handle,
196 throw error(
"Failed to add custom subtitle track!");
207 k4a_result_t result = k4a_record_write_header(m_handle);
211 throw error(
"Failed to write header!");
226 throw error(
"Failed to write capture!");
237 k4a_result_t result = k4a_record_write_imu_sample(m_handle, imu_sample);
241 throw error(
"Failed to write imu sample!");
251 const std::chrono::microseconds device_timestamp_usec,
252 uint8_t *custom_data,
253 size_t custom_data_size)
255 k4a_result_t result = k4a_record_write_custom_track_data(m_handle,
257 internal::clamp_cast<uint64_t>(
258 device_timestamp_usec.count()),
264 throw error(
"Failed to write custom track data!");
276 k4a_result_t result = k4a_record_create(path, device.
handle(), device_configuration, &handle);
280 throw error(
"Failed to create recorder!");
record & operator=(record &&other) noexcept
Moves another k4a::record into this k4a::record; other is set to invalid.
Definition: record.hpp:51
void add_tag(const char *name, const char *value)
Adds a tag to the recording Throws error on failure.
Definition: record.hpp:112
Structure containing additional metadata specific to custom subtitle tracks.
Definition: types.h:239
void add_custom_subtitle_track(const char *track_name, const char *codec_id, const uint8_t *codec_context, size_t codec_context_size, const k4a_record_subtitle_settings_t *track_settings)
Adds custom subtitle tracks to the recording Throws error on failure.
Definition: record.hpp:181
bool is_valid() const noexcept
Returns true if the k4a::record is valid, false otherwise.
Definition: record.hpp:72
k4a_result_t
Result code returned by Azure Kinect APIs.
Definition: k4atypes.h:217
Exception type thrown when a K4A API call fails.
Definition: k4a.hpp:33
void add_attachment(const char *attachment_name, const uint8_t *buffer, size_t buffer_size)
Adds an attachment to the recording Throws error on failure.
Definition: record.hpp:142
void add_custom_video_track(const char *track_name, const char *codec_id, const uint8_t *codec_context, size_t codec_context_size, const k4a_record_video_settings_t *track_settings)
Adds custom video tracks to the recording Throws error on failure.
Definition: record.hpp:157
void flush()
Flushes all pending recording data to disk.
Definition: record.hpp:94
#define K4A_FAILED(_result_)
Validate that a k4a_result_t is failed.
Definition: k4atypes.h:753
IMU sample.
Definition: k4atypes.h:1199
void write_custom_track_data(const char *track_name, const std::chrono::microseconds device_timestamp_usec, uint8_t *custom_data, size_t custom_data_size)
Writes data for a custom track to file Throws error on failure.
Definition: record.hpp:250
record(k4a_record_t handle=nullptr) noexcept
Creates a k4a::record from a k4a_record_t Takes ownership of the handle, i.e.
Definition: record.hpp:30
Wrapper for k4a_record_t.
Definition: record.hpp:22
Wrapper for k4a_capture_t.
Definition: k4a.hpp:414
void add_imu_track()
Adds the track header for recording IMU Throws error on failure.
Definition: record.hpp:127
void write_capture(const capture &capture)
Writes a camera capture to file Throws error on failure.
Definition: record.hpp:220
k4a_device_t handle() const noexcept
Returns the underlying k4a_device_t handle.
Definition: k4a.hpp:1145
Structure containing additional metadata specific to custom video tracks.
Definition: types.h:224
static record create(const char *path, const device &device, const k4a_device_configuration_t &device_configuration)
Opens a new recording file for writing Throws error on failure.
Definition: record.hpp:273
k4a_capture_t handle() const noexcept
Returns the underlying k4a_capture_t handle.
Definition: k4a.hpp:532
void write_imu_sample(const k4a_imu_sample_t &imu_sample)
Writes an imu sample to file Throws error on failure.
Definition: record.hpp:235
Wrapper for k4a_device_t.
Definition: k4a.hpp:1087
Configuration parameters for an Azure Kinect device.
Definition: k4atypes.h:917
void write_header()
Writes the recording header and metadata to file Throws error on failure.
Definition: record.hpp:205
record(record &&other) noexcept
Moves another k4a::record into a new k4a::record.
Definition: record.hpp:34
void close() noexcept
Closes a K4A recording.
Definition: record.hpp:81
Handle to a k4a recording opened for writing.
Definition: types.h:34