You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

316 lines
11 KiB

4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
3 years ago
3 years ago
3 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
  1. package cos
  2. import (
  3. "context"
  4. "encoding/xml"
  5. "net/http"
  6. )
  7. type JobInput struct {
  8. Object string `xml:"Object,omitempty"`
  9. }
  10. type JobOutput struct {
  11. Region string `xml:"Region,omitempty"`
  12. Bucket string `xml:"Bucket,omitempty"`
  13. Object string `xml:"Object,omitempty"`
  14. }
  15. type Container struct {
  16. Format string `xml:"Format"`
  17. }
  18. type Video struct {
  19. Codec string `xml:"Codec"`
  20. Width string `xml:"Width"`
  21. Height string `xml:"Height"`
  22. Fps string `xml:"Fps"`
  23. Remove string `xml:"Remove,omitempty"`
  24. Profile string `xml:"Profile"`
  25. Bitrate string `xml:"Bitrate"`
  26. Crf string `xml:"Crf"`
  27. Gop string `xml:"Gop"`
  28. Preset string `xml:"Preset"`
  29. Bufsize string `xml:"Bufsize"`
  30. Maxrate string `xml:"Maxrate"`
  31. HlsTsTime string `xml:"HlsTsTime"`
  32. Pixfmt string `xml:"Pixfmt"`
  33. LongShortMode string `xml:"LongShortMode"`
  34. }
  35. type TimeInterval struct {
  36. Start string `xml:"Start"`
  37. Duration string `xml:"Duration"`
  38. }
  39. type Audio struct {
  40. Codec string `xml:"Codec"`
  41. Samplerate string `xml:"Samplerate"`
  42. Bitrate string `xml:"Bitrate"`
  43. Channels string `xml:"Channels"`
  44. Remove string `xml:"Remove,omitempty"`
  45. }
  46. type TransConfig struct {
  47. AdjDarMethod string `xml:"AdjDarMethod"`
  48. IsCheckReso string `xml:"IsCheckReso"`
  49. ResoAdjMethod string `xml:"ResoAdjMethod"`
  50. IsCheckVideoBitrate string `xml:"IsCheckVideoBitrate"`
  51. VideoBitrateAdjMethod string `xml:"VideoBitrateAdjMethod"`
  52. IsCheckAudioBitrate string `xml:"IsCheckAudioBitrate"`
  53. AudioBitrateAdjMethod string `xml:"AudioBitrateAdjMethod"`
  54. }
  55. type Transcode struct {
  56. Container *Container `xml:"Container,omitempty"`
  57. Video *Video `xml:"Video,omitempty"`
  58. TimeInterval *TimeInterval `xml:"TimeInterval,omitempty"`
  59. Audio *Audio `xml:"Audio,omitempty"`
  60. TransConfig *TransConfig `xml:"TransConfig,omitempty"`
  61. }
  62. type Image struct {
  63. Url string `xml:"Url,omitempty"`
  64. Mode string `xml:"Mode,omitempty"`
  65. Width string `xml:"Width,omitempty"`
  66. Height string `xml:"Height,omitempty"`
  67. Transparency string `xml:"Transparency,omitempty"`
  68. Background string `xml:"Background,omitempty"`
  69. }
  70. type Text struct {
  71. FontSize string `xml:"FontSize,omitempty"`
  72. FontType string `xml:"FontType,omitempty"`
  73. FontColor string `xml:"FontColor,omitempty"`
  74. Transparency string `xml:"Transparency,omitempty"`
  75. Text string `xml:"Text,omitempty"`
  76. }
  77. type Watermark struct {
  78. Type string `xml:"Type,omitempty"`
  79. Pos string `xml:"Pos,omitempty"`
  80. LocMode string `xml:"LocMode,omitempty"`
  81. Dx string `xml:"Dx,omitempty"`
  82. Dy string `xml:"Dy,omitempty"`
  83. StartTime string `xml:"StartTime,omitempty"`
  84. EndTime string `xml:"EndTime,omitempty"`
  85. Image *Image `xml:"Image,omitempty"`
  86. Text *Text `xml:"Text,omitempty"`
  87. }
  88. type ConcatFragment struct {
  89. Url string `xml:"Url,omitempty"`
  90. StartTime string `xml:"StartTime,omitempty"`
  91. EndTime string `xml:"EndTime,omitempty"`
  92. }
  93. type ConcatTemplate struct {
  94. ConcatFragment []ConcatFragment `xml:"ConcatFragment,omitempty"`
  95. Audio *Audio `xml:"Audio,omitempty"`
  96. Video *Video `xml:"Video,omitempty"`
  97. Container *Container `xml:"Container,omitempty"`
  98. Index string `xml:"Index,omitempty"`
  99. }
  100. type MediaProcessJobOperation struct {
  101. Output *JobOutput `xml:"Output,omitempty"`
  102. Transcode *Transcode `xml:"Transcode,omitempty"`
  103. Watermark *Watermark `xml:"Watermark,omitempty"`
  104. TemplateId string `xml:"TemplateId,omitempty"`
  105. WatermarkTemplateId []string `xml:"WatermarkTemplateId,omitempty"`
  106. ConcatTemplate *ConcatTemplate `xml:"ConcatTemplate,omitempty"`
  107. }
  108. type CreateMediaJobsOptions struct {
  109. XMLName xml.Name `xml:"Request"`
  110. Tag string `xml:"Tag,omitempty"`
  111. Input *JobInput `xml:"Input,omitempty"`
  112. Operation *MediaProcessJobOperation `xml:"Operation,omitempty"`
  113. QueueId string `xml:"QueueId,omitempty"`
  114. CallBack string `xml:"CallBack,omitempty"`
  115. }
  116. type MediaProcessJobDetail struct {
  117. Code string `xml:"Code,omitempty"`
  118. Message string `xml:"Message,omitempty"`
  119. JobId string `xml:"JobId,omitempty"`
  120. Tag string `xml:"Tag,omitempty"`
  121. State string `xml:"State,omitempty"`
  122. CreationTime string `xml:"CreationTime,omitempty"`
  123. QueueId string `xml:"QueueId,omitempty"`
  124. Input *JobInput `xml:"Input,omitempty"`
  125. Operation *MediaProcessJobOperation `xml:"Operation,omitempty"`
  126. }
  127. type CreateMediaJobsResult struct {
  128. XMLName xml.Name `xml:"Response"`
  129. JobsDetail MediaProcessJobDetail `xml:"JobsDetail,omitempty"`
  130. }
  131. func (s *CIService) CreateMediaJobs(ctx context.Context, opt *CreateMediaJobsOptions) (*CreateMediaJobsResult, *Response, error) {
  132. var res CreateMediaJobsResult
  133. sendOpt := sendOptions{
  134. baseURL: s.client.BaseURL.CIURL,
  135. uri: "/jobs",
  136. method: http.MethodPost,
  137. body: opt,
  138. result: &res,
  139. }
  140. resp, err := s.client.send(ctx, &sendOpt)
  141. return &res, resp, err
  142. }
  143. type DescribeMediaProcessJobResult struct {
  144. XMLName xml.Name `xml:"Response"`
  145. JobsDetail *MediaProcessJobDetail `xml:"JobsDetail,omitempty"`
  146. NonExistJobIds string `xml:"NonExistJobIds,omitempty"`
  147. }
  148. func (s *CIService) DescribeMediaJob(ctx context.Context, jobid string) (*DescribeMediaProcessJobResult, *Response, error) {
  149. var res DescribeMediaProcessJobResult
  150. sendOpt := sendOptions{
  151. baseURL: s.client.BaseURL.CIURL,
  152. uri: "/jobs/" + jobid,
  153. method: http.MethodGet,
  154. result: &res,
  155. }
  156. resp, err := s.client.send(ctx, &sendOpt)
  157. return &res, resp, err
  158. }
  159. type DescribeMediaJobsOptions struct {
  160. QueueId string `url:"queueId,omitempty"`
  161. Tag string `url:"tag,omitempty"`
  162. OrderByTime string `url:"orderByTime,omitempty"`
  163. NextToken string `url:"nextToken,omitempty"`
  164. Size int `url:"size,omitempty"`
  165. States string `url:"states,omitempty"`
  166. StartCreationTime string `url:"startCreationTime,omitempty"`
  167. EndCreationTime string `url:"endCreationTime,omitempty"`
  168. }
  169. type DescribeMediaJobsResult struct {
  170. XMLName xml.Name `xml:"Response"`
  171. JobsDetail []DocProcessJobDetail `xml:"JobsDetail,omitempty"`
  172. NextToken string `xml:"NextToken,omitempty"`
  173. }
  174. func (s *CIService) DescribeMediaJobs(ctx context.Context, opt *DescribeMediaJobsOptions) (*DescribeMediaJobsResult, *Response, error) {
  175. var res DescribeMediaJobsResult
  176. sendOpt := sendOptions{
  177. baseURL: s.client.BaseURL.CIURL,
  178. uri: "/jobs",
  179. optQuery: opt,
  180. method: http.MethodGet,
  181. result: &res,
  182. }
  183. resp, err := s.client.send(ctx, &sendOpt)
  184. return &res, resp, err
  185. }
  186. type DescribeMediaProcessQueuesOptions struct {
  187. QueueIds string `url:"queueIds,omitempty"`
  188. State string `url:"state,omitempty"`
  189. PageNumber int `url:"pageNumber,omitempty"`
  190. PageSize int `url:"pageSize,omitempty"`
  191. }
  192. type DescribeMediaProcessQueuesResult struct {
  193. XMLName xml.Name `xml:"Response"`
  194. RequestId string `xml:"RequestId,omitempty"`
  195. TotalCount int `xml:"TotalCount,omitempty"`
  196. PageNumber int `xml:"PageNumber,omitempty"`
  197. PageSize int `xml:"PageSize,omitempty"`
  198. QueueList []MediaProcessQueue `xml:"QueueList,omitempty"`
  199. NonExistPIDs []string `xml:"NonExistPIDs,omitempty"`
  200. }
  201. type MediaProcessQueue struct {
  202. QueueId string `xml:"QueueId,omitempty"`
  203. Name string `xml:"Name,omitempty"`
  204. State string `xml:"State,omitempty"`
  205. MaxSize int `xml:"MaxSize,omitempty"`
  206. MaxConcurrent int `xml:"MaxConcurrent,omitempty"`
  207. UpdateTime string `xml:"UpdateTime,omitempty"`
  208. CreateTime string `xml:"CreateTime,omitempty"`
  209. NotifyConfig *MediaProcessQueueNotifyConfig `xml:"NotifyConfig,omitempty"`
  210. }
  211. type MediaProcessQueueNotifyConfig struct {
  212. Url string `xml:"Url,omitempty"`
  213. State string `xml:"State,omitempty"`
  214. Type string `xml:"Type,omitempty"`
  215. Event string `xml:"Event,omitempty"`
  216. }
  217. func (s *CIService) DescribeMediaProcessQueues(ctx context.Context, opt *DescribeMediaProcessQueuesOptions) (*DescribeMediaProcessQueuesResult, *Response, error) {
  218. var res DescribeMediaProcessQueuesResult
  219. sendOpt := sendOptions{
  220. baseURL: s.client.BaseURL.CIURL,
  221. uri: "/queue",
  222. optQuery: opt,
  223. method: http.MethodGet,
  224. result: &res,
  225. }
  226. resp, err := s.client.send(ctx, &sendOpt)
  227. return &res, resp, err
  228. }
  229. type UpdateMediaProcessQueueOptions struct {
  230. XMLName xml.Name `xml:"Request"`
  231. Name string `xml:"Name,omitempty"`
  232. QueueID string `xml:"QueueID,omitempty"`
  233. State string `xml:"State,omitempty"`
  234. NotifyConfig *MediaProcessQueueNotifyConfig `xml:"NotifyConfig,omitempty"`
  235. }
  236. type UpdateMediaProcessQueueResult struct {
  237. XMLName xml.Name `xml:"Response"`
  238. RequestId string `xml:"RequestId"`
  239. Queue *MediaProcessQueue `xml:"Queue"`
  240. }
  241. func (s *CIService) UpdateMediaProcessQueue(ctx context.Context, opt *UpdateMediaProcessQueueOptions) (*UpdateMediaProcessQueueResult, *Response, error) {
  242. var res UpdateMediaProcessQueueResult
  243. sendOpt := sendOptions{
  244. baseURL: s.client.BaseURL.CIURL,
  245. uri: "/queue/" + opt.QueueID,
  246. body: opt,
  247. method: http.MethodPut,
  248. result: &res,
  249. }
  250. resp, err := s.client.send(ctx, &sendOpt)
  251. return &res, resp, err
  252. }
  253. type DescribeMediaProcessBucketsOptions struct {
  254. Regions string `url:"regions,omitempty"`
  255. BucketNames string `url:"bucketNames,omitempty"`
  256. BucketName string `url:"bucketName,omitempty"`
  257. PageNumber int `url:"pageNumber,omitempty"`
  258. PageSize int `url:"pageSize,omitempty"`
  259. }
  260. type DescribeMediaProcessBucketsResult struct {
  261. XMLName xml.Name `xml:"Response"`
  262. RequestId string `xml:"RequestId,omitempty"`
  263. TotalCount int `xml:"TotalCount,omitempty"`
  264. PageNumber int `xml:"PageNumber,omitempty"`
  265. PageSize int `xml:"PageSize,omitempty"`
  266. MediaBucketList []MediaProcessBucket `xml:"MediaBucketList,omitempty"`
  267. }
  268. type MediaProcessBucket struct {
  269. BucketId string `xml:"BucketId,omitempty"`
  270. Region string `xml:"Region,omitempty"`
  271. CreateTime string `xml:"CreateTime,omitempty"`
  272. }
  273. func (s *CIService) DescribeMediaProcessBuckets(ctx context.Context, opt *DescribeMediaProcessBucketsOptions) (*DescribeMediaProcessBucketsResult, *Response, error) {
  274. var res DescribeMediaProcessBucketsResult
  275. sendOpt := sendOptions{
  276. baseURL: s.client.BaseURL.CIURL,
  277. uri: "/mediabucket",
  278. optQuery: opt,
  279. method: http.MethodGet,
  280. result: &res,
  281. }
  282. resp, err := s.client.send(ctx, &sendOpt)
  283. return &res, resp, err
  284. }