Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
S
sentinel
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
曲欣亮
sentinel
Commits
e3025edb
Commit
e3025edb
authored
Feb 14, 2019
by
Quxl
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of
http://key@gitlab.egolm.com/hanxu/siff-film-api.git
parents
363940c8
e9e40a82
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
592 additions
and
401 deletions
+592
-401
AliyunApiController.java
...main/java/com/egolm/film/api/web/AliyunApiController.java
+114
-2
AliyunSign.java
src/main/java/com/egolm/film/util/AliyunSign.java
+246
-169
AliyunUtil.java
src/main/java/com/egolm/film/util/AliyunUtil.java
+228
-228
application-dev.properties
src/main/resources/application-dev.properties
+2
-1
application-pro.properties
src/main/resources/application-pro.properties
+2
-1
No files found.
src/main/java/com/egolm/film/api/web/AliyunApiController.java
View file @
e3025edb
...
@@ -12,12 +12,16 @@ import org.springframework.web.bind.annotation.RequestMapping;
...
@@ -12,12 +12,16 @@ import org.springframework.web.bind.annotation.RequestMapping;
import
org.springframework.web.bind.annotation.RequestMethod
;
import
org.springframework.web.bind.annotation.RequestMethod
;
import
org.springframework.web.bind.annotation.ResponseBody
;
import
org.springframework.web.bind.annotation.ResponseBody
;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONObject
;
import
com.aliyuncs.vod.model.v20170321.CreateUploadVideoResponse
;
import
com.aliyuncs.vod.model.v20170321.CreateUploadVideoResponse
;
import
com.aliyuncs.vod.model.v20170321.GetVideoPlayAuthResponse
;
import
com.aliyuncs.vod.model.v20170321.GetVideoPlayAuthResponse
;
import
com.aliyuncs.vod.model.v20170321.RefreshUploadVideoResponse
;
import
com.aliyuncs.vod.model.v20170321.RefreshUploadVideoResponse
;
import
com.egolm.common.HttpUtil
;
import
com.egolm.common.StringUtil
;
import
com.egolm.common.StringUtil
;
import
com.egolm.common.bean.Rjx
;
import
com.egolm.common.bean.Rjx
;
import
com.egolm.film.api.service.Messages
;
import
com.egolm.film.api.service.Messages
;
import
com.egolm.film.util.AliyunSign
;
import
com.egolm.film.util.AliyunUtil
;
import
com.egolm.film.util.AliyunUtil
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.Api
;
...
@@ -36,6 +40,10 @@ public class AliyunApiController {
...
@@ -36,6 +40,10 @@ public class AliyunApiController {
@Value
(
"${aliyun.sts.accessKeySecret}"
)
@Value
(
"${aliyun.sts.accessKeySecret}"
)
private
String
accessKeySecret
;
private
String
accessKeySecret
;
@Value
(
"${aliyun.video.templateId}"
)
private
String
templateId
;
@Autowired
@Autowired
private
Messages
messages
;
private
Messages
messages
;
...
@@ -74,7 +82,7 @@ public class AliyunApiController {
...
@@ -74,7 +82,7 @@ public class AliyunApiController {
return
Rjx
.
jsonOk
().
set
(
"RequestId"
,
response
.
getRequestId
()).
set
(
"UploadAuth"
,
response
.
getUploadAuth
())
return
Rjx
.
jsonOk
().
set
(
"RequestId"
,
response
.
getRequestId
()).
set
(
"UploadAuth"
,
response
.
getUploadAuth
())
.
set
(
"UploadAddress"
,
response
.
getUploadAddress
())
.
set
(
"UploadAddress"
,
response
.
getUploadAddress
())
.
set
(
"VideoId"
,
response
.
getVideoId
());
.
set
(
"VideoId"
,
response
.
getVideoId
())
.
set
(
"templateId"
,
templateId
)
;
}
}
...
@@ -93,7 +101,7 @@ public class AliyunApiController {
...
@@ -93,7 +101,7 @@ public class AliyunApiController {
AliyunUtil
aliyunUtil
=
new
AliyunUtil
(
accessKeyId
,
accessKeySecret
);
AliyunUtil
aliyunUtil
=
new
AliyunUtil
(
accessKeyId
,
accessKeySecret
);
RefreshUploadVideoResponse
response
=
aliyunUtil
.
refreshUploadVideo
(
videoId
);
RefreshUploadVideoResponse
response
=
aliyunUtil
.
refreshUploadVideo
(
videoId
);
if
(
response
!=
null
)
{
if
(
response
!=
null
)
{
return
Rjx
.
jsonOk
().
set
(
"RequestId"
,
response
.
getRequestId
()).
set
(
"UploadAuth"
,
response
.
getUploadAuth
()).
set
(
"UploadAddress"
,
response
.
getUploadAddress
());
return
Rjx
.
jsonOk
().
set
(
"RequestId"
,
response
.
getRequestId
()).
set
(
"UploadAuth"
,
response
.
getUploadAuth
()).
set
(
"UploadAddress"
,
response
.
getUploadAddress
())
.
set
(
"templateId"
,
templateId
)
;
}
else
{
}
else
{
return
Rjx
.
jsonErr
().
setCode
(-
1
).
setMessage
(
"InvalidVideo.NotFound : The video does not exist."
);
return
Rjx
.
jsonErr
().
setCode
(-
1
).
setMessage
(
"InvalidVideo.NotFound : The video does not exist."
);
}
}
...
@@ -129,5 +137,109 @@ public class AliyunApiController {
...
@@ -129,5 +137,109 @@ public class AliyunApiController {
}
}
}
}
/**
* https://help.aliyun.com/document_detail/52839.html?spm=a2c4g.11186623.2.16.56da9028Qxc5wl#TranscodeTemplate
* @Title: transcode
* @Description: TODO(这里用一句话描述这个方法的作用)
* @param: @param request
* @param: @return
* @return: Object
* @throws
*/
@ResponseBody
@ApiOperation
(
"新增视频转码模板"
)
@ApiImplicitParams
({
@ApiImplicitParam
(
paramType
=
"query"
,
name
=
"templateName"
,
dataType
=
"String"
,
required
=
true
,
value
=
"转码组名称"
,
defaultValue
=
""
),
@ApiImplicitParam
(
paramType
=
"query"
,
name
=
"watermarkIds"
,
dataType
=
"String"
,
required
=
true
,
value
=
"水印ID(值来源于水印管理)"
,
defaultValue
=
""
),
})
@RequestMapping
(
value
=
"/addTranscodeTemplate"
,
method
=
RequestMethod
.
GET
)
public
Object
addTranscodeTemplate
(
HttpServletRequest
request
)
{
String
templateName
=
request
.
getParameter
(
"templateName"
);
String
watermarkIds
=
request
.
getParameter
(
"watermarkIds"
);
if
(!
StringUtil
.
isNotEmpty
(
templateName
,
watermarkIds
))
{
return
Rjx
.
jsonErr
().
setCode
(-
1
).
setMessage
(
"参数不能为空"
);
}
//模板参数信息
JSONObject
videoObj
=
new
JSONObject
();
videoObj
.
put
(
"Codec"
,
"H.264"
);
videoObj
.
put
(
"Bitrate"
,
"900"
);
videoObj
.
put
(
"Width"
,
"960"
);
videoObj
.
put
(
"Height"
,
"540"
);
videoObj
.
put
(
"Remove"
,
false
);
videoObj
.
put
(
"Fps"
,
"25"
);
videoObj
.
put
(
"Gop"
,
"250"
);
JSONObject
audioObj
=
new
JSONObject
();
audioObj
.
put
(
"Codec"
,
"AAC"
);
audioObj
.
put
(
"Bitrate"
,
"96"
);
audioObj
.
put
(
"Remove"
,
false
);
audioObj
.
put
(
"Samplerate"
,
"44100"
);
audioObj
.
put
(
"Channels"
,
"2"
);
JSONObject
containerObj
=
new
JSONObject
();
containerObj
.
put
(
"Format"
,
"m3u8"
);
//填m3u8 生成的格式就为 hls
JSONObject
muxConfigObj
=
new
JSONObject
();
JSONObject
segmentObj
=
new
JSONObject
();
segmentObj
.
put
(
"Duration"
,
"10"
);
muxConfigObj
.
put
(
"Segment"
,
segmentObj
);
JSONObject
encryptSettingObj
=
new
JSONObject
();
encryptSettingObj
.
put
(
"EncryptType"
,
"Private"
);
JSONObject
packageSettingObj
=
new
JSONObject
();
packageSettingObj
.
put
(
"PackageType"
,
"HLSPackage"
);
JSONObject
packageConfigObj
=
new
JSONObject
();
packageConfigObj
.
put
(
"BandWidth"
,
"900000"
);
packageSettingObj
.
put
(
"PackageConfig"
,
packageConfigObj
);
JSONObject
obj
=
new
JSONObject
();
obj
.
put
(
"Video"
,
videoObj
);
obj
.
put
(
"Audio"
,
audioObj
);
obj
.
put
(
"Container"
,
containerObj
);
obj
.
put
(
"MuxConfig"
,
muxConfigObj
);
obj
.
put
(
"EncryptSetting"
,
encryptSettingObj
);
//obj.put("PackageSetting", packageSettingObj);
obj
.
put
(
"WatermarkIds"
,
watermarkIds
);
obj
.
put
(
"Definition"
,
"SD"
);
//原画
obj
.
put
(
"TemplateName"
,
templateName
);
JSONArray
array
=
new
JSONArray
();
array
.
add
(
obj
);
//生成私有参数,不同API需要修改
Map
<
String
,
String
>
privateParams
=
new
HashMap
<
String
,
String
>();
privateParams
.
put
(
"Action"
,
"AddTranscodeTemplateGroup"
);
privateParams
.
put
(
"Name"
,
templateName
);
privateParams
.
put
(
"TranscodeTemplateList"
,
array
.
toJSONString
());
System
.
out
.
println
(
array
.
toJSONString
());
//生成公共参数,不需要修改
Map
<
String
,
String
>
publicParams
=
AliyunSign
.
generatePublicParamters
();
//生成OpenAPI地址,不需要修改
String
URL
=
AliyunSign
.
generateOpenAPIURL
(
publicParams
,
privateParams
);
//发送HTTP GET 请求
String
result
=
HttpUtil
.
get
(
URL
);
System
.
out
.
println
(
result
);
return
result
;
}
}
}
src/main/java/com/egolm/film/util/AliyunSign.java
View file @
e3025edb
This diff is collapsed.
Click to expand it.
src/main/java/com/egolm/film/util/AliyunUtil.java
View file @
e3025edb
...
@@ -213,7 +213,7 @@ public class AliyunUtil {
...
@@ -213,7 +213,7 @@ public class AliyunUtil {
// API名称
// API名称
privateParams
.
put
(
"Action"
,
"GetVideoPlayAuth"
);
privateParams
.
put
(
"Action"
,
"GetVideoPlayAuth"
);
String
url
=
AliyunSign
.
generate
URL
(
"GET"
,
this
.
accessKeyId
,
publicParams
,
privateParams
);
String
url
=
AliyunSign
.
generate
OpenAPIURL
(
publicParams
,
privateParams
);
String
result
=
HttpsUtil
.
doGet
(
url
);
String
result
=
HttpsUtil
.
doGet
(
url
);
System
.
out
.
println
(
result
);
System
.
out
.
println
(
result
);
...
...
src/main/resources/application-dev.properties
View file @
e3025edb
...
@@ -36,5 +36,6 @@ spring.datasource.min-idle=10
...
@@ -36,5 +36,6 @@ spring.datasource.min-idle=10
aliyun.sts.accessKeyId
=
LTAIOtHCCpDLXYp8
aliyun.sts.accessKeyId
=
LTAIOtHCCpDLXYp8
aliyun.sts.accessKeySecret
=
9XTHW7P9TTRvCsBHBSclOue2tdWOoa
aliyun.sts.accessKeySecret
=
9XTHW7P9TTRvCsBHBSclOue2tdWOoa
#\u89C6\u9891\u8F6C\u7801ID
aliyun.video.templateId
=
d9f4a79cba14ce4cbc98d6516d35bf37
opt.project.type
=
1
opt.project.type
=
1
\ No newline at end of file
src/main/resources/application-pro.properties
View file @
e3025edb
...
@@ -35,5 +35,6 @@ spring.datasource.min-idle=10
...
@@ -35,5 +35,6 @@ spring.datasource.min-idle=10
aliyun.sts.accessKeyId
=
LTAIOtHCCpDLXYp8
aliyun.sts.accessKeyId
=
LTAIOtHCCpDLXYp8
aliyun.sts.accessKeySecret
=
9XTHW7P9TTRvCsBHBSclOue2tdWOoa
aliyun.sts.accessKeySecret
=
9XTHW7P9TTRvCsBHBSclOue2tdWOoa
#\u89C6\u9891\u8F6C\u7801ID
aliyun.video.templateId
=
d9f4a79cba14ce4cbc98d6516d35bf37
opt.project.type
=
1
opt.project.type
=
1
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment