Add channels & control query

This commit is contained in:
John Zhao
2018-04-09 15:54:14 +08:00
parent 1f9a7ac318
commit 84bcf15e11
6 changed files with 151 additions and 52 deletions

44
src/internal/channels.cc Normal file
View File

@@ -0,0 +1,44 @@
#include "internal/channels.h"
#include <glog/logging.h>
#include "uvc/uvc.h"
MYNTEYE_BEGIN_NAMESPACE
Channels::Channels(std::shared_ptr<uvc::device> device) : device_(device) {
VLOG(2) << __func__;
}
Channels::~Channels() {
VLOG(2) << __func__;
}
bool Channels::ControlQuery(
const uvc::xu &xu, uint8_t selector, const query_t &query, uint16_t size,
uint8_t *data) {
CHECK_NOTNULL(device_);
uvc::xu_query code;
switch (query) {
case SET_CUR:
code = uvc::XU_SET_CUR;
break;
case GET_CUR:
code = uvc::XU_GET_CUR;
break;
case GET_MIN:
code = uvc::XU_GET_MIN;
break;
case GET_MAX:
code = uvc::XU_GET_MAX;
break;
case GET_DEF:
code = uvc::XU_GET_DEF;
break;
default:
LOG(FATAL) << "ControlQuery query code is unaccepted";
}
return uvc::xu_control_query(*device_, xu, selector, code, size, data);
}
MYNTEYE_END_NAMESPACE

42
src/internal/channels.h Normal file
View File

@@ -0,0 +1,42 @@
#ifndef MYNTEYE_INTERNAL_CHANNELS_H_ // NOLINT
#define MYNTEYE_INTERNAL_CHANNELS_H_
#pragma once
#include <memory>
#include "mynteye/mynteye.h"
MYNTEYE_BEGIN_NAMESPACE
namespace uvc {
struct device;
struct xu;
} // namespace uvc
class Channels {
public:
typedef enum Query {
SET_CUR,
GET_CUR,
GET_MIN,
GET_MAX,
GET_DEF,
LAST
} query_t;
explicit Channels(std::shared_ptr<uvc::device> device);
~Channels();
private:
bool ControlQuery(
const uvc::xu &xu, uint8_t selector, const query_t &query, uint16_t size,
uint8_t *data);
std::shared_ptr<uvc::device> device_;
};
MYNTEYE_END_NAMESPACE
#endif // MYNTEYE_INTERNAL_CHANNELS_H_ NOLINT