7#ifndef K4A_PLAYBACK_HPP
8#define K4A_PLAYBACK_HPP
43 m_handle = other.m_handle;
44 other.m_handle =
nullptr;
59 m_handle = other.m_handle;
60 other.m_handle =
nullptr;
67 explicit operator bool() const noexcept
76 return m_handle !=
nullptr;
85 k4a_playback_data_block_release(m_handle);
96 return std::chrono::microseconds(k4a_playback_data_block_get_device_timestamp_usec(m_handle));
105 return k4a_playback_data_block_get_buffer_size(m_handle);
114 return k4a_playback_data_block_get_buffer(m_handle);
142 other.m_handle =
nullptr;
152 playback &operator=(
const playback &) =
delete;
161 m_handle = other.m_handle;
162 other.m_handle =
nullptr;
170 explicit operator bool() const noexcept
179 return m_handle !=
nullptr;
188 if (m_handle !=
nullptr)
190 k4a_playback_close(m_handle);
209 result = k4a_playback_get_raw_calibration(m_handle, &
calibration[0], &buffer);
214 throw error(
"Failed to read raw device calibration from recording!");
228 k4a_result_t result = k4a_playback_get_calibration(m_handle, &calib);
232 throw error(
"Failed to read device calibration from recording!");
245 k4a_result_t result = k4a_playback_get_record_configuration(m_handle, &config);
249 throw error(
"Failed to read record configuration!");
268 *cap =
capture(capture_handle);
276 throw error(
"Failed to get next capture!");
292 *cap =
capture(capture_handle);
300 throw error(
"Failed to get previous capture!");
308 bool get_tag(
const char *name, std::string *out)
const
317 result = k4a_playback_get_tag(m_handle, name, &tag[0], &buffer);
323 tag.resize(buffer - 1);
332 *out = std::move(tag);
356 throw error(
"Failed to get next IMU sample!");
378 throw error(
"Failed to get previous IMU sample!");
388 k4a_result_t result = k4a_playback_seek_timestamp(m_handle, offset.count(), origin);
392 throw error(
"Failed to seek recording!");
402 return std::chrono::microseconds(k4a_playback_get_recording_length_usec(m_handle));
414 k4a_result_t result = k4a_playback_set_color_conversion(m_handle, format);
418 throw error(
"Failed to set color conversion!");
431 k4a_stream_result_t result = k4a_playback_get_next_data_block(m_handle, track, &block_handle);
443 throw error(
"Failed to get next data block!");
455 k4a_stream_result_t result = k4a_playback_get_previous_data_block(m_handle, track, &block_handle);
467 throw error(
"Failed to get previous data block!");
478 size_t data_size = 0;
482 data->resize(data_size);
486 throw error(
"Failed to read attachment!");
505 throw error(
"Failed to open recording!");
data_block(k4a_playback_data_block_t handle=nullptr) noexcept
const uint8_t * get_buffer() const noexcept
std::chrono::microseconds get_device_timestamp_usec() const noexcept
size_t get_buffer_size() const noexcept
data_block & operator=(data_block &&other) noexcept
bool is_valid() const noexcept
data_block(data_block &&other) noexcept
std::vector< uint8_t > get_raw_calibration() const
void seek_timestamp(std::chrono::microseconds offset, k4a_playback_seek_origin_t origin)
playback(k4a_playback_t handle=nullptr) noexcept
bool is_valid() const noexcept
bool get_previous_data_block(const char *track, data_block *block)
bool get_next_imu_sample(k4a_imu_sample_t *sample)
bool get_next_data_block(const char *track, data_block *block)
bool get_previous_capture(capture *cap)
bool get_previous_imu_sample(k4a_imu_sample_t *sample)
bool get_tag(const char *name, std::string *out) const
static playback open(const char *path)
std::chrono::microseconds get_recording_length() const noexcept
calibration get_calibration() const
void set_color_conversion(k4a_image_format_t format)
k4a_record_configuration_t get_record_configuration() const
bool get_attachment(const char *attachment, std::vector< uint8_t > *data)
playback & operator=(playback &&other) noexcept
bool get_next_capture(capture *cap)
playback(playback &&other) noexcept
k4a_playback_seek_origin_t
@ K4A_BUFFER_RESULT_TOO_SMALL
@ K4A_BUFFER_RESULT_SUCCEEDED
@ K4A_STREAM_RESULT_SUCCEEDED
K4ARECORD_EXPORT k4a_buffer_result_t k4a_playback_get_attachment(k4a_playback_t playback_handle, const char *file_name, uint8_t *data, size_t *data_size)