本篇文档提供了C/C++ SDK媒资管理模块相关功能的API调用示例。主要包含搜索媒资信息、获取视频信息、修改视频信息、删除视频、获取源文件信息、获取图片信息、删除图片信息等。
初始化客户端
使用前请先初始化客户端,请参见初始化。
搜索媒资信息
调用SearchMedia接口,完成搜索媒资信息功能。
接口参数和返回字段请参见SearchMedia。调用示例如下:
#include <stdio.h>
#include <string>
#include <map>
#include "vod_sdk/openApiUtil.h"
/**
* 搜索媒资信息
*/
VodApiResponse searchMedia(VodCredential authInfo) {
string apiName = "SearchMedia";
map<string, string> args;
args["Fields"] = "Title,CoverURL,Status";
args["Match"] = "Status in ('Normal','Checking') and CreationTime = ('2018-07-01T08:00:00Z','2018-08-01T08:00:00Z')";
args["PageNo"] = "1";
args["PageSize"] = "10";
args["SearchType"] = "video";
args["SortBy"] = "CreationTime:Desc";
return getAcsResponse(authInfo, apiName, args);
}
// 请求示例
void main() {
VodCredential authInfo = initVodClient("<Your AccessKeyId>", "<Your AccessKeySecret>");
VodApiResponse response = searchMedia(authInfo);
printf("httpCode: %d, result: %s\n", response.httpCode, response.result.c_str());
}
获取视频信息
调用GetVideoInfo接口,完成获取视频信息功能。
接口参数和返回字段请参见GetVideoInfo。调用示例如下:
#include <stdio.h>
#include <string>
#include <map>
#include "vod_sdk/openApiUtil.h"
/**
* 获取视频信息
*/
VodApiResponse getVideoInfo(VodCredential authInfo) {
string apiName = "GetVideoInfo";
map<string, string> args;
args["VideoId"] = "<VideoId>";
return getAcsResponse(authInfo, apiName, args);
}
// 请求示例
void main() {
VodCredential authInfo = initVodClient("<Your AccessKeyId>", "<Your AccessKeySecret>");
VodApiResponse response = getVideoInfo(authInfo);
printf("httpCode: %d, result: %s\n", response.httpCode, response.result.c_str());
}
批量获取视频信息
调用GetVideoInfos接口,完成批量获取视频信息功能。
接口参数和返回字段请参见GetVideoInfos。调用示例如下:
#include <stdio.h>
#include <string>
#include <map>
#include "vod_sdk/openApiUtil.h"
/**
* 批量获取视频信息函数
*/
VodApiResponse getVideoInfos(VodCredential authInfo) {
string apiName = "GetVideoInfos";
map<string, string> args;
args["VideoIds"] = "VideoId1,VideoId2";
return getAcsResponse(authInfo, apiName, args);
}
// 请求示例
void main() {
VodCredential authInfo = initVodClient("<Your AccessKeyId>", "<Your AccessKeySecret>");
VodApiResponse response = getVideoInfos(authInfo);
printf("httpCode: %d, result: %s\n", response.httpCode, response.result.c_str());
}
修改视频信息
调用UpdateVideoInfo接口,完成修改视频信息功能。
接口参数和返回字段请参见UpdateVideoInfo。调用示例如下:
#include <stdio.h>
#include <string>
#include <map>
#include "vod_sdk/openApiUtil.h"
/**
* 修改视频信息
*/
VodApiResponse updateVideoInfo(VodCredential authInfo) {
string apiName = "UpdateVideoInfo";
map<string, string> args;
args["VideoId"] = "VideoId";
args["Title"] = "new Title";
args["Description"] = "new Description";
args["Tags"] = "new Tag1,new Tag2";
return getAcsResponse(authInfo, apiName, args);
}
// 请求示例
void main() {
VodCredential authInfo = initVodClient("<Your AccessKeyId>", "<Your AccessKeySecret>");
VodApiResponse response = updateVideoInfo(authInfo);
printf("httpCode: %d, result: %s\n", response.httpCode, response.result.c_str());
}
批量修改视频信息
调用UpdateVideoInfos接口,完成批量修改视频信息功能。
接口参数和返回字段请参见UpdateVideoInfos。调用示例如下:
#include <stdio.h>
#include <string>
#include <map>
#include <jsoncpp/json/json.h>
#include "vod_sdk/openApiUtil.h"
/**
* 批量修改视频信息
*/
VodApiResponse updateVideoInfos(VodCredential authInfo) {
string apiName = "UpdateVideoInfos";
map<string, string> args;
Json::Value updateContentArray;
Json::Value updateContent1;
updateContent1["VideoId"] = "VideoId1";
// updateContent1["Title"] = "new Title";
// updateContent1["Tags"] = "new Tag1,new Tag2";
updateContentArray.append(updateContent1);
Json::Value updateContent2;
updateContent2["VideoId"] = "VideoId2";
// updateContent2["Title"] = "new Title";
// updateContent2["Tags"] = "new Tag1,new Tag2";
updateContentArray.append(updateContent2);
args["UpdateContent"] = updateContentArray.toStyledString();
return getAcsResponse(authInfo, apiName, args);
}
// 请求示例
void main() {
VodCredential authInfo = initVodClient("<Your AccessKeyId>", "<Your AccessKeySecret>");
VodApiResponse response = updateVideoInfos(authInfo);
printf("httpCode: %d, result: %s\n", response.httpCode, response.result.c_str());
}
删除视频
调用DeleteVideo接口,完成删除视频功能。
接口参数和返回字段请参见DeleteVideo。调用示例如下:
#include <stdio.h>
#include <string>
#include <map>
#include "vod_sdk/openApiUtil.h"
/**
* 删除视频
*/
VodApiResponse deleteVideo(VodCredential authInfo) {
string apiName = "DeleteVideo";
map<string, string> args;
//多个用逗号分隔
args["VideoIds"] = "VideoId1,VideoId2";
return getAcsResponse(authInfo, apiName, args);
}
// 请求示例
void main() {
VodCredential authInfo = initVodClient("<Your AccessKeyId>", "<Your AccessKeySecret>");
VodApiResponse response = deleteVideo(authInfo);
printf("httpCode: %d, result: %s\n", response.httpCode, response.result.c_str());
}
获取源文件信息(含源片下载地址)
调用GetMezzanineInfo接口,完成获取源文件信息功能。
接口参数和返回字段请参见GetMezzanineInfo。调用示例如下:
#include <stdio.h>
#include <string>
#include <map>
#include "vod_sdk/openApiUtil.h"
/**
* 获取源文件信息
*/
VodApiResponse getMezzanineInfo(VodCredential authInfo) {
string apiName = "GetMezzanineInfo";
map<string, string> args;
args["VideoId"] = "<VideoId>";
//源片下载地址过期时间,单位s
args["AuthTimeout"] = "3600";
return getAcsResponse(authInfo, apiName, args);
}
// 请求示例
void main() {
VodCredential authInfo = initVodClient("<Your AccessKeyId>", "<Your AccessKeySecret>");
VodApiResponse response = getMezzanineInfo(authInfo);
printf("httpCode: %d, result: %s\n", response.httpCode, response.result.c_str());
}
获取视频列表
调用GetVideoList接口,完成获取视频列表功能。
接口参数和返回字段请参见GetVideoList。调用示例如下:
#include <stdio.h>
#include <string>
#include <map>
#include "vod_sdk/openApiUtil.h"
/**
* 获取视频列表
*/
VodApiResponse getVideoList(VodCredential authInfo) {
string apiName = "GetVideoList";
map<string, string> args;
args["PageNo"] = "1";
args["PageSize"] = "20";
args["StartTime"] = "2018-12-27T09:00:38Z";
args["EndTime"] = "2018-12-28T09:00:38Z";
return getAcsResponse(authInfo, apiName, args);
}
// 请求示例
void main() {
VodCredential authInfo = initVodClient("<Your AccessKeyId>", "<Your AccessKeySecret>");
VodApiResponse response = getVideoList(authInfo);
printf("httpCode: %d, result: %s\n", response.httpCode, response.result.c_str());
}
删除媒体流
调用DeleteStream接口,完成删除媒体流功能。
接口参数和返回字段请参见DeleteStream。调用示例如下:
#include <stdio.h>
#include <string>
#include <map>
#include "vod_sdk/openApiUtil.h"
/**
* 删除媒体流函数
*/
VodApiResponse deleteStream(VodCredential authInfo) {
string apiName = "DeleteStream";
map<string, string> args;
args["VideoId"] = "<VideoId>";
args["JobIds"] = "JobId1,JobId2";
return getAcsResponse(authInfo, apiName, args);
}
// 请求示例
void main() {
VodCredential authInfo = initVodClient("<Your AccessKeyId>", "<Your AccessKeySecret>");
VodApiResponse response = deleteStream(authInfo);
printf("httpCode: %d, result: %s\n", response.httpCode, response.result.c_str());
}
批量删除源文件
调用DeleteMezzanines接口,完成批量删除源文件功能。
接口参数和返回字段请参见DeleteMezzanines。调用示例如下:
#include <stdio.h>
#include <string>
#include <map>
#include "vod_sdk/openApiUtil.h"
/**
* 批量删除源文件函数
*/
VodApiResponse deleteMezzanines(VodCredential authInfo) {
string apiName = "DeleteMezzanines";
map<string, string> args;
args["VideoIds"] = "VideoId1,VideoId2";
args["Force"] = "false";
return getAcsResponse(authInfo, apiName, args);
}
// 请求示例
void main() {
VodCredential authInfo = initVodClient("<Your AccessKeyId>", "<Your AccessKeySecret>");
VodApiResponse response = deleteMezzanines(authInfo);
printf("httpCode: %d, result: %s\n", response.httpCode, response.result.c_str());
}
批量更新图片信息
调用UpdateImageInfos接口,完成批量更新图片信息功能。
接口参数和返回字段请参见UpdateImageInfos。调用示例如下:
#include <stdio.h>
#include <string>
#include <map>
#include <jsoncpp/json/json.h>
#include "vod_sdk/openApiUtil.h"
/**
* 批量更新图片信息函数
*/
VodApiResponse updateImageInfos(VodCredential authInfo) {
string apiName = "UpdateImageInfos";
map<string, string> args;
Json::Value updateContentArray;
Json::Value updateContent1;
updateContent1["ImageId"] = "ImageId1";
// updateContent1["Title"] = "new Title";
// updateContent1["Tags"] = "new Tag1,new Tag2";
updateContentArray.append(updateContent1);
Json::Value updateContent2;
updateContent2["ImageId"] = "ImageId2";
// updateContent2["Title"] = "new Title";
// updateContent2["Tags"] = "new Tag1,new Tag2";
updateContentArray.append(updateContent2);
args["UpdateContent"] = updateContentArray.toStyledString();
return getAcsResponse(authInfo, apiName, args);
}
// 请求示例
void main() {
VodCredential authInfo = initVodClient("<Your AccessKeyId>", "<Your AccessKeySecret>");
VodApiResponse response = updateImageInfos(authInfo);
printf("httpCode: %d, result: %s\n", response.httpCode, response.result.c_str());
}
获取图片信息
调用GetImageInfo接口,完成获取图片信息功能。
接口参数和返回字段请参见GetImageInfo。调用示例如下:
#include <stdio.h>
#include <string>
#include <map>
#include "vod_sdk/openApiUtil.h"
/**
* 获取图片信息函数
*/
VodApiResponse getImageInfo(VodCredential authInfo) {
string apiName = "GetImageInfo";
map<string, string> args;
args["ImageId"] = "<ImageId>";
return getAcsResponse(authInfo, apiName, args);
}
// 请求示例
void main() {
VodCredential authInfo = initVodClient("<Your AccessKeyId>", "<Your AccessKeySecret>");
VodApiResponse response = getImageInfo(authInfo);
printf("httpCode: %d, result: %s\n", response.httpCode, response.result.c_str());
}
删除图片
调用DeleteImage接口,完成删除图片功能。
接口参数和返回字段请参见DeleteImage。调用示例如下:
#include <stdio.h>
#include <string>
#include <map>
#include "vod_sdk/openApiUtil.h"
/**
* 删除图片函数
*/
VodApiResponse deleteImage(VodCredential authInfo) {
string apiName = "DeleteImage";
map<string, string> args;
//根据ImageURL删除图片文件
args["DeleteImageType"] = "ImageURL";
args["ImageURLs"] = "http://sample.192.168.0.0/16/cover.jpg";
//根据ImageId删除图片文件
args["DeleteImageType"] = "ImageId";
args["ImageIds"] = "ImageId1,ImageId2";
//根据VideoId删除指定ImageType的图片文件
args["DeleteImageType"] = "VideoId";
args["VideoId"] = "<VideoId>";
args["ImageType"] = "SpriteSnapshot";
return getAcsResponse(authInfo, apiName, args);
}
// 请求示例
void main() {
VodCredential authInfo = initVodClient("<Your AccessKeyId>", "<Your AccessKeySecret>");
VodApiResponse response = deleteImage(authInfo);
printf("httpCode: %d, result: %s\n", response.httpCode, response.result.c_str());
}
在文档使用中是否遇到以下问题
更多建议
匿名提交