Update videorecog.
This commit is contained in:
161
videorecog/src/VideorecogClient.cc
Normal file
161
videorecog/src/VideorecogClient.cc
Normal file
@@ -0,0 +1,161 @@
|
||||
/*
|
||||
* 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::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();
|
||||
}
|
||||
|
||||
51
videorecog/src/model/DetectVideoShotRequest.cc
Normal file
51
videorecog/src/model/DetectVideoShotRequest.cc
Normal file
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
* 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/model/DetectVideoShotRequest.h>
|
||||
|
||||
using AlibabaCloud::Videorecog::Model::DetectVideoShotRequest;
|
||||
|
||||
DetectVideoShotRequest::DetectVideoShotRequest() :
|
||||
RpcServiceRequest("videorecog", "2020-03-20", "DetectVideoShot")
|
||||
{
|
||||
setMethod(HttpRequest::Method::Post);
|
||||
}
|
||||
|
||||
DetectVideoShotRequest::~DetectVideoShotRequest()
|
||||
{}
|
||||
|
||||
bool DetectVideoShotRequest::getAsync()const
|
||||
{
|
||||
return async_;
|
||||
}
|
||||
|
||||
void DetectVideoShotRequest::setAsync(bool async)
|
||||
{
|
||||
async_ = async;
|
||||
setBodyParameter("Async", async ? "true" : "false");
|
||||
}
|
||||
|
||||
std::string DetectVideoShotRequest::getVideoUrl()const
|
||||
{
|
||||
return videoUrl_;
|
||||
}
|
||||
|
||||
void DetectVideoShotRequest::setVideoUrl(const std::string& videoUrl)
|
||||
{
|
||||
videoUrl_ = videoUrl;
|
||||
setBodyParameter("VideoUrl", videoUrl);
|
||||
}
|
||||
|
||||
53
videorecog/src/model/DetectVideoShotResult.cc
Normal file
53
videorecog/src/model/DetectVideoShotResult.cc
Normal file
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
* 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/model/DetectVideoShotResult.h>
|
||||
#include <json/json.h>
|
||||
|
||||
using namespace AlibabaCloud::Videorecog;
|
||||
using namespace AlibabaCloud::Videorecog::Model;
|
||||
|
||||
DetectVideoShotResult::DetectVideoShotResult() :
|
||||
ServiceResult()
|
||||
{}
|
||||
|
||||
DetectVideoShotResult::DetectVideoShotResult(const std::string &payload) :
|
||||
ServiceResult()
|
||||
{
|
||||
parse(payload);
|
||||
}
|
||||
|
||||
DetectVideoShotResult::~DetectVideoShotResult()
|
||||
{}
|
||||
|
||||
void DetectVideoShotResult::parse(const std::string &payload)
|
||||
{
|
||||
Json::Reader reader;
|
||||
Json::Value value;
|
||||
reader.parse(payload, value);
|
||||
setRequestId(value["RequestId"].asString());
|
||||
auto dataNode = value["Data"];
|
||||
auto allShotFrameIds = dataNode["ShotFrameIds"]["ShotFrameId"];
|
||||
for (auto value : allShotFrameIds)
|
||||
data_.shotFrameIds.push_back(value.asString());
|
||||
|
||||
}
|
||||
|
||||
DetectVideoShotResult::Data DetectVideoShotResult::getData()const
|
||||
{
|
||||
return data_;
|
||||
}
|
||||
|
||||
62
videorecog/src/model/GenerateVideoCoverRequest.cc
Normal file
62
videorecog/src/model/GenerateVideoCoverRequest.cc
Normal file
@@ -0,0 +1,62 @@
|
||||
/*
|
||||
* 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/model/GenerateVideoCoverRequest.h>
|
||||
|
||||
using AlibabaCloud::Videorecog::Model::GenerateVideoCoverRequest;
|
||||
|
||||
GenerateVideoCoverRequest::GenerateVideoCoverRequest() :
|
||||
RpcServiceRequest("videorecog", "2020-03-20", "GenerateVideoCover")
|
||||
{
|
||||
setMethod(HttpRequest::Method::Post);
|
||||
}
|
||||
|
||||
GenerateVideoCoverRequest::~GenerateVideoCoverRequest()
|
||||
{}
|
||||
|
||||
bool GenerateVideoCoverRequest::getIsGif()const
|
||||
{
|
||||
return isGif_;
|
||||
}
|
||||
|
||||
void GenerateVideoCoverRequest::setIsGif(bool isGif)
|
||||
{
|
||||
isGif_ = isGif;
|
||||
setBodyParameter("IsGif", isGif ? "true" : "false");
|
||||
}
|
||||
|
||||
bool GenerateVideoCoverRequest::getAsync()const
|
||||
{
|
||||
return async_;
|
||||
}
|
||||
|
||||
void GenerateVideoCoverRequest::setAsync(bool async)
|
||||
{
|
||||
async_ = async;
|
||||
setBodyParameter("Async", async ? "true" : "false");
|
||||
}
|
||||
|
||||
std::string GenerateVideoCoverRequest::getVideoUrl()const
|
||||
{
|
||||
return videoUrl_;
|
||||
}
|
||||
|
||||
void GenerateVideoCoverRequest::setVideoUrl(const std::string& videoUrl)
|
||||
{
|
||||
videoUrl_ = videoUrl;
|
||||
setBodyParameter("VideoUrl", videoUrl);
|
||||
}
|
||||
|
||||
60
videorecog/src/model/GenerateVideoCoverResult.cc
Normal file
60
videorecog/src/model/GenerateVideoCoverResult.cc
Normal file
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
* 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/model/GenerateVideoCoverResult.h>
|
||||
#include <json/json.h>
|
||||
|
||||
using namespace AlibabaCloud::Videorecog;
|
||||
using namespace AlibabaCloud::Videorecog::Model;
|
||||
|
||||
GenerateVideoCoverResult::GenerateVideoCoverResult() :
|
||||
ServiceResult()
|
||||
{}
|
||||
|
||||
GenerateVideoCoverResult::GenerateVideoCoverResult(const std::string &payload) :
|
||||
ServiceResult()
|
||||
{
|
||||
parse(payload);
|
||||
}
|
||||
|
||||
GenerateVideoCoverResult::~GenerateVideoCoverResult()
|
||||
{}
|
||||
|
||||
void GenerateVideoCoverResult::parse(const std::string &payload)
|
||||
{
|
||||
Json::Reader reader;
|
||||
Json::Value value;
|
||||
reader.parse(payload, value);
|
||||
setRequestId(value["RequestId"].asString());
|
||||
auto dataNode = value["Data"];
|
||||
auto allOutputsNode = dataNode["Outputs"]["Output"];
|
||||
for (auto dataNodeOutputsOutput : allOutputsNode)
|
||||
{
|
||||
Data::Output outputObject;
|
||||
if(!dataNodeOutputsOutput["ImageURL"].isNull())
|
||||
outputObject.imageURL = dataNodeOutputsOutput["ImageURL"].asString();
|
||||
if(!dataNodeOutputsOutput["Confidence"].isNull())
|
||||
outputObject.confidence = std::stof(dataNodeOutputsOutput["Confidence"].asString());
|
||||
data_.outputs.push_back(outputObject);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
GenerateVideoCoverResult::Data GenerateVideoCoverResult::getData()const
|
||||
{
|
||||
return data_;
|
||||
}
|
||||
|
||||
51
videorecog/src/model/GetAsyncJobResultRequest.cc
Normal file
51
videorecog/src/model/GetAsyncJobResultRequest.cc
Normal file
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
* 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/model/GetAsyncJobResultRequest.h>
|
||||
|
||||
using AlibabaCloud::Videorecog::Model::GetAsyncJobResultRequest;
|
||||
|
||||
GetAsyncJobResultRequest::GetAsyncJobResultRequest() :
|
||||
RpcServiceRequest("videorecog", "2020-03-20", "GetAsyncJobResult")
|
||||
{
|
||||
setMethod(HttpRequest::Method::Post);
|
||||
}
|
||||
|
||||
GetAsyncJobResultRequest::~GetAsyncJobResultRequest()
|
||||
{}
|
||||
|
||||
bool GetAsyncJobResultRequest::getAsync()const
|
||||
{
|
||||
return async_;
|
||||
}
|
||||
|
||||
void GetAsyncJobResultRequest::setAsync(bool async)
|
||||
{
|
||||
async_ = async;
|
||||
setBodyParameter("Async", async ? "true" : "false");
|
||||
}
|
||||
|
||||
std::string GetAsyncJobResultRequest::getJobId()const
|
||||
{
|
||||
return jobId_;
|
||||
}
|
||||
|
||||
void GetAsyncJobResultRequest::setJobId(const std::string& jobId)
|
||||
{
|
||||
jobId_ = jobId;
|
||||
setBodyParameter("JobId", jobId);
|
||||
}
|
||||
|
||||
60
videorecog/src/model/GetAsyncJobResultResult.cc
Normal file
60
videorecog/src/model/GetAsyncJobResultResult.cc
Normal file
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
* 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/model/GetAsyncJobResultResult.h>
|
||||
#include <json/json.h>
|
||||
|
||||
using namespace AlibabaCloud::Videorecog;
|
||||
using namespace AlibabaCloud::Videorecog::Model;
|
||||
|
||||
GetAsyncJobResultResult::GetAsyncJobResultResult() :
|
||||
ServiceResult()
|
||||
{}
|
||||
|
||||
GetAsyncJobResultResult::GetAsyncJobResultResult(const std::string &payload) :
|
||||
ServiceResult()
|
||||
{
|
||||
parse(payload);
|
||||
}
|
||||
|
||||
GetAsyncJobResultResult::~GetAsyncJobResultResult()
|
||||
{}
|
||||
|
||||
void GetAsyncJobResultResult::parse(const std::string &payload)
|
||||
{
|
||||
Json::Reader reader;
|
||||
Json::Value value;
|
||||
reader.parse(payload, value);
|
||||
setRequestId(value["RequestId"].asString());
|
||||
auto dataNode = value["Data"];
|
||||
if(!dataNode["JobId"].isNull())
|
||||
data_.jobId = dataNode["JobId"].asString();
|
||||
if(!dataNode["Status"].isNull())
|
||||
data_.status = dataNode["Status"].asString();
|
||||
if(!dataNode["Result"].isNull())
|
||||
data_.result = dataNode["Result"].asString();
|
||||
if(!dataNode["ErrorCode"].isNull())
|
||||
data_.errorCode = dataNode["ErrorCode"].asString();
|
||||
if(!dataNode["ErrorMessage"].isNull())
|
||||
data_.errorMessage = dataNode["ErrorMessage"].asString();
|
||||
|
||||
}
|
||||
|
||||
GetAsyncJobResultResult::Data GetAsyncJobResultResult::getData()const
|
||||
{
|
||||
return data_;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user