Commit 27e0c0d85da4268ddbc34d5708e56e0cca379f8f
1 parent
01bbee1d
1
Showing
5 changed files
with
44 additions
and
171 deletions
src/main/java/com/cnlive/mz/live/action/UgcLiveAction.java
| ... | ... | @@ -9,28 +9,20 @@ |
| 9 | 9 | |
| 10 | 10 | package com.cnlive.mz.live.action; |
| 11 | 11 | |
| 12 | -import java.io.IOException; | |
| 13 | 12 | import java.util.HashMap; |
| 14 | 13 | import java.util.Map; |
| 15 | 14 | |
| 16 | -import javax.servlet.http.HttpServletResponse; | |
| 17 | - | |
| 18 | 15 | import org.apache.commons.lang.StringUtils; |
| 19 | 16 | import org.apache.log4j.Logger; |
| 20 | 17 | import org.smart4j.framework.dao.bean.Pager; |
| 21 | 18 | import org.smart4j.framework.ioc.annotation.Inject; |
| 22 | -import org.smart4j.framework.mvc.DataContext; | |
| 23 | 19 | import org.smart4j.framework.mvc.annotation.Action; |
| 24 | 20 | import org.smart4j.framework.mvc.annotation.Request; |
| 25 | 21 | import org.smart4j.framework.mvc.bean.Params; |
| 26 | 22 | import org.smart4j.framework.mvc.bean.Redirect; |
| 27 | 23 | import org.smart4j.framework.mvc.bean.ResultBean; |
| 28 | 24 | |
| 29 | -import com.cnlive.mz.commons.net.HttpReq; | |
| 30 | -import com.cnlive.mz.live.entity.TChannel; | |
| 31 | 25 | import com.cnlive.mz.live.entity.TLive; |
| 32 | -import com.cnlive.mz.live.service.TCheckService; | |
| 33 | -import com.cnlive.mz.live.service.TRoomService; | |
| 34 | 26 | import com.cnlive.mz.live.service.UgcLiveService; |
| 35 | 27 | |
| 36 | 28 | @Action |
| ... | ... | @@ -39,7 +31,6 @@ public class UgcLiveAction { |
| 39 | 31 | private Logger log = Logger.getLogger("UgcLiveAction"); |
| 40 | 32 | @Inject |
| 41 | 33 | private UgcLiveService ugcLiveService; |
| 42 | - | |
| 43 | 34 | |
| 44 | 35 | /** |
| 45 | 36 | * 1.0 获取直播活动信息接口Server.md |
| ... | ... | @@ -190,7 +181,7 @@ public class UgcLiveAction { |
| 190 | 181 | String streamName = live_url.substring(index + 1); |
| 191 | 182 | System.out.println("streamName===" + streamName); |
| 192 | 183 | // 直播断流。 |
| 193 | - ugcLiveService.stop(appId,activityid); | |
| 184 | + ugcLiveService.stop(appId, activityid); | |
| 194 | 185 | } |
| 195 | 186 | map.put("location", tLive.getLive_url()); |
| 196 | 187 | rb.setData(map); |
| ... | ... | @@ -313,49 +304,10 @@ public class UgcLiveAction { |
| 313 | 304 | * @return 302 跳转播放地址 |
| 314 | 305 | */ |
| 315 | 306 | @Request.Get("/live/epg/play/app") |
| 316 | - public Redirect appURL(Params params) throws IOException { | |
| 307 | + public Redirect app(Params params) { | |
| 317 | 308 | log.info(params); |
| 318 | 309 | 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 | - } | |
| 310 | + r.setRedirectUrl(ugcLiveService.getAppPlayUrl(params)); | |
| 359 | 311 | return r; |
| 360 | 312 | } |
| 361 | 313 | |
| ... | ... | @@ -366,46 +318,11 @@ public class UgcLiveAction { |
| 366 | 318 | * @return |
| 367 | 319 | */ |
| 368 | 320 | @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 | - | |
| 321 | + public Redirect h5(Params params) { | |
| 322 | + String url = ugcLiveService.getH5PlayUrl(params); | |
| 323 | + Redirect r = new Redirect(); | |
| 324 | + r.setRedirectUrl(url); | |
| 325 | + return r; | |
| 409 | 326 | } |
| 410 | 327 | |
| 411 | 328 | /** |
| ... | ... | @@ -415,47 +332,18 @@ public class UgcLiveAction { |
| 415 | 332 | * @return |
| 416 | 333 | */ |
| 417 | 334 | @Request.Get("/live/epg/play/swf") |
| 418 | - public ResultBean swfURL(Params params) { | |
| 419 | - HttpServletResponse response = DataContext.getResponse(); | |
| 335 | + public ResultBean swf(Params params) { | |
| 420 | 336 | ResultBean rb = new ResultBean(); |
| 421 | - String appId = params.getString("appId"); | |
| 422 | - String activityid = params.getString("activityId"); | |
| 423 | 337 | 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 | - } | |
| 338 | + String url = ugcLiveService.getH5PlayUrl(params); | |
| 339 | + map.put("location", url); | |
| 340 | + rb.setErrorMessage("启动swf活动成功"); | |
| 341 | + rb.setErrorCode("0"); | |
| 342 | + return rb; | |
| 455 | 343 | } |
| 456 | 344 | |
| 457 | - @Request.Post("/live/epg/error500") | |
| 458 | - public ResultBean error(Params params) { | |
| 345 | + @Request.Get("/live/serverError") | |
| 346 | + public ResultBean error500() { | |
| 459 | 347 | ResultBean rb = new ResultBean(); |
| 460 | 348 | Map<String, Object> map = new HashMap<String, Object>(); |
| 461 | 349 | map.put("location", ""); |
| ... | ... | @@ -464,40 +352,16 @@ public class UgcLiveAction { |
| 464 | 352 | rb.setErrorMessage("失败"); |
| 465 | 353 | return rb; |
| 466 | 354 | } |
| 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); | |
| 355 | + | |
| 356 | + | |
| 357 | + @Request.Get("/live/clientError") | |
| 358 | + public ResultBean error404() { | |
| 359 | + ResultBean rb = new ResultBean(); | |
| 360 | + Map<String, Object> map = new HashMap<String, Object>(); | |
| 361 | + map.put("location", ""); | |
| 362 | + rb.setData(map); | |
| 363 | + rb.setErrorCode("404"); | |
| 364 | + rb.setErrorMessage("失败"); | |
| 365 | + return rb; | |
| 502 | 366 | } |
| 503 | 367 | } |
| 504 | 368 | \ No newline at end of file | ... | ... |
src/main/java/com/cnlive/mz/live/action/VideoAction.java
| ... | ... | @@ -115,6 +115,7 @@ public class VideoAction { |
| 115 | 115 | } else { |
| 116 | 116 | tLive.setDirect(Integer.parseInt(direct)); |
| 117 | 117 | } |
| 118 | + tLive.setHls_live_url(Constants.KS_HOST_HTTP + tLive.getT_user_id() + "/index.m3u8"); | |
| 118 | 119 | tLive.setLive_url(Constants.KS_HOST_RTMP + tLive.getT_user_id() ); |
| 119 | 120 | success = tLiveService.startLive(tLive); |
| 120 | 121 | } | ... | ... |
src/main/java/com/cnlive/mz/live/action/VodIpsAction.java
| ... | ... | @@ -26,8 +26,9 @@ public class VodIpsAction { |
| 26 | 26 | |
| 27 | 27 | private Logger log = Logger.getLogger("VodIpsAction"); |
| 28 | 28 | |
| 29 | - @Request.Get("/vodips/h5/{id}") | |
| 30 | - public Redirect h5(int id, Params params) { | |
| 29 | + @Request.Get("/vodips/h5") | |
| 30 | + public Redirect h5(Params params) { | |
| 31 | + System.out.println(params); | |
| 31 | 32 | String vId=params.getString("vId"); |
| 32 | 33 | int rate=params.getInt("rate"); |
| 33 | 34 | Redirect r = new Redirect(); |
| ... | ... | @@ -36,8 +37,9 @@ public class VodIpsAction { |
| 36 | 37 | return r; |
| 37 | 38 | } |
| 38 | 39 | |
| 39 | - @Request.Get("/vodips/app/{id}") | |
| 40 | - public Redirect app(int id, Params params) { | |
| 40 | + @Request.Get("/vodips/app") | |
| 41 | + public Redirect app(Params params) { | |
| 42 | + System.out.println(params); | |
| 41 | 43 | String vId=params.getString("vId"); |
| 42 | 44 | int rate=params.getInt("rate"); |
| 43 | 45 | String url=vodIpsServer.getAppPlayUrl(vId, rate); |
| ... | ... | @@ -46,8 +48,9 @@ public class VodIpsAction { |
| 46 | 48 | return r; |
| 47 | 49 | } |
| 48 | 50 | |
| 49 | - @Request.Get("/vodips/flash/{id}") | |
| 50 | - public ResultBean flash(int id, Params params) { | |
| 51 | + @Request.Get("/vodips/swf") | |
| 52 | + public ResultBean flash(Params params) { | |
| 53 | + System.out.println(params); | |
| 51 | 54 | String vId=params.getString("vId"); |
| 52 | 55 | int rate=params.getInt("rate"); |
| 53 | 56 | String url=vodIpsServer.getFlashPlayUrl(vId, rate); | ... | ... |
src/main/java/com/cnlive/socket/TE.java
| ... | ... | @@ -14,7 +14,7 @@ import org.apache.commons.httpclient.methods.GetMethod; |
| 14 | 14 | |
| 15 | 15 | public class TE { |
| 16 | 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"); | |
| 17 | + new TE().doGet("http://bc.cnlive.com/live/epg/play/app?appId=inbevnr031&channelID=1472020387351&isHLS=0&platform_id=com.cnlive.libs×tamp=1471942267&uid=7C1B686C33E0456B883295A57CBBDA87_1471941483046&sp_id=inbevnr031&activityId=1472020387351"); | |
| 18 | 18 | } |
| 19 | 19 | |
| 20 | 20 | private HttpClient getHttpClient() { |
| ... | ... | @@ -31,6 +31,7 @@ public void doGet(String url) { |
| 31 | 31 | InputStream stream = null; |
| 32 | 32 | try { |
| 33 | 33 | int exeCode = client.executeMethod(method); |
| 34 | + System.out.println(exeCode); | |
| 34 | 35 | StatusLine status = method.getStatusLine(); |
| 35 | 36 | int statusCode = status.getStatusCode(); |
| 36 | 37 | StringBuffer buf = new StringBuffer(); | ... | ... |
src/main/webapp/WEB-INF/web.xml
| ... | ... | @@ -11,6 +11,10 @@ |
| 11 | 11 | </servlet> |
| 12 | 12 | <error-page> |
| 13 | 13 | <error-code>500</error-code> |
| 14 | - <location>/live/epg/error500</location> | |
| 14 | + <location>/live/serverError</location> | |
| 15 | + </error-page> | |
| 16 | + <error-page> | |
| 17 | + <error-code>404</error-code> | |
| 18 | + <location>/live/clientError</location> | |
| 15 | 19 | </error-page> |
| 16 | 20 | </web-app> |
| 17 | 21 | \ No newline at end of file | ... | ... |