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

Specialized StreamPlayer designed to handle records which format is managed by RecordFormat, which are a succession of typed content blocks described by ContentBlock objects. More...

#include <RecordFormatStreamPlayer.h>

Inheritance diagram for vrs::RecordFormatStreamPlayer:
vrs::StreamPlayer vrs::TagsRecordPlayer vrs_sample_apps::AudioStreamPlayer vrs_sample_apps::ImageStreamPlayer vrs_sample_apps::MotionStreamPlayer vrs_sample_code::ImagePlayer vrs_sample_code::MyCameraStreamPlayer vrs_sample_code::StreamPlayerDemo

Public Member Functions

virtual bool onDataLayoutRead (const CurrentRecord &record, size_t, DataLayout &)
 
virtual bool onImageRead (const CurrentRecord &record, size_t blockIndex, const ContentBlock &cb)
 
virtual bool onAudioRead (const CurrentRecord &record, size_t blockIndex, const ContentBlock &cb)
 
virtual bool onCustomBlockRead (const CurrentRecord &rec, size_t blkIdx, const ContentBlock &cb)
 
virtual bool onUnsupportedBlock (const CurrentRecord &rec, size_t blkIdx, const ContentBlock &cb)
 
void onAttachedToFileReader (RecordFileReader &recordFileReader, StreamId streamId) override
 
bool processRecordHeader (const CurrentRecord &record, DataReference &outDataReference) override
 
void processRecord (const CurrentRecord &record, uint32_t readSize) override
 
RecordFormatReadergetLastRecordFormatReader (StreamId id, Record::Type recordType) const
 
RecordFormatReadergetCurrentRecordFormatReader () const
 
- Public Member Functions inherited from vrs::StreamPlayer
virtual bool processStateHeader (const CurrentRecord &, DataReference &)
 
virtual void processState (const CurrentRecord &, uint32_t)
 
virtual bool processConfigurationHeader (const CurrentRecord &, DataReference &)
 
virtual void processConfiguration (const CurrentRecord &, uint32_t)
 
virtual bool processDataHeader (const CurrentRecord &, DataReference &)
 
virtual void processData (const CurrentRecord &, uint32_t)
 
virtual int recordReadComplete (RecordFileReader &, const IndexRecord::RecordInfo &)
 
virtual void flush ()
 

Protected Member Functions

template<class T >
T & getExpectedLayout (DataLayout &layout, size_t blockIndex)
 
template<class T >
T & getLegacyLayout (DataLayout &layout, size_t blockIndex)
 
template<class T >
T & getCachedLayout (vector< unique_ptr< DataLayout > > &layoutCache, DataLayout &layout, size_t blockIndex)
 

Protected Attributes

RecordFileReaderrecordFileReader_ {}
 
map< tuple< StreamId, Record::Type, uint32_t >, RecordFormatReaderreaders_
 
map< pair< StreamId, Record::Type >, RecordFormatReader * > lastReader_
 
RecordFormatReadercurrentReader_ {}
 

Detailed Description

Specialized StreamPlayer designed to handle records which format is managed by RecordFormat, which are a succession of typed content blocks described by ContentBlock objects.

For each of the record's content blocks a specific callback will be called depending on the type of content block. The content blocks are decoded in order, until they are all read, some decoding error occurred, or a callback returns false. The block's index is passed in case you need to disambiguate successive blocks of the same type, or need to know when a new block is started.

Member Function Documentation

◆ getCurrentRecordFormatReader()

RecordFormatReader * vrs::RecordFormatStreamPlayer::getCurrentRecordFormatReader ( ) const
inline

For RecordFormatStreamPlayer internal use.

◆ getLastRecordFormatReader()

RecordFormatReader * vrs::RecordFormatStreamPlayer::getLastRecordFormatReader ( StreamId  id,
Record::Type  recordType 
) const

For RecordFormatStreamPlayer internal use.

◆ onAttachedToFileReader()

void vrs::RecordFormatStreamPlayer::onAttachedToFileReader ( RecordFileReader recordFileReader,
StreamId  streamId 
)
overridevirtual

Callback called when the object is attached to a RecordFileReader object, so that this object can initialize itself. For RecordFormatStreamPlayer internal use. Do not prevent this initialization, or the record won't be read correctly.

Parameters
recordFileReaderRecord file reader this stream player was just attached to.
streamIdStreamId of the stream of records this stream player is associated with.

Reimplemented from vrs::StreamPlayer.

◆ onAudioRead()

virtual bool vrs::RecordFormatStreamPlayer::onAudioRead ( const CurrentRecord record,
size_t  blockIndex,
const ContentBlock cb 
)
inlinevirtual

Callback for audio content blocks. The ContentBlock object 'cb' describes the audio content block, but the content block's data has not been read yet. Query the ContentBlock object to know the details about the audio data and the content block's size. Then you can allocate or reuse a buffer, and call record.reader->read() to read the content block's data in that buffer.

Parameters
recordMetadata associated with the record being read.
blockIndexIndex of the content block being read.
cbContentBlock describing the audio data to be read.
Returns
Return true if remaining record content blocks should be read.

Reimplemented in vrs_sample_apps::AudioStreamPlayer.

◆ onCustomBlockRead()

virtual bool vrs::RecordFormatStreamPlayer::onCustomBlockRead ( const CurrentRecord rec,
size_t  blkIdx,
const ContentBlock cb 
)
inlinevirtual

Callback for custom content blocks. The ContentBlock object 'cb' describes the custom content block, but the content block's data has not been read yet. Query the ContentBlock object to know the details about the custom data and the content block's size. Then you can allocate or reuse a buffer, and call record.reader->read() to read the content block's data in that buffer.

Parameters
recMetadata associated with the record being read.
blkIdxIndex of the content block being read.
cbContentBlock describing the data to be read.
Returns
Return true if remaining record content blocks should be read.

◆ onDataLayoutRead()

virtual bool vrs::RecordFormatStreamPlayer::onDataLayoutRead ( const CurrentRecord record,
size_t  ,
DataLayout  
)
inlinevirtual

Callback for DataLayout content blocks, after it was read.

Parameters
recordMetadata associated with the record being read.
blockIndexIndex of the content block being read.
dlDataLayout read.
Returns
Return true if remaining record content blocks should be read. Return false, if the record should not be read entirely, for instance, if you only need to read some metadata stored in the first content block, but don't need to read & decode the rest of the record.

Reimplemented in vrs::TagsRecordPlayer, vrs_sample_apps::ImageStreamPlayer, and vrs_sample_apps::MotionStreamPlayer.

◆ onImageRead()

virtual bool vrs::RecordFormatStreamPlayer::onImageRead ( const CurrentRecord record,
size_t  blockIndex,
const ContentBlock cb 
)
inlinevirtual

Callback for image content blocks. The ContentBlock object 'cb' describes the image content block, but the content block's data has not been read yet. Query the ContentBlock object to know the details about the image and the content block's size. Then you can allocate or reuse a buffer, and call record.reader->read() to read the content block's data in that buffer. Depending on cb.image().getImageFormat(), the content block's data will be: ImageFormat::RAW: raw pixel buffer data, in the format specified by cb.image.getPixelFormat(). ImageFormat::JPG: JPG data, as it found in a regular .jpg file. ImageFormat::PNG: PNG data, as it found in a regular .png file. ImageFormat::VIDEO: compressed data, as generated by the video codec cb.image.getCodecName(). Preferably, use a VideoRecordFormatStreamPlayer object to decode such records.

Parameters
recordMetadata associated with the record being read.
blockIndexIndex of the content block being read.
cbContentBlock describing the image data to be read.
Returns
Return true if remaining record content blocks should be read.

Reimplemented in vrs_sample_apps::ImageStreamPlayer.

◆ onUnsupportedBlock()

bool vrs::RecordFormatStreamPlayer::onUnsupportedBlock ( const CurrentRecord rec,
size_t  blkIdx,
const ContentBlock cb 
)
virtual

Callback for unsupported or unrecognized content blocks. If the size of a content block can't be determined, and the content block can not be decoded safely, this callback is called instead of any of the preceding callbacks. This callback is also called when the other callbacks aren't implemented.

Parameters
recMetadata associated with the record being read.
blkIdxIndex of the block being read.
cbContentBlock describing the data to be read.
Returns
Return true if remaining record content blocks should be read.

◆ processRecord()

void vrs::RecordFormatStreamPlayer::processRecord ( const CurrentRecord record,
uint32_t  readSize 
)
overridevirtual

Callback called when a record is read. For RecordFormatStreamPlayer internal use.

Reimplemented from vrs::StreamPlayer.

◆ processRecordHeader()

bool vrs::RecordFormatStreamPlayer::processRecordHeader ( const CurrentRecord record,
DataReference outDataReference 
)
overridevirtual

Callback called when a record is read. For RecordFormatStreamPlayer internal use.

Reimplemented from vrs::StreamPlayer.


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