1 #pragma once
2 
3 #include <pangolin/pangolin.h>
4 #include <pangolin/video/video.h>
5 #include <pangolin/utils/posix/condition_variable.h>
6 #include <pangolin/utils/posix/shared_memory_buffer.h>
7 
8 #include <memory>
9 #include <vector>
10 
11 namespace pangolin
12 {
13 
14 class SharedMemoryVideo : public VideoInterface
15 {
16 public:
17   SharedMemoryVideo(size_t w, size_t h, std::string pix_fmt,
18     const std::shared_ptr<SharedMemoryBufferInterface>& shared_memory,
19     const std::shared_ptr<ConditionVariableInterface>& buffer_full);
20   ~SharedMemoryVideo();
21 
22   size_t SizeBytes() const;
23   const std::vector<StreamInfo>& Streams() const;
24   void Start();
25   void Stop();
26   bool GrabNext(unsigned char *image, bool wait);
27   bool GrabNewest(unsigned char *image, bool wait);
28 
29 private:
30   PixelFormat _fmt;
31   size_t _frame_size;
32   std::vector<StreamInfo> _streams;
33   std::shared_ptr<SharedMemoryBufferInterface> _shared_memory;
34   std::shared_ptr<ConditionVariableInterface> _buffer_full;
35 };
36 
37 }
38