Commit 6ebb2230dde6eafab20799aeaa201dce65e70e3f
1 parent
b9f453df
添加直播接口
Showing
7 changed files
with
171 additions
and
77 deletions
.settings/org.eclipse.wst.common.component
| ... | ... | @@ -14,15 +14,6 @@ |
| 14 | 14 | <dependent-module archiveName="smart-framework-4.0.0.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/smart-framework/smart-framework"> |
| 15 | 15 | <dependency-type>uses</dependency-type> |
| 16 | 16 | </dependent-module> |
| 17 | - <dependent-module archiveName="smart-plugin-dbcp-1.0.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/smart-plugin-dbcp/smart-plugin-dbcp"> | |
| 18 | - <dependency-type>uses</dependency-type> | |
| 19 | - </dependent-module> | |
| 20 | - <dependent-module archiveName="smart-plugin-rest-1.0.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/smart-plugin-rest/smart-plugin-rest"> | |
| 21 | - <dependency-type>uses</dependency-type> | |
| 22 | - </dependent-module> | |
| 23 | - <dependent-module archiveName="smart-plugin-i18n-1.0.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/smart-plugin-i18n/smart-plugin-i18n"> | |
| 24 | - <dependency-type>uses</dependency-type> | |
| 25 | - </dependent-module> | |
| 26 | 17 | <dependent-module archiveName="cnlive_mam_commons-0.0.1-SNAPSHOT.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/cnlive_mam_commons/cnlive_mam_commons"> |
| 27 | 18 | <dependency-type>uses</dependency-type> |
| 28 | 19 | </dependent-module> | ... | ... |
src/main/java/com/cnlive/mz/live/action/VideoAction.java
0 → 100644
| 1 | +package com.cnlive.mz.live.action; | |
| 2 | + | |
| 3 | +import java.util.Date; | |
| 4 | +import java.util.LinkedHashMap; | |
| 5 | +import java.util.Map; | |
| 6 | + | |
| 7 | +import org.smart4j.framework.dao.bean.Pager; | |
| 8 | +import org.smart4j.framework.ioc.annotation.Inject; | |
| 9 | +import org.smart4j.framework.mvc.annotation.Action; | |
| 10 | +import org.smart4j.framework.mvc.annotation.Request; | |
| 11 | +import org.smart4j.framework.mvc.bean.ApiBean; | |
| 12 | +import org.smart4j.framework.mvc.bean.Params; | |
| 13 | + | |
| 14 | +import com.cnlive.mz.commons.CnliveUtil; | |
| 15 | +import com.cnlive.mz.live.entity.TApp; | |
| 16 | +import com.cnlive.mz.live.entity.TLive; | |
| 17 | +import com.cnlive.mz.live.entity.TVideo; | |
| 18 | +import com.cnlive.mz.live.service.TAppService; | |
| 19 | +import com.cnlive.mz.live.service.TDispatchServerService; | |
| 20 | +import com.cnlive.mz.live.service.TLiveService; | |
| 21 | +import com.cnlive.mz.live.service.TUserService; | |
| 22 | +import com.cnlive.mz.live.service.TVideoService; | |
| 23 | + | |
| 24 | +@Action | |
| 25 | +public class VideoAction { | |
| 26 | + @Inject | |
| 27 | + private TDispatchServerService tDispatchServerService; | |
| 28 | + @Inject | |
| 29 | + private TAppService tAppService; | |
| 30 | + @Inject | |
| 31 | + private TVideoService tVideoService; | |
| 32 | + @Inject | |
| 33 | + private TUserService tUserService; | |
| 34 | + @Inject | |
| 35 | + private TLiveService tLiveService; | |
| 36 | + | |
| 37 | + /** | |
| 38 | + * 服务器定向 | |
| 39 | + * | |
| 40 | + * @param params | |
| 41 | + * @return | |
| 42 | + * {"mediaComment":"","nickName":"阳Sir","appId":"1","mediaName":"","userId" | |
| 43 | + * :"1167015","uuid": | |
| 44 | + * "1167015_1463725085798_6a551f9122494a05ac8566b7a2ae1092"} | |
| 45 | + */ | |
| 46 | + @Request.Post("/api/video/redirect") | |
| 47 | + public ApiBean redirect(Params params) { | |
| 48 | + String app_access_key = params.getString("app_access_key"); | |
| 49 | + String video_type = params.getString("video_type"); | |
| 50 | + String userId = params.getString("userId"); | |
| 51 | + TApp app = tAppService.getAppByAccessKey(app_access_key); | |
| 52 | + ApiBean apiBean = new ApiBean(); | |
| 53 | + apiBean.setCode(100); | |
| 54 | + apiBean.setMessage("请求成功"); | |
| 55 | + Map map = tDispatchServerService.getDispatchServer(app, video_type, app_access_key); | |
| 56 | + String chat_room_id = ""; | |
| 57 | + int active_id = 0; | |
| 58 | + String ks_id = ""; | |
| 59 | + if (video_type.equals("3")) { | |
| 60 | + TLive tLive = tLiveService.save(Integer.parseInt(userId)); | |
| 61 | + chat_room_id = tLive.getChat_room_id(); | |
| 62 | + active_id = tLive.getId(); | |
| 63 | + ks_id = userId + "_" + tLive.getId(); | |
| 64 | + } | |
| 65 | + map.put("chat_room_id", chat_room_id); | |
| 66 | + map.put("active_id", active_id); | |
| 67 | + map.put("ks_id", ks_id); | |
| 68 | + apiBean.setData(map); | |
| 69 | + return apiBean; | |
| 70 | + } | |
| 71 | + | |
| 72 | + @Request.Post("/api/video/supload") | |
| 73 | + public ApiBean supload(Params params) { | |
| 74 | + Map data = new LinkedHashMap(); | |
| 75 | + String app_access_key = params.getString("app_access_key"); | |
| 76 | + String video_type = params.getString("video_type"); | |
| 77 | + String user_access_key = params.getString("user_access_key"); | |
| 78 | + String server_access_key = params.getString("server_access_key"); | |
| 79 | + String active_id = params.getString("active_id"); | |
| 80 | + String title = params.getString("title"); | |
| 81 | + String description = params.getString("description"); | |
| 82 | + String args = params.getString("custom_args"); | |
| 83 | + String uuid = CnliveUtil.getUUID(); | |
| 84 | + String md5 = params.getString("md5"); | |
| 85 | + String relation_id = params.getString("relation_id"); | |
| 86 | + if (video_type.equals("2")) { | |
| 87 | + // 2:sdk上传录播文件 | |
| 88 | + TVideo tVideo = new TVideo(); | |
| 89 | + tVideo.setCustom_args(args); | |
| 90 | + tVideo.setRelation_id(relation_id); | |
| 91 | + tVideo.setName(params.getString("name")); | |
| 92 | + tVideo.setVideo_type(params.getString("video_type")); | |
| 93 | + tVideo.setPlat(params.getString("plat")); | |
| 94 | + tVideo.setState(207); | |
| 95 | + tVideo.setMd5(md5); | |
| 96 | + tVideo.setVideo_uuid(uuid); | |
| 97 | + tVideo.setTitle(title); | |
| 98 | + tVideo.setDescription(description); | |
| 99 | + tVideoService.saveSdkVideo(tVideo, server_access_key, user_access_key, app_access_key); | |
| 100 | + } else if (video_type.equals("3")) { | |
| 101 | + // 3: sdk直播上传文件 | |
| 102 | + TLive tLive = tLiveService.getTLiveById(Integer.parseInt(active_id)); | |
| 103 | + tLive.setTitle(title); | |
| 104 | + tLive.setDescription(description); | |
| 105 | + tLive.setStart_time(new Date()); | |
| 106 | + tLive.setUuid(uuid); | |
| 107 | + tLive.setUser_uuid(params.getString("name")); | |
| 108 | + tLive.setRelation_id(relation_id); | |
| 109 | + tLive.setLive_url("http://cnlive.hlslive.ks-cdn.com/live/" + relation_id + "_" + tLive.getId() | |
| 110 | + + "/index.m3u8"); | |
| 111 | + tLiveService.startLive(tLive); | |
| 112 | + } | |
| 113 | + data.put("video_uuid", uuid); | |
| 114 | + ApiBean apiBean = new ApiBean(); | |
| 115 | + apiBean.setCode(100); | |
| 116 | + apiBean.setMessage("请求成功"); | |
| 117 | + apiBean.setData(data); | |
| 118 | + return apiBean; | |
| 119 | + } | |
| 120 | + | |
| 121 | + @Request.Post("/api/video/all") | |
| 122 | + public ApiBean all(Params params) { | |
| 123 | + String app_access_key = params.getString("app_access_key"); | |
| 124 | + String relationId = params.getString("relation_id"); | |
| 125 | + String pageNo = params.getString("page_no"); | |
| 126 | + String relation_id = params.getString("relation_id"); | |
| 127 | + String upload_type = params.getString("upload_type"); | |
| 128 | + String page_no = params.getString("page_no"); | |
| 129 | + String video_type = params.getString("video_type"); | |
| 130 | + Pager<TVideo> page = tVideoService.findAll(app_access_key, relationId, pageNo); | |
| 131 | + ApiBean apiBean = new ApiBean(); | |
| 132 | + apiBean.setCode(100); | |
| 133 | + apiBean.setMessage("请求成功"); | |
| 134 | + apiBean.setData(page); | |
| 135 | + return apiBean; | |
| 136 | + } | |
| 137 | + | |
| 138 | + @Request.Post("/api/video/uploadNotify") | |
| 139 | + public ApiBean uploadNotify(Params params) { | |
| 140 | + String video_uuid = params.getString("video_uuid"); | |
| 141 | + String upload_type = params.getString("upload_type"); | |
| 142 | + String video_type = params.getString("video_type"); | |
| 143 | + String state = params.getString("state"); | |
| 144 | + if (video_type.equals("2")) { | |
| 145 | + // 点播通知 | |
| 146 | + tVideoService.notify(video_uuid); | |
| 147 | + } else if (video_type.equals("3")) { | |
| 148 | + // 直播通知 | |
| 149 | + tLiveService.notify(video_uuid); | |
| 150 | + } | |
| 151 | + ApiBean apiBean = new ApiBean(); | |
| 152 | + apiBean.setCode(100); | |
| 153 | + apiBean.setMessage("请求成功"); | |
| 154 | + return apiBean; | |
| 155 | + } | |
| 156 | + | |
| 157 | + @Request.Post("/api/video/delete") | |
| 158 | + public ApiBean delete(Params params) { | |
| 159 | + String user_access_key = params.getString("user_access_key"); | |
| 160 | + String video_uuid = params.getString("video_uuid"); | |
| 161 | + String app_access_key = params.getString("app_access_key"); | |
| 162 | + String video_type = params.getString("video_type");// 视频类型 | |
| 163 | + tVideoService.delete(video_uuid); | |
| 164 | + ApiBean apiBean = new ApiBean(); | |
| 165 | + apiBean.setCode(100); | |
| 166 | + apiBean.setMessage("请求成功"); | |
| 167 | + return apiBean; | |
| 168 | + } | |
| 169 | +} | ... | ... |
src/main/java/com/cnlive/mz/live/action/VideoApiAction.java deleted
100644 → 0
| 1 | -package com.cnlive.mz.live.action; | |
| 2 | - | |
| 3 | -import org.smart4j.framework.ioc.annotation.Inject; | |
| 4 | -import org.smart4j.framework.mvc.annotation.Action; | |
| 5 | -import org.smart4j.framework.mvc.annotation.Request; | |
| 6 | -import org.smart4j.framework.mvc.bean.Params; | |
| 7 | -import org.smart4j.framework.mvc.bean.Result; | |
| 8 | - | |
| 9 | -import com.cnlive.mz.live.entity.ResultBean; | |
| 10 | -import com.cnlive.mz.live.entity.TApp; | |
| 11 | -import com.cnlive.mz.live.service.AppService; | |
| 12 | -import com.cnlive.mz.live.service.VideoApiService; | |
| 13 | - | |
| 14 | -@Action | |
| 15 | -public class VideoApiAction { | |
| 16 | - @Inject | |
| 17 | - private VideoApiService videoApiService; | |
| 18 | - @Inject | |
| 19 | - private AppService appService; | |
| 20 | - | |
| 21 | - @Request.Post("com/api/video/redirect") | |
| 22 | - public Result redirect(Params params) { | |
| 23 | - String app_access_key = params.getString("app_access_key"); | |
| 24 | - String video_type = params.getString("video_type"); | |
| 25 | - TApp app =appService.getAppByAccessKey(app_access_key); | |
| 26 | - //String ip = getRequest().getRemoteAddr(); | |
| 27 | - String ip =null; | |
| 28 | - ResultBean resultBean = new ResultBean(); | |
| 29 | - resultBean.setCode(100); | |
| 30 | - resultBean.setMessage("请求成功"); | |
| 31 | - resultBean.setData(videoApiService.getDispatchServer(app,ip, video_type, app_access_key)); | |
| 32 | - Result result= new Result(true); | |
| 33 | - return result.data(resultBean); | |
| 34 | - } | |
| 35 | - @Request.Post("com/api/video/all") | |
| 36 | - public Result all(Params params){ | |
| 37 | - String app_access_key =params.getString("app_access_key"); | |
| 38 | - String relationId = params.getString("relation_id"); | |
| 39 | - String pageNo = params.getString("page_no"); | |
| 40 | - ResultBean resultBean = new ResultBean(); | |
| 41 | - resultBean.setCode(100); | |
| 42 | - resultBean.setMessage("请求成功"); | |
| 43 | - resultBean.setData(videoApiService.findAll(app_access_key, relationId, pageNo)); | |
| 44 | - Result result= new Result(true); | |
| 45 | - return result.data(resultBean); | |
| 46 | - } | |
| 47 | - /*@Request.Post("com/api/video/uploadNotify") | |
| 48 | - public Result uploadNotify(Params params){ | |
| 49 | - String video_uuid = params.getString("video_uuid"); | |
| 50 | - System.out.println("video_uuid:" + video_uuid); | |
| 51 | - String upload_type = params.getString("upload_type"); | |
| 52 | - int video_type = params.getInt("video_type"); | |
| 53 | - String state = params.getString("state"); | |
| 54 | - videoApiService.notify(video_uuid, upload_type, video_type, state); | |
| 55 | - Result result= new Result(true); | |
| 56 | - return result.data(new ResultBean(100, "请求成功", null)); | |
| 57 | - }*/ | |
| 58 | - public static void main(String[] args) { | |
| 59 | - | |
| 60 | - } | |
| 61 | -} |
src/main/webapp/static/assets/cnlive/336x220.jpg
0 → 100644
9.06 KB
target/m2e-wtp/web-resources/META-INF/MANIFEST.MF
target/m2e-wtp/web-resources/META-INF/maven/com.cnlive.mz.live.web/cnlive_live_web/pom.properties
target/m2e-wtp/web-resources/META-INF/maven/com.cnlive.mz.live.web/cnlive_live_web/pom.xml
| ... | ... | @@ -53,11 +53,6 @@ |
| 53 | 53 | <artifactId>cnlive_live_model</artifactId> |
| 54 | 54 | <version>0.0.1-SNAPSHOT</version> |
| 55 | 55 | </dependency> |
| 56 | - <dependency> | |
| 57 | - <groupId>com.cnlive</groupId> | |
| 58 | - <artifactId>cnlive_media_tools</artifactId> | |
| 59 | - <version>1.0.0</version> | |
| 60 | - </dependency> | |
| 61 | 56 | </dependencies> |
| 62 | 57 | <packaging>war</packaging> |
| 63 | 58 | </project> | ... | ... |