1
0

Cues.h 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. #pragma once
  2. #include <bfc/platform/types.h>
  3. #include "mkv_reader.h"
  4. #include <map>
  5. const uint32_t mkv_segment_cues = 0xc53bb6b;
  6. const uint32_t mkv_cues_cuepoint = 0x3b;
  7. const uint32_t mkv_cuepoint_cuetime=0x33;
  8. const uint32_t mkv_cuepoint_cuetrackpositions = 0x37;
  9. const uint32_t mkv_cuetrackpositions_cuetrack= 0x77;
  10. const uint32_t mkv_cuetrackpositions_cueclusterposition=0x71;
  11. namespace nsmkv
  12. {
  13. class CueTrackPosition
  14. {
  15. public:
  16. CueTrackPosition()
  17. #ifdef WA_VALIDATE
  18. :
  19. track_found(false),
  20. cluster_position_found(false)
  21. // block_number_found(false)
  22. #endif
  23. {
  24. track=0;
  25. cluster_position=0;
  26. block_number=0;
  27. }
  28. uint64_t track;
  29. uint64_t cluster_position;
  30. uint64_t block_number;
  31. #ifdef WA_VALIDATE
  32. bool track_found;
  33. bool cluster_position_found;
  34. // bool block_number_found;
  35. #endif
  36. };
  37. class CuePoint
  38. {
  39. public:
  40. CuePoint()
  41. #ifdef WA_VALIDATE
  42. :
  43. cue_time_found(false)
  44. #endif
  45. {
  46. cue_time = 0;
  47. }
  48. CueTrackPosition *GetPosition(uint64_t track);
  49. uint64_t cue_time;
  50. typedef std::map<uint64_t, CueTrackPosition*> CueTrackPositions; // keyed on track number
  51. CueTrackPositions cue_track_positions;
  52. #ifdef WA_VALIDATE
  53. bool cue_time_found;
  54. #endif
  55. };
  56. class Cues
  57. {
  58. public:
  59. enum
  60. {
  61. SEEK_WHATEVER=0,
  62. SEEK_FORWARD=1,
  63. SEEK_BACKWARD=2,
  64. };
  65. CuePoint *GetCuePoint(uint64_t when, uint64_t current_time=0, int seek_direction=SEEK_WHATEVER);
  66. typedef std::map<uint64_t, CuePoint*> CuePoints; // use Map on cue_time to ensure order
  67. CuePoints cue_points;
  68. };
  69. uint64_t ReadCues(MKVReader *reader, uint64_t size, nsmkv::Cues &cues);
  70. }