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.

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