@@ -91,7 +91,7 @@ stream_profiles dds_sensor_proxy::init_stream_profiles()
91
91
}
92
92
else
93
93
{
94
- register_basic_converters ();
94
+ register_converters ();
95
95
if ( format_conversion::basic == format )
96
96
_formats_converter.drop_non_basic_formats ();
97
97
profiles = _formats_converter.get_all_possible_profiles ( profiles );
@@ -102,8 +102,27 @@ stream_profiles dds_sensor_proxy::init_stream_profiles()
102
102
}
103
103
104
104
105
- void dds_sensor_proxy::register_basic_converters ()
105
+ void dds_sensor_proxy::register_converters ()
106
106
{
107
+ // Some stream types have typicaly more then one stream, indexes must be used to differentiate them and needs to be
108
+ // set in converter target profiles. Gather info for such stream types in one loop over all profiles.
109
+ std::set< int > y8_indexes;
110
+ std::set< int > y16_indexes;
111
+ std::set< int > jpeg_indexes;
112
+ for ( auto & stream : streams () )
113
+ {
114
+ for ( auto & profile : stream.second ->profiles () )
115
+ {
116
+ if ( auto vsp = std::dynamic_pointer_cast< realdds::dds_video_stream_profile >( profile ) )
117
+ if ( vsp->encoding ().to_rs2 () == RS2_FORMAT_Y8 )
118
+ y8_indexes.insert ( stream.first .index );
119
+ else if ( vsp->encoding ().to_rs2 () == RS2_FORMAT_Y16 )
120
+ y16_indexes.insert ( stream.first .index );
121
+ else if ( vsp->encoding ().to_rs2 () == RS2_FORMAT_MJPEG )
122
+ jpeg_indexes.insert ( stream.first .index );
123
+ }
124
+ }
125
+
107
126
// Color
108
127
_formats_converter.register_converter ( processing_block_factory::create_id_pbf ( RS2_FORMAT_RGB8, RS2_STREAM_COLOR ) );
109
128
_formats_converter.register_converter ( processing_block_factory::create_id_pbf ( RS2_FORMAT_RGBA8, RS2_STREAM_COLOR ) );
@@ -122,33 +141,48 @@ void dds_sensor_proxy::register_basic_converters()
122
141
{ RS2_FORMAT_YUYV, RS2_FORMAT_RGB8, RS2_FORMAT_Y8, RS2_FORMAT_RGBA8, RS2_FORMAT_BGR8, RS2_FORMAT_BGRA8 },
123
142
RS2_STREAM_COLOR ) );
124
143
144
+ if ( jpeg_indexes.size () > 0 )
145
+ {
146
+ std::vector< stream_profile > target_profiles;
147
+ for ( int index : jpeg_indexes )
148
+ target_profiles.push_back ( { RS2_FORMAT_RGB8, RS2_STREAM_COLOR, index } );
149
+ _formats_converter.register_converter ( { { RS2_FORMAT_MJPEG, RS2_STREAM_COLOR } }, target_profiles,
150
+ []() { return std::make_shared< mjpeg_converter >( RS2_FORMAT_RGB8 ); } );
151
+ }
152
+
125
153
// Depth
126
154
_formats_converter.register_converter (
127
155
processing_block_factory::create_id_pbf ( RS2_FORMAT_Z16, RS2_STREAM_DEPTH ) );
128
156
129
157
// Infrared (converter source needs type to be handled properly by formats_converter)
130
- _formats_converter.register_converter (
131
- { { { RS2_FORMAT_Y8, RS2_STREAM_INFRARED } },
132
- { { RS2_FORMAT_Y8, RS2_STREAM_INFRARED, 0 },
133
- { RS2_FORMAT_Y8, RS2_STREAM_INFRARED, 1 },
134
- { RS2_FORMAT_Y8, RS2_STREAM_INFRARED, 2 } },
135
- []() { return std::make_shared< identity_processing_block >(); } } );
136
- std::string product_line = get_device ().get_info ( RS2_CAMERA_INFO_PRODUCT_LINE );
137
- bool d400 = product_line.find (" D400" ) != std::string::npos;
138
- _formats_converter.register_converter (
139
- { { { RS2_FORMAT_Y16, RS2_STREAM_INFRARED } },
140
- { { RS2_FORMAT_Y16, RS2_STREAM_INFRARED, 1 },
141
- { RS2_FORMAT_Y16, RS2_STREAM_INFRARED, 2 } },
142
- [d400]() -> std::shared_ptr< stream_filter_processing_block >
143
- {
144
- // Y16 is calibration format, sent with 10bit data that needs conversion to 16bit.
145
- // D400 products don't have DDS so we use rs-dds-adapter that already converts.
146
- // Calibration with other products that use rs-dds-adapter is currently not supported.
147
- if ( d400 )
148
- return std::make_shared< identity_processing_block >();
149
-
150
- return std::make_shared< y16_10msb_to_y16 >();
151
- } } );
158
+ if ( y8_indexes.size () > 0 )
159
+ {
160
+ std::vector< stream_profile > target_profiles;
161
+ for ( int index : y8_indexes )
162
+ target_profiles.push_back ( { RS2_FORMAT_Y8, RS2_STREAM_INFRARED, index } );
163
+ _formats_converter.register_converter ( { { { RS2_FORMAT_Y8, RS2_STREAM_INFRARED } }, target_profiles,
164
+ []() { return std::make_shared< identity_processing_block >(); } } );
165
+ }
166
+
167
+ if ( y16_indexes.size () > 0 )
168
+ {
169
+ std::vector< stream_profile > target_profiles;
170
+ for ( int index : y16_indexes )
171
+ target_profiles.push_back ( { RS2_FORMAT_Y16, RS2_STREAM_INFRARED, index } );
172
+ std::string product_line = get_device ().get_info ( RS2_CAMERA_INFO_PRODUCT_LINE );
173
+ bool d400 = product_line.find (" D400" ) != std::string::npos;
174
+ _formats_converter.register_converter ( { { { RS2_FORMAT_Y16, RS2_STREAM_INFRARED } }, target_profiles,
175
+ [d400]() -> std::shared_ptr< stream_filter_processing_block >
176
+ {
177
+ // Y16 is calibration format, sent with 10bit data that needs conversion to 16bit.
178
+ // D400 products don't have DDS so we use rs-dds-adapter that already converts.
179
+ // Calibration with other products that use rs-dds-adapter is currently not supported.
180
+ if ( d400 )
181
+ return std::make_shared< identity_processing_block >();
182
+
183
+ return std::make_shared< y16_10msb_to_y16 >();
184
+ } } );
185
+ }
152
186
153
187
// Motion
154
188
_formats_converter.register_converter ( processing_block_factory::create_id_pbf ( RS2_FORMAT_COMBINED_MOTION, RS2_STREAM_MOTION ) );
0 commit comments