2
0

TimeProvider.h 722 B

1234567891011121314151617181920212223242526272829303132
  1. #pragma once
  2. #include <stdint.h> // for uint8_t
  3. #include <vector> // for vector
  4. namespace cspot {
  5. class TimeProvider {
  6. private:
  7. unsigned long long timestampDiff;
  8. public:
  9. /**
  10. * @brief Bypasses the need for NTP server sync by syncing with spotify's servers
  11. *
  12. */
  13. TimeProvider();
  14. /**
  15. * @brief Syncs the TimeProvider with spotify server's timestamp
  16. *
  17. * @param pongPacket pong packet containing timestamp
  18. */
  19. void syncWithPingPacket(const std::vector<uint8_t>& pongPacket);
  20. /**
  21. * @brief Get current timestamp synced with spotify servers
  22. *
  23. * @return unsigned long long timestamp
  24. */
  25. unsigned long long getSyncedTimestamp();
  26. };
  27. } // namespace cspot