Update OrbbecSDK version to 2.6.2

This commit is contained in:
ob-yalian
2025-12-15 14:11:02 +08:00
parent 72f3ce9378
commit bc408a244c
20 changed files with 134 additions and 41 deletions
@@ -111,6 +111,8 @@ OB_EXPORT ob_device *ob_create_net_device_ex(ob_context *context, const char *ad
/** /**
* @brief Set a device plug-in callback function * @brief Set a device plug-in callback function
* *
* @deprecated This function is deprecated. Please use ob_register_device_changed_callback() instead.
*
* @attention The added and removed device lists returned through the callback interface need to be released manually * @attention The added and removed device lists returned through the callback interface need to be released manually
* @attention This function supports multiple callbacks. Each call to this function adds a new callback to an internal list. * @attention This function supports multiple callbacks. Each call to this function adds a new callback to an internal list.
* *
@@ -121,6 +123,36 @@ OB_EXPORT ob_device *ob_create_net_device_ex(ob_context *context, const char *ad
*/ */
OB_EXPORT void ob_set_device_changed_callback(ob_context *context, ob_device_changed_callback callback, void *user_data, ob_error **error); OB_EXPORT void ob_set_device_changed_callback(ob_context *context, ob_device_changed_callback callback, void *user_data, ob_error **error);
/**
* @brief Register a device plug-in callback function.
*
* This function registers a callback that will be triggered whenever a device is plugged in or unplugged.
*
* @attention The added and removed device lists returned through the callback interface need to be released manually.
* @attention This function supports multiple callbacks. Each call to this function adds a new callback to an internal list.
*
* @param[in] context Pointer to the context object.
* @param[in] callback Pointer to the callback function triggered when a device is plugged or unplugged.
* @param[in] user_data Pointer to user data that can be passed to and retrieved from the callback function.
* @param[out] error Pointer to an error object that will be populated if an error occurs during callback function setting.
*
* @return A ob_callback_id that uniquely identifies the registered callback.
* This ID can be used later to unregister the callback with ob_unregister_device_changed_callback().
* Returns INVALID_DEVICE_CHANGED_CALLBACK_ID if the registration fails.
*/
OB_EXPORT ob_callback_id ob_register_device_changed_callback(ob_context *context, ob_device_changed_callback callback, void *user_data, ob_error **error);
/**
* @brief Unregister a previously registered device plug-in callback function.
*
* This function removes a callback that was registered by ob_register_device_changed_callback().
*
* @param[in] context Pointer to the context object.
* @param[in] callback_id The callback ID returned by ob_register_device_changed_callback().
* @param[out] error Pointer to an error object that will be populated if an error occurs during callback function setting.
*/
OB_EXPORT void ob_unregister_device_changed_callback(ob_context *context, ob_callback_id callback_id, ob_error **error);
/** /**
* @brief Activates device clock synchronization to synchronize the clock of the host and all created devices (if supported). * @brief Activates device clock synchronization to synchronize the clock of the host and all created devices (if supported).
* *
@@ -260,26 +260,27 @@ typedef enum {
* @brief Enumeration value describing the firmware upgrade status * @brief Enumeration value describing the firmware upgrade status
*/ */
typedef enum { typedef enum {
STAT_DONE_WITH_DUPLICATES = 6, /**< update completed, but some files were duplicated and ignored */ STAT_DONE_REBOOT_AND_REUPDATE = 7, /**< update completed and device requires manual reboot and a second update*/
STAT_VERIFY_SUCCESS = 5, /**< Image file verifify success */ STAT_DONE_WITH_DUPLICATES = 6, /**< update completed, but some files were duplicated and ignored */
STAT_FILE_TRANSFER = 4, /**< file transfer */ STAT_VERIFY_SUCCESS = 5, /**< Image file verifify success */
STAT_DONE = 3, /**< update completed */ STAT_FILE_TRANSFER = 4, /**< file transfer */
STAT_IN_PROGRESS = 2, /**< upgrade in process */ STAT_DONE = 3, /**< update completed */
STAT_START = 1, /**< start the upgrade */ STAT_IN_PROGRESS = 2, /**< upgrade in process */
STAT_VERIFY_IMAGE = 0, /**< Image file verification */ STAT_START = 1, /**< start the upgrade */
ERR_VERIFY = -1, /**< Verification failed */ STAT_VERIFY_IMAGE = 0, /**< Image file verification */
ERR_PROGRAM = -2, /**< Program execution failed */ ERR_VERIFY = -1, /**< Verification failed */
ERR_ERASE = -3, /**< Flash parameter failed */ ERR_PROGRAM = -2, /**< Program execution failed */
ERR_FLASH_TYPE = -4, /**< Flash type error */ ERR_ERASE = -3, /**< Flash parameter failed */
ERR_IMAGE_SIZE = -5, /**< Image file size error */ ERR_FLASH_TYPE = -4, /**< Flash type error */
ERR_OTHER = -6, /**< other errors */ ERR_IMAGE_SIZE = -5, /**< Image file size error */
ERR_DDR = -7, /**< DDR access error */ ERR_OTHER = -6, /**< other errors */
ERR_TIMEOUT = -8, /**< timeout error */ ERR_DDR = -7, /**< DDR access error */
ERR_MISMATCH = -9, /**< Mismatch firmware error */ ERR_TIMEOUT = -8, /**< timeout error */
ERR_UNSUPPORT_DEV = -10, /**< Unsupported device error */ ERR_MISMATCH = -9, /**< Mismatch firmware error */
ERR_INVALID_COUNT = -11, /**< invalid firmware/preset count */ ERR_UNSUPPORT_DEV = -10, /**< Unsupported device error */
ERR_FILE_READ = -12, /**< Read image file error */ ERR_INVALID_COUNT = -11, /**< invalid firmware/preset count */
ERR_TRANSFER = -13 /**< Transfer failed */ ERR_FILE_READ = -12, /**< Read image file error */
ERR_TRANSFER = -13 /**< Transfer failed */
} OBUpgradeState, } OBUpgradeState,
OBFwUpdateState, ob_upgrade_state, ob_fw_update_state; OBFwUpdateState, ob_upgrade_state, ob_fw_update_state;
@@ -1925,6 +1926,13 @@ typedef void(ob_frame_destroy_callback)(uint8_t *buffer, void *user_data);
typedef void(ob_log_callback)(ob_log_severity severity, const char *message, void *user_data); typedef void(ob_log_callback)(ob_log_severity severity, const char *message, void *user_data);
typedef void (*ob_playback_status_changed_callback)(ob_playback_status status, void *user_data); typedef void (*ob_playback_status_changed_callback)(ob_playback_status status, void *user_data);
/**
* @brief Callback Id
*/
typedef uint64_t OBCallbackId, ob_callback_id;
#define INVALID_CALLBACK_ID (0)
/** /**
* @brief Check if the sensor_type is a video sensor * @brief Check if the sensor_type is a video sensor
* *
@@ -16,6 +16,8 @@
#include <functional> #include <functional>
#include <memory> #include <memory>
#include <string> #include <string>
#include <unordered_map>
#include <mutex>
namespace ob { namespace ob {
@@ -42,9 +44,20 @@ public:
*/ */
typedef std::function<void(OBLogSeverity severity, const char *logMsg)> LogCallback; typedef std::function<void(OBLogSeverity severity, const char *logMsg)> LogCallback;
struct DeviceChangedCallbackContext {
Context *ctx;
uint64_t callbackId;
DeviceChangedCallback callback;
};
private: private:
ob_context *impl_ = nullptr; ob_context *impl_ = nullptr;
DeviceChangedCallback deviceChangedCallback_; std::mutex callbackMtx_;
std::mutex legacyCallbackMtx_;
OBCallbackId legacyCallbackId_ = INVALID_CALLBACK_ID;
std::unordered_map<OBCallbackId, std::unique_ptr<DeviceChangedCallbackContext>> devChangedCallbacks_;
// static LogCallback logCallback_; // static LogCallback logCallback_;
public: public:
@@ -66,6 +79,7 @@ public:
* @brief Context destructor. * @brief Context destructor.
*/ */
~Context() noexcept { ~Context() noexcept {
// delete contex of C API, which will auto unregister all callbacks
ob_error *error = nullptr; ob_error *error = nullptr;
ob_delete_context(impl_, &error); ob_delete_context(impl_, &error);
Error::handle(&error, false); Error::handle(&error, false);
@@ -136,14 +150,45 @@ public:
/** /**
* @brief Set the device plug-in callback function. * @brief Set the device plug-in callback function.
*
* @deprecated This function is deprecated. Please use registerDeviceChangedCallback() instead.
*
* @attention This function supports multiple callbacks. Each call to this function adds a new callback to an internal list. * @attention This function supports multiple callbacks. Each call to this function adds a new callback to an internal list.
* *
* @param[in] callback The function triggered when the device is plugged and unplugged. * @param[in] callback The function triggered when the device is plugged and unplugged.
*/ */
void setDeviceChangedCallback(DeviceChangedCallback callback) { void setDeviceChangedCallback(DeviceChangedCallback callback) {
deviceChangedCallback_ = callback; std::lock_guard<std::mutex> lock(legacyCallbackMtx_);
ob_error *error = nullptr; // remove the last callback first
ob_set_device_changed_callback(impl_, &Context::deviceChangedCallback, this, &error); unregisterDeviceChangedCallback(legacyCallbackId_);
// register the new callback
legacyCallbackId_ = registerDeviceChangedCallback(callback);
}
OBCallbackId registerDeviceChangedCallback(DeviceChangedCallback callback) {
ob_error *error = nullptr;
auto cbCtxHolder = std::unique_ptr<DeviceChangedCallbackContext>(new DeviceChangedCallbackContext({ this, 0, nullptr }));
auto id = ob_register_device_changed_callback(impl_, &Context::deviceChangedCallback, (void *)cbCtxHolder.get(), &error);
Error::handle(&error);
cbCtxHolder->callbackId = id;
cbCtxHolder->callback = callback;
{
std::unique_lock<std::mutex> lock(callbackMtx_);
devChangedCallbacks_[id] = std::move(cbCtxHolder);
}
return id;
}
void unregisterDeviceChangedCallback(OBCallbackId id) {
ob_error *error = nullptr;
ob_unregister_device_changed_callback(impl_, id, &error);
{
std::unique_lock<std::mutex> lock(callbackMtx_);
if(devChangedCallbacks_.count(id)) {
devChangedCallbacks_.erase(id);
}
}
Error::handle(&error); Error::handle(&error);
} }
@@ -277,11 +322,19 @@ public:
private: private:
static void deviceChangedCallback(ob_device_list *removedList, ob_device_list *addedList, void *userData) { static void deviceChangedCallback(ob_device_list *removedList, ob_device_list *addedList, void *userData) {
auto ctx = static_cast<Context *>(userData); auto cbCtx = static_cast<DeviceChangedCallbackContext *>(userData);
if(ctx && ctx->deviceChangedCallback_) { if(cbCtx && cbCtx->ctx && cbCtx->callbackId != INVALID_CALLBACK_ID) {
DeviceChangedCallback callbackCopy;
{
// preventing the captured variables from being released.
std::unique_lock<std::mutex> lock(cbCtx->ctx->callbackMtx_);
if(cbCtx->ctx->devChangedCallbacks_.count(cbCtx->callbackId)) {
callbackCopy = cbCtx->callback;
}
}
auto removed = std::make_shared<DeviceList>(removedList); auto removed = std::make_shared<DeviceList>(removedList);
auto added = std::make_shared<DeviceList>(addedList); auto added = std::make_shared<DeviceList>(addedList);
ctx->deviceChangedCallback_(removed, added); callbackCopy(removed, added);
} }
} }
@@ -8,12 +8,12 @@ set(CMAKE_IMPORT_FILE_VERSION 1)
# Import target "ob::OrbbecSDK" for configuration "Release" # Import target "ob::OrbbecSDK" for configuration "Release"
set_property(TARGET ob::OrbbecSDK APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE) set_property(TARGET ob::OrbbecSDK APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE)
set_target_properties(ob::OrbbecSDK PROPERTIES set_target_properties(ob::OrbbecSDK PROPERTIES
IMPORTED_LOCATION_RELEASE "${_IMPORT_PREFIX}/lib/libOrbbecSDK.so.2.6.1" IMPORTED_LOCATION_RELEASE "${_IMPORT_PREFIX}/lib/libOrbbecSDK.so.2.6.2"
IMPORTED_SONAME_RELEASE "libOrbbecSDK.so.2" IMPORTED_SONAME_RELEASE "libOrbbecSDK.so.2"
) )
list(APPEND _cmake_import_check_targets ob::OrbbecSDK ) list(APPEND _cmake_import_check_targets ob::OrbbecSDK )
list(APPEND _cmake_import_check_files_for_ob::OrbbecSDK "${_IMPORT_PREFIX}/lib/libOrbbecSDK.so.2.6.1" ) list(APPEND _cmake_import_check_files_for_ob::OrbbecSDK "${_IMPORT_PREFIX}/lib/libOrbbecSDK.so.2.6.2" )
# Commands beyond this point should not need to know the version. # Commands beyond this point should not need to know the version.
set(CMAKE_IMPORT_FILE_VERSION) set(CMAKE_IMPORT_FILE_VERSION)
@@ -9,19 +9,19 @@
# The variable CVF_VERSION must be set before calling configure_file(). # The variable CVF_VERSION must be set before calling configure_file().
set(PACKAGE_VERSION "2.6.1") set(PACKAGE_VERSION "2.6.2")
if(PACKAGE_VERSION VERSION_LESS PACKAGE_FIND_VERSION) if(PACKAGE_VERSION VERSION_LESS PACKAGE_FIND_VERSION)
set(PACKAGE_VERSION_COMPATIBLE FALSE) set(PACKAGE_VERSION_COMPATIBLE FALSE)
else() else()
if("2.6.1" MATCHES "^([0-9]+)\\.") if("2.6.2" MATCHES "^([0-9]+)\\.")
set(CVF_VERSION_MAJOR "${CMAKE_MATCH_1}") set(CVF_VERSION_MAJOR "${CMAKE_MATCH_1}")
if(NOT CVF_VERSION_MAJOR VERSION_EQUAL 0) if(NOT CVF_VERSION_MAJOR VERSION_EQUAL 0)
string(REGEX REPLACE "^0+" "" CVF_VERSION_MAJOR "${CVF_VERSION_MAJOR}") string(REGEX REPLACE "^0+" "" CVF_VERSION_MAJOR "${CVF_VERSION_MAJOR}")
endif() endif()
else() else()
set(CVF_VERSION_MAJOR "2.6.1") set(CVF_VERSION_MAJOR "2.6.2")
endif() endif()
if(PACKAGE_FIND_VERSION_RANGE) if(PACKAGE_FIND_VERSION_RANGE)
@@ -1 +1 @@
libOrbbecSDK.so.2.6.1 libOrbbecSDK.so.2.6.2
@@ -8,12 +8,12 @@ set(CMAKE_IMPORT_FILE_VERSION 1)
# Import target "ob::OrbbecSDK" for configuration "Release" # Import target "ob::OrbbecSDK" for configuration "Release"
set_property(TARGET ob::OrbbecSDK APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE) set_property(TARGET ob::OrbbecSDK APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE)
set_target_properties(ob::OrbbecSDK PROPERTIES set_target_properties(ob::OrbbecSDK PROPERTIES
IMPORTED_LOCATION_RELEASE "${_IMPORT_PREFIX}/lib/libOrbbecSDK.so.2.6.1" IMPORTED_LOCATION_RELEASE "${_IMPORT_PREFIX}/lib/libOrbbecSDK.so.2.6.2"
IMPORTED_SONAME_RELEASE "libOrbbecSDK.so.2" IMPORTED_SONAME_RELEASE "libOrbbecSDK.so.2"
) )
list(APPEND _cmake_import_check_targets ob::OrbbecSDK ) list(APPEND _cmake_import_check_targets ob::OrbbecSDK )
list(APPEND _cmake_import_check_files_for_ob::OrbbecSDK "${_IMPORT_PREFIX}/lib/libOrbbecSDK.so.2.6.1" ) list(APPEND _cmake_import_check_files_for_ob::OrbbecSDK "${_IMPORT_PREFIX}/lib/libOrbbecSDK.so.2.6.2" )
# Commands beyond this point should not need to know the version. # Commands beyond this point should not need to know the version.
set(CMAKE_IMPORT_FILE_VERSION) set(CMAKE_IMPORT_FILE_VERSION)
@@ -9,19 +9,19 @@
# The variable CVF_VERSION must be set before calling configure_file(). # The variable CVF_VERSION must be set before calling configure_file().
set(PACKAGE_VERSION "2.6.1") set(PACKAGE_VERSION "2.6.2")
if(PACKAGE_VERSION VERSION_LESS PACKAGE_FIND_VERSION) if(PACKAGE_VERSION VERSION_LESS PACKAGE_FIND_VERSION)
set(PACKAGE_VERSION_COMPATIBLE FALSE) set(PACKAGE_VERSION_COMPATIBLE FALSE)
else() else()
if("2.6.1" MATCHES "^([0-9]+)\\.") if("2.6.2" MATCHES "^([0-9]+)\\.")
set(CVF_VERSION_MAJOR "${CMAKE_MATCH_1}") set(CVF_VERSION_MAJOR "${CMAKE_MATCH_1}")
if(NOT CVF_VERSION_MAJOR VERSION_EQUAL 0) if(NOT CVF_VERSION_MAJOR VERSION_EQUAL 0)
string(REGEX REPLACE "^0+" "" CVF_VERSION_MAJOR "${CVF_VERSION_MAJOR}") string(REGEX REPLACE "^0+" "" CVF_VERSION_MAJOR "${CVF_VERSION_MAJOR}")
endif() endif()
else() else()
set(CVF_VERSION_MAJOR "2.6.1") set(CVF_VERSION_MAJOR "2.6.2")
endif() endif()
if(PACKAGE_FIND_VERSION_RANGE) if(PACKAGE_FIND_VERSION_RANGE)
+1 -1
View File
@@ -1 +1 @@
libOrbbecSDK.so.2.6.1 libOrbbecSDK.so.2.6.2
@@ -12,7 +12,7 @@
<!-- Console log output level --> <!-- Console log output level -->
<ConsoleLogLevel>3</ConsoleLogLevel> <ConsoleLogLevel>3</ConsoleLogLevel>
<!-- Default log output file path, string type. If this item is not configured, the default <!-- Default log output file path, string type. If this item is not configured, the default
path will be used: Win/Linux: "./Log"; Android: "/sdcard/3DCamera/Log" --> path will be used: Win/Linux: "./Log"; Android: "/sdcard/orbbec/Log" -->
<!-- <OutputDir>./log</OutputDir> --> <!-- <OutputDir>./log</OutputDir> -->
<!-- Default log output file size, int type, unit: MB --> <!-- Default log output file size, int type, unit: MB -->
<MaxFileSize>100</MaxFileSize> <MaxFileSize>100</MaxFileSize>