Add start/stop source
This commit is contained in:
@@ -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: \
|
||||
|
||||
Reference in New Issue
Block a user