|
33 | 33 | #include <libfreenect2/frame_listener.hpp> |
34 | 34 | #include <libfreenect2/packet_pipeline.h> |
35 | 35 | #include <string> |
| 36 | +#include <vector> |
36 | 37 |
|
37 | 38 | namespace libfreenect2 |
38 | 39 | { |
@@ -274,6 +275,68 @@ class LIBFREENECT2_API Freenect2 |
274 | 275 | Freenect2& operator=(const Freenect2&); |
275 | 276 | }; |
276 | 277 |
|
| 278 | +class Freenect2ReplayDevice; |
| 279 | + |
| 280 | +/** |
| 281 | + * Library context to create and open replay devices. |
| 282 | + * |
| 283 | + * You openDevice() and control the device with returned Freenect2ReplayDevice object. |
| 284 | + * |
| 285 | + * You may open devices with custom PacketPipeline. |
| 286 | + * After passing a PacketPipeline object to libfreenect2 do not use or free the object, |
| 287 | + * libfreenect2 will take care. If openDevice() fails the PacketPipeline object will get |
| 288 | + * deleted. A new PacketPipeline object has to be created each time a device is opened. |
| 289 | + */ |
| 290 | +class LIBFREENECT2_API Freenect2Replay |
| 291 | +{ |
| 292 | +public: |
| 293 | + /** |
| 294 | + * Creates the context. |
| 295 | + */ |
| 296 | + Freenect2Replay(); |
| 297 | + virtual ~Freenect2Replay(); |
| 298 | + |
| 299 | + /** |
| 300 | + * @return Replay device serial number. |
| 301 | + */ |
| 302 | + std::string getDefaultDeviceSerialNumber(); |
| 303 | + |
| 304 | + /** Open device by a collection of stored frame filenames with default pipeline. |
| 305 | + * See filename format below. |
| 306 | + * @param frame_filenames A list of filenames for stored frames. |
| 307 | + * @return New device object, or NULL on failure |
| 308 | + */ |
| 309 | + Freenect2Device *openDevice(const std::vector<std::string>& frame_filenames); |
| 310 | + |
| 311 | + /** Open device by a collection of stored frame filenames with the specified pipeline. |
| 312 | + * File names non-compliant with the filename format will be skipped. |
| 313 | + * Filename format: <prefix>_<timestamp>_<sequence>.<suffix> |
| 314 | + * <prefix> - a string of the filename, anything |
| 315 | + * <timestamp> -- packet timestamp as in pipeline packets |
| 316 | + * <sequence> -- frame sequence number in the packet |
| 317 | + * <suffix> -- .depth, .jpg, or .jpeg (case insensitive) |
| 318 | + * @param frame_filenames A list of filenames for stored frames. |
| 319 | + * @param factory New PacketPipeline instance. This is always automatically freed. |
| 320 | + * @return New device object, or NULL on failure |
| 321 | + */ |
| 322 | + Freenect2Device *openDevice(const std::vector<std::string>& frame_filenames, const PacketPipeline *factory); |
| 323 | + |
| 324 | +private: |
| 325 | + typedef std::vector<Freenect2ReplayDevice*> DeviceVector; |
| 326 | + DeviceVector devices_; |
| 327 | + |
| 328 | + bool initialized; |
| 329 | + |
| 330 | + void addDevice(Freenect2ReplayDevice *device); |
| 331 | + void removeDevice(Freenect2ReplayDevice *device); |
| 332 | + void clearDevices(); |
| 333 | + int getNumDevices(); |
| 334 | + |
| 335 | + /* Disable copy and assignment constructors */ |
| 336 | + Freenect2Replay(const Freenect2Replay&); |
| 337 | + Freenect2Replay& operator=(const Freenect2Replay&); |
| 338 | +}; |
| 339 | + |
277 | 340 | ///@} |
278 | 341 | } /* namespace libfreenect2 */ |
279 | 342 | #endif /* LIBFREENECT2_HPP_ */ |
0 commit comments