#pragma once
#include "libobsensor/h/ObTypes.h"
#include "IProperty.hpp"
#include "ISensor.hpp"
#include "IFilter.hpp"
#include "IPresetManager.hpp"
#include "IDeviceComponent.hpp"
namespace libobsensor {
struct DeviceInfo {
int pid_ = 0;
int vid_ = 0;
std::string uid_; std::string name_;
std::string fullName_;
std::string connectionType_; uint16_t type_ = 0; std::string fwVersion_;
std::string hwVersion_;
std::string supportedSdkVersion_;
std::string asicName_;
std::string deviceSn_;
OBUvcBackendType backendType_ = OB_UVC_BACKEND_TYPE_AUTO;
};
struct NetDeviceInfo : public DeviceInfo {
std::string ipAddress_;
std::string localMac_;
std::string subnetMask_;
std::string gateway_;
};
typedef std::function<void(OBFwUpdateState state, const char *message, uint8_t percent)> DeviceFwUpdateCallback;
class IDevice : public std::enable_shared_from_this<IDevice> {
public:
virtual ~IDevice() = default;
virtual void reset() = 0;
virtual void reboot() = 0;
virtual void deactivate() = 0;
virtual std::shared_ptr<const DeviceInfo> getInfo() const = 0;
virtual bool isDeactivated() const = 0;
virtual const std::string &getExtensionInfo(const std::string &infoKey) const = 0;
virtual bool isExtensionInfoExists(const std::string &infoKey) const = 0;
virtual uint64_t getDeviceErrorState() const = 0;
virtual void fetchDeviceErrorState() = 0;
virtual bool isComponentExists(DeviceComponentId compId) const = 0;
virtual bool isComponentCreated(DeviceComponentId compId) const = 0; virtual DeviceComponentPtr<IDeviceComponent> getComponent(DeviceComponentId compId, bool throwExIfNotFound = true) = 0;
virtual DeviceComponentPtr<IPropertyServer> getPropertyServer() = 0;
virtual bool isSensorExists(OBSensorType type) const = 0;
virtual bool isSensorCreated(OBSensorType type) const = 0; virtual DeviceComponentPtr<ISensor> getSensor(OBSensorType type) = 0;
virtual std::vector<OBSensorType> getSensorTypeList() const = 0;
virtual bool hasAnySensorStreamActivated() = 0;
virtual std::vector<std::shared_ptr<IFilter>> createRecommendedPostProcessingFilters(OBSensorType type) = 0;
virtual std::shared_ptr<IFilter> getSensorFrameFilter(const std::string &name, OBSensorType type, bool throwIfNotFound = true) = 0;
virtual void updateFirmware(const std::vector<uint8_t> &firmware, DeviceFwUpdateCallback updateCallback, bool async) = 0;
virtual void setFirmwareUpdateState(bool isUpdating) = 0;
virtual bool isFirmwareUpdating() const = 0;
virtual void updateOptionalDepthPresets(const char filePathList[][OB_PATH_MAX], uint8_t pathCount, DeviceFwUpdateCallback updateCallback) = 0;
virtual void activateDeviceAccessor() = 0;
virtual int getFirmwareVersionInt() = 0;
public:
template <typename T> DeviceComponentPtr<T> getComponentT(DeviceComponentId compId, bool throwExIfNotFound = true) {
auto comp = getComponent(compId, throwExIfNotFound);
if(comp) {
return comp.as<T>();
}
return DeviceComponentPtr<T>(nullptr);
}
protected:
virtual void init() = 0;
};
}
#ifdef __cplusplus
extern "C" {
#endif
struct ob_device_t {
std::shared_ptr<libobsensor::IDevice> device;
};
struct ob_device_info_t {
std::shared_ptr<const libobsensor::DeviceInfo> info;
};
struct ob_camera_param_list_t {
std::vector<OBCameraParam> paramList;
};
#ifdef __cplusplus
}
#endif