Skip to content

Commit 6de8509

Browse files
authored
Merge pull request #282 from tencentyun/feature_jojoliang_1a086920
Feature jojoliang 1a086920
2 parents 08b4159 + bcc8fc4 commit 6de8509

File tree

3 files changed

+188
-1
lines changed

3 files changed

+188
-1
lines changed

ci_media.go

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4155,3 +4155,32 @@ func (s *CIService) CreateGeneratePlayListJob(ctx context.Context, opt *CreateGe
41554155
resp, err := s.client.send(ctx, &sendOpt)
41564156
return &res, resp, err
41574157
}
4158+
4159+
// CreateMultiGeneratePlayListJobsOptions TODO
4160+
type CreateMultiGeneratePlayListJobsOptions struct {
4161+
XMLName xml.Name `xml:"Request"`
4162+
Tag string `xml:"Tag,omitempty"`
4163+
Input *JobInput `xml:"Input,omitempty"`
4164+
Operation []GeneratePlayListJobOperation `xml:"Operation,omitempty"`
4165+
QueueId string `xml:"QueueId,omitempty"`
4166+
QueueType string `xml:"QueueType,omitempty"`
4167+
CallBackFormat string `xml:"CallBackFormat,omitempty"`
4168+
CallBackType string `xml:"CallBackType,omitempty"`
4169+
CallBack string `xml:"CallBack,omitempty"`
4170+
CallBackMqConfig *NotifyConfigCallBackMqConfig `xml:"CallBackMqConfig,omitempty"`
4171+
CallBackKafkaConfig *KafkaConfig `xml:"CallBackKafkaConfig,omitempty"`
4172+
}
4173+
4174+
// CreateMultiGeneratePlayListJobs TODO
4175+
func (s *CIService) CreateMultiGeneratePlayListJobs(ctx context.Context, opt *CreateMultiGeneratePlayListJobsOptions) (*CreateMultiMediaJobsResult, *Response, error) {
4176+
var res CreateMultiMediaJobsResult
4177+
sendOpt := sendOptions{
4178+
baseURL: s.client.BaseURL.CIURL,
4179+
uri: "/jobs",
4180+
method: http.MethodPost,
4181+
body: opt,
4182+
result: &res,
4183+
}
4184+
resp, err := s.client.send(ctx, &sendOpt)
4185+
return &res, resp, err
4186+
}

ci_media_test.go

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3646,3 +3646,85 @@ func TestCIService_CreateGeneratePlayListJob(t *testing.T) {
36463646
t.Fatalf("CI.CreateGeneratePlayListJob returned error: %v", err)
36473647
}
36483648
}
3649+
3650+
func TestCIService_CreateMultiGeneratePlayListJobs(t *testing.T) {
3651+
setup()
3652+
defer teardown()
3653+
3654+
mux.HandleFunc("/jobs", func(w http.ResponseWriter, r *http.Request) {
3655+
testMethod(t, r, http.MethodPost)
3656+
testHeader(t, r, "Content-Type", "application/xml")
3657+
})
3658+
3659+
opt := &CreateMultiGeneratePlayListJobsOptions{
3660+
Input: &JobInput{
3661+
Object: "test.mp4",
3662+
},
3663+
Operation: []GeneratePlayListJobOperation{
3664+
{
3665+
Tag: "GeneratePlayList",
3666+
Output: &JobOutput{
3667+
Region: "ap-beijing",
3668+
Bucket: "abc-1250000000",
3669+
Object: "live/a.m3u8",
3670+
},
3671+
Transcode: &LiveTanscode{
3672+
Video: &LiveTanscodeVideo{
3673+
Codec: "H.264",
3674+
Width: "960", // 设置480、720、960、1080
3675+
Bitrate: "2000",
3676+
Maxrate: "5000",
3677+
Fps: "30",
3678+
},
3679+
Container: &Container{
3680+
Format: "hls",
3681+
ClipConfig: &ClipConfig{
3682+
Duration: "5",
3683+
},
3684+
},
3685+
TransConfig: &LiveTanscodeTransConfig{
3686+
HlsEncrypt: &HlsEncrypt{
3687+
IsHlsEncrypt: true,
3688+
},
3689+
InitialClipNum: "2",
3690+
CosTag: "a=a&b=b",
3691+
},
3692+
},
3693+
},
3694+
{
3695+
Tag: "GeneratePlayList",
3696+
Output: &JobOutput{
3697+
Region: "ap-beijing",
3698+
Bucket: "abc-1250000000",
3699+
Object: "live/b.m3u8",
3700+
},
3701+
Transcode: &LiveTanscode{
3702+
Video: &LiveTanscodeVideo{
3703+
Codec: "H.264",
3704+
Width: "1080", // 设置480、720、960、1080
3705+
Bitrate: "2000",
3706+
Maxrate: "5000",
3707+
Fps: "30",
3708+
},
3709+
Container: &Container{
3710+
Format: "hls",
3711+
ClipConfig: &ClipConfig{
3712+
Duration: "5",
3713+
},
3714+
},
3715+
TransConfig: &LiveTanscodeTransConfig{
3716+
InitialClipNum: "2",
3717+
CosTag: "a=a&b=b",
3718+
},
3719+
},
3720+
},
3721+
},
3722+
QueueId: "p893bcda225bf4945a378da6662e81a89",
3723+
CallBack: "https://www.callback.com",
3724+
}
3725+
3726+
_, _, err := client.CI.CreateMultiGeneratePlayListJobs(context.Background(), opt)
3727+
if err != nil {
3728+
t.Fatalf("CI.CreateMultiGeneratePlayListJobs returned errors: %v", err)
3729+
}
3730+
}

example/CI/workflow_and_job/jobs.go

Lines changed: 77 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1111,6 +1111,82 @@ func JobNotifyCallback() {
11111111
}
11121112
}
11131113

1114+
func InvokeMultiGeneratePlayListJobs() {
1115+
c := getClient()
1116+
createJobOpt := &cos.CreateMultiGeneratePlayListJobsOptions{
1117+
Tag: "GeneratePlayList",
1118+
Input: &cos.JobInput{
1119+
Object: "speed.mp4",
1120+
},
1121+
Operation: []cos.GeneratePlayListJobOperation{
1122+
{
1123+
Tag: "GeneratePlayList",
1124+
Output: &cos.JobOutput{
1125+
Region: "ap-beijing",
1126+
Bucket: "test-1234567890",
1127+
Object: "live/a.m3u8",
1128+
},
1129+
Transcode: &cos.LiveTanscode{
1130+
Video: &cos.LiveTanscodeVideo{
1131+
Codec: "H.264",
1132+
Width: "1280", // 设置480、720、960、1080
1133+
Bitrate: "293",
1134+
Maxrate: "5000",
1135+
Fps: "25",
1136+
},
1137+
Container: &cos.Container{
1138+
Format: "hls",
1139+
ClipConfig: &cos.ClipConfig{
1140+
Duration: "3",
1141+
},
1142+
},
1143+
TransConfig: &cos.LiveTanscodeTransConfig{
1144+
// HlsEncrypt: &cos.HlsEncrypt{
1145+
// IsHlsEncrypt: true,
1146+
// },
1147+
InitialClipNum: "10",
1148+
CosTag: "a=a&b=b",
1149+
},
1150+
},
1151+
},
1152+
{
1153+
Tag: "GeneratePlayList",
1154+
Output: &cos.JobOutput{
1155+
Region: "ap-beijing",
1156+
Bucket: "test-1234567890",
1157+
Object: "live/b.m3u8",
1158+
},
1159+
Transcode: &cos.LiveTanscode{
1160+
Video: &cos.LiveTanscodeVideo{
1161+
Codec: "H.264",
1162+
Width: "1280", // 设置480、720、960、1080
1163+
Bitrate: "293",
1164+
Maxrate: "5000",
1165+
Fps: "25",
1166+
},
1167+
Container: &cos.Container{
1168+
Format: "hls",
1169+
ClipConfig: &cos.ClipConfig{
1170+
Duration: "3",
1171+
},
1172+
},
1173+
TransConfig: &cos.LiveTanscodeTransConfig{
1174+
// HlsEncrypt: &cos.HlsEncrypt{
1175+
// IsHlsEncrypt: true,
1176+
// },
1177+
InitialClipNum: "10",
1178+
CosTag: "a=a&b=b",
1179+
},
1180+
},
1181+
},
1182+
},
1183+
}
1184+
createJobRes, _, err := c.CI.CreateMultiGeneratePlayListJobs(context.Background(), createJobOpt)
1185+
log_status(err)
1186+
fmt.Printf("%+v\n", createJobRes.JobsDetail)
1187+
}
1188+
11141189
func main() {
1115-
InvokeTranscodeJob()
1190+
// InvokeTranscodeJob()
1191+
InvokeMultiGeneratePlayListJobs()
11161192
}

0 commit comments

Comments
 (0)