#pragma once
#include "libobsensor/h/ObTypes.h"
#include "IStreamProfile.hpp"
#include "IFrame.hpp"
#include "ISourcePort.hpp"
#include "IDeviceComponent.hpp"
#include <memory>
namespace libobsensor {
class IDevice;
typedef enum {
STREAM_STATE_STARTING, STREAM_STATE_STREAMING, STREAM_STATE_STOPPING, STREAM_STATE_STOPPED, STREAM_STATE_ERROR, STREAM_STATE_START_FAILED, } OBStreamState;
#define STREAM_STATE_STR(state) \
(state == STREAM_STATE_STARTING ? "STARTING" \
: state == STREAM_STATE_STREAMING ? "STREAMING" \
: state == STREAM_STATE_STOPPING ? "STOPPING" \
: state == STREAM_STATE_STOPPED ? "STOPPED" \
: state == STREAM_STATE_ERROR ? "STREAM_STATE_ERROR" \
: state == STREAM_STATE_START_FAILED ? "START_FAILED" \
: "UNKNOWN")
typedef std::function<void(OBStreamState, const std::shared_ptr<const StreamProfile> &)> StreamStateChangedCallback;
class ISensor : virtual public IDeviceComponent {
public:
virtual ~ISensor() noexcept override = default;
virtual OBSensorType getSensorType() const = 0;
virtual void start(std::shared_ptr<const StreamProfile> sp, FrameCallback callback) = 0;
virtual void stop() = 0;
virtual void setStreamProfileList(const StreamProfileList &profileList) = 0;
virtual StreamProfileList getStreamProfileList() const = 0;
virtual void setStreamProfileFilter(std::shared_ptr<IStreamProfileFilter> filter) = 0;
virtual void updateDefaultStreamProfile(const std::shared_ptr<const StreamProfile> &sp) = 0;
virtual std::shared_ptr<const StreamProfile> getActivatedStreamProfile() const = 0;
virtual FrameCallback getFrameCallback() const = 0;
virtual OBStreamState getStreamState() const = 0;
virtual bool isStreamActivated() const = 0;
virtual uint32_t registerStreamStateChangedCallback(StreamStateChangedCallback callback) = 0;
virtual void unregisterStreamStateChangedCallback(uint32_t token) = 0;
virtual void setFrameRecordingCallback(FrameCallback callback) = 0;
};
struct LazySensor {
explicit LazySensor(IDevice *device, OBSensorType type) : device(device), sensorType(type) {}
IDevice *device; OBSensorType sensorType;
};
}
#ifdef __cplusplus
extern "C" {
#endif
struct ob_sensor_t {
std::shared_ptr<libobsensor::IDevice> device; OBSensorType type;
};
struct ob_sensor_list_t {
std::shared_ptr<libobsensor::IDevice> device;
std::vector<OBSensorType> sensorTypes;
};
#ifdef __cplusplus
}
#endif