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.

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