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 "ForwardDefinitions.h"
20#include "Record.h"
21
22namespace vrs {
23
24class RecordReader;
25
28 double timestamp;
29 StreamId streamId;
30 Record::Type recordType;
31 uint32_t formatVersion;
32 uint32_t recordSize;
38 const IndexRecord::RecordInfo* recordInfo;
39 RecordFileReader* fileReader;
40};
41
54 public:
55 virtual ~StreamPlayer();
56
61
69 virtual bool processRecordHeader(const CurrentRecord& record, DataReference& outDataReference) {
70 if (record.recordType == Record::Type::DATA) {
71 return processDataHeader(record, outDataReference);
72 } else if (record.recordType == Record::Type::CONFIGURATION) {
73 return processConfigurationHeader(record, outDataReference);
74 } else if (record.recordType == Record::Type::STATE) {
75 return processStateHeader(record, outDataReference);
76 } else {
77 return false;
78 }
79 }
85 virtual void processRecord(const CurrentRecord& record, uint32_t readSize) {
86 if (record.recordType == Record::Type::DATA) {
87 processData(record, readSize);
88 } else if (record.recordType == Record::Type::CONFIGURATION) {
89 processConfiguration(record, readSize);
90 } else if (record.recordType == Record::Type::STATE) {
91 processState(record, readSize);
92 }
93 }
94
100 virtual bool processStateHeader(
101 const CurrentRecord& /* record */,
102 DataReference& /* outDataReference */) {
103 return false;
104 }
105
110 virtual void processState(const CurrentRecord& /* record */, uint32_t /* bytesWrittenCount */) {}
111
118 const CurrentRecord& /* record */,
119 DataReference& /* outDataReference */) {
120 return false;
121 }
122
128 const CurrentRecord& /* record */,
129 uint32_t /* bytesWrittenCount */) {}
130
136 virtual bool processDataHeader(
137 const CurrentRecord& /* record */,
138 DataReference& /* outDataReference */) {
139 return false;
140 }
141
146 virtual void processData(const CurrentRecord& /* record */, uint32_t /* bytesWrittenCount */) {}
147
152 RecordFileReader& /*reader*/,
153 const IndexRecord::RecordInfo& /*recordInfo*/) {
154 return 0;
155 }
156
160 virtual void flush() {}
161};
162
163} // namespace vrs
Container of data pointers, to tell where to write data when reading a record.
Definition DataReference.h:59
The class to read VRS files.
Definition RecordFileReader.h:66
Type
Definition Record.h:88
@ STATE
device or algorithm state information.
@ CONFIGURATION
device or algorithm configuration.
@ DATA
device or algorithm data.
Abstract VRS internal helper class to read & (if necessary) uncompress records.
Definition RecordReaders.h:29
VRS stream identifier class.
Definition StreamId.h:242
Class designed to receive record data when reading a VRS file.
Definition StreamPlayer.h:53
virtual bool processRecordHeader(const CurrentRecord &record, DataReference &outDataReference)
Definition StreamPlayer.h:69
virtual void processConfiguration(const CurrentRecord &, uint32_t)
Definition StreamPlayer.h:127
virtual void processRecord(const CurrentRecord &record, uint32_t readSize)
Definition StreamPlayer.h:85
virtual void flush()
Definition StreamPlayer.h:160
virtual void onAttachedToFileReader(RecordFileReader &, StreamId)
Definition StreamPlayer.h:60
virtual void processData(const CurrentRecord &, uint32_t)
Definition StreamPlayer.h:146
virtual int recordReadComplete(RecordFileReader &, const IndexRecord::RecordInfo &)
Definition StreamPlayer.h:151
virtual void processState(const CurrentRecord &, uint32_t)
Definition StreamPlayer.h:110
virtual bool processConfigurationHeader(const CurrentRecord &, DataReference &)
Definition StreamPlayer.h:117
virtual bool processDataHeader(const CurrentRecord &, DataReference &)
Definition StreamPlayer.h:136
virtual bool processStateHeader(const CurrentRecord &, DataReference &)
Definition StreamPlayer.h:100
Definition AsyncDiskFileChunk.hpp:49
Class describing which record is being read. Most fields are really self explanatory.
Definition StreamPlayer.h:27
uint32_t recordSize
Definition StreamPlayer.h:32
RecordReader * reader
Definition StreamPlayer.h:37
Helper class to hold the details about a single VRS record in memory.
Definition IndexRecord.h:105