29#include <vrs/FileFormat.h>
30#include <vrs/FileHandler.h>
31#include <vrs/IndexRecord.h>
32#include <vrs/Record.h>
33#include <vrs/RecordFormat.h>
34#include <vrs/RecordReaders.h>
35#include <vrs/Recordable.h>
36#include <vrs/StreamId.h>
43using std::string_view;
49 !std::is_convertible_v<const T&, string_view> && std::is_convertible_v<T, string>,
106 int openFile(string_view filePath,
bool autoWriteFixedIndex =
false);
108 template <
typename T, EnableIfStringConvertible<T> = 0>
109 inline int openFile(
const T& filePath,
bool autoWriteFixedIndex =
false) {
110 return openFile(string_view(
static_cast<string>(filePath)), autoWriteFixedIndex);
152 const vector<const IndexRecord::RecordInfo*>& records,
153 bool clearSequence =
true);
182 bool setupPlayer =
false);
256 const string& tagName,
266 const vector<IndexRecord::RecordInfo>&
getIndex()
const {
273 const vector<const IndexRecord::RecordInfo*>&
getIndex(
StreamId streamId)
const;
278 return static_cast<uint32_t
>(recordIndex_.size());
361 uint32_t
getRecordIndex(
const IndexRecord::RecordInfo* record)
const;
373 uint32_t
getRecordSize(uint32_t recordIndex,
bool useBoundaries =
true)
const;
412 StreamPlayer* streamPlayer =
nullptr);
423 const string&
getTag(
const string& name)
const {
424 return getTag(fileTags_, name);
502 uint32_t formatVersion,
520 return file_->setCachingStrategy(cachingStrategy);
523 return file_->getCachingStrategy();
528 return file_->setStatsCallback(statsCallback);
536 return file_->purgeCache();
563 using ParentType = std::array<uint32_t, enumCount<Record::Type>()>;
569 inline uint32_t operator[](
Record::Type recordType)
const {
570 return ParentType::operator[](
static_cast<uint32_t
>(recordType));
573 return ParentType::operator[](
static_cast<uint32_t
>(recordType));
575 uint32_t totalCount()
const;
581 int doOpenFile(
const FileSpec& fileSpec,
bool autoWriteFixedIndex,
bool checkSignatureOnly);
585 bool autoWriteFixedIndex,
587 bool readConfigRecords(
588 const set<const IndexRecord::RecordInfo*>& configRecords,
591 static const string&
getTag(
const map<string, string>& tags,
const string& name);
594 int64_t getFollowingRecordOffset(uint32_t recordIndex,
bool useBoundaries)
const;
595 mutable vector<int64_t> recordBoundaries_;
596 mutable map<uint32_t, int64_t> recordLimits_;
599 std::unique_ptr<FileHandler> file_;
604 set<StreamId> streamIds_;
605 map<StreamId, StreamTags> streamTags_;
606 map<string, string> fileTags_;
607 vector<IndexRecord::RecordInfo> recordIndex_;
608 mutable map<StreamId, RecordTypeCounter> streamRecordCounts_;
611 map<StreamId, StreamPlayer*> streamPlayers_;
614 unique_ptr<ProgressLogger> defaultProgressLogger_;
616 unique_ptr<std::thread> detailsSaveThread_;
617 mutable map<StreamId, vector<const IndexRecord::RecordInfo*>> streamIndex_;
620 mutable map<pair<StreamId, Record::Type>, pair<uint32_t, size_t>> lastRequest_;
621 int64_t endOfUserRecordsOffset_{};
622 uint32_t recordHeaderSize_{};
623 bool fileHasAnIndex_{};
624 bool autoPrefetch_{};
635 const std::vector<const IndexRecord::RecordInfo*>& index,
RecordReader specialized to read compressed records. For VRS internal usage only.
Definition RecordReaders.h:115
Helper to identify a particular content block within a file.
Definition RecordFormat.h:640
The DataLayout class describes the data stored inside a DataLayoutContentBlock.
Definition DataLayout.h:209
ProgressLogger class to be notified of some process' progress.
Definition ProgressLogger.h:31
Definition RecordFileReader.h:562
The class to read VRS files.
Definition RecordFileReader.h:75
uint32_t getRecordFormats(StreamId streamId, RecordFormatMap &outFormats) const
Definition RecordFileReader.cpp:988
int readAllRecords()
Definition RecordFileReader.cpp:1092
void setStreamPlayer(StreamId streamId, StreamPlayer *streamPlayer)
Definition RecordFileReader.cpp:107
bool purgeFileCache()
Definition RecordFileReader.h:535
uint32_t getRecordSize(uint32_t recordIndex, bool useBoundaries=true) const
Definition RecordFileReader.cpp:586
void buildRecordBoundaries(bool boundariesAndLimits=false) const
private, for testing only
Definition RecordFileReader.cpp:509
const string & getSerialNumber(StreamId streamId) const
Definition RecordFileReader.cpp:1032
int closeFile()
Definition RecordFileReader.cpp:483
bool prefetchRecordSequence(const vector< const IndexRecord::RecordInfo * > &records, bool clearSequence=true)
Definition RecordFileReader.cpp:597
const string & getTag(StreamId streamId, const string &name) const
Definition RecordFileReader.h:442
bool isRecordAvailableOrPrefetch(const IndexRecord::RecordInfo &recordInfo)
Definition RecordFileReader.cpp:1114
bool isOpened() const
Definition RecordFileReader.cpp:193
const string & getFlavor(StreamId streamId) const
Definition RecordFileReader.cpp:1028
const map< StreamId, StreamTags > & getStreamTags() const
Get the tags for all the streams at once.
Definition RecordFileReader.h:434
StreamId getStreamForType(RecordableTypeId typeId, uint32_t indexNumber=0) const
Definition RecordFileReader.cpp:630
const IndexRecord::RecordInfo * getRecord(uint32_t globalIndex) const
Definition RecordFileReader.cpp:689
vector< std::pair< string, int64_t > > getFileChunks() const
Definition RecordFileReader.cpp:1106
StreamId getStreamForFlavor(RecordableTypeId typeId, const string &flavor, uint32_t indexNumber=0) const
Definition RecordFileReader.cpp:653
bool getRecordFormat(StreamId streamId, Record::Type recordType, uint32_t formatVersion, RecordFormat &outFormat) const
Definition RecordFileReader.cpp:973
uint32_t getRecordIndex(const IndexRecord::RecordInfo *record) const
Definition RecordFileReader.cpp:855
int openFile(const T &filePath, bool autoWriteFixedIndex=false)
Template overload for types that convert to string but not directly to string_view.
Definition RecordFileReader.h:109
double getLastDataRecordTime() const
Definition RecordFileReader.cpp:910
double getFirstDataRecordTime() const
Definition RecordFileReader.cpp:901
void setOpenProgressLogger(ProgressLogger *progressLogger)
Definition RecordFileReader.cpp:87
const IndexRecord::RecordInfo * getLastRecord(StreamId streamId, Record::Type recordType) const
Definition RecordFileReader.cpp:727
bool hasIndex() const
Definition RecordFileReader.cpp:615
bool readFirstConfigurationRecords(StreamPlayer *streamPlayer=nullptr)
Definition RecordFileReader.cpp:953
const vector< IndexRecord::RecordInfo > & getIndex() const
Definition RecordFileReader.h:266
bool mightContainAudio(StreamId streamId) const
Definition RecordFileReader.cpp:1060
bool isVrsFile(string_view filePath)
Definition RecordFileReader.cpp:201
bool readFirstConfigurationRecord(StreamId streamId, StreamPlayer *streamPlayer=nullptr)
Definition RecordFileReader.cpp:949
int readRecord(const IndexRecord::RecordInfo &recordInfo)
Definition RecordFileReader.cpp:1145
const string & getTag(const string &name) const
Definition RecordFileReader.h:423
int openFile(string_view filePath, bool autoWriteFixedIndex=false)
Definition RecordFileReader.cpp:118
bool setCachingStrategy(CachingStrategy cachingStrategy)
Definition RecordFileReader.h:519
bool setStatsCallback(const FileHandler::CacheStatsCallbackFunction &statsCallback)
Set callback function for cache stats.
Definition RecordFileReader.h:527
bool mightContainImages(StreamId streamId) const
Definition RecordFileReader.cpp:1056
const string & getOriginalRecordableTypeName(StreamId streamId) const
Definition RecordFileReader.cpp:1024
int clearStreamPlayers()
Definition RecordFileReader.cpp:504
StreamId getStreamForSerialNumber(const string &streamSerialNumber) const
Find the stream with the specified stream serial number.
Definition RecordFileReader.cpp:680
void setFileHandler(std::unique_ptr< FileHandler > fileHandler)
Definition RecordFileReader.cpp:97
const map< string, string > & getTags() const
Definition RecordFileReader.h:416
static int vrsFilePathToFileSpec(string_view filePath, FileSpec &outFileSpec, bool checkLocalFile=false)
Definition RecordFileReader.cpp:124
std::unique_ptr< FileHandler > getFileHandler() const
Definition RecordFileReader.cpp:103
const IndexRecord::RecordInfo * getNearestRecordByTime(double timestamp, double epsilon, StreamId streamId={}, Record::Type recordType=Record::Type::UNDEFINED) const
Definition RecordFileReader.cpp:801
bool readFirstConfigurationRecordsForType(RecordableTypeId typeId, StreamPlayer *streamPlayer=nullptr)
Definition RecordFileReader.cpp:961
StreamId getStreamForName(const string &name) const
Definition RecordFileReader.cpp:640
StreamId getStreamForTag(const string &tagName, const string &tag, RecordableTypeId typeId=RecordableTypeId::Undefined) const
Definition RecordFileReader.cpp:667
string getStreamsSignature() const
Definition RecordFileReader.cpp:1036
const set< StreamId > & getStreams() const
Definition RecordFileReader.h:210
int64_t getTotalSourceSize() const
Definition RecordFileReader.cpp:1110
const IndexRecord::RecordInfo * getRecordByTime(double timestamp) const
Definition RecordFileReader.cpp:743
uint32_t getRecordCount() const
Definition RecordFileReader.h:277
uint32_t getRecordStreamIndex(const IndexRecord::RecordInfo *record) const
Definition RecordFileReader.cpp:862
Type
Definition Record.h:90
VRS stream identifier class.
Definition StreamId.h:249
Class designed to receive record data when reading a VRS file.
Definition StreamPlayer.h:53
RecordReader specialized to read uncompressed records. For VRS internal usage only.
Definition RecordReaders.h:107
Definition Compressor.cpp:112
map< pair< Record::Type, uint32_t >, RecordFormat > RecordFormatMap
Map a pair of record type/format version to a record format, for a particular stream.
Definition RecordFormat.h:630
std::enable_if_t< !std::is_convertible_v< const T &, string_view > &&std::is_convertible_v< T, string >, int > EnableIfStringConvertible
Helper to enable overloads for types that convert to string but not directly to string_view.
Definition RecordFileReader.h:50
CachingStrategy
Caching strategy requests.
Definition FileHandler.h:38
RecordableTypeId
VRS stream type or class identifier enum.
Definition StreamId.h:51
@ Undefined
Value used for default initializations and marking undefined situations.
ContentType
Type of a record's block.
Definition RecordFormat.h:35
constexpr const char * kFailFastOnIncompleteIndex
Definition RecordFileReader.h:60
Generalized file descriptor class, allowing the efficient representation of complex file objects,...
Definition FileSpec.h:40
Helper class to hold the details about a single VRS record in memory.
Definition IndexRecord.h:109