ros_stream_subscription_installer.h
Go to the documentation of this file.
1 /*
2  * Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License").
5  * You may not use this file except in compliance with the License.
6  * A copy of the License is located at
7  *
8  * http://aws.amazon.com/apache2.0
9  *
10  * or in the "license" file accompanying this file. This file is distributed
11  * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
12  * express or implied. See the License for the specific language governing
13  * permissions and limitations under the License.
14  */
15 #pragma once
16 #include <aws/core/utils/logging/LogMacros.h>
20 #include <kinesis_video_msgs/KinesisVideoFrame.h>
22 
23 
24 namespace Aws {
25 namespace Kinesis {
26 
33  1, /* Implies a video stream with kinesis_video_msgs::KinesisVideoFrame message transport. */
35  2, /* Implies a video stream with sensor_msgs::Image message transport. */
37  3 /* KinesisVideoFrame with AWS Rekognition results published to a ROS topic. */
39 
41  KinesisStreamManagerInterface & stream_manager, std::string stream_name,
42  const kinesis_video_msgs::KinesisVideoFrame::ConstPtr & frame_msg);
43 
45  KinesisStreamManagerInterface & stream_manager, std::string stream_name,
46  const kinesis_video_msgs::KinesisVideoFrame::ConstPtr & frame_msg,
47  const ros::Publisher & publisher);
48 
49 typedef void (*ImageTransportCallbackFn)(const KinesisStreamManagerInterface & stream_manager,
50  std::string stream_name,
51  const sensor_msgs::ImageConstPtr & image);
52 
57 {
58 public:
61  {
62  }
63 
70  virtual bool SetDefaultCallbacks()
71  {
72  bool status = true;
73  ImageTransportCallbackFn image_transport_callback;
74  KinesisVideoFrameTransportCallbackFn kinesis_video_frame_transport_callback;
75  RekognitionEnabledKinesisVideoFrameTransportCallbackFn rekognition_video_frame_callback;
76 
77  /* Set up subscription callbacks */
78  image_transport_callback = &ImageTransportCallback;
79  kinesis_video_frame_transport_callback = &KinesisVideoFrameTransportCallback;
80  rekognition_video_frame_callback = &RekognitionEnabledKinesisVideoFrameTransportCallback;
81 
82  if (!this->SetupImageTransport(image_transport_callback) ||
83  !this->SetupKinesisVideoFrameTransport(kinesis_video_frame_transport_callback) ||
85  rekognition_video_frame_callback)) {
86  AWS_LOG_FATAL(__func__, "Failed to set up subscription callbacks.");
87  status = false;
88  }
89  return status;
90  }
95  bool SetupImageTransport(const ImageTransportCallbackFn callback);
112  void Uninstall(const std::string & topic_name) override;
119  {
120  stream_manager_ = stream_manager;
121  }
122 
123 private:
126  std::vector<ros::Subscriber> standard_subscribers_;
127  std::vector<image_transport::Subscriber> image_transport_subscribers_;
128  std::map<std::string, ros::Publisher> publishers_; /* Publishers associated with a subscriber. Key
129  is the *subscription* topic name. */
130 };
131 
132 } // namespace Kinesis
133 } // namespace Aws
void(* KinesisVideoFrameTransportCallbackFn)(KinesisStreamManagerInterface &stream_manager, std::string stream_name, const kinesis_video_msgs::KinesisVideoFrame::ConstPtr &frame_msg)
enum Aws::Kinesis::kinesis_stream_ros_input_type_e KinesisStreamRosInputType
bool SetupImageTransport(const ImageTransportCallbackFn callback)
void set_stream_manager(KinesisStreamManagerInterface *stream_manager)
bool SetupKinesisVideoFrameTransport(const KinesisVideoFrameTransportCallbackFn callback)
const char * topic_name
void Uninstall(const std::string &topic_name) override
void(* RekognitionEnabledKinesisVideoFrameTransportCallbackFn)(KinesisStreamManagerInterface &stream_manager, std::string stream_name, const kinesis_video_msgs::KinesisVideoFrame::ConstPtr &frame_msg, const ros::Publisher &publisher)
void(* ImageTransportCallbackFn)(const KinesisStreamManagerInterface &stream_manager, std::string stream_name, const sensor_msgs::ImageConstPtr &image)
const char * stream_name
void RekognitionEnabledKinesisVideoFrameTransportCallback(KinesisStreamManagerInterface &stream_manager, std::string stream_name, const kinesis_video_msgs::KinesisVideoFrame::ConstPtr &frame_msg, const ros::Publisher &publisher)
Aws::Kinesis::KinesisStreamManagerInterface * stream_manager_
void KinesisVideoFrameTransportCallback(KinesisStreamManagerInterface &stream_manager, std::string stream_name, const kinesis_video_msgs::KinesisVideoFrame::ConstPtr &frame_msg)
void ImageTransportCallback(const KinesisStreamManagerInterface &stream_manager, std::string stream_name, const sensor_msgs::ImageConstPtr &image)
std::vector< image_transport::Subscriber > image_transport_subscribers_
bool SetupRekognitionEnabledKinesisVideoFrameTransport(const RekognitionEnabledKinesisVideoFrameTransportCallbackFn callback)


kinesis_video_streamer
Author(s): AWS RoboMaker
autogenerated on Fri Mar 5 2021 03:29:15