VRS
A file format for sensor data.
Loading...
Searching...
No Matches
Classes | Public Types | Public Member Functions | Static Public Attributes | List of all members
vrs::MultiRecordFileReader Class Reference

Facilitates reading multiple VRS files simultaneously. Records are sorted by timestamps across all the files, therefore it is essential that *** all the files must have their timestamps in the same time domain. *** Operates in a manner similar to RecordFileReader, but with multiple files. More...

#include <MultiRecordFileReader.h>

Public Types

using UniqueStreamId = StreamId
 

Public Member Functions

 MultiRecordFileReader (const MultiRecordFileReader &)=delete
 
MultiRecordFileReaderoperator= (const MultiRecordFileReader &)=delete
 
int open (const std::vector< std::string > &paths)
 
int open (const std::vector< FileSpec > &fileSpecs)
 
int open (const std::string &path)
 
int open (const FileSpec &fileSpec)
 
int close ()
 
const set< UniqueStreamId > & getStreams () const
 
bool isOpened () const
 
uint32_t getRecordCount () const
 
uint32_t getRecordCount (UniqueStreamId uniqueStreamId) const
 
uint32_t getRecordCount (UniqueStreamId uniqueStreamId, Record::Type recordType) const
 
const StreamTagsgetTags (UniqueStreamId uniqueStreamId) const
 
const string & getTag (const string &name) const
 
const string & getTag (UniqueStreamId uniqueStreamId, const string &name) const
 
vector< std::pair< string, int64_t > > getFileChunks () const
 
const string & getFlavor (UniqueStreamId uniqueStreamId) const
 
const string & getSerialNumber (UniqueStreamId uniqueStreamId) const
 
vector< UniqueStreamIdgetStreams (RecordableTypeId typeId, const string &flavor={}) const
 
UniqueStreamId getStreamForName (const string &name) const
 
UniqueStreamId getStreamForTag (const string &tagName, const string &tag, RecordableTypeId typeId=RecordableTypeId::Undefined) const
 
UniqueStreamId getStreamForSerialNumber (const string &serialNumber) const
 
bool mightContainImages (UniqueStreamId uniqueStreamId) const
 
bool mightContainAudio (UniqueStreamId uniqueStreamId) const
 
uint32_t getRecordIndex (const IndexRecord::RecordInfo *record) const
 
const IndexRecord::RecordInfogetRecord (uint32_t globalIndex) const
 
uint32_t getRecordSize (uint32_t globalIndex) const
 
const IndexRecord::RecordInfogetRecord (UniqueStreamId streamId, uint32_t indexNumber) const
 
const IndexRecord::RecordInfogetRecord (UniqueStreamId streamId, Record::Type recordType, uint32_t indexNumber) const
 
const IndexRecord::RecordInfogetLastRecord (UniqueStreamId streamId, Record::Type recordType) const
 
const vector< const IndexRecord::RecordInfo * > & getIndex (UniqueStreamId streamId) const
 
const string & getOriginalRecordableTypeName (UniqueStreamId streamId) const
 
void setStreamPlayer (UniqueStreamId streamId, StreamPlayer *streamPlayer)
 
uint32_t getRecordFormats (UniqueStreamId streamId, RecordFormatMap &outFormats) const
 
int readRecord (const IndexRecord::RecordInfo &recordInfo)
 
int readRecord (const IndexRecord::RecordInfo &recordInfo, StreamPlayer *player, bool setupPlayer)
 
bool setCachingStrategy (CachingStrategy cachingStrategy)
 
CachingStrategy getCachingStrategy () const
 
bool prefetchRecordSequence (const vector< const IndexRecord::RecordInfo * > &records, bool clearSequence=true)
 
bool isRecordAvailableOrPrefetch (const IndexRecord::RecordInfo &record) const
 
bool purgeFileCache ()
 
const map< string, string > & getTags () const
 
const IndexRecord::RecordInfogetFirstRecord (Record::Type recordType) const
 
const IndexRecord::RecordInfogetLastRecord (Record::Type recordType) const
 
const IndexRecord::RecordInfogetRecordByTime (double timestamp) const
 
const IndexRecord::RecordInfogetRecordByTime (UniqueStreamId streamId, double timestamp) const
 
const IndexRecord::RecordInfogetRecordByTime (StreamId streamId, Record::Type recordType, double timestamp) const
 
const IndexRecord::RecordInfogetNearestRecordByTime (double timestamp, double epsilon, StreamId streamId={}, Record::Type recordType=Record::Type::UNDEFINED) const
 
std::unique_ptr< FileHandlergetFileHandler () const
 
UniqueStreamId getUniqueStreamId (const IndexRecord::RecordInfo *record) const
 
int64_t getTotalSourceSize () const
 
bool readFirstConfigurationRecord (UniqueStreamId uniqueStreamId, StreamPlayer *streamPlayer=nullptr)
 
bool readFirstConfigurationRecords (StreamPlayer *streamPlayer=nullptr)
 
bool readFirstConfigurationRecordsForType (RecordableTypeId typeId, StreamPlayer *streamPlayer=nullptr)
 
const std::vector< unique_ptr< RecordFileReader > > & getReaders () const
 Get the list of RecordFileReader objects used to read all the streams.
 

Static Public Attributes

static const string kRelatedFileTags []
 

Detailed Description

Facilitates reading multiple VRS files simultaneously. Records are sorted by timestamps across all the files, therefore it is essential that *** all the files must have their timestamps in the same time domain. *** Operates in a manner similar to RecordFileReader, but with multiple files.

Member Typedef Documentation

◆ UniqueStreamId

External facing StreamId which handles collisions between StreamId across multiple files (RecordFileReaders). Since this is just an alias, it doesn't prevent misuse of using StreamId in places where UniqueStreamId is expected.

Member Function Documentation

◆ close()

int vrs::MultiRecordFileReader::close ( )

Close the underlying files, if any are open.

Returns
0 on success or if no file was open. Some file system error code upon encountering an error while closing any of the underlying files.

◆ getCachingStrategy()

CachingStrategy vrs::MultiRecordFileReader::getCachingStrategy ( ) const

Get Caching strategy for all the underlying file handlers. The same strategy is supposed to be used by all file handlers.

◆ getFileChunks()

vector< pair< string, int64_t > > vrs::MultiRecordFileReader::getFileChunks ( ) const

Get a list of the constituent paths + sizes (in bytes) across all files. When no file is open, an empty vector is returned. When a single file is open, the underlying chunks with their sizes are returned. When multiple files are open, file paths and their sizes are returned.

Returns
A vector of pairs path-file size in bytes.

◆ getFileHandler()

unique_ptr< FileHandler > vrs::MultiRecordFileReader::getFileHandler ( ) const

Get a clone of the current file handler, for use elsewhere.

Returns
A copy of the current file handler. nullptr may be returned if no underlying files are open yet.

◆ getFirstRecord()

const IndexRecord::RecordInfo * vrs::MultiRecordFileReader::getFirstRecord ( Record::Type  recordType) const

Get the record with smallest timestamp across all streams and files, of a specified record type.

Parameters
recordTypeType of record to look for.
Returns
Pointer to the first record of the specified type, or null if no records of the specified type exist.

◆ getFlavor()

const string & vrs::MultiRecordFileReader::getFlavor ( UniqueStreamId  uniqueStreamId) const

Streams using << Recordable Class >> ids require a << flavor >>, which must be provided when the stream was created. Use this API to get the recordable flavor provided, if any, when the stream was created.

Parameters
uniqueStreamIdStreamId of the record stream to consider.
Returns
The flavor for the corresponding RecordableTypeId, or an empty string, if no flavor was provided when the stream was created.

◆ getIndex()

const vector< const IndexRecord::RecordInfo * > & vrs::MultiRecordFileReader::getIndex ( UniqueStreamId  streamId) const

Get a record index limited to a specific stream.

Parameters
streamIdUniqueStreamId of the record stream to consider.
Returns
The index of the file, with all the records corresponding to the selected stream.

◆ getLastRecord() [1/2]

const IndexRecord::RecordInfo * vrs::MultiRecordFileReader::getLastRecord ( Record::Type  recordType) const

Get the record with largest timestamp across all streams and files, of a specified record type.

Parameters
recordTypeType of record to look for.
Returns
Pointer to the last record of the specified type, or null if no records of the specified type exist.

◆ getLastRecord() [2/2]

const IndexRecord::RecordInfo * vrs::MultiRecordFileReader::getLastRecord ( UniqueStreamId  streamId,
Record::Type  recordType 
) const

Find the last record for a specific stream and specific type.

Parameters
streamIdUniqueStreamId of the record stream to consider.
recordTypeType of the records to consider.
Returns
Pointer to the record info, or nullptr if the streamId or no record of the type was found.

◆ getNearestRecordByTime()

const IndexRecord::RecordInfo * vrs::MultiRecordFileReader::getNearestRecordByTime ( double  timestamp,
double  epsilon,
StreamId  streamId = {},
Record::Type  recordType = Record::Type::UNDEFINED 
) const

Find the nearest record of a specific stream within the range of (timestamp - epsilon) - (timestamp + epsilon).

Parameters
timestamptimestamp to seek.
epsilonthe threshold we search for the index.
streamIdStreamId of the stream to consider. Leave undefined to search all streams
recordTyperecord type to find, or Record::Type::UNDEFINED for any record type.
Returns
Pointer to the record info, or nullptr (timestamp is too big?).

◆ getOriginalRecordableTypeName()

const string & vrs::MultiRecordFileReader::getOriginalRecordableTypeName ( UniqueStreamId  streamId) const
inline

RecordableTypeId text descriptions may change over time, so at the time of recording, we capture the text name, so that we can see what it was when the file was recorded.

Parameters
streamIdUniqueStreamId of the record stream to consider.
Returns
The original text description for the corresponding RecordableTypeId.

◆ getRecord() [1/3]

const IndexRecord::RecordInfo * vrs::MultiRecordFileReader::getRecord ( uint32_t  globalIndex) const

Get the record corresponding to the given index position in the global index.

Parameters
globalIndexPosition in the global index to look up.
Returns
Corresponding record if present or nullptr if the given index is invalid.

◆ getRecord() [2/3]

const IndexRecord::RecordInfo * vrs::MultiRecordFileReader::getRecord ( UniqueStreamId  streamId,
Record::Type  recordType,
uint32_t  indexNumber 
) const

Find a specific record for a specific stream and type, by index number. nullptr is returned if no record is found for that index number.

Parameters
streamIdUniqueStreamId of the record stream to consider.
recordTypeType of the records to consider.
indexNumberIndex of the record to look for.
Returns
Pointer to the record info, or nullptr if the streamId or the indexNumber wasn't found for that specific type.

◆ getRecord() [3/3]

const IndexRecord::RecordInfo * vrs::MultiRecordFileReader::getRecord ( UniqueStreamId  streamId,
uint32_t  indexNumber 
) const

Find a specific record for a specific stream, regardless of type, by index number.

Parameters
streamIdUniqueStreamId of the record stream to consider.
indexNumberIndex position (for streamId - not global index) of the record to look for.
Returns
Pointer to the record info, or nullptr if the streamId, or a record with the indexNumber wasn't found.

◆ getRecordByTime() [1/3]

const IndexRecord::RecordInfo * vrs::MultiRecordFileReader::getRecordByTime ( double  timestamp) const

Find the first record at or after a timestamp.

Parameters
timestamptimestamp to seek.
Returns
Pointer to the record info, or nullptr (timestamp is too big?).

◆ getRecordByTime() [2/3]

const IndexRecord::RecordInfo * vrs::MultiRecordFileReader::getRecordByTime ( StreamId  streamId,
Record::Type  recordType,
double  timestamp 
) const

Find the first record of a specific stream of a specific type at or after a timestamp.

Parameters
streamIdStreamId of the stream to consider.
recordTyperecord type to find.
timestamptimestamp to seek.
Returns
Pointer to the record info, or nullptr (timestamp is too big?).

◆ getRecordByTime() [3/3]

const IndexRecord::RecordInfo * vrs::MultiRecordFileReader::getRecordByTime ( UniqueStreamId  streamId,
double  timestamp 
) const

Find the first record of a specific stream at or after a timestamp.

Parameters
streamIdUniqueStreamId of the stream to consider.
timestamptimestamp to seek.
Returns
Pointer to the record info, or nullptr (timestamp is too big?).

◆ getRecordCount() [1/3]

uint32_t vrs::MultiRecordFileReader::getRecordCount ( ) const

Get the number of records across all open files.

Returns
The number of records across all open files, or 0, if no file is opened.

◆ getRecordCount() [2/3]

uint32_t vrs::MultiRecordFileReader::getRecordCount ( UniqueStreamId  uniqueStreamId) const

Get the number of records of a specific stream.

Parameters
uniqueStreamIdStreamId of the record stream to consider.
Returns
The number of records of the specified stream.

◆ getRecordCount() [3/3]

uint32_t vrs::MultiRecordFileReader::getRecordCount ( UniqueStreamId  uniqueStreamId,
Record::Type  recordType 
) const

Get the number of records for a specific stream and specific record type. Attention: this computation has a linear complexity, so cache the result!

Parameters
uniqueStreamIdStreamId of the record stream to consider.
recordTypeType of records to count.
Returns
Number of records for the specified stream id & record type.

◆ getRecordFormats()

uint32_t vrs::MultiRecordFileReader::getRecordFormats ( UniqueStreamId  streamId,
RecordFormatMap outFormats 
) const

Get all the RecordFormat description used in this VRS file. Mostly useful for tools like VRStool & VRSplayer.

Parameters
streamIdUniqueStreamId of the record stream to consider.
outFormatsReference to be set.
Returns
Number of formats found.

◆ getRecordIndex()

uint32_t vrs::MultiRecordFileReader::getRecordIndex ( const IndexRecord::RecordInfo record) const

Get a record's index in the global index, which is ordered by timestamp across all open files.

Parameters
recordPointer of the record.
Returns
Index in the global index, or getRecordCount() is record is nullptr or an invalid pointer.

◆ getRecordSize()

uint32_t vrs::MultiRecordFileReader::getRecordSize ( uint32_t  globalIndex) const

Get a record's size in the global index.

Parameters
globalIndexPosition in the global index to look up.
Returns
The size of the record on disk, all included, or 0 if the index is invalid.

◆ getSerialNumber()

const string & vrs::MultiRecordFileReader::getSerialNumber ( UniqueStreamId  uniqueStreamId) const

Get a stream's serial number.

Parameters
uniqueStreamIdStreamId of the record stream to consider.
Returns
The serial number, or an empty string if the stream wasn't found.

◆ getStreamForName()

MultiRecordFileReader::UniqueStreamId vrs::MultiRecordFileReader::getStreamForName ( const string &  name) const

Find a stream from an absolute or relative numeric name. Absolute numeric names are in the form <numeric_recordable_type_id>-<instance_id>, eg 1201-1 Relative numeric names are in the form <numeric_recordable_type_id>+<instance_id>, eg 1201+1 Relative numeric names have instance ids interpreted as the nth stream of that type, eg 1201+3 is the 3rd stream with the recordable type id 1201 (if there is such a stream). In all cases, use isValid() to verify that the stream was found in the file.

Parameters
namean absolute or relative numeric name
Returns
a StreamId, valid only if the numeric name exists in the file.

◆ getStreamForSerialNumber()

UniqueStreamId vrs::MultiRecordFileReader::getStreamForSerialNumber ( const string &  serialNumber) const

Find the stream with the given serial number.

Parameters
serialNumberthe serial number to look for.
Returns
A UniqueStreamId. Call isValid() to know if a matching stream was actually found.

◆ getStreamForTag()

UniqueStreamId vrs::MultiRecordFileReader::getStreamForTag ( const string &  tagName,
const string &  tag,
RecordableTypeId  typeId = RecordableTypeId::Undefined 
) const

Find the first stream with given tag name + value pair and RecordableTypeId

Parameters
tagNameThe name of the tag to look for.
tagThe tag value to look for.
typeIdThe RecordableTypeId to limit the search to, or RecordableTypeId::Undefined to look for any device type. Note: if more than one streams match the criteria, the "first" one is returned, which means the one with the lowest RecordableTypeId enum value, or if equal, the one with the lowest UniqueStreamId instanceId.
Returns
A UniqueStreamId. Call isValid() to know if a matching stream was actually found.

◆ getStreams() [1/2]

const set< UniqueStreamId > & vrs::MultiRecordFileReader::getStreams ( ) const

Get the set of StreamId for all the streams across all the open files. In case the the same StreamId is used in multiple files, this method generates UniqueStreamIds for disambiguation and uses those instead.

Returns
The set of stream IDs for which there are records.

◆ getStreams() [2/2]

vector< UniqueStreamId > vrs::MultiRecordFileReader::getStreams ( RecordableTypeId  typeId,
const string &  flavor = {} 
) const

Get a set of StreamId for a specific type, and an optional flavor.

Parameters
typeIda recordable type id, maybe a Recordable Class. Use RecordableTypeId::Undefined to match any recordable type.
flavoran option flavor.
Returns
A vector of stream ids of the given type, and of the provided flavor (if any).

◆ getTag() [1/2]

const string & vrs::MultiRecordFileReader::getTag ( const string &  name) const
inline

Get a specific file tag by name. (Not to be confused with stream tags) If multiple files are opened and they have multiple values for the same tag name, one of the values is returned arbitrarily.

Parameters
nameName of the tag to look for.
Returns
The tag value, or the empty string if the tag wasn't found.

◆ getTag() [2/2]

const string & vrs::MultiRecordFileReader::getTag ( UniqueStreamId  uniqueStreamId,
const string &  name 
) const
inline

Get a specific tag for a specific record stream.

Parameters
uniqueStreamIdStreamId of the record stream to consider.
nameName of the tag to look for.
Returns
The tag value, or the empty string if the tag wasn't found.

◆ getTags() [1/2]

const map< string, string > & vrs::MultiRecordFileReader::getTags ( ) const
inline

Get the tags map for all the underlying files. Does not include any stream tags.

Returns
The tags map for all underlying files.

◆ getTags() [2/2]

const StreamTags & vrs::MultiRecordFileReader::getTags ( UniqueStreamId  uniqueStreamId) const

Get the tags for a specific record stream.

Parameters
uniqueStreamIdStreamId of the record stream to consider.
Returns
The tags for the stream. If the streamId doesn't exist in the file, the map returned will be an empty map.

◆ getTotalSourceSize()

int64_t vrs::MultiRecordFileReader::getTotalSourceSize ( ) const

Get the total size of all underlying files.

Returns
The number of bytes of all the files combined.

◆ getUniqueStreamId()

UniqueStreamId vrs::MultiRecordFileReader::getUniqueStreamId ( const IndexRecord::RecordInfo record) const

Get UniqueStreamId corresponding to the given record. This must be used as opposed to reading the StreamId from RecordInfo directly since it handles StreamId collisions between streams from multiple files.

Parameters
recordRecord whose UniqueStreamId is supposed to be determined
Returns
UniqueStreamId corresponding to the given record. An invalid UniqueStreamId is returned for an illegal record.

◆ isOpened()

bool vrs::MultiRecordFileReader::isOpened ( ) const
inline

Tell if files are being read. Must be true for most operations.

Returns
True if the file is opened.

◆ isRecordAvailableOrPrefetch()

bool vrs::MultiRecordFileReader::isRecordAvailableOrPrefetch ( const IndexRecord::RecordInfo record) const

Check if a file record is available for immediate loading (e.g. on disk or in-cache). If not, begin background prefetching at the requested frame (but do not wait for results).

Parameters
recordInfoRecordInfo reference of the record to read.
Returns
true if available, false if unavailable (e.g. would require a network fetch).

◆ mightContainAudio()

bool vrs::MultiRecordFileReader::mightContainAudio ( UniqueStreamId  uniqueStreamId) const

Tell if a stream might contain some audio data (and probably will). This is a best guess effort, but it is still possible that no audio will actually be found!

Parameters
streamIdStreamId of the record stream to check.
Returns
True if at least one Data record RecordFormat definition found in the stream has at least one audio content block, and the stream contains at least one data record.

◆ mightContainImages()

bool vrs::MultiRecordFileReader::mightContainImages ( UniqueStreamId  uniqueStreamId) const

Tell if a stream might contain at least one image (and probably will). This is a best guess effort, but it is still possible that no images are actually found!

Parameters
streamIdStreamId of the record stream to check.
Returns
True if at least one Data record RecordFormat definition found in the stream has at least one image content block, and the stream contains at least one data record.

◆ open() [1/4]

int vrs::MultiRecordFileReader::open ( const FileSpec fileSpec)
inline

Open a single VRS file. This method is expected to be invoked only once per instance.

Parameters
fileSpecVRS fileSpec to open.
Returns
0 on success and you can read the file, or some non-zero error code, in which case, further read calls will fail.

◆ open() [2/4]

int vrs::MultiRecordFileReader::open ( const std::string &  path)
inline

Open a single VRS file. This method is expected to be invoked only once per instance.

Parameters
pathVRS file path to open.
Returns
0 on success and you can read the file, or some non-zero error code, in which case, further read calls will fail.

◆ open() [3/4]

int vrs::MultiRecordFileReader::open ( const std::vector< FileSpec > &  fileSpecs)

Open the given VRS files. Only related files are allowed to be opened together. i.e. the files which have the same values for tags defined in kRelatedFileTags. If these tags are present, then the values must match. All the files must have their timestamps in the same time domain. This method is expected to be invoked only once per instance.

Parameters
fileSpecsVRS file specs to open.
Returns
0 on success and you can read all the files, or some non-zero error code, in which case, further read calls will fail.

◆ open() [4/4]

int vrs::MultiRecordFileReader::open ( const std::vector< std::string > &  paths)

Open the given VRS files. Only related files are allowed to be opened together. i.e. the files which have the same values for tags defined in kRelatedFileTags. If these tags are present, then the values must match. All the files must have their timestamps in the same time domain. This method is expected to be invoked only once per instance.

Parameters
pathsVRS file paths to open.
Returns
0 on success and you can read all the files, or some non-zero error code, in which case, further read calls will fail.

◆ prefetchRecordSequence()

bool vrs::MultiRecordFileReader::prefetchRecordSequence ( const vector< const IndexRecord::RecordInfo * > &  records,
bool  clearSequence = true 
)

When streaming VRS files from the cloud, it may be very beneficial to tell before hand which records will be read, in order, so that the data can be prefetched optimally. Note the only some FileHandlers implement this, others will just ignore the request, which is always safe to make.

Parameters
recordsa sequence of records in the exact order they will be read. It's ok to skip one or more records, but:
  • don't try to read "past" records, or you'll confuse the caching strategy, possibly leading to much worse performance.
  • if you read a single record out of the sequence, the prefetch list will be cleared. You may call this method as often as you like, and any previous read sequence will be cleared, but whatever is already in the cache will remain.
clearSequenceFlag on whether to cancel any pre-existing custom read sequence upon caching starts.
Returns
True if the file handler backend supports this request, false if it was ignored.

◆ purgeFileCache()

bool vrs::MultiRecordFileReader::purgeFileCache ( )

If the underlying file handler caches data on reads, purge its caches to free memory. Sets the caching strategy to Passive, and clears any pending read sequence.

Returns
True if all the underlying caches were purged, false if they weren't for some reason. Note: this is a best effort. If transactions are pending, their cache blocks won't be cleared.

◆ readFirstConfigurationRecord()

bool vrs::MultiRecordFileReader::readFirstConfigurationRecord ( UniqueStreamId  uniqueStreamId,
StreamPlayer streamPlayer = nullptr 
)

Helper function: Read the first configuration record of a particular stream. This might be necessary to properly read records containing image or audio blocks, if their configuration is contained in the configuration record using datalayout conventions. Notes:

  • a RecordFormatStreamPlayer must be attached to the stream prior to making this call, because that's where the configuration data is being cached.
  • that this API reads the first configuration record of the stream, and if the stream contains more than one configuration record, that record may not be the right one for all your data records.
  • if you provide a stream player, the caching happens in that stream player, which won't solve the use case described above.
    Parameters
    uniqueStreamIdUniqueStreamId of the record stream to consider.
    streamPlayer(optional): provide a streamPlayer that will receive the records. If provided, and a stream player is already registered to receive records for that stream, the provided stream player will get the data, and the registered stream player will not get anything.
    Returns
    True if a config record was read for the given stream.

◆ readFirstConfigurationRecords()

bool vrs::MultiRecordFileReader::readFirstConfigurationRecords ( StreamPlayer streamPlayer = nullptr)

Helper function: Read the first configuration record of all the streams. This might be necessary to properly read records containing image or audio blocks, if their configuration is contained in the configuration record using datalayout conventions. Notes:

  • a RecordFormatStreamPlayer must be attached to the stream prior to making this call, because that's where the configuration data is being cached.
  • that this API reads the first configuration record of the stream, and if the stream contains more than one configuration record, that record may not be the right one for all your data records.
  • if you provide a stream player, the caching happens in that stream player, which won't solve the use case described above.
    Parameters
    streamPlayer(optional): provide a stream player that will receive the records. If provided, and a stream player is already registered to receive records for that stream, the provided stream player will get the data, and the registered stream player will not get anything.
    Returns
    True if a config record was read for the given stream.

◆ readFirstConfigurationRecordsForType()

bool vrs::MultiRecordFileReader::readFirstConfigurationRecordsForType ( RecordableTypeId  typeId,
StreamPlayer streamPlayer = nullptr 
)

Helper function: Read the first configuration record for all the streams of a particular recordable type. See readFirstConfigurationRecord() for limitations.

Parameters
typeIdThe RecordableTypeId of the type of device to look for.
streamPlayer(optional): provide a stream player that will receive the records. If provided, and a stream player is already registered to receive records for that stream, the provided stream player will get the data, and the registered stream player will not get anything.
Returns
true if a configuration record was properly read for each matching stream.

◆ readRecord() [1/2]

int vrs::MultiRecordFileReader::readRecord ( const IndexRecord::RecordInfo recordInfo)

Preferred way to read records.

Parameters
recordInfoRecordInfo reference of the record to read.
Returns
0 on success, or a non-zero error code. If there is no StreamPlayer hooked up for the stream, no read operation is done and 0 is returned.

◆ readRecord() [2/2]

int vrs::MultiRecordFileReader::readRecord ( const IndexRecord::RecordInfo recordInfo,
StreamPlayer player,
bool  setupPlayer 
)

Read a record with a specific stream player. Attention! Unlike the RecordFileReader version of this API, do not read different streams with the same stream player, or you might get unexpected results. Stream players should not be used with different RecordFileReader objects, which this class might do.

Parameters
recordInfoRecordInfo reference of the record to read.
setupPlayertell if the player should be initialized through its onAttachedToFileReader callback. This must happen at least once per player, the first time around. This operation can be expensive, so this should be done only once.
Returns
0 on success, or a non-zero error code.

◆ setCachingStrategy()

bool vrs::MultiRecordFileReader::setCachingStrategy ( CachingStrategy  cachingStrategy)

Set Caching strategy for all the underlying file handlers. This should be called after opening the files, as open might replace the file handler.

Parameters
cachingStrategyCaching strategy desired.
Returns
True if the caching strategy was set. False if any of the underlying file handlers doesn't support the requested strategy, or any particular strategy.

◆ setStreamPlayer()

void vrs::MultiRecordFileReader::setStreamPlayer ( UniqueStreamId  streamId,
StreamPlayer streamPlayer 
)

Hook a stream player to a specific stream after opening a file and before reading records. The file player does not take ownership of the StreamPlayer. Using the same StreamPlayer instance for multiple streams is supported. So the caller is responsible for deleting the StreamPlayer objects after the file is read. Disconnect the StreamPlayer by passing a nullptr for the stream id.

Parameters
streamIdUniqueStreamId to hook the stream player to.
streamPlayerStreamPlayer to attach.

Member Data Documentation

◆ kRelatedFileTags

const string vrs::MultiRecordFileReader::kRelatedFileTags[]
inlinestatic
Initial value:
= {
tag_conventions::kCaptureTimeEpoch,
tag_conventions::kSessionId}

Tags which determine whether VRS files are related to each other. Related files are expected to have the same value for these tags.


The documentation for this class was generated from the following files: