VRS
A file format for sensor data.
Loading...
Searching...
No Matches
StreamPlayer.h
1/*
2 * Copyright (c) Meta Platforms, Inc. and affiliates.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#pragma once
18
19#include <vrs/ForwardDefinitions.h>
20#include <vrs/Record.h>
21#include <vrs/VrsExport.h>
22
23namespace vrs {
24
25class RecordReader;
26
28struct VRS_API CurrentRecord {
29 double timestamp;
30 StreamId streamId;
31 Record::Type recordType;
32 uint32_t formatVersion;
33 uint32_t recordSize;
39 const IndexRecord::RecordInfo* recordInfo;
40 RecordFileReader* fileReader;
41};
42
54class VRS_API StreamPlayer {
55 public:
56 virtual ~StreamPlayer();
57
62
70 virtual bool processRecordHeader(const CurrentRecord& record, DataReference& outDataReference) {
71 if (record.recordType == Record::Type::DATA) {
72 return processDataHeader(record, outDataReference);
73 } else if (record.recordType == Record::Type::CONFIGURATION) {
74 return processConfigurationHeader(record, outDataReference);
75 } else if (record.recordType == Record::Type::STATE) {
76 return processStateHeader(record, outDataReference);
77 } else {
78 return false;
79 }
80 }
86 virtual void processRecord(const CurrentRecord& record, uint32_t readSize) {
87 if (record.recordType == Record::Type::DATA) {
88 processData(record, readSize);
89 } else if (record.recordType == Record::Type::CONFIGURATION) {
90 processConfiguration(record, readSize);
91 } else if (record.recordType == Record::Type::STATE) {
92 processState(record, readSize);
93 }
94 }
95
101 virtual bool processStateHeader(
102 const CurrentRecord& /* record */,
103 DataReference& /* outDataReference */) {
104 return false;
105 }
106
111 virtual void processState(const CurrentRecord& /* record */, uint32_t /* bytesWrittenCount */) {}
112
119 const CurrentRecord& /* record */,
120 DataReference& /* outDataReference */) {
121 return false;
122 }
123
129 const CurrentRecord& /* record */,
130 uint32_t /* bytesWrittenCount */) {}
131
137 virtual bool processDataHeader(
138 const CurrentRecord& /* record */,
139 DataReference& /* outDataReference */) {
140 return false;
141 }
142
147 virtual void processData(const CurrentRecord& /* record */, uint32_t /* bytesWrittenCount */) {}
148
153 RecordFileReader& /*reader*/,
154 const IndexRecord::RecordInfo& /*recordInfo*/) {
155 return 0;
156 }
157
161 virtual void flush() {}
162};
163
164} // namespace vrs
Container of data pointers, to tell where to write data when reading a record.
Definition DataReference.h:61
The class to read VRS files.
Definition RecordFileReader.h:76
Type
Definition Record.h:91
Abstract VRS internal helper class to read & (if necessary) uncompress records.
Definition RecordReaders.h:30
VRS stream identifier class.
Definition StreamId.h:251
Class designed to receive record data when reading a VRS file.
Definition StreamPlayer.h:54
virtual bool processRecordHeader(const CurrentRecord &record, DataReference &outDataReference)
Definition StreamPlayer.h:70
virtual void processConfiguration(const CurrentRecord &, uint32_t)
Definition StreamPlayer.h:128
virtual void processRecord(const CurrentRecord &record, uint32_t readSize)
Definition StreamPlayer.h:86
virtual void flush()
Definition StreamPlayer.h:161
virtual void onAttachedToFileReader(RecordFileReader &, StreamId)
Definition StreamPlayer.h:61
virtual void processData(const CurrentRecord &, uint32_t)
Definition StreamPlayer.h:147
virtual int recordReadComplete(RecordFileReader &, const IndexRecord::RecordInfo &)
Definition StreamPlayer.h:152
virtual void processState(const CurrentRecord &, uint32_t)
Definition StreamPlayer.h:111
virtual bool processConfigurationHeader(const CurrentRecord &, DataReference &)
Definition StreamPlayer.h:118
virtual bool processDataHeader(const CurrentRecord &, DataReference &)
Definition StreamPlayer.h:137
virtual bool processStateHeader(const CurrentRecord &, DataReference &)
Definition StreamPlayer.h:101
Definition Compressor.cpp:113
Class describing which record is being read. Most fields are really self explanatory.
Definition StreamPlayer.h:28
uint32_t recordSize
Definition StreamPlayer.h:33
RecordReader * reader
Definition StreamPlayer.h:38
Helper class to hold the details about a single VRS record in memory.
Definition IndexRecord.h:110