Skip to content

Commit

Permalink
Roll back stream type changes (will get from Eran's PR)
Browse files Browse the repository at this point in the history
  • Loading branch information
OhadMeir committed Nov 6, 2022
1 parent 7d6185e commit a9bf07e
Show file tree
Hide file tree
Showing 9 changed files with 29 additions and 42 deletions.
4 changes: 1 addition & 3 deletions third-party/realdds/include/realdds/dds-stream-base.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,8 @@ class dds_stream_base : public std::enable_shared_from_this< dds_stream_base >
std::string const _sensor_name;
int _default_profile_index = 0;
dds_stream_profiles _profiles;
int _type;

dds_stream_base( std::string const & stream_name, std::string const & sensor_name, int type = 0);
dds_stream_base( std::string const & stream_name, std::string const & sensor_name );

public:
virtual ~dds_stream_base() = default;
Expand All @@ -40,7 +39,6 @@ class dds_stream_base : public std::enable_shared_from_this< dds_stream_base >
std::string const & sensor_name() const { return _sensor_name; }
dds_stream_profiles const & profiles() const { return _profiles; }
int default_profile_index() const { return _default_profile_index; }
int type() const { return _type; }

virtual bool is_open() const = 0;
virtual bool is_streaming() const = 0;
Expand Down
6 changes: 3 additions & 3 deletions third-party/realdds/include/realdds/dds-stream-server.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ struct image_header
class dds_stream_server : public dds_stream_base
{
protected:
dds_stream_server( std::string const & stream_name, std::string const & sensor_name, int type = 0 );
dds_stream_server( std::string const & stream_name, std::string const & sensor_name );

public:
virtual ~dds_stream_server();
Expand All @@ -63,7 +63,7 @@ class dds_video_stream_server : public dds_stream_server
typedef dds_stream_server super;

public:
dds_video_stream_server( std::string const & stream_name, std::string const & sensor_name, int type = 0 );
dds_video_stream_server( std::string const & stream_name, std::string const & sensor_name );

void open( std::string const & topic_name, std::shared_ptr< dds_publisher > const & ) override;

Expand All @@ -77,7 +77,7 @@ class dds_motion_stream_server : public dds_stream_server
typedef dds_stream_server super;

public:
dds_motion_stream_server( std::string const & stream_name, std::string const & sensor_name, int type = 0 );
dds_motion_stream_server( std::string const & stream_name, std::string const & sensor_name );

void open( std::string const & topic_name, std::shared_ptr< dds_publisher > const & ) override;

Expand Down
6 changes: 3 additions & 3 deletions third-party/realdds/include/realdds/dds-stream.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class dds_stream : public dds_stream_base
typedef dds_stream_base super;

protected:
dds_stream( std::string const & stream_name, std::string const & sensor_name, int type = 0 );
dds_stream( std::string const & stream_name, std::string const & sensor_name );

// dds_stream_base
public:
Expand All @@ -38,7 +38,7 @@ class dds_video_stream : public dds_stream
typedef dds_stream super;

public:
dds_video_stream( std::string const & stream_name, std::string const & sensor_name, int type = 0 );
dds_video_stream( std::string const & stream_name, std::string const & sensor_name );

private:
class impl;
Expand All @@ -50,7 +50,7 @@ class dds_motion_stream : public dds_stream
typedef dds_stream super;

public:
dds_motion_stream( std::string const & stream_name, std::string const & sensor_name, int type = 0 );
dds_motion_stream( std::string const & stream_name, std::string const & sensor_name );

private:
class impl;
Expand Down
10 changes: 2 additions & 8 deletions third-party/realdds/src/dds-device-impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -196,10 +196,7 @@ bool dds_device::impl::init()
auto & stream = _streams[stream_name];
if( stream )
DDS_THROW( runtime_error, "stream '" + stream_name + "' already exists" );
int stream_type = 0;
if ( video_stream_profiles->num_of_profiles > 0 )
stream_type = video_stream_profiles->profiles[0].type;
stream = std::make_shared< dds_video_stream >( stream_name, sensor_name, stream_type );
stream = std::make_shared< dds_video_stream >( stream_name, sensor_name );

dds_stream_profiles profiles;
int default_profile_index = 0;
Expand Down Expand Up @@ -242,10 +239,7 @@ bool dds_device::impl::init()
auto & stream = _streams[stream_name];
if( stream )
DDS_THROW( runtime_error, "stream '" + stream_name + "' already exists" );
int stream_type = 0;
if ( motion_stream_profiles->num_of_profiles > 0 )
stream_type = motion_stream_profiles->profiles[0].type;
stream = std::make_shared< dds_motion_stream >( stream_name, sensor_name, stream_type );
stream = std::make_shared< dds_motion_stream >( stream_name, sensor_name );

dds_stream_profiles profiles;
int default_profile_index = 0;
Expand Down
9 changes: 5 additions & 4 deletions third-party/realdds/src/dds-device-server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include <realdds/dds-topic-writer.h>

#include <fastdds/dds/topic/Topic.hpp>
#include <fastdds/dds/subscriber/SampleInfo.hpp>


using namespace eprosima::fastdds::dds;
Expand Down Expand Up @@ -46,9 +47,9 @@ void dds_device_server::start_streaming( const std::string & stream_name,
const image_header & header )
{
auto it = _stream_name_to_server.find( stream_name );
if( it == _stream_name_to_server.end() )
if ( it == _stream_name_to_server.end() )
DDS_THROW( runtime_error, "stream '" + stream_name + "' does not exist" );
auto& stream = it->second;
auto & stream = it->second;
stream->start_streaming( header );
}

Expand Down Expand Up @@ -105,7 +106,7 @@ static void on_discovery_video_stream( std::shared_ptr< dds_video_stream_server
vsp->uid().sid,
vsp->frequency(),
static_cast< int8_t >( vsp->format().to_rs2() ),
static_cast< int8_t >( stream->type() ),
static_cast< int8_t >( 0 ), // RS2_STREAM_ANY
static_cast< int16_t >( vsp->width() ),
static_cast< int16_t >( vsp->height() ),
stream->default_profile_index() == index };
Expand Down Expand Up @@ -141,7 +142,7 @@ static void on_discovery_motion_stream( std::shared_ptr< dds_motion_stream_serve
msp->uid().sid,
msp->frequency(),
static_cast< int8_t >( msp->format().to_rs2() ),
static_cast< int8_t >( stream->type() ) };
static_cast< int8_t >( 0 ) }; // RS2_STREAM_ANY

motion_stream_profiles.profiles[index++] = std::move( msp_msg );
}
Expand Down
4 changes: 1 addition & 3 deletions third-party/realdds/src/dds-stream-base.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,9 @@ namespace realdds {


dds_stream_base::dds_stream_base( std::string const & name,
std::string const & sensor_name,
int type)
std::string const & sensor_name )
: _name( name )
, _sensor_name( name )
, _type( type )
{
}

Expand Down
14 changes: 6 additions & 8 deletions third-party/realdds/src/dds-stream-server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ using namespace eprosima::fastdds::dds;
using namespace realdds;


dds_stream_server::dds_stream_server( std::string const & stream_name, std::string const & sensor_name, int type )
: dds_stream_base( stream_name, sensor_name, type )
dds_stream_server::dds_stream_server( std::string const & stream_name, std::string const & sensor_name )
: dds_stream_base( stream_name, sensor_name )
{
}

Expand All @@ -31,9 +31,8 @@ dds_stream_server::~dds_stream_server()


dds_video_stream_server::dds_video_stream_server( std::string const& stream_name,
std::string const& sensor_name,
int type )
: dds_stream_server( stream_name, sensor_name, type )
std::string const& sensor_name )
: dds_stream_server( stream_name, sensor_name )
{
}

Expand All @@ -47,9 +46,8 @@ void dds_video_stream_server::check_profile( std::shared_ptr< dds_stream_profile


dds_motion_stream_server::dds_motion_stream_server( std::string const & stream_name,
std::string const & sensor_name,
int type )
: dds_stream_server( stream_name, sensor_name, type )
std::string const & sensor_name )
: dds_stream_server( stream_name, sensor_name )
{
}

Expand Down
12 changes: 6 additions & 6 deletions third-party/realdds/src/dds-stream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
namespace realdds {


dds_stream::dds_stream( std::string const & stream_name, std::string const & sensor_name, int type )
: super( stream_name, sensor_name, type )
dds_stream::dds_stream( std::string const & stream_name, std::string const & sensor_name )
: super( stream_name, sensor_name )
{
}

Expand All @@ -34,15 +34,15 @@ std::shared_ptr< dds_topic > const & dds_stream::get_topic() const
}


dds_video_stream::dds_video_stream( std::string const & stream_name, std::string const & sensor_name, int type )
: super( stream_name, sensor_name, type )
dds_video_stream::dds_video_stream( std::string const & stream_name, std::string const & sensor_name )
: super( stream_name, sensor_name )
, _impl( std::make_shared< dds_video_stream::impl >() )
{
}


dds_motion_stream::dds_motion_stream( std::string const & stream_name, std::string const & sensor_name, int type )
: super( stream_name, sensor_name, type )
dds_motion_stream::dds_motion_stream( std::string const & stream_name, std::string const & sensor_name )
: super( stream_name, sensor_name )
, _impl( std::make_shared< dds_motion_stream::impl >() )
{
}
Expand Down
6 changes: 2 additions & 4 deletions tools/dds/dds-server/rs-dds-server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,10 @@ std::vector< std::shared_ptr< realdds::dds_stream_server > > get_supported_strea
std::map< std::string, realdds::dds_stream_profiles > name_to_profiles;
std::map< std::string, int > name_to_default_profile;
std::map< std::string, std::string > name_to_sensor;
std::map< std::string, int > name_to_type;
for( auto sensor : dev.query_sensors() )
{
std::string const sensor_name = sensor.get_info( RS2_CAMERA_INFO_NAME );
auto stream_profiles = sensor.get_stream_profiles();
name_to_type[sensor_name] = stream_profiles.empty() ? 0 : stream_profiles[0].stream_type();
std::for_each( stream_profiles.begin(), stream_profiles.end(), [&]( const rs2::stream_profile & sp ) {
std::string stream_name = sp.stream_name();
name_to_sensor[stream_name] = sensor_name;
Expand Down Expand Up @@ -94,9 +92,9 @@ std::vector< std::shared_ptr< realdds::dds_stream_server > > get_supported_strea
std::string const & sensor_name = name_to_sensor[stream_name];
std::shared_ptr< realdds::dds_stream_server > server;
if( std::dynamic_pointer_cast<realdds::dds_video_stream_profile>( profiles.front() ) )
server = std::make_shared< realdds::dds_video_stream_server >( stream_name, sensor_name, name_to_type[sensor_name] );
server = std::make_shared< realdds::dds_video_stream_server >( stream_name, sensor_name );
else
server = std::make_shared< realdds::dds_motion_stream_server >( stream_name, sensor_name, name_to_type[sensor_name] );
server = std::make_shared< realdds::dds_motion_stream_server >( stream_name, sensor_name );
server->init_profiles( profiles, default_profile_index );
servers.push_back( server );
}
Expand Down

0 comments on commit a9bf07e

Please sign in to comment.