default_callbacks.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  */
20 #pragma once
21 #include <aws/core/auth/AWSCredentialsProviderChain.h>
22 #include <kinesis-video-producer/Auth.h>
23 #include <kinesis-video-producer/ClientCallbackProvider.h>
24 #include <kinesis-video-producer/DefaultCallbackProvider.h>
25 #include <kinesis-video-producer/DefaultDeviceInfoProvider.h>
26 
27 #define AWS_ACCESS_KEY_ENV_VAR "AWS_ACCESS_KEY_ID"
28 #define AWS_SECRET_KEY_ENV_VAR "AWS_SECRET_ACCESS_KEY"
29 #define AWS_SESSION_TOKEN_ENV_VAR "AWS_SESSION_TOKEN"
30 #define AWS_DEFAULT_CREDENTIAL_ROTATION_PERIOD_IN_SECONDS (2400)
31 
32 
33 namespace Aws {
34 namespace Kinesis {
35 
42 std::unique_ptr<com::amazonaws::kinesis::video::CredentialProvider> CreateDefaultCredentialProvider();
47 class ProducerSdkAWSCredentialsProvider : public com::amazonaws::kinesis::video::CredentialProvider
48 {
49 public:
50  ProducerSdkAWSCredentialsProvider(std::shared_ptr<Auth::DefaultAWSCredentialsProviderChain>
51  default_aws_credentials_provider = nullptr)
52  {
53  if (default_aws_credentials_provider) {
54  default_aws_credentials_provider_ = default_aws_credentials_provider;
55  } else {
57  Aws::MakeShared<Auth::DefaultAWSCredentialsProviderChain>(__func__);
58  }
59  }
60 
61 private:
62  std::shared_ptr<Auth::DefaultAWSCredentialsProviderChain> default_aws_credentials_provider_;
63 
64  void updateCredentials(com::amazonaws::kinesis::video::Credentials & producer_sdk_credentials) override
65  {
66  Auth::AWSCredentials aws_sdk_credentials =
67  default_aws_credentials_provider_->GetAWSCredentials();
68  producer_sdk_credentials.setAccessKey(aws_sdk_credentials.GetAWSAccessKeyId().c_str());
69  producer_sdk_credentials.setSecretKey(aws_sdk_credentials.GetAWSSecretKey().c_str());
70  producer_sdk_credentials.setSessionToken(aws_sdk_credentials.GetSessionToken().c_str());
71  auto now = std::chrono::duration_cast<std::chrono::seconds>(
72  std::chrono::system_clock::now().time_since_epoch());
73  auto refresh_interval = std::chrono::duration_cast<std::chrono::seconds>(
74  std::chrono::milliseconds(Auth::REFRESH_THRESHOLD));
75  producer_sdk_credentials.setExpiration(now + refresh_interval);
76  }
77 };
78 
79 class DefaultClientCallbackProvider : public com::amazonaws::kinesis::video::ClientCallbackProvider
80 {
81 public:
82  UINT64 getCallbackCustomData() override;
83  StorageOverflowPressureFunc getStorageOverflowPressureCallback() override;
84  static STATUS storageOverflowPressure(UINT64 custom_handle, UINT64 remaining_bytes);
85 };
86 
87 class DefaultStreamCallbackProvider : public com::amazonaws::kinesis::video::StreamCallbackProvider
88 {
89 public:
90  UINT64 getCallbackCustomData() override;
91  StreamConnectionStaleFunc getStreamConnectionStaleCallback() override;
92  StreamErrorReportFunc getStreamErrorReportCallback() override;
93  DroppedFrameReportFunc getDroppedFrameReportCallback() override;
94 
95 private:
96  static STATUS streamConnectionStaleHandler(UINT64 custom_data, STREAM_HANDLE stream_handle,
97  UINT64 last_buffering_ack);
98  static STATUS streamErrorReportHandler(UINT64 custom_data, STREAM_HANDLE stream_handle,
99  UPLOAD_HANDLE upload_handle, UINT64 errored_timecode,
100  STATUS status_code);
101  static STATUS droppedFrameReportHandler(UINT64 custom_data, STREAM_HANDLE stream_handle,
102  UINT64 dropped_frame_timecode);
103 };
104 
105 } // namespace Kinesis
106 } // namespace Aws
void updateCredentials(com::amazonaws::kinesis::video::Credentials &producer_sdk_credentials) override
std::unique_ptr< com::amazonaws::kinesis::video::CredentialProvider > CreateDefaultCredentialProvider()
std::shared_ptr< Auth::DefaultAWSCredentialsProviderChain > default_aws_credentials_provider_
ProducerSdkAWSCredentialsProvider(std::shared_ptr< Auth::DefaultAWSCredentialsProviderChain > default_aws_credentials_provider=nullptr)


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