Commit b4b2ebc4ecf2a7e345294fae4376bf39cbfa9732
Merge branch 'master'
Showing
11 changed files
with
803 additions
and
676 deletions
.classpath
| ... | ... | @@ -24,9 +24,9 @@ |
| 24 | 24 | <attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/> |
| 25 | 25 | </attributes> |
| 26 | 26 | </classpathentry> |
| 27 | - <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"> | |
| 27 | + <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"> | |
| 28 | 28 | <attributes> |
| 29 | - <attribute name="owner.project.facets" value="java"/> | |
| 29 | + <attribute name="maven.pomderived" value="true"/> | |
| 30 | 30 | </attributes> |
| 31 | 31 | </classpathentry> |
| 32 | 32 | <classpathentry kind="output" path="target/classes"/> | ... | ... |
.settings/org.eclipse.jdt.core.prefs
| 1 | -eclipse.preferences.version=1 | |
| 2 | -org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled | |
| 3 | -org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate | |
| 4 | -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7 | |
| 5 | -org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve | |
| 6 | -org.eclipse.jdt.core.compiler.compliance=1.7 | |
| 7 | -org.eclipse.jdt.core.compiler.debug.lineNumber=generate | |
| 8 | -org.eclipse.jdt.core.compiler.debug.localVariable=generate | |
| 9 | -org.eclipse.jdt.core.compiler.debug.sourceFile=generate | |
| 10 | -org.eclipse.jdt.core.compiler.problem.assertIdentifier=error | |
| 11 | -org.eclipse.jdt.core.compiler.problem.enumIdentifier=error | |
| 12 | -org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning | |
| 13 | -org.eclipse.jdt.core.compiler.source=1.7 | |
| 1 | +eclipse.preferences.version=1 | |
| 2 | +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled | |
| 3 | +org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate | |
| 4 | +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 | |
| 5 | +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve | |
| 6 | +org.eclipse.jdt.core.compiler.compliance=1.6 | |
| 7 | +org.eclipse.jdt.core.compiler.debug.lineNumber=generate | |
| 8 | +org.eclipse.jdt.core.compiler.debug.localVariable=generate | |
| 9 | +org.eclipse.jdt.core.compiler.debug.sourceFile=generate | |
| 10 | +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error | |
| 11 | +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error | |
| 12 | +org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning | |
| 13 | +org.eclipse.jdt.core.compiler.source=1.6 | ... | ... |
.settings/org.eclipse.wst.common.component
| ... | ... | @@ -9,9 +9,15 @@ |
| 9 | 9 | <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"> |
| 10 | 10 | <dependency-type>uses</dependency-type> |
| 11 | 11 | </dependent-module> |
| 12 | + <dependent-module archiveName="cnlive_ks3-1.0-SNAPSHOT.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/cnlive_ks3/cnlive_ks3"> | |
| 13 | + <dependency-type>uses</dependency-type> | |
| 14 | + </dependent-module> | |
| 12 | 15 | <dependent-module archiveName="smart-framework-4.0.1.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/smart-framework/smart-framework"> |
| 13 | 16 | <dependency-type>uses</dependency-type> |
| 14 | 17 | </dependent-module> |
| 18 | + <dependent-module archiveName="smart-plugin-job-1.0.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/smart-plugin-job/smart-plugin-job"> | |
| 19 | + <dependency-type>uses</dependency-type> | |
| 20 | + </dependent-module> | |
| 15 | 21 | <dependent-module archiveName="smart-plugin-dbcp-1.0.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/smart-plugin-dbcp/smart-plugin-dbcp"> |
| 16 | 22 | <dependency-type>uses</dependency-type> |
| 17 | 23 | </dependent-module> | ... | ... |
.settings/org.eclipse.wst.common.project.facet.core.xml
src/main/java/com/cnlive/mz/live/action/LiveAction.java
| 1 | -/** | |
| 2 | - * Project Name:cnlive_live_web | |
| 3 | - * File Name:RoomAction.java | |
| 4 | - * Package Name:com.cnlive.mz.live.action | |
| 5 | - * Date:2016年4月25日下午1:12:48 | |
| 6 | - * Copyright (c) 2016, cnlive.com All Rights Reserved. | |
| 7 | - * | |
| 8 | - */ | |
| 9 | - | |
| 10 | -package com.cnlive.mz.live.action; | |
| 11 | - | |
| 12 | -import java.io.IOException; | |
| 13 | -import java.io.UnsupportedEncodingException; | |
| 14 | -import java.util.HashMap; | |
| 15 | -import java.util.List; | |
| 16 | -import java.util.Map; | |
| 17 | - | |
| 18 | -import javax.servlet.http.HttpServletRequest; | |
| 19 | -import javax.servlet.http.HttpServletResponse; | |
| 20 | - | |
| 21 | -import org.apache.commons.httpclient.NameValuePair; | |
| 22 | -import org.apache.commons.lang.StringUtils; | |
| 23 | -import org.apache.log4j.Logger; | |
| 24 | -import org.smart4j.framework.dao.bean.Pager; | |
| 25 | -import org.smart4j.framework.ioc.annotation.Inject; | |
| 26 | -import org.smart4j.framework.mvc.DataContext; | |
| 27 | -import org.smart4j.framework.mvc.annotation.Action; | |
| 28 | -import org.smart4j.framework.mvc.annotation.Request; | |
| 29 | -import org.smart4j.framework.mvc.bean.Multipart; | |
| 30 | -import org.smart4j.framework.mvc.bean.Multiparts; | |
| 31 | -import org.smart4j.framework.mvc.bean.Params; | |
| 32 | -import org.smart4j.framework.mvc.bean.Result; | |
| 33 | -import org.smart4j.framework.mvc.bean.ResultBean; | |
| 34 | -import org.smart4j.framework.mvc.bean.View; | |
| 35 | -import org.smart4j.framework.util.CastUtil; | |
| 36 | - | |
| 37 | -import com.cnlive.mz.commons.Constants; | |
| 38 | -import com.cnlive.mz.commons.net.HttpReq; | |
| 39 | -import com.cnlive.mz.live.common.LiveUtils; | |
| 40 | -import com.cnlive.mz.live.entity.TChannel; | |
| 41 | -import com.cnlive.mz.live.entity.TLive; | |
| 42 | -import com.cnlive.mz.live.entity.TRoom; | |
| 43 | -import com.cnlive.mz.live.rest.BaseUtil; | |
| 44 | -import com.cnlive.mz.live.service.TCheckService; | |
| 45 | -import com.cnlive.mz.live.service.TLiveService; | |
| 46 | -import com.cnlive.mz.live.service.TRoomService; | |
| 47 | - | |
| 48 | -/** | |
| 49 | - * TODO: 机构主播和个人主播发起直播活动 <br/> | |
| 50 | - * Date: 2016年4月25日 下午1:12:48 <br/> | |
| 51 | - * | |
| 52 | - * @author liujicheng | |
| 53 | - * @version V1.0 | |
| 54 | - * @since JDK 1.6 | |
| 55 | - */ | |
| 56 | -@Action | |
| 57 | -public class LiveAction { | |
| 58 | - | |
| 59 | - private Logger log = Logger.getLogger("LiveAction"); | |
| 60 | - @Inject | |
| 61 | - private TLiveService tLiveService; | |
| 62 | - @Inject | |
| 63 | - private TRoomService tRoomService; | |
| 64 | - @Inject | |
| 65 | - private TCheckService tCheckService; | |
| 66 | - | |
| 67 | - @Request.Get("/live/preload") | |
| 68 | - public View preload() { | |
| 69 | - int user_id = CastUtil.castInt(DataContext.getRequest().getSession().getAttribute(LiveUtils.SESSION_KEY_ID)); | |
| 70 | - View view = new View("live/live_add.jsp"); | |
| 71 | - List<TRoom> tRooms = tRoomService.getTRooms(user_id); | |
| 72 | - view.data("tRooms", tRooms); | |
| 73 | - return view; | |
| 74 | - } | |
| 75 | - | |
| 76 | - @Request.Get("/live/list/{page_number}") | |
| 77 | - public View list(int page_number) { | |
| 78 | - int user_id = CastUtil.castInt(DataContext.getRequest().getSession().getAttribute(LiveUtils.SESSION_KEY_ID)); | |
| 79 | - System.out.println(user_id); | |
| 80 | - Pager<TLive> tLive = tLiveService.getTLivePager(page_number, Constants.PAGE_SIZE, user_id); | |
| 81 | - return new View("live/live_management.jsp").data("tLive", tLive); | |
| 82 | - } | |
| 83 | - | |
| 84 | - @Request.Post("/live/save") | |
| 85 | - public Result saveLive(Params params, Multiparts multiparts) { | |
| 86 | - System.out.println(params + "....and....." + multiparts); | |
| 87 | - int user_id = CastUtil.castInt(DataContext.getRequest().getSession().getAttribute(LiveUtils.SESSION_KEY_ID)); | |
| 88 | - Multipart multipart = multiparts.getOne(); | |
| 89 | - tLiveService.add(user_id, params, multipart); | |
| 90 | - return new Result(false); | |
| 91 | - } | |
| 92 | - | |
| 93 | - @Request.Get("/live/edit/{id}") | |
| 94 | - public View edit(int id) { | |
| 95 | - TLive tLive = tLiveService.getTLiveById(id); | |
| 96 | - TRoom tRoom = tRoomService.getTRoomById(Integer.parseInt(tLive.getLive_room_id())); | |
| 97 | - List<TRoom> list = tRoomService.getTRooms(tLive.getT_user_id()); | |
| 98 | - View view = new View("live/live_edit.jsp"); | |
| 99 | - view.data("tActivity", tLive); | |
| 100 | - view.data("tRoom", tRoom); | |
| 101 | - view.data("tRooms", list); | |
| 102 | - return view; | |
| 103 | - } | |
| 104 | - | |
| 105 | - // | |
| 106 | - @Request.Get("/live/preview/{id}") | |
| 107 | - public View preview(int id) { | |
| 108 | - TLive tLive = tLiveService.getTLiveById(id); | |
| 109 | - TRoom tRoom = tRoomService.getTRoomById(Integer.parseInt(tLive.getLive_room_id())); | |
| 110 | - View view = new View("live/live_preview.jsp"); | |
| 111 | - view.data("tLive", tLive); | |
| 112 | - view.data("tRoom", tRoom); | |
| 113 | - return view; | |
| 114 | - } | |
| 115 | - | |
| 116 | - @Request.Get("/live/alllive/{page_number}") | |
| 117 | - public View liveList(int page_number) { | |
| 118 | - int user_id = CastUtil.castInt(DataContext.getRequest().getSession().getAttribute(LiveUtils.SESSION_KEY_ID)); | |
| 119 | - Pager<TLive> tLive = tLiveService.getAllTLivePager(page_number, Constants.PAGE_SIZE); | |
| 120 | - return new View("live/all_live_management.jsp").data("tLive", tLive); | |
| 121 | - } | |
| 122 | - | |
| 123 | - @Request.Get("/live/search/{page_number}") | |
| 124 | - public View search(int page_number, Params params) { | |
| 125 | - int user_id = CastUtil.castInt(DataContext.getRequest().getSession().getAttribute(LiveUtils.SESSION_KEY_ID)); | |
| 126 | - System.out.println(user_id); | |
| 127 | - System.out.println("...parmas..." + params); | |
| 128 | - String t_user_id = params.getString("search_user_id"); | |
| 129 | - String title = params.getString("search_title"); | |
| 130 | - | |
| 131 | - try { | |
| 132 | - title = new String(title.trim().getBytes("ISO-8859-1"), "utf-8"); | |
| 133 | - System.out.println("...title.." + title); | |
| 134 | - } catch (UnsupportedEncodingException e) { | |
| 135 | - e.printStackTrace(); | |
| 136 | - } | |
| 137 | - | |
| 138 | - Pager<TLive> tLive = tLiveService.getTLiveAllPager(page_number, Constants.PAGE_SIZE, t_user_id, title); | |
| 139 | - System.out.println("tLive=====" + tLive); | |
| 140 | - return new View("live/all_live_management.jsp").data("tLive", tLive); | |
| 141 | - } | |
| 142 | - | |
| 143 | - /** | |
| 144 | - * 1.0 获取直播活动信息接口Server.md | |
| 145 | - * | |
| 146 | - * @param params | |
| 147 | - * @return | |
| 148 | - */ | |
| 149 | - @Request.Get("/live/epg/getLiveActivityPlayInfo4Server") | |
| 150 | - public ResultBean getLiveActivityPlayInfo4Server(Params params) { | |
| 151 | - ResultBean rb = new ResultBean(); | |
| 152 | - String appId = params.getString("appId"); | |
| 153 | - String activityId = params.getString("activityId"); | |
| 154 | - String timestamp = params.getString("timestamp"); | |
| 155 | - if (StringUtils.isEmpty(appId) || StringUtils.isEmpty(activityId)) { | |
| 156 | - Map<String, Object> map = new HashMap<String, Object>(); | |
| 157 | - map.put("location", ""); | |
| 158 | - rb.setData(map); | |
| 159 | - rb.setErrorCode("200"); | |
| 160 | - log.error("参数不正确"); | |
| 161 | - rb.setErrorMessage("启动活动失败"); | |
| 162 | - return rb; | |
| 163 | - } else { | |
| 164 | - TLive tLive = tLiveService.selectByParams(appId, activityId); | |
| 165 | - Map<String, Object> map = new HashMap<String, Object>(); | |
| 166 | - map.put("activityId", activityId); | |
| 167 | - map.put("location", tLive.getLive_url()); | |
| 168 | - rb.setData(map); | |
| 169 | - rb.setErrorCode("0"); | |
| 170 | - rb.setErrorMessage("启动活动成功"); | |
| 171 | - return rb; | |
| 172 | - } | |
| 173 | - } | |
| 174 | - | |
| 175 | - /** | |
| 176 | - * 1.3 创建直播活动接口.md | |
| 177 | - * | |
| 178 | - * @param params | |
| 179 | - * @return | |
| 180 | - */ | |
| 181 | - @Request.Post("/live/epg/createActivity") | |
| 182 | - public ResultBean createActivity(Params params) { | |
| 183 | - log.info("打印参数开始......"); | |
| 184 | - log.info(params); | |
| 185 | - log.info("打印参数结束......"); | |
| 186 | - ResultBean rb = new ResultBean(); | |
| 187 | - String appId = params.getString("appId"); | |
| 188 | - String activityId = params.getString("activityId"); | |
| 189 | - int isHorizontalScreen = params.getInt("isHorizontalScreen"); | |
| 190 | - String channelID = params.getString("channelId"); | |
| 191 | - if (StringUtils.isNotEmpty(appId) && StringUtils.isNotEmpty(activityId) && StringUtils.isNotEmpty(channelID) | |
| 192 | - && StringUtils.isNotEmpty("" + isHorizontalScreen)) { | |
| 193 | - TLive tLive = tLiveService.selectByParams(appId, activityId); | |
| 194 | - if (tLive != null) { | |
| 195 | - Map<String, Object> map = new HashMap<String, Object>(); | |
| 196 | - map.put("location", ""); | |
| 197 | - rb.setData(map); | |
| 198 | - rb.setErrorCode("500"); | |
| 199 | - rb.setErrorMessage("创建活动失败,活动ID已存在"); | |
| 200 | - log.error("创建活动失败,活动ID已存在"); | |
| 201 | - return rb; | |
| 202 | - } else { | |
| 203 | - boolean flag = tLiveService.addAcitvity(params); | |
| 204 | - TLive tlive = tLiveService.selectByParams(appId, activityId); | |
| 205 | - if (flag) { | |
| 206 | - Map<String, Object> map = new HashMap<String, Object>(); | |
| 207 | - map.put("location",com.cnlive.mz.live.common.Constants.KS_HOST_UP_RTMP + channelID + "?vdoid=" + activityId); | |
| 208 | - rb.setData(map); | |
| 209 | - rb.setErrorCode("0"); | |
| 210 | - rb.setErrorMessage("创建活动成功"); | |
| 211 | - log.info("创建活动成功"); | |
| 212 | - // 通知cms直播 | |
| 213 | - boolean success = tLiveService.startLive(tlive); | |
| 214 | - return rb; | |
| 215 | - } else { | |
| 216 | - Map<String, Object> map = new HashMap<String, Object>(); | |
| 217 | - map.put("location", ""); | |
| 218 | - rb.setData(map); | |
| 219 | - rb.setErrorCode("500"); | |
| 220 | - rb.setErrorMessage("创建活动失败,保存数据库失败"); | |
| 221 | - log.error("保存数据库失败"); | |
| 222 | - return rb; | |
| 223 | - } | |
| 224 | - } | |
| 225 | - } else { | |
| 226 | - Map<String, Object> map = new HashMap<String, Object>(); | |
| 227 | - map.put("location", ""); | |
| 228 | - rb.setData(map); | |
| 229 | - rb.setErrorCode("500"); | |
| 230 | - rb.setErrorMessage("创建活动失败,参数不正确"); | |
| 231 | - log.error("参数不正确"); | |
| 232 | - return rb; | |
| 233 | - } | |
| 234 | - | |
| 235 | - } | |
| 236 | - | |
| 237 | - /** | |
| 238 | - * 1.4 启动直播活动接口.md | |
| 239 | - * | |
| 240 | - * @param params | |
| 241 | - * @return | |
| 242 | - */ | |
| 243 | - @Request.Get("/live/epg/startActivity") | |
| 244 | - public ResultBean startActivity(Params params) { | |
| 245 | - ResultBean rb = new ResultBean(); | |
| 246 | - log.info(params); | |
| 247 | - String appId = params.getString("appId"); | |
| 248 | - String activityid = params.getString("activityId"); | |
| 249 | - if (StringUtils.isEmpty(appId) || StringUtils.isEmpty(activityid)) { | |
| 250 | - rb.setErrorCode("500"); | |
| 251 | - rb.setErrorMessage("启动活动失败,参数不正确"); | |
| 252 | - return rb; | |
| 253 | - } else { | |
| 254 | - TLive tLive = tLiveService.selectByParams(appId, activityid); | |
| 255 | - if (tLive == null) { | |
| 256 | - log.info("tLive为空......"); | |
| 257 | - rb.setErrorCode("500"); | |
| 258 | - rb.setErrorMessage("启动活动失败,活动对象为空"); | |
| 259 | - return rb; | |
| 260 | - } else { | |
| 261 | - rb.setErrorCode("0"); | |
| 262 | - rb.setErrorMessage("启动活动成功"); | |
| 263 | - return rb; | |
| 264 | - } | |
| 265 | - } | |
| 266 | - } | |
| 267 | - | |
| 268 | - /** | |
| 269 | - * 1.5 停止直播活动接口.md | |
| 270 | - * | |
| 271 | - * @param params | |
| 272 | - * @return | |
| 273 | - */ | |
| 274 | - @Request.Get("/live/epg/stopActivity") | |
| 275 | - public ResultBean stopActivity(Params params) { | |
| 276 | - log.info(params); | |
| 277 | - ResultBean rb = new ResultBean(); | |
| 278 | - String appId = params.getString("appId"); | |
| 279 | - String activityid = params.getString("activityId"); | |
| 280 | - TLive tLive = tLiveService.selectByParams(appId, activityid); | |
| 281 | - Map<String, Object> map = new HashMap<String, Object>(); | |
| 282 | - if (StringUtils.isEmpty(appId) || StringUtils.isEmpty(activityid)) { | |
| 283 | - map.put("location", ""); | |
| 284 | - rb.setData(map); | |
| 285 | - rb.setErrorCode("500"); | |
| 286 | - rb.setErrorMessage("停止直播失败,参数不正确"); | |
| 287 | - return rb; | |
| 288 | - } else { | |
| 289 | - if (tLive == null) { | |
| 290 | - map.put("location", ""); | |
| 291 | - rb.setData(map); | |
| 292 | - rb.setErrorCode("500"); | |
| 293 | - rb.setErrorMessage("停止直播失败,活动对象为空"); | |
| 294 | - return rb; | |
| 295 | - } else { | |
| 296 | - String live_url = tLive.getLive_url(); | |
| 297 | - int index = live_url.lastIndexOf("/"); | |
| 298 | - String streamName = live_url.substring(index + 1); | |
| 299 | - System.out.println("streamName===" + streamName); | |
| 300 | - // 直播断流。 | |
| 301 | - tCheckService.close(streamName, tLive.getId(), tLive.getUuid()); | |
| 302 | - } | |
| 303 | - // 直播通知 | |
| 304 | - // tLiveService.notify(video_uuid, -1); | |
| 305 | - map.put("location", tLive.getLive_url()); | |
| 306 | - rb.setData(map); | |
| 307 | - rb.setErrorCode("0"); | |
| 308 | - rb.setErrorMessage("停止直播成功"); | |
| 309 | - return rb; | |
| 310 | - } | |
| 311 | - } | |
| 312 | - | |
| 313 | - /** | |
| 314 | - * 1.6 获取直播活动列表接口.md | |
| 315 | - * | |
| 316 | - * @param params | |
| 317 | - * @return | |
| 318 | - */ | |
| 319 | - @Request.Get("/live/epg/getActivity") | |
| 320 | - public ResultBean getActivities(Params params) { | |
| 321 | - ResultBean rb = new ResultBean(); | |
| 322 | - String appId = params.getString("appId"); | |
| 323 | - String pageNo = params.getString("pageNo"); | |
| 324 | - String pageSize = params.getString("pageSize"); | |
| 325 | - if (StringUtils.isEmpty(appId) || StringUtils.isEmpty(pageNo) || StringUtils.isEmpty(pageSize)) { | |
| 326 | - Map<String, Object> map = new HashMap<String, Object>(); | |
| 327 | - map.put("location", ""); | |
| 328 | - rb.setData(map); | |
| 329 | - rb.setErrorCode("500"); | |
| 330 | - rb.setErrorMessage("获取活动列表失败,参数不正确"); | |
| 331 | - return rb; | |
| 332 | - } else { | |
| 333 | - Pager<TLive> tLive = tLiveService.getActivityPager(pageNo, pageSize, appId); | |
| 334 | - if (tLive == null) { | |
| 335 | - rb.setData(""); | |
| 336 | - rb.setErrorCode("500"); | |
| 337 | - rb.setErrorMessage("获取活动列表失败,活动对象为空"); | |
| 338 | - return rb; | |
| 339 | - } else { | |
| 340 | - rb.setData(tLive); | |
| 341 | - rb.setErrorCode("0"); | |
| 342 | - rb.setErrorMessage("获取活动列表成功"); | |
| 343 | - return rb; | |
| 344 | - } | |
| 345 | - | |
| 346 | - } | |
| 347 | - } | |
| 348 | - | |
| 349 | - /** | |
| 350 | - * 1.7 获取直播回放接口.md | |
| 351 | - * | |
| 352 | - * @param args | |
| 353 | - */ | |
| 354 | - @Request.Get("/live/epg/getActivityVodInfo") | |
| 355 | - public ResultBean getActivityVodInfo(Params params) { | |
| 356 | - ResultBean rb = new ResultBean(); | |
| 357 | - String appId = params.getString("appId"); | |
| 358 | - String activityid = params.getString("activityId"); | |
| 359 | - Map<String, Object> map = new HashMap<String, Object>(); | |
| 360 | - if (StringUtils.isEmpty(appId) || StringUtils.isEmpty(activityid)) { | |
| 361 | - map.put("location", ""); | |
| 362 | - rb.setData(map); | |
| 363 | - rb.setErrorCode("500"); | |
| 364 | - rb.setErrorMessage("获取直播回放失败,参数不正确"); | |
| 365 | - return rb; | |
| 366 | - } else { | |
| 367 | - TLive tLive = tLiveService.selectByParams(appId, activityid); | |
| 368 | - if (tLive == null) { | |
| 369 | - map.put("location", ""); | |
| 370 | - rb.setData(map); | |
| 371 | - rb.setErrorCode("500"); | |
| 372 | - rb.setErrorMessage("获取直播回放失败,活动对象为空"); | |
| 373 | - return rb; | |
| 374 | - } else { | |
| 375 | - map.put("location", tLive.getPlayback_url()); | |
| 376 | - rb.setData(map); | |
| 377 | - rb.setErrorCode("0"); | |
| 378 | - rb.setErrorMessage("获取直播回放成功"); | |
| 379 | - return rb; | |
| 380 | - } | |
| 381 | - } | |
| 382 | - } | |
| 383 | - | |
| 384 | - /** | |
| 385 | - * 1.7 获取直播回放接口.md | |
| 386 | - * | |
| 387 | - * @param args | |
| 388 | - */ | |
| 389 | - @Request.Get("/live/epg/liveplayByAPP") | |
| 390 | - public ResultBean liveplayByAPP(Params params) { | |
| 391 | - log.info(params); | |
| 392 | - ResultBean rb = new ResultBean(); | |
| 393 | - String appId = params.getString("appId"); | |
| 394 | - String activityid = params.getString("activityId"); | |
| 395 | - Map<String, Object> map = new HashMap<String, Object>(); | |
| 396 | - if (StringUtils.isEmpty(appId) || StringUtils.isEmpty(activityid)) { | |
| 397 | - map.put("location", ""); | |
| 398 | - rb.setData(map); | |
| 399 | - rb.setErrorCode("500"); | |
| 400 | - rb.setErrorMessage("获取直播回放失败,参数不正确"); | |
| 401 | - return rb; | |
| 402 | - } else { | |
| 403 | - TLive tLive = tLiveService.selectByParams(appId, activityid); | |
| 404 | - if (tLive == null) { | |
| 405 | - map.put("location", ""); | |
| 406 | - rb.setData(map); | |
| 407 | - rb.setErrorCode("500"); | |
| 408 | - rb.setErrorMessage("获取直播回放失败,活动对象为空"); | |
| 409 | - return rb; | |
| 410 | - } else { | |
| 411 | - map.put("location", tLive.getPlayback_url()); | |
| 412 | - rb.setData(map); | |
| 413 | - rb.setErrorCode("0"); | |
| 414 | - rb.setErrorMessage("获取直播回放成功"); | |
| 415 | - return rb; | |
| 416 | - } | |
| 417 | - } | |
| 418 | - } | |
| 419 | - | |
| 420 | - /** | |
| 421 | - * 1.8 获取APP直播URL接口.md | |
| 422 | - * | |
| 423 | - * @param params | |
| 424 | - * @return | |
| 425 | - */ | |
| 426 | - @Request.Get("/live/epg/play/app") | |
| 427 | - public ResultBean appURL(Params params) throws IOException { | |
| 428 | - HttpServletResponse response = DataContext.getResponse(); | |
| 429 | - ResultBean rb = new ResultBean(); | |
| 430 | - String appId = params.getString("appId"); | |
| 431 | - String activityid = params.getString("activityId"); | |
| 432 | - Map<String, Object> map = new HashMap<String, Object>(); | |
| 433 | - if (StringUtils.isEmpty(appId) || StringUtils.isEmpty(activityid)) { | |
| 434 | - map.put("location", ""); | |
| 435 | - rb.setData(map); | |
| 436 | - rb.setErrorCode("500"); | |
| 437 | - rb.setErrorMessage("启动app活动失败"); | |
| 438 | - return rb; | |
| 439 | - } else { | |
| 440 | - TLive tLive = tLiveService.selectByParams(appId, activityid); | |
| 441 | - if (tLive == null) { | |
| 442 | - map.put("location", ""); | |
| 443 | - rb.setData(map); | |
| 444 | - rb.setErrorCode("500"); | |
| 445 | - rb.setErrorMessage("启动app活动失败,活动对象为空"); | |
| 446 | - return rb; | |
| 447 | - } else { | |
| 448 | - TChannel tchannel = tLiveService.selectChannel(tLive.getRelation_id()); | |
| 449 | - if (tchannel != null) { | |
| 450 | - // 请求到app....... | |
| 451 | - redirect(response, "http://ips.cnlive.com/IPS/liveplayByAPP.action?appId=" + appId + "&channelID=" | |
| 452 | - + tLive.getRelation_id()); | |
| 453 | - map.put("location", ""); | |
| 454 | - rb.setData(map); | |
| 455 | - rb.setErrorCode("0"); | |
| 456 | - rb.setErrorMessage("302重定向到app"); | |
| 457 | - return rb; | |
| 458 | - } else { | |
| 459 | - map.put("location", tLive.getLive_url()); | |
| 460 | - rb.setData(map); | |
| 461 | - rb.setErrorCode("0"); | |
| 462 | - rb.setErrorMessage("启动app活动成功"); | |
| 463 | - return rb; | |
| 464 | - } | |
| 465 | - } | |
| 466 | - } | |
| 467 | - | |
| 468 | - } | |
| 469 | - | |
| 470 | - /** | |
| 471 | - * 1.9 获取H5直播URL接口.md | |
| 472 | - * | |
| 473 | - * @param params | |
| 474 | - * @return | |
| 475 | - */ | |
| 476 | - @Request.Get("/live/epg/play/h5") | |
| 477 | - public ResultBean h5URL(Params params) { | |
| 478 | - HttpServletResponse response = DataContext.getResponse(); | |
| 479 | - ResultBean rb = new ResultBean(); | |
| 480 | - String appId = params.getString("appId"); | |
| 481 | - String activityid = params.getString("activityId"); | |
| 482 | - Map<String, Object> map = new HashMap<String, Object>(); | |
| 483 | - if (StringUtils.isEmpty(appId) || StringUtils.isEmpty(activityid)) { | |
| 484 | - map.put("location", ""); | |
| 485 | - rb.setData(map); | |
| 486 | - rb.setErrorCode("500"); | |
| 487 | - rb.setErrorMessage("启动h5活动失败"); | |
| 488 | - return rb; | |
| 489 | - } else { | |
| 490 | - TLive tLive = tLiveService.selectByParams(appId, activityid); | |
| 491 | - if (tLive == null) { | |
| 492 | - map.put("location", ""); | |
| 493 | - rb.setData(map); | |
| 494 | - rb.setErrorCode("500"); | |
| 495 | - rb.setErrorMessage("启动h5活动失败,活动对象为空"); | |
| 496 | - return rb; | |
| 497 | - } else { | |
| 498 | - TChannel tchannel = tLiveService.selectChannel(tLive.getRelation_id()); | |
| 499 | - if (tchannel != null) { | |
| 500 | - // 重定向到h5....... | |
| 501 | - redirect(response, "http://ips.cnlive.com/IPS/liveplayByH5?appId=" + appId + "&channelID=" | |
| 502 | - + tLive.getRelation_id()); | |
| 503 | - map.put("location", ""); | |
| 504 | - rb.setData(map); | |
| 505 | - rb.setErrorCode("0"); | |
| 506 | - rb.setErrorMessage("302重定向到h5"); | |
| 507 | - return rb; | |
| 508 | - } else { | |
| 509 | - map.put("location", tLive.getLive_url()); | |
| 510 | - rb.setData(map); | |
| 511 | - rb.setErrorCode("0"); | |
| 512 | - rb.setErrorMessage("启动h5活动成功"); | |
| 513 | - return rb; | |
| 514 | - } | |
| 515 | - } | |
| 516 | - } | |
| 517 | - | |
| 518 | - } | |
| 519 | - | |
| 520 | - /** | |
| 521 | - * 2.0 获取SWF直播URL接口.md | |
| 522 | - * | |
| 523 | - * @param params | |
| 524 | - * @return | |
| 525 | - */ | |
| 526 | - @Request.Get("/live/epg/play/swf") | |
| 527 | - public ResultBean swfURL(Params params) { | |
| 528 | - HttpServletResponse response = DataContext.getResponse(); | |
| 529 | - ResultBean rb = new ResultBean(); | |
| 530 | - String appId = params.getString("appId"); | |
| 531 | - String activityid = params.getString("activityId"); | |
| 532 | - Map<String, Object> map = new HashMap<String, Object>(); | |
| 533 | - if (StringUtils.isEmpty(appId) || StringUtils.isEmpty(activityid)) { | |
| 534 | - map.put("location", ""); | |
| 535 | - rb.setData(map); | |
| 536 | - rb.setErrorCode("500"); | |
| 537 | - rb.setErrorMessage("启动swf活动失败"); | |
| 538 | - return rb; | |
| 539 | - } else { | |
| 540 | - TLive tLive = tLiveService.selectByParams(appId, activityid); | |
| 541 | - if (tLive == null) { | |
| 542 | - map.put("location", ""); | |
| 543 | - rb.setData(map); | |
| 544 | - rb.setErrorCode("500"); | |
| 545 | - rb.setErrorMessage("启动swf活动失败,活动对象为空"); | |
| 546 | - return rb; | |
| 547 | - } else { | |
| 548 | - TChannel tchannel = tLiveService.selectChannel(tLive.getRelation_id()); | |
| 549 | - rb.setData(map); | |
| 550 | - rb.setErrorCode("0"); | |
| 551 | - if (tchannel != null) { | |
| 552 | - // 302重定向到swf....... | |
| 553 | - redirect(response, "http://ips.cnlive.com/IPS/liveplayBySWF.action?appId=" + appId + "&channelID=" | |
| 554 | - + tLive.getRelation_id()); | |
| 555 | - map.put("location", ""); | |
| 556 | - rb.setErrorMessage("302重定向到swf"); | |
| 557 | - return rb; | |
| 558 | - } else { | |
| 559 | - | |
| 560 | - map.put("location", tLive.getLive_url()); | |
| 561 | - rb.setErrorMessage("启动swf活动成功"); | |
| 562 | - return rb; | |
| 563 | - } | |
| 564 | - } | |
| 565 | - } | |
| 566 | - | |
| 567 | - } | |
| 568 | - | |
| 569 | - /** | |
| 570 | - * 2.1 获取推流直播播放地址.md | |
| 571 | - * | |
| 572 | - * @param params | |
| 573 | - * @return | |
| 574 | - */ | |
| 575 | - @Request.Get("/live/epg/play") | |
| 576 | - public ResultBean startLiveActivity(Params params) { | |
| 577 | - ResultBean rb = new ResultBean(); | |
| 578 | - String appId = params.getString("appId"); | |
| 579 | - String activityid = params.getString("activityId"); | |
| 580 | - if (StringUtils.isEmpty(appId) || StringUtils.isEmpty(activityid)) { | |
| 581 | - Map<String, Object> map = new HashMap<String, Object>(); | |
| 582 | - map.put("location", ""); | |
| 583 | - rb.setData(map); | |
| 584 | - rb.setErrorCode("500"); | |
| 585 | - rb.setErrorMessage("启动活动失败"); | |
| 586 | - return rb; | |
| 587 | - } else { | |
| 588 | - TLive tLive = tLiveService.selectByParams(appId, activityid); | |
| 589 | - Map<String, Object> map = new HashMap<String, Object>(); | |
| 590 | - map.put("location", tLive.getLive_url()); | |
| 591 | - rb.setData(map); | |
| 592 | - rb.setErrorCode("0"); | |
| 593 | - rb.setErrorMessage("启动活动成功"); | |
| 594 | - return rb; | |
| 595 | - } | |
| 596 | - } | |
| 597 | - | |
| 598 | - @Request.Post("/live/epg/error500") | |
| 599 | - public ResultBean error(Params params) { | |
| 600 | - ResultBean rb = new ResultBean(); | |
| 601 | - Map<String, Object> map = new HashMap<String, Object>(); | |
| 602 | - map.put("location", ""); | |
| 603 | - rb.setData(map); | |
| 604 | - rb.setErrorCode("500"); | |
| 605 | - rb.setErrorMessage("失败"); | |
| 606 | - return rb; | |
| 607 | - } | |
| 608 | - | |
| 609 | - public static void redirect(HttpServletResponse response, String redirectUrl) { | |
| 610 | - try { | |
| 611 | - response.setContentType("application/mpegurl"); | |
| 612 | - response.setStatus(302); | |
| 613 | - response.setHeader("Location", redirectUrl); | |
| 614 | - response.setHeader("Connection", "close"); | |
| 615 | - } catch (Exception e) { | |
| 616 | - throw new RuntimeException(e); | |
| 617 | - } | |
| 618 | - } | |
| 619 | - | |
| 620 | - @Request.Get("/live/epg/302") | |
| 621 | - public void red302() { | |
| 622 | - HttpServletResponse response = DataContext.getResponse(); | |
| 623 | - redirect(response, "http://ips.cnlive.com/IPS/liveplayBySWF.action?activityId=12345"); | |
| 624 | - } | |
| 625 | - | |
| 626 | - public static void main(String[] args) { | |
| 627 | - | |
| 628 | - /* | |
| 629 | - * NameValuePair[] nvp = new NameValuePair[6]; NameValuePair nv1 = new | |
| 630 | - * NameValuePair(); nv1.setName("appId"); nv1.setValue("123"); nvp[0] = | |
| 631 | - * nv1; NameValuePair nv2 = new NameValuePair(); | |
| 632 | - * nv2.setName("activityId"); nv2.setValue("234e"); nvp[1] = nv2; | |
| 633 | - * NameValuePair nv3 = new NameValuePair(); nv3.setName("activityName"); | |
| 634 | - * nv3.setValue("ee"); nvp[2] = nv3; NameValuePair nv4 = new | |
| 635 | - * NameValuePair(); nv4.setName("activityStatus"); nv4.setValue("11"); | |
| 636 | - * nvp[3] = nv4; NameValuePair nv5 = new NameValuePair(); | |
| 637 | - * nv5.setName("isHorizontalScreen"); nv5.setValue("321"); nvp[4] = nv5; | |
| 638 | - * NameValuePair nv6 = new NameValuePair(); nv6.setName("channelId"); | |
| 639 | - * nv6.setValue("ww"); nvp[5] = nv6; String ss = | |
| 640 | - * HttpReq.postRequestWidthResult( | |
| 641 | - * "http://bc.cnlive.com/live/epg/createActivity", nvp); | |
| 642 | - * System.out.println(ss); <<<<<<< HEAD String aa = HttpReq | |
| 643 | - * .getRequestWidthResult( | |
| 644 | - * "http://bc.cnlive.com/live/epg/startActivity?appId=123&activityId=234" | |
| 645 | - * ); System.out.println(aa); | |
| 646 | - */ | |
| 647 | - String aa = HttpReq | |
| 648 | - .getRequestWidthResult("http://bc.cnlive.com/live/epg/startActivity?appId=123&activityId=234"); | |
| 649 | - System.out.println(aa); | |
| 650 | - } | |
| 1 | +/** | |
| 2 | + * Project Name:cnlive_live_web | |
| 3 | + * File Name:RoomAction.java | |
| 4 | + * Package Name:com.cnlive.mz.live.action | |
| 5 | + * Date:2016年4月25日下午1:12:48 | |
| 6 | + * Copyright (c) 2016, cnlive.com All Rights Reserved. | |
| 7 | + * | |
| 8 | + */ | |
| 9 | + | |
| 10 | +package com.cnlive.mz.live.action; | |
| 11 | + | |
| 12 | +import java.io.IOException; | |
| 13 | +import java.io.UnsupportedEncodingException; | |
| 14 | +import java.util.HashMap; | |
| 15 | +import java.util.List; | |
| 16 | +import java.util.Map; | |
| 17 | + | |
| 18 | +import javax.servlet.http.HttpServletResponse; | |
| 19 | + | |
| 20 | +import org.apache.commons.lang.StringUtils; | |
| 21 | +import org.apache.log4j.Logger; | |
| 22 | +import org.smart4j.framework.dao.bean.Pager; | |
| 23 | +import org.smart4j.framework.ioc.annotation.Inject; | |
| 24 | +import org.smart4j.framework.mvc.DataContext; | |
| 25 | +import org.smart4j.framework.mvc.annotation.Action; | |
| 26 | +import org.smart4j.framework.mvc.annotation.Request; | |
| 27 | +import org.smart4j.framework.mvc.bean.Multipart; | |
| 28 | +import org.smart4j.framework.mvc.bean.Multiparts; | |
| 29 | +import org.smart4j.framework.mvc.bean.Params; | |
| 30 | +import org.smart4j.framework.mvc.bean.Redirect; | |
| 31 | +import org.smart4j.framework.mvc.bean.Result; | |
| 32 | +import org.smart4j.framework.mvc.bean.ResultBean; | |
| 33 | +import org.smart4j.framework.mvc.bean.View; | |
| 34 | +import org.smart4j.framework.util.CastUtil; | |
| 35 | + | |
| 36 | +import com.cnlive.mz.commons.Constants; | |
| 37 | +import com.cnlive.mz.commons.net.HttpReq; | |
| 38 | +import com.cnlive.mz.live.common.LiveUtils; | |
| 39 | +import com.cnlive.mz.live.entity.TChannel; | |
| 40 | +import com.cnlive.mz.live.entity.TLive; | |
| 41 | +import com.cnlive.mz.live.entity.TRoom; | |
| 42 | +import com.cnlive.mz.live.service.TCheckService; | |
| 43 | +import com.cnlive.mz.live.service.TLiveService; | |
| 44 | +import com.cnlive.mz.live.service.TRoomService; | |
| 45 | + | |
| 46 | +/** | |
| 47 | + * TODO: 机构主播和个人主播发起直播活动 <br/> | |
| 48 | + * Date: 2016年4月25日 下午1:12:48 <br/> | |
| 49 | + * | |
| 50 | + * @author liujicheng | |
| 51 | + * @version V1.0 | |
| 52 | + * @since JDK 1.6 | |
| 53 | + */ | |
| 54 | +@Action | |
| 55 | +public class LiveAction { | |
| 56 | + | |
| 57 | + private Logger log = Logger.getLogger("LiveAction"); | |
| 58 | + @Inject | |
| 59 | + private TLiveService tLiveService; | |
| 60 | + @Inject | |
| 61 | + private TRoomService tRoomService; | |
| 62 | + @Inject | |
| 63 | + private TCheckService tCheckService; | |
| 64 | + | |
| 65 | + @Request.Get("/live/preload") | |
| 66 | + public View preload() { | |
| 67 | + int user_id = CastUtil.castInt(DataContext.getRequest().getSession().getAttribute(LiveUtils.SESSION_KEY_ID)); | |
| 68 | + View view = new View("live/live_add.jsp"); | |
| 69 | + List<TRoom> tRooms = tRoomService.getTRooms(user_id); | |
| 70 | + view.data("tRooms", tRooms); | |
| 71 | + return view; | |
| 72 | + } | |
| 73 | + | |
| 74 | + @Request.Get("/live/list/{page_number}") | |
| 75 | + public View list(int page_number) { | |
| 76 | + int user_id = CastUtil.castInt(DataContext.getRequest().getSession().getAttribute(LiveUtils.SESSION_KEY_ID)); | |
| 77 | + System.out.println(user_id); | |
| 78 | + Pager<TLive> tLive = tLiveService.getTLivePager(page_number, Constants.PAGE_SIZE, user_id); | |
| 79 | + return new View("live/live_management.jsp").data("tLive", tLive); | |
| 80 | + } | |
| 81 | + | |
| 82 | + @Request.Post("/live/save") | |
| 83 | + public Result saveLive(Params params, Multiparts multiparts) { | |
| 84 | + System.out.println(params + "....and....." + multiparts); | |
| 85 | + int user_id = CastUtil.castInt(DataContext.getRequest().getSession().getAttribute(LiveUtils.SESSION_KEY_ID)); | |
| 86 | + Multipart multipart = multiparts.getOne(); | |
| 87 | + tLiveService.add(user_id, params, multipart); | |
| 88 | + return new Result(false); | |
| 89 | + } | |
| 90 | + | |
| 91 | + @Request.Get("/live/edit/{id}") | |
| 92 | + public View edit(int id) { | |
| 93 | + TLive tLive = tLiveService.getTLiveById(id); | |
| 94 | + TRoom tRoom = tRoomService.getTRoomById(Integer.parseInt(tLive.getLive_room_id())); | |
| 95 | + List<TRoom> list = tRoomService.getTRooms(tLive.getT_user_id()); | |
| 96 | + View view = new View("live/live_edit.jsp"); | |
| 97 | + view.data("tActivity", tLive); | |
| 98 | + view.data("tRoom", tRoom); | |
| 99 | + view.data("tRooms", list); | |
| 100 | + return view; | |
| 101 | + } | |
| 102 | + | |
| 103 | + // | |
| 104 | + @Request.Get("/live/preview/{id}") | |
| 105 | + public View preview(int id) { | |
| 106 | + TLive tLive = tLiveService.getTLiveById(id); | |
| 107 | + TRoom tRoom = tRoomService.getTRoomById(Integer.parseInt(tLive.getLive_room_id())); | |
| 108 | + View view = new View("live/live_preview.jsp"); | |
| 109 | + view.data("tLive", tLive); | |
| 110 | + view.data("tRoom", tRoom); | |
| 111 | + return view; | |
| 112 | + } | |
| 113 | + | |
| 114 | + @Request.Get("/live/alllive/{page_number}") | |
| 115 | + public View liveList(int page_number) { | |
| 116 | + int user_id = CastUtil.castInt(DataContext.getRequest().getSession().getAttribute(LiveUtils.SESSION_KEY_ID)); | |
| 117 | + Pager<TLive> tLive = tLiveService.getAllTLivePager(page_number, Constants.PAGE_SIZE); | |
| 118 | + return new View("live/all_live_management.jsp").data("tLive", tLive); | |
| 119 | + } | |
| 120 | + | |
| 121 | + @Request.Get("/live/search/{page_number}") | |
| 122 | + public View search(int page_number, Params params) { | |
| 123 | + int user_id = CastUtil.castInt(DataContext.getRequest().getSession().getAttribute(LiveUtils.SESSION_KEY_ID)); | |
| 124 | + System.out.println(user_id); | |
| 125 | + System.out.println("...parmas..." + params); | |
| 126 | + String t_user_id = params.getString("search_user_id"); | |
| 127 | + String title = params.getString("search_title"); | |
| 128 | + | |
| 129 | + try { | |
| 130 | + title = new String(title.trim().getBytes("ISO-8859-1"), "utf-8"); | |
| 131 | + System.out.println("...title.." + title); | |
| 132 | + } catch (UnsupportedEncodingException e) { | |
| 133 | + e.printStackTrace(); | |
| 134 | + } | |
| 135 | + | |
| 136 | + Pager<TLive> tLive = tLiveService.getTLiveAllPager(page_number, Constants.PAGE_SIZE, t_user_id, title); | |
| 137 | + System.out.println("tLive=====" + tLive); | |
| 138 | + return new View("live/all_live_management.jsp").data("tLive", tLive); | |
| 139 | + } | |
| 140 | + | |
| 141 | + public static void main(String[] args) { | |
| 142 | + | |
| 143 | + /* | |
| 144 | + * NameValuePair[] nvp = new NameValuePair[6]; NameValuePair nv1 = new | |
| 145 | + * NameValuePair(); nv1.setName("appId"); nv1.setValue("123"); nvp[0] = | |
| 146 | + * nv1; NameValuePair nv2 = new NameValuePair(); | |
| 147 | + * nv2.setName("activityId"); nv2.setValue("234e"); nvp[1] = nv2; | |
| 148 | + * NameValuePair nv3 = new NameValuePair(); nv3.setName("activityName"); | |
| 149 | + * nv3.setValue("ee"); nvp[2] = nv3; NameValuePair nv4 = new | |
| 150 | + * NameValuePair(); nv4.setName("activityStatus"); nv4.setValue("11"); | |
| 151 | + * nvp[3] = nv4; NameValuePair nv5 = new NameValuePair(); | |
| 152 | + * nv5.setName("isHorizontalScreen"); nv5.setValue("321"); nvp[4] = nv5; | |
| 153 | + * NameValuePair nv6 = new NameValuePair(); nv6.setName("channelId"); | |
| 154 | + * nv6.setValue("ww"); nvp[5] = nv6; String ss = | |
| 155 | + * HttpReq.postRequestWidthResult( | |
| 156 | + * "http://bc.cnlive.com/live/epg/createActivity", nvp); | |
| 157 | + * System.out.println(ss); <<<<<<< HEAD String aa = HttpReq | |
| 158 | + * .getRequestWidthResult( | |
| 159 | + * "http://bc.cnlive.com/live/epg/startActivity?appId=123&activityId=234" | |
| 160 | + * ); System.out.println(aa); | |
| 161 | + */ | |
| 162 | + String aa = HttpReq.getRequestWidthResult("http://bc.cnlive.com/live/epg/startActivity?appId=123&activityId=234"); | |
| 163 | + System.out.println(aa); | |
| 164 | + } | |
| 651 | 165 | } |
| 652 | 166 | \ No newline at end of file | ... | ... |
src/main/java/com/cnlive/mz/live/action/UgcLiveAction.java
0 → 100644
| 1 | +/** | |
| 2 | + * Project Name:cnlive_live_web | |
| 3 | + * File Name:RoomAction.java | |
| 4 | + * Package Name:com.cnlive.mz.live.action | |
| 5 | + * Date:2016年4月25日下午1:12:48 | |
| 6 | + * Copyright (c) 2016, cnlive.com All Rights Reserved. | |
| 7 | + * | |
| 8 | + */ | |
| 9 | + | |
| 10 | +package com.cnlive.mz.live.action; | |
| 11 | + | |
| 12 | +import java.io.IOException; | |
| 13 | +import java.util.HashMap; | |
| 14 | +import java.util.Map; | |
| 15 | + | |
| 16 | +import javax.servlet.http.HttpServletResponse; | |
| 17 | + | |
| 18 | +import org.apache.commons.lang.StringUtils; | |
| 19 | +import org.apache.log4j.Logger; | |
| 20 | +import org.smart4j.framework.dao.bean.Pager; | |
| 21 | +import org.smart4j.framework.ioc.annotation.Inject; | |
| 22 | +import org.smart4j.framework.mvc.DataContext; | |
| 23 | +import org.smart4j.framework.mvc.annotation.Action; | |
| 24 | +import org.smart4j.framework.mvc.annotation.Request; | |
| 25 | +import org.smart4j.framework.mvc.bean.Params; | |
| 26 | +import org.smart4j.framework.mvc.bean.Redirect; | |
| 27 | +import org.smart4j.framework.mvc.bean.ResultBean; | |
| 28 | + | |
| 29 | +import com.cnlive.mz.commons.net.HttpReq; | |
| 30 | +import com.cnlive.mz.live.entity.TChannel; | |
| 31 | +import com.cnlive.mz.live.entity.TLive; | |
| 32 | +import com.cnlive.mz.live.service.TCheckService; | |
| 33 | +import com.cnlive.mz.live.service.TRoomService; | |
| 34 | +import com.cnlive.mz.live.service.UgcLiveService; | |
| 35 | + | |
| 36 | +@Action | |
| 37 | +public class UgcLiveAction { | |
| 38 | + | |
| 39 | + private Logger log = Logger.getLogger("UgcLiveAction"); | |
| 40 | + @Inject | |
| 41 | + private UgcLiveService ugcLiveService; | |
| 42 | + | |
| 43 | + | |
| 44 | + /** | |
| 45 | + * 1.0 获取直播活动信息接口Server.md | |
| 46 | + * | |
| 47 | + * @param params | |
| 48 | + * @return | |
| 49 | + */ | |
| 50 | + @Request.Get("/live/epg/getLiveActivityPlayInfo4Server") | |
| 51 | + public ResultBean getLiveActivityPlayInfo4Server(Params params) { | |
| 52 | + ResultBean rb = new ResultBean(); | |
| 53 | + String appId = params.getString("appId"); | |
| 54 | + String activityId = params.getString("activityId"); | |
| 55 | + String timestamp = params.getString("timestamp"); | |
| 56 | + if (StringUtils.isEmpty(appId) || StringUtils.isEmpty(activityId)) { | |
| 57 | + Map<String, Object> map = new HashMap<String, Object>(); | |
| 58 | + map.put("location", ""); | |
| 59 | + rb.setData(map); | |
| 60 | + rb.setErrorCode("200"); | |
| 61 | + log.error("参数不正确"); | |
| 62 | + rb.setErrorMessage("启动活动失败"); | |
| 63 | + return rb; | |
| 64 | + } else { | |
| 65 | + TLive tLive = ugcLiveService.getTLiveByActivityId(appId, activityId); | |
| 66 | + Map<String, Object> map = new HashMap<String, Object>(); | |
| 67 | + map.put("activityId", activityId); | |
| 68 | + map.put("location", tLive.getLive_url()); | |
| 69 | + rb.setData(map); | |
| 70 | + rb.setErrorCode("0"); | |
| 71 | + rb.setErrorMessage("启动活动成功"); | |
| 72 | + return rb; | |
| 73 | + } | |
| 74 | + } | |
| 75 | + | |
| 76 | + /** | |
| 77 | + * 1.3 创建直播活动接口.md | |
| 78 | + * | |
| 79 | + * @param params | |
| 80 | + * @return | |
| 81 | + */ | |
| 82 | + @Request.Post("/live/epg/createActivity") | |
| 83 | + public ResultBean create(Params params) { | |
| 84 | + log.info(params); | |
| 85 | + ResultBean rb = new ResultBean(); | |
| 86 | + String appId = params.getString("appId"); | |
| 87 | + String activityId = params.getString("activityId"); | |
| 88 | + int isHorizontalScreen = params.getInt("isHorizontalScreen"); | |
| 89 | + String channelID = params.getString("channelId"); | |
| 90 | + Map<String, Object> map = new HashMap<String, Object>(); | |
| 91 | + if (StringUtils.isNotEmpty(appId) && StringUtils.isNotEmpty(activityId) && StringUtils.isNotEmpty(channelID) | |
| 92 | + && StringUtils.isNotEmpty("" + isHorizontalScreen)) { | |
| 93 | + TLive tLive = ugcLiveService.getTLiveByActivityId(appId, activityId); | |
| 94 | + if (tLive != null) { | |
| 95 | + map.put("location", ""); | |
| 96 | + rb.setData(map); | |
| 97 | + rb.setErrorCode("500"); | |
| 98 | + rb.setErrorMessage("创建活动失败,活动ID已存在"); | |
| 99 | + log.error("创建活动失败,活动ID已存在"); | |
| 100 | + return rb; | |
| 101 | + } else { | |
| 102 | + boolean flag = ugcLiveService.create(params); | |
| 103 | + if (flag) { | |
| 104 | + map.put("location", com.cnlive.mz.live.common.Constants.KS_HOST_UP_RTMP + channelID + "?vdoid=" + activityId); | |
| 105 | + rb.setData(map); | |
| 106 | + rb.setErrorCode("0"); | |
| 107 | + rb.setErrorMessage("创建活动成功"); | |
| 108 | + log.info("创建活动成功"); | |
| 109 | + return rb; | |
| 110 | + } else { | |
| 111 | + map.put("location", ""); | |
| 112 | + rb.setData(map); | |
| 113 | + rb.setErrorCode("500"); | |
| 114 | + rb.setErrorMessage("创建活动失败,保存数据库失败"); | |
| 115 | + log.error("保存数据库失败"); | |
| 116 | + return rb; | |
| 117 | + } | |
| 118 | + } | |
| 119 | + } else { | |
| 120 | + map.put("location", ""); | |
| 121 | + rb.setData(map); | |
| 122 | + rb.setErrorCode("500"); | |
| 123 | + rb.setErrorMessage("创建活动失败,参数不正确"); | |
| 124 | + log.error("参数不正确"); | |
| 125 | + return rb; | |
| 126 | + } | |
| 127 | + } | |
| 128 | + | |
| 129 | + /** | |
| 130 | + * 1.4 启动直播活动接口.md | |
| 131 | + * | |
| 132 | + * @param params | |
| 133 | + * @return | |
| 134 | + */ | |
| 135 | + @Request.Get("/live/epg/startActivity") | |
| 136 | + public ResultBean start(Params params) { | |
| 137 | + ResultBean rb = new ResultBean(); | |
| 138 | + log.info(params); | |
| 139 | + String appId = params.getString("appId"); | |
| 140 | + String activityid = params.getString("activityId"); | |
| 141 | + if (StringUtils.isEmpty(appId) || StringUtils.isEmpty(activityid)) { | |
| 142 | + rb.setErrorCode("500"); | |
| 143 | + rb.setErrorMessage("启动活动失败,参数不正确"); | |
| 144 | + return rb; | |
| 145 | + } else { | |
| 146 | + TLive tLive = ugcLiveService.getTLiveByActivityId(appId, activityid); | |
| 147 | + if (tLive == null) { | |
| 148 | + log.info("tLive为空......"); | |
| 149 | + rb.setErrorCode("500"); | |
| 150 | + rb.setErrorMessage("启动活动失败,活动对象为空"); | |
| 151 | + return rb; | |
| 152 | + } else { | |
| 153 | + rb.setErrorCode("0"); | |
| 154 | + rb.setErrorMessage("启动活动成功"); | |
| 155 | + return rb; | |
| 156 | + } | |
| 157 | + } | |
| 158 | + } | |
| 159 | + | |
| 160 | + /** | |
| 161 | + * 1.5 停止直播活动接口.md | |
| 162 | + * | |
| 163 | + * @param params | |
| 164 | + * @return | |
| 165 | + */ | |
| 166 | + @Request.Get("/live/epg/stopActivity") | |
| 167 | + public ResultBean stop(Params params) { | |
| 168 | + log.info(params); | |
| 169 | + ResultBean rb = new ResultBean(); | |
| 170 | + String appId = params.getString("appId"); | |
| 171 | + String activityid = params.getString("activityId"); | |
| 172 | + TLive tLive = ugcLiveService.getTLiveByActivityId(appId, activityid); | |
| 173 | + Map<String, Object> map = new HashMap<String, Object>(); | |
| 174 | + if (StringUtils.isEmpty(appId) || StringUtils.isEmpty(activityid)) { | |
| 175 | + map.put("location", ""); | |
| 176 | + rb.setData(map); | |
| 177 | + rb.setErrorCode("500"); | |
| 178 | + rb.setErrorMessage("停止直播失败,参数不正确"); | |
| 179 | + return rb; | |
| 180 | + } else { | |
| 181 | + if (tLive == null) { | |
| 182 | + map.put("location", ""); | |
| 183 | + rb.setData(map); | |
| 184 | + rb.setErrorCode("500"); | |
| 185 | + rb.setErrorMessage("停止直播失败,活动对象为空"); | |
| 186 | + return rb; | |
| 187 | + } else { | |
| 188 | + String live_url = tLive.getLive_url(); | |
| 189 | + int index = live_url.lastIndexOf("/"); | |
| 190 | + String streamName = live_url.substring(index + 1); | |
| 191 | + System.out.println("streamName===" + streamName); | |
| 192 | + // 直播断流。 | |
| 193 | + ugcLiveService.stop(appId,activityid); | |
| 194 | + } | |
| 195 | + map.put("location", tLive.getLive_url()); | |
| 196 | + rb.setData(map); | |
| 197 | + rb.setErrorCode("0"); | |
| 198 | + rb.setErrorMessage("停止直播成功"); | |
| 199 | + return rb; | |
| 200 | + } | |
| 201 | + } | |
| 202 | + | |
| 203 | + /** | |
| 204 | + * 1.6 获取直播活动列表接口.md | |
| 205 | + * | |
| 206 | + * @param params | |
| 207 | + * @return | |
| 208 | + */ | |
| 209 | + @Request.Get("/live/epg/getActivity") | |
| 210 | + public ResultBean getActivities(Params params) { | |
| 211 | + ResultBean rb = new ResultBean(); | |
| 212 | + String appId = params.getString("appId"); | |
| 213 | + String pageNo = params.getString("pageNo"); | |
| 214 | + String pageSize = params.getString("pageSize"); | |
| 215 | + if (StringUtils.isEmpty(appId) || StringUtils.isEmpty(pageNo) || StringUtils.isEmpty(pageSize)) { | |
| 216 | + Map<String, Object> map = new HashMap<String, Object>(); | |
| 217 | + map.put("location", ""); | |
| 218 | + rb.setData(map); | |
| 219 | + rb.setErrorCode("500"); | |
| 220 | + rb.setErrorMessage("获取活动列表失败,参数不正确"); | |
| 221 | + return rb; | |
| 222 | + } else { | |
| 223 | + Pager<TLive> tLive = ugcLiveService.getActivityPager(pageNo, pageSize, appId); | |
| 224 | + if (tLive == null) { | |
| 225 | + rb.setData(""); | |
| 226 | + rb.setErrorCode("500"); | |
| 227 | + rb.setErrorMessage("获取活动列表失败,活动对象为空"); | |
| 228 | + return rb; | |
| 229 | + } else { | |
| 230 | + rb.setData(tLive); | |
| 231 | + rb.setErrorCode("0"); | |
| 232 | + rb.setErrorMessage("获取活动列表成功"); | |
| 233 | + return rb; | |
| 234 | + } | |
| 235 | + } | |
| 236 | + } | |
| 237 | + | |
| 238 | + /** | |
| 239 | + * 1.7 获取直播回放接口.md | |
| 240 | + * | |
| 241 | + * @param args | |
| 242 | + */ | |
| 243 | + @Request.Get("/live/epg/getActivityVodInfo") | |
| 244 | + public ResultBean getActivityVodInfo(Params params) { | |
| 245 | + ResultBean rb = new ResultBean(); | |
| 246 | + String appId = params.getString("appId"); | |
| 247 | + String activityid = params.getString("activityId"); | |
| 248 | + Map<String, Object> map = new HashMap<String, Object>(); | |
| 249 | + if (StringUtils.isEmpty(appId) || StringUtils.isEmpty(activityid)) { | |
| 250 | + map.put("location", ""); | |
| 251 | + rb.setData(map); | |
| 252 | + rb.setErrorCode("500"); | |
| 253 | + rb.setErrorMessage("获取直播回放失败,参数不正确"); | |
| 254 | + return rb; | |
| 255 | + } else { | |
| 256 | + TLive tLive = ugcLiveService.getTLiveByActivityId(appId, activityid); | |
| 257 | + if (tLive == null) { | |
| 258 | + map.put("location", ""); | |
| 259 | + rb.setData(map); | |
| 260 | + rb.setErrorCode("500"); | |
| 261 | + rb.setErrorMessage("获取直播回放失败,活动对象为空"); | |
| 262 | + return rb; | |
| 263 | + } else { | |
| 264 | + map.put("location", tLive.getPlayback_url()); | |
| 265 | + rb.setData(map); | |
| 266 | + rb.setErrorCode("0"); | |
| 267 | + rb.setErrorMessage("获取直播回放成功"); | |
| 268 | + return rb; | |
| 269 | + } | |
| 270 | + } | |
| 271 | + } | |
| 272 | + | |
| 273 | + /** | |
| 274 | + * 1.7 获取直播回放接口.md | |
| 275 | + * | |
| 276 | + * @param args | |
| 277 | + */ | |
| 278 | + @Request.Get("/live/epg/liveplayByAPP") | |
| 279 | + public ResultBean liveplayByAPP(Params params) { | |
| 280 | + log.info(params); | |
| 281 | + ResultBean rb = new ResultBean(); | |
| 282 | + String appId = params.getString("appId"); | |
| 283 | + String activityid = params.getString("activityId"); | |
| 284 | + Map<String, Object> map = new HashMap<String, Object>(); | |
| 285 | + if (StringUtils.isEmpty(appId) || StringUtils.isEmpty(activityid)) { | |
| 286 | + map.put("location", ""); | |
| 287 | + rb.setData(map); | |
| 288 | + rb.setErrorCode("500"); | |
| 289 | + rb.setErrorMessage("获取直播回放失败,参数不正确"); | |
| 290 | + return rb; | |
| 291 | + } else { | |
| 292 | + TLive tLive = ugcLiveService.getTLiveByActivityId(appId, activityid); | |
| 293 | + if (tLive == null) { | |
| 294 | + map.put("location", ""); | |
| 295 | + rb.setData(map); | |
| 296 | + rb.setErrorCode("500"); | |
| 297 | + rb.setErrorMessage("获取直播回放失败,活动对象为空"); | |
| 298 | + return rb; | |
| 299 | + } else { | |
| 300 | + map.put("location", tLive.getPlayback_url()); | |
| 301 | + rb.setData(map); | |
| 302 | + rb.setErrorCode("0"); | |
| 303 | + rb.setErrorMessage("获取直播回放成功"); | |
| 304 | + return rb; | |
| 305 | + } | |
| 306 | + } | |
| 307 | + } | |
| 308 | + | |
| 309 | + /** | |
| 310 | + * 1.8 获取APP直播URL接口.md | |
| 311 | + * | |
| 312 | + * @param params | |
| 313 | + * @return 302 跳转播放地址 | |
| 314 | + */ | |
| 315 | + @Request.Get("/live/epg/play/app") | |
| 316 | + public Redirect appURL(Params params) throws IOException { | |
| 317 | + log.info(params); | |
| 318 | + Redirect r = new Redirect(); | |
| 319 | + String c = "http://wideo03.cnlive.com/video/data1/2016/0821/143844/800/8352b125fc404807851daa21d7e8f417_143844_800.m3u8"; | |
| 320 | + String appId = params.getString("appId"); | |
| 321 | + String activityid = params.getString("activityId"); | |
| 322 | + String isHLS = params.getString("isHLS"); | |
| 323 | + if (StringUtils.isEmpty(activityid)) { | |
| 324 | + // sdk 请求 | |
| 325 | + if (appId.isEmpty()) { | |
| 326 | + appId = params.getString("sp_id"); | |
| 327 | + } | |
| 328 | + String channelID = params.getString("channelID"); | |
| 329 | + TLive tLive = ugcLiveService.selectByRelationId(channelID); | |
| 330 | + TChannel tchannel = ugcLiveService.selectChannel(tLive.getRelation_id()); | |
| 331 | + if (tchannel != null) { | |
| 332 | + // pgc直播 | |
| 333 | + r.setRedirectUrl("http://ips.cnlive.com/IPS/liveplayByAPP.action?appId=" + appId + "&channelID=" + tLive.getRelation_id()); | |
| 334 | + } else { | |
| 335 | + // ugc直播 | |
| 336 | + if (StringUtils.isNotEmpty(isHLS) && isHLS.equals("1")) { | |
| 337 | + r.setRedirectUrl(tLive.getHls_live_url()); | |
| 338 | + } else { | |
| 339 | + r.setRedirectUrl(tLive.getLive_url()); | |
| 340 | + } | |
| 341 | + // r.setRedirectUrl(c); | |
| 342 | + } | |
| 343 | + } else { | |
| 344 | + TLive tLive = ugcLiveService.getTLiveByActivityId(appId, activityid); | |
| 345 | + TChannel tchannel = ugcLiveService.selectChannel(tLive.getRelation_id()); | |
| 346 | + if (tchannel != null) { | |
| 347 | + // pgc直播 | |
| 348 | + r.setRedirectUrl("http://ips.cnlive.com/IPS/liveplayByAPP.action?appId=" + appId + "&channelID=" + tLive.getRelation_id()); | |
| 349 | + } else { | |
| 350 | + // ugc直播 | |
| 351 | + if (StringUtils.isNotEmpty(isHLS) && isHLS.equals("1")) { | |
| 352 | + r.setRedirectUrl(tLive.getHls_live_url()); | |
| 353 | + } else { | |
| 354 | + r.setRedirectUrl(tLive.getLive_url()); | |
| 355 | + } | |
| 356 | + // r.setRedirectUrl(c); | |
| 357 | + } | |
| 358 | + } | |
| 359 | + return r; | |
| 360 | + } | |
| 361 | + | |
| 362 | + /** | |
| 363 | + * 1.9 获取H5直播URL接口.md | |
| 364 | + * | |
| 365 | + * @param params | |
| 366 | + * @return | |
| 367 | + */ | |
| 368 | + @Request.Get("/live/epg/play/h5") | |
| 369 | + public ResultBean h5URL(Params params) { | |
| 370 | + HttpServletResponse response = DataContext.getResponse(); | |
| 371 | + ResultBean rb = new ResultBean(); | |
| 372 | + String appId = params.getString("appId"); | |
| 373 | + String activityid = params.getString("activityId"); | |
| 374 | + Map<String, Object> map = new HashMap<String, Object>(); | |
| 375 | + if (StringUtils.isEmpty(appId) || StringUtils.isEmpty(activityid)) { | |
| 376 | + map.put("location", ""); | |
| 377 | + rb.setData(map); | |
| 378 | + rb.setErrorCode("500"); | |
| 379 | + rb.setErrorMessage("启动h5活动失败"); | |
| 380 | + return rb; | |
| 381 | + } else { | |
| 382 | + TLive tLive = ugcLiveService.getTLiveByActivityId(appId, activityid); | |
| 383 | + if (tLive == null) { | |
| 384 | + map.put("location", ""); | |
| 385 | + rb.setData(map); | |
| 386 | + rb.setErrorCode("500"); | |
| 387 | + rb.setErrorMessage("启动h5活动失败,活动对象为空"); | |
| 388 | + return rb; | |
| 389 | + } else { | |
| 390 | + TChannel tchannel = ugcLiveService.selectChannel(tLive.getRelation_id()); | |
| 391 | + if (tchannel != null) { | |
| 392 | + // 重定向到h5....... | |
| 393 | + redirect(response, "http://ips.cnlive.com/IPS/liveplayByH5?appId=" + appId + "&channelID=" + tLive.getRelation_id()); | |
| 394 | + map.put("location", ""); | |
| 395 | + rb.setData(map); | |
| 396 | + rb.setErrorCode("0"); | |
| 397 | + rb.setErrorMessage("302重定向到h5"); | |
| 398 | + return rb; | |
| 399 | + } else { | |
| 400 | + map.put("location", tLive.getLive_url()); | |
| 401 | + rb.setData(map); | |
| 402 | + rb.setErrorCode("0"); | |
| 403 | + rb.setErrorMessage("启动h5活动成功"); | |
| 404 | + return rb; | |
| 405 | + } | |
| 406 | + } | |
| 407 | + } | |
| 408 | + | |
| 409 | + } | |
| 410 | + | |
| 411 | + /** | |
| 412 | + * 2.0 获取SWF直播URL接口.md | |
| 413 | + * | |
| 414 | + * @param params | |
| 415 | + * @return | |
| 416 | + */ | |
| 417 | + @Request.Get("/live/epg/play/swf") | |
| 418 | + public ResultBean swfURL(Params params) { | |
| 419 | + HttpServletResponse response = DataContext.getResponse(); | |
| 420 | + ResultBean rb = new ResultBean(); | |
| 421 | + String appId = params.getString("appId"); | |
| 422 | + String activityid = params.getString("activityId"); | |
| 423 | + Map<String, Object> map = new HashMap<String, Object>(); | |
| 424 | + if (StringUtils.isEmpty(appId) || StringUtils.isEmpty(activityid)) { | |
| 425 | + map.put("location", ""); | |
| 426 | + rb.setData(map); | |
| 427 | + rb.setErrorCode("500"); | |
| 428 | + rb.setErrorMessage("启动swf活动失败"); | |
| 429 | + return rb; | |
| 430 | + } else { | |
| 431 | + TLive tLive = ugcLiveService.getTLiveByActivityId(appId, activityid); | |
| 432 | + if (tLive == null) { | |
| 433 | + map.put("location", ""); | |
| 434 | + rb.setData(map); | |
| 435 | + rb.setErrorCode("500"); | |
| 436 | + rb.setErrorMessage("启动swf活动失败,活动对象为空"); | |
| 437 | + return rb; | |
| 438 | + } else { | |
| 439 | + TChannel tchannel = ugcLiveService.selectChannel(tLive.getRelation_id()); | |
| 440 | + rb.setData(map); | |
| 441 | + rb.setErrorCode("0"); | |
| 442 | + if (tchannel != null) { | |
| 443 | + // 302重定向到swf....... | |
| 444 | + redirect(response, "http://ips.cnlive.com/IPS/liveplayBySWF.action?appId=" + appId + "&channelID=" + tLive.getRelation_id()); | |
| 445 | + map.put("location", ""); | |
| 446 | + rb.setErrorMessage("302重定向到swf"); | |
| 447 | + return rb; | |
| 448 | + } else { | |
| 449 | + map.put("location", tLive.getLive_url()); | |
| 450 | + rb.setErrorMessage("启动swf活动成功"); | |
| 451 | + return rb; | |
| 452 | + } | |
| 453 | + } | |
| 454 | + } | |
| 455 | + } | |
| 456 | + | |
| 457 | + @Request.Post("/live/epg/error500") | |
| 458 | + public ResultBean error(Params params) { | |
| 459 | + ResultBean rb = new ResultBean(); | |
| 460 | + Map<String, Object> map = new HashMap<String, Object>(); | |
| 461 | + map.put("location", ""); | |
| 462 | + rb.setData(map); | |
| 463 | + rb.setErrorCode("500"); | |
| 464 | + rb.setErrorMessage("失败"); | |
| 465 | + return rb; | |
| 466 | + } | |
| 467 | + | |
| 468 | + public static void redirect(HttpServletResponse response, String redirectUrl) { | |
| 469 | + try { | |
| 470 | + response.setContentType("application/mpegurl"); | |
| 471 | + response.setStatus(302); | |
| 472 | + response.setHeader("Location", redirectUrl); | |
| 473 | + response.setHeader("Connection", "close"); | |
| 474 | + } catch (Exception e) { | |
| 475 | + throw new RuntimeException(e); | |
| 476 | + } | |
| 477 | + } | |
| 478 | + | |
| 479 | + public static void main(String[] args) { | |
| 480 | + | |
| 481 | + /* | |
| 482 | + * NameValuePair[] nvp = new NameValuePair[6]; NameValuePair nv1 = new | |
| 483 | + * NameValuePair(); nv1.setName("appId"); nv1.setValue("123"); nvp[0] = | |
| 484 | + * nv1; NameValuePair nv2 = new NameValuePair(); | |
| 485 | + * nv2.setName("activityId"); nv2.setValue("234e"); nvp[1] = nv2; | |
| 486 | + * NameValuePair nv3 = new NameValuePair(); nv3.setName("activityName"); | |
| 487 | + * nv3.setValue("ee"); nvp[2] = nv3; NameValuePair nv4 = new | |
| 488 | + * NameValuePair(); nv4.setName("activityStatus"); nv4.setValue("11"); | |
| 489 | + * nvp[3] = nv4; NameValuePair nv5 = new NameValuePair(); | |
| 490 | + * nv5.setName("isHorizontalScreen"); nv5.setValue("321"); nvp[4] = nv5; | |
| 491 | + * NameValuePair nv6 = new NameValuePair(); nv6.setName("channelId"); | |
| 492 | + * nv6.setValue("ww"); nvp[5] = nv6; String ss = | |
| 493 | + * HttpReq.postRequestWidthResult( | |
| 494 | + * "http://bc.cnlive.com/live/epg/createActivity", nvp); | |
| 495 | + * System.out.println(ss); <<<<<<< HEAD String aa = HttpReq | |
| 496 | + * .getRequestWidthResult( | |
| 497 | + * "http://bc.cnlive.com/live/epg/startActivity?appId=123&activityId=234" | |
| 498 | + * ); System.out.println(aa); | |
| 499 | + */ | |
| 500 | + String aa = HttpReq.getRequestWidthResult("http://bc.cnlive.com/live/epg/startActivity?appId=123&activityId=234"); | |
| 501 | + System.out.println(aa); | |
| 502 | + } | |
| 503 | +} | |
| 0 | 504 | \ No newline at end of file | ... | ... |
src/main/java/com/cnlive/socket/Client.java
0 → 100644
| 1 | +package com.cnlive.socket; | |
| 2 | + | |
| 3 | +import java.io.BufferedReader; | |
| 4 | +import java.io.IOException; | |
| 5 | +import java.io.InputStreamReader; | |
| 6 | +import java.io.PrintWriter; | |
| 7 | +import java.net.Socket; | |
| 8 | +import java.net.UnknownHostException; | |
| 9 | + | |
| 10 | +public class Client { | |
| 11 | + Socket client; | |
| 12 | + PrintWriter pw; | |
| 13 | + public Client() throws UnknownHostException, IOException { | |
| 14 | + client=new Socket("bc.cnlive.com",65432); | |
| 15 | + pw=new PrintWriter(client.getOutputStream()); | |
| 16 | + BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); | |
| 17 | + pw.write(br.readLine()); | |
| 18 | + pw.close(); | |
| 19 | + br.close(); | |
| 20 | + } | |
| 21 | + public static void main(String[] args) { | |
| 22 | + try { | |
| 23 | + new Client(); | |
| 24 | + } catch (UnknownHostException e) { | |
| 25 | + e.printStackTrace(); | |
| 26 | + } catch (IOException e) { | |
| 27 | + e.printStackTrace(); | |
| 28 | + } | |
| 29 | + } | |
| 30 | +} | |
| 0 | 31 | \ No newline at end of file | ... | ... |
src/main/java/com/cnlive/socket/SocketServer.java
| ... | ... | @@ -30,7 +30,7 @@ public class SocketServer { |
| 30 | 30 | |
| 31 | 31 | private int port; |
| 32 | 32 | private volatile boolean running = false; |
| 33 | - private long receiveTimeDelay = 30000; | |
| 33 | + private long receiveTimeDelay = 7000; | |
| 34 | 34 | private ConcurrentHashMap<Class, ObjectAction> actionMapping = new ConcurrentHashMap<Class, ObjectAction>(); |
| 35 | 35 | private Thread connWatchDog; |
| 36 | 36 | |
| ... | ... | @@ -125,9 +125,7 @@ public class SocketServer { |
| 125 | 125 | } |
| 126 | 126 | } |
| 127 | 127 | } |
| 128 | - | |
| 129 | 128 | } |
| 130 | - | |
| 131 | 129 | private void overThis() { |
| 132 | 130 | if (run) |
| 133 | 131 | run = false; | ... | ... |
src/main/java/com/cnlive/socket/TE.java
0 → 100644
| 1 | +package com.cnlive.socket; | |
| 2 | + | |
| 3 | +import java.io.BufferedReader; | |
| 4 | +import java.io.IOException; | |
| 5 | +import java.io.InputStream; | |
| 6 | +import java.io.InputStreamReader; | |
| 7 | + | |
| 8 | +import org.apache.commons.httpclient.Header; | |
| 9 | +import org.apache.commons.httpclient.HttpClient; | |
| 10 | +import org.apache.commons.httpclient.HttpException; | |
| 11 | +import org.apache.commons.httpclient.HttpMethod; | |
| 12 | +import org.apache.commons.httpclient.StatusLine; | |
| 13 | +import org.apache.commons.httpclient.methods.GetMethod; | |
| 14 | + | |
| 15 | +public class TE { | |
| 16 | +public static void main(String[] args) { | |
| 17 | + new TE().doGet("http://bc.cnlive.com/live/epg/play/app?app_id=60_irg1rhs308&channelID=1471754157393"); | |
| 18 | +} | |
| 19 | + | |
| 20 | +private HttpClient getHttpClient() { | |
| 21 | + HttpClient client = new HttpClient(); | |
| 22 | + client.getHttpConnectionManager().getParams().setConnectionTimeout(2200); | |
| 23 | + client.getHttpConnectionManager().getParams().setSoTimeout(2200); | |
| 24 | + return client; | |
| 25 | +} | |
| 26 | +public void doGet(String url) { | |
| 27 | + BufferedReader in = null; | |
| 28 | + HttpClient client = this.getHttpClient(); | |
| 29 | + HttpMethod method = new GetMethod(url); | |
| 30 | + method.setFollowRedirects(false); | |
| 31 | + InputStream stream = null; | |
| 32 | + try { | |
| 33 | + int exeCode = client.executeMethod(method); | |
| 34 | + StatusLine status = method.getStatusLine(); | |
| 35 | + int statusCode = status.getStatusCode(); | |
| 36 | + StringBuffer buf = new StringBuffer(); | |
| 37 | + if (statusCode == 301 || statusCode == 302) { | |
| 38 | + Header[] hs = method.getResponseHeaders("Location"); | |
| 39 | + for (Header h : hs) { | |
| 40 | + System.out.println(h.getName() + "--" + h.getValue()); | |
| 41 | + String playUrl = h.getValue(); | |
| 42 | + | |
| 43 | + } | |
| 44 | + } else { | |
| 45 | + stream = method.getResponseBodyAsStream(); | |
| 46 | + in = new BufferedReader(new InputStreamReader(stream, "UTF-8")); | |
| 47 | + String line; | |
| 48 | + while (null != (line = in.readLine())) { | |
| 49 | + buf.append(line).append("\n"); | |
| 50 | + } | |
| 51 | + System.out.println(buf.toString()); | |
| 52 | + } | |
| 53 | + } catch (HttpException e) { | |
| 54 | + e.printStackTrace(); | |
| 55 | + } catch (IOException e) { | |
| 56 | + e.printStackTrace(); | |
| 57 | + } finally { | |
| 58 | + if (in != null) { | |
| 59 | + try { | |
| 60 | + in.close(); | |
| 61 | + } catch (Exception e) { | |
| 62 | + e.printStackTrace(); | |
| 63 | + } | |
| 64 | + } | |
| 65 | + if (stream != null) { | |
| 66 | + try { | |
| 67 | + stream.close(); | |
| 68 | + } catch (Exception e) { | |
| 69 | + e.printStackTrace(); | |
| 70 | + } | |
| 71 | + } | |
| 72 | + method.releaseConnection(); | |
| 73 | + } | |
| 74 | +} | |
| 75 | + | |
| 76 | +} | ... | ... |
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
| 1 | 1 | #Generated by Maven Integration for Eclipse |
| 2 | -#Mon Aug 22 09:38:15 CST 2016 | |
| 2 | +#Sun Aug 21 18:26:43 CST 2016 | |
| 3 | 3 | version=0.0.1-SNAPSHOT |
| 4 | 4 | groupId=com.cnlive.mz.live.web |
| 5 | 5 | m2e.projectName=cnlive_live_web |
| 6 | -m2e.projectLocation=C\:\\Users\\Administrator\\git\\cnlive_live_web | |
| 6 | +m2e.projectLocation=D\:\\1_CNLIVE_JAVA_CODE\\cnlive_live_web | |
| 7 | 7 | artifactId=cnlive_live_web | ... | ... |