Commit 4593c890f955d2172baba2d011d9856f017f30fe

Authored by 刘基城
2 parents b6b7b17f 4f74989d

Merge branch 'v532' into 'master'

添加直播回放act



See merge request !7
.settings/org.eclipse.wst.common.component
... ... @@ -8,10 +8,16 @@
8 8 <dependent-module archiveName="cnlive_live_model-0.0.1-SNAPSHOT.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/cnlive_live_model/cnlive_live_model">
9 9 <dependency-type>uses</dependency-type>
10 10 </dependent-module>
11   - <dependent-module archiveName="cnlive_ks3-1.0-SNAPSHOT.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/cnlive_ks3/cnlive_ks3">
  11 + <dependent-module archiveName="smart-framework-4.0.0.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/smart-framework/smart-framework">
12 12 <dependency-type>uses</dependency-type>
13 13 </dependent-module>
14   - <dependent-module archiveName="smart-framework-4.0.0.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/smart-framework/smart-framework">
  14 + <dependent-module archiveName="smart-plugin-dbcp-1.0.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/smart-plugin-dbcp/smart-plugin-dbcp">
  15 + <dependency-type>uses</dependency-type>
  16 + </dependent-module>
  17 + <dependent-module archiveName="smart-plugin-rest-1.0.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/smart-plugin-rest/smart-plugin-rest">
  18 + <dependency-type>uses</dependency-type>
  19 + </dependent-module>
  20 + <dependent-module archiveName="smart-plugin-i18n-1.0.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/smart-plugin-i18n/smart-plugin-i18n">
15 21 <dependency-type>uses</dependency-type>
16 22 </dependent-module>
17 23 <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">
... ...
src/main/java/com/cnlive/mz/live/action/CopyOfIndexAction.java deleted 100644 → 0
1   -/**
2   - * Project Name:cnlive_live_web
3   - * File Name:IndexAction.java
4   - * Package Name:com.cnlive.mz.live.action
5   - * Date:2015年8月3日下午3:18:31
6   - * Copyright (c) 2015, cnlive.com All Rights Reserved.
7   - *
8   - */
9   -
10   -package com.cnlive.mz.live.action;
11   -
12   -import java.io.File;
13   -import java.util.HashMap;
14   -import java.util.LinkedHashMap;
15   -import java.util.Map;
16   -
17   -import net.sf.json.JSONObject;
18   -
19   -import org.apache.commons.lang.StringUtils;
20   -import org.smart4j.framework.ioc.annotation.Inject;
21   -import org.smart4j.framework.mvc.annotation.Action;
22   -import org.smart4j.framework.mvc.annotation.Request;
23   -import org.smart4j.framework.mvc.bean.Params;
24   -
25   -import com.cnlive.mz.live.bean.Account;
26   -import com.cnlive.ksyun.KsYun;
27   -import com.cnlive.mz.commons.CNLiveFFmpeg;
28   -import com.cnlive.mz.commons.CnliveUtil;
29   -import com.cnlive.mz.commons.DateUtil;
30   -import com.cnlive.mz.commons.JsonUtil;
31   -import com.cnlive.mz.commons.net.HttpReq;
32   -import com.cnlive.mz.commons.sys.Scp;
33   -import com.cnlive.mz.live.bean.ResultBean;
34   -import com.cnlive.mz.live.entity.TApp;
35   -import com.cnlive.mz.live.entity.TDispatchServer;
36   -import com.cnlive.mz.live.entity.TUser;
37   -import com.cnlive.mz.live.entity.TVideo;
38   -import com.cnlive.mz.live.service.TActivityService;
39   -import com.cnlive.mz.live.service.TAppService;
40   -import com.cnlive.mz.live.service.TChannelService;
41   -import com.cnlive.mz.live.service.TDispatchServerService;
42   -import com.cnlive.mz.live.service.TUserService;
43   -import com.cnlive.mz.live.service.TVideoService;
44   -import com.cnlive.mz.live.service.TWowzaService;
45   -
46   -@Action
47   -public class CopyOfIndexAction {
48   - @Inject
49   - private TChannelService tChannelService;
50   - @Inject
51   - private TActivityService tActivityService;
52   - @Inject
53   - private TWowzaService tWowzaService;
54   -
55   - @Inject
56   - private TUserService tUserService;
57   -
58   - @Request.Post("/api/video/uploadNotify")
59   - public void uploadNotify(Params params) {
60   - String video_uuid = params.getString("video_uuid");
61   - String upload_type = params.getString("upload_type");
62   - String video_type = params.getString("video_type");
63   - String state = params.getString("state");
64   - notify(video_uuid);
65   - // renderJson(new ResultBean(100, "请求成功", null));
66   - }
67   -
68   - /**
69   - * sdk 方式上传
70   - */
71   - @Request.Post("/api/video/supload")
72   - public void supload(Params params) {
73   - ResultBean resultBean = new ResultBean();
74   - try {
75   - Map data = new LinkedHashMap();
76   - String app_access_key = params.getString("app_access_key");
77   - String user_access_key = params.getString("user_access_key");
78   - String server_access_key = params.getString("server_access_key");
79   - String uuid = CnliveUtil.getUUID();
80   - String md5 = params.getString("md5");
81   - TVideo tVideo = new TVideo();
82   - tVideo.setCustom_args(params.getString("custom_args"));
83   - tVideo.setRelation_id(params.getString("relation_id"));
84   - tVideo.setName(params.getString("name"));
85   - tVideo.setVideo_type(params.getString("video_type"));
86   - tVideo.setPlat(params.getString("plat"));
87   - tVideo.setState(207);
88   - tVideo.setMd5(md5);
89   - tVideo.setVideo_uuid(uuid);
90   - tVideo.setTitle(params.getString("title"));
91   - tVideo.setVideo_type(params.getString("video_type"));
92   - tVideo.setDescription(params.getString("description"));
93   - saveSdkVideoSrc(tVideo, server_access_key, user_access_key, app_access_key);
94   - resultBean.setCode(100);
95   - resultBean.setMessage("请求成功");
96   - data.put("video_uuid", uuid);
97   - resultBean.setData(data);
98   - } catch (Exception e) {
99   - e.printStackTrace();
100   - }
101   - // renderJson(resultBean);
102   - }
103   -
104   - TDispatchServerService tDispatchServerService;
105   - TAppService tAppService;
106   - TVideoService tVideoService;
107   -
108   - public void saveSdkVideoSrc(TVideo tVideo, String server_access_key, String user_access_key, String app_access_key) {
109   - TDispatchServer dispatchServer = tDispatchServerService.getServerByAccessKey(server_access_key);
110   - TUser user = tUserService.getUserByAccessKey(user_access_key);
111   - TApp app = tAppService.getAppByAccessKey(app_access_key);
112   - int video_type = Integer.parseInt(tVideo.getVideo_type());
113   - String name = tVideo.getName();
114   - tVideo.setT_app_id(app.getId());
115   - tVideo.setT_user_id(user.getId());
116   - tVideo.setT_dispatch_server_id(dispatchServer.getId());
117   - tVideo.setState(207);
118   - tVideoService.save(tVideo);
119   - }
120   -
121   - public void notify(String video_uuid) {
122   - TVideo video = tVideoService.getVideoByUuId(video_uuid);
123   - tVideoService.updateState(video.getId(), 302);
124   - NotifyThread t = new NotifyThread(video);
125   - t.start();
126   - }
127   -
128   - public String tempPath = "/opt/video/";
129   -
130   - class NotifyThread extends Thread {
131   - TVideo video;
132   -
133   - NotifyThread(TVideo video) {
134   - this.video = video;
135   - }
136   -
137   - @Override
138   - public void run() {
139   - TDispatchServer dispatchServer = tDispatchServerService.getDispatchServerById(video
140   - .getT_dispatch_server_id());
141   - String floder = "/home/lijielong/video/storage/";// dispatchServer.getStr("floder");
142   - String account = dispatchServer.getAccount();
143   - Account acc = (Account) JsonUtil.getDtoFromJsonObjStr(account, Account.class);
144   - String name = video.getName();
145   - String md5 = video.getMd5();
146   - String ip = dispatchServer.getIp();
147   - String remoteFile = floder + md5 + "/" + name;
148   - boolean flag = Scp.get(ip, acc.getS_name(), acc.getS_password(), tempPath, remoteFile);
149   - if (flag) {
150   - String localFilePath = tempPath + name;
151   - File localFile = new File(localFilePath);
152   - String basePath = tempPath + DateUtil.getDays("yyyy/MM/dd/");
153   - new File(basePath).mkdirs();
154   - String imageKey = DateUtil.getDays("yyyy/MM/dd/") + video.getVideo_uuid() + ".jpg";
155   - String imagePath = tempPath + imageKey;
156   - CNLiveFFmpeg ffmpeg = new CNLiveFFmpeg(localFilePath);
157   - String w = ffmpeg.getWidth();
158   - String h = ffmpeg.getHeight();
159   - int width = Integer.parseInt(w);
160   - int height = Integer.parseInt(h);
161   - CNLiveFFmpeg.getPreviewImg(localFilePath, imagePath);
162   -
163   - File image = new File(imagePath);
164   - if (!image.exists()) {
165   - image = new File("/usr/local/tomcat/webapps/ROOT/resource/assets/images/336x220.jpg");
166   - }
167   - String ks3ImagePath = putToKS3(image, imageKey);
168   - String ks3VideoPath = putToKS3(localFile, DateUtil.getDays("yyyy/MM/dd/") + name);
169   - Map map = new HashMap();
170   - map.put("file_path", ks3VideoPath);
171   - map.put("preview_image", ks3ImagePath);
172   - tVideoService.update(video.getId(), map);
173   - } else {
174   - System.out.println("scp get file fail " + remoteFile);
175   - }
176   - }
177   - }
178   -
179   - public String putToKS3(File file, String key) {
180   - KsYun yun = new KsYun(false);
181   - yun.singlePut("cnlive-ugc", key, file);
182   - return "http://cnlive-ugc.ks3-cn-beijing.ksyun.com/" + key;
183   - }
184   -
185   - private void pushToCms(TVideo video, String start_time, String endTime) {
186   - String url = "http://icms.staff.cnlive.com/icms_service/api/ugcContentSave.do";
187   - JSONObject obj = JSONObject.fromObject(video.getCustom_args());
188   - Map map = new HashMap();
189   - map.put("MAM_UUID", video.getName());
190   - map.put("MAM_USERID", String.valueOf(obj.get("userId")));
191   - map.put("MAM_NickName", obj.get("nickName"));
192   - map.put("MAM_Title", video.getTitle());
193   - map.put("MAM_Description", video.getDescription());
194   - map.put("MAM_PublishDate", start_time);
195   - map.put("MAM_VideoUrl", video.getFile_path());
196   - map.put("MAM_VideoHUrl", video.getFile_path());
197   - map.put("MAM_VideoUHUrl", video.getFile_path());
198   - map.put("MAM_VideoLUrl", video.getFile_path());
199   - if (StringUtils.isNotEmpty(endTime)) {
200   - map.put("MAM_EndTime", endTime);
201   - }
202   - JSONObject jsonObj = JSONObject.fromObject(map);
203   - String str = HttpReq.postRequestWidthResult(url, "json", jsonObj.toString());
204   - System.out.println("测试期间:调用cms" + str);
205   - }
206   -
207   -}
src/main/java/com/cnlive/mz/live/action/IndexAction.java
... ... @@ -15,6 +15,7 @@ import java.util.Map;
15 15  
16 16 import javax.servlet.http.HttpSession;
17 17  
  18 +import org.apache.commons.lang3.StringUtils;
18 19 import org.smart4j.framework.core.ConfigHelper;
19 20 import org.smart4j.framework.ioc.annotation.Inject;
20 21 import org.smart4j.framework.mvc.DataContext;
... ... @@ -53,7 +54,6 @@ public class IndexAction {
53 54 @Inject
54 55 private TUserService tUserService;
55 56  
56   -
57 57 int type = 1;
58 58  
59 59 @Request.Get("/index")
... ... @@ -89,11 +89,16 @@ public class IndexAction {
89 89 @Request.Post("/doswitch")
90 90 public Result doSwitch(Params params) {
91 91 String channel_ids = params.getString("channel_ids");
92   - String wowza_id = params.getString("wowza_id");
93   - tActivityService.doSwitch(channel_ids, Integer.parseInt(wowza_id));
94   - return new Result(true);
  92 + if (StringUtils.isEmpty(channel_ids)) {
  93 + System.out.println("没选择频道");
  94 + return new Result(false);
  95 + } else {
  96 + String wowza_id = params.getString("wowza_id");
  97 + tActivityService.doSwitch(channel_ids, Integer.parseInt(wowza_id));
  98 + return new Result(true);
  99 + }
95 100 }
96   -
  101 +
97 102 @Request.Get("/login/success")
98 103 public View loginSuccess(Params params) {
99 104 String userName = params.getString("username");
... ... @@ -102,7 +107,7 @@ public class IndexAction {
102 107 if (tUser == null) {
103 108 view = new View("index/loginfail.jsp");
104 109 } else {
105   - HttpSession session=DataContext.getRequest().getSession();
  110 + HttpSession session = DataContext.getRequest().getSession();
106 111 session.setAttribute(LiveUtils.SESSION_KEY_NAME, tUser.getName());
107 112 session.setAttribute(LiveUtils.SESSION_KEY_ID, tUser.getId());
108 113 session.setAttribute(LiveUtils.SESSION_ROLE_ID, tUser.getIs_admin());
... ... @@ -125,17 +130,17 @@ public class IndexAction {
125 130 public void logout() {
126 131 HttpSession session = DataContext.getRequest().getSession();
127 132 String logoutUrl = ConfigHelper.getString("auth.logout.url");
128   - String webUrl= ConfigHelper.getString("website.url");
  133 + String webUrl = ConfigHelper.getString("website.url");
129 134 session.removeAttribute(LiveUtils.SESSION_KEY_NAME);
130 135 session.removeAttribute(LiveUtils.SESSION_KEY_ID);
131 136 session.invalidate();
132 137 try {
133   - DataContext.getResponse().sendRedirect(logoutUrl+webUrl+"/logout/success");
  138 + DataContext.getResponse().sendRedirect(logoutUrl + webUrl + "/logout/success");
134 139 } catch (IOException e) {
135 140 e.printStackTrace();
136 141 }
137 142 }
138   -
  143 +
139 144 @Request.Get("/logout/success")
140 145 public Result logoutSuccess() {
141 146 return new Result(true).data("退出成功");
... ...
src/main/java/com/cnlive/mz/live/action/VideoAction.java
... ... @@ -6,16 +6,18 @@ import java.util.Map;
6 6  
7 7 import org.smart4j.framework.dao.bean.Pager;
8 8 import org.smart4j.framework.ioc.annotation.Inject;
  9 +import org.smart4j.framework.mvc.DataContext;
9 10 import org.smart4j.framework.mvc.annotation.Action;
10 11 import org.smart4j.framework.mvc.annotation.Request;
11 12 import org.smart4j.framework.mvc.bean.ApiBean;
12 13 import org.smart4j.framework.mvc.bean.Params;
  14 +import org.smart4j.framework.mvc.bean.View;
  15 +import org.smart4j.framework.util.CastUtil;
13 16  
14 17 import com.cnlive.mz.commons.CnliveUtil;
15   -import com.cnlive.mz.live.entity.TApp;
  18 +import com.cnlive.mz.live.common.LiveUtils;
16 19 import com.cnlive.mz.live.entity.TLive;
17 20 import com.cnlive.mz.live.entity.TVideo;
18   -import com.cnlive.mz.live.service.TAppService;
19 21 import com.cnlive.mz.live.service.TDispatchServerService;
20 22 import com.cnlive.mz.live.service.TLiveService;
21 23 import com.cnlive.mz.live.service.TUserService;
... ... @@ -25,8 +27,7 @@ import com.cnlive.mz.live.service.TVideoService;
25 27 public class VideoAction {
26 28 @Inject
27 29 private TDispatchServerService tDispatchServerService;
28   - @Inject
29   - private TAppService tAppService;
  30 +
30 31 @Inject
31 32 private TVideoService tVideoService;
32 33 @Inject
... ... @@ -47,25 +48,8 @@ public class VideoAction {
47 48 public ApiBean redirect(Params params) {
48 49 String app_access_key = params.getString("app_access_key");
49 50 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);
  51 + String user_id = params.getString("relation_id");
  52 + ApiBean apiBean = tDispatchServerService.redirect(video_type, app_access_key, user_id);
69 53 return apiBean;
70 54 }
71 55  
... ... @@ -79,14 +63,14 @@ public class VideoAction {
79 63 String active_id = params.getString("active_id");
80 64 String title = params.getString("title");
81 65 String description = params.getString("description");
82   - String args = params.getString("custom_args");
  66 + String custom_args = params.getString("custom_args");
83 67 String uuid = CnliveUtil.getUUID();
84 68 String md5 = params.getString("md5");
85 69 String relation_id = params.getString("relation_id");
86 70 if (video_type.equals("2")) {
87 71 // 2:sdk上传录播文件
88 72 TVideo tVideo = new TVideo();
89   - tVideo.setCustom_args(args);
  73 + tVideo.setCustom_args(custom_args);
90 74 tVideo.setRelation_id(relation_id);
91 75 tVideo.setName(params.getString("name"));
92 76 tVideo.setVideo_type(params.getString("video_type"));
... ... @@ -106,7 +90,8 @@ public class VideoAction {
106 90 tLive.setUuid(uuid);
107 91 tLive.setUser_uuid(params.getString("name"));
108 92 tLive.setRelation_id(relation_id);
109   - tLive.setLive_url("http://cnlive.hlslive.ks-cdn.com/live/" + relation_id + "_" + tLive.getId()
  93 + tLive.setCustom_args(custom_args);
  94 + tLive.setLive_url("http://cnlive.hlslive.ks-cdn.com/live/" + tLive.getT_user_id() + "_" + tLive.getId()
110 95 + "/index.m3u8");
111 96 tLiveService.startLive(tLive);
112 97 }
... ... @@ -125,8 +110,7 @@ public class VideoAction {
125 110 String pageNo = params.getString("page_no");
126 111 String relation_id = params.getString("relation_id");
127 112 String upload_type = params.getString("upload_type");
128   - String page_no = params.getString("page_no");
129   - String video_type = params.getString("video_type");
  113 + // String video_type = params.getString("video_type");
130 114 Pager<TVideo> page = tVideoService.findAll(app_access_key, relationId, pageNo);
131 115 ApiBean apiBean = new ApiBean();
132 116 apiBean.setCode(100);
... ... @@ -135,6 +119,31 @@ public class VideoAction {
135 119 return apiBean;
136 120 }
137 121  
  122 + @Request.Get("/video/list/{page_number}")
  123 + public View list(int page_number) {
  124 + int user_id = CastUtil.castInt(DataContext.getRequest().getSession().getAttribute(LiveUtils.SESSION_KEY_ID));
  125 + Pager<TVideo> page = tVideoService.list(user_id, page_number, 33);
  126 + return new View("live/video_management.jsp").data("videos", page);
  127 + }
  128 +
  129 + @Request.Post("/video/view/{id}")
  130 + public View one(int id) {
  131 + TVideo page = tVideoService.getVideoById(id);
  132 + return new View("live/video_view.jsp").data("videos", page);
  133 + }
  134 +
  135 + @Request.Post("/api/video/one")
  136 + public ApiBean one(Params params) {
  137 + String app_access_key = params.getString("app_access_key");
  138 + String video_uuid = params.getString("video_uuid");
  139 + TVideo page = tVideoService.getVideoByUuId(video_uuid);
  140 + ApiBean apiBean = new ApiBean();
  141 + apiBean.setCode(100);
  142 + apiBean.setMessage("请求成功");
  143 + apiBean.setData(page);
  144 + return apiBean;
  145 + }
  146 +
138 147 @Request.Post("/api/video/uploadNotify")
139 148 public ApiBean uploadNotify(Params params) {
140 149 String video_uuid = params.getString("video_uuid");
... ...
src/main/webapp/pages/common/left.jsp
... ... @@ -43,12 +43,15 @@
43 43 </li>
44 44  
45 45 <!-- 主播 -->
46   - <li class="header">系统设置</li>
  46 + <li class="header">UGC直播</li>
47 47 <li>
48 48 <a href="${BASE}/room/list/1"><i class="fa fa-circle-o text-yellow"></i>直播间管理</a>
49 49 </li>
50 50 <li>
51   - <a href="${BASE}/live/list/1"><i class="fa fa-circle-o text-yellow"></i>直播活动</a>
  51 + <a href="${BASE}/live/list/1"><i class="fa fa-circle-o text-yellow"></i>直播活动管理</a>
  52 + </li>
  53 + <li>
  54 + <a href="${BASE}/video/list/1"><i class="fa fa-circle-o text-yellow"></i>直播录制管理</a>
52 55 </li>
53 56 </c:if>
54 57 <c:if test="${sessionScope.roleId=='0'}">
... ...
src/main/webapp/pages/live/live_add.jsp
... ... @@ -82,10 +82,10 @@
82 82 </div>
83 83 </div>
84 84 <div class="form-group">
85   - <label>海报 </label>
  85 + <label>封面海报 </label>
86 86 <div class="input-group">
87 87 <span class="input-group-addon"><i
88   - class="fa fa-file-word-o"></i> </span> <input id="input-22" type="file" name="input-22" accept="image/*" class="file-loading">
  88 + class="fa fa-file-word-o"></i> </span> <input id="input-22" type="file" name="input-22" accept="image/*" class="file-loading">
89 89 </div>
90 90 </div>
91 91 <div class="form-group">
... ... @@ -106,7 +106,7 @@
106 106 </div>
107 107  
108 108 <div class="form-group">
109   - <label>活动简 </label>
  109 + <label>活动简 </label>
110 110 <div class="input-group">
111 111 <span class="input-group-addon"><i
112 112 class="fa fa-file-word-o"></i> </span> <script id="editor" type="text/plain" style="width:1024px;height:500px;"></script>
... ...
target/classes/com/cnlive/mz/live/action/ActivityAction.class
No preview for this file type
target/classes/com/cnlive/mz/live/action/ChannelAction.class
No preview for this file type
target/classes/com/cnlive/mz/live/action/IndexAction.class
No preview for this file type
target/classes/com/cnlive/mz/live/aspect/ActionAspect.class
No preview for this file type
target/classes/com/cnlive/mz/live/aspect/AuthFilter.class
No preview for this file type
target/m2e-wtp/web-resources/META-INF/maven/com.cnlive.mz.live.web/cnlive_live_web/pom.properties
1 1 #Generated by Maven Integration for Eclipse
2   -#Thu May 26 14:32:01 CST 2016
  2 +#Mon Jun 06 10:53:20 CST 2016
3 3 version=0.0.1-SNAPSHOT
4 4 groupId=com.cnlive.mz.live.web
5 5 m2e.projectName=cnlive_live_web
... ...