| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305 |
- /*
- * Copyright 2009-2017 Alibaba Cloud All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
- #include <alibabacloud/videorecog/VideorecogClient.h>
- #include <alibabacloud/core/SimpleCredentialsProvider.h>
- using namespace AlibabaCloud;
- using namespace AlibabaCloud::Location;
- using namespace AlibabaCloud::Videorecog;
- using namespace AlibabaCloud::Videorecog::Model;
- namespace
- {
- const std::string SERVICE_NAME = "videorecog";
- }
- VideorecogClient::VideorecogClient(const Credentials &credentials, const ClientConfiguration &configuration) :
- RpcServiceClient(SERVICE_NAME, std::make_shared<SimpleCredentialsProvider>(credentials), configuration)
- {
- auto locationClient = std::make_shared<LocationClient>(credentials, configuration);
- endpointProvider_ = std::make_shared<EndpointProvider>(locationClient, configuration.regionId(), SERVICE_NAME, "videorecog");
- }
- VideorecogClient::VideorecogClient(const std::shared_ptr<CredentialsProvider>& credentialsProvider, const ClientConfiguration & configuration) :
- RpcServiceClient(SERVICE_NAME, credentialsProvider, configuration)
- {
- auto locationClient = std::make_shared<LocationClient>(credentialsProvider, configuration);
- endpointProvider_ = std::make_shared<EndpointProvider>(locationClient, configuration.regionId(), SERVICE_NAME, "videorecog");
- }
- VideorecogClient::VideorecogClient(const std::string & accessKeyId, const std::string & accessKeySecret, const ClientConfiguration & configuration) :
- RpcServiceClient(SERVICE_NAME, std::make_shared<SimpleCredentialsProvider>(accessKeyId, accessKeySecret), configuration)
- {
- auto locationClient = std::make_shared<LocationClient>(accessKeyId, accessKeySecret, configuration);
- endpointProvider_ = std::make_shared<EndpointProvider>(locationClient, configuration.regionId(), SERVICE_NAME, "videorecog");
- }
- VideorecogClient::~VideorecogClient()
- {}
- VideorecogClient::DetectVideoShotOutcome VideorecogClient::detectVideoShot(const DetectVideoShotRequest &request) const
- {
- auto endpointOutcome = endpointProvider_->getEndpoint();
- if (!endpointOutcome.isSuccess())
- return DetectVideoShotOutcome(endpointOutcome.error());
- auto outcome = makeRequest(endpointOutcome.result(), request);
- if (outcome.isSuccess())
- return DetectVideoShotOutcome(DetectVideoShotResult(outcome.result()));
- else
- return DetectVideoShotOutcome(outcome.error());
- }
- void VideorecogClient::detectVideoShotAsync(const DetectVideoShotRequest& request, const DetectVideoShotAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context) const
- {
- auto fn = [this, request, handler, context]()
- {
- handler(this, request, detectVideoShot(request), context);
- };
- asyncExecute(new Runnable(fn));
- }
- VideorecogClient::DetectVideoShotOutcomeCallable VideorecogClient::detectVideoShotCallable(const DetectVideoShotRequest &request) const
- {
- auto task = std::make_shared<std::packaged_task<DetectVideoShotOutcome()>>(
- [this, request]()
- {
- return this->detectVideoShot(request);
- });
- asyncExecute(new Runnable([task]() { (*task)(); }));
- return task->get_future();
- }
- VideorecogClient::EvaluateVideoQualityOutcome VideorecogClient::evaluateVideoQuality(const EvaluateVideoQualityRequest &request) const
- {
- auto endpointOutcome = endpointProvider_->getEndpoint();
- if (!endpointOutcome.isSuccess())
- return EvaluateVideoQualityOutcome(endpointOutcome.error());
- auto outcome = makeRequest(endpointOutcome.result(), request);
- if (outcome.isSuccess())
- return EvaluateVideoQualityOutcome(EvaluateVideoQualityResult(outcome.result()));
- else
- return EvaluateVideoQualityOutcome(outcome.error());
- }
- void VideorecogClient::evaluateVideoQualityAsync(const EvaluateVideoQualityRequest& request, const EvaluateVideoQualityAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context) const
- {
- auto fn = [this, request, handler, context]()
- {
- handler(this, request, evaluateVideoQuality(request), context);
- };
- asyncExecute(new Runnable(fn));
- }
- VideorecogClient::EvaluateVideoQualityOutcomeCallable VideorecogClient::evaluateVideoQualityCallable(const EvaluateVideoQualityRequest &request) const
- {
- auto task = std::make_shared<std::packaged_task<EvaluateVideoQualityOutcome()>>(
- [this, request]()
- {
- return this->evaluateVideoQuality(request);
- });
- asyncExecute(new Runnable([task]() { (*task)(); }));
- return task->get_future();
- }
- VideorecogClient::GenerateVideoCoverOutcome VideorecogClient::generateVideoCover(const GenerateVideoCoverRequest &request) const
- {
- auto endpointOutcome = endpointProvider_->getEndpoint();
- if (!endpointOutcome.isSuccess())
- return GenerateVideoCoverOutcome(endpointOutcome.error());
- auto outcome = makeRequest(endpointOutcome.result(), request);
- if (outcome.isSuccess())
- return GenerateVideoCoverOutcome(GenerateVideoCoverResult(outcome.result()));
- else
- return GenerateVideoCoverOutcome(outcome.error());
- }
- void VideorecogClient::generateVideoCoverAsync(const GenerateVideoCoverRequest& request, const GenerateVideoCoverAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context) const
- {
- auto fn = [this, request, handler, context]()
- {
- handler(this, request, generateVideoCover(request), context);
- };
- asyncExecute(new Runnable(fn));
- }
- VideorecogClient::GenerateVideoCoverOutcomeCallable VideorecogClient::generateVideoCoverCallable(const GenerateVideoCoverRequest &request) const
- {
- auto task = std::make_shared<std::packaged_task<GenerateVideoCoverOutcome()>>(
- [this, request]()
- {
- return this->generateVideoCover(request);
- });
- asyncExecute(new Runnable([task]() { (*task)(); }));
- return task->get_future();
- }
- VideorecogClient::GetAsyncJobResultOutcome VideorecogClient::getAsyncJobResult(const GetAsyncJobResultRequest &request) const
- {
- auto endpointOutcome = endpointProvider_->getEndpoint();
- if (!endpointOutcome.isSuccess())
- return GetAsyncJobResultOutcome(endpointOutcome.error());
- auto outcome = makeRequest(endpointOutcome.result(), request);
- if (outcome.isSuccess())
- return GetAsyncJobResultOutcome(GetAsyncJobResultResult(outcome.result()));
- else
- return GetAsyncJobResultOutcome(outcome.error());
- }
- void VideorecogClient::getAsyncJobResultAsync(const GetAsyncJobResultRequest& request, const GetAsyncJobResultAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context) const
- {
- auto fn = [this, request, handler, context]()
- {
- handler(this, request, getAsyncJobResult(request), context);
- };
- asyncExecute(new Runnable(fn));
- }
- VideorecogClient::GetAsyncJobResultOutcomeCallable VideorecogClient::getAsyncJobResultCallable(const GetAsyncJobResultRequest &request) const
- {
- auto task = std::make_shared<std::packaged_task<GetAsyncJobResultOutcome()>>(
- [this, request]()
- {
- return this->getAsyncJobResult(request);
- });
- asyncExecute(new Runnable([task]() { (*task)(); }));
- return task->get_future();
- }
- VideorecogClient::RecognizeVideoCastCrewListOutcome VideorecogClient::recognizeVideoCastCrewList(const RecognizeVideoCastCrewListRequest &request) const
- {
- auto endpointOutcome = endpointProvider_->getEndpoint();
- if (!endpointOutcome.isSuccess())
- return RecognizeVideoCastCrewListOutcome(endpointOutcome.error());
- auto outcome = makeRequest(endpointOutcome.result(), request);
- if (outcome.isSuccess())
- return RecognizeVideoCastCrewListOutcome(RecognizeVideoCastCrewListResult(outcome.result()));
- else
- return RecognizeVideoCastCrewListOutcome(outcome.error());
- }
- void VideorecogClient::recognizeVideoCastCrewListAsync(const RecognizeVideoCastCrewListRequest& request, const RecognizeVideoCastCrewListAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context) const
- {
- auto fn = [this, request, handler, context]()
- {
- handler(this, request, recognizeVideoCastCrewList(request), context);
- };
- asyncExecute(new Runnable(fn));
- }
- VideorecogClient::RecognizeVideoCastCrewListOutcomeCallable VideorecogClient::recognizeVideoCastCrewListCallable(const RecognizeVideoCastCrewListRequest &request) const
- {
- auto task = std::make_shared<std::packaged_task<RecognizeVideoCastCrewListOutcome()>>(
- [this, request]()
- {
- return this->recognizeVideoCastCrewList(request);
- });
- asyncExecute(new Runnable([task]() { (*task)(); }));
- return task->get_future();
- }
- VideorecogClient::SplitVideoPartsOutcome VideorecogClient::splitVideoParts(const SplitVideoPartsRequest &request) const
- {
- auto endpointOutcome = endpointProvider_->getEndpoint();
- if (!endpointOutcome.isSuccess())
- return SplitVideoPartsOutcome(endpointOutcome.error());
- auto outcome = makeRequest(endpointOutcome.result(), request);
- if (outcome.isSuccess())
- return SplitVideoPartsOutcome(SplitVideoPartsResult(outcome.result()));
- else
- return SplitVideoPartsOutcome(outcome.error());
- }
- void VideorecogClient::splitVideoPartsAsync(const SplitVideoPartsRequest& request, const SplitVideoPartsAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context) const
- {
- auto fn = [this, request, handler, context]()
- {
- handler(this, request, splitVideoParts(request), context);
- };
- asyncExecute(new Runnable(fn));
- }
- VideorecogClient::SplitVideoPartsOutcomeCallable VideorecogClient::splitVideoPartsCallable(const SplitVideoPartsRequest &request) const
- {
- auto task = std::make_shared<std::packaged_task<SplitVideoPartsOutcome()>>(
- [this, request]()
- {
- return this->splitVideoParts(request);
- });
- asyncExecute(new Runnable([task]() { (*task)(); }));
- return task->get_future();
- }
- VideorecogClient::UnderstandVideoContentOutcome VideorecogClient::understandVideoContent(const UnderstandVideoContentRequest &request) const
- {
- auto endpointOutcome = endpointProvider_->getEndpoint();
- if (!endpointOutcome.isSuccess())
- return UnderstandVideoContentOutcome(endpointOutcome.error());
- auto outcome = makeRequest(endpointOutcome.result(), request);
- if (outcome.isSuccess())
- return UnderstandVideoContentOutcome(UnderstandVideoContentResult(outcome.result()));
- else
- return UnderstandVideoContentOutcome(outcome.error());
- }
- void VideorecogClient::understandVideoContentAsync(const UnderstandVideoContentRequest& request, const UnderstandVideoContentAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context) const
- {
- auto fn = [this, request, handler, context]()
- {
- handler(this, request, understandVideoContent(request), context);
- };
- asyncExecute(new Runnable(fn));
- }
- VideorecogClient::UnderstandVideoContentOutcomeCallable VideorecogClient::understandVideoContentCallable(const UnderstandVideoContentRequest &request) const
- {
- auto task = std::make_shared<std::packaged_task<UnderstandVideoContentOutcome()>>(
- [this, request]()
- {
- return this->understandVideoContent(request);
- });
- asyncExecute(new Runnable([task]() { (*task)(); }));
- return task->get_future();
- }
|