@@ -40,7 +40,12 @@ static const ParameterDefinition params[] = {
4040 .set__description (" enable performance timing" )
4141 .set__read_only (false )}};
4242
43- FFMPEGSubscriber::FFMPEGSubscriber () : logger_(rclcpp::get_logger(" FFMPEGSubscriber" )) {}
43+ FFMPEGSubscriber::FFMPEGSubscriber () : logger_(rclcpp::get_logger(" FFMPEGSubscriber" ))
44+ {
45+ #ifndef IMAGE_TRANSPORT_USE_NODEINTERFACE
46+ node_ = nullptr ;
47+ #endif
48+ }
4449
4550FFMPEGSubscriber::~FFMPEGSubscriber () { decoder_.reset (); }
4651
@@ -56,29 +61,20 @@ void FFMPEGSubscriber::shutdown()
5661
5762void FFMPEGSubscriber::frameReady (const ImageConstPtr & img, bool ) const { (*userCallback_)(img); }
5863
59- #ifdef IMAGE_TRANSPORT_API_V1
6064void FFMPEGSubscriber::subscribeImpl (
61- rclcpp::Node * node, const std::string & base_topic, const Callback & callback,
62- rmw_qos_profile_t custom_qos )
65+ NodeType node, const std::string & base_topic, const Callback & callback, QoSType custom_qos ,
66+ rclcpp::SubscriptionOptions opt )
6367{
6468 initialize (node, base_topic);
65- FFMPEGSubscriberPlugin::subscribeImpl (node, base_topic, callback, custom_qos);
66- }
69+ # ifdef IMAGE_TRANSPORT_NEEDS_PUBLISHEROPTIONS
70+ FFMPEGSubscriberPlugin::subscribeImpl (node, base_topic, callback, custom_qos, opt);
6771#else
68- void FFMPEGSubscriber::subscribeImpl (
69- rclcpp::Node * node, const std::string & base_topic, const Callback & callback,
70- QoSType custom_qos, rclcpp::SubscriptionOptions opt)
71- {
72- initialize (node, base_topic);
73- #ifdef IMAGE_TRANSPORT_API_V2
7472 (void )opt; // to suppress compiler warning
7573 FFMPEGSubscriberPlugin::subscribeImpl (node, base_topic, callback, custom_qos);
76- #else
77- FFMPEGSubscriberPlugin::subscribeImpl (node, base_topic, callback, custom_qos, opt);
7874#endif
7975}
80- # endif
81- void FFMPEGSubscriber::initialize (rclcpp::Node * node, const std::string & base_topic_o)
76+
77+ void FFMPEGSubscriber::initialize (NodeType node, const std::string & base_topic_o)
8278{
8379 node_ = node;
8480#ifdef IMAGE_TRANSPORT_RESOLVES_BASE_TOPIC
@@ -87,10 +83,15 @@ void FFMPEGSubscriber::initialize(rclcpp::Node * node, const std::string & base_
8783 const std::string base_topic =
8884 node_->get_node_topics_interface ()->resolve_topic_name (base_topic_o);
8985#endif
90- uint ns_len = node_->get_effective_namespace ().length ();
86+
87+ #ifdef IMAGE_TRANSPORT_USE_NODEINTERFACE
88+ uint ns_prefix_len = std::string (node.get_node_base_interface ()->get_namespace ()).length ();
89+ #else
90+ uint ns_len = node->get_effective_namespace ().length ();
9191 // if a namespace is given (ns_len > 1), then strip one more
9292 // character to avoid a leading "/" that will then become a "."
9393 uint ns_prefix_len = ns_len > 1 ? ns_len + 1 : ns_len;
94+ #endif
9495 std::string param_base_name = base_topic.substr (ns_prefix_len);
9596 std::replace (param_base_name.begin (), param_base_name.end (), ' /' , ' .' );
9697 paramNamespace_ = param_base_name + " ." + getTransportName () + " ." ;
@@ -100,7 +101,7 @@ void FFMPEGSubscriber::initialize(rclcpp::Node * node, const std::string & base_
100101 }
101102}
102103
103- void FFMPEGSubscriber::declareParameter (rclcpp::Node * node, const ParameterDefinition & definition)
104+ void FFMPEGSubscriber::declareParameter (NodeType node, const ParameterDefinition & definition)
104105{
105106 const auto v = definition.declare (node, paramNamespace_);
106107 const auto & n = definition.descriptor .name ;
0 commit comments