Skip to content

Commit 7867c9e

Browse files
committed
Merge pull request #507 from xlz/preemptive-api-expansion
Preemptive API expansion
2 parents 7fa5b68 + 625a9e9 commit 7867c9e

File tree

3 files changed

+39
-17
lines changed

3 files changed

+39
-17
lines changed

include/libfreenect2/frame_listener.hpp

+14-3
Original file line numberDiff line numberDiff line change
@@ -44,23 +44,34 @@ namespace libfreenect2
4444
class LIBFREENECT2_API Frame
4545
{
4646
public:
47-
/** Available types of frames and their pixel format. */
47+
/** Available types of frames. */
4848
enum Type
4949
{
5050
Color = 1, ///< 1920x1080 32-bit BGRX.
5151
Ir = 2, ///< 512x424 float. Range is [0.0, 65535.0].
5252
Depth = 4 ///< 512x424 float, unit: millimeter. Non-positive, NaN, and infinity are invalid or missing data.
5353
};
5454

55-
uint32_t timestamp; ///< Unit: roughly or exactly 0.1 millisecond
56-
uint32_t sequence; ///< Increasing frame sequence number
55+
/** (Proposed for 0.2) Pixel format. */
56+
enum Format
57+
{
58+
BGRX,
59+
RGBX,
60+
Gray,
61+
Float
62+
};
63+
5764
size_t width; ///< Length of a line (in pixels).
5865
size_t height; ///< Number of lines in the frame.
5966
size_t bytes_per_pixel; ///< Number of bytes in a pixel.
6067
unsigned char* data; ///< Data of the frame (aligned). @see See Frame::Type for pixel format.
68+
uint32_t timestamp; ///< Unit: roughly or exactly 0.1 millisecond
69+
uint32_t sequence; ///< Increasing frame sequence number
6170
float exposure; ///< From 0.5 (very bright) to ~60.0 (fully covered)
6271
float gain; ///< From 1.0 (bright) to 1.5 (covered)
6372
float gamma; ///< From 1.0 (bright) to 6.4 (covered)
73+
uint32_t status; ///< Reserved. To be defined in 0.2.
74+
Format format; ///< Reserved. To be defined in 0.2.
6475

6576
/** Construct a new frame.
6677
* @param width Width in pixel

include/libfreenect2/libfreenect2.hpp

+13-5
Original file line numberDiff line numberDiff line change
@@ -369,14 +369,22 @@ class LIBFREENECT2_API Freenect2Device
369369
* All above configuration must only be called before start() or after stop().
370370
*
371371
* FrameListener will receive frames when the device is running.
372+
*
373+
* @return Undefined. To be defined in 0.2.
372374
*/
373-
virtual void start() = 0;
375+
virtual bool start() = 0;
374376

375-
/** Stop data processing. */
376-
virtual void stop() = 0;
377+
/** Stop data processing.
378+
*
379+
* @return Undefined. To be defined in 0.2.
380+
*/
381+
virtual bool stop() = 0;
377382

378-
/** Shut down the device. */
379-
virtual void close() = 0;
383+
/** Shut down the device.
384+
*
385+
* @return Undefined. To be defined in 0.2.
386+
*/
387+
virtual bool close() = 0;
380388
};
381389

382390
class Freenect2Impl;

src/libfreenect2.cpp

+12-9
Original file line numberDiff line numberDiff line change
@@ -259,9 +259,9 @@ class Freenect2DeviceImpl : public Freenect2Device
259259

260260
virtual void setColorFrameListener(libfreenect2::FrameListener* rgb_frame_listener);
261261
virtual void setIrAndDepthFrameListener(libfreenect2::FrameListener* ir_frame_listener);
262-
virtual void start();
263-
virtual void stop();
264-
virtual void close();
262+
virtual bool start();
263+
virtual bool stop();
264+
virtual bool close();
265265
};
266266

267267
struct PrintBusAndDevice
@@ -671,10 +671,10 @@ bool Freenect2DeviceImpl::open()
671671
return true;
672672
}
673673

674-
void Freenect2DeviceImpl::start()
674+
bool Freenect2DeviceImpl::start()
675675
{
676676
LOG_INFO << "starting...";
677-
if(state_ != Open) return;
677+
if(state_ != Open) return false;
678678

679679
CommandTransaction::Result serial_result, firmware_result, result;
680680

@@ -801,16 +801,17 @@ void Freenect2DeviceImpl::start()
801801

802802
state_ = Streaming;
803803
LOG_INFO << "started";
804+
return true;
804805
}
805806

806-
void Freenect2DeviceImpl::stop()
807+
bool Freenect2DeviceImpl::stop()
807808
{
808809
LOG_INFO << "stopping...";
809810

810811
if(state_ != Streaming)
811812
{
812813
LOG_INFO << "already stopped, doing nothing";
813-
return;
814+
return false;
814815
}
815816

816817
LOG_INFO << "disabling usb transfer submission...";
@@ -837,16 +838,17 @@ void Freenect2DeviceImpl::stop()
837838

838839
state_ = Open;
839840
LOG_INFO << "stopped";
841+
return true;
840842
}
841843

842-
void Freenect2DeviceImpl::close()
844+
bool Freenect2DeviceImpl::close()
843845
{
844846
LOG_INFO << "closing...";
845847

846848
if(state_ == Closed)
847849
{
848850
LOG_INFO << "already closed, doing nothing";
849-
return;
851+
return true;
850852
}
851853

852854
if(state_ == Streaming)
@@ -885,6 +887,7 @@ void Freenect2DeviceImpl::close()
885887

886888
state_ = Closed;
887889
LOG_INFO << "closed";
890+
return true;
888891
}
889892

890893
PacketPipeline *createDefaultPacketPipeline()

0 commit comments

Comments
 (0)