9 #ifndef CLUON_PLAYER_HPP 10 #define CLUON_PLAYER_HPP 13 #include "cluon/cluonDataStructures.hpp" 31 IndexEntry(
const int64_t &sampleTimeStamp,
const uint64_t &filePosition) noexcept;
34 int64_t m_sampleTimeStamp{0};
35 uint64_t m_filePosition{0};
42 ONE_MILLISECOND_IN_MICROSECONDS = 1000,
43 ONE_SECOND_IN_MICROSECONDS = 1000 * ONE_MILLISECOND_IN_MICROSECONDS,
44 MAX_DELAY_IN_MICROSECONDS = 1 * ONE_SECOND_IN_MICROSECONDS,
46 MIN_ENTRIES_FOR_LOOK_AHEAD = 5000,
63 Player(
const std::string &file,
const bool &autoRewind,
const bool &threading) noexcept;
70 std::pair<bool, cluon::data::Envelope> getNextEnvelopeToBeReplayed() noexcept;
75 uint32_t delay()
const noexcept;
80 bool hasMoreData()
const noexcept;
85 void rewind() noexcept;
87 void seekTo(
float ratio) noexcept;
92 uint32_t totalNumberOfEnvelopesInRecFile()
const noexcept;
96 bool hasMoreDataFromRecFile()
const noexcept;
103 void initializeIndex() noexcept;
109 void computeInitialCacheLevelAndFillCache() noexcept;
114 void resetCaches() noexcept;
119 inline void resetIterators() noexcept;
128 uint32_t fillEnvelopeCache(
const uint32_t &maxNumberOfEntriesToReadFromFile) noexcept;
134 inline void checkAvailabilityOfNextEnvelopeToBeReplayed() noexcept;
142 std::fstream m_recFile;
150 mutable std::mutex m_indexMutex;
151 std::multimap<int64_t, IndexEntry> m_index;
155 std::multimap<int64_t, IndexEntry>::iterator m_previousPreviousEnvelopeAlreadyReplayed;
156 std::multimap<int64_t, IndexEntry>::iterator m_previousEnvelopeAlreadyReplayed;
157 std::multimap<int64_t, IndexEntry>::iterator m_currentEnvelopeToReplay;
160 std::multimap<int64_t, IndexEntry>::iterator m_nextEntryToReadFromRecFile;
162 uint32_t m_desiredInitialLevel;
165 cluon::data::TimeStamp m_firstTimePointReturningAEnvelope;
166 uint64_t m_numberOfReturnedEnvelopesInTotal;
176 void setEnvelopeCacheFillingRunning(
const bool &running) noexcept;
177 bool isEnvelopeCacheFillingRunning()
const noexcept;
182 void manageCache() noexcept;
191 float checkRefillingCache(
const uint32_t &numberOfEntries,
float refillMultiplicator) noexcept;
194 mutable std::mutex m_envelopeCacheFillingThreadIsRunningMutex;
195 bool m_envelopeCacheFillingThreadIsRunning;
196 std::thread m_envelopeCacheFillingThread;
199 std::map<uint64_t, cluon::data::Envelope> m_envelopeCache;
202 void setPlayerListener(std::function<
void(cluon::data::PlayerStatus playerStatus)> playerListener) noexcept;
205 std::mutex m_playerListenerMutex;
206 std::function<void(cluon::data::PlayerStatus playerStatus)> m_playerListener{
nullptr};
Definition: Player.hpp:39
#define LIBCLUON_API
Definition: cluon.hpp:56
Definition: Player.hpp:28