default_callbacks.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/utils/logging/LogMacros.h>
17 
18 using namespace std;
19 using namespace com::amazonaws::kinesis::video;
20 
21 
22 namespace Aws {
23 namespace Kinesis {
24 
25 /*******************************
26  * Client callbacks
27  *******************************/
28 UINT64 DefaultClientCallbackProvider::getCallbackCustomData()
29 {
30  return reinterpret_cast<UINT64>(this);
31 }
32 StorageOverflowPressureFunc DefaultClientCallbackProvider::getStorageOverflowPressureCallback()
33 {
34  return storageOverflowPressure;
35 }
36 STATUS DefaultClientCallbackProvider::storageOverflowPressure(UINT64 custom_handle,
37  UINT64 remaining_bytes)
38 {
39  UNUSED_PARAM(custom_handle);
40  return STATUS_SUCCESS;
41 }
42 
43 /*******************************
44  * Credentials setup
45  *******************************/
46 unique_ptr<CredentialProvider> CreateDefaultCredentialProvider()
47 {
48  char const *access_key, *secret_key, *session_token;
49  if (nullptr == (access_key = getenv(AWS_ACCESS_KEY_ENV_VAR))) {
50  return unique_ptr<CredentialProvider>{};
51  }
52  if (nullptr == (secret_key = getenv(AWS_SECRET_KEY_ENV_VAR))) {
53  return unique_ptr<CredentialProvider>{};
54  }
55  if (nullptr == (session_token = getenv(AWS_SESSION_TOKEN_ENV_VAR))) {
56  session_token = "";
57  }
58 
59  auto now_time = std::chrono::duration_cast<std::chrono::seconds>(
60  std::chrono::system_clock::now().time_since_epoch());
61  unique_ptr<Credentials> credentials_ = make_unique<Credentials>(
62  string(access_key), string(secret_key), string(session_token),
63  now_time + std::chrono::seconds(AWS_DEFAULT_CREDENTIAL_ROTATION_PERIOD_IN_SECONDS));
64  return make_unique<StaticCredentialProvider>(*credentials_.get());
65 }
66 
67 /*******************************
68  * Stream callbacks
69  *******************************/
70 UINT64 DefaultStreamCallbackProvider::getCallbackCustomData()
71 {
72  return reinterpret_cast<UINT64>(this);
73 }
74 
75 StreamConnectionStaleFunc DefaultStreamCallbackProvider::getStreamConnectionStaleCallback()
76 {
77  return streamConnectionStaleHandler;
78 };
79 
80 StreamErrorReportFunc DefaultStreamCallbackProvider::getStreamErrorReportCallback()
81 {
82  return streamErrorReportHandler;
83 };
84 
85 DroppedFrameReportFunc DefaultStreamCallbackProvider::getDroppedFrameReportCallback()
86 {
87  return droppedFrameReportHandler;
88 };
89 
90 STATUS DefaultStreamCallbackProvider::streamConnectionStaleHandler(UINT64 custom_data,
91  STREAM_HANDLE stream_handle,
92  UINT64 last_buffering_ack)
93 {
94  AWS_LOGSTREAM_WARN(__func__, "Reporting stream stale. Last ACK received " << last_buffering_ack);
95  return STATUS_SUCCESS;
96 }
97 
98 STATUS
99 DefaultStreamCallbackProvider::streamErrorReportHandler(UINT64 custom_data,
100  STREAM_HANDLE stream_handle,
101  UPLOAD_HANDLE upload_handle,
102  UINT64 errored_timecode,
103  STATUS status_code)
104 {
105  AWS_LOGSTREAM_ERROR(__func__, "Reporting stream error. Errored timecode: "
106  << errored_timecode << " Status: " << status_code);
107  return STATUS_SUCCESS;
108 }
109 
110 STATUS
111 DefaultStreamCallbackProvider::droppedFrameReportHandler(UINT64 custom_data,
112  STREAM_HANDLE stream_handle,
113  UINT64 dropped_frame_timecode)
114 {
115  AWS_LOGSTREAM_WARN(__func__,
116  "Reporting dropped frame. Frame timecode " << dropped_frame_timecode);
117  return STATUS_SUCCESS;
118 }
119 
120 } // namespace Kinesis
121 } // namespace Aws
#define AWS_SECRET_KEY_ENV_VAR
#define AWS_DEFAULT_CREDENTIAL_ROTATION_PERIOD_IN_SECONDS
#define AWS_SESSION_TOKEN_ENV_VAR
std::unique_ptr< com::amazonaws::kinesis::video::CredentialProvider > CreateDefaultCredentialProvider()
#define AWS_ACCESS_KEY_ENV_VAR
This module provides default callbacks for use with the Kinesis Producer Library. You can implement y...


kinesis_manager
Author(s): AWS RoboMaker
autogenerated on Thu Mar 4 2021 03:28:41