| 47 | typedef std::map<std::string, std::string> ConfigStrings; |
| 48 | |
| 49 | class DeviceImpl : public Device |
| 50 | { |
| 51 | private: |
| 52 | libfreenect2::Freenect2Device *dev; |
| 53 | ColorStream* color; |
| 54 | DepthStream* depth; |
| 55 | IrStream* ir; |
| 56 | Registration *reg; |
| 57 | ConfigStrings config; |
| 58 | bool device_stop; |
| 59 | bool device_used; |
| 60 | libfreenect2::SyncMultiFrameListener listener; |
| 61 | libfreenect2::thread* thread; |
| 62 | |
| 63 | static void static_run(void* cookie) |
| 64 | { |
| 65 | static_cast<DeviceImpl*>(cookie)->run(); |
| 66 | } |
| 67 | |
| 68 | VideoStream* getStream(libfreenect2::Frame::Type type) |
| 69 | { |
| 70 | if (type == libfreenect2::Frame::Depth) |
| 71 | return depth; |
| 72 | if (type == libfreenect2::Frame::Ir) |
| 73 | return ir; |
| 74 | if (type == libfreenect2::Frame::Color) |
| 75 | return color; |
| 76 | return NULL; |
| 77 | } |
| 78 | |
| 79 | void run() |
| 80 | { |
| 81 | libfreenect2::FrameMap frames; |
| 82 | uint32_t seqNum = 0; |
| 83 | libfreenect2::Frame::Type seqType; |
| 84 | |
| 85 | struct streams { |
| 86 | const char* name; |
| 87 | libfreenect2::Frame::Type type; |
| 88 | } streams[] = { |
| 89 | { "Ir", libfreenect2::Frame::Ir }, |
| 90 | { "Depth", libfreenect2::Frame::Depth }, |
| 91 | { "Color", libfreenect2::Frame::Color } |
| 92 | }; |
| 93 | while(!device_stop) |
| 94 | { |
| 95 | listener.waitForNewFrame(frames); |
| 96 | |
| 97 | for (unsigned i = 0; i < sizeof(streams)/sizeof(*streams); i++) { |
| 98 | struct streams& s = streams[i]; |
| 99 | VideoStream* stream = getStream(s.type); |
| 100 | libfreenect2::Frame *frame = frames[s.type]; |
| 101 | if (stream) { |
| 102 | if (seqNum == 0) |
| 103 | seqType = s.type; |
| 104 | if (s.type == seqType) |
| 105 | seqNum++; |
| 106 | frame->timestamp = seqNum * 33369; |
nothing calls this directly
no outgoing calls
no test coverage detected