Lumiverse  2.5
A framework for creating lighting control applications
ArnoldMemoryFrameManager.h
Go to the documentation of this file.
1 
4 #ifndef _ArnoldMemoryFRAMEMANAGER_H_
5 #define _ArnoldMemoryFRAMEMANAGER_H_
6 
7 #pragma once
8 
9 #include "LumiverseCoreConfig.h"
10 #ifdef USE_ARNOLD
11 
12 #include "../lib/libjson/libjson.h"
13 #include "ArnoldFrameManager.h"
14 
15 #include <mutex>
16 #include <functional>
17 #include <set>
18 #include <chrono>
19 #include <iostream>
20 
21 namespace Lumiverse {
23  struct FrameData {
24  // The time point
25  time_t time;
26  // RGBA frame buffer
27  float *buffer;
28 
29  // To make the ordered set.
30  bool operator<(FrameData other) const {
31  return time < other.time;
32  }
33  };
34 
42  class ArnoldMemoryFrameManager : public ArnoldFrameManager
43  {
44  public:
48  ArnoldMemoryFrameManager(int fps = 24) :
49  ArnoldFrameManager(fps), m_bufferSet([](FrameData l, FrameData r) { return l < r; }) { }
50 
54  virtual ~ArnoldMemoryFrameManager();
55 
60  virtual void dump(time_t time, float *frame, size_t width, size_t height);
61 
69  virtual float *getCurrentFrameBuffer();
70 
78  virtual time_t getCurrentTime() const;
79 
86  virtual time_t getNextTime() const;
87 
93  virtual bool hasNext() const;
94 
99  virtual bool isEmpty() const { return m_bufferSet.size() == 0; }
100 
106  virtual size_t getFrameNum() const { return m_bufferSet.size(); }
107 
113  virtual void clear();
114 
120  virtual std::string getType() { return "ArnoldMemoryFrameManager"; }
121 
122  private:
123  // A set for frame data ordered by time ascendingly.
124  std::set<FrameData, std::function<bool(FrameData, FrameData)>> m_bufferSet;
125  // Lock for the set.
126  std::mutex m_buffer;
127  };
128 
129 }
130 
131 #endif
132 
133 #endif
Contains all core Lumiverse functions and variables.
Definition: Device.cpp:2
The superclass for all implementation of frame managers.