@@ -176,6 +176,12 @@ dds_device_proxy::dds_device_proxy( std::shared_ptr< const device_info > const &
176176 std::shared_ptr< dds_sensor_proxy > proxy;
177177 int sensor_index = 0 ;
178178 rs2_stream type = RS2_STREAM_ANY;
179+ // dds_streams bear stream type and index information, we add it to a dds_sensor_proxy mapped by a newly generated
180+ // unique ID. After the sensor initialization we get all the "final" profiles from formats-converter with type and
181+ // index but without IDs. We need to find the dds_stream that each profile was created from so we create a map from
182+ // type and index to dds_stream ID and index, because the dds_sensor_proxy holds a map from sidx to dds_stream. We
183+ // need both the ID from that map key and the stream itself (for intrinsics information)
184+ std::map< sid_index, sid_index > type_and_index_to_dds_stream_sidx;
179185 };
180186 std::map< std::string, sensor_info > sensor_name_to_info;
181187
@@ -185,7 +191,7 @@ dds_device_proxy::dds_device_proxy( std::shared_ptr< const device_info > const &
185191 {
186192 auto & sensor = sensor_name_to_info[stream->sensor_name ()];
187193 if ( stream->type_string () == " depth"
188- || stream->type_string () == " infrared " )
194+ || stream->type_string () == " ir " )
189195 {
190196 // If there's depth or infrared, it is a depth sensor regardless of what else is in there
191197 // E.g., the D405 has a color stream in the depth sensor
@@ -208,13 +214,6 @@ dds_device_proxy::dds_device_proxy( std::shared_ptr< const device_info > const &
208214 }
209215 } ); // End foreach_stream lambda
210216
211- // dds_streams bear stream type and index information, we add it to a dds_sensor_proxy mapped by a newly generated
212- // unique ID. After the sensor initialization we get all the "final" profiles from formats-converter with type and
213- // index but without IDs. We need to find the dds_stream that each profile was created from so we create a map from
214- // type and index to dds_stream ID and index, because the dds_sensor_proxy holds a map from sidx to dds_stream. We
215- // need both the ID from that map key and the stream itself (for intrinsics information)
216- std::map< sid_index, sid_index > type_and_index_to_dds_stream_sidx;
217-
218217 _dds_dev->foreach_stream (
219218 [&]( std::shared_ptr< realdds::dds_stream > const & stream )
220219 {
@@ -235,9 +234,14 @@ dds_device_proxy::dds_device_proxy( std::shared_ptr< const device_info > const &
235234 = std::make_shared< librealsense::stream >( stream_type, sidx.index );
236235 sensor_info.proxy ->add_dds_stream ( sidx, stream );
237236 _stream_name_to_owning_sensor[stream->name ()] = sensor_info.proxy ;
238- type_and_index_to_dds_stream_sidx.insert ( { type_and_index, sidx } );
239- LOG_DEBUG ( sidx.to_string () << " " << get_string ( sensor_info.type ) << " '" << stream->sensor_name ()
240- << " ' : '" << stream->name () << " ' " << get_string ( stream_type ) );
237+ if ( ! sensor_info.type_and_index_to_dds_stream_sidx .insert ( { type_and_index, sidx } ).second )
238+ LOG_ERROR ( " Failed to insert '" << stream->sensor_name () << " ' " << type_and_index.to_string () << " "
239+ << get_string ( sensor_info.type ) << " -> " << get_string ( stream_type )
240+ << " " << sidx.to_string () << " '" << stream->name () << " ' mapping" );
241+ // else
242+ // LOG_DEBUG( "'" << stream->sensor_name() << "' " << type_and_index.to_string() << " "
243+ // << get_string( sensor_info.type ) << " -> " << get_string( stream_type ) << " "
244+ // << sidx.to_string() << " '" << stream->name() << "'" );
241245
242246 software_sensor & sensor = get_software_sensor ( sensor_info.sensor_index );
243247 auto video_stream = std::dynamic_pointer_cast< realdds::dds_video_stream >( stream );
@@ -279,36 +283,35 @@ dds_device_proxy::dds_device_proxy( std::shared_ptr< const device_info > const &
279283 }
280284 } ); // End foreach_stream lambda
281285
282- for ( auto & sensor_info : sensor_name_to_info )
286+ for ( auto & name_info : sensor_name_to_info )
283287 {
284- LOG_DEBUG ( sensor_info.first );
288+ auto & sensor_name = name_info.first ;
289+ auto & sensor_info = name_info.second ;
290+ auto & sensor_proxy = sensor_info.proxy ;
291+ // LOG_DEBUG( sensor_name );
285292
286293 // Set profile's ID based on the dds_stream's ID (index already set). Connect the profile to the extrinsics graph.
287- for ( auto & profile : sensor_info.second .proxy ->get_stream_profiles () )
294+ // The get_stream_profiles() call will initialize the profiles (calling dds_sensor_proxy::init_stream_profiles())
295+ for ( auto & profile : sensor_proxy->get_stream_profiles () )
288296 {
289- // if( auto p = std::dynamic_pointer_cast< librealsense::video_stream_profile_interface >( profile ) )
290- // {
291- // LOG_DEBUG( " " << get_string( p->get_stream_type() ) << ' ' << p->get_stream_index() << ' '
292- // << get_string( p->get_format() ) << ' ' << p->get_width() << 'x' << p->get_height()
293- // << " @ " << p->get_framerate() );
294- // }
295- // else if( auto p = std::dynamic_pointer_cast<librealsense::motion_stream_profile_interface>( profile ) )
296- // {
297- // LOG_DEBUG( " " << get_string( p->get_stream_type() ) << ' ' << p->get_stream_index() << ' '
298- // << get_string( p->get_format() ) << " @ " << p->get_framerate() );
299- // }
300- sid_index type_and_index ( profile->get_stream_type (), profile->get_stream_index () );
301-
302- auto & streams = sensor_info.second .proxy ->streams ();
303-
304- sid_index sidx = type_and_index_to_dds_stream_sidx.at ( type_and_index );
297+ auto & source_profiles = sensor_proxy->_formats_converter .get_source_profiles_from_target ( profile );
298+ if ( source_profiles.size () != 1 )
299+ LOG_ERROR ( " More than one source profile available for [" << profile << " ]: " << source_profiles );
300+ auto source_profile = source_profiles[0 ];
301+
302+ sid_index type_and_index ( source_profile->get_stream_type (), source_profile->get_stream_index () );
303+ sid_index sidx = sensor_info.type_and_index_to_dds_stream_sidx .at ( type_and_index );
304+
305+ auto & streams = sensor_proxy->streams ();
305306 auto stream_iter = streams.find ( sidx );
306307 if ( stream_iter == streams.end () )
307308 {
308- LOG_DEBUG ( " no dds stream" );
309+ LOG_ERROR ( " No dds stream " << sidx.to_string () << " found for '" << sensor_name << " ' " << profile
310+ << " -> " << source_profile << " " << type_and_index.to_string () );
309311 continue ;
310312 }
311313
314+ // LOG_DEBUG( " " << profile << " -> " << source_profile << " " << type_and_index.to_string() );
312315 profile->set_unique_id ( sidx.sid ); // Was lost on clone
313316
314317 // NOTE: the 'initialization_done' call above creates target profiles from the raw profiles we supplied it.
@@ -348,7 +351,7 @@ dds_device_proxy::dds_device_proxy( std::shared_ptr< const device_info > const &
348351 auto const dds_extr = _dds_dev->get_extrinsics ( from_stream.first , to_stream.first );
349352 if ( ! dds_extr )
350353 {
351- LOG_DEBUG ( " missing extrinsics from " << from_stream.first << " to " << to_stream.first );
354+ // LOG_DEBUG( "missing extrinsics from " << from_stream.first << " to " << to_stream.first );
352355 continue ;
353356 }
354357 rs2_extrinsics extr = to_rs2_extrinsics ( dds_extr );
0 commit comments