![]() |
VRS
A file format for sensor data.
|
Essential VRS class holding a record's details and payload in memory during creation. More...
#include <Record.h>
Classes | |
struct | uninitialized_byte |
Public for testing. More... | |
Public Types | |
enum class | Type : uint8_t { UNDEFINED = 0 , STATE = 1 , CONFIGURATION = 2 , DATA = 3 , TAGS = 4 , COUNT } |
Public Member Functions | |
void | recycle () |
void | set (double timestamp, Type type, uint32_t formatVersion, const DataSource &data, uint64_t creationOrder) |
void | addDirectWriteRecordData (std::unique_ptr< DirectWriteRecordData > &&directWriteRecordData) |
Add some data to write directly at the end of the record when it's written to disk. | |
bool | shouldTryToCompress () const |
uint32_t | compressRecord (Compressor &compressor) |
int | writeRecord (WriteFileHandler &file, StreamId streamId, uint32_t &inOutRecordSize, Compressor &compressor, uint32_t compressedSize) |
double | getTimestamp () const |
Get the record's timestamp. | |
uint64_t | getCreationOrder () const |
size_t | getSize () const |
Get the record's payload size, uncompressed. | |
Type | getRecordType () const |
Get the record's record type. | |
Static Public Member Functions | |
static const char * | typeName (Type type) |
Get a record type as a text string. | |
Static Public Attributes | |
static const double | kMaxTimestamp = numeric_limits<double>::max() |
Maximum timestamp for a record. | |
Friends | |
class | RecordManager |
Essential VRS class holding a record's details and payload in memory during creation.
Record are containers for data captured at a specific point in time (their timestamp).
Records can only be created using Recordable::createRecord(), and are then owned and managed by the recordable's private RecordManager.
There are 3 types of user records: configuration, state and data records.
Configuration records are meant to describe how the device (or virtual device, such as an algorithm), is configured: this could represent the resolution of a camera sensor, its framerate, its exposure setting if it's fixed, etc. Whenever the configuration of a device changes, a new configuration record should be generated. At the beginning of any recording, a configuration record is also expected, and VRS itself might call a Recordable's createConfigurationRecord() method to be sure a configuration record is created.
State records are meant to describe the internal state of the device or virtual device. A camera might be configured in auto-exposure mode, so that the exposure of the camera might evolve over time, based on the images recorded. Similarly, algorithms, in particular vision algorithms, may have an internal state, and it might be useful to record that state. However, we do not necessarily want to record every state change. The internal exposure of a camera might change at every frame, and the potentially very large internal state of a vision algorithm is also likely to change each time a sensor record is processed. Devices with changing internal state are expected to generate state records, as necessary, but at a controlled rate, so as to allow to reproduce replay conditions without generating an overwhelming amount of data. Similarly to configuration records, State records might be requested by VRS, by calling a Recordable's createStateRecord method.
Data records are used to capture the actual sensor data. Devices are expected to create Data records whenever data is received from some kind of device driver, or arbitrarily in the case of synthetic data.
Records and compressed Records have space for a RecordHeader allocated before their data, so records can be written in a single write operation.
See Recordable::createRecord() to see how to create records.
|
strong |
Record type definitions. Only Configuration, State and Data records are used by the client users of the APIs. Tags records are internal to VRS, and will not be exposed in the RecordFileReader's index even when they are used internally.
uint32_t vrs::Record::compressRecord | ( | Compressor & | compressor | ) |
Try to compress the record.
void vrs::Record::recycle | ( | ) |
When VRS is done using a record, it recycles it, rather than delete it.
void vrs::Record::set | ( | double | timestamp, |
Type | type, | ||
uint32_t | formatVersion, | ||
const DataSource & | data, | ||
uint64_t | creationOrder | ||
) |
Copy data into the record, so that we can write it to disk later if we needed.
bool vrs::Record::shouldTryToCompress | ( | ) | const |
Tell if an attempt should be made to compress the record. If compression can't reduce the size of the record, then the record is written uncompressed.
int vrs::Record::writeRecord | ( | WriteFileHandler & | file, |
StreamId | streamId, | ||
uint32_t & | inOutRecordSize, | ||
Compressor & | compressor, | ||
uint32_t | compressedSize | ||
) |
Write a possibly compressed record to a file (header + data).