Add start/stop source
This commit is contained in:
parent
f1b480e4c3
commit
d80189512d
|
@ -149,6 +149,21 @@ enum class Option : std::uint8_t {
|
|||
LAST
|
||||
};
|
||||
|
||||
/**
|
||||
* @ingroup enumerations
|
||||
* @brief Source allows the user to choose which data to be captured.
|
||||
*/
|
||||
enum class Source : std::uint8_t {
|
||||
/** Video streaming of stereo, color, depth, etc. */
|
||||
VIDEO_STREAMING,
|
||||
/** Motion tracking of IMU (accelerometer, gyroscope) */
|
||||
MOTION_TRACKING,
|
||||
/** Enable everything together */
|
||||
ALL,
|
||||
/** Last guard */
|
||||
LAST
|
||||
};
|
||||
|
||||
#define MYNTEYE_ENUM_HELPERS(TYPE) \
|
||||
const char *to_string(const TYPE &value); \
|
||||
inline bool is_valid(const TYPE &value) { \
|
||||
|
@ -170,6 +185,7 @@ MYNTEYE_ENUM_HELPERS(Stream)
|
|||
MYNTEYE_ENUM_HELPERS(Capabilities)
|
||||
MYNTEYE_ENUM_HELPERS(Info)
|
||||
MYNTEYE_ENUM_HELPERS(Option)
|
||||
MYNTEYE_ENUM_HELPERS(Source)
|
||||
|
||||
#undef MYNTEYE_ENUM_HELPERS
|
||||
|
||||
|
|
|
@ -113,6 +113,32 @@ void Device::SetMotionCallback(motion_callback_t callback) {
|
|||
motion_callback_ = callback;
|
||||
}
|
||||
|
||||
void Device::Start(const Source &source) {
|
||||
if (source == Source::VIDEO_STREAMING) {
|
||||
StartVideoStreaming();
|
||||
} else if (source == Source::MOTION_TRACKING) {
|
||||
StartMotionTracking();
|
||||
} else if (source == Source::ALL) {
|
||||
Start(Source::VIDEO_STREAMING);
|
||||
Start(Source::MOTION_TRACKING);
|
||||
} else {
|
||||
LOG(FATAL) << "Unsupported source :(";
|
||||
}
|
||||
}
|
||||
|
||||
void Device::Stop(const Source &source) {
|
||||
if (source == Source::VIDEO_STREAMING) {
|
||||
StopVideoStreaming();
|
||||
} else if (source == Source::MOTION_TRACKING) {
|
||||
StopMotionTracking();
|
||||
} else if (source == Source::ALL) {
|
||||
Stop(Source::VIDEO_STREAMING);
|
||||
Stop(Source::MOTION_TRACKING);
|
||||
} else {
|
||||
LOG(FATAL) << "Unsupported source :(";
|
||||
}
|
||||
}
|
||||
|
||||
StreamRequest Device::GetStreamRequest(const Capabilities &capability) const {
|
||||
if (!Supports(capability)) {
|
||||
LOG(FATAL) << "Unsupported capability: " << to_string(capability);
|
||||
|
@ -121,6 +147,21 @@ StreamRequest Device::GetStreamRequest(const Capabilities &capability) const {
|
|||
return requests.at(capability);
|
||||
}
|
||||
|
||||
void Device::StartVideoStreaming() {}
|
||||
|
||||
void Device::StopVideoStreaming() {}
|
||||
|
||||
void Device::StartMotionTracking() {
|
||||
if (!Supports(Capabilities::IMU)) {
|
||||
LOG(FATAL) << "IMU is not supported by this device";
|
||||
}
|
||||
// TODO(JohnZhao)
|
||||
}
|
||||
|
||||
void Device::StopMotionTracking() {
|
||||
// TODO(JohnZhao)
|
||||
}
|
||||
|
||||
void Device::ReadDeviceInfo() {
|
||||
// TODO(JohnZhao): Read device info
|
||||
}
|
||||
|
|
|
@ -54,6 +54,9 @@ class Device {
|
|||
void SetStreamCallback(const Stream &stream, stream_callback_t callback);
|
||||
void SetMotionCallback(motion_callback_t callback);
|
||||
|
||||
virtual void Start(const Source &source);
|
||||
virtual void Stop(const Source &source);
|
||||
|
||||
protected:
|
||||
std::shared_ptr<uvc::device> device() const {
|
||||
return device_;
|
||||
|
@ -65,6 +68,12 @@ class Device {
|
|||
|
||||
StreamRequest GetStreamRequest(const Capabilities &capability) const;
|
||||
|
||||
virtual void StartVideoStreaming();
|
||||
virtual void StopVideoStreaming();
|
||||
|
||||
virtual void StartMotionTracking();
|
||||
virtual void StopMotionTracking();
|
||||
|
||||
private:
|
||||
Model model_;
|
||||
std::shared_ptr<uvc::device> device_;
|
||||
|
|
|
@ -102,6 +102,20 @@ const char *to_string(const Option &value) {
|
|||
#undef CASE
|
||||
}
|
||||
|
||||
const char *to_string(const Source &value) {
|
||||
#define CASE(X) \
|
||||
case Source::X: \
|
||||
return "Source::" #X;
|
||||
switch (value) {
|
||||
CASE(VIDEO_STREAMING)
|
||||
CASE(MOTION_TRACKING)
|
||||
CASE(ALL)
|
||||
default:
|
||||
return "Source::UNKNOWN";
|
||||
}
|
||||
#undef CASE
|
||||
}
|
||||
|
||||
const char *to_string(const Format &value) {
|
||||
#define CASE(X) \
|
||||
case Format::X: \
|
||||
|
|
|
@ -62,6 +62,12 @@ TEST(Option, VerifyToString) {
|
|||
EXPECT_STREQ("Option::ERASE_CHIP", to_string(Option::ERASE_CHIP));
|
||||
}
|
||||
|
||||
TEST(Source, VerifyToString) {
|
||||
EXPECT_STREQ("Source::VIDEO_STREAMING", to_string(Source::VIDEO_STREAMING));
|
||||
EXPECT_STREQ("Source::MOTION_TRACKING", to_string(Source::MOTION_TRACKING));
|
||||
EXPECT_STREQ("Source::ALL", to_string(Source::ALL));
|
||||
}
|
||||
|
||||
TEST(Format, VerifyToString) {
|
||||
EXPECT_STREQ("Format::YUYV", to_string(Format::YUYV));
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user