diff --git a/src/dds/rs-dds-sensor-proxy.cpp b/src/dds/rs-dds-sensor-proxy.cpp index 8cbf66557e1..bee716b731b 100644 --- a/src/dds/rs-dds-sensor-proxy.cpp +++ b/src/dds/rs-dds-sensor-proxy.cpp @@ -4,7 +4,7 @@ #include "rs-dds-sensor-proxy.h" #include "rs-dds-option.h" -#include +#include #include #include @@ -35,6 +35,12 @@ dds_sensor_proxy::dds_sensor_proxy( std::string const & sensor_name, , _name( sensor_name ) , _md_enabled( dev->supports_metadata() ) { + rsutils::json const & settings = owner->get_context()->get_settings(); + if( auto interval_j = settings.nested( std::string( "options-update-interval", 23 ) ) ) + { + auto interval = interval_j.get< uint32_t >(); // NOTE: can throw! + _options_watcher.set_update_interval( std::chrono::milliseconds( interval ) ); + } } @@ -156,6 +162,12 @@ void dds_sensor_proxy::register_basic_converters() } +rsutils::subscription dds_sensor_proxy::register_options_changed_callback( options_watcher::callback && cb ) +{ + return _options_watcher.subscribe( std::move( cb ) ); +} + + std::shared_ptr< realdds::dds_video_stream_profile > dds_sensor_proxy::find_profile( sid_index sidx, realdds::dds_video_stream_profile const & profile ) const { @@ -536,6 +548,7 @@ void dds_sensor_proxy::add_option( std::shared_ptr< realdds::dds_option > option [=]( const std::string & name, float value ) { _dev->set_option_value( option, value ); }, [=]( const std::string & name ) -> float { return _dev->query_option_value( option ); } ); register_option( option_id, opt ); + _options_watcher.register_option( option_id, opt ); } diff --git a/src/dds/rs-dds-sensor-proxy.h b/src/dds/rs-dds-sensor-proxy.h index 848d10cf973..6b15f8687c0 100644 --- a/src/dds/rs-dds-sensor-proxy.h +++ b/src/dds/rs-dds-sensor-proxy.h @@ -1,13 +1,12 @@ // License: Apache 2.0. See LICENSE file in root directory. // Copyright(c) 2023 Intel Corporation. All Rights Reserved. - #pragma once - #include "sid_index.h" #include #include #include +#include #include @@ -42,6 +41,7 @@ class dds_sensor_proxy : public software_sensor std::shared_ptr< realdds::dds_device > const _dev; std::string const _name; bool const _md_enabled; + options_watcher _options_watcher; typedef realdds::dds_metadata_syncer syncer_type; static void frame_releaser( syncer_type::frame_type * f ) { static_cast< frame * >( f )->release(); } @@ -80,6 +80,10 @@ class dds_sensor_proxy : public software_sensor const std::map< sid_index, std::shared_ptr< realdds::dds_stream > > & streams() const { return _streams; } + // sensor_interface +public: + rsutils::subscription register_options_changed_callback( options_watcher::callback && ) override; + protected: void register_basic_converters(); stream_profiles init_stream_profiles() override;