From 056af3430fc51712c63ac8c5d9fe5f9dcb2ec4c4 Mon Sep 17 00:00:00 2001 From: zeyus Date: Mon, 11 Aug 2025 12:58:26 +0200 Subject: [PATCH 1/2] Added uid reset to C API --- include/lsl/streaminfo.h | 8 ++++++++ src/lsl_streaminfo_c.cpp | 4 ++++ 2 files changed, 12 insertions(+) diff --git a/include/lsl/streaminfo.h b/include/lsl/streaminfo.h index 109fe1aca..b64284775 100644 --- a/include/lsl/streaminfo.h +++ b/include/lsl/streaminfo.h @@ -125,6 +125,14 @@ extern LIBLSL_C_API double lsl_get_created_at(lsl_streaminfo info); */ extern LIBLSL_C_API const char *lsl_get_uid(lsl_streaminfo info); +/** + * Reset the UID of the stream info to a new random value. + * + * This can be used to generate a UID if one doesn't exist. + * @return An immutable library-owned pointer to the new string value. @sa lsl_destroy_string() + */ +extern LIBLSL_C_API const char *lsl_reset_uid(lsl_streaminfo info); + /** * Session ID for the given stream. * diff --git a/src/lsl_streaminfo_c.cpp b/src/lsl_streaminfo_c.cpp index 968501bc2..2493c7114 100644 --- a/src/lsl_streaminfo_c.cpp +++ b/src/lsl_streaminfo_c.cpp @@ -49,6 +49,10 @@ LIBLSL_C_API const char *lsl_get_source_id(lsl_streaminfo info) { LIBLSL_C_API int32_t lsl_get_version(lsl_streaminfo info) { return info->version(); } LIBLSL_C_API double lsl_get_created_at(lsl_streaminfo info) { return info->created_at(); } LIBLSL_C_API const char *lsl_get_uid(lsl_streaminfo info) { return info->uid().c_str(); } +LIBLSL_C_API const char *lsl_reset_uid(lsl_streaminfo info) { + return info->reset_uid().c_str(); + +} LIBLSL_C_API const char *lsl_get_session_id(lsl_streaminfo info) { return info->session_id().c_str(); } From f7c83e991b944fb08396c527c484fad201163817 Mon Sep 17 00:00:00 2001 From: Chadwick Boulay Date: Tue, 16 Jun 2026 22:45:05 -0400 Subject: [PATCH 2/2] streaminfo: tidy lsl_reset_uid and add C++ reset_uid() wrapper Collapse the C wrapper to the one-line style of its siblings and expose a matching stream_info::reset_uid() in the C++ header for API parity. Co-Authored-By: Claude Opus 4.8 (1M context) --- include/lsl_cpp.h | 9 +++++++++ src/lsl_streaminfo_c.cpp | 5 +---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/include/lsl_cpp.h b/include/lsl_cpp.h index 8ec6849c9..4b2fde345 100644 --- a/include/lsl_cpp.h +++ b/include/lsl_cpp.h @@ -288,6 +288,15 @@ class stream_info { */ std::string uid() const { return lsl_get_uid(obj.get()); } + /** + * Reset the unique ID of the stream to a new random value. + * + * This can be used to assign a UID to a stream_info that does not yet have one (e.g., one + * constructed locally and not obtained from an inlet). + * @return The new UID. + */ + std::string reset_uid() { return lsl_reset_uid(obj.get()); } + /** * Session ID for the given stream. * diff --git a/src/lsl_streaminfo_c.cpp b/src/lsl_streaminfo_c.cpp index 2493c7114..8c836c8fd 100644 --- a/src/lsl_streaminfo_c.cpp +++ b/src/lsl_streaminfo_c.cpp @@ -49,10 +49,7 @@ LIBLSL_C_API const char *lsl_get_source_id(lsl_streaminfo info) { LIBLSL_C_API int32_t lsl_get_version(lsl_streaminfo info) { return info->version(); } LIBLSL_C_API double lsl_get_created_at(lsl_streaminfo info) { return info->created_at(); } LIBLSL_C_API const char *lsl_get_uid(lsl_streaminfo info) { return info->uid().c_str(); } -LIBLSL_C_API const char *lsl_reset_uid(lsl_streaminfo info) { - return info->reset_uid().c_str(); - -} +LIBLSL_C_API const char *lsl_reset_uid(lsl_streaminfo info) { return info->reset_uid().c_str(); } LIBLSL_C_API const char *lsl_get_session_id(lsl_streaminfo info) { return info->session_id().c_str(); }