OpenDaVINCI  4.16.0
RecMemIndex.h
Go to the documentation of this file.
1 
20 #ifndef OPENDAVINCI_TOOLS_PLAYER_RECMEMINDEX_H_
21 #define OPENDAVINCI_TOOLS_PLAYER_RECMEMINDEX_H_
22 
23 #include <deque>
24 #include <fstream>
25 #include <map>
26 #include <thread>
27 
33 
36 
37 namespace odtools {
38  namespace player {
39 
40  using namespace std;
41 
43  public:
45  virtual ~RawMemoryBufferEntry();
47  RawMemoryBufferEntry& operator=(const RawMemoryBufferEntry &obj);
48 
49  public:
53  };
54 
60  private:
61  enum {
62  ONE_MILLISECOND_IN_MICROSECONDS = 1000,
63  };
64 
65  private:
73  RecMemIndex(const RecMemIndex &/*obj*/) = delete;
74 
83  RecMemIndex& operator=(const RecMemIndex &/*obj*/) = delete;
84 
85  public:
94  RecMemIndex(const odcore::io::URL &url, const uint32_t &memorySegmentSize, const uint32_t &numberOfMemorySegments, const bool &threading);
95 
96  virtual ~RecMemIndex();
97 
103  bool hasMoreData() const;
104 
108  void rewind();
109 
117  int64_t peekNextSampleTimeToPlayBack() const;
118 
125  odcore::data::Container makeNextRawMemoryEntryAvailable();
126 
127  private:
134  void initializeIndex();
135 
136  private: // File handle for the RecMemIndex.
137  bool m_threading;
138 
139  odcore::io::URL m_url;
140 
141  // Handle to .rec.mem file.
142  fstream m_recMemFile;
143  bool m_recMemFileValid;
144 
145  private: // Index and cache management.
146  mutable odcore::base::Mutex m_indexMutex;
147  multimap<int64_t, IndexEntry> m_index;
148  multimap<int64_t, IndexEntry>::iterator m_nextEntryToPlayBack;
149  multimap<int64_t, IndexEntry>::iterator m_nextEntryToReadFromRecMemFile;
150  bool m_hasMoreData;
151 
152  // Mapping of pos_type (within .rec.mem file) --> meta-entry describing tupel (Container, raw memory).
153  map<uint64_t, shared_ptr<RawMemoryBufferEntry> > m_rawMemoryBuffer;
154  deque<shared_ptr<RawMemoryBufferEntry> > m_unusedEntriesFromRawMemoryBuffer;
155  vector<shared_ptr<RawMemoryBufferEntry> > m_allEntriesFromRawMemoryBuffer;
156 
157  map<string, std::shared_ptr<odcore::wrapper::SharedMemory> > m_mapOfPointersToSharedMemorySegments;
158 
159  private:
165  void setRawMemoryBufferFillingRunning(const bool &running);
166  bool isRawMemoryBufferFillingRunning() const;
167 
171  void manageRawMemoryBuffer();
172 
173  private:
174  mutable odcore::base::Mutex m_rawMemoryBufferFillingThreadIsRunningMutex;
175  bool m_rawMemoryBufferFillingThreadIsRunning;
176  std::thread m_rawMemoryBufferFillingThread;
177  };
178 
179  } // player
180 } // tools
181 
182 #endif /*OPENDAVINCI_TOOLS_PLAYER_RECMEMINDEX_H_*/
Definition: URL.h:38
Definition: base/Mutex.h:49
Definition: Container.h:40
uint32_t m_lengthOfRawMemoryBuffer
Definition: RecMemIndex.h:52
odcore::data::Container m_container
Definition: RecMemIndex.h:50
#define OPENDAVINCI_API
Definition: opendavinci.h:67
Definition: RecMemIndex.h:59
Definition: RecMemIndex.h:42
char * m_rawMemoryBuffer
Definition: RecMemIndex.h:51