@@ -3,8 +3,10 @@ package cos
33import (
44 "context"
55 "encoding/xml"
6+ "errors"
67 "fmt"
78 "net/http"
9+ "strings"
810)
911
1012type JobInput struct {
@@ -16,6 +18,7 @@ type JobOutput struct {
1618 Bucket string `xml:"Bucket,omitempty"`
1719 Object string `xml:"Object,omitempty"`
1820 SpriteObject string `xml:"SpriteObject,omitempty"`
21+ AuObject string `xml:"AuObject,omitempty"`
1922}
2023
2124type Container struct {
@@ -155,17 +158,78 @@ type Segment struct {
155158 Duration string `xml:"Duration,omitempty"`
156159}
157160
161+ type VideoMontageVideo struct {
162+ Codec string `xml:"Codec"`
163+ Width string `xml:"Width"`
164+ Height string `xml:"Height"`
165+ Fps string `xml:"Fps"`
166+ Remove string `xml:"Remove,omitempty"`
167+ Bitrate string `xml:"Bitrate"`
168+ Crf string `xml:"Crf"`
169+ }
170+
171+ type VideoMontage struct {
172+ Container * Container `xml:"Container,omitempty"`
173+ Video * VideoMontageVideo `xml:"Video,omitempty"`
174+ Audio * Audio `xml:"Audio,omitempty"`
175+ Duration string `xml:"Duration,omitempty"`
176+ }
177+
178+ type AudioConfig struct {
179+ Codec string `xml:"Codec"`
180+ Samplerate string `xml:"Samplerate"`
181+ Bitrate string `xml:"Bitrate"`
182+ Channels string `xml:"Channels"`
183+ }
184+
185+ type VoiceSeparate struct {
186+ AudioMode string `xml:"AudioMode,omitempty"` // IsAudio 人声, IsBackground 背景声, AudioAndBackground 人声和背景声
187+ AudioConfig * AudioConfig `xml:"AudioConfig,omitempty"`
188+ }
189+
190+ type ColorEnhance struct {
191+ Enable string `xml:"Enable"`
192+ Contrast string `xml:"Contrast"`
193+ Correction string `xml:"Correction"`
194+ Saturation string `xml:"Saturation"`
195+ }
196+
197+ type MsSharpen struct {
198+ Enable string `xml:"Enable"`
199+ SharpenLevel string `xml:"SharpenLevel"`
200+ }
201+
202+ type VideoProcess struct {
203+ ColorEnhance * ColorEnhance `xml:"ColorEnhance,omitempty"`
204+ MsSharpen * MsSharpen `xml:"MsSharpen,omitempty"`
205+ }
206+
207+ type SDRtoHDR struct {
208+ HdrMode string `xml:"HdrMode,omitempty"` // HLG、HDR10
209+ }
210+
211+ type SuperResolution struct {
212+ Resolution string `xml:"Resolution,omitempty"` // sdtohd、hdto4k
213+ EnableScaleUp string `xml:"EnableScaleUp,omitempty"`
214+ }
215+
158216type MediaProcessJobOperation struct {
159- Tag string `xml:"Tag,omitempty"`
160- Output * JobOutput `xml:"Output,omitempty"`
161- Transcode * Transcode `xml:"Transcode,omitempty"`
162- Watermark * Watermark `xml:"Watermark,omitempty"`
163- TemplateId string `xml:"TemplateId,omitempty"`
164- WatermarkTemplateId []string `xml:"WatermarkTemplateId,omitempty"`
165- ConcatTemplate * ConcatTemplate `xml:"ConcatTemplate,omitempty"`
166- Snapshot * Snapshot `xml:"Snapshot,omitempty"`
167- Animation * Animation `xml:"Animation,omitempty"`
168- Segment * Segment `xml:"Segment,omitempty"`
217+ Tag string `xml:"Tag,omitempty"`
218+ Output * JobOutput `xml:"Output,omitempty"`
219+ Transcode * Transcode `xml:"Transcode,omitempty"`
220+ Watermark * Watermark `xml:"Watermark,omitempty"`
221+ TemplateId string `xml:"TemplateId,omitempty"`
222+ WatermarkTemplateId []string `xml:"WatermarkTemplateId,omitempty"`
223+ ConcatTemplate * ConcatTemplate `xml:"ConcatTemplate,omitempty"`
224+ Snapshot * Snapshot `xml:"Snapshot,omitempty"`
225+ Animation * Animation `xml:"Animation,omitempty"`
226+ Segment * Segment `xml:"Segment,omitempty"`
227+ VideoMontage * VideoMontage `xml:"VideoMontage,omitempty"`
228+ VoiceSeparate * VoiceSeparate `xml:"VoiceSeparate,omitempty"`
229+ VideoProcess * VideoProcess `xml:"VideoProcess,omitempty"`
230+ TranscodeTemplateId string `xml:"TranscodeTemplateId,omitempty"` // 视频增强、超分、SDRtoHDR任务类型,可以选择转码模板相关参数
231+ SDRtoHDR * SDRtoHDR `xml:"SDRtoHDR,omitempty"`
232+ SuperResolution * SuperResolution `xml:"SuperResolution,omitempty"`
169233}
170234
171235type CreateMediaJobsOptions struct {
@@ -380,6 +444,31 @@ func (s *CIService) DescribeMediaJob(ctx context.Context, jobid string) (*Descri
380444 return & res , resp , err
381445}
382446
447+ type DescribeMutilMediaProcessJobResult struct {
448+ XMLName xml.Name `xml:"Response"`
449+ JobsDetail []MediaProcessJobDetail `xml:"JobsDetail,omitempty"`
450+ NonExistJobIds []string `xml:"NonExistJobIds,omitempty"`
451+ }
452+
453+ func (s * CIService ) DescribeMultiMediaJob (ctx context.Context , jobids []string ) (* DescribeMutilMediaProcessJobResult , * Response , error ) {
454+ jobidsStr := ""
455+ if len (jobids ) < 1 {
456+ return nil , nil , errors .New ("empty param jobids" )
457+ } else {
458+ jobidsStr = strings .Join (jobids , "," )
459+ }
460+
461+ var res DescribeMutilMediaProcessJobResult
462+ sendOpt := sendOptions {
463+ baseURL : s .client .BaseURL .CIURL ,
464+ uri : "/jobs/" + jobidsStr ,
465+ method : http .MethodGet ,
466+ result : & res ,
467+ }
468+ resp , err := s .client .send (ctx , & sendOpt )
469+ return & res , resp , err
470+ }
471+
383472type DescribeMediaJobsOptions struct {
384473 QueueId string `url:"queueId,omitempty"`
385474 Tag string `url:"tag,omitempty"`
@@ -397,6 +486,7 @@ type DescribeMediaJobsResult struct {
397486 NextToken string `xml:"NextToken,omitempty"`
398487}
399488
489+ // https://cloud.tencent.com/document/product/460/48235
400490func (s * CIService ) DescribeMediaJobs (ctx context.Context , opt * DescribeMediaJobsOptions ) (* DescribeMediaJobsResult , * Response , error ) {
401491 var res DescribeMediaJobsResult
402492 sendOpt := sendOptions {
@@ -640,3 +730,29 @@ func (s *CIService) GetSnapshot(ctx context.Context, name string, opt *GetSnapsh
640730 resp , err := s .client .send (ctx , & sendOpt )
641731 return resp , err
642732}
733+
734+ type GetPrivateM3U8Options struct {
735+ Expires int `url:"expires"`
736+ }
737+
738+ // 获取私有m3u8资源接口 https://cloud.tencent.com/document/product/460/63738
739+ func (s * CIService ) GetPrivateM3U8 (ctx context.Context , name string , opt * GetPrivateM3U8Options , id ... string ) (* Response , error ) {
740+ var u string
741+ if len (id ) == 1 {
742+ u = fmt .Sprintf ("/%s?versionId=%s&ci-process=pm3u8" , encodeURIComponent (name ), id [0 ])
743+ } else if len (id ) == 0 {
744+ u = fmt .Sprintf ("/%s?ci-process=pm3u8" , encodeURIComponent (name ))
745+ } else {
746+ return nil , fmt .Errorf ("wrong params" )
747+ }
748+
749+ sendOpt := sendOptions {
750+ baseURL : s .client .BaseURL .BucketURL ,
751+ uri : u ,
752+ method : http .MethodGet ,
753+ optQuery : opt ,
754+ disableCloseBody : true ,
755+ }
756+ resp , err := s .client .send (ctx , & sendOpt )
757+ return resp , err
758+ }
0 commit comments