bool RosStreamSubscriptionInstaller::SetupKinesisVideoFrameTransport()

in kinesis_video_streamer/src/ros_stream_subscription_installer.cpp [50:77]


bool RosStreamSubscriptionInstaller::SetupKinesisVideoFrameTransport(
    const KinesisVideoFrameTransportCallbackFn callback)
{
    if (!callback) {
        AWS_LOG_ERROR(__func__, "Invalid callback was provided at SetupKinesisVideoFrameTransport");
        return false;
    }
    SubscriberSetupFn kinesis_video_frame_setup_closure =
        [this, callback](const StreamSubscriptionDescriptor & descriptor) -> bool {
            auto callback_wrapper = [this, callback, descriptor]
                    (const kinesis_video_msgs::msg::KinesisVideoFrame::ConstSharedPtr frame) -> void {
                callback(*this->stream_manager_, descriptor.stream_name, frame);
            };
            if (auto node_handle = handle_.lock()) {
                /* Use sensor data default QoS settings (volatile, best effort - typical for streaming) */
                rclcpp::QoS kinesis_qos_profile = rclcpp::SensorDataQoS().keep_last(descriptor.message_queue_size);
                standard_subscribers_.push_back(
                        node_handle->create_subscription<kinesis_video_msgs::msg::KinesisVideoFrame>(
                          descriptor.topic_name, kinesis_qos_profile, callback_wrapper));
            } else {
                AWS_LOG_ERROR(__func__, "Cannot set up subscription - the node handle has been destroyed.");
                return false;
            }
            return true;
        };
    installers_.insert({KINESIS_STREAM_INPUT_TYPE_KINESIS_VIDEO_FRAME, kinesis_video_frame_setup_closure});
    return true;
}