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>
37#include <vrs/VrsExport.h>
44using std::string_view;
50 !std::is_convertible_v<const T&, string_view> && std::is_convertible_v<T, string>,
92 bool isVrsFile(string_view filePath);
98 bool isVrsFile(
const FileSpec& fileSpec);
107 int openFile(string_view filePath,
bool autoWriteFixedIndex =
false);
109 template <
typename T, EnableIfStringConvertible<T> = 0>
110 inline int openFile(
const T& filePath,
bool autoWriteFixedIndex =
false) {
111 return openFile(string_view(
static_cast<string>(filePath)), autoWriteFixedIndex);
119 int openFile(
const FileSpec& fileSpec,
bool autoWriteFixedIndex =
false);
123 bool isOpened()
const;
136 int clearStreamPlayers();
152 bool prefetchRecordSequence(
153 const vector<const IndexRecord::RecordInfo*>& records,
154 bool clearSequence =
true);
183 bool setupPlayer =
false);
188 int readAllRecords();
192 vector<std::pair<string, int64_t>> getFileChunks()
const;
196 int64_t getTotalSourceSize()
const;
207 bool hasIndex()
const;
220 vector<StreamId> getStreams(
RecordableTypeId typeId,
const string& flavor = {})
const;
227 StreamId getStreamForType(RecordableTypeId typeId, uint32_t indexNumber = 0)
const;
237 StreamId getStreamForName(
const string& name)
const;
246 getStreamForFlavor(RecordableTypeId typeId,
const string& flavor, uint32_t indexNumber = 0)
const;
256 StreamId getStreamForTag(
257 const string& tagName,
259 RecordableTypeId typeId = RecordableTypeId::Undefined)
const;
262 StreamId getStreamForSerialNumber(
const string& streamSerialNumber)
const;
267 const vector<IndexRecord::RecordInfo>&
getIndex()
const {
274 const vector<const IndexRecord::RecordInfo*>& getIndex(
StreamId streamId)
const;
279 return static_cast<uint32_t
>(recordIndex_.size());
285 uint32_t getRecordCount(
StreamId streamId)
const;
357 Record::Type recordType = Record::Type::UNDEFINED)
const;
362 uint32_t getRecordIndex(
const IndexRecord::RecordInfo* record)
const;
367 uint32_t getRecordStreamIndex(
const IndexRecord::RecordInfo* record)
const;
374 uint32_t getRecordSize(uint32_t recordIndex,
bool useBoundaries =
true)
const;
378 double getFirstDataRecordTime()
const;
382 double getLastDataRecordTime()
const;
398 bool readFirstConfigurationRecord(StreamId streamId, StreamPlayer* streamPlayer =
nullptr);
404 bool readFirstConfigurationRecords(StreamPlayer* streamPlayer =
nullptr);
411 bool readFirstConfigurationRecordsForType(
412 RecordableTypeId typeId,
413 StreamPlayer* streamPlayer =
nullptr);
424 const string&
getTag(
const string& name)
const {
425 return getTag(fileTags_, name);
444 return getTag(getTags(streamId).user, name);
451 const string& getOriginalRecordableTypeName(
StreamId streamId)
const;
459 const string& getFlavor(
StreamId streamId)
const;
472 const string& getSerialNumber(
StreamId streamId)
const;
477 string getStreamsSignature()
const;
484 bool mightContainImages(
StreamId streamId)
const;
491 bool mightContainAudio(
StreamId streamId)
const;
500 bool getRecordFormat(
503 uint32_t formatVersion,
521 return file_->setCachingStrategy(cachingStrategy);
524 return file_->getCachingStrategy();
529 return file_->setStatsCallback(statsCallback);
537 return file_->purgeCache();
548 void setFileHandler(std::unique_ptr<FileHandler> fileHandler);
552 std::unique_ptr<FileHandler> getFileHandler()
const;
561 vrsFilePathToFileSpec(string_view filePath,
FileSpec& outFileSpec,
bool checkLocalFile =
false);
564 using ParentType = std::array<uint32_t, enumCount<Record::Type>()>;
570 inline uint32_t operator[](
Record::Type recordType)
const {
571 return ParentType::operator[](
static_cast<uint32_t
>(recordType));
574 return ParentType::operator[](
static_cast<uint32_t
>(recordType));
576 uint32_t totalCount()
const;
579 void buildRecordBoundaries(
bool boundariesAndLimits =
false)
const;
582 int doOpenFile(
const FileSpec& fileSpec,
bool autoWriteFixedIndex,
bool checkSignatureOnly);
586 bool autoWriteFixedIndex,
588 bool readConfigRecords(
589 const set<const IndexRecord::RecordInfo*>& configRecords,
592 static const string& getTag(
const map<string, string>& tags,
const string& name);
595 int64_t getFollowingRecordOffset(uint32_t recordIndex,
bool useBoundaries)
const;
596 mutable vector<int64_t> recordBoundaries_;
597 mutable map<uint32_t, int64_t> recordLimits_;
600 std::unique_ptr<FileHandler> file_;
605 set<StreamId> streamIds_;
606 map<StreamId, StreamTags> streamTags_;
607 map<string, string> fileTags_;
608 vector<IndexRecord::RecordInfo> recordIndex_;
609 mutable map<StreamId, RecordTypeCounter> streamRecordCounts_;
612 map<StreamId, StreamPlayer*> streamPlayers_;
615 unique_ptr<ProgressLogger> defaultProgressLogger_;
617 unique_ptr<std::thread> detailsSaveThread_;
618 mutable map<StreamId, vector<const IndexRecord::RecordInfo*>> streamIndex_;
621 mutable map<pair<StreamId, Record::Type>, pair<uint32_t, size_t>> lastRequest_;
622 int64_t endOfUserRecordsOffset_{};
623 uint32_t recordHeaderSize_{};
624 bool fileHasAnIndex_{};
625 bool autoPrefetch_{};
636 const std::vector<const IndexRecord::RecordInfo*>& index,
RecordReader specialized to read compressed records. For VRS internal usage only.
Definition RecordReaders.h:116
Helper to identify a particular content block within a file.
Definition RecordFormat.h:644
The DataLayout class describes the data stored inside a DataLayoutContentBlock.
Definition DataLayout.h:211
ProgressLogger class to be notified of some process' progress.
Definition ProgressLogger.h:33
Definition RecordFileReader.h:563
The class to read VRS files.
Definition RecordFileReader.h:76
bool purgeFileCache()
Definition RecordFileReader.h:536
const string & getTag(StreamId streamId, const string &name) const
Definition RecordFileReader.h:443
const map< StreamId, StreamTags > & getStreamTags() const
Get the tags for all the streams at once.
Definition RecordFileReader.h:435
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:110
const vector< IndexRecord::RecordInfo > & getIndex() const
Definition RecordFileReader.h:267
const string & getTag(const string &name) const
Definition RecordFileReader.h:424
bool setCachingStrategy(CachingStrategy cachingStrategy)
Definition RecordFileReader.h:520
bool setStatsCallback(const FileHandler::CacheStatsCallbackFunction &statsCallback)
Set callback function for cache stats.
Definition RecordFileReader.h:528
const map< string, string > & getTags() const
Definition RecordFileReader.h:417
const set< StreamId > & getStreams() const
Definition RecordFileReader.h:211
uint32_t getRecordCount() const
Definition RecordFileReader.h:278
Type
Definition Record.h:91
VRS stream identifier class.
Definition StreamId.h:251
Class designed to receive record data when reading a VRS file.
Definition StreamPlayer.h:54
RecordReader specialized to read uncompressed records. For VRS internal usage only.
Definition RecordReaders.h:108
Definition Compressor.cpp:113
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:634
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:51
CachingStrategy
Caching strategy requests.
Definition FileHandler.h:38
RecordableTypeId
VRS stream type or class identifier enum.
Definition StreamId.h:51
ContentType
Type of a record's block.
Definition RecordFormat.h:36
constexpr const char * kFailFastOnIncompleteIndex
Definition RecordFileReader.h:61
Generalized file descriptor class, allowing the efficient representation of complex file objects,...
Definition FileSpec.h:42
Helper class to hold the details about a single VRS record in memory.
Definition IndexRecord.h:110