1
0

seektable.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. #pragma once
  2. #include <map>
  3. #include "../nsavi/avi_header.h"
  4. //#define SEEK_TABLE_STORE_CHUNK_HEADER
  5. namespace nsavi
  6. {
  7. struct HeaderList;
  8. struct SeekEntry
  9. {
  10. SeekEntry(int dummy=0) : timestamp(0), absolute(false) {}
  11. int timestamp; // in miliseconds
  12. bool absolute;
  13. uint64_t file_position = 0;
  14. #ifdef SEEK_TABLE_STORE_CHUNK_HEADER
  15. uint32_t chunk_id; // chunk ID at file_position, used to verify seeking
  16. uint32_t chunk_size; // chunk size at file_position, used to verify seeking
  17. #endif
  18. uint64_t stream_time = 0; // actually allocated to header_list->stream_list_size
  19. };
  20. class SeekTable
  21. {
  22. public:
  23. SeekTable(int stream_number, bool require_keyframes, const nsavi::HeaderList *header_list);
  24. ~SeekTable();
  25. enum
  26. {
  27. SEEK_WHATEVER=0,
  28. SEEK_FORWARD=1,
  29. SEEK_BACKWARD=2,
  30. };
  31. const SeekEntry *GetSeekPoint(int &timestamp_ms, int current_ms=0, int seek_direction=SEEK_WHATEVER);
  32. void AddIndex(const IDX1 *index);
  33. void AddIndex(const INDX *index, uint64_t start_time);
  34. // returns a recommend place to go hunting for an idx1, indx or ix## chunk
  35. // usually based on indx super chunks already found in header_list
  36. bool GetIndexLocation(int timestamp, uint64_t *position, uint64_t *start_time);
  37. typedef std::map<int, SeekEntry> SeekEntries; // mapped to timestamp in milliseconds
  38. SeekEntries seek_entries;
  39. std::map<const void *, bool> data_processed; // TODO: make nu::Set
  40. const nsavi::HeaderList *header_list;
  41. int stream_number; // which stream number is this Seek Table associated with
  42. bool require_keyframes; // whether or not the master stream requires keyframes
  43. const nsavi::STRH *stream;
  44. const nsavi::AVISUPERINDEX *super_index;
  45. uint32_t indices_processed;
  46. uint64_t super_index_duration;
  47. };
  48. }