-
Notifications
You must be signed in to change notification settings - Fork 4.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open streams working for all stream types + some bug fixes #11045
Changes from 8 commits
f64defa
e23f732
634aa7b
471e6f2
63c9544
cf0e141
cab9905
a655f4d
7d6185e
6493c65
ac6f8bb
cf39725
f7dbb75
189ea50
9890c59
afe730e
4f9f8a5
4480f74
a7abce6
cc05f8c
a2f5fe2
f57ffa1
09443aa
8b54053
3985402
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
// License: Apache 2.0. See LICENSE file in root directory. | ||
// Copyright(c) 2022 Intel Corporation. All Rights Reserved. | ||
|
||
#pragma once | ||
|
||
|
||
#include <realdds/topics/control/controlPubSubTypes.h> // raw::device::control | ||
#include <librealsense2/utilities/concurrency/concurrency.h> | ||
|
||
#include <memory> | ||
#include <string> | ||
|
||
|
||
namespace realdds { | ||
|
||
|
||
namespace topics { | ||
namespace raw { | ||
namespace device { | ||
class control; | ||
} | ||
} // namespace raw | ||
} // namespace topics | ||
|
||
|
||
class dds_subscriber; | ||
class dds_topic_reader; | ||
|
||
|
||
// A control is a command sent from a client (camera user) and the server (this class) receives and interprets. | ||
// | ||
class dds_control_server | ||
{ | ||
public: | ||
dds_control_server( std::shared_ptr< dds_subscriber > const & subscriber, const std::string & topic_name ); | ||
~dds_control_server(); | ||
|
||
typedef std::function< void() > on_control_message_received_callback; | ||
void on_control_message_received( on_control_message_received_callback callback ); | ||
|
||
private: | ||
std::shared_ptr< dds_subscriber > _subscriber; | ||
std::shared_ptr< dds_topic_reader > _reader; | ||
}; | ||
|
||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -83,18 +83,20 @@ class dds_stream_profile | |
{ | ||
dds_stream_uid _uid; | ||
dds_stream_format _format; | ||
int16_t _frequency; // "Frames" per second | ||
int16_t _frequency; // "Frames" per second | ||
int8_t _inner_type; // User defined type | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't quite understand the need here. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. RS applications like I agree that this is a duplication that can be avoided by sending a stream type. Currently in notificaiton-msg it is sent in the profile struct, and I didn't want to change that so we won't have a difficult merge. I will take the information to the stream from the first profile in the message assuming all profiles have the same type (true for libRS, not sure that true in the general case) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So approve my PR and sending a type as part of the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. By the way -- I don't think the type should be an argument to the stream, but a subtype of the stream: i.e., a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Then we will have to add types to realdds if LibRS adds a type. realdds doesn't really care about the type, it just need to relay it to the user There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. But the type does change things, and can change functionality. |
||
|
||
std::weak_ptr< dds_stream_base > _stream; | ||
|
||
public: | ||
virtual ~dds_stream_profile() {} | ||
|
||
protected: | ||
dds_stream_profile( dds_stream_uid uid, dds_stream_format format, int16_t frequency ) | ||
dds_stream_profile( dds_stream_uid uid, dds_stream_format format, int16_t frequency, int8_t inner_type = 0 ) | ||
: _uid( uid ) | ||
, _format( format ) | ||
, _frequency( frequency ) | ||
, _inner_type( inner_type ) | ||
{ | ||
} | ||
dds_stream_profile( dds_stream_profile && ) = default; | ||
|
@@ -107,6 +109,7 @@ class dds_stream_profile | |
dds_stream_uid uid() const { return _uid; } | ||
dds_stream_format format() const { return _format; } | ||
int16_t frequency() const { return _frequency; } | ||
int8_t type() const { return _inner_type; } | ||
|
||
// These are for debugging - not functional | ||
virtual std::string to_string() const; | ||
|
@@ -125,8 +128,9 @@ class dds_video_stream_profile : public dds_stream_profile | |
uint8_t _bytes_per_pixel; | ||
|
||
public: | ||
dds_video_stream_profile( dds_stream_uid uid, dds_stream_format format, int16_t frequency, uint16_t width, uint16_t height, uint8_t bytes_per_pixel ) | ||
: dds_stream_profile( uid, format, frequency ) | ||
dds_video_stream_profile( dds_stream_uid uid, dds_stream_format format, int16_t frequency, uint16_t width, uint16_t height, | ||
uint8_t bytes_per_pixel, int8_t inner_type = 0 ) | ||
: dds_stream_profile( uid, format, frequency, inner_type ) | ||
, _width( width ) | ||
, _height( height ) | ||
, _bytes_per_pixel( bytes_per_pixel ) | ||
|
@@ -146,8 +150,8 @@ class dds_video_stream_profile : public dds_stream_profile | |
class dds_motion_stream_profile : public dds_stream_profile | ||
{ | ||
public: | ||
dds_motion_stream_profile( dds_stream_uid uid, dds_stream_format format, int16_t frequency ) | ||
: dds_stream_profile( uid, format, frequency ) | ||
dds_motion_stream_profile( dds_stream_uid uid, dds_stream_format format, int16_t frequency, int8_t inner_type = 0 ) | ||
: dds_stream_profile( uid, format, frequency, inner_type ) | ||
{ | ||
} | ||
dds_motion_stream_profile( dds_motion_stream_profile && ) = default; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
// License: Apache 2.0. See LICENSE file in root directory. | ||
// Copyright(c) 2022 Intel Corporation. All Rights Reserved. | ||
|
||
#pragma once | ||
|
||
#include <memory> | ||
|
||
|
||
namespace eprosima { | ||
namespace fastdds { | ||
namespace dds { | ||
class Subscriber; | ||
} // namespace dds | ||
} // namespace fastdds | ||
} // namespace eprosima | ||
|
||
|
||
namespace realdds { | ||
|
||
|
||
class dds_participant; | ||
|
||
|
||
// The Subscriber manages the activities of several dds_topic_reader (DataReader) entities | ||
// | ||
class dds_subscriber | ||
{ | ||
std::shared_ptr< dds_participant > _participant; | ||
|
||
eprosima::fastdds::dds::Subscriber * _subscriber; | ||
|
||
public: | ||
dds_subscriber( std::shared_ptr< dds_participant > const & participant ); | ||
~dds_subscriber(); | ||
|
||
eprosima::fastdds::dds::Subscriber * get() const { return _subscriber; } | ||
eprosima::fastdds::dds::Subscriber * operator->() const { return get(); } | ||
|
||
std::shared_ptr< dds_participant > const & get_participant() const { return _participant; } | ||
}; | ||
|
||
|
||
} // namespace realdds |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
// License: Apache 2.0. See LICENSE file in root directory. | ||
// Copyright(c) 2022 Intel Corporation. All Rights Reserved. | ||
|
||
#include <realdds/dds-control-server.h> | ||
|
||
#include <realdds/dds-participant.h> | ||
#include <realdds/dds-subscriber.h> | ||
#include <realdds/dds-stream-server.h> | ||
#include <realdds/dds-utilities.h> | ||
#include <realdds/topics/dds-topics.h> | ||
#include <realdds/dds-topic.h> | ||
#include <realdds/dds-topic-reader.h> | ||
|
||
#include <fastdds/dds/topic/Topic.hpp> | ||
|
||
#include <fastdds/dds/domain/DomainParticipant.hpp> | ||
#include <fastdds/dds/subscriber/Subscriber.hpp> | ||
#include <fastdds/dds/subscriber/DataReader.hpp> | ||
#include <fastdds/dds/subscriber/DataReaderListener.hpp> | ||
#include <fastdds/dds/subscriber/qos/SubscriberQos.hpp> | ||
#include <librealsense2/utilities/concurrency/concurrency.h> | ||
|
||
|
||
using namespace eprosima::fastdds::dds; | ||
|
||
namespace realdds { | ||
|
||
|
||
dds_control_server::dds_control_server( std::shared_ptr< dds_subscriber > const & subscriber, const std::string & topic_name ) | ||
: _subscriber( subscriber ) | ||
{ | ||
auto topic = topics::device::control::create_topic( subscriber->get_participant(), topic_name.c_str() ); | ||
_reader = std::make_shared< dds_topic_reader >( topic, subscriber ); | ||
|
||
dds_topic_reader::qos rqos( RELIABLE_RELIABILITY_QOS ); | ||
rqos.history().depth = 10; // default is 1 | ||
rqos.endpoint().history_memory_policy = eprosima::fastrtps::rtps::DYNAMIC_RESERVE_MEMORY_MODE; | ||
maloel marked this conversation as resolved.
Show resolved
Hide resolved
|
||
_reader->run( rqos ); | ||
} | ||
|
||
|
||
dds_control_server::~dds_control_server() | ||
{ | ||
} | ||
|
||
|
||
void dds_control_server::on_control_message_received( on_control_message_received_callback callback ) | ||
{ | ||
if ( !_reader ) | ||
DDS_THROW( runtime_error, "setting callback when reader is not created" ); | ||
maloel marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
_reader->on_data_available( callback ); | ||
} | ||
|
||
|
||
} // namespace realdds |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From my understanding of the usage, this is not really a server but a client -- a listener for control messages.
If so -- then how is this different than a topic-reader? Do you envision more logic being placed here? I don't see much logic belonging in realdds other than high-level commands (stream start/stop, control get/set) that would still need customization by the end implementation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that we will need more logic to handle stuff like query-reply pairs and msg-id matching.
If it will all be in the application than you are right and we can refactor this out
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it'll be where the control messages are handled.
Most controls will be handled in the app and only a few will be done entirely in realdds and even then it'll likely be in the device-server. If there's a lot of code we can certainly push to another class but at this time I don't see much justification.