From 535b780ad4330fca11e08f41728ca5f2f3fc4bce Mon Sep 17 00:00:00 2001
From: xc <xucheng@yyigou.com>
Date: Mon, 08 Feb 2021 15:28:14 +0800
Subject: [PATCH] Monica测试用例
---
src/main/java/com/hbbh/adapter/config/Swagger2Conf.java | 6
src/main/java/com/hbbh/adapter/manager/MonibucaManager.java | 2
src/main/java/com/hbbh/adapter/manager/impl/MonibucaManagerImpl.java | 6
src/main/java/com/hbbh/adapter/controller/api/MonibucaAPI.java | 2
src/main/resources/public/index.html | 290 +++++++++++++++++++++--------------------
src/main/java/com/hbbh/adapter/controller/MonibucaController.java | 4
README.md | 68 --------
7 files changed, 165 insertions(+), 213 deletions(-)
diff --git a/README.md b/README.md
index c88b518..7d42cb7 100644
--- a/README.md
+++ b/README.md
@@ -1,77 +1,21 @@
-# golden实时数据库适配程序
+# Monibuca监控处理程序
-**同步获取golden实时数据库的程序,技术选型:Springboot+JPA**
-**暂时不要使用,半成品**
+**通过使用http的方式调用Monica实例,处理视频流**
## V1.0
+#### 准备工作
+- 运行Monica实例机器IP
+
#### 已有功能
-- 同步所有表与标签信息的数据结构
-- 针对SMS,ktnz2c_plc,dlz_plc,djw_plc,bds_plc进行基本数据同步,每三十秒同步更新一次
+- 将rtsp流转换成 HLS,WebRTC,FLV.js,Jessibuca 并进行H5播放
#### 目前还存在的已知一些问题
-
-- 持久层操作冗余
-- 同步操作时间过长,需要优化
-- 介入数据只是基本数据,针对详细数据未完全介入进来
#### 环境介绍
-- golden数据库服务器 来自:47.92.145.232机器上
-- 同步环境 :开发环境MariaDB 的库名为:localgd上
-
-
-#### 标签点完整数据结构 (示例):
-```json
-{
- "basePoint": {
- "alarmindex": 0,
- "archive": true,
- "calcindex": 917504,
- "changedate": 1575520921000,
- "changer": "sa",
- "classof": "RTDB_CALC",
- "compdev": 1.0,
- "compdevpercent": 0.009999999776482582,
- "compress": true,
- "comptimemax": 28800,
- "comptimemin": 0,
- "createdate": 1574164482000,
- "creator": "sa",
- "desc": "1号空压机故障指示",
- "digits": -5,
- "excdev": 0.5,
- "excdevpercent": 0.004999999888241291,
- "exctimemax": 600,
- "exctimemin": 0,
- "highlimit": 100.0,
- "id": 9838,
- "lowlimit": 0.0,
- "microsecond": false,
- "mirror": false,
- "padding": "AAAAAAA=",
- "scanindex": 0,
- "shutdown": false,
- "step": false,
- "summary": false,
- "table": 11,
- "table_dot_tag": "SMS.SMS01_1号空压机故障指示",
- "tag": "SMS01_1号空压机故障指示",
- "type": "RTDB_BOOL",
- "typical": 50.0,
- "unit": ""
- },
- "calcPoint": {
- "equation": "if('DLZ_PLC.1号空压机故障指示'==1,1,0)",
- "id": 9838,
- "period": 65536,
- "timecopy": "RTDB_CALC_TIME"
- },
- "error": 0
-}
-```
#### 项目部署可能会涉及到Linux命令
diff --git a/src/main/java/com/hbbh/adapter/config/Swagger2Conf.java b/src/main/java/com/hbbh/adapter/config/Swagger2Conf.java
index 9fa609b..3886441 100644
--- a/src/main/java/com/hbbh/adapter/config/Swagger2Conf.java
+++ b/src/main/java/com/hbbh/adapter/config/Swagger2Conf.java
@@ -12,8 +12,8 @@
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;
-@Configuration
-@EnableSwagger2
+//@Configuration
+//@EnableSwagger2
public class Swagger2Conf extends WebMvcConfigurationSupport {
@Bean
@@ -41,7 +41,7 @@
registry.addResourceHandler("/**").addResourceLocations(
"classpath:/static/");
registry.addResourceHandler("swagger-ui.html").addResourceLocations(
- "classpath:/META-INF/resources/");
+ "classpath:/META-INF/resources/public/");
registry.addResourceHandler("/webjars/**").addResourceLocations(
"classpath:/META-INF/resources/webjars/");
super.addResourceHandlers(registry);
diff --git a/src/main/java/com/hbbh/adapter/controller/MonibucaController.java b/src/main/java/com/hbbh/adapter/controller/MonibucaController.java
index 98c4b26..df7dc40 100644
--- a/src/main/java/com/hbbh/adapter/controller/MonibucaController.java
+++ b/src/main/java/com/hbbh/adapter/controller/MonibucaController.java
@@ -27,9 +27,9 @@
@Override
@RequestMapping(value = "/test/video", method = RequestMethod.GET)
@ApiOperation("test")
- public CallResult<String> parseVideoRTSP() {
+ public String parseVideoRTSP() {
try {
- CallResult<String> result = monibucaManager.parseVideo();
+ String result = monibucaManager.parseVideo();
return result;
} catch (Exception e) {
log.error("接口:com.hbbh.adapter.controller.api.MonibucaAPIController.parseVideoRTSP 调用失败");
diff --git a/src/main/java/com/hbbh/adapter/controller/api/MonibucaAPI.java b/src/main/java/com/hbbh/adapter/controller/api/MonibucaAPI.java
index 7222d4d..0dd7e33 100644
--- a/src/main/java/com/hbbh/adapter/controller/api/MonibucaAPI.java
+++ b/src/main/java/com/hbbh/adapter/controller/api/MonibucaAPI.java
@@ -12,7 +12,7 @@
* @return
* -1 解析失败
*/
- public CallResult<String> parseVideoRTSP();
+ public String parseVideoRTSP();
/**
* @param param streamPath地址
diff --git a/src/main/java/com/hbbh/adapter/manager/MonibucaManager.java b/src/main/java/com/hbbh/adapter/manager/MonibucaManager.java
index 7efbc5a..427f4f8 100644
--- a/src/main/java/com/hbbh/adapter/manager/MonibucaManager.java
+++ b/src/main/java/com/hbbh/adapter/manager/MonibucaManager.java
@@ -20,5 +20,5 @@
* .flv 视频流格式
*
*/
- CallResult<String> parseVideo();
+ String parseVideo();
}
diff --git a/src/main/java/com/hbbh/adapter/manager/impl/MonibucaManagerImpl.java b/src/main/java/com/hbbh/adapter/manager/impl/MonibucaManagerImpl.java
index effc647..772e423 100644
--- a/src/main/java/com/hbbh/adapter/manager/impl/MonibucaManagerImpl.java
+++ b/src/main/java/com/hbbh/adapter/manager/impl/MonibucaManagerImpl.java
@@ -33,7 +33,7 @@
* @return jessibucaDemo
*/
@Override
- public CallResult<String> parseVideo() {
+ public String parseVideo() {
String url="http://localhost:8081/rtsp/pull";
Map<String, String> params = Maps.newLinkedHashMap();
params.put("target",rtspDemo);
@@ -46,8 +46,8 @@
String code = map.get("code")+"";
String msg = map.get("msg")+"";
if (!StringUtils.equals("0",code)){
- CallResult.success(msg,"-1");
+ return "-1";
}
- return CallResult.success(jessibucaDemo);
+ return jessibucaDemo;
}
}
diff --git a/src/main/resources/public/index.html b/src/main/resources/public/index.html
index 4c197fe..b002e56 100755
--- a/src/main/resources/public/index.html
+++ b/src/main/resources/public/index.html
@@ -2,9 +2,9 @@
<html>
<head>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>Jessibuca 1.0</title>
- <meta charset="utf-8" />
+ <meta charset="utf-8"/>
<style>
.btn {
display: inline-block;
@@ -74,168 +74,176 @@
</head>
<body>
- <div class="player-wrapper" id="container" style="background-color: #0D0E1B;width:900px;height:500px">
+<div class="player-wrapper" id="container" style="background-color: #0D0E1B;width:900px;height:500px">
+</div>
+<div class="btn-wrapper" id="playDom">
+ <button class="btn" id="play">播放</button>
+</div>
+<div class="btn-wrapper btn-wrapper2" id="stopDom" style="display: none">
+ <div style="margin-top: 5px">
+ <button class="btn btn-danger" id="stop">结束</button>
</div>
- <div class="btn-wrapper" id="playDom">
- <button class="btn" id="play">播放</button>
- </div>
- <div class="btn-wrapper btn-wrapper2" id="stopDom" style="display: none">
- <div style="margin-top: 5px">
- <button class="btn btn-danger" id="stop">结束</button>
- </div>
- </div>
- <button class="btn" onclick="h5lc.fullscreen=true">全屏</button>
- <div id="logout" class="logs">
- </div>
+</div>
+<button class="btn" onclick="h5lc.fullscreen=true">全屏</button>
+<div id="logout" class="logs">
+</div>
- <script src="./ajax.js"></script>
- <script src="./renderer.js"></script>
- <script>
- onerror = handleErr;
- var txt = "";
- window.onkeydown = function () {
- h5lc.fullscreen = false
- }
- var $play = document.getElementById('play');
- var $stop = document.getElementById('stop');
- var $playDom = document.getElementById('playDom');
- var $stopDom = document.getElementById('stopDom');
- var container = document.getElementById("container");
- var isPlaying = false;
- disabledMouseWheel(container);
- let stream = queryParam('stream') || 'user1';
- let decoder = queryParam('decoder') || 'ff';
- let source = queryParam('source') || 'localhost';
- var h5lc = new Jessibuca({ container, decoder: decoder + ".js", videoBuffer: 0 });
+<script src="./ajax.js"></script>
+<script src="./renderer.js"></script>
+<script src="https://cdn.staticfile.org/jquery/1.10.2/jquery.min.js"></script>
- h5lc.onLoad = function () {
- //this.play("wss://pulls.1234326.cn/live/L01.flv")
- //this.play("ws://localhost:8080/live/test.flv")
- //this.play("ws://" + source + ":8080/live/" + stream)
- //this.play("ws://pull3.afb1188.com/live/" + stream + ".flv")
- //this.play("ws://pull2.afb1188.com/live/" + stream + ".flv")
+<script>
+ onerror = handleErr;
+ var txt = "";
+ window.onkeydown = function () {
+ h5lc.fullscreen = false
+ }
+ var $play = document.getElementById('play');
+ var $stop = document.getElementById('stop');
+ var $playDom = document.getElementById('playDom');
+ var $stopDom = document.getElementById('stopDom');
+ var container = document.getElementById("container");
+ var isPlaying = false;
+ disabledMouseWheel(container);
+ let stream = queryParam('stream') || 'user1';
+ let decoder = queryParam('decoder') || 'ff';
+ let source = queryParam('source') || 'localhost';
+ var h5lc = new Jessibuca({container, decoder: decoder + ".js", videoBuffer: 0});
+
+ h5lc.onLoad = function () {
+ //this.play("wss://pulls.1234326.cn/live/L01.flv")
+ //this.play("ws://localhost:8080/live/test.flv")
+ //this.play("ws://" + source + ":8080/live/" + stream)
+ //this.play("ws://pull3.afb1188.com/live/" + stream + ".flv")
+ //this.play("ws://pull2.afb1188.com/live/" + stream + ".flv")
+ }
+ h5lc.onPlay = function () {
+ isPlaying = true;
+ $playDom.style.display = 'none';
+ $stopDom.style.display = 'block';
+ }
+ $play.addEventListener('click', function () {
+ if (isPlaying) {
+ return;
}
- h5lc.onPlay = function () {
- isPlaying = true;
- $playDom.style.display = 'none';
- $stopDom.style.display = 'block';
- }
- $play.addEventListener('click', function () {
- if (isPlaying) {
- return;
+ isPlaying = true;
+ $.get("http://127.0.0.1:8088/monica/test/video", function (data) {
+ h5lc.play(data)
}
- isPlaying = true;
- play();
- $playDom.style.display = 'none';
- $stopDom.style.display = 'block';
- }, false);
+ );
+ //play();
+ $playDom.style.display = 'none';
+ $stopDom.style.display = 'block';
+ }, false);
- $stop.addEventListener('click', function () {
- if (!isPlaying) {
- return;
- }
-
- isPlaying = false;
- stop();
-
- $playDom.style.display = 'block';
- $stopDom.style.display = 'none';
- }, false);
-
-
- function play(firstResponseIp) {
- //h5lc.play("ws://" + (firstResponseIp || source) + ":8080/live/" + stream)
- //h5lc.play("ws://pull2.afb1188.com/live/" + stream + ".flv")
- //h5lc.play("ws://localhost:8080/live/" + stream)
- h5lc.play("ws://localhost:8080/live/test.flv")
- // h5lc.play("ws://119.9.118.39:8080/live/user1", canvas)
- // h5lc.play("ws://test.qihaipi.com/gnddragon/test.flv", canvas)
- // h5lc.play("ws://localhost:8080/live/test.flv", canvas)
-
- }
- function getFastCdnFromList(ipList) {
- ipList = ipList || [];
- var firstResponseIp = '';
-
- for (var i = 0, len = ipList.length; i < len; i++) {
- var tempIp = ipList[i].name;
- var reqHref = 'http://' + tempIp + '/test';
- var request = _ajax.get(reqHref);
- request.then(function (data) {
- if (!firstResponseIp) {
- firstResponseIp = tempIp;
- // 直接可以播放了。
- play(firstResponseIp);
- }
- })
- }
- }
- function stop() {
- h5lc.close()
+ $stop.addEventListener('click', function () {
+ if (!isPlaying) {
+ return;
}
- function queryParam(name, url) {
- var search = window.location.search;
- var qArr = '';
- var key = {};
+ isPlaying = false;
+ stop();
- if (url) {
- qArr = url.split("?")[1].split("&")
+ $playDom.style.display = 'block';
+ $stopDom.style.display = 'none';
+ }, false);
- } else {
- if (!window.location.search) {
- return
+
+ function play(firstResponseIp) {
+ //h5lc.play("ws://" + (firstResponseIp || source) + ":8080/live/" + stream)
+ //h5lc.play("ws://pull2.afb1188.com/live/" + stream + ".flv")
+ //h5lc.play("ws://localhost:8080/live/" + stream)
+ h5lc.play("ws://localhost:8080/live/test.flv")
+ // h5lc.play("ws://119.9.118.39:8080/live/user1", canvas)
+ // h5lc.play("ws://test.qihaipi.com/gnddragon/test.flv", canvas)
+ // h5lc.play("ws://localhost:8080/live/test.flv", canvas)
+
+ }
+
+ function getFastCdnFromList(ipList) {
+ ipList = ipList || [];
+ var firstResponseIp = '';
+
+ for (var i = 0, len = ipList.length; i < len; i++) {
+ var tempIp = ipList[i].name;
+ var reqHref = 'http://' + tempIp + '/test';
+ var request = _ajax.get(reqHref);
+ request.then(function (data) {
+ if (!firstResponseIp) {
+ firstResponseIp = tempIp;
+ // 直接可以播放了。
+ play(firstResponseIp);
}
- qArr = search.substr(1).split("&")
+ })
+ }
+ }
+
+ function stop() {
+ h5lc.close()
+ }
+
+ function queryParam(name, url) {
+ var search = window.location.search;
+ var qArr = '';
+ var key = {};
+
+ if (url) {
+ qArr = url.split("?")[1].split("&")
+
+ } else {
+ if (!window.location.search) {
+ return
}
+ qArr = search.substr(1).split("&")
+ }
- for (var i = 0; i < qArr.length; i++) {
+ for (var i = 0; i < qArr.length; i++) {
- var firstPos = qArr[i].indexOf('=');
- key[qArr[i].slice(0, firstPos)] = qArr[i].slice(firstPos + 1)
- }
+ var firstPos = qArr[i].indexOf('=');
+ key[qArr[i].slice(0, firstPos)] = qArr[i].slice(firstPos + 1)
+ }
- if (name) {
+ if (name) {
+ return key[name]
+ } else {
+ if (url) {
return key[name]
} else {
- if (url) {
- return key[name]
- } else {
- return key
- }
+ return key
}
}
+ }
- function disabledMouseWheel(ele) {
- if (ele.addEventListener) {
- ele.addEventListener('DOMMouseScroll', scrollFunc, false);
- } //W3C
- ele.onmousewheel = scrollFunc; //IE/Opera/Chrome
- }
+ function disabledMouseWheel(ele) {
+ if (ele.addEventListener) {
+ ele.addEventListener('DOMMouseScroll', scrollFunc, false);
+ } //W3C
+ ele.onmousewheel = scrollFunc; //IE/Opera/Chrome
+ }
- function scrollFunc(evt) {
- evt = evt || window.event;
- if (evt.preventDefault) {
- // Firefox
- evt.preventDefault();
- evt.stopPropagation();
- } else {
- // IE
- evt.cancelBubble = true;
- evt.returnValue = false;
- }
- return false;
+ function scrollFunc(evt) {
+ evt = evt || window.event;
+ if (evt.preventDefault) {
+ // Firefox
+ evt.preventDefault();
+ evt.stopPropagation();
+ } else {
+ // IE
+ evt.cancelBubble = true;
+ evt.returnValue = false;
}
+ return false;
+ }
- function handleErr(msg, url, l) {
- txt = "There was an error on this page.\n\n";
- txt += "Error: " + msg + "\n";
- txt += "URL: " + url + "\n";
- txt += "Line: " + l + "\n\n";
- document.getElementById("logout").innerHTML += txt + "<br>";
- return true;
- }
- </script>
+ function handleErr(msg, url, l) {
+ txt = "There was an error on this page.\n\n";
+ txt += "Error: " + msg + "\n";
+ txt += "URL: " + url + "\n";
+ txt += "Line: " + l + "\n\n";
+ document.getElementById("logout").innerHTML += txt + "<br>";
+ return true;
+ }
+</script>
</body>
--
Gitblit v1.9.1