237 lines
11 KiB
C++
237 lines
11 KiB
C++
|
|
/**
|
|||
|
|
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|||
|
|
* SPDX-License-Identifier: Apache-2.0.
|
|||
|
|
*/
|
|||
|
|
|
|||
|
|
#include <aws/core/utils/Outcome.h>
|
|||
|
|
#include <aws/core/auth/AWSAuthSigner.h>
|
|||
|
|
#include <aws/core/client/CoreErrors.h>
|
|||
|
|
#include <aws/core/client/RetryStrategy.h>
|
|||
|
|
#include <aws/core/http/HttpClient.h>
|
|||
|
|
#include <aws/core/http/HttpResponse.h>
|
|||
|
|
#include <aws/core/http/HttpClientFactory.h>
|
|||
|
|
#include <aws/core/auth/AWSCredentialsProviderChain.h>
|
|||
|
|
#include <aws/core/utils/json/JsonSerializer.h>
|
|||
|
|
#include <aws/core/utils/memory/stl/AWSStringStream.h>
|
|||
|
|
#include <aws/core/utils/threading/Executor.h>
|
|||
|
|
#include <aws/core/utils/DNS.h>
|
|||
|
|
#include <aws/core/utils/logging/LogMacros.h>
|
|||
|
|
|
|||
|
|
#include <aws/kinesis-video-archived-media/KinesisVideoArchivedMediaClient.h>
|
|||
|
|
#include <aws/kinesis-video-archived-media/KinesisVideoArchivedMediaEndpoint.h>
|
|||
|
|
#include <aws/kinesis-video-archived-media/KinesisVideoArchivedMediaErrorMarshaller.h>
|
|||
|
|
#include <aws/kinesis-video-archived-media/model/GetClipRequest.h>
|
|||
|
|
#include <aws/kinesis-video-archived-media/model/GetDASHStreamingSessionURLRequest.h>
|
|||
|
|
#include <aws/kinesis-video-archived-media/model/GetHLSStreamingSessionURLRequest.h>
|
|||
|
|
#include <aws/kinesis-video-archived-media/model/GetMediaForFragmentListRequest.h>
|
|||
|
|
#include <aws/kinesis-video-archived-media/model/ListFragmentsRequest.h>
|
|||
|
|
|
|||
|
|
using namespace Aws;
|
|||
|
|
using namespace Aws::Auth;
|
|||
|
|
using namespace Aws::Client;
|
|||
|
|
using namespace Aws::KinesisVideoArchivedMedia;
|
|||
|
|
using namespace Aws::KinesisVideoArchivedMedia::Model;
|
|||
|
|
using namespace Aws::Http;
|
|||
|
|
using namespace Aws::Utils::Json;
|
|||
|
|
|
|||
|
|
static const char* SERVICE_NAME = "kinesisvideo";
|
|||
|
|
static const char* ALLOCATION_TAG = "KinesisVideoArchivedMediaClient";
|
|||
|
|
|
|||
|
|
|
|||
|
|
KinesisVideoArchivedMediaClient::KinesisVideoArchivedMediaClient(const Client::ClientConfiguration& clientConfiguration) :
|
|||
|
|
BASECLASS(clientConfiguration,
|
|||
|
|
Aws::MakeShared<AWSAuthV4Signer>(ALLOCATION_TAG, Aws::MakeShared<DefaultAWSCredentialsProviderChain>(ALLOCATION_TAG),
|
|||
|
|
SERVICE_NAME, Aws::Region::ComputeSignerRegion(clientConfiguration.region)),
|
|||
|
|
Aws::MakeShared<KinesisVideoArchivedMediaErrorMarshaller>(ALLOCATION_TAG)),
|
|||
|
|
m_executor(clientConfiguration.executor)
|
|||
|
|
{
|
|||
|
|
init(clientConfiguration);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
KinesisVideoArchivedMediaClient::KinesisVideoArchivedMediaClient(const AWSCredentials& credentials, const Client::ClientConfiguration& clientConfiguration) :
|
|||
|
|
BASECLASS(clientConfiguration,
|
|||
|
|
Aws::MakeShared<AWSAuthV4Signer>(ALLOCATION_TAG, Aws::MakeShared<SimpleAWSCredentialsProvider>(ALLOCATION_TAG, credentials),
|
|||
|
|
SERVICE_NAME, Aws::Region::ComputeSignerRegion(clientConfiguration.region)),
|
|||
|
|
Aws::MakeShared<KinesisVideoArchivedMediaErrorMarshaller>(ALLOCATION_TAG)),
|
|||
|
|
m_executor(clientConfiguration.executor)
|
|||
|
|
{
|
|||
|
|
init(clientConfiguration);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
KinesisVideoArchivedMediaClient::KinesisVideoArchivedMediaClient(const std::shared_ptr<AWSCredentialsProvider>& credentialsProvider,
|
|||
|
|
const Client::ClientConfiguration& clientConfiguration) :
|
|||
|
|
BASECLASS(clientConfiguration,
|
|||
|
|
Aws::MakeShared<AWSAuthV4Signer>(ALLOCATION_TAG, credentialsProvider,
|
|||
|
|
SERVICE_NAME, Aws::Region::ComputeSignerRegion(clientConfiguration.region)),
|
|||
|
|
Aws::MakeShared<KinesisVideoArchivedMediaErrorMarshaller>(ALLOCATION_TAG)),
|
|||
|
|
m_executor(clientConfiguration.executor)
|
|||
|
|
{
|
|||
|
|
init(clientConfiguration);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
KinesisVideoArchivedMediaClient::~KinesisVideoArchivedMediaClient()
|
|||
|
|
{
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
void KinesisVideoArchivedMediaClient::init(const ClientConfiguration& config)
|
|||
|
|
{
|
|||
|
|
SetServiceClientName("Kinesis Video Archived Media");
|
|||
|
|
m_configScheme = SchemeMapper::ToString(config.scheme);
|
|||
|
|
if (config.endpointOverride.empty())
|
|||
|
|
{
|
|||
|
|
m_uri = m_configScheme + "://" + KinesisVideoArchivedMediaEndpoint::ForRegion(config.region, config.useDualStack);
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
OverrideEndpoint(config.endpointOverride);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
void KinesisVideoArchivedMediaClient::OverrideEndpoint(const Aws::String& endpoint)
|
|||
|
|
{
|
|||
|
|
if (endpoint.compare(0, 7, "http://") == 0 || endpoint.compare(0, 8, "https://") == 0)
|
|||
|
|
{
|
|||
|
|
m_uri = endpoint;
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
m_uri = m_configScheme + "://" + endpoint;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
GetClipOutcome KinesisVideoArchivedMediaClient::GetClip(const GetClipRequest& request) const
|
|||
|
|
{
|
|||
|
|
Aws::Http::URI uri = m_uri;
|
|||
|
|
Aws::StringStream ss;
|
|||
|
|
ss << "/getClip";
|
|||
|
|
uri.SetPath(uri.GetPath() + ss.str());
|
|||
|
|
return GetClipOutcome(MakeRequestWithUnparsedResponse(uri, request, Aws::Http::HttpMethod::HTTP_POST));
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
GetClipOutcomeCallable KinesisVideoArchivedMediaClient::GetClipCallable(const GetClipRequest& request) const
|
|||
|
|
{
|
|||
|
|
auto task = Aws::MakeShared< std::packaged_task< GetClipOutcome() > >(ALLOCATION_TAG, [this, request](){ return this->GetClip(request); } );
|
|||
|
|
auto packagedFunction = [task]() { (*task)(); };
|
|||
|
|
m_executor->Submit(packagedFunction);
|
|||
|
|
return task->get_future();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
void KinesisVideoArchivedMediaClient::GetClipAsync(const GetClipRequest& request, const GetClipResponseReceivedHandler& handler, const std::shared_ptr<const Aws::Client::AsyncCallerContext>& context) const
|
|||
|
|
{
|
|||
|
|
m_executor->Submit( [this, request, handler, context](){ this->GetClipAsyncHelper( request, handler, context ); } );
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
void KinesisVideoArchivedMediaClient::GetClipAsyncHelper(const GetClipRequest& request, const GetClipResponseReceivedHandler& handler, const std::shared_ptr<const Aws::Client::AsyncCallerContext>& context) const
|
|||
|
|
{
|
|||
|
|
handler(this, request, GetClip(request), context);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
GetDASHStreamingSessionURLOutcome KinesisVideoArchivedMediaClient::GetDASHStreamingSessionURL(const GetDASHStreamingSessionURLRequest& request) const
|
|||
|
|
{
|
|||
|
|
Aws::Http::URI uri = m_uri;
|
|||
|
|
Aws::StringStream ss;
|
|||
|
|
ss << "/getDASHStreamingSessionURL";
|
|||
|
|
uri.SetPath(uri.GetPath() + ss.str());
|
|||
|
|
return GetDASHStreamingSessionURLOutcome(MakeRequest(uri, request, Aws::Http::HttpMethod::HTTP_POST, Aws::Auth::SIGV4_SIGNER));
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
GetDASHStreamingSessionURLOutcomeCallable KinesisVideoArchivedMediaClient::GetDASHStreamingSessionURLCallable(const GetDASHStreamingSessionURLRequest& request) const
|
|||
|
|
{
|
|||
|
|
auto task = Aws::MakeShared< std::packaged_task< GetDASHStreamingSessionURLOutcome() > >(ALLOCATION_TAG, [this, request](){ return this->GetDASHStreamingSessionURL(request); } );
|
|||
|
|
auto packagedFunction = [task]() { (*task)(); };
|
|||
|
|
m_executor->Submit(packagedFunction);
|
|||
|
|
return task->get_future();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
void KinesisVideoArchivedMediaClient::GetDASHStreamingSessionURLAsync(const GetDASHStreamingSessionURLRequest& request, const GetDASHStreamingSessionURLResponseReceivedHandler& handler, const std::shared_ptr<const Aws::Client::AsyncCallerContext>& context) const
|
|||
|
|
{
|
|||
|
|
m_executor->Submit( [this, request, handler, context](){ this->GetDASHStreamingSessionURLAsyncHelper( request, handler, context ); } );
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
void KinesisVideoArchivedMediaClient::GetDASHStreamingSessionURLAsyncHelper(const GetDASHStreamingSessionURLRequest& request, const GetDASHStreamingSessionURLResponseReceivedHandler& handler, const std::shared_ptr<const Aws::Client::AsyncCallerContext>& context) const
|
|||
|
|
{
|
|||
|
|
handler(this, request, GetDASHStreamingSessionURL(request), context);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
GetHLSStreamingSessionURLOutcome KinesisVideoArchivedMediaClient::GetHLSStreamingSessionURL(const GetHLSStreamingSessionURLRequest& request) const
|
|||
|
|
{
|
|||
|
|
Aws::Http::URI uri = m_uri;
|
|||
|
|
Aws::StringStream ss;
|
|||
|
|
ss << "/getHLSStreamingSessionURL";
|
|||
|
|
uri.SetPath(uri.GetPath() + ss.str());
|
|||
|
|
return GetHLSStreamingSessionURLOutcome(MakeRequest(uri, request, Aws::Http::HttpMethod::HTTP_POST, Aws::Auth::SIGV4_SIGNER));
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
GetHLSStreamingSessionURLOutcomeCallable KinesisVideoArchivedMediaClient::GetHLSStreamingSessionURLCallable(const GetHLSStreamingSessionURLRequest& request) const
|
|||
|
|
{
|
|||
|
|
auto task = Aws::MakeShared< std::packaged_task< GetHLSStreamingSessionURLOutcome() > >(ALLOCATION_TAG, [this, request](){ return this->GetHLSStreamingSessionURL(request); } );
|
|||
|
|
auto packagedFunction = [task]() { (*task)(); };
|
|||
|
|
m_executor->Submit(packagedFunction);
|
|||
|
|
return task->get_future();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
void KinesisVideoArchivedMediaClient::GetHLSStreamingSessionURLAsync(const GetHLSStreamingSessionURLRequest& request, const GetHLSStreamingSessionURLResponseReceivedHandler& handler, const std::shared_ptr<const Aws::Client::AsyncCallerContext>& context) const
|
|||
|
|
{
|
|||
|
|
m_executor->Submit( [this, request, handler, context](){ this->GetHLSStreamingSessionURLAsyncHelper( request, handler, context ); } );
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
void KinesisVideoArchivedMediaClient::GetHLSStreamingSessionURLAsyncHelper(const GetHLSStreamingSessionURLRequest& request, const GetHLSStreamingSessionURLResponseReceivedHandler& handler, const std::shared_ptr<const Aws::Client::AsyncCallerContext>& context) const
|
|||
|
|
{
|
|||
|
|
handler(this, request, GetHLSStreamingSessionURL(request), context);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
GetMediaForFragmentListOutcome KinesisVideoArchivedMediaClient::GetMediaForFragmentList(const GetMediaForFragmentListRequest& request) const
|
|||
|
|
{
|
|||
|
|
Aws::Http::URI uri = m_uri;
|
|||
|
|
Aws::StringStream ss;
|
|||
|
|
ss << "/getMediaForFragmentList";
|
|||
|
|
uri.SetPath(uri.GetPath() + ss.str());
|
|||
|
|
return GetMediaForFragmentListOutcome(MakeRequestWithUnparsedResponse(uri, request, Aws::Http::HttpMethod::HTTP_POST));
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
GetMediaForFragmentListOutcomeCallable KinesisVideoArchivedMediaClient::GetMediaForFragmentListCallable(const GetMediaForFragmentListRequest& request) const
|
|||
|
|
{
|
|||
|
|
auto task = Aws::MakeShared< std::packaged_task< GetMediaForFragmentListOutcome() > >(ALLOCATION_TAG, [this, request](){ return this->GetMediaForFragmentList(request); } );
|
|||
|
|
auto packagedFunction = [task]() { (*task)(); };
|
|||
|
|
m_executor->Submit(packagedFunction);
|
|||
|
|
return task->get_future();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
void KinesisVideoArchivedMediaClient::GetMediaForFragmentListAsync(const GetMediaForFragmentListRequest& request, const GetMediaForFragmentListResponseReceivedHandler& handler, const std::shared_ptr<const Aws::Client::AsyncCallerContext>& context) const
|
|||
|
|
{
|
|||
|
|
m_executor->Submit( [this, request, handler, context](){ this->GetMediaForFragmentListAsyncHelper( request, handler, context ); } );
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
void KinesisVideoArchivedMediaClient::GetMediaForFragmentListAsyncHelper(const GetMediaForFragmentListRequest& request, const GetMediaForFragmentListResponseReceivedHandler& handler, const std::shared_ptr<const Aws::Client::AsyncCallerContext>& context) const
|
|||
|
|
{
|
|||
|
|
handler(this, request, GetMediaForFragmentList(request), context);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
ListFragmentsOutcome KinesisVideoArchivedMediaClient::ListFragments(const ListFragmentsRequest& request) const
|
|||
|
|
{
|
|||
|
|
Aws::Http::URI uri = m_uri;
|
|||
|
|
Aws::StringStream ss;
|
|||
|
|
ss << "/listFragments";
|
|||
|
|
uri.SetPath(uri.GetPath() + ss.str());
|
|||
|
|
return ListFragmentsOutcome(MakeRequest(uri, request, Aws::Http::HttpMethod::HTTP_POST, Aws::Auth::SIGV4_SIGNER));
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
ListFragmentsOutcomeCallable KinesisVideoArchivedMediaClient::ListFragmentsCallable(const ListFragmentsRequest& request) const
|
|||
|
|
{
|
|||
|
|
auto task = Aws::MakeShared< std::packaged_task< ListFragmentsOutcome() > >(ALLOCATION_TAG, [this, request](){ return this->ListFragments(request); } );
|
|||
|
|
auto packagedFunction = [task]() { (*task)(); };
|
|||
|
|
m_executor->Submit(packagedFunction);
|
|||
|
|
return task->get_future();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
void KinesisVideoArchivedMediaClient::ListFragmentsAsync(const ListFragmentsRequest& request, const ListFragmentsResponseReceivedHandler& handler, const std::shared_ptr<const Aws::Client::AsyncCallerContext>& context) const
|
|||
|
|
{
|
|||
|
|
m_executor->Submit( [this, request, handler, context](){ this->ListFragmentsAsyncHelper( request, handler, context ); } );
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
void KinesisVideoArchivedMediaClient::ListFragmentsAsyncHelper(const ListFragmentsRequest& request, const ListFragmentsResponseReceivedHandler& handler, const std::shared_ptr<const Aws::Client::AsyncCallerContext>& context) const
|
|||
|
|
{
|
|||
|
|
handler(this, request, ListFragments(request), context);
|
|||
|
|
}
|
|||
|
|
|