Skip to content

Commit 097711f

Browse files
committed
Merge branch 'dev_dna' into 'master' (merge request !74)
dev_dna
2 parents 9b4c409 + e7ef3e5 commit 097711f

File tree

4 files changed

+372
-4
lines changed

4 files changed

+372
-4
lines changed

ci_media.go

Lines changed: 211 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ type JobOutput struct {
3838
Object string `xml:"Object,omitempty"`
3939
SpriteObject string `xml:"SpriteObject,omitempty"`
4040
AuObject string `xml:"AuObject,omitempty"`
41+
BassObject string `xml:"BassObject,omitempty"`
42+
DrumObject string `xml:"DrumObject,omitempty"`
4143
StreamExtract []StreamExtract `xml:"StreamExtract,omitempty"`
4244
}
4345

@@ -339,9 +341,12 @@ type HlsEncrypt struct {
339341

340342
// Segment TODO
341343
type Segment struct {
342-
Format string `xml:"Format,omitempty"`
343-
Duration string `xml:"Duration,omitempty"`
344-
HlsEncrypt *HlsEncrypt `xml:"HlsEncrypt,omitempty"`
344+
Format string `xml:"Format,omitempty"`
345+
Duration string `xml:"Duration,omitempty"`
346+
TranscodeIndex string `xml:"TranscodeIndex,omitempty"`
347+
HlsEncrypt *HlsEncrypt `xml:"HlsEncrypt,omitempty"`
348+
StartTime string `xml:"StartTime,omitempty"`
349+
EndTime string `xml:"EndTime,omitempty"`
345350
}
346351

347352
// VideoMontageVideo TODO
@@ -731,6 +736,12 @@ type MediaProcessJobOperation struct {
731736
SoundHoundResult *SoundHoundResult `xml:"SoundHoundResult,omitempty"`
732737
FillConcat *FillConcat `xml:"FillConcat,omitempty"`
733738
VideoSynthesis *VideoSynthesis `xml:"VideoSynthesis,omitempty"`
739+
DnaConfig *DnaConfig `xml:"DnaConfig,omitempty"`
740+
DnaResult *DnaResult `xml:"DnaResult,omitempty"`
741+
VocalScore *VocalScore `xml:"VocalScore,omitempty"`
742+
VocalScoreResult *VocalScoreResult `xml:"VocalScoreResult,omitempty"`
743+
ImageInspect *ImageInspect `xml:"ImageInspect,omitempty"`
744+
ImageInspectResult *ImageInspectResult `xml:"ImageInspectResult,omitempty"`
734745
}
735746

736747
// CreatePicJobsOptions TODO
@@ -1639,6 +1650,10 @@ type SegmentVideoBody struct {
16391650
BackgroundRed string `xml:"BackgroundRed,omitempty"`
16401651
BackgroundGreen string `xml:"BackgroundGreen,omitempty"`
16411652
BackgroundLogoUrl string `xml:"BackgroundLogoUrl,omitempty"`
1653+
BinaryThreshold string `xml:"BinaryThreshold,omitempty"`
1654+
RemoveRed string `xml:"RemoveRed,omitempty"`
1655+
RemoveGreen string `xml:"RemoveGreen,omitempty"`
1656+
RemoveBlue string `xml:"RemoveBlue,omitempty"`
16421657
}
16431658

16441659
// NodeSmartCover TODO
@@ -1680,6 +1695,7 @@ type NodeOperation struct {
16801695
StreamPackInfo *NodeHlsPackInfo `xml:"StreamPackInfo,omitempty" json:"StreamPackInfo,omitempty"`
16811696
Condition *WorkflowNodeCondition `xml:"Condition,omitempty" json:"Condition,omitempty"`
16821697
SegmentVideoBody *SegmentVideoBody `xml:"SegmentVideoBody,omitempty" json:"SegmentVideoBody,omitempty"`
1698+
ImageInspect *ImageInspect `xml:"ImageInspect,omitempty" json:"ImageInspect,omitempty"`
16831699
}
16841700

16851701
// Node TODO
@@ -3053,6 +3069,12 @@ type InventoryTriggerJobOperationJobParam struct {
30533069
WordsGeneralize *WordsGeneralize `xml:"WordsGeneralize,omitempty"`
30543070
WordsGeneralizeResult *WordsGeneralizeResult `xml:"WordsGeneralizeResult,omitempty"`
30553071
NoiseReduction *NoiseReduction `xml:"NoiseReduction,omitempty"`
3072+
DnaConfig *DnaConfig `xml:"DnaConfig,omitempty"`
3073+
DnaResult *DnaResult `xml:"DnaResult,omitempty"`
3074+
VocalScore *VocalScore `xml:"VocalScore,omitempty"`
3075+
VocalScoreResult *VocalScoreResult `xml:"VocalScoreResult,omitempty"`
3076+
ImageInspect *ImageInspect `xml:"ImageInspect,omitempty"`
3077+
ImageInspectResult *ImageInspectResult `xml:"ImageInspectResult,omitempty"`
30563078
}
30573079

30583080
// InventoryTriggerJob TODO
@@ -3429,3 +3451,189 @@ type VideoSynthesisSpliceInfo struct {
34293451
Width string `xml:"Width,omitempty"`
34303452
Height string `xml:"Height,omitempty"`
34313453
}
3454+
3455+
// DnaConfig DNA任务配置
3456+
type DnaConfig struct {
3457+
RuleType string `xml:"RuleType,omitempty"`
3458+
DnaDbId string `xml:"DnaDbId,omitempty"`
3459+
VideoId string `xml:"VideoId,omitempty"`
3460+
}
3461+
3462+
// DnaResult DNA任务结果
3463+
type DnaResult struct {
3464+
VideoId string `xml:"VideoId,omitempty"`
3465+
Duration int `xml:"Duration,omitempty"`
3466+
Detection *DnaResultDetection `xml:"Detection,omitempty"`
3467+
}
3468+
3469+
// DnaResultDetection DNA任务结果
3470+
type DnaResultDetection struct {
3471+
VideoId string `xml:"VideoId,omitempty"`
3472+
Similar int `xml:"Similar,omitempty"`
3473+
SimilarDuration int `xml:"SimilarDuration,omitempty"`
3474+
Duration int `xml:"Duration,omitempty"`
3475+
MatchDetail []DnaResultMatchDetail `xml:"MatchDetail,omitempty"`
3476+
Audio DnaResultAudio `xml:"Audio,omitempty"`
3477+
}
3478+
3479+
// DnaResultDetection DNA任务结果
3480+
type DnaResultMatchDetail struct {
3481+
MatchStartTime int `xml:"MatchStartTime,omitempty"`
3482+
MatchEndTime int `xml:"MatchEndTime,omitempty"`
3483+
SrcStartTime int `xml:"SrcStartTime,omitempty"`
3484+
SrcEndTime int `xml:"SrcEndTime,omitempty"`
3485+
}
3486+
3487+
// DnaResultAudio DNA任务结果
3488+
type DnaResultAudio struct {
3489+
Similar int `xml:"Similar,omitempty"`
3490+
}
3491+
3492+
// GetDnaDbOptions 查询 DNA 库列表参数
3493+
type GetDnaDbOptions struct {
3494+
Ids string `url:"ids,omitempty"`
3495+
PageNumber string `url:"pageNumber,omitempty"`
3496+
PageSize string `url:"pageSize,omitempty"`
3497+
}
3498+
3499+
// GetDnaDbResult 查询 DNA 库列表结果
3500+
type GetDnaDbResult struct {
3501+
XMLName xml.Name `xml:"Response"`
3502+
RequestId string `xml:"RequestId,omitempty"`
3503+
TotalCount int `xml:"TotalCount,omitempty"`
3504+
PageNumber int `xml:"PageNumber,omitempty"`
3505+
PageSize int `xml:"PageSize,omitempty"`
3506+
DNADbConfig []DNADbConfig `xml:"DNADbConfig,omitempty"`
3507+
NonExistIDs []string `xml:"NonExistIDs,omitempty"`
3508+
}
3509+
3510+
// DNADbConfig DNA 库详情
3511+
type DNADbConfig struct {
3512+
BucketId string `xml:"BucketId,omitempty"`
3513+
Region string `xml:"Region,omitempty"`
3514+
DNADbId string `xml:"DNADbId,omitempty"`
3515+
DNADbName string `xml:"DNADbName,omitempty"`
3516+
Capacity int `xml:"Capacity,omitempty"`
3517+
Description string `xml:"Description,omitempty"`
3518+
UpdateTime string `xml:"UpdateTime,omitempty"`
3519+
CreateTime string `xml:"CreateTime,omitempty"`
3520+
}
3521+
3522+
// GetDnaDb 查询 DNA 库列表
3523+
func (s *CIService) GetDnaDb(ctx context.Context, opt *GetDnaDbOptions) (*GetDnaDbResult, *Response, error) {
3524+
var res GetDnaDbResult
3525+
sendOpt := sendOptions{
3526+
baseURL: s.client.BaseURL.CIURL,
3527+
uri: "/dnadb",
3528+
optQuery: opt,
3529+
method: http.MethodGet,
3530+
result: &res,
3531+
}
3532+
resp, err := s.client.send(ctx, &sendOpt)
3533+
return &res, resp, err
3534+
}
3535+
3536+
// GetDnaDbFilesOptions 获取 DNA 库中文件列表参数
3537+
type GetDnaDbFilesOptions struct {
3538+
object string `url:"object,omitempty"`
3539+
DnaDbId string `url:"dnaDbId,omitempty"`
3540+
PageNumber string `url:"pageNumber,omitempty"`
3541+
PageSize string `url:"pageSize,omitempty"`
3542+
}
3543+
3544+
// GetDnaDbFilesResult 查询 DNA 库列表结果
3545+
type GetDnaDbFilesResult struct {
3546+
XMLName xml.Name `xml:"Response"`
3547+
RequestId string `xml:"RequestId,omitempty"`
3548+
TotalCount int `xml:"TotalCount,omitempty"`
3549+
PageNumber int `xml:"PageNumber,omitempty"`
3550+
PageSize int `xml:"PageSize,omitempty"`
3551+
DNADbFiles []DNADbFiles `xml:"DNADbFiles,omitempty"`
3552+
}
3553+
3554+
// DNADbFiles DNA 文件详情
3555+
type DNADbFiles struct {
3556+
BucketId string `xml:"BucketId,omitempty"`
3557+
Region string `xml:"Region,omitempty"`
3558+
DNADbId string `xml:"DNADbId,omitempty"`
3559+
VideoId string `xml:"VideoId,omitempty"`
3560+
Object int `xml:"Object,omitempty"`
3561+
ETag string `xml:"ETag,omitempty"`
3562+
UpdateTime string `xml:"UpdateTime,omitempty"`
3563+
CreateTime string `xml:"CreateTime,omitempty"`
3564+
}
3565+
3566+
// GetDnaDb 查询 DNA 库列表
3567+
func (s *CIService) GetDnaDbFiles(ctx context.Context, opt *GetDnaDbFilesOptions) (*GetDnaDbFilesResult, *Response, error) {
3568+
var res GetDnaDbFilesResult
3569+
sendOpt := sendOptions{
3570+
baseURL: s.client.BaseURL.CIURL,
3571+
uri: "/dnadb_files",
3572+
optQuery: opt,
3573+
method: http.MethodGet,
3574+
result: &res,
3575+
}
3576+
resp, err := s.client.send(ctx, &sendOpt)
3577+
return &res, resp, err
3578+
}
3579+
3580+
// VocalScore 音乐评分
3581+
type VocalScore struct {
3582+
StandardObject string `xml:"StandardObject,omitempty"`
3583+
}
3584+
3585+
// VocalScore 音乐评分结果
3586+
type VocalScoreResult struct {
3587+
PitchScore *VocalScoreResultPitchScore `xml:"PitchScore,omitempty"`
3588+
RhythemScore *VocalScoreResultRhythemScore `xml:"RhythemScore,omitempty"`
3589+
}
3590+
3591+
type VocalScoreResultPitchScore struct {
3592+
TotalScore float64 `xml:"TotalScore,omitempty"`
3593+
SentenceScores []VocalScoreResultSentenceScores `xml:"SentenceScores,omitempty"`
3594+
}
3595+
3596+
type VocalScoreResultSentenceScores struct {
3597+
StartTime float64 `xml:"StartTime,omitempty"`
3598+
EndTime float64 `xml:"EndTime,omitempty"`
3599+
Score float64 `xml:"Score,omitempty"`
3600+
}
3601+
3602+
type VocalScoreResultRhythemScore struct {
3603+
TotalScore float64 `xml:"TotalScore,omitempty"`
3604+
SentenceScores []VocalScoreResultSentenceScores `xml:"SentenceScores,omitempty"`
3605+
}
3606+
3607+
// ImageInspect 黑产检测
3608+
type ImageInspect struct {
3609+
AutoProcess string `xml:"AutoProcess,omitempty"`
3610+
ProcessType string `xml:"ProcessType,omitempty"`
3611+
}
3612+
3613+
// ImageInspectResult 黑产检测结果
3614+
type ImageInspectResult struct {
3615+
State string `xml:"State,omitempty"`
3616+
Code string `xml:"Code,omitempty"`
3617+
Message string `xml:"Message,omitempty"`
3618+
InputObjectName string `xml:"InputObjectName,omitempty"`
3619+
InputObjectUrl string `xml:"InputObjectUrl,omitempty"`
3620+
ProcessResult *ImageInspectProcessResult `xml:"ProcessResult,omitempty"`
3621+
}
3622+
3623+
// ImageInspectProcessResult 黑产检测结果
3624+
type ImageInspectProcessResult struct {
3625+
PicSize int `xml:"PicSize,omitempty"`
3626+
PicType string `xml:"PicType,omitempty"`
3627+
Suspicious string `xml:"Suspicious,omitempty"`
3628+
SuspiciousBeginByte int `xml:"SuspiciousBeginByte,omitempty"`
3629+
SuspiciousEndByte int `xml:"SuspiciousEndByte,omitempty"`
3630+
SuspiciousSize int `xml:"SuspiciousSize,omitempty"`
3631+
SuspiciousType string `xml:"SuspiciousType,omitempty"`
3632+
AutoProcessResult *ImageInspectAutoProcessResult `xml:"AutoProcessResult,omitempty"`
3633+
}
3634+
3635+
// ImageInspectResult 黑产检测结果
3636+
type ImageInspectAutoProcessResult struct {
3637+
Code string `xml:"Code,omitempty"`
3638+
Message string `xml:"Message,omitempty"`
3639+
}

ci_media_test.go

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3320,3 +3320,49 @@ func TestCIService_DeleteTemplate(t *testing.T) {
33203320
t.Fatalf("CI.DeleteTemplate returned error: %v", err)
33213321
}
33223322
}
3323+
3324+
func TestCIService_GetDnaDb(t *testing.T) {
3325+
setup()
3326+
defer teardown()
3327+
3328+
mux.HandleFunc("/dnadb", func(w http.ResponseWriter, r *http.Request) {
3329+
testMethod(t, r, http.MethodGet)
3330+
v := values{
3331+
"pageNumber": "2",
3332+
"pageSize": "10",
3333+
}
3334+
testFormValues(t, r, v)
3335+
})
3336+
opt := &GetDnaDbOptions{
3337+
PageNumber: "2",
3338+
PageSize: "10",
3339+
}
3340+
3341+
_, _, err := client.CI.GetDnaDb(context.Background(), opt)
3342+
if err != nil {
3343+
t.Fatalf("CI.GetDnaDb returned error: %v", err)
3344+
}
3345+
}
3346+
3347+
func TestCIService_GetDnaDbFiles(t *testing.T) {
3348+
setup()
3349+
defer teardown()
3350+
3351+
mux.HandleFunc("/dnadb_files", func(w http.ResponseWriter, r *http.Request) {
3352+
testMethod(t, r, http.MethodGet)
3353+
v := values{
3354+
"pageNumber": "2",
3355+
"pageSize": "10",
3356+
}
3357+
testFormValues(t, r, v)
3358+
})
3359+
opt := &GetDnaDbFilesOptions{
3360+
PageNumber: "2",
3361+
PageSize: "10",
3362+
}
3363+
3364+
_, _, err := client.CI.GetDnaDbFiles(context.Background(), opt)
3365+
if err != nil {
3366+
t.Fatalf("CI.GetDnaDbFiles returned error: %v", err)
3367+
}
3368+
}

example/CI/workflow_and_job/dna.go

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
package main
2+
3+
import (
4+
"context"
5+
"fmt"
6+
7+
"github.com/tencentyun/cos-go-sdk-v5"
8+
)
9+
10+
func log_status(err error) {
11+
if err == nil {
12+
return
13+
}
14+
if cos.IsNotFoundError(err) {
15+
// WARN
16+
fmt.Println("WARN: Resource is not existed")
17+
} else if e, ok := cos.IsCOSError(err); ok {
18+
fmt.Printf("ERROR: Code: %v\n", e.Code)
19+
fmt.Printf("ERROR: Message: %v\n", e.Message)
20+
fmt.Printf("ERROR: Resource: %v\n", e.Resource)
21+
fmt.Printf("ERROR: RequestId: %v\n", e.RequestID)
22+
// ERROR
23+
} else {
24+
fmt.Printf("ERROR: %v\n", err)
25+
// ERROR
26+
}
27+
}
28+
29+
// InvokeDNAJob 提交一个DNA任务
30+
// https://cloud.tencent.com/document/product/460/96115
31+
func InvokeDNAJob() {
32+
c := getClient()
33+
createJobOpt := &cos.CreateJobsOptions{
34+
Tag: "DNA",
35+
Input: &cos.JobInput{
36+
Object: "input/test.mp4",
37+
},
38+
Operation: &cos.MediaProcessJobOperation{
39+
DnaConfig: &cos.DnaConfig{
40+
RuleType: "GetFingerPrint",
41+
DnaDbId: "xxx",
42+
},
43+
UserData: "This is my DNA job",
44+
JobLevel: 1,
45+
},
46+
}
47+
createJobRes, _, err := c.CI.CreateJob(context.Background(), createJobOpt)
48+
log_status(err)
49+
fmt.Printf("%+v\n", createJobRes.JobsDetail)
50+
}
51+
52+
// GetDnaDb 查询 DNA 库列表
53+
// https://cloud.tencent.com/document/product/460/96117
54+
func GetDnaDb() {
55+
c := getClient()
56+
opt := &cos.GetDnaDbOptions{
57+
PageNumber: "2",
58+
PageSize: "10",
59+
}
60+
res, _, err := c.CI.GetDnaDb(context.Background(), opt)
61+
log_status(err)
62+
fmt.Printf("%+v\n", res)
63+
}
64+
65+
// GetDnaDbFiles 获取 DNA 库中文件列表
66+
// https://cloud.tencent.com/document/product/460/96116
67+
func GetDnaDbFiles() {
68+
c := getClient()
69+
opt := &cos.GetDnaDbFilesOptions{
70+
PageNumber: "2",
71+
PageSize: "10",
72+
}
73+
res, _, err := c.CI.GetDnaDbFiles(context.Background(), opt)
74+
log_status(err)
75+
fmt.Printf("%+v\n", res)
76+
}
77+
78+
func main() {
79+
}

0 commit comments

Comments
 (0)