ADTF File Library
Loading...
Searching...
No Matches
indexedfilereader_v201_v301.h
Go to the documentation of this file.
1
16
17#ifndef INDEXEDFILE_READER_V201_V301_CLASS_HEADER
18#define INDEXEDFILE_READER_V201_V301_CLASS_HEADER
19
22
23#include <memory>
24#include <map>
25#include <optional>
26
27namespace ifhd
28{
29namespace v201_v301
30{
31
36{
37 public:
41 virtual ~SourceFile() = default;
42
49 virtual void read(void* destination, uint64_t count) = 0;
50
56 virtual void seek(uint64_t offset) = 0;
57};
58
59//*************************************************************************************************
64{
65 private:
66 class IndexedFileReaderImpl;
67 std::unique_ptr<IndexedFileReaderImpl> _d;
68
69 protected:
71 // For internal use only (will be moved to a private implementation).
72 uint32_t _flags;
73 int64_t _end_of_data_marker;
74 bool _file_pos_invalid;
75 ChunkHeader* _current_chunk;
76 void* _current_chunk_data;
77 bool _header_valid;
78 bool _data_valid;
79 bool _prefetched;
80 int64_t _chunk_index;
81 int64_t _index_table_index;
82 FilePos _file_pos_current_chunk;
83
84 IndexReadTable _index_table;
85
86 protected:
87 bool _compatibility_v110;
88 void* _delegate;
89 mutable std::map<std::string, FileExtension> _extension_info_v110_by_name;
90 a_util::filesystem::Path _filename;
92
93 public:
98
103
107 static constexpr auto read_cache_default = std::nullopt;
111 static constexpr size_t read_cache_deactivated = 0;
125 virtual void open(const a_util::filesystem::Path& filename,
126 const std::optional<size_t>& read_cache_size = IndexedFileReader::read_cache_default,
127 uint32_t flags = 0);
128
137 virtual void open(const std::shared_ptr<SourceFile>& source_file, uint32_t flags = 0);
138
144 virtual void close();
145
151 void reset();
152
163 int64_t getCurrentPos(TimeFormat time_format) const;
164
175 int64_t setCurrentPos(int64_t position, TimeFormat time_format);
176
177
190 int64_t seek(uint16_t stream_id,
191 int64_t position,
192 TimeFormat time_format,
193 uint32_t flags=0);
194
202 void queryChunkInfo(ChunkHeader** chunk_header);
203
213 void readChunk(void** data, uint32_t flags=0);
214
221 void skipChunk();
222
235 void readNextChunk(ChunkHeader** chunk_header, void** data, uint32_t flags=0, uint32_t stream_id=0);
236
243
251 void readNextChunkInfo(ChunkHeader** chunk_header);
252
260 int64_t getFilePos() const;
261
270 int64_t getChunkCount() const;
271
280 timestamp_t getDuration() const;
281
290 uint32_t getVersionId() const;
291
300 timestamp_t getTimeOffset() const;
301
312 int64_t getStreamTableIndexCount(uint16_t stream_id) const;
313
324 int64_t getStreamIndexCount(uint16_t stream_id) const;
325
336 void getAdditionalStreamInfo(uint16_t stream_id,
337 const void** info_data,
338 size_t* info_size) const;
349 std::string getStreamName(uint16_t stream_id) const;
350
357 bool streamExists(uint16_t stream_id) const;
358
369 timestamp_t getFirstTime(uint16_t stream_id) const;
370
381 timestamp_t getLastTime(uint16_t stream_id) const;
382
388 size_t getExtensionCount() const;
389
403 bool findExtension(const char* identifier,
404 FileExtension** extension_info,
405 void** data) const;
406
418 void getExtension(size_t index,
419 FileExtension** extension_info,
420 void** data) const;
421
434 int64_t lookupChunkRef(uint16_t stream_id, int64_t position, TimeFormat time_format) const;
435
446 bool getLastChunkWithFlagBefore(uint64_t chunk_index, uint16_t stream_id, uint16_t flag,
447 ChunkHeader& header,
448 std::vector<uint8_t>& data);
449
450 protected:
454 virtual void initialize();
455
460
465
466 protected:
467
472
476 void readCurrentChunkData(void* buffer);
477
482 void setEOF();
483
489 void readDataBlock(void* buffer, size_t buffer_size);
490
496
501
506};
507
508} // namespace
509} // namespace
510
511//*************************************************************************************************
512#endif // _INDEXEDFILE_READER_V201_V301_CLASS_HEADER_
Definition indexreadtable_v201_v301.h:32
void readCurrentChunkData(void *buffer)
int64_t getStreamTableIndexCount(uint16_t stream_id) const
void readNextChunkInfo(ChunkHeader **chunk_header)
int64_t lookupChunkRef(uint16_t stream_id, int64_t position, TimeFormat time_format) const
bool streamExists(uint16_t stream_id) const
Checks if stream with given id exists.
bool findExtension(const char *identifier, FileExtension **extension_info, void **data) const
int64_t getCurrentPos(TimeFormat time_format) const
timestamp_t getTimeOffset() const
static constexpr auto read_cache_default
Definition indexedfilereader_v201_v301.h:107
void queryChunkInfo(ChunkHeader **chunk_header)
static constexpr size_t read_cache_deactivated
Definition indexedfilereader_v201_v301.h:111
std::string getStreamName(uint16_t stream_id) const
timestamp_t getLastTime(uint16_t stream_id) const
int64_t getStreamIndexCount(uint16_t stream_id) const
timestamp_t getFirstTime(uint16_t stream_id) const
bool getLastChunkWithFlagBefore(uint64_t chunk_index, uint16_t stream_id, uint16_t flag, ChunkHeader &header, std::vector< uint8_t > &data)
virtual void open(const a_util::filesystem::Path &filename, const std::optional< size_t > &read_cache_size=IndexedFileReader::read_cache_default, uint32_t flags=0)
void readChunk(void **data, uint32_t flags=0)
virtual void open(const std::shared_ptr< SourceFile > &source_file, uint32_t flags=0)
int64_t setCurrentPos(int64_t position, TimeFormat time_format)
void readNextChunk(ChunkHeader **chunk_header, void **data, uint32_t flags=0, uint32_t stream_id=0)
void getExtension(size_t index, FileExtension **extension_info, void **data) const
void readDataBlock(void *buffer, size_t buffer_size)
int64_t seek(uint16_t stream_id, int64_t position, TimeFormat time_format, uint32_t flags=0)
void getAdditionalStreamInfo(uint16_t stream_id, const void **info_data, size_t *info_size) const
Definition indexedfilereader_v201_v301.h:36
virtual void read(void *destination, uint64_t count)=0
virtual ~SourceFile()=default
virtual void seek(uint64_t offset)=0
namespace for indexed file definitions in version 2.0, 2.1, 3.0 and 3.1
Definition indexedfile_types_v201_v301.h:28
TimeFormat
Definition indexedfile_types_v201_v301.h:57
namespace for IFHD File library
Definition indexedfile_types.h:30
utils5ext::FilePos FilePos
file pos type
Definition indexedfile_types.h:54
header for chunks Each Chunk header 16 Byte aligned within the file.
Definition indexedfile_types_v201_v301.h:189
Header for a file extensions.
Definition indexedfile_types_v201_v301.h:161