Skip to content

Commit

Permalink
Handle PR#11566 comments
Browse files Browse the repository at this point in the history
  • Loading branch information
OhadMeir committed Mar 20, 2023
1 parent 63b2f10 commit adc94d7
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 17 deletions.
49 changes: 41 additions & 8 deletions src/context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -998,7 +998,7 @@ namespace librealsense
create_processing_block( filter_name );
}

bool processing_block_exists( processing_blocks const & blocks, std::string const & block_name )
bool processing_block_exists( processing_blocks const & blocks, std::string const & block_name ) const
{
for( auto & block : blocks )
if( block_name.compare( block->get_info( RS2_CAMERA_INFO_NAME ) ) == 0 )
Expand All @@ -1014,7 +1014,8 @@ namespace librealsense
if( filter_name.compare( "Depth Huffman Decoder" ) == 0 )
current_filters.add_processing_block( std::make_shared< depth_decompression_huffman >() );
else if( filter_name.compare( "Decimation Filter" ) == 0 )
//TODO - set options? might be needed according to stream type
// sensor.cpp sets format option based on sensor type, but the filter does not use it and selects the
// appropriate decimation algorithm based on processed frame profile format.
current_filters.add_processing_block( std::make_shared< decimation_filter >() );
else if( filter_name.compare( "HDR Merge" ) == 0 )
current_filters.add_processing_block( std::make_shared< hdr_merge >() );
Expand Down Expand Up @@ -1053,13 +1054,38 @@ namespace librealsense
{
public:
dds_color_sensor_proxy( std::string const & sensor_name,
software_device * owner,
std::shared_ptr< realdds::dds_device > const & dev )
software_device * owner,
std::shared_ptr< realdds::dds_device > const & dev )
: dds_sensor_proxy( sensor_name, owner, dev )
{
}
};

// For cases when checking if this is< depth_sensor > (like realsense-viewer::subdevice_model)
class dds_depth_sensor_proxy : public dds_sensor_proxy, public depth_sensor
{
public:
dds_depth_sensor_proxy( std::string const & sensor_name,
software_device * owner,
std::shared_ptr< realdds::dds_device > const & dev )
: dds_sensor_proxy( sensor_name, owner, dev )
{
}

// Needed by abstract interfaces
float get_depth_scale() const override { return get_option( RS2_OPTION_DEPTH_UNITS ).query(); }

void create_snapshot( std::shared_ptr<depth_sensor> & snapshot ) const override
{
snapshot = std::make_shared<depth_sensor_snapshot>( get_depth_scale() );
}

void enable_recording( std::function<void( const depth_sensor & )> recording_function ) override
{
//does not change over time
}
};

// This is the rs2 device; it proxies to an actual DDS device that does all the actual
// work. For example:
// auto dev_list = ctx.query_devices();
Expand Down Expand Up @@ -1198,10 +1224,7 @@ namespace librealsense
if( ! sensor_info.proxy )
{
// This is a new sensor we haven't seen yet
if( stream->sensor_name().compare( "RGB Camera" ) == 0 )
sensor_info.proxy = std::make_shared< dds_color_sensor_proxy>( stream->sensor_name(), this, _dds_dev );
else
sensor_info.proxy = std::make_shared< dds_sensor_proxy >( stream->sensor_name(), this, _dds_dev );
sensor_info.proxy = create_sensor( stream->sensor_name() );
sensor_info.sensor_index = add_sensor( sensor_info.proxy );
assert( sensor_info.sensor_index == _software_sensors.size() );
_software_sensors.push_back( sensor_info.proxy );
Expand Down Expand Up @@ -1303,6 +1326,16 @@ namespace librealsense
}
// TODO - need to register extrinsics group in dev?
} //End dds_device_proxy constructor

std::shared_ptr< dds_sensor_proxy> create_sensor( const std::string & sensor_name )
{
if( sensor_name.compare( "RGB Camera" ) == 0 )
return std::make_shared< dds_color_sensor_proxy>( sensor_name, this, _dds_dev );
else if( sensor_name.compare( "Stereo Module" ) == 0 )
return std::make_shared< dds_depth_sensor_proxy>( sensor_name, this, _dds_dev );

return std::make_shared< dds_sensor_proxy >( sensor_name, this, _dds_dev );
}
};

class dds_device_info : public device_info
Expand Down
2 changes: 1 addition & 1 deletion third-party/realdds/include/realdds/dds-stream-base.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class dds_stream_base : public std::enable_shared_from_this< dds_stream_base >
void enable_metadata(); // Must call before init_profiles
void init_profiles( dds_stream_profiles const & profiles, int default_profile_index = 0 );
void init_options( dds_options const & options );
void set_recommended_filters( std::vector< std::string > const & recommended_filters );
void set_recommended_filters( std::vector< std::string > && recommended_filters );

std::string const & name() const { return _name; }
std::string const & sensor_name() const { return _sensor_name; }
Expand Down
15 changes: 9 additions & 6 deletions third-party/realdds/src/dds-device-impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -301,12 +301,15 @@ bool dds_device::impl::init()
}
else if( state_type::WAIT_FOR_DEVICE_OPTIONS == state && id == "device-options" )
{
LOG_DEBUG( "... device-options: " << j["options"].size() << " options received" );

for( auto & option_json : j["options"] )
if( rsutils::json::has( j, "options" ) )
{
auto option = dds_option::from_json( option_json, _info.name );
_options.push_back( option );
LOG_DEBUG( "... device-options: " << j["options"].size() << " options received" );

for( auto & option_json : j["options"] )
{
auto option = dds_option::from_json( option_json, _info.name );
_options.push_back( option );
}
}

if( n_streams_expected )
Expand Down Expand Up @@ -418,7 +421,7 @@ bool dds_device::impl::init()
filter_names.push_back( filter );
}

stream_it->second->set_recommended_filters( filter_names );
stream_it->second->set_recommended_filters( std::move( filter_names ) );
}

if( _streams.size() >= n_streams_expected )
Expand Down
2 changes: 1 addition & 1 deletion third-party/realdds/src/dds-stream-base.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ void dds_stream_base::init_options( dds_options const & options )
}


void dds_stream_base::set_recommended_filters( std::vector< std::string > const & recommended_filters )
void dds_stream_base::set_recommended_filters( std::vector< std::string > && recommended_filters )
{
if( !_recommended_filters.empty() )
DDS_THROW( runtime_error, "stream '" + _name + "' recommended filters are already set" );
Expand Down
2 changes: 1 addition & 1 deletion tools/dds/dds-server/lrs-device-controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ std::vector< std::shared_ptr< realdds::dds_stream_server > > lrs_device_controll
}
}
server->init_options( options );
server->set_recommended_filters( filter_names );
server->set_recommended_filters( std::move( filter_names ) );

servers.push_back( server );
}
Expand Down

0 comments on commit adc94d7

Please sign in to comment.