diff --git a/ci_media.go b/ci_media.go index ea11f69..7981489 100644 --- a/ci_media.go +++ b/ci_media.go @@ -189,6 +189,134 @@ type CreateMultiMediaJobsResult struct { JobsDetail []MediaProcessJobDetail `xml:"JobsDetail,omitempty"` } +type MediaProcessJobsNotifyBody struct { + XMLName xml.Name `xml:"Response"` + EventName string `xml:"EventName"` + JobsDetail struct { + Code string `xml:"Code"` + CreationTime string `xml:"CreationTime"` + EndTime string `xml:"EndTime"` + Input struct { + BucketId string `xml:"BucketId"` + Object string `xml:"Object"` + Region string `xml:"Region"` + } `xml:"Input"` + JobId string `xml:"JobId"` + Message string `xml:"Message"` + Operation struct { + MediaInfo struct { + Format struct { + Text string `xml:",chardata"` + Bitrate string `xml:"Bitrate"` + Duration string `xml:"Duration"` + FormatLongName string `xml:"FormatLongName"` + FormatName string `xml:"FormatName"` + NumProgram string `xml:"NumProgram"` + NumStream string `xml:"NumStream"` + Size string `xml:"Size"` + StartTime string `xml:"StartTime"` + } `xml:"Format"` + Stream struct { + Audio []struct { + Bitrate string `xml:"Bitrate"` + Channel string `xml:"Channel"` + ChannelLayout string `xml:"ChannelLayout"` + CodecLongName string `xml:"CodecLongName"` + CodecName string `xml:"CodecName"` + CodecTag string `xml:"CodecTag"` + CodecTagString string `xml:"CodecTagString"` + CodecTimeBase string `xml:"CodecTimeBase"` + Duration string `xml:"Duration"` + Index string `xml:"Index"` + Language string `xml:"Language"` + SampleFmt string `xml:"SampleFmt"` + SampleRate string `xml:"SampleRate"` + StartTime string `xml:"StartTime"` + Timebase string `xml:"Timebase"` + } `xml:"Audio"` + Subtitle string `xml:"Subtitle"` + Video []struct { + AvgFps string `xml:"AvgFps"` + Bitrate string `xml:"Bitrate"` + CodecLongName string `xml:"CodecLongName"` + CodecName string `xml:"CodecName"` + CodecTag string `xml:"CodecTag"` + CodecTagString string `xml:"CodecTagString"` + CodecTimeBase string `xml:"CodecTimeBase"` + Dar string `xml:"Dar"` + Duration string `xml:"Duration"` + Fps string `xml:"Fps"` + HasBFrame string `xml:"HasBFrame"` + Height string `xml:"Height"` + Index string `xml:"Index"` + Language string `xml:"Language"` + Level string `xml:"Level"` + NumFrames string `xml:"NumFrames"` + PixFormat string `xml:"PixFormat"` + Profile string `xml:"Profile"` + RefFrames string `xml:"RefFrames"` + Rotation string `xml:"Rotation"` + Sar string `xml:"Sar"` + StartTime string `xml:"StartTime"` + Timebase string `xml:"Timebase"` + Width string `xml:"Width"` + } `xml:"Video"` + } `xml:"Stream"` + } `xml:"MediaInfo"` + MediaResult struct { + OutputFile struct { + Bucket string `xml:"Bucket"` + ObjectName string `xml:"ObjectName"` + ObjectPrefix string `xml:"ObjectPrefix"` + Region string `xml:"Region"` + } `xml:"OutputFile"` + } `xml:"MediaResult"` + Output struct { + Bucket string `xml:"Bucket"` + Object string `xml:"Object"` + Region string `xml:"Region"` + } `xml:"Output"` + TemplateId string `xml:"TemplateId"` + TemplateName string `xml:"TemplateName"` + } `xml:"Operation"` + QueueId string `xml:"QueueId"` + StartTime string `xml:"StartTime"` + State string `xml:"State"` + Tag string `xml:"Tag"` + } `xml:"JobsDetail"` +} + +type WorkflowExecutionNotifyBody struct { + XMLName xml.Name `xml:"Response"` + EventName string `xml:"EventName"` + WorkflowExecution struct { + RunId string `xml:"RunId"` + BucketId string `xml:"BucketId"` + Object string `xml:"Object"` + CosHeaders []struct { + Key string `xml:"Key"` + Value string `xml:"Value"` + } `xml:"CosHeaders"` + WorkflowId string `xml:"WorkflowId"` + WorkflowName string `xml:"WorkflowName"` + CreateTime string `xml:"CreateTime"` + State string `xml:"State"` + Tasks []struct { + Type string `xml:"Type"` + CreateTime string `xml:"CreateTime"` + EndTime string `xml:"EndTime"` + State string `xml:"State"` + JobId string `xml:"JobId"` + Name string `xml:"Name"` + TemplateId string `xml:"TemplateId"` + TemplateName string `xml:"TemplateName"` + TranscodeTemplateId string `xml:"TranscodeTemplateId,omitempty"` + TranscodeTemplateName string `xml:"TranscodeTemplateName,omitempty"` + HdrMode string `xml:"HdrMode,omitempty"` + } `xml:"Tasks"` + } `xml:"WorkflowExecution"` +} + func (s *CIService) CreateMultiMediaJobs(ctx context.Context, opt *CreateMultiMediaJobsOptions) (*CreateMultiMediaJobsResult, *Response, error) { var res CreateMultiMediaJobsResult sendOpt := sendOptions{ diff --git a/example/CI/media_process/media_process.go b/example/CI/media_process/media_process.go index 0d2dafd..bf2ae7c 100644 --- a/example/CI/media_process/media_process.go +++ b/example/CI/media_process/media_process.go @@ -2,6 +2,7 @@ package main import ( "context" + "encoding/xml" "fmt" "net/http" "net/url" @@ -322,9 +323,33 @@ func InvokeMultiTasks() { } } +func TaskNotifyCallback() { + taskBody := "TaskFinishSuccess2021-09-14T14:38:59+08002021-09-14T14:39:59+0800e28ef88b61ed41b7a6ea76a8147f4f9eap-guangzhouj7123e78c152611ec9e8c1ba6632b91a83775.738000143.732000QuickTime / MOVmov,mp4,m4a,3gp,3g2,mj202678368130.000000f89f22f7a8be4f478434da58eb11d7da.mp4ap-guangzhouf89f22f7a8be4f478434da58eb11d7da.mp4ap-guangzhout064fb9214850f49aaac44b5561a7b0b3bMP4-FHDp6f358a37bf9442ad8f859db055cd0edb2021-09-14T14:38:59+0800SuccessTranscode" + var body cos.MediaProcessJobsNotifyBody + err := xml.Unmarshal([]byte(taskBody), &body) + if err != nil { + fmt.Println(fmt.Sprintf("err:%v", err)) + } else { + fmt.Println(fmt.Sprintf("body:%v", body)) + } +} + +func WorkflowExecutionNotifyCallback() { + workflowExecutionBody := "WorkflowFinishi70ae991a152911ecb184525400a8700f62ddbc1245.mp4x-cos-meta-id62ddbc1245Content-Typevideo/mp4w29ba54d02b7340dd9fb44eb5beb786b92021-09-14 15:00:26+0800SuccessTranscode2021-09-14 15:00:27+08002021-09-14 15:00:42+0800Successj70bab192152911ecab79bba409874f7fTranscode_1607323983818t088613dea8d564a9ba7e6b02cbd5de877HLS-FHD" + var body cos.WorkflowExecutionNotifyBody + err := xml.Unmarshal([]byte(workflowExecutionBody), &body) + if err != nil { + fmt.Println(fmt.Sprintf("err:%v", err)) + } else { + fmt.Println(fmt.Sprintf("body:%v", body)) + } +} + func main() { // InvokeSnapshotTask() // InvokeConcatTask() // InvokeTranscodeTask() - InvokeMultiTasks() + // InvokeMultiTasks() + TaskNotifyCallback() + WorkflowExecutionNotifyCallback() }