update sdk version to v2.0.20

This commit is contained in:
jj
2024-11-08 10:46:03 +08:00
parent cc8dcd8a82
commit 8fef735d43
18 changed files with 321 additions and 54 deletions
@@ -44,7 +44,7 @@ public:
private:
ob_context *impl_ = nullptr;
DeviceChangedCallback deviceChangedCallback_;
static LogCallback logCallback_;
// static LogCallback logCallback_;
public:
/**
@@ -145,7 +145,22 @@ public:
}
/**
* @brief Set the level of the global log, which affects both the log level output to the console, output to the file and output the user defined callback.
* @brief For linux, there are two ways to enable the UVC backend: libuvc and libusb. This function is used to set the backend type.
* @brief It is effective when the new device is created.
*
* @attention This interface is only available for Linux.
*
* @param[in] backend_type The backend type to be used.
*/
void setUvcBackendType(OBUvcBackendType type) const {
ob_error *error = nullptr;
ob_set_uvc_backend_type(impl_, type, &error);
Error::handle(&error);
}
/**
* @brief Set the level of the global log, which affects both the log level output to the console, output to the file and output the user defined
* callback.
*
* @param severity The log output level.
*/
@@ -187,8 +202,8 @@ public:
*/
static void setLoggerToCallback(OBLogSeverity severity, LogCallback callback) {
ob_error *error = nullptr;
Context::logCallback_ = callback;
ob_set_logger_to_callback(severity, &Context::logCallback, &Context::logCallback_, &error);
Context::getLogCallback() = callback;
ob_set_logger_to_callback(severity, &Context::logCallback, &Context::getLogCallback(), &error);
Error::handle(&error);
}
@@ -223,6 +238,12 @@ private:
}
}
// Lazy initialization of the logcallback_. The purpose is to initialize logcallback_ in .hpp
static LogCallback& getLogCallback() {
static LogCallback logCallback_ = nullptr;
return logCallback_;
}
// for backward compatibility
#define enableMultiDeviceSync enableDeviceClockSync
};
@@ -29,6 +29,7 @@ class SensorList;
class DevicePresetList;
class OBDepthWorkModeList;
class CameraParamList;
class DeviceFrameInterleaveList;
class Device {
public:
@@ -748,6 +749,53 @@ public:
Error::handle(&error);
}
/**
* @brief Check if the device supports the frame interleave feature.
*
* @return bool Returns true if the device supports the frame interleave feature.
*/
bool isFrameInterleaveSupported() const {
ob_error *error = nullptr;
bool ret = ob_device_is_frame_interleave_supported(impl_, &error);
Error::handle(&error);
return ret;
}
/**
* @brief Get current frame interleave name
* @return const char* return the current frame interleave name, it should be one of the frame interleave names returned by @ref
* getAvailableFrameInterleaveList.
*/
const char *getCurrentFrameInterleaveName() const {
ob_error *error = nullptr;
const char *name = ob_device_get_current_frame_interleave_name(impl_, &error);
Error::handle(&error);
return name;
}
/**
* @brief load the frame interleave according to frame interleave name.
* @param frameInterleaveName The frame interleave name to set. The name should be one of the frame interleave names returned by @ref
* getAvailableFrameInterleaveList.
*/
void loadFrameInterleave(const char *frameInterleaveName) const {
ob_error *error = nullptr;
ob_device_load_frame_interleave(impl_, frameInterleaveName, &error);
Error::handle(&error);
}
/**
* @brief Get available frame interleave list
*
* @return DeviceFrameInterleaveList return the available frame interleave list.
*/
std::shared_ptr<DeviceFrameInterleaveList> getAvailableFrameInterleaveList() const {
ob_error *error = nullptr;
auto list = ob_device_get_available_frame_interleave_list(impl_, &error);
Error::handle(&error);
return std::make_shared<DeviceFrameInterleaveList>(list);
}
private:
static void firmwareUpdateCallback(ob_fw_update_state state, const char *message, uint8_t percent, void *userData) {
auto device = static_cast<Device *>(userData);
@@ -1360,5 +1408,57 @@ public:
}
};
} // namespace ob
/**
* @brief Class representing a list of device Frame Interleave
*/
class DeviceFrameInterleaveList {
private:
ob_device_frame_interleave_list_t *impl_ = nullptr;
public:
explicit DeviceFrameInterleaveList(ob_device_frame_interleave_list_t *impl) : impl_(impl) {}
~DeviceFrameInterleaveList() noexcept {
ob_error *error = nullptr;
ob_delete_frame_interleave_list(impl_, &error);
Error::handle(&error, false);
}
/**
* @brief Get the number of device frame interleave in the list
*
* @return uint32_t the number of device frame interleave in the list
*/
uint32_t getCount() {
ob_error *error = nullptr;
auto count = ob_device_frame_interleave_list_get_count(impl_, &error);
Error::handle(&error);
return count;
}
/**
* @brief Get the name of the device frame interleave at the specified index
*
* @param index the index of the device frame interleave
* @return const char* the name of the device frame interleave
*/
const char *getName(uint32_t index) {
ob_error *error = nullptr;
const char *name = ob_device_frame_interleave_list_get_name(impl_, index, &error);
Error::handle(&error);
return name;
}
/**
* @brief check if the frame interleave list contains the special name frame interleave.
* @param name The name of the frame interleave
* @return bool Returns true if the special name is found in the frame interleave list, otherwise returns false.
*/
bool hasFrameInterleave(const char *name) {
ob_error *error = nullptr;
auto result = ob_device_frame_interleave_list_has_frame_interleave(impl_, name, &error);
Error::handle(&error);
return result;
}
};
} // namespace ob
@@ -426,6 +426,20 @@ public:
OBStreamType getAlignToStreamType() {
return static_cast<OBStreamType>(static_cast<int>(getConfigValue("AlignType")));
}
/**
* @brief Sets whether the output frame resolution should match the target resolution.
* When enabled, the output frame resolution will be adjusted to match (same as) the target resolution.
* When disabled, the output frame resolution will match the original resolution while maintaining
* the aspect ratio of the target resolution.
*
*
* @param state If true, output frame resolution will match the target resolution; otherwise, it will
* maintain the original resolution with the target's aspect ratio.
*/
void setMatchTargetResolution(bool state) {
setConfigValue("MatchTargetRes", state);
}
};
/**
@@ -942,7 +956,7 @@ public:
class OBFilterList {
private:
ob_filter_list_t* impl_;
ob_filter_list_t *impl_;
public:
explicit OBFilterList(ob_filter_list_t *impl) : impl_(impl) {}
@@ -1010,4 +1024,3 @@ template <typename T> bool Filter::is() {
}
} // namespace ob
@@ -2,4 +2,4 @@
// Licensed under the MIT License.
#pragma once
// empty file, leave here for backwards compatibility
#include <libobsensor/h/ObTypes.h>