main.cpp
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 #include <aws/core/Aws.h>
16 #include <aws/core/utils/logging/LogMacros.h>
24 #include <ros/ros.h>
25 
26 using namespace Aws::Client;
27 using namespace Aws::Kinesis;
28 
29 
30 #ifndef RETURN_CODE_MASK
31 #define RETURN_CODE_MASK (0xff) /* Process exit code is in range (0, 255) */
32 #endif
33 
34 #ifndef UNKNOWN_ERROR_KINESIS_VIDEO_EXIT_CODE
35 #define UNKNOWN_ERROR_KINESIS_VIDEO_EXIT_CODE (0xf0)
36 #endif
37 
38 constexpr char kNodeName[] = "kinesis_video_streamer";
39 
40 int shutdown(Aws::SDKOptions options, int return_code) {
41  AWS_LOG_INFO(__func__, "Shutting down Kinesis Video Node...");
42  Aws::Utils::Logging::ShutdownAWSLogging();
43  Aws::ShutdownAPI(options);
44  return return_code & RETURN_CODE_MASK;
45 }
46 
47 int main(int argc, char * argv[])
48 {
49  int return_code = UNKNOWN_ERROR_KINESIS_VIDEO_EXIT_CODE;
50 
51  ros::init(argc, argv, kNodeName);
52  StreamerNode streamer("~");
53 
54  Aws::Utils::Logging::InitializeAWSLogging(
55  Aws::MakeShared<Aws::Utils::Logging::AWSROSLogger>(kNodeName));
56  Aws::SDKOptions options;
57  Aws::InitAPI(options);
58 
59  KinesisManagerStatus status = streamer.Initialize();
60  if (!KINESIS_MANAGER_STATUS_SUCCEEDED(status)) {
61  return shutdown(options, status);
62  }
63 
64  status = streamer.InitializeStreamSubscriptions();
65  if (!KINESIS_MANAGER_STATUS_SUCCEEDED(status)) {
66  return shutdown(options, status);
67  }
68 
69  AWS_LOG_INFO(__func__, "Starting Kinesis Video Node...");
70  streamer.Spin();
71 
72  return shutdown(options, return_code);
73 }
enum Aws::Kinesis::kinesis_manager_status_e KinesisManagerStatus
ROSCPP_DECL void init(int &argc, char **argv, const std::string &name, uint32_t options=0)
#define KINESIS_MANAGER_STATUS_SUCCEEDED(status)
KinesisManagerStatus Initialize()
Definition: streamer.cpp:64
#define UNKNOWN_ERROR_KINESIS_VIDEO_EXIT_CODE
Definition: main.cpp:35
int shutdown(Aws::SDKOptions options, int return_code)
Definition: main.cpp:40
KinesisManagerStatus InitializeStreamSubscriptions()
Definition: streamer.cpp:93
#define RETURN_CODE_MASK
Definition: main.cpp:31
constexpr char kNodeName[]
Definition: main.cpp:38
int main(int argc, char *argv[])
Definition: main.cpp:47


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