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.

303 lines
10 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
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"`
  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"`
  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 MediaProcessJobOperation struct {
  89. Output *JobOutput `xml:"Output,omitempty"`
  90. Transcode *Transcode `xml:"Transcode,omitempty"`
  91. Watermark *Watermark `xml:"Watermark,omitempty"`
  92. TemplateId string `xml:"TemplateId,omitempty"`
  93. WatermarkTemplateId []string `xml:"WatermarkTemplateId,omitempty"`
  94. }
  95. type CreateMediaJobsOptions struct {
  96. XMLName xml.Name `xml:"Request"`
  97. Tag string `xml:"Tag,omitempty"`
  98. Input *JobInput `xml:"Input,omitempty"`
  99. Operation *MediaProcessJobOperation `xml:"Operation,omitempty"`
  100. QueueId string `xml:"QueueId,omitempty"`
  101. }
  102. type MediaProcessJobDetail struct {
  103. Code string `xml:"Code,omitempty"`
  104. Message string `xml:"Message,omitempty"`
  105. JobId string `xml:"JobId,omitempty"`
  106. Tag string `xml:"Tag,omitempty"`
  107. State string `xml:"State,omitempty"`
  108. CreationTime string `xml:"CreationTime,omitempty"`
  109. QueueId string `xml:"QueueId,omitempty"`
  110. Input *JobInput `xml:"Input,omitempty"`
  111. Operation *MediaProcessJobOperation `xml:"Operation,omitempty"`
  112. }
  113. type CreateMediaJobsResult struct {
  114. XMLName xml.Name `xml:"Response"`
  115. JobsDetail MediaProcessJobDetail `xml:"JobsDetail,omitempty"`
  116. }
  117. func (s *CIService) CreateMediaJobs(ctx context.Context, opt *CreateMediaJobsOptions) (*CreateMediaJobsResult, *Response, error) {
  118. var res CreateMediaJobsResult
  119. sendOpt := sendOptions{
  120. baseURL: s.client.BaseURL.CIURL,
  121. uri: "/jobs",
  122. method: http.MethodPost,
  123. body: opt,
  124. result: &res,
  125. }
  126. resp, err := s.client.send(ctx, &sendOpt)
  127. return &res, resp, err
  128. }
  129. type DescribeMediaProcessJobResult struct {
  130. XMLName xml.Name `xml:"Response"`
  131. JobsDetail *MediaProcessJobDetail `xml:"JobsDetail,omitempty"`
  132. NonExistJobIds string `xml:"NonExistJobIds,omitempty"`
  133. }
  134. func (s *CIService) DescribeMediaJobs(ctx context.Context, jobid string) (*DescribeMediaProcessJobResult, *Response, error) {
  135. var res DescribeMediaProcessJobResult
  136. sendOpt := sendOptions{
  137. baseURL: s.client.BaseURL.CIURL,
  138. uri: "/jobs/" + jobid,
  139. method: http.MethodGet,
  140. result: &res,
  141. }
  142. resp, err := s.client.send(ctx, &sendOpt)
  143. return &res, resp, err
  144. }
  145. type DescribeMediaProcessJobsOptions struct {
  146. QueueId string `url:"queueId,omitempty"`
  147. Tag string `url:"tag,omitempty"`
  148. OrderByTime string `url:"orderByTime,omitempty"`
  149. NextToken string `url:"nextToken,omitempty"`
  150. Size int `url:"size,omitempty"`
  151. States string `url:"states,omitempty"`
  152. StartCreationTime string `url:"startCreationTime,omitempty"`
  153. EndCreationTime string `url:"endCreationTime,omitempty"`
  154. }
  155. type DescribeMediaProcessJobsResult struct {
  156. XMLName xml.Name `xml:"Response"`
  157. JobsDetail []DocProcessJobDetail `xml:"JobsDetail,omitempty"`
  158. NextToken string `xml:"NextToken,omitempty"`
  159. }
  160. func (s *CIService) DescribeMediaProcessJobs(ctx context.Context, opt *DescribeMediaProcessJobsOptions) (*DescribeMediaProcessJobsResult, *Response, error) {
  161. var res DescribeMediaProcessJobsResult
  162. sendOpt := sendOptions{
  163. baseURL: s.client.BaseURL.CIURL,
  164. uri: "/jobs",
  165. optQuery: opt,
  166. method: http.MethodGet,
  167. result: &res,
  168. }
  169. resp, err := s.client.send(ctx, &sendOpt)
  170. return &res, resp, err
  171. }
  172. type DescribeMediaProcessQueuesOptions struct {
  173. QueueIds string `url:"queueIds,omitempty"`
  174. State string `url:"state,omitempty"`
  175. PageNumber int `url:"pageNumber,omitempty"`
  176. PageSize int `url:"pageSize,omitempty"`
  177. }
  178. type DescribeMediaProcessQueuesResult struct {
  179. XMLName xml.Name `xml:"Response"`
  180. RequestId string `xml:"RequestId,omitempty"`
  181. TotalCount int `xml:"TotalCount,omitempty"`
  182. PageNumber int `xml:"PageNumber,omitempty"`
  183. PageSize int `xml:"PageSize,omitempty"`
  184. QueueList []MediaProcessQueue `xml:"QueueList,omitempty"`
  185. NonExistPIDs []string `xml:"NonExistPIDs,omitempty"`
  186. }
  187. type MediaProcessQueue struct {
  188. QueueId string `xml:"QueueId,omitempty"`
  189. Name string `xml:"Name,omitempty"`
  190. State string `xml:"State,omitempty"`
  191. MaxSize int `xml:"MaxSize,omitempty"`
  192. MaxConcurrent int `xml:"MaxConcurrent,omitempty"`
  193. UpdateTime string `xml:"UpdateTime,omitempty"`
  194. CreateTime string `xml:"CreateTime,omitempty"`
  195. NotifyConfig *MediaProcessQueueNotifyConfig `xml:"NotifyConfig,omitempty"`
  196. }
  197. type MediaProcessQueueNotifyConfig struct {
  198. Url string `xml:"Url,omitempty"`
  199. State string `xml:"State,omitempty"`
  200. Type string `xml:"Type,omitempty"`
  201. Event string `xml:"Event,omitempty"`
  202. }
  203. func (s *CIService) DescribeMediaProcessQueues(ctx context.Context, opt *DescribeMediaProcessQueuesOptions) (*DescribeMediaProcessQueuesResult, *Response, error) {
  204. var res DescribeMediaProcessQueuesResult
  205. sendOpt := sendOptions{
  206. baseURL: s.client.BaseURL.CIURL,
  207. uri: "/queue",
  208. optQuery: opt,
  209. method: http.MethodGet,
  210. result: &res,
  211. }
  212. resp, err := s.client.send(ctx, &sendOpt)
  213. return &res, resp, err
  214. }
  215. type UpdateMediaProcessQueueOptions struct {
  216. XMLName xml.Name `xml:"Request"`
  217. Name string `xml:"Name,omitempty"`
  218. QueueID string `xml:"QueueID,omitempty"`
  219. State string `xml:"State,omitempty"`
  220. NotifyConfig *MediaProcessQueueNotifyConfig `xml:"NotifyConfig,omitempty"`
  221. }
  222. type UpdateMediaProcessQueueResult struct {
  223. XMLName xml.Name `xml:"Response"`
  224. RequestId string `xml:"RequestId"`
  225. Queue *MediaProcessQueue `xml:"Queue"`
  226. }
  227. func (s *CIService) UpdateMediaProcessQueue(ctx context.Context, opt *UpdateMediaProcessQueueOptions) (*UpdateMediaProcessQueueResult, *Response, error) {
  228. var res UpdateMediaProcessQueueResult
  229. sendOpt := sendOptions{
  230. baseURL: s.client.BaseURL.CIURL,
  231. uri: "/queue/" + opt.QueueID,
  232. body: opt,
  233. method: http.MethodPut,
  234. result: &res,
  235. }
  236. resp, err := s.client.send(ctx, &sendOpt)
  237. return &res, resp, err
  238. }
  239. type DescribeMediaProcessBucketsOptions struct {
  240. Regions string `url:"regions,omitempty"`
  241. BucketNames string `url:"bucketNames,omitempty"`
  242. BucketName string `url:"bucketName,omitempty"`
  243. PageNumber int `url:"pageNumber,omitempty"`
  244. PageSize int `url:"pageSize,omitempty"`
  245. }
  246. type DescribeMediaProcessBucketsResult struct {
  247. XMLName xml.Name `xml:"Response"`
  248. RequestId string `xml:"RequestId,omitempty"`
  249. TotalCount int `xml:"TotalCount,omitempty"`
  250. PageNumber int `xml:"PageNumber,omitempty"`
  251. PageSize int `xml:"PageSize,omitempty"`
  252. MediaBucketList []MediaProcessBucket `xml:"MediaBucketList,omitempty"`
  253. }
  254. type MediaProcessBucket struct {
  255. BucketId string `xml:"BucketId,omitempty"`
  256. Region string `xml:"Region,omitempty"`
  257. CreateTime string `xml:"CreateTime,omitempty"`
  258. }
  259. func (s *CIService) DescribeMediaProcessBuckets(ctx context.Context, opt *DescribeMediaProcessBucketsOptions) (*DescribeMediaProcessBucketsResult, *Response, error) {
  260. var res DescribeMediaProcessBucketsResult
  261. sendOpt := sendOptions{
  262. baseURL: s.client.BaseURL.CIURL,
  263. uri: "/mediabucket",
  264. optQuery: opt,
  265. method: http.MethodGet,
  266. result: &res,
  267. }
  268. resp, err := s.client.send(ctx, &sendOpt)
  269. return &res, resp, err
  270. }