Commit 6d2d8bdf639ebf6a25f5a2c52d7f3b3520af66d0

Authored by 刘基城
2 parents 52b8ae53 54aba86a

Merge branch 'master' of

http://bj.gitlab.cnlive.com/liujicheng/cnlive_live_web into v532

# Conflicts:
#	target/m2e-wtp/web-resources/META-INF/maven/com.cnlive.mz.live.web/cnlive_live_web/pom.properties

Too many changes to show.

To preserve performance only 14 of 84 files are displayed.

.classpath
1   -<?xml version="1.0" encoding="UTF-8"?>
2   -<classpath>
3   - <classpathentry kind="src" output="target/classes" path="src/main/java">
4   - <attributes>
5   - <attribute name="optional" value="true"/>
6   - <attribute name="maven.pomderived" value="true"/>
7   - </attributes>
8   - </classpathentry>
9   - <classpathentry kind="src" output="target/test-classes" path="src/test/java">
10   - <attributes>
11   - <attribute name="optional" value="true"/>
12   - <attribute name="maven.pomderived" value="true"/>
13   - </attributes>
14   - </classpathentry>
15   - <classpathentry including="**/*.java" kind="src" path="src/main/resources"/>
16   - <classpathentry kind="src" path="src/main/resources/i18n"/>
17   - <classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
18   - <attributes>
19   - <attribute name="maven.pomderived" value="true"/>
20   - <attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
21   - </attributes>
22   - </classpathentry>
23   - <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6">
24   - <attributes>
25   - <attribute name="maven.pomderived" value="true"/>
26   - </attributes>
27   - </classpathentry>
28   - <classpathentry kind="output" path="target/classes"/>
29   -</classpath>
  1 +<?xml version="1.0" encoding="UTF-8"?>
  2 +<classpath>
  3 + <classpathentry kind="src" output="target/classes" path="src/main/java">
  4 + <attributes>
  5 + <attribute name="optional" value="true"/>
  6 + <attribute name="maven.pomderived" value="true"/>
  7 + </attributes>
  8 + </classpathentry>
  9 + <classpathentry kind="src" output="target/test-classes" path="src/test/java">
  10 + <attributes>
  11 + <attribute name="optional" value="true"/>
  12 + <attribute name="maven.pomderived" value="true"/>
  13 + </attributes>
  14 + </classpathentry>
  15 + <classpathentry including="**/*.java" kind="src" path="src/main/resources"/>
  16 + <classpathentry kind="src" path="src/main/resources/i18n"/>
  17 + <classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
  18 + <attributes>
  19 + <attribute name="maven.pomderived" value="true"/>
  20 + <attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
  21 + </attributes>
  22 + </classpathentry>
  23 + <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6">
  24 + <attributes>
  25 + <attribute name="maven.pomderived" value="true"/>
  26 + </attributes>
  27 + </classpathentry>
  28 + <classpathentry kind="output" path="target/classes"/>
  29 +</classpath>
... ...
.classpath.rej 0 → 100644
  1 +diff a/.classpath b/.classpath (rejected hunks)
  2 +@@ -1,29 +0,29 @@
  3 +-<?xml version="1.0" encoding="UTF-8"?>
  4 +-<classpath>
  5 +- <classpathentry kind="src" output="target/classes" path="src/main/java">
  6 +- <attributes>
  7 +- <attribute name="optional" value="true"/>
  8 +- <attribute name="maven.pomderived" value="true"/>
  9 +- </attributes>
  10 +- </classpathentry>
  11 +- <classpathentry kind="src" output="target/test-classes" path="src/test/java">
  12 +- <attributes>
  13 +- <attribute name="optional" value="true"/>
  14 +- <attribute name="maven.pomderived" value="true"/>
  15 +- </attributes>
  16 +- </classpathentry>
  17 ++<?xml version="1.0" encoding="UTF-8"?>
  18 ++<classpath>
  19 ++ <classpathentry kind="src" output="target/classes" path="src/main/java">
  20 ++ <attributes>
  21 ++ <attribute name="optional" value="true"/>
  22 ++ <attribute name="maven.pomderived" value="true"/>
  23 ++ </attributes>
  24 ++ </classpathentry>
  25 ++ <classpathentry kind="src" output="target/test-classes" path="src/test/java">
  26 ++ <attributes>
  27 ++ <attribute name="optional" value="true"/>
  28 ++ <attribute name="maven.pomderived" value="true"/>
  29 ++ </attributes>
  30 ++ </classpathentry>
  31 + <classpathentry including="**/*.java" kind="src" path="src/main/resources"/>
  32 +- <classpathentry kind="src" path="src/main/resources/i18n"/>
  33 +- <classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
  34 +- <attributes>
  35 +- <attribute name="maven.pomderived" value="true"/>
  36 +- <attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
  37 +- </attributes>
  38 +- </classpathentry>
  39 +- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6">
  40 +- <attributes>
  41 +- <attribute name="maven.pomderived" value="true"/>
  42 +- </attributes>
  43 +- </classpathentry>
  44 +- <classpathentry kind="output" path="target/classes"/>
  45 +-</classpath>
  46 ++ <classpathentry kind="src" path="src/main/resources/i18n"/>
  47 ++ <classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
  48 ++ <attributes>
  49 ++ <attribute name="maven.pomderived" value="true"/>
  50 ++ <attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
  51 ++ </attributes>
  52 ++ </classpathentry>
  53 ++ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6">
  54 ++ <attributes>
  55 ++ <attribute name="maven.pomderived" value="true"/>
  56 ++ </attributes>
  57 ++ </classpathentry>
  58 ++ <classpathentry kind="output" path="target/classes"/>
  59 ++</classpath>
... ...
.settings/org.eclipse.wst.common.component
1   -<?xml version="1.0" encoding="UTF-8"?><project-modules id="moduleCoreId" project-version="1.5.0">
2   - <wb-module deploy-name="cnlive_live_web">
3   - <wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/>
4   - <wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/resources"/>
5   - <wb-resource deploy-path="/" source-path="/target/m2e-wtp/web-resources"/>
6   - <wb-resource deploy-path="/" source-path="/src/main/webapp" tag="defaultRootSource"/>
7   - <wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/resources/i18n"/>
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   - <dependency-type>uses</dependency-type>
10   - </dependent-module>
11   - <dependent-module archiveName="smart-framework-4.0.1.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/smart-framework/smart-framework">
12   - <dependency-type>uses</dependency-type>
13   - </dependent-module>
14   - <dependent-module archiveName="smart-plugin-job-1.0.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/smart-plugin-job/smart-plugin-job">
15   - <dependency-type>uses</dependency-type>
16   - </dependent-module>
17   - <dependent-module archiveName="smart-plugin-dbcp-1.0.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/smart-plugin-dbcp/smart-plugin-dbcp">
18   - <dependency-type>uses</dependency-type>
19   - </dependent-module>
20   - <dependent-module archiveName="smart-plugin-rest-1.0.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/smart-plugin-rest/smart-plugin-rest">
21   - <dependency-type>uses</dependency-type>
22   - </dependent-module>
23   - <dependent-module archiveName="smart-plugin-i18n-1.0.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/smart-plugin-i18n/smart-plugin-i18n">
24   - <dependency-type>uses</dependency-type>
25   - </dependent-module>
26   - <dependent-module archiveName="cnlive_mam_commons-0.0.1-SNAPSHOT.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/cnlive_mam_commons/cnlive_mam_commons">
27   - <dependency-type>uses</dependency-type>
28   - </dependent-module>
29   - <property name="java-output-path" value="/cnlive_live_web/target/classes"/>
30   - <property name="context-root" value="cnlive_live_web"/>
31   - </wb-module>
32   -</project-modules>
  1 +<?xml version="1.0" encoding="UTF-8"?><project-modules id="moduleCoreId" project-version="1.5.0">
  2 + <wb-module deploy-name="cnlive_live_web">
  3 + <wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/>
  4 + <wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/resources"/>
  5 + <wb-resource deploy-path="/" source-path="/target/m2e-wtp/web-resources"/>
  6 + <wb-resource deploy-path="/" source-path="/src/main/webapp" tag="defaultRootSource"/>
  7 + <wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/resources/i18n"/>
  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 + <dependency-type>uses</dependency-type>
  10 + </dependent-module>
  11 + <dependent-module archiveName="smart-framework-4.0.1.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/smart-framework/smart-framework">
  12 + <dependency-type>uses</dependency-type>
  13 + </dependent-module>
  14 + <dependent-module archiveName="smart-plugin-job-1.0.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/smart-plugin-job/smart-plugin-job">
  15 + <dependency-type>uses</dependency-type>
  16 + </dependent-module>
  17 + <dependent-module archiveName="smart-plugin-dbcp-1.0.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/smart-plugin-dbcp/smart-plugin-dbcp">
  18 + <dependency-type>uses</dependency-type>
  19 + </dependent-module>
  20 + <dependent-module archiveName="smart-plugin-rest-1.0.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/smart-plugin-rest/smart-plugin-rest">
  21 + <dependency-type>uses</dependency-type>
  22 + </dependent-module>
  23 + <dependent-module archiveName="smart-plugin-i18n-1.0.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/smart-plugin-i18n/smart-plugin-i18n">
  24 + <dependency-type>uses</dependency-type>
  25 + </dependent-module>
  26 + <dependent-module archiveName="cnlive_mam_commons-0.0.1-SNAPSHOT.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/cnlive_mam_commons/cnlive_mam_commons">
  27 + <dependency-type>uses</dependency-type>
  28 + </dependent-module>
  29 + <property name="java-output-path" value="/cnlive_live_web/target/classes"/>
  30 + <property name="context-root" value="cnlive_live_web"/>
  31 + </wb-module>
  32 +</project-modules>
... ...
src/main/java/com/cnlive/mz/live/action/CheckAction.java 0 → 100644
  1 +package com.cnlive.mz.live.action;
  2 +
  3 +import java.io.UnsupportedEncodingException;
  4 +import java.net.URLEncoder;
  5 +import java.util.List;
  6 +import java.util.Map;
  7 +
  8 +import org.smart4j.framework.dao.bean.Pager;
  9 +import org.smart4j.framework.ioc.annotation.Inject;
  10 +import org.smart4j.framework.mvc.DataContext;
  11 +import org.smart4j.framework.mvc.annotation.Action;
  12 +import org.smart4j.framework.mvc.annotation.Request;
  13 +import org.smart4j.framework.mvc.bean.Params;
  14 +import org.smart4j.framework.mvc.bean.Result;
  15 +import org.smart4j.framework.mvc.bean.View;
  16 +import org.smart4j.framework.util.CastUtil;
  17 +
  18 +import com.cnlive.mz.commons.JsonUtil;
  19 +import com.cnlive.mz.commons.net.HttpReq;
  20 +import com.cnlive.mz.live.common.LiveUtils;
  21 +import com.cnlive.mz.live.entity.TLive;
  22 +import com.cnlive.mz.live.rest.BaseUtil;
  23 +import com.cnlive.mz.live.service.TCheckService;
  24 +import com.cnlive.mz.live.service.TLiveService;
  25 +import com.cnlive.mz.live.service.TRoomService;
  26 +
  27 +@Action
  28 +public class CheckAction {
  29 +
  30 + @Inject
  31 + private TLiveService tLiveService;
  32 + @Inject
  33 + private TRoomService tRoomService;
  34 + @Inject
  35 + private TCheckService tCheckService;
  36 +
  37 + // @Request.Get("/check/list/{page_number}")
  38 + // public View list(int page_number) {
  39 + // int user_id =
  40 + // CastUtil.castInt(DataContext.getRequest().getSession().getAttribute(LiveUtils.SESSION_KEY_ID));
  41 + // System.out.println(user_id);
  42 + // Pager<TLive> tLive = tCheckService.getTCheckLivePager(page_number, 9,
  43 + // user_id);
  44 + // List list = tLiveService.getLives(user_id);
  45 + // View view = new View("check/check_management.jsp");
  46 + // view.data("tLive", tLive);
  47 + // view.data("list", list);
  48 + // return view;
  49 + // //return new View("check/demo.html");
  50 + // }
  51 + @Request.Post("/check/close/{id}")
  52 + public Result coseLive(int id, Params params) throws UnsupportedEncodingException {
  53 + String userId = params.getString("user_id");
  54 + String streamName = userId + "_" + id;
  55 + String accesskey = BaseUtil.getAccessKey();
  56 + accesskey = java.net.URLEncoder.encode(accesskey, "utf-8");
  57 + String signature = BaseUtil.signature(streamName);
  58 + String del = "del";
  59 + String delsignature = BaseUtil.signature(del, streamName);
  60 + String expire = BaseUtil.getTimestamp();
  61 + System.out.println(expire + "---expire---");
  62 + // ��ӵ�������
  63 + try {
  64 + addBlackList(signature, accesskey, expire, streamName);
  65 + delBlackList(delsignature, accesskey, expire, streamName);
  66 + } catch (UnsupportedEncodingException e) {
  67 + e.printStackTrace();
  68 + }
  69 + boolean flag = tCheckService.closeLive(id);
  70 + return new Result(flag);
  71 + }
  72 +
  73 + /**
  74 + * ��ӵ�����
  75 + *
  76 + * @param signature
  77 + * @param accesskey
  78 + * @param expire
  79 + * @param streamName
  80 + * @return
  81 + * @throws UnsupportedEncodingException
  82 + */
  83 + public String addBlackList(String signature, String accesskey, String expire, String streamName)
  84 + throws UnsupportedEncodingException {
  85 + String url = "http://cnlive.dashboard.ks-cdn.com/blacklist?signature=" + signature + "&accesskey=" + accesskey
  86 + + "&expire=" + expire + "&app=live&method=add&name=" + streamName;
  87 + System.out.println(url);
  88 + String jsonArrStr = HttpReq.getRequestWidthResult(url);
  89 + int status = HttpReq.getRequest(url);
  90 + System.out.println(status + "......and......" + jsonArrStr);
  91 + /*
  92 + * Map map = JsonUtil.getMapFromJsonObjStr(jsonArrStr); String
  93 + * chatRoomid = (String) map.get("Content-Length");
  94 + */
  95 + return jsonArrStr;
  96 + }
  97 +
  98 + /**
  99 + * �Ӻ���ɾ��
  100 + *
  101 + * @param signature
  102 + * @param accesskey
  103 + * @param expire
  104 + * @param streamName
  105 + * @return
  106 + * @throws UnsupportedEncodingException
  107 + */
  108 + public Object delBlackList(String signature, String accesskey, String expire, String streamName)
  109 + throws UnsupportedEncodingException {
  110 + String url = "http://cnlive.dashboard.ks-cdn.com/blacklist?signature=" + signature + "&accesskey=" + accesskey
  111 + + "&expire=" + expire + "&app=live&method=del&name=" + streamName;
  112 + System.out.println("..url.." + url);
  113 + String jsonArrStr = HttpReq.getRequestWidthResult(url);
  114 + System.out.println("..jsonArrStr.." + jsonArrStr);
  115 + /*
  116 + * Map map = JsonUtil.getMapFromJsonObjStr(jsonArrStr); String
  117 + * chatRoomid = (String) map.get("Content-Length");
  118 + */
  119 + return jsonArrStr;
  120 + }
  121 +
  122 +}
... ...
src/main/java/com/cnlive/mz/live/action/HttpPostArgumentTest2.java
1   -package com.cnlive.mz.live.action;
2   -
3   -import java.io.File;
4   -import java.io.IOException;
5   -
6   -import org.apache.commons.httpclient.NameValuePair;
7   -import org.apache.commons.httpclient.params.HttpMethodParams;
8   -import org.apache.http.HttpEntity;
9   -import org.apache.http.HttpResponse;
10   -import org.apache.http.HttpStatus;
11   -import org.apache.http.ParseException;
12   -import org.apache.http.client.HttpClient;
13   -import org.apache.http.client.methods.HttpPost;
14   -import org.apache.http.entity.mime.MultipartEntity;
15   -import org.apache.http.entity.mime.content.FileBody;
16   -import org.apache.http.entity.mime.content.StringBody;
17   -import org.apache.http.impl.client.DefaultHttpClient;
18   -import org.apache.http.util.EntityUtils;
19   -
20   -import com.cnlive.mz.commons.net.HttpReq;
21   -
22   -public class HttpPostArgumentTest2 {
23   -
24   - private static String user_access_key = "cf34f28db21b46678237bfa849e239ea";
25   - private static String app_access_key = "7338ebf9cab441c0843e437a18d85549";
26   -
27   - public void SubmitPost(String url, String filepath) {
28   - HttpClient httpclient = new DefaultHttpClient();
29   - try {
30   - HttpPost httppost = new HttpPost(url);
31   - FileBody bin = new FileBody(new File(filepath));
32   - MultipartEntity reqEntity = new MultipartEntity();
33   - // reqEntity.addPart("file", bin);
34   - reqEntity.addPart("app_access_key", new StringBody("7338ebf9cab441c0843e437a18d85549"));
35   - reqEntity.addPart("user_access_key", new StringBody("cf34f28db21b46678237bfa849e239ea"));
36   - reqEntity.addPart("direct", new StringBody("0"));
37   - reqEntity.addPart("upload_type", new StringBody("1"));
38   - reqEntity.addPart("md5", new StringBody("liujicheng"));
39   - reqEntity.addPart("title", new StringBody("title"));
40   - reqEntity.addPart("name", new StringBody("中投视频宣传片熊猫test"));
41   - reqEntity.addPart("server_access_key", new StringBody("3830ce241dad4b9f844d131c890231ae"));
42   -
43   - httppost.setEntity(reqEntity);
44   - HttpResponse response = httpclient.execute(httppost);
45   - int statusCode = response.getStatusLine().getStatusCode();
46   - System.out.println(statusCode);
47   - System.out.println("服务器正常响应.....");
48   - HttpEntity resEntity = response.getEntity();
49   - System.out.println(EntityUtils.toString(resEntity));
50   - System.out.println(resEntity.getContent());
51   - EntityUtils.consume(resEntity);
52   -
53   - } catch (ParseException e) {
54   - e.printStackTrace();
55   - } catch (IOException e) {
56   - e.printStackTrace();
57   - } finally {
58   - try {
59   - httpclient.getConnectionManager().shutdown();
60   - } catch (Exception ignore) {
61   - ignore.printStackTrace();
62   - }
63   - }
64   - }
65   -
66   - public static void redirect() {
67   - NameValuePair[] param = { new NameValuePair("relation_id", "283645"), new NameValuePair("video_type", "3"),
68   - new NameValuePair("user_access_key", user_access_key),
69   - new NameValuePair("app_access_key", app_access_key) };
70   - String c = HttpReq.postRequestWidthResult("http://bc.cnlive.com/api/video/redirect", param);
71   - System.out.println(c);
72   - }
73   -
74   - public static void delete() {
75   - NameValuePair[] param = { new NameValuePair("video_type", "2"),
76   - new NameValuePair("app_access_key", "7338ebf9cab441c0843e437a18d85549"),
77   - new NameValuePair("user_access_key", "cf34f28db21b46678237bfa849e239ea"),
78   - new NameValuePair("video_uuid", "a8794762b3e92c7d6589a6157cf1ef27,7e26dee78a584f8c5ab1d93a9c878f1d") };
79   - String c = HttpReq.postRequestWidthResult("http://bc.cnlive.com/api/video/delete", param);
80   - System.out.println(c);
81   - }
82   -
83   - private static String md5 = "ffa699fb66750acab30b71b8ceb0172d1";
84   -
85   - public static void supload() {
86   - NameValuePair[] param = { new NameValuePair("app_access_key", app_access_key),
87   - new NameValuePair("user_access_key", user_access_key), new NameValuePair("video_type", "2"),
88   - new NameValuePair("upload_type", "0"), new NameValuePair("direct", "1"), new NameValuePair("md5", md5),
89   - new NameValuePair("title", "tit三道恩le1"), new NameValuePair("relation_id", "615207"),
90   - new NameValuePair("custom_args", "custom_args1"), new NameValuePair("name", "VID_20151224_105421.mp4"),
91   - new NameValuePair("server_access_key", "3830ce241dad4b9f844d131c890231ae") };
92   - String c = HttpReq.postRequestWidthResult("http://bc.cnlive.com/api/video/supload", param);
93   - System.out.println(c);
94   - }
95   -
96   - public static void uploadNotify() {
97   - NameValuePair[] param = { new NameValuePair("app_access_key", app_access_key),
98   - new NameValuePair("user_access_key", user_access_key), new NameValuePair("upload_type", "1"),
99   - new NameValuePair("video_type", "2"), new NameValuePair("state", "200"),
100   - new NameValuePair("video_uuid", md5) };
101   - String c = HttpReq
102   - .postRequestWidthResult("http://localhost:8080/cnlive_live_web/api/video/uploadNotify", param);
103   - System.out.println(c);
104   - }
105   -
106   - public static void all() {
107   - NameValuePair[] param = { new NameValuePair("app_access_key", app_access_key),
108   - new NameValuePair("relation_id", "498122"),
109   -
110   - new NameValuePair("user_access_key", user_access_key), new NameValuePair("upload_type", "1"),
111   - new NameValuePair("video_type", "2"), new NameValuePair("page_no", "1"),
112   - new NameValuePair("video_uuid", md5) };
113   - String c = HttpReq.postRequestWidthResult("http://localhost:8080/cnlive_live_web/api/video/all", param);
114   - System.out.println(c);
115   - }
116   -
117   - public static void main(String[] args) {
118   - // new HttpPostArgumentTest2().delete();
119   - //HttpPostArgumentTest2.all();
120   - HttpPostArgumentTest2.redirect();
121   - // HttpReq.postRequestWidthResult("http://120.132.76.51:9696/cnlive_encoding_job/task",
122   - // "json", "jsonjsonjsonjson");r
123   - }
124   -
125   -}
  1 +package com.cnlive.mz.live.action;
  2 +
  3 +import java.io.File;
  4 +import java.io.IOException;
  5 +
  6 +import org.apache.commons.httpclient.NameValuePair;
  7 +import org.apache.commons.httpclient.params.HttpMethodParams;
  8 +import org.apache.http.HttpEntity;
  9 +import org.apache.http.HttpResponse;
  10 +import org.apache.http.HttpStatus;
  11 +import org.apache.http.ParseException;
  12 +import org.apache.http.client.HttpClient;
  13 +import org.apache.http.client.methods.HttpPost;
  14 +import org.apache.http.entity.mime.MultipartEntity;
  15 +import org.apache.http.entity.mime.content.FileBody;
  16 +import org.apache.http.entity.mime.content.StringBody;
  17 +import org.apache.http.impl.client.DefaultHttpClient;
  18 +import org.apache.http.util.EntityUtils;
  19 +
  20 +import com.cnlive.mz.commons.net.HttpReq;
  21 +
  22 +public class HttpPostArgumentTest2 {
  23 +
  24 + private static String user_access_key = "cf34f28db21b46678237bfa849e239ea";
  25 + private static String app_access_key = "7338ebf9cab441c0843e437a18d85549";
  26 +
  27 + public void SubmitPost(String url, String filepath) {
  28 + HttpClient httpclient = new DefaultHttpClient();
  29 + try {
  30 + HttpPost httppost = new HttpPost(url);
  31 + FileBody bin = new FileBody(new File(filepath));
  32 + MultipartEntity reqEntity = new MultipartEntity();
  33 + // reqEntity.addPart("file", bin);
  34 + reqEntity.addPart("app_access_key", new StringBody("7338ebf9cab441c0843e437a18d85549"));
  35 + reqEntity.addPart("user_access_key", new StringBody("cf34f28db21b46678237bfa849e239ea"));
  36 + reqEntity.addPart("direct", new StringBody("0"));
  37 + reqEntity.addPart("upload_type", new StringBody("1"));
  38 + reqEntity.addPart("md5", new StringBody("liujicheng"));
  39 + reqEntity.addPart("title", new StringBody("title"));
  40 + reqEntity.addPart("name", new StringBody("中投视频宣传片熊猫test"));
  41 + reqEntity.addPart("server_access_key", new StringBody("3830ce241dad4b9f844d131c890231ae"));
  42 +
  43 + httppost.setEntity(reqEntity);
  44 + HttpResponse response = httpclient.execute(httppost);
  45 + int statusCode = response.getStatusLine().getStatusCode();
  46 + System.out.println(statusCode);
  47 + System.out.println("服务器正常响应.....");
  48 + HttpEntity resEntity = response.getEntity();
  49 + System.out.println(EntityUtils.toString(resEntity));
  50 + System.out.println(resEntity.getContent());
  51 + EntityUtils.consume(resEntity);
  52 +
  53 + } catch (ParseException e) {
  54 + e.printStackTrace();
  55 + } catch (IOException e) {
  56 + e.printStackTrace();
  57 + } finally {
  58 + try {
  59 + httpclient.getConnectionManager().shutdown();
  60 + } catch (Exception ignore) {
  61 + ignore.printStackTrace();
  62 + }
  63 + }
  64 + }
  65 +
  66 + public static void redirect() {
  67 + NameValuePair[] param = { new NameValuePair("relation_id", "283645"), new NameValuePair("video_type", "3"),
  68 + new NameValuePair("user_access_key", user_access_key),
  69 + new NameValuePair("app_access_key", app_access_key) };
  70 + String c = HttpReq.postRequestWidthResult("http://bc.cnlive.com/api/video/redirect", param);
  71 + System.out.println(c);
  72 + }
  73 +
  74 + public static void delete() {
  75 + NameValuePair[] param = { new NameValuePair("video_type", "2"),
  76 + new NameValuePair("app_access_key", "7338ebf9cab441c0843e437a18d85549"),
  77 + new NameValuePair("user_access_key", "cf34f28db21b46678237bfa849e239ea"),
  78 + new NameValuePair("video_uuid", "a8794762b3e92c7d6589a6157cf1ef27,7e26dee78a584f8c5ab1d93a9c878f1d") };
  79 + String c = HttpReq.postRequestWidthResult("http://bc.cnlive.com/api/video/delete", param);
  80 + System.out.println(c);
  81 + }
  82 +
  83 + private static String md5 = "ffa699fb66750acab30b71b8ceb0172d1";
  84 +
  85 + public static void supload() {
  86 + NameValuePair[] param = { new NameValuePair("app_access_key", app_access_key),
  87 + new NameValuePair("user_access_key", user_access_key), new NameValuePair("video_type", "2"),
  88 + new NameValuePair("upload_type", "0"), new NameValuePair("direct", "1"), new NameValuePair("md5", md5),
  89 + new NameValuePair("title", "tit三道恩le1"), new NameValuePair("relation_id", "615207"),
  90 + new NameValuePair("custom_args", "custom_args1"), new NameValuePair("name", "VID_20151224_105421.mp4"),
  91 + new NameValuePair("server_access_key", "3830ce241dad4b9f844d131c890231ae") };
  92 + String c = HttpReq.postRequestWidthResult("http://bc.cnlive.com/api/video/supload", param);
  93 + System.out.println(c);
  94 + }
  95 +
  96 + public static void uploadNotify() {
  97 + NameValuePair[] param = { new NameValuePair("app_access_key", app_access_key),
  98 + new NameValuePair("user_access_key", user_access_key), new NameValuePair("upload_type", "1"),
  99 + new NameValuePair("video_type", "2"), new NameValuePair("state", "200"),
  100 + new NameValuePair("video_uuid", md5) };
  101 + String c = HttpReq
  102 + .postRequestWidthResult("http://localhost:8080/cnlive_live_web/api/video/uploadNotify", param);
  103 + System.out.println(c);
  104 + }
  105 +
  106 + public static void all() {
  107 + NameValuePair[] param = { new NameValuePair("app_access_key", app_access_key),
  108 + new NameValuePair("relation_id", "498122"),
  109 +
  110 + new NameValuePair("user_access_key", user_access_key), new NameValuePair("upload_type", "1"),
  111 + new NameValuePair("video_type", "2"), new NameValuePair("page_no", "1"),
  112 + new NameValuePair("video_uuid", md5) };
  113 + String c = HttpReq.postRequestWidthResult("http://localhost:8080/cnlive_live_web/api/video/all", param);
  114 + System.out.println(c);
  115 + }
  116 +
  117 + public static void main(String[] args) {
  118 + // new HttpPostArgumentTest2().delete();
  119 + //HttpPostArgumentTest2.all();
  120 + HttpPostArgumentTest2.redirect();
  121 + // HttpReq.postRequestWidthResult("http://120.132.76.51:9696/cnlive_encoding_job/task",
  122 + // "json", "jsonjsonjsonjson");r
  123 + }
  124 +
  125 +}
... ...
src/main/java/com/cnlive/mz/live/action/Init.java 0 → 100644
  1 +package com.cnlive.mz.live.action;
  2 +
  3 +import java.io.IOException;
  4 +
  5 +import javax.servlet.ServletConfig;
  6 +import javax.servlet.ServletException;
  7 +import javax.servlet.http.HttpServlet;
  8 +import javax.servlet.http.HttpServletRequest;
  9 +import javax.servlet.http.HttpServletResponse;
  10 +
  11 +import org.smart4j.plugin.job.JobHelper;
  12 +
  13 +import com.cnlive.mz.live.service.impl.Job;
  14 +
  15 +public class Init extends HttpServlet {
  16 +
  17 + @Override
  18 + public void init(ServletConfig config) throws ServletException {
  19 + // 初始化
  20 + JobHelper.startJob(Job.class, "0/30 * * * * ?");
  21 + }
  22 +
  23 + @Override
  24 + protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
  25 + super.doGet(req, resp);
  26 + }
  27 +
  28 + @Override
  29 + protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
  30 + super.doPost(req, resp);
  31 + }
  32 +}
... ...
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.UnsupportedEncodingException;
13   -import java.util.List;
14   -
15   -import org.smart4j.framework.dao.bean.Pager;
16   -import org.smart4j.framework.ioc.annotation.Inject;
17   -import org.smart4j.framework.mvc.DataContext;
18   -import org.smart4j.framework.mvc.annotation.Action;
19   -import org.smart4j.framework.mvc.annotation.Request;
20   -import org.smart4j.framework.mvc.bean.Multipart;
21   -import org.smart4j.framework.mvc.bean.Multiparts;
22   -import org.smart4j.framework.mvc.bean.Params;
23   -import org.smart4j.framework.mvc.bean.Result;
24   -import org.smart4j.framework.mvc.bean.View;
25   -import org.smart4j.framework.util.CastUtil;
26   -
27   -import com.cnlive.mz.commons.Constants;
28   -import com.cnlive.mz.commons.net.HttpReq;
29   -import com.cnlive.mz.live.common.LiveUtils;
30   -import com.cnlive.mz.live.entity.TLive;
31   -import com.cnlive.mz.live.entity.TRoom;
32   -import com.cnlive.mz.live.rest.BaseUtil;
33   -import com.cnlive.mz.live.service.TLiveService;
34   -import com.cnlive.mz.live.service.TRoomService;
35   -
36   -/**
37   - * TODO: 机构主播和个人主播发起直播活动 <br/>
38   - * Date: 2016年4月25日 下午1:12:48 <br/>
39   - *
40   - * @author liujicheng
41   - * @version V1.0
42   - * @since JDK 1.6
43   - */
44   -@Action
45   -public class LiveAction {
46   - @Inject
47   - private TLiveService tLiveService;
48   - @Inject
49   - private TRoomService tRoomService;
50   -
51   - @Request.Get("/live/preload")
52   - public View preload() {
53   - int user_id = CastUtil.castInt(DataContext.getRequest().getSession().getAttribute(LiveUtils.SESSION_KEY_ID));
54   - View view = new View("live/live_add.jsp");
55   - List<TRoom> tRooms = tRoomService.getTRooms(user_id);
56   - view.data("tRooms", tRooms);
57   - return view;
58   - }
59   -
60   - @Request.Get("/live/list/{page_number}")
61   - public View list(int page_number) {
62   - int user_id = CastUtil.castInt(DataContext.getRequest().getSession().getAttribute(LiveUtils.SESSION_KEY_ID));
63   - System.out.println(user_id);
64   - Pager<TLive> tLive = tLiveService.getTLivePager(page_number, Constants.PAGE_SIZE, user_id);
65   - return new View("live/live_management.jsp").data("tLive", tLive);
66   - }
67   -
68   - @Request.Post("/live/save")
69   - public Result saveLive(Params params, Multiparts multiparts) {
70   - System.out.println(params + "....and....." + multiparts);
71   - int user_id = CastUtil.castInt(DataContext.getRequest().getSession().getAttribute(LiveUtils.SESSION_KEY_ID));
72   - Multipart multipart = multiparts.getOne();
73   - tLiveService.add(user_id, params, multipart);
74   - return new Result(false);
75   - }
76   -
77   - @Request.Get("/live/edit/{id}")
78   - public View edit(int id) {
79   - TLive tLive = tLiveService.getTLiveById(id);
80   - TRoom tRoom = tRoomService.getTRoomById(Integer.parseInt(tLive.getLive_room_id()));
81   - List<TRoom> list = tRoomService.getTRooms(tLive.getT_user_id());
82   - View view = new View("live/live_edit.jsp");
83   - view.data("tActivity", tLive);
84   - view.data("tRoom", tRoom);
85   - view.data("tRooms", list);
86   - return view;
87   - }
88   -
89   - //
90   - @Request.Get("/live/preview/{id}")
91   - public View preview(int id) {
92   - TLive tLive = tLiveService.getTLiveById(id);
93   - TRoom tRoom = tRoomService.getTRoomById(Integer.parseInt(tLive.getLive_room_id()));
94   - View view = new View("live/live_preview.jsp");
95   - view.data("tLive", tLive);
96   - view.data("tRoom", tRoom);
97   - return view;
98   - }
99   -
100   - @Request.Get("/check/list/{page_number}")
101   - public View check(int page_number) {
102   - int user_id = CastUtil.castInt(DataContext.getRequest().getSession().getAttribute(LiveUtils.SESSION_KEY_ID));
103   - Pager<TLive> tLive = tLiveService.getTCheckLivePager(page_number, 12, user_id);
104   - View view = new View("check/monitor.jsp");
105   - view.data("tLive", tLive);
106   - return view;
107   - }
108   -
109   - // 置顶
110   - @Request.Get("/check/top/{id}")
111   - public Result top(int id) {
112   - tLiveService.top(id);
113   - return new Result(true);
114   - }
115   -
116   - // 切断
117   - @Request.Get("/check/cut/{id}")
118   - public Result cut(int id) {
119   - return new Result(true);
120   - }
121   -
122   - // 通过审核
123   - @Request.Get("/check/pass/{id}")
124   - public Result pass(int id) {
125   - tLiveService.pass(id);
126   - return new Result(true);
127   - }
128   -
129   - @Request.Post("/check/close/{id}")
130   - public Result coseLive(int id, Params params) throws UnsupportedEncodingException {
131   - String userId = params.getString("user_id");
132   - String streamName = userId + "_" + id;
133   - // String streamName = "498122_57";
134   - String accesskey = "I3TC8a4xboPUMe5xlp22";
135   - accesskey = java.net.URLEncoder.encode(accesskey, "utf-8");
136   - String signature = BaseUtil.signature(streamName);
137   - String expire = String.valueOf(BaseUtil.getTimestamp()).substring(0, 10);
138   - System.out.println(expire + "---expire---");
139   - // 添加到黑名单。。
140   - try {
141   - addBlackList(signature, accesskey, expire, streamName);
142   - } catch (UnsupportedEncodingException e) {
143   - e.printStackTrace();
144   - }
145   - boolean flag = tLiveService.closeLive(id);
146   - return new Result(flag);
147   - }
148   -
149   - /**
150   - * 添加到黑名单
151   - *
152   - * @param signature
153   - * @param accesskey
154   - * @param expire
155   - * @param streamName
156   - * @return
157   - * @throws UnsupportedEncodingException
158   - */
159   - public String addBlackList(String signature, String accesskey, String expire, String streamName)
160   - throws UnsupportedEncodingException {
161   - String url = "http://cnlive.dashboard.ks-cdn.com/blacklist?signature=" + signature + "&accesskey=" + accesskey
162   - + "&expire=" + expire + "&method=add&app=live&name=" + streamName;
163   - System.out.println(url);
164   - String jsonArrStr = HttpReq.getRequestWidthResult(url);
165   - int status = HttpReq.getRequest(url);
166   - System.out.println("............" + status);
167   - System.out.println("............" + jsonArrStr);
168   - /*
169   - * Map map = JsonUtil.getMapFromJsonObjStr(jsonArrStr); String
170   - * chatRoomid = (String) map.get("Content-Length");
171   - */
172   - return jsonArrStr;
173   - }
174   -
175   - /**
176   - * 从黑名单删除
177   - *
178   - * @param signature
179   - * @param accesskey
180   - * @param expire
181   - * @param streamName
182   - * @return
183   - * @throws UnsupportedEncodingException
184   - */
185   - public Object delBlackList(String signature, String accesskey, String expire, String streamName)
186   - throws UnsupportedEncodingException {
187   - String url = "http://cnlive.uplive.ks-cdn.com/blacklist?signature=" + signature + "&accesskey=" + accesskey
188   - + "&expire=" + expire + "&method=del&app=live&name=" + streamName;
189   - String jsonArrStr = HttpReq.getRequestWidthResult(url);
190   - System.out.println();
191   - /*
192   - * Map map = JsonUtil.getMapFromJsonObjStr(jsonArrStr); String
193   - * chatRoomid = (String) map.get("Content-Length");
194   - */
195   - return jsonArrStr;
196   - }
  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.UnsupportedEncodingException;
  13 +import java.util.List;
  14 +
  15 +import org.smart4j.framework.dao.bean.Pager;
  16 +import org.smart4j.framework.ioc.annotation.Inject;
  17 +import org.smart4j.framework.mvc.DataContext;
  18 +import org.smart4j.framework.mvc.annotation.Action;
  19 +import org.smart4j.framework.mvc.annotation.Request;
  20 +import org.smart4j.framework.mvc.bean.Multipart;
  21 +import org.smart4j.framework.mvc.bean.Multiparts;
  22 +import org.smart4j.framework.mvc.bean.Params;
  23 +import org.smart4j.framework.mvc.bean.Result;
  24 +import org.smart4j.framework.mvc.bean.View;
  25 +import org.smart4j.framework.util.CastUtil;
  26 +
  27 +import com.cnlive.mz.commons.Constants;
  28 +import com.cnlive.mz.commons.net.HttpReq;
  29 +import com.cnlive.mz.live.common.LiveUtils;
  30 +import com.cnlive.mz.live.entity.TLive;
  31 +import com.cnlive.mz.live.entity.TRoom;
  32 +import com.cnlive.mz.live.rest.BaseUtil;
  33 +import com.cnlive.mz.live.service.TCheckService;
  34 +import com.cnlive.mz.live.service.TLiveService;
  35 +import com.cnlive.mz.live.service.TRoomService;
  36 +
  37 +/**
  38 + * TODO: 机构主播和个人主播发起直播活动 <br/>
  39 + * Date: 2016年4月25日 下午1:12:48 <br/>
  40 + *
  41 + * @author liujicheng
  42 + * @version V1.0
  43 + * @since JDK 1.6
  44 + */
  45 +@Action
  46 +public class LiveAction {
  47 + @Inject
  48 + private TLiveService tLiveService;
  49 + @Inject
  50 + private TRoomService tRoomService;
  51 + @Inject
  52 + private TCheckService tCheckService;
  53 + @Request.Get("/live/preload")
  54 + public View preload() {
  55 + int user_id = CastUtil.castInt(DataContext.getRequest().getSession().getAttribute(LiveUtils.SESSION_KEY_ID));
  56 + View view = new View("live/live_add.jsp");
  57 + List<TRoom> tRooms = tRoomService.getTRooms(user_id);
  58 + view.data("tRooms", tRooms);
  59 + return view;
  60 + }
  61 +
  62 + @Request.Get("/live/list/{page_number}")
  63 + public View list(int page_number) {
  64 + int user_id = CastUtil.castInt(DataContext.getRequest().getSession().getAttribute(LiveUtils.SESSION_KEY_ID));
  65 + System.out.println(user_id);
  66 + Pager<TLive> tLive = tLiveService.getTLivePager(page_number, Constants.PAGE_SIZE, user_id);
  67 + return new View("live/live_management.jsp").data("tLive", tLive);
  68 + }
  69 +
  70 + @Request.Post("/live/save")
  71 + public Result saveLive(Params params, Multiparts multiparts) {
  72 + System.out.println(params + "....and....." + multiparts);
  73 + int user_id = CastUtil.castInt(DataContext.getRequest().getSession().getAttribute(LiveUtils.SESSION_KEY_ID));
  74 + Multipart multipart = multiparts.getOne();
  75 + tLiveService.add(user_id, params, multipart);
  76 + return new Result(false);
  77 + }
  78 +
  79 + @Request.Get("/live/edit/{id}")
  80 + public View edit(int id) {
  81 + TLive tLive = tLiveService.getTLiveById(id);
  82 + TRoom tRoom = tRoomService.getTRoomById(Integer.parseInt(tLive.getLive_room_id()));
  83 + List<TRoom> list = tRoomService.getTRooms(tLive.getT_user_id());
  84 + View view = new View("live/live_edit.jsp");
  85 + view.data("tActivity", tLive);
  86 + view.data("tRoom", tRoom);
  87 + view.data("tRooms", list);
  88 + return view;
  89 + }
  90 +
  91 + //
  92 + @Request.Get("/live/preview/{id}")
  93 + public View preview(int id) {
  94 + TLive tLive = tLiveService.getTLiveById(id);
  95 + TRoom tRoom = tRoomService.getTRoomById(Integer.parseInt(tLive.getLive_room_id()));
  96 + View view = new View("live/live_preview.jsp");
  97 + view.data("tLive", tLive);
  98 + view.data("tRoom", tRoom);
  99 + return view;
  100 + }
  101 +
  102 + @Request.Get("/check/list/{page_number}")
  103 + public View check(int page_number) {
  104 + int user_id = CastUtil.castInt(DataContext.getRequest().getSession().getAttribute(LiveUtils.SESSION_KEY_ID));
  105 + Pager<TLive> tLive = tLiveService.getTCheckLivePager(page_number, 12, user_id);
  106 + View view = new View("check/monitor.jsp");
  107 + view.data("tLive", tLive);
  108 + return view;
  109 + }
  110 +
  111 + // 置顶
  112 + @Request.Get("/check/top/{id}")
  113 + public Result top(int id) {
  114 + tLiveService.top(id);
  115 + return new Result(true);
  116 + }
  117 +
  118 + // 切断
  119 + @Request.Post("/check/cut/{id}")
  120 + public Result cut(int id,Params params) throws UnsupportedEncodingException {
  121 + String live_url = params.getString("live_url");
  122 + if(live_url.isEmpty()){
  123 + return null;
  124 + }else{
  125 + int index = live_url.lastIndexOf("live");
  126 + String streamName = live_url.substring(index+6);
  127 + System.out.println("streamName==="+streamName);
  128 + String accesskey = BaseUtil.getAccessKey();
  129 + accesskey = java.net.URLEncoder.encode(accesskey,"utf-8");
  130 + String signature = BaseUtil.signature(streamName);
  131 + String del = "del";
  132 + String delsignature = BaseUtil.signature(del,streamName);
  133 + String expire = BaseUtil.getTimestamp();
  134 + System.out.println(expire+"---expire---");
  135 + //断流。
  136 + try {
  137 + addBlackList(signature,accesskey,expire,streamName);
  138 + delBlackList(delsignature,accesskey,expire,streamName);
  139 + } catch (UnsupportedEncodingException e) {
  140 + e.printStackTrace();
  141 + }
  142 + boolean flag = tCheckService.closeLive(id);
  143 + return new Result(flag);
  144 + }
  145 + }
  146 + // 通过审核
  147 + @Request.Get("/check/pass/{id}")
  148 + public Result pass(int id) {
  149 + tLiveService.pass(id);
  150 + return new Result(true);
  151 + }
  152 +
  153 + @Request.Post("/check/close/{id}")
  154 + public Result coseLive(int id, Params params) throws UnsupportedEncodingException {
  155 + String userId = params.getString("user_id");
  156 + String streamName = userId + "_" + id;
  157 + // String streamName = "498122_57";
  158 + String accesskey = "I3TC8a4xboPUMe5xlp22";
  159 + accesskey = java.net.URLEncoder.encode(accesskey, "utf-8");
  160 + String signature = BaseUtil.signature(streamName);
  161 + String expire = String.valueOf(BaseUtil.getTimestamp()).substring(0, 10);
  162 + System.out.println(expire + "---expire---");
  163 + // 添加到黑名单。。
  164 + try {
  165 + addBlackList(signature, accesskey, expire, streamName);
  166 + } catch (UnsupportedEncodingException e) {
  167 + e.printStackTrace();
  168 + }
  169 + boolean flag = tLiveService.closeLive(id);
  170 + return new Result(flag);
  171 + }
  172 +
  173 + /**
  174 + * 添加到黑名单
  175 + *
  176 + * @param signature
  177 + * @param accesskey
  178 + * @param expire
  179 + * @param streamName
  180 + * @return
  181 + * @throws UnsupportedEncodingException
  182 + */
  183 + public String addBlackList(String signature, String accesskey, String expire,String streamName) throws UnsupportedEncodingException {
  184 + String url = "http://cnlive.dashboard.ks-cdn.com/blacklist?signature="+signature+"&accesskey="+accesskey+"&expire="+expire+"&app=live&method=add&name=" + streamName;
  185 + System.out.println(url);
  186 + String jsonArrStr = HttpReq.getRequestWidthResult(url);
  187 + int status = HttpReq.getRequest(url);
  188 + System.out.println(status+"......and......"+jsonArrStr);
  189 + return jsonArrStr;
  190 + }
  191 +
  192 + /**
  193 + * 从黑名单删除
  194 + *
  195 + * @param signature
  196 + * @param accesskey
  197 + * @param expire
  198 + * @param streamName
  199 + * @return
  200 + * @throws UnsupportedEncodingException
  201 + */
  202 + public Object delBlackList(String signature, String accesskey, String expire,String streamName) throws UnsupportedEncodingException {
  203 + String url = "http://cnlive.dashboard.ks-cdn.com/blacklist?signature="+signature+"&accesskey="+accesskey+"&expire="+expire+"&app=live&method=del&name=" + streamName;
  204 + System.out.println("..url.."+url);
  205 + String jsonArrStr = HttpReq.getRequestWidthResult(url);
  206 + System.out.println("..jsonArrStr.."+jsonArrStr);
  207 + return jsonArrStr;
  208 +
  209 + }
197 210 }
198 211 \ No newline at end of file
... ...
src/main/java/com/cnlive/mz/live/action/RoomAction.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.util.List;
13   -import java.util.Map;
14   -
15   -import org.smart4j.framework.dao.bean.Pager;
16   -import org.smart4j.framework.ioc.annotation.Inject;
17   -import org.smart4j.framework.mvc.DataContext;
18   -import org.smart4j.framework.mvc.annotation.Action;
19   -import org.smart4j.framework.mvc.annotation.Request;
20   -import org.smart4j.framework.mvc.bean.Multiparts;
21   -import org.smart4j.framework.mvc.bean.Params;
22   -import org.smart4j.framework.mvc.bean.Result;
23   -import org.smart4j.framework.mvc.bean.View;
24   -import org.smart4j.framework.orm.DataSet;
25   -import org.smart4j.framework.util.CastUtil;
26   -
27   -import com.cnlive.mz.commons.Constants;
28   -import com.cnlive.mz.live.common.LiveUtils;
29   -import com.cnlive.mz.live.entity.TRoom;
30   -import com.cnlive.mz.live.service.TRoomService;
31   -
32   -/**
33   - * TODO: 这里用一句话描述当前类的作用 Date: 2016年4月25日 下午1:12:48 <br/>
34   - *
35   - * @author liujicheng
36   - * @version V1.0
37   - * @since JDK 1.6
38   - */
39   -@Action
40   -public class RoomAction {
41   - @Inject
42   - private TRoomService tRoomService;
43   - int user_id = 0;
44   -
45   - @Request.Get("/room/list/{page_number}")
46   - public View list(int page_number) {
47   - // int user_id =
48   - // CastUtil.castInt(DataContext.getRequest().getSession().getAttribute(LiveUtils.SESSION_KEY_ID));
49   - Pager<TRoom> tRooms = tRoomService.getTRoomPager(page_number, Constants.PAGE_SIZE, user_id);
50   - return new View("room/room_management.jsp").data("tRooms", tRooms);
51   - }
52   -
53   - @Request.Get("/room/delete/{id}")
54   - public Result delete(int id) {
55   - int user_id = CastUtil.castInt(DataContext.getRequest().getSession().getAttribute(LiveUtils.SESSION_KEY_ID));
56   - boolean success = tRoomService.delete(id, user_id);
57   - return new Result(success);
58   - }
59   -
60   - // 查看读取
61   - @Request.Get("/room/edit/{id}")
62   - public View edit(int id) {
63   - /*String sql = "select * "
64   - + "from t_video t "
65   - + "where t_user_id = ? and state !=207 and state !=201 and state !=601 order by t.create_time desc ";
66   - List<Map<String,Object>> videoList = DataSet.selectMapWithSql(sql, 9);
67   - System.out.println("....................."+videoList);
68   - for (int i = 0; i < videoList.size(); i++) {
69   - System.out.println(".....................");
70   - System.out.println(videoList.get(i));
71   - }*/
72   - TRoom tRoom = tRoomService.getTRoomById(id);
73   - View view = new View("room/room_edit.jsp");
74   - view.data("tRoom", tRoom);
75   - return view;
76   - }
77   -
78   - @Request.Post("/room/add")
79   - public Result add(Params params, Multiparts multiparts) {
80   - int user_id = CastUtil.castInt(DataContext.getRequest().getSession().getAttribute(LiveUtils.SESSION_KEY_ID));
81   - tRoomService.save(user_id, params, multiparts);
82   - return new Result(true);
83   - }
84   -
85   - // 查看读取
86   - @Request.Get("/room/pload")
87   - public View pload() {
88   - System.out.println(".......");
89   - View view = new View("room/room_add.jsp");
90   - return view;
91   - }
92   - //room/editSave
93   - @Request.Post("/room/editSave")
94   - public Result editSave(Params params, Multiparts multiparts) {
95   - System.out.println(params+"..nnnn.."+multiparts);
96   - int user_id = CastUtil.castInt(DataContext.getRequest().getSession().getAttribute(LiveUtils.SESSION_KEY_ID));
97   - tRoomService.save(user_id, params, multiparts);
98   - return new Result(true);
99   - }
100   -}
  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.util.List;
  13 +import java.util.Map;
  14 +
  15 +import org.smart4j.framework.dao.bean.Pager;
  16 +import org.smart4j.framework.ioc.annotation.Inject;
  17 +import org.smart4j.framework.mvc.DataContext;
  18 +import org.smart4j.framework.mvc.annotation.Action;
  19 +import org.smart4j.framework.mvc.annotation.Request;
  20 +import org.smart4j.framework.mvc.bean.Multiparts;
  21 +import org.smart4j.framework.mvc.bean.Params;
  22 +import org.smart4j.framework.mvc.bean.Result;
  23 +import org.smart4j.framework.mvc.bean.View;
  24 +import org.smart4j.framework.orm.DataSet;
  25 +import org.smart4j.framework.util.CastUtil;
  26 +
  27 +import com.cnlive.mz.commons.Constants;
  28 +import com.cnlive.mz.live.common.LiveUtils;
  29 +import com.cnlive.mz.live.entity.TRoom;
  30 +import com.cnlive.mz.live.service.TRoomService;
  31 +
  32 +/**
  33 + * TODO: 这里用一句话描述当前类的作用 Date: 2016年4月25日 下午1:12:48 <br/>
  34 + *
  35 + * @author liujicheng
  36 + * @version V1.0
  37 + * @since JDK 1.6
  38 + */
  39 +@Action
  40 +public class RoomAction {
  41 + @Inject
  42 + private TRoomService tRoomService;
  43 + int user_id = 0;
  44 +
  45 + @Request.Get("/room/list/{page_number}")
  46 + public View list(int page_number) {
  47 + // int user_id =
  48 + // CastUtil.castInt(DataContext.getRequest().getSession().getAttribute(LiveUtils.SESSION_KEY_ID));
  49 + Pager<TRoom> tRooms = tRoomService.getTRoomPager(page_number, Constants.PAGE_SIZE, user_id);
  50 + return new View("room/room_management.jsp").data("tRooms", tRooms);
  51 + }
  52 +
  53 + @Request.Get("/room/delete/{id}")
  54 + public Result delete(int id) {
  55 + int user_id = CastUtil.castInt(DataContext.getRequest().getSession().getAttribute(LiveUtils.SESSION_KEY_ID));
  56 + boolean success = tRoomService.delete(id, user_id);
  57 + return new Result(success);
  58 + }
  59 +
  60 + // 查看读取
  61 + @Request.Get("/room/edit/{id}")
  62 + public View edit(int id) {
  63 + /*String sql = "select * "
  64 + + "from t_video t "
  65 + + "where t_user_id = ? and state !=207 and state !=201 and state !=601 order by t.create_time desc ";
  66 + List<Map<String,Object>> videoList = DataSet.selectMapWithSql(sql, 9);
  67 + System.out.println("....................."+videoList);
  68 + for (int i = 0; i < videoList.size(); i++) {
  69 + System.out.println(".....................");
  70 + System.out.println(videoList.get(i));
  71 + }*/
  72 + TRoom tRoom = tRoomService.getTRoomById(id);
  73 + View view = new View("room/room_edit.jsp");
  74 + view.data("tRoom", tRoom);
  75 + return view;
  76 + }
  77 +
  78 + @Request.Post("/room/add")
  79 + public Result add(Params params, Multiparts multiparts) {
  80 + int user_id = CastUtil.castInt(DataContext.getRequest().getSession().getAttribute(LiveUtils.SESSION_KEY_ID));
  81 + tRoomService.save(user_id, params, multiparts);
  82 + return new Result(true);
  83 + }
  84 +
  85 + // 查看读取
  86 + @Request.Get("/room/pload")
  87 + public View pload() {
  88 + System.out.println(".......");
  89 + View view = new View("room/room_add.jsp");
  90 + return view;
  91 + }
  92 + //room/editSave
  93 + @Request.Post("/room/editSave")
  94 + public Result editSave(Params params, Multiparts multiparts) {
  95 + System.out.println(params+"..nnnn.."+multiparts);
  96 + int user_id = CastUtil.castInt(DataContext.getRequest().getSession().getAttribute(LiveUtils.SESSION_KEY_ID));
  97 + tRoomService.save(user_id, params, multiparts);
  98 + return new Result(true);
  99 + }
  100 +}
... ...
src/main/java/com/cnlive/mz/live/action/VideoAction.java
1   -package com.cnlive.mz.live.action;
2   -
3   -import java.util.Date;
4   -import java.util.LinkedHashMap;
5   -import java.util.Map;
6   -
7   -import org.apache.commons.lang3.StringUtils;
8   -import org.smart4j.framework.dao.bean.Pager;
9   -import org.smart4j.framework.ioc.annotation.Inject;
10   -import org.smart4j.framework.mvc.DataContext;
11   -import org.smart4j.framework.mvc.annotation.Action;
12   -import org.smart4j.framework.mvc.annotation.Request;
13   -import org.smart4j.framework.mvc.bean.ApiBean;
14   -import org.smart4j.framework.mvc.bean.Params;
15   -import org.smart4j.framework.mvc.bean.Result;
16   -import org.smart4j.framework.mvc.bean.View;
17   -import org.smart4j.framework.util.CastUtil;
18   -
19   -import com.cnlive.mz.commons.CnliveUtil;
20   -import com.cnlive.mz.live.common.LiveUtils;
21   -import com.cnlive.mz.live.entity.TLive;
22   -import com.cnlive.mz.live.entity.TVideo;
23   -import com.cnlive.mz.live.service.TDispatchServerService;
24   -import com.cnlive.mz.live.service.TLiveService;
25   -import com.cnlive.mz.live.service.TUserService;
26   -import com.cnlive.mz.live.service.TVideoService;
27   -
28   -@Action
29   -public class VideoAction {
30   - @Inject
31   - private TDispatchServerService tDispatchServerService;
32   - @Inject
33   - private TVideoService tVideoService;
34   - @Inject
35   - private TUserService tUserService;
36   - @Inject
37   - private TLiveService tLiveService;
38   -
39   - /**
40   - * 服务器定向
41   - *
42   - * @param params
43   - * @return
44   - * {"mediaComment":"","nickName":"阳Sir","appId":"1","mediaName":"","userId"
45   - * :"1167015","uuid":
46   - * "1167015_1463725085798_6a551f9122494a05ac8566b7a2ae1092"}
47   - */
48   - @Request.Post("/api/video/redirect")
49   - public ApiBean redirect(Params params) {
50   - String app_access_key = params.getString("app_access_key");
51   - String video_type = params.getString("video_type");
52   - String user_id = params.getString("relation_id");
53   - ApiBean apiBean = tDispatchServerService.redirect(video_type, app_access_key, user_id);
54   - return apiBean;
55   - }
56   -
57   - @Request.Post("/api/video/supload")
58   - public ApiBean supload(Params params) {
59   - Map data = new LinkedHashMap();
60   - String app_access_key = params.getString("app_access_key");
61   - String video_type = params.getString("video_type");
62   - String user_access_key = params.getString("user_access_key");
63   - String server_access_key = params.getString("server_access_key");
64   - String active_id = params.getString("active_id");
65   - String title = params.getString("title");
66   - String direct = params.getString("direct");
67   - String description = params.getString("description");
68   - String custom_args = params.getString("custom_args");
69   - String md5 = params.getString("md5");
70   - String relation_id = params.getString("relation_id");
71   - String uuid = "";
72   - if (video_type.equals("2")) {
73   - // 2:sdk上传录播文件
74   - TVideo tVideo = new TVideo();
75   - tVideo.setCustom_args(custom_args);
76   - tVideo.setRelation_id(relation_id);
77   - tVideo.setName(params.getString("name"));
78   - tVideo.setVideo_type(params.getString("video_type"));
79   - tVideo.setPlat(params.getString("plat"));
80   - tVideo.setState(207);
81   - tVideo.setMd5(md5);
82   - uuid = CnliveUtil.getUUID();
83   - tVideo.setVideo_uuid(uuid);
84   - tVideo.setTitle(title);
85   - tVideo.setDescription(description);
86   - tVideoService.saveSdkVideo(tVideo, server_access_key, user_access_key, app_access_key);
87   - } else if (video_type.equals("3")) {
88   - TLive tLive = tLiveService.getTLiveByUUId(active_id);
89   - tLive.setT_status_id(1);
90   - tLive.setTitle(title);
91   - tLive.setDescription(description);
92   - tLive.setStart_time(new Date());
93   - tLive.setUser_uuid(params.getString("name"));
94   - tLive.setRelation_id(relation_id);
95   - tLive.setCustom_args(custom_args);
96   - uuid = tLive.getUuid();
97   - if (StringUtils.isEmpty(direct)) {
98   - tLive.setDirect(0);
99   - } else {
100   - tLive.setDirect(Integer.parseInt(direct));
101   - }
102   - // tLive.setLive_url("http://cnlive.hlslive.ks-cdn.com/live/" +
103   - // tLive.getT_user_id() + "_" + uuid
104   - // + "/index.m3u8");
105   - tLive.setLive_url("rtmp://cnlive.rtmplive.ks-cdn.com/live/" + tLive.getT_user_id() + "_" + uuid);
106   - tLiveService.startLive(tLive);
107   - }
108   - data.put("video_uuid", uuid);
109   - ApiBean apiBean = new ApiBean();
110   - apiBean.setCode(100);
111   - apiBean.setMessage("请求成功");
112   - apiBean.setData(data);
113   - return apiBean;
114   - }
115   -
116   - @Request.Post("/api/video/all")
117   - public ApiBean all(Params params) {
118   - String app_access_key = params.getString("app_access_key");
119   - String relationId = params.getString("relation_id");
120   - String pageNo = params.getString("page_no");
121   - String relation_id = params.getString("relation_id");
122   - String upload_type = params.getString("upload_type");
123   - // String video_type = params.getString("video_type");
124   - Pager<TVideo> page = tVideoService.findAll(app_access_key, relationId, pageNo);
125   - ApiBean apiBean = new ApiBean();
126   - apiBean.setCode(100);
127   - apiBean.setMessage("请求成功");
128   - apiBean.setData(page);
129   - return apiBean;
130   - }
131   -
132   - @Request.Get("/video/list/{page_number}")
133   - public View list(int page_number) {
134   - int user_id = CastUtil.castInt(DataContext.getRequest().getSession().getAttribute(LiveUtils.SESSION_KEY_ID));
135   - Pager<TVideo> page = tVideoService.list(user_id, page_number, 33);
136   - return new View("live/video_management.jsp").data("videos", page);
137   - }
138   -
139   - @Request.Get("/video/check/{page_number}")
140   - public View check(int page_number) {
141   - Pager<TVideo> page = tVideoService.list(page_number, 33);
142   - return new View("live/video_management.jsp").data("videos", page);
143   - }
144   -
145   - @Request.Get("/video/pass/{id}")
146   - public Result pass(int id) {
147   - tVideoService.pass(id);
148   - return new Result(true);
149   - }
150   -
151   - @Request.Get("/video/view/{id}")
152   - public View view(int id) {
153   - TVideo tVideo = tVideoService.getVideoById(id);
154   - return new View("live/video_view.jsp").data("tVideo", tVideo);
155   - }
156   -
157   - @Request.Post("/api/video/one")
158   - public ApiBean one(Params params) {
159   - String app_access_key = params.getString("app_access_key");
160   - String video_uuid = params.getString("video_uuid");
161   - TVideo page = tVideoService.getVideoByUuId(video_uuid);
162   - ApiBean apiBean = new ApiBean();
163   - apiBean.setCode(100);
164   - apiBean.setMessage("请求成功");
165   - apiBean.setData(page);
166   - return apiBean;
167   - }
168   -
169   - @Request.Post("/api/video/uploadNotify")
170   - public ApiBean uploadNotify(Params params) {
171   - String video_uuid = params.getString("video_uuid");
172   - String upload_type = params.getString("upload_type");
173   - String video_type = params.getString("video_type");
174   - String state = params.getString("state");
175   - if (video_type.equals("2")) {
176   - // 点播通知
177   - tVideoService.notify(video_uuid);
178   - } else if (video_type.equals("3")) {
179   - // 直播通知
180   - tLiveService.notify(video_uuid);
181   - }
182   - ApiBean apiBean = new ApiBean();
183   - apiBean.setCode(100);
184   - apiBean.setMessage("请求成功");
185   - return apiBean;
186   - }
187   -
188   - @Request.Get("/api/video/error/{video_uuid}")
189   - public ApiBean beat(String video_uuid) {
190   - // 直播通知
191   - tLiveService.notify(video_uuid);
192   - ApiBean apiBean = new ApiBean();
193   - apiBean.setCode(100);
194   - apiBean.setMessage("请求成功");
195   - return apiBean;
196   - }
197   -
198   - @Request.Post("/api/video/delete")
199   - public ApiBean delete(Params params) {
200   - String user_access_key = params.getString("user_access_key");
201   - String video_uuid = params.getString("video_uuid");
202   - String app_access_key = params.getString("app_access_key");
203   - String video_type = params.getString("video_type");// 视频类型
204   - tVideoService.delete(video_uuid);
205   - ApiBean apiBean = new ApiBean();
206   - apiBean.setCode(100);
207   - apiBean.setMessage("请求成功");
208   - return apiBean;
209   - }
210   -}
  1 +package com.cnlive.mz.live.action;
  2 +
  3 +import java.util.Date;
  4 +import java.util.LinkedHashMap;
  5 +import java.util.Map;
  6 +
  7 +import org.apache.commons.lang3.StringUtils;
  8 +import org.smart4j.framework.dao.bean.Pager;
  9 +import org.smart4j.framework.ioc.annotation.Inject;
  10 +import org.smart4j.framework.mvc.DataContext;
  11 +import org.smart4j.framework.mvc.annotation.Action;
  12 +import org.smart4j.framework.mvc.annotation.Request;
  13 +import org.smart4j.framework.mvc.bean.ApiBean;
  14 +import org.smart4j.framework.mvc.bean.Params;
  15 +import org.smart4j.framework.mvc.bean.Result;
  16 +import org.smart4j.framework.mvc.bean.View;
  17 +import org.smart4j.framework.util.CastUtil;
  18 +
  19 +import com.cnlive.mz.commons.CnliveUtil;
  20 +import com.cnlive.mz.live.common.LiveUtils;
  21 +import com.cnlive.mz.live.entity.TLive;
  22 +import com.cnlive.mz.live.entity.TVideo;
  23 +import com.cnlive.mz.live.service.TDispatchServerService;
  24 +import com.cnlive.mz.live.service.TLiveService;
  25 +import com.cnlive.mz.live.service.TUserService;
  26 +import com.cnlive.mz.live.service.TVideoService;
  27 +
  28 +@Action
  29 +public class VideoAction {
  30 + @Inject
  31 + private TDispatchServerService tDispatchServerService;
  32 + @Inject
  33 + private TVideoService tVideoService;
  34 + @Inject
  35 + private TUserService tUserService;
  36 + @Inject
  37 + private TLiveService tLiveService;
  38 +
  39 + /**
  40 + * 服务器定向
  41 + *
  42 + * @param params
  43 + * @return
  44 + * {"mediaComment":"","nickName":"阳Sir","appId":"1","mediaName":"","userId"
  45 + * :"1167015","uuid":
  46 + * "1167015_1463725085798_6a551f9122494a05ac8566b7a2ae1092"}
  47 + */
  48 + @Request.Post("/api/video/redirect")
  49 + public ApiBean redirect(Params params) {
  50 + String app_access_key = params.getString("app_access_key");
  51 + String video_type = params.getString("video_type");
  52 + String user_id = params.getString("relation_id");
  53 + ApiBean apiBean = tDispatchServerService.redirect(video_type, app_access_key, user_id);
  54 + return apiBean;
  55 + }
  56 +
  57 + @Request.Post("/api/video/supload")
  58 + public ApiBean supload(Params params) {
  59 + Map data = new LinkedHashMap();
  60 + String app_access_key = params.getString("app_access_key");
  61 + String video_type = params.getString("video_type");
  62 + String user_access_key = params.getString("user_access_key");
  63 + String server_access_key = params.getString("server_access_key");
  64 + String active_id = params.getString("active_id");
  65 + String title = params.getString("title");
  66 + String direct = params.getString("direct");
  67 + String description = params.getString("description");
  68 + String custom_args = params.getString("custom_args");
  69 + String md5 = params.getString("md5");
  70 + String relation_id = params.getString("relation_id");
  71 + String uuid = "";
  72 + if (video_type.equals("2")) {
  73 + // 2:sdk上传录播文件
  74 + TVideo tVideo = new TVideo();
  75 + tVideo.setCustom_args(custom_args);
  76 + tVideo.setRelation_id(relation_id);
  77 + tVideo.setName(params.getString("name"));
  78 + tVideo.setVideo_type(params.getString("video_type"));
  79 + tVideo.setPlat(params.getString("plat"));
  80 + tVideo.setState(207);
  81 + tVideo.setMd5(md5);
  82 + uuid = CnliveUtil.getUUID();
  83 + tVideo.setVideo_uuid(uuid);
  84 + tVideo.setTitle(title);
  85 + tVideo.setDescription(description);
  86 + tVideoService.saveSdkVideo(tVideo, server_access_key, user_access_key, app_access_key);
  87 + } else if (video_type.equals("3")) {
  88 + TLive tLive = tLiveService.getTLiveByUUId(active_id);
  89 + tLive.setT_status_id(1);
  90 + tLive.setTitle(title);
  91 + tLive.setDescription(description);
  92 + tLive.setStart_time(new Date());
  93 + tLive.setUser_uuid(params.getString("name"));
  94 + tLive.setRelation_id(relation_id);
  95 + tLive.setCustom_args(custom_args);
  96 + uuid = tLive.getUuid();
  97 + if (StringUtils.isEmpty(direct)) {
  98 + tLive.setDirect(0);
  99 + } else {
  100 + tLive.setDirect(Integer.parseInt(direct));
  101 + }
  102 + // tLive.setLive_url("http://cnlive.hlslive.ks-cdn.com/live/" +
  103 + // tLive.getT_user_id() + "_" + uuid
  104 + // + "/index.m3u8");
  105 + tLive.setLive_url("rtmp://cnlive.rtmplive.ks-cdn.com/live/" + tLive.getT_user_id() + "_" + uuid);
  106 + tLiveService.startLive(tLive);
  107 + }
  108 + data.put("video_uuid", uuid);
  109 + ApiBean apiBean = new ApiBean();
  110 + apiBean.setCode(100);
  111 + apiBean.setMessage("请求成功");
  112 + apiBean.setData(data);
  113 + return apiBean;
  114 + }
  115 +
  116 + @Request.Post("/api/video/all")
  117 + public ApiBean all(Params params) {
  118 + String app_access_key = params.getString("app_access_key");
  119 + String relationId = params.getString("relation_id");
  120 + String pageNo = params.getString("page_no");
  121 + String relation_id = params.getString("relation_id");
  122 + String upload_type = params.getString("upload_type");
  123 + // String video_type = params.getString("video_type");
  124 + Pager<TVideo> page = tVideoService.findAll(app_access_key, relationId, pageNo);
  125 + ApiBean apiBean = new ApiBean();
  126 + apiBean.setCode(100);
  127 + apiBean.setMessage("请求成功");
  128 + apiBean.setData(page);
  129 + return apiBean;
  130 + }
  131 +
  132 + @Request.Get("/video/list/{page_number}")
  133 + public View list(int page_number) {
  134 + int user_id = CastUtil.castInt(DataContext.getRequest().getSession().getAttribute(LiveUtils.SESSION_KEY_ID));
  135 + Pager<TVideo> page = tVideoService.list(user_id, page_number, 33);
  136 + return new View("live/video_management.jsp").data("videos", page);
  137 + }
  138 +
  139 + @Request.Get("/video/check/{page_number}")
  140 + public View check(int page_number) {
  141 + Pager<TVideo> page = tVideoService.list(page_number, 33);
  142 + return new View("live/video_management.jsp").data("videos", page);
  143 + }
  144 +
  145 + @Request.Get("/video/pass/{id}")
  146 + public Result pass(int id) {
  147 + tVideoService.pass(id);
  148 + return new Result(true);
  149 + }
  150 +
  151 + @Request.Get("/video/view/{id}")
  152 + public View view(int id) {
  153 + TVideo tVideo = tVideoService.getVideoById(id);
  154 + return new View("live/video_view.jsp").data("tVideo", tVideo);
  155 + }
  156 +
  157 + @Request.Post("/api/video/one")
  158 + public ApiBean one(Params params) {
  159 + String app_access_key = params.getString("app_access_key");
  160 + String video_uuid = params.getString("video_uuid");
  161 + TVideo page = tVideoService.getVideoByUuId(video_uuid);
  162 + ApiBean apiBean = new ApiBean();
  163 + apiBean.setCode(100);
  164 + apiBean.setMessage("请求成功");
  165 + apiBean.setData(page);
  166 + return apiBean;
  167 + }
  168 +
  169 + @Request.Post("/api/video/uploadNotify")
  170 + public ApiBean uploadNotify(Params params) {
  171 + String video_uuid = params.getString("video_uuid");
  172 + String upload_type = params.getString("upload_type");
  173 + String video_type = params.getString("video_type");
  174 + String state = params.getString("state");
  175 + if (video_type.equals("2")) {
  176 + // 点播通知
  177 + tVideoService.notify(video_uuid);
  178 + } else if (video_type.equals("3")) {
  179 + // 直播通知
  180 + tLiveService.notify(video_uuid);
  181 + }
  182 + ApiBean apiBean = new ApiBean();
  183 + apiBean.setCode(100);
  184 + apiBean.setMessage("请求成功");
  185 + return apiBean;
  186 + }
  187 +
  188 + @Request.Get("/api/video/error/{video_uuid}")
  189 + public ApiBean beat(String video_uuid) {
  190 + // 直播通知
  191 + tLiveService.notify(video_uuid);
  192 + ApiBean apiBean = new ApiBean();
  193 + apiBean.setCode(100);
  194 + apiBean.setMessage("请求成功");
  195 + return apiBean;
  196 + }
  197 +
  198 + @Request.Post("/api/video/delete")
  199 + public ApiBean delete(Params params) {
  200 + String user_access_key = params.getString("user_access_key");
  201 + String video_uuid = params.getString("video_uuid");
  202 + String app_access_key = params.getString("app_access_key");
  203 + String video_type = params.getString("video_type");// 视频类型
  204 + tVideoService.delete(video_uuid);
  205 + ApiBean apiBean = new ApiBean();
  206 + apiBean.setCode(100);
  207 + apiBean.setMessage("请求成功");
  208 + return apiBean;
  209 + }
  210 +}
... ...
src/main/java/com/cnlive/mz/live/rest/BaseUtil.java
1   -package com.cnlive.mz.live.rest;
2   -
3   -import java.io.BufferedReader;
4   -import java.io.IOException;
5   -import java.io.InputStreamReader;
6   -import java.io.PrintWriter;
7   -import java.io.UnsupportedEncodingException;
8   -import java.net.URL;
9   -import java.net.URLConnection;
10   -import java.security.MessageDigest;
11   -import java.text.DateFormat;
12   -import java.text.ParseException;
13   -import java.text.SimpleDateFormat;
14   -import java.util.Calendar;
15   -import java.util.Date;
16   -import java.util.Locale;
17   -import java.util.UUID;
18   -
19   -import javax.crypto.Mac;
20   -import javax.crypto.spec.SecretKeySpec;
21   -
22   -import org.apache.commons.codec.binary.Base64;
23   -
24   -import sun.misc.BASE64Encoder;
25   -
26   -public class BaseUtil {
27   -
28   - private static final String ENCODING = "UTF-8";
29   - private static final String AK_SECRET = "7SxVU5lFpqCEQIqxLprQat9BWoyZNKlKfSScTuIk";
30   - private static final String AK_ID = "I3TC8a4xboPUMe5xlp22";
31   -
32   - /*
33   - * 计算MD5+BASE64
34   - */
35   - public static String MD5Base64(String s) {
36   - if (s == null)
37   - return null;
38   - String encodeStr = "";
39   - byte[] utfBytes = s.getBytes();
40   - MessageDigest mdTemp;
41   - try {
42   - mdTemp = MessageDigest.getInstance("MD5");
43   - mdTemp.update(utfBytes);
44   - byte[] md5Bytes = mdTemp.digest();
45   - BASE64Encoder b64Encoder = new BASE64Encoder();
46   - encodeStr = b64Encoder.encode(md5Bytes);
47   - } catch (Exception e) {
48   - throw new Error("Failed to generate MD5 : " + e.getMessage());
49   - }
50   - return encodeStr;
51   - }
52   -
53   - /*
54   - * 哈希计算 HMAC-SHA1 base64
55   - */
56   - public static String HMACSha1(String data, String key) {
57   - String result;
58   - try {
59   - SecretKeySpec signingKey = new SecretKeySpec(key.getBytes(), "HmacSHA1");
60   - Mac mac = Mac.getInstance("HmacSHA1");
61   - mac.init(signingKey);
62   - byte[] rawHmac = mac.doFinal(data.getBytes());
63   - //result = new String(Base64.encodeBase64(rawHmac, false), ENCODING);
64   - //result = (new BASE64Encoder()).encode(rawHmac);
65   - result = new String(Base64.encodeBase64(rawHmac),ENCODING);
66   - } catch (Exception e) {
67   - throw new Error("Failed to generate HMAC : " + e.getMessage());
68   - }
69   - return result;
70   - }
71   -
72   - /**
73   - * 获取当前时间戳
74   - * @return
75   - */
76   - public static String getTimestamp(){
77   - DateFormat df = new SimpleDateFormat("yyyyMMdd");
78   - Date date = null;
79   - try {
80   - date = df.parse("20160607");
81   - } catch (ParseException e) {
82   - e.printStackTrace();
83   - }
84   - Calendar cal = Calendar.getInstance();
85   - cal.setTime(date);
86   - long timestamp = cal.getTimeInMillis();
87   - Calendar calendar = Calendar.getInstance();
88   - calendar.add(Calendar.DATE,+1);
89   - SimpleDateFormat sdf = new SimpleDateFormat("MMddHHmmss");
90   - String motoday = sdf.format(calendar.getTime());
91   - //Timestamp ts = new Timestamp(System.currentTimeMillis());
92   - long currentTime=Calendar.getInstance().getTimeInMillis();
93   - // System.out.println(ts+"---..ts..----");
94   - // Date date = new Date();
95   - // SimpleDateFormat sd = new SimpleDateFormat("MMddHHmmss");
96   - // String ss = sd.format(date);
97   - return String.valueOf(timestamp);
98   - //return motoday;
99   - }
100   - /**
101   - * 签名算法:signature 字符串格式,由三部分组成:GET+”\n”+Expire+”\n”+Resource
102   - * 2016 0602171212
103   - * @return
104   - * @throws UnsupportedEncodingException
105   - */
106   - public static String signature(String streamName) throws UnsupportedEncodingException {
107   -
108   - String method = "GET";
109   - String Expire = String.valueOf(BaseUtil.getTimestamp()).substring(0, 10);
110   - System.out.println(Expire+"---expire----");
111   - String Resource = "app=live&method=add&nonce=cnlive&public=0&vdoid=12345&stream="+streamName;
112   - Resource = java.net.URLEncoder.encode(Resource,"utf-8");
113   - String stringToSign = method + "\n" + Expire + "\n" + Resource;
114   - // 2.计算 HMAC-SHA1
115   - String signature = HMACSha1(stringToSign, AK_SECRET);
116   - System.out.println(signature+"------");
117   - signature =java.net.URLEncoder.encode(signature,"utf-8");
118   - return signature;
119   - }
120   -
121   - public static String UUid() {
122   - String uuid = UUID.randomUUID().toString();
123   - uuid = uuid.replaceAll("-", "");
124   - return uuid;
125   - }
126   -
127   - public static int random_7(int number) {
128   - int x = (int) (Math.random() * 10);
129   - for (int i = 0; i < number; i++) {
130   - String num = Math.random() * 10 + "";
131   - }
132   - return x;
133   - }
134   -
135   - /*
136   - * 等同于javaScript中的 new Date().toUTCString();
137   - */
138   - public static String toGMTString(Date date) {
139   - SimpleDateFormat df = new SimpleDateFormat("E, dd MMM yyyy HH:mm:ss z", Locale.UK);
140   - df.setTimeZone(new java.util.SimpleTimeZone(0, "GMT"));
141   - return df.format(date);
142   - }
143   -
144   - /*
145   - * 发送POST请求
146   - */
147   - public static String sendPost(String url, String body, String ak_id, String ak_secret) {
148   - PrintWriter out = null;
149   - BufferedReader in = null;
150   - String result = "";
151   - try {
152   - URL realUrl = new URL(url);
153   -
154   - /*
155   - * http header 参数
156   - */
157   - String method = "POST";
158   - String accept = "json";
159   - String content_type = "application/json";
160   - String path = realUrl.getFile();
161   - String date = toGMTString(new Date());
162   -
163   - // 1.对body做MD5+BASE64加密
164   - String bodyMd5 = MD5Base64(body);
165   - String stringToSign = method + "\n" + accept + "\n" + bodyMd5 + "\n" + content_type + "\n" + date + "\n"
166   - + path;
167   - // 2.计算 HMAC-SHA1
168   - String signature = HMACSha1(stringToSign, ak_secret);
169   - // 3.得到 authorization header
170   - String authHeader = "Dataplus " + ak_id + ":" + signature;
171   -
172   - // 打开和URL之间的连接
173   - URLConnection conn = realUrl.openConnection();
174   - // 设置通用的请求属性
175   - conn.setRequestProperty("accept", accept);
176   - conn.setRequestProperty("content-type", content_type);
177   - conn.setRequestProperty("date", date);
178   - conn.setRequestProperty("Authorization", authHeader);
179   - // 发送POST请求必须设置如下两行
180   - conn.setDoOutput(true);
181   - conn.setDoInput(true);
182   - // 获取URLConnection对象对应的输出流
183   - out = new PrintWriter(conn.getOutputStream());
184   - // 发送请求参数
185   - out.print(body);
186   - // flush输出流的缓冲
187   - out.flush();
188   - // 定义BufferedReader输入流来读取URL的响应
189   - in = new BufferedReader(new InputStreamReader(conn.getInputStream()));
190   - String line;
191   - while ((line = in.readLine()) != null) {
192   - result += line;
193   - }
194   - } catch (Exception e) {
195   - System.out.println("发送 POST 请求出现异常!" + e);
196   - e.printStackTrace();
197   - }
198   - // 使用finally块来关闭输出流、输入流
199   - finally {
200   - try {
201   - if (out != null) {
202   - out.close();
203   - }
204   - if (in != null) {
205   - in.close();
206   - }
207   - } catch (IOException ex) {
208   - ex.printStackTrace();
209   - }
210   - }
211   - return result;
212   - }
213   -
214   - /*
215   - * GET请求
216   - */
217   -
218   - public static String sendGet(String url, String ak_id, String ak_secret) {
219   - String result = "";
220   - BufferedReader in = null;
221   - try {
222   - URL realUrl = new URL(url);
223   - /*
224   - * http header 参数
225   - */
226   - String method = "GET";
227   - String Expire = "1436976000";
228   - String Resource = "nonce=4e1f2519c626cbfbab1520c255830c26&public=0&vdoid=12345";
229   - String content_type = "application/json";
230   - String path = realUrl.getFile();
231   - String date = toGMTString(new Date());
232   - // 1.对body做MD5+BASE64加密
233   - // String bodyMd5 = MD5Base64(body);
234   - String stringToSign = method + "\n" + Expire + "\n" + Resource;
235   - // 2.计算 HMAC-SHA1
236   - String signature = HMACSha1(stringToSign, ak_secret);
237   - // 3.得到 authorization header
238   - String authHeader = "Dataplus " + ak_id + ":" + signature;
239   - // 打开和URL之间的连接
240   - URLConnection connection = realUrl.openConnection();
241   - // 设置通用的请求属性
242   - connection.setRequestProperty("accept", "json");
243   - connection.setRequestProperty("content-type", content_type);
244   - connection.setRequestProperty("date", date);
245   - connection.setRequestProperty("Authorization", authHeader);
246   - // 建立实际的连接
247   - connection.connect();
248   - // 定义 BufferedReader输入流来读取URL的响应
249   - in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
250   - String line;
251   - while ((line = in.readLine()) != null) {
252   - result += line;
253   - }
254   - } catch (Exception e) {
255   - System.out.println("发送GET请求出现异常!" + e);
256   - e.printStackTrace();
257   - }
258   - // 使用finally块来关闭输入流
259   - finally {
260   - try {
261   - if (in != null) {
262   - in.close();
263   - }
264   - } catch (Exception e) {
265   - e.printStackTrace();
266   - }
267   - }
268   - return result;
269   - }
270   -
271   - public static void main(String[] args) throws Exception {
272   - // 发送POST请求示例
273   - /*
274   - * String ak_id = "fWUN8KDtJZJGo0ArQ4qo"; // 用户ak String ak_secret =
275   - * "UIWPYVeaV8kq2vWImDkLBvWs/pwmTJVF9MCNHDsC"; // 用户ak_secret String url
276   - * = "https://kmr-cn-beijing.ksyun.com"; String body =
277   - * "{\"param1\": \"GET\n1436976000\nnonce=4e1f2519c626cbfbab1520c255830c26&public=0&vdoid=12345\", \"param2\":\"fWUN8KDtJZJGo0ArQ4qo\"}"
278   - * ; System.out.println("response body:" + sendPost(url, body, AK_ID,
279   - * AK_SECRET));
280   - */
281   -
282   - Date date = new Date();
283   - System.out.println(toGMTString(date));
284   - String hh = HMACSha1("GET\n1436976124\nnonce=4e1f2519c626cbfbab1520c255830c26&public=1&vdoid=1",
285   - "fWUN8KDtJZJGo0ArQ4qo");
286   - String hhhh = MD5Base64(hh);
287   - System.out.println(hh);
288   - System.out.println("..............");
289   - //String str = signature();
290   - //System.out.println(str);//L2muBoImPzyvwyzfBtGXEu+wRNE=
291   - /*// 发送GET请求
292   - String ak_id1 = "fWUN8KDtJZJGo0ArQ4qo"; //用户ak
293   - String ak_secret1 = "UIWPYVeaV8kq2vWImDkLBvWs/pwmTJVF9MCNHDsC"; // 用户ak_secret
294   - String url1 = "http://cnlive.uplive.ks-cdn.com?signature=L2muBoImPzyvwyzfBtGXEu+wRNE=&accesskey=fWUN8KDtJZJGo0ArQ4qo&expire=1436976000&method=add&app=live&name=498122_57";
295   - System.out.println("response body:" +sendGet(url1, ak_id1, ak_secret1));*/
296   - //long d = getTimestamp();
297   - //System.out.println(d);
298   - }
299   -}
  1 +package com.cnlive.mz.live.rest;
  2 +
  3 +import java.io.BufferedReader;
  4 +import java.io.IOException;
  5 +import java.io.InputStreamReader;
  6 +import java.io.PrintWriter;
  7 +import java.io.UnsupportedEncodingException;
  8 +import java.net.URL;
  9 +import java.net.URLConnection;
  10 +import java.security.MessageDigest;
  11 +import java.text.DateFormat;
  12 +import java.text.ParseException;
  13 +import java.text.SimpleDateFormat;
  14 +import java.util.Calendar;
  15 +import java.util.Date;
  16 +import java.util.Locale;
  17 +import java.util.UUID;
  18 +
  19 +import javax.crypto.Mac;
  20 +import javax.crypto.spec.SecretKeySpec;
  21 +
  22 +import org.apache.commons.codec.binary.Base64;
  23 +
  24 +import com.cnlive.mz.commons.net.HttpReq;
  25 +
  26 +import sun.misc.BASE64Encoder;
  27 +
  28 +public class BaseUtil {
  29 +
  30 + private static final String ENCODING = "UTF-8";
  31 +
  32 + // AccessKey、SecretKey
  33 + private static final String SECRET_KEY = "iqljE4WxQaSMeSd1QP+PPYSpvtK0uWyH0/r6tgi7";
  34 + private static final String ACCESS_KEY = "I3TC8a4xboN9kSJnUIQh";
  35 +
  36 +
  37 + /*
  38 + * 计算MD5+BASE64
  39 + */
  40 + public static String MD5Base64(String s) {
  41 + if (s == null)
  42 + return null;
  43 + String encodeStr = "";
  44 + byte[] utfBytes = s.getBytes();
  45 + MessageDigest mdTemp;
  46 + try {
  47 + mdTemp = MessageDigest.getInstance("MD5");
  48 + mdTemp.update(utfBytes);
  49 + byte[] md5Bytes = mdTemp.digest();
  50 + BASE64Encoder b64Encoder = new BASE64Encoder();
  51 + encodeStr = b64Encoder.encode(md5Bytes);
  52 + } catch (Exception e) {
  53 + throw new Error("Failed to generate MD5 : " + e.getMessage());
  54 + }
  55 + return encodeStr;
  56 + }
  57 +
  58 + /*
  59 + * 哈希计算 HMAC-SHA1 base64
  60 + */
  61 + public static String HMACSha1(String data, String key) {
  62 + String result;
  63 + try {
  64 + SecretKeySpec signingKey = new SecretKeySpec(key.getBytes(), "HmacSHA1");
  65 + Mac mac = Mac.getInstance("HmacSHA1");
  66 + mac.init(signingKey);
  67 + byte[] rawHmac = mac.doFinal(data.getBytes());
  68 + //result = new String(Base64.encodeBase64(rawHmac, false), ENCODING);
  69 + //result = (new BASE64Encoder()).encode(rawHmac);
  70 + result = new String(Base64.encodeBase64(rawHmac),ENCODING);
  71 + } catch (Exception e) {
  72 + throw new Error("Failed to generate HMAC : " + e.getMessage());
  73 + }
  74 + return result;
  75 + }
  76 +
  77 + /**
  78 + * 获取当前时间戳
  79 + * @return
  80 + */
  81 + public static String getTimestamp(){
  82 + DateFormat df = new SimpleDateFormat("yyyyMMdd");
  83 + Date date = null;
  84 + try {
  85 + date = df.parse("20160607");
  86 + } catch (ParseException e) {
  87 + e.printStackTrace();
  88 + }
  89 + Calendar cal = Calendar.getInstance();
  90 + cal.setTime(date);
  91 + long timestamp = cal.getTimeInMillis();
  92 + System.out.println("------timestamp-----"+timestamp);
  93 + //return String.valueOf(timestamp).substring(0, 10);
  94 + Calendar calendar = Calendar.getInstance();
  95 + calendar.add(Calendar.DATE,+1);
  96 + SimpleDateFormat sdf = new SimpleDateFormat("MMddHHmmss");
  97 + String motoday = sdf.format(calendar.getTime());
  98 + //Timestamp ts = new Timestamp(System.currentTimeMillis());
  99 + long currentTime=Calendar.getInstance().getTimeInMillis();
  100 + // System.out.println(ts+"---..ts..----");
  101 + // Date date = new Date();
  102 + // SimpleDateFormat sd = new SimpleDateFormat("MMddHHmmss");
  103 + // String ss = sd.format(date);
  104 + return String.valueOf(timestamp);
  105 + //return motoday;
  106 +
  107 + }
  108 + /**
  109 + * 签名算法:signature 字符串格式,由三部分组成:GET+”\n”+Expire+”\n”+Resource
  110 + * 2016 0602171212
  111 + * @return
  112 + * @throws UnsupportedEncodingException
  113 + */
  114 + public static String signature(String streamName) throws UnsupportedEncodingException {
  115 +
  116 + String method = "GET";
  117 + String expire = BaseUtil.getTimestamp();
  118 + String app = "live";
  119 + String methodadd = "add";
  120 + String name = streamName;
  121 + app = java.net.URLEncoder.encode(app, "utf-8");
  122 + methodadd = java.net.URLEncoder.encode(methodadd, "utf-8");
  123 + name = java.net.URLEncoder.encode(name, "utf-8");
  124 + System.out.println(expire + "---expire----");
  125 + String Resource = "app="+app+"&method="+methodadd+"&name=" + name;
  126 + //Resource = java.net.URLEncoder.encode(Resource, "utf-8");
  127 + String stringToSign = method + "\n" + expire + "\n" + Resource;
  128 + System.out.println("--stringToSign--"+stringToSign);
  129 + // 2.计算 HMAC-SHA1
  130 + String signature = HMACSha1(stringToSign, SECRET_KEY);
  131 + System.out.println( "---signature---"+signature );
  132 + signature = java.net.URLEncoder.encode(signature, "utf-8");
  133 + return signature;
  134 + }
  135 + public static String signature(String methodNname,String streamName) throws UnsupportedEncodingException {
  136 +
  137 + String method = "GET";
  138 + String expire = BaseUtil.getTimestamp();
  139 + String app = "live";
  140 + //String methodadd = methodNname;
  141 + //String name = streamName;
  142 + app = java.net.URLEncoder.encode(app, "utf-8");
  143 + methodNname = java.net.URLEncoder.encode(methodNname, "utf-8");
  144 + streamName = java.net.URLEncoder.encode(streamName, "utf-8");
  145 + System.out.println(expire + "---expire----");
  146 + String Resource = "app="+app+"&method="+methodNname+"&name=" + streamName;
  147 + //Resource = java.net.URLEncoder.encode(Resource, "utf-8");
  148 + String stringToSign = method + "\n" + expire + "\n" + Resource;
  149 + System.out.println("--stringToSign--"+stringToSign);
  150 + // 2.计算 HMAC-SHA1
  151 + String signature = HMACSha1(stringToSign, SECRET_KEY);
  152 + System.out.println( "---signature---"+signature );
  153 + signature = java.net.URLEncoder.encode(signature, "utf-8");
  154 + return signature;
  155 + }
  156 +
  157 + public static String UUid() {
  158 +
  159 + String uuid = UUID.randomUUID().toString();
  160 + uuid = uuid.replaceAll("-", "");
  161 + return uuid;
  162 + }
  163 + public static String getAccessKey() {
  164 + return ACCESS_KEY;
  165 + }
  166 +
  167 + public static int random_7(int number) {
  168 + int x = (int) (Math.random() * 10);
  169 + for (int i = 0; i < number; i++) {
  170 + String num = Math.random() * 10 + "";
  171 + }
  172 + return x;
  173 + }
  174 +
  175 + /*
  176 + * 等同于javaScript中的 new Date().toUTCString();
  177 + */
  178 + public static String toGMTString(Date date) {
  179 + SimpleDateFormat df = new SimpleDateFormat("E, dd MMM yyyy HH:mm:ss z", Locale.UK);
  180 + df.setTimeZone(new java.util.SimpleTimeZone(0, "GMT"));
  181 + return df.format(date);
  182 + }
  183 +
  184 + /*
  185 + * 发送POST请求
  186 + */
  187 + public static String sendPost(String url, String body, String ak_id, String ak_secret) {
  188 + PrintWriter out = null;
  189 + BufferedReader in = null;
  190 + String result = "";
  191 + try {
  192 + URL realUrl = new URL(url);
  193 +
  194 + /*
  195 + * http header 参数
  196 + */
  197 + String method = "POST";
  198 + String accept = "json";
  199 + String content_type = "application/json";
  200 + String path = realUrl.getFile();
  201 + String date = toGMTString(new Date());
  202 +
  203 + // 1.对body做MD5+BASE64加密
  204 + String bodyMd5 = MD5Base64(body);
  205 + String stringToSign = method + "\n" + accept + "\n" + bodyMd5 + "\n" + content_type + "\n" + date + "\n"
  206 + + path;
  207 + // 2.计算 HMAC-SHA1
  208 + String signature = HMACSha1(stringToSign, ak_secret);
  209 + // 3.得到 authorization header
  210 + String authHeader = "Dataplus " + ak_id + ":" + signature;
  211 +
  212 + // 打开和URL之间的连接
  213 + URLConnection conn = realUrl.openConnection();
  214 + // 设置通用的请求属性
  215 + conn.setRequestProperty("accept", accept);
  216 + conn.setRequestProperty("content-type", content_type);
  217 + conn.setRequestProperty("date", date);
  218 + conn.setRequestProperty("Authorization", authHeader);
  219 + // 发送POST请求必须设置如下两行
  220 + conn.setDoOutput(true);
  221 + conn.setDoInput(true);
  222 + // 获取URLConnection对象对应的输出流
  223 + out = new PrintWriter(conn.getOutputStream());
  224 + // 发送请求参数
  225 + out.print(body);
  226 + // flush输出流的缓冲
  227 + out.flush();
  228 + // 定义BufferedReader输入流来读取URL的响应
  229 + in = new BufferedReader(new InputStreamReader(conn.getInputStream()));
  230 + String line;
  231 + while ((line = in.readLine()) != null) {
  232 + result += line;
  233 + }
  234 + } catch (Exception e) {
  235 + System.out.println("发送 POST 请求出现异常!" + e);
  236 + e.printStackTrace();
  237 + }
  238 + // 使用finally块来关闭输出流、输入流
  239 + finally {
  240 + try {
  241 + if (out != null) {
  242 + out.close();
  243 + }
  244 + if (in != null) {
  245 + in.close();
  246 + }
  247 + } catch (IOException ex) {
  248 + ex.printStackTrace();
  249 + }
  250 + }
  251 + return result;
  252 + }
  253 +
  254 + /*
  255 + * GET请求
  256 + */
  257 +
  258 + public static String sendGet(String url, String ak_id, String ak_secret) {
  259 + String result = "";
  260 + BufferedReader in = null;
  261 + try {
  262 + URL realUrl = new URL(url);
  263 + /*
  264 + * http header 参数
  265 + */
  266 +// String method = "GET";
  267 +// String Expire = "1436976000";
  268 +// String Resource = "nonce=4e1f2519c626cbfbab1520c255830c26&public=0&vdoid=12345";
  269 +// String content_type = "application/json";
  270 +// String path = realUrl.getFile();
  271 +// String date = toGMTString(new Date());
  272 +// // 1.对body做MD5+BASE64加密
  273 +// // String bodyMd5 = MD5Base64(body);
  274 +// String stringToSign = method + "\n" + Expire + "\n" + Resource;
  275 +// // 2.计算 HMAC-SHA1
  276 +// String signature = HMACSha1(stringToSign, ak_secret);
  277 +// // 3.得到 authorization header
  278 +// String authHeader = "Dataplus " + ak_id + ":" + signature;
  279 + // 打开和URL之间的连接
  280 + URLConnection connection = realUrl.openConnection();
  281 + // 设置通用的请求属性
  282 +// connection.setRequestProperty("accept", "json");
  283 +// connection.setRequestProperty("content-type", content_type);
  284 +// connection.setRequestProperty("date", date);
  285 +// connection.setRequestProperty("Authorization", authHeader);
  286 + // 建立实际的连接
  287 + connection.connect();
  288 + // 定义 BufferedReader输入流来读取URL的响应
  289 + in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
  290 + String line;
  291 + while ((line = in.readLine()) != null) {
  292 + result += line;
  293 + }
  294 + } catch (Exception e) {
  295 + System.out.println("发送GET请求出现异常!" + e);
  296 + e.printStackTrace();
  297 + }
  298 + // 使用finally块来关闭输入流
  299 + finally {
  300 + try {
  301 + if (in != null) {
  302 + in.close();
  303 + }
  304 + } catch (Exception e) {
  305 + e.printStackTrace();
  306 + }
  307 + }
  308 + return result;
  309 + }
  310 +
  311 + public static void main(String[] args) throws Exception {
  312 + // 发送POST请求示例
  313 + /*
  314 + * String ak_id = "fWUN8KDtJZJGo0ArQ4qo"; // 用户ak String ak_secret =
  315 + * "UIWPYVeaV8kq2vWImDkLBvWs/pwmTJVF9MCNHDsC"; // 用户ak_secret String url
  316 + * = "https://kmr-cn-beijing.ksyun.com"; String body =
  317 + * "{\"param1\": \"GET\n1436976000\nnonce=4e1f2519c626cbfbab1520c255830c26&public=0&vdoid=12345\", \"param2\":\"fWUN8KDtJZJGo0ArQ4qo\"}"
  318 + * ; System.out.println("response body:" + sendPost(url, body, AK_ID,
  319 + * AK_SECRET));
  320 + */
  321 +
  322 + Date date = new Date();
  323 + System.out.println(toGMTString(date));
  324 + String hh = HMACSha1("GET\n1436976124\nnonce=4e1f2519c626cbfbab1520c255830c26&public=1&vdoid=1",
  325 + "fWUN8KDtJZJGo0ArQ4qo");
  326 + String hhhh = MD5Base64(hh);
  327 + System.out.println(hh);
  328 + System.out.println("..............");
  329 +
  330 + // String str = signature();
  331 + // System.out.println(str);//L2muBoImPzyvwyzfBtGXEu+wRNE=
  332 +
  333 + // 发送GET请求
  334 + String url1 = "http://cnlive.dashboard.ks-cdn.com/blacklist?signature=iDPKaesXXW3A26CScNyjpNkzxZs%3D&accesskey=I3TC8a4xboPUMe5xlp22&expire=1483200000&app=live&method=add&stream=310166_863";
  335 + System.out.println("response body:" +sendGet(url1, ACCESS_KEY, SECRET_KEY));
  336 +
  337 + // long d = getTimestamp();
  338 + // System.out.println(d);
  339 +
  340 + //String str = signature();
  341 + //System.out.println(str);//L2muBoImPzyvwyzfBtGXEu+wRNE=
  342 + /*// 发送GET请求
  343 + String ak_id1 = "fWUN8KDtJZJGo0ArQ4qo"; //用户ak
  344 + String ak_secret1 = "UIWPYVeaV8kq2vWImDkLBvWs/pwmTJVF9MCNHDsC"; // 用户ak_secret
  345 + String url1 = "http://cnlive.uplive.ks-cdn.com?signature=L2muBoImPzyvwyzfBtGXEu+wRNE=&accesskey=fWUN8KDtJZJGo0ArQ4qo&expire=1436976000&method=add&app=live&name=498122_57";
  346 + System.out.println("response body:" +sendGet(url1, ak_id1, ak_secret1));*/
  347 + //long d = getTimestamp();
  348 + //System.out.println(d);
  349 +
  350 + }
  351 +}
... ...
src/main/java/com/cnlive/mz/live/rest/BaseUtil.java.bak 0 → 100644
  1 +package com.cnlive.mz.live.rest;
  2 +
  3 +import java.io.BufferedReader;
  4 +import java.io.IOException;
  5 +import java.io.InputStreamReader;
  6 +import java.io.PrintWriter;
  7 +import java.io.UnsupportedEncodingException;
  8 +import java.net.URL;
  9 +import java.net.URLConnection;
  10 +import java.security.MessageDigest;
  11 +import java.text.DateFormat;
  12 +import java.text.ParseException;
  13 +import java.text.SimpleDateFormat;
  14 +import java.util.Calendar;
  15 +import java.util.Date;
  16 +import java.util.Locale;
  17 +import java.util.UUID;
  18 +
  19 +import javax.crypto.Mac;
  20 +import javax.crypto.spec.SecretKeySpec;
  21 +
  22 +import org.apache.commons.codec.binary.Base64;
  23 +
  24 +import com.cnlive.mz.commons.net.HttpReq;
  25 +
  26 +import sun.misc.BASE64Encoder;
  27 +
  28 +public class BaseUtil {
  29 +
  30 + private static final String ENCODING = "UTF-8";
  31 +<<<<<<< HEAD
  32 + // AccessKey、SecretKey
  33 + private static final String SECRET_KEY = "iqljE4WxQaSMeSd1QP+PPYSpvtK0uWyH0/r6tgi7";
  34 + private static final String ACCESS_KEY = "I3TC8a4xboN9kSJnUIQh";
  35 +=======
  36 + private static final String AK_SECRET = "7SxVU5lFpqCEQIqxLprQat9BWoyZNKlKfSScTuIk";
  37 + private static final String AK_ID = "I3TC8a4xboPUMe5xlp22";
  38 +>>>>>>> 180640a4e451ae2b82ae745eb6b1d1651dc5f17f
  39 +
  40 + /*
  41 + * 计算MD5+BASE64
  42 + */
  43 + public static String MD5Base64(String s) {
  44 + if (s == null)
  45 + return null;
  46 + String encodeStr = "";
  47 + byte[] utfBytes = s.getBytes();
  48 + MessageDigest mdTemp;
  49 + try {
  50 + mdTemp = MessageDigest.getInstance("MD5");
  51 + mdTemp.update(utfBytes);
  52 + byte[] md5Bytes = mdTemp.digest();
  53 + BASE64Encoder b64Encoder = new BASE64Encoder();
  54 + encodeStr = b64Encoder.encode(md5Bytes);
  55 + } catch (Exception e) {
  56 + throw new Error("Failed to generate MD5 : " + e.getMessage());
  57 + }
  58 + return encodeStr;
  59 + }
  60 +
  61 + /*
  62 + * 哈希计算 HMAC-SHA1 base64
  63 + */
  64 + public static String HMACSha1(String data, String key) {
  65 + String result;
  66 + try {
  67 + SecretKeySpec signingKey = new SecretKeySpec(key.getBytes(), "HmacSHA1");
  68 + Mac mac = Mac.getInstance("HmacSHA1");
  69 + mac.init(signingKey);
  70 + byte[] rawHmac = mac.doFinal(data.getBytes());
  71 + //result = new String(Base64.encodeBase64(rawHmac, false), ENCODING);
  72 + //result = (new BASE64Encoder()).encode(rawHmac);
  73 + result = new String(Base64.encodeBase64(rawHmac),ENCODING);
  74 + } catch (Exception e) {
  75 + throw new Error("Failed to generate HMAC : " + e.getMessage());
  76 + }
  77 + return result;
  78 + }
  79 +
  80 + /**
  81 + * 获取当前时间戳
  82 + * @return
  83 + */
  84 + public static String getTimestamp(){
  85 + DateFormat df = new SimpleDateFormat("yyyyMMdd");
  86 + Date date = null;
  87 + try {
  88 + date = df.parse("20160607");
  89 + } catch (ParseException e) {
  90 + e.printStackTrace();
  91 + }
  92 + Calendar cal = Calendar.getInstance();
  93 + cal.setTime(date);
  94 + long timestamp = cal.getTimeInMillis();
  95 +<<<<<<< HEAD
  96 + System.out.println("------timestamp-----"+timestamp);
  97 + //return String.valueOf(timestamp).substring(0, 10);
  98 + return "1483200000";
  99 +=======
  100 + Calendar calendar = Calendar.getInstance();
  101 + calendar.add(Calendar.DATE,+1);
  102 + SimpleDateFormat sdf = new SimpleDateFormat("MMddHHmmss");
  103 + String motoday = sdf.format(calendar.getTime());
  104 + //Timestamp ts = new Timestamp(System.currentTimeMillis());
  105 + long currentTime=Calendar.getInstance().getTimeInMillis();
  106 + // System.out.println(ts+"---..ts..----");
  107 + // Date date = new Date();
  108 + // SimpleDateFormat sd = new SimpleDateFormat("MMddHHmmss");
  109 + // String ss = sd.format(date);
  110 + return String.valueOf(timestamp);
  111 + //return motoday;
  112 +>>>>>>> 180640a4e451ae2b82ae745eb6b1d1651dc5f17f
  113 + }
  114 + /**
  115 + * 签名算法:signature 字符串格式,由三部分组成:GET+”\n”+Expire+”\n”+Resource
  116 + * 2016 0602171212
  117 + * @return
  118 + * @throws UnsupportedEncodingException
  119 + */
  120 + public static String signature(String streamName) throws UnsupportedEncodingException {
  121 +
  122 + String method = "GET";
  123 +<<<<<<< HEAD
  124 + String expire = BaseUtil.getTimestamp();
  125 + String app = "live";
  126 + String methodadd = "add";
  127 + String name = streamName;
  128 + app = java.net.URLEncoder.encode(app, "utf-8");
  129 + methodadd = java.net.URLEncoder.encode(methodadd, "utf-8");
  130 + name = java.net.URLEncoder.encode(name, "utf-8");
  131 + System.out.println(expire + "---expire----");
  132 + String Resource = "app="+app+"&method="+methodadd+"&name=" + name;
  133 + //Resource = java.net.URLEncoder.encode(Resource, "utf-8");
  134 + String stringToSign = method + "\n" + expire + "\n" + Resource;
  135 + System.out.println("--stringToSign--"+stringToSign);
  136 + // 2.计算 HMAC-SHA1
  137 + String signature = HMACSha1(stringToSign, SECRET_KEY);
  138 + System.out.println( "---signature---"+signature );
  139 + signature = java.net.URLEncoder.encode(signature, "utf-8");
  140 +=======
  141 + String Expire = String.valueOf(BaseUtil.getTimestamp()).substring(0, 10);
  142 + System.out.println(Expire+"---expire----");
  143 + String Resource = "app=live&method=add&nonce=cnlive&public=0&vdoid=12345&stream="+streamName;
  144 + Resource = java.net.URLEncoder.encode(Resource,"utf-8");
  145 + String stringToSign = method + "\n" + Expire + "\n" + Resource;
  146 + // 2.计算 HMAC-SHA1
  147 + String signature = HMACSha1(stringToSign, AK_SECRET);
  148 + System.out.println(signature+"------");
  149 + signature =java.net.URLEncoder.encode(signature,"utf-8");
  150 +>>>>>>> 180640a4e451ae2b82ae745eb6b1d1651dc5f17f
  151 + return signature;
  152 + }
  153 + public static String signature(String methodNname,String streamName) throws UnsupportedEncodingException {
  154 +
  155 +<<<<<<< HEAD
  156 + String method = "GET";
  157 + String expire = BaseUtil.getTimestamp();
  158 + String app = "live";
  159 + //String methodadd = methodNname;
  160 + //String name = streamName;
  161 + app = java.net.URLEncoder.encode(app, "utf-8");
  162 + methodNname = java.net.URLEncoder.encode(methodNname, "utf-8");
  163 + streamName = java.net.URLEncoder.encode(streamName, "utf-8");
  164 + System.out.println(expire + "---expire----");
  165 + String Resource = "app="+app+"&method="+methodNname+"&name=" + streamName;
  166 + //Resource = java.net.URLEncoder.encode(Resource, "utf-8");
  167 + String stringToSign = method + "\n" + expire + "\n" + Resource;
  168 + System.out.println("--stringToSign--"+stringToSign);
  169 + // 2.计算 HMAC-SHA1
  170 + String signature = HMACSha1(stringToSign, SECRET_KEY);
  171 + System.out.println( "---signature---"+signature );
  172 + signature = java.net.URLEncoder.encode(signature, "utf-8");
  173 + return signature;
  174 + }
  175 +
  176 + public static String getUUid() {
  177 +=======
  178 + public static String UUid() {
  179 +>>>>>>> 180640a4e451ae2b82ae745eb6b1d1651dc5f17f
  180 + String uuid = UUID.randomUUID().toString();
  181 + uuid = uuid.replaceAll("-", "");
  182 + return uuid;
  183 + }
  184 + public static String getAccessKey() {
  185 + return ACCESS_KEY;
  186 + }
  187 +
  188 + public static int random_7(int number) {
  189 + int x = (int) (Math.random() * 10);
  190 + for (int i = 0; i < number; i++) {
  191 + String num = Math.random() * 10 + "";
  192 + }
  193 + return x;
  194 + }
  195 +
  196 + /*
  197 + * 等同于javaScript中的 new Date().toUTCString();
  198 + */
  199 + public static String toGMTString(Date date) {
  200 + SimpleDateFormat df = new SimpleDateFormat("E, dd MMM yyyy HH:mm:ss z", Locale.UK);
  201 + df.setTimeZone(new java.util.SimpleTimeZone(0, "GMT"));
  202 + return df.format(date);
  203 + }
  204 +
  205 + /*
  206 + * 发送POST请求
  207 + */
  208 + public static String sendPost(String url, String body, String ak_id, String ak_secret) {
  209 + PrintWriter out = null;
  210 + BufferedReader in = null;
  211 + String result = "";
  212 + try {
  213 + URL realUrl = new URL(url);
  214 +
  215 + /*
  216 + * http header 参数
  217 + */
  218 + String method = "POST";
  219 + String accept = "json";
  220 + String content_type = "application/json";
  221 + String path = realUrl.getFile();
  222 + String date = toGMTString(new Date());
  223 +
  224 + // 1.对body做MD5+BASE64加密
  225 + String bodyMd5 = MD5Base64(body);
  226 + String stringToSign = method + "\n" + accept + "\n" + bodyMd5 + "\n" + content_type + "\n" + date + "\n"
  227 + + path;
  228 + // 2.计算 HMAC-SHA1
  229 + String signature = HMACSha1(stringToSign, ak_secret);
  230 + // 3.得到 authorization header
  231 + String authHeader = "Dataplus " + ak_id + ":" + signature;
  232 +
  233 + // 打开和URL之间的连接
  234 + URLConnection conn = realUrl.openConnection();
  235 + // 设置通用的请求属性
  236 + conn.setRequestProperty("accept", accept);
  237 + conn.setRequestProperty("content-type", content_type);
  238 + conn.setRequestProperty("date", date);
  239 + conn.setRequestProperty("Authorization", authHeader);
  240 + // 发送POST请求必须设置如下两行
  241 + conn.setDoOutput(true);
  242 + conn.setDoInput(true);
  243 + // 获取URLConnection对象对应的输出流
  244 + out = new PrintWriter(conn.getOutputStream());
  245 + // 发送请求参数
  246 + out.print(body);
  247 + // flush输出流的缓冲
  248 + out.flush();
  249 + // 定义BufferedReader输入流来读取URL的响应
  250 + in = new BufferedReader(new InputStreamReader(conn.getInputStream()));
  251 + String line;
  252 + while ((line = in.readLine()) != null) {
  253 + result += line;
  254 + }
  255 + } catch (Exception e) {
  256 + System.out.println("发送 POST 请求出现异常!" + e);
  257 + e.printStackTrace();
  258 + }
  259 + // 使用finally块来关闭输出流、输入流
  260 + finally {
  261 + try {
  262 + if (out != null) {
  263 + out.close();
  264 + }
  265 + if (in != null) {
  266 + in.close();
  267 + }
  268 + } catch (IOException ex) {
  269 + ex.printStackTrace();
  270 + }
  271 + }
  272 + return result;
  273 + }
  274 +
  275 + /*
  276 + * GET请求
  277 + */
  278 +
  279 + public static String sendGet(String url, String ak_id, String ak_secret) {
  280 + String result = "";
  281 + BufferedReader in = null;
  282 + try {
  283 + URL realUrl = new URL(url);
  284 + /*
  285 + * http header 参数
  286 + */
  287 +// String method = "GET";
  288 +// String Expire = "1436976000";
  289 +// String Resource = "nonce=4e1f2519c626cbfbab1520c255830c26&public=0&vdoid=12345";
  290 +// String content_type = "application/json";
  291 +// String path = realUrl.getFile();
  292 +// String date = toGMTString(new Date());
  293 +// // 1.对body做MD5+BASE64加密
  294 +// // String bodyMd5 = MD5Base64(body);
  295 +// String stringToSign = method + "\n" + Expire + "\n" + Resource;
  296 +// // 2.计算 HMAC-SHA1
  297 +// String signature = HMACSha1(stringToSign, ak_secret);
  298 +// // 3.得到 authorization header
  299 +// String authHeader = "Dataplus " + ak_id + ":" + signature;
  300 + // 打开和URL之间的连接
  301 + URLConnection connection = realUrl.openConnection();
  302 + // 设置通用的请求属性
  303 +// connection.setRequestProperty("accept", "json");
  304 +// connection.setRequestProperty("content-type", content_type);
  305 +// connection.setRequestProperty("date", date);
  306 +// connection.setRequestProperty("Authorization", authHeader);
  307 + // 建立实际的连接
  308 + connection.connect();
  309 + // 定义 BufferedReader输入流来读取URL的响应
  310 + in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
  311 + String line;
  312 + while ((line = in.readLine()) != null) {
  313 + result += line;
  314 + }
  315 + } catch (Exception e) {
  316 + System.out.println("发送GET请求出现异常!" + e);
  317 + e.printStackTrace();
  318 + }
  319 + // 使用finally块来关闭输入流
  320 + finally {
  321 + try {
  322 + if (in != null) {
  323 + in.close();
  324 + }
  325 + } catch (Exception e) {
  326 + e.printStackTrace();
  327 + }
  328 + }
  329 + return result;
  330 + }
  331 +
  332 + public static void main(String[] args) throws Exception {
  333 + // 发送POST请求示例
  334 + /*
  335 + * String ak_id = "fWUN8KDtJZJGo0ArQ4qo"; // 用户ak String ak_secret =
  336 + * "UIWPYVeaV8kq2vWImDkLBvWs/pwmTJVF9MCNHDsC"; // 用户ak_secret String url
  337 + * = "https://kmr-cn-beijing.ksyun.com"; String body =
  338 + * "{\"param1\": \"GET\n1436976000\nnonce=4e1f2519c626cbfbab1520c255830c26&public=0&vdoid=12345\", \"param2\":\"fWUN8KDtJZJGo0ArQ4qo\"}"
  339 + * ; System.out.println("response body:" + sendPost(url, body, AK_ID,
  340 + * AK_SECRET));
  341 + */
  342 +
  343 + Date date = new Date();
  344 + System.out.println(toGMTString(date));
  345 + String hh = HMACSha1("GET\n1436976124\nnonce=4e1f2519c626cbfbab1520c255830c26&public=1&vdoid=1",
  346 + "fWUN8KDtJZJGo0ArQ4qo");
  347 + String hhhh = MD5Base64(hh);
  348 + System.out.println(hh);
  349 + System.out.println("..............");
  350 +<<<<<<< HEAD
  351 + // String str = signature();
  352 + // System.out.println(str);//L2muBoImPzyvwyzfBtGXEu+wRNE=
  353 +
  354 + // 发送GET请求
  355 + String url1 = "http://cnlive.dashboard.ks-cdn.com/blacklist?signature=iDPKaesXXW3A26CScNyjpNkzxZs%3D&accesskey=I3TC8a4xboPUMe5xlp22&expire=1483200000&app=live&method=add&stream=310166_863";
  356 + System.out.println("response body:" +sendGet(url1, ACCESS_KEY, SECRET_KEY));
  357 +
  358 + // long d = getTimestamp();
  359 + // System.out.println(d);
  360 +=======
  361 + //String str = signature();
  362 + //System.out.println(str);//L2muBoImPzyvwyzfBtGXEu+wRNE=
  363 + /*// 发送GET请求
  364 + String ak_id1 = "fWUN8KDtJZJGo0ArQ4qo"; //用户ak
  365 + String ak_secret1 = "UIWPYVeaV8kq2vWImDkLBvWs/pwmTJVF9MCNHDsC"; // 用户ak_secret
  366 + String url1 = "http://cnlive.uplive.ks-cdn.com?signature=L2muBoImPzyvwyzfBtGXEu+wRNE=&accesskey=fWUN8KDtJZJGo0ArQ4qo&expire=1436976000&method=add&app=live&name=498122_57";
  367 + System.out.println("response body:" +sendGet(url1, ak_id1, ak_secret1));*/
  368 + //long d = getTimestamp();
  369 + //System.out.println(d);
  370 +>>>>>>> 180640a4e451ae2b82ae745eb6b1d1651dc5f17f
  371 + }
  372 +}
... ...
src/main/resources/logging.properties 0 → 100644
  1 +handlers = org.apache.juli.FileHandler, java.util.logging.ConsoleHandler
  2 +
  3 +############################################################
  4 +# Handler specific properties.
  5 +# Describes specific configuration info for Handlers.
  6 +############################################################
  7 +
  8 +org.apache.juli.FileHandler.level = FINE
  9 +org.apache.juli.FileHandler.directory = ${catalina.base}/logs
  10 +org.apache.juli.FileHandler.prefix = error-debug.
  11 +
  12 +java.util.logging.ConsoleHandler.level = FINE
  13 +java.util.logging.ConsoleHandler.formatter = java.util.logging.SimpleFormatter
0 14 \ No newline at end of file
... ...
src/main/webapp/crossdomain.xml
1   -<?xml version="1.0" encoding="utf-8"?>
2   -<cross-domain-policy>
3   - <allow-access-from domain="*"/>
  1 +<?xml version="1.0" encoding="utf-8"?>
  2 +<cross-domain-policy>
  3 + <allow-access-from domain="*"/>
4 4 </cross-domain-policy>
5 5 \ No newline at end of file
... ...
src/main/webapp/pages/check/check_management.jsp
... ... @@ -160,13 +160,14 @@ body {
160 160 <div id="a1_${item.id}" class="a1_class"
161 161 style="height: 150px">
162 162 <input type="hidden" value='${item.id}' name="liveid"
163   - id="liveid"> <input type="hidden"
164   - value='${item.title}' name="title" id="title"> <input
165   - type="hidden" value='${item.live_url}' name="live_url"
166   - id="live_url_${item.id}"> <input type="hidden"
167   - value='${item.start_time}' name="start_time"
168   - id="start_time"> <input type="hidden"
169   - value='${item.end_time}' name="end_time" id="end_time">
  163 + id="liveid">
  164 + <input type="hidden"value='${item.title}' name="title" id="title">
  165 + <input type="hidden" value='${item.live_url}' name="live_url"
  166 + id="live_url_${item.id}">
  167 + <input type="hidden"value='${item.start_time}' name="start_time"
  168 + id="start_time">
  169 + <input type="hidden"value='${item.end_time}' name="end_time" id="end_time">
  170 + <input type="hidden"value='${item.t_user_id}' name="t_user_id" id="t_user_${item.id}">
170 171 <%-- <h4 class="blue smaller">
171 172 <i class="icon-picture orange"></i>视频源 : ${item.title}
172 173 </h4> --%>
... ... @@ -209,7 +210,9 @@ body {
209 210  
210 211 $(".a1_class #liveid").each(function() {
211 212 var id = $(this).val();
212   - var live_url = $('#live_url_' + id).val();
  213 + var live_url = $('#live_url_' + id).val();
  214 + var t_user_id = $('#t_user_'+id).val();
  215 +
213 216 var flashvars = {
214 217 p : 1,
215 218 e : 1,
... ... @@ -218,29 +221,28 @@ body {
218 221 };
219 222 var video = [live_url ];
220 223 var support = [ 'all' ];
221   - CKobject.embedHTML5('a1_' + id, 'ckplayer_' + id,
222   - 250, 153, video, flashvars, support);
223   -
  224 + CKobject.embedHTML5('a1_' + id, 'ckplayer_' + id,250, 153, video, flashvars, support);
  225 +
224 226 //m3u8 文件播放
225   - /* var flashvars={
  227 + /* var flashvars={
226 228 f:'http://localhost:8080/cnlive_live_web/static/assets/ckplayer/m3u8.swf',
227   - a:'http://wideo01.cnlive.com/video/data1/2016/0524/124235/1500/b148a555a7984a539b56d7e17cb360f7_124235_1500.m3u8',
  229 + a:live_url,
228 230 s:4,
229 231 c:0,
230 232 p:1
231 233 };
232 234 var params={bgcolor:'#FFF',allowFullScreen:true,allowScriptAccess:'always',wmode:'transparent'};
233   - var video=['http://wideo01.cnlive.com/video/data1/2016/0524/124235/1500/b148a555a7984a539b56d7e17cb360f7_124235_1500.m3u8'];
234   - CKobject.embed('http://localhost:8080/cnlive_live_web/static/assets/ckplayer/ckplayer.swf', 'a1_' + id, 'ckplayer_' + id, 250, 153,false,flashvars,video,params); */
  235 + var video=[live_url];
  236 + CKobject.embed('http://localhost:8080/cnlive_live_web/static/assets/ckplayer/ckplayer.swf', 'a1_' + id, 'ckplayer_' + id, 250, 153,false,flashvars,video,params); */
235 237 // rtmp 直播流播放。
236   - /* var flashvars = {
  238 + /* var flashvars = {
237 239 // f:'rtmp://localhost/live/livestreame',
238   - f : 'rtmp://cnlive.uplive.ks-cdn.com/live/LIVEVJ154A34CF536',
  240 + f :'http://cnlive.uplive.ks-cdn.com/live/'+t_user_id+'_'+id,
239 241 c : 0
240 242 };
241   - var video = [ 'http://cnlive.hlslive.ks-cdn.com/live/LIVEVJ154A34CF536/index.m3u8'];
  243 + var video = [ 'http://cnlive.hlslive.ks-cdn.com/live/'+t_user_id+'_'+id+'/index.m3u8'];
242 244 CKobject.embed('../../static/assets/ckplayer/ckplayer.swf','a1_' + id, 'ckplayer_' + id, 250,
243   - 153, false, flashvars, video); */
  245 + 153, false, flashvars, video); */
244 246  
245 247 });
246 248  
... ...