time_keeper.h 461 B

12345678910111213141516171819202122232425
  1. #pragma once
  2. #include <stdlib.h>
  3. #include <chrono>
  4. namespace ffmpeg {
  5. /**
  6. * Class keeps the track of the decoded timestamps (us) for media streams.
  7. */
  8. class TimeKeeper {
  9. public:
  10. TimeKeeper() = default;
  11. // adjust provided @timestamp to the corrected value
  12. // return advised sleep time before next frame processing in (us)
  13. long adjust(long& decoderTimestamp);
  14. private:
  15. long startTime_{0};
  16. long streamTimestamp_{0};
  17. };
  18. } // namespace ffmpeg