新增监控
This commit is contained in:
parent
322e00404c
commit
c95eb2d060
@ -7,6 +7,7 @@ import com.yutou.tools.mybatis.model.Permission;
|
||||
import com.yutou.tools.mybatis.model.PermissionExample;
|
||||
import com.yutou.tools.mybatis.model.UKey;
|
||||
import com.yutou.tools.mybatis.model.UKeyExample;
|
||||
import com.yutou.tools.utils.ConfigTools;
|
||||
import com.yutou.tools.utils.RedisTools;
|
||||
import com.yutou.tools.utils.Tools;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@ -44,6 +45,12 @@ public class RoleAccessDecisionManager implements AccessDecisionManager {
|
||||
case "/login/check.do":
|
||||
return;
|
||||
}
|
||||
if("dev".equals(ConfigTools.load(ConfigTools.CONFIG, "model"))) {
|
||||
return;
|
||||
}
|
||||
if(url.endsWith(".ts")||url.endsWith(".m3u8")){
|
||||
return;
|
||||
}
|
||||
if(url.startsWith("/public/")){
|
||||
return;
|
||||
}
|
||||
@ -80,11 +87,13 @@ public class RoleAccessDecisionManager implements AccessDecisionManager {
|
||||
List<Permission> permissions = permissionDao.selectByExample(pExample);
|
||||
if (!permissions.isEmpty()) {
|
||||
if (!powers.toJavaList(String.class).contains(permissions.get(0).getId()+"")) {
|
||||
System.out.println("111111");
|
||||
error();
|
||||
}else{
|
||||
authentication.setAuthenticated(true);
|
||||
}
|
||||
}else{
|
||||
System.out.println("2222222");
|
||||
error();
|
||||
}
|
||||
}
|
||||
|
@ -11,6 +11,7 @@ import com.yutou.tools.utils.RedisTools;
|
||||
import com.yutou.tools.utils.Tools;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
@ -291,4 +292,25 @@ public class NasManager {
|
||||
}
|
||||
return json;
|
||||
}
|
||||
|
||||
@RequestMapping("/nas/door/cctv.do")
|
||||
public void getDoorCCTV(HttpServletResponse response){
|
||||
try {
|
||||
System.out.println("???");
|
||||
response.sendRedirect(NasUrl+":9999/live/index.m3u8");
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
@RequestMapping("/nas/door/{*.ts}")
|
||||
public void getDoorCCTVOfTs(HttpServletResponse response, HttpServletRequest request, @PathVariable("*.ts") String name){
|
||||
try {
|
||||
if(!name.endsWith(".ts")){
|
||||
return;
|
||||
}
|
||||
response.sendRedirect(NasUrl+":9999/live/"+request.getRequestURI().replace("/nas/door/",""));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
200
web/html/body/nas/cctv.html
Normal file
200
web/html/body/nas/cctv.html
Normal file
@ -0,0 +1,200 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>监控</title>
|
||||
<link rel="stylesheet" href="/layui/css/layui.css">
|
||||
<link href="https://cdn.bootcss.com/video.js/7.6.5/alt/video-js-cdn.min.css" rel="stylesheet">
|
||||
<meta charset="utf-8"/>
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
|
||||
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<div class="layui-layout layui-layout-admin">
|
||||
<div id="header"></div>
|
||||
<div class="layui-body" style="left: 200px;overflow:auto;">
|
||||
<div id="side"></div>
|
||||
<div class="myDiy">
|
||||
<video id="myVideo" class="video-js vjs-default-skin vjs-big-play-centered" controls preload="auto" width="1080"
|
||||
height="708" data-setup='{}'>
|
||||
<source id="source" src="/nas/door/cctv.do" type="application/x-mpegURL">
|
||||
</video>
|
||||
<button id="myButton" type="button" class="button layui-btn-radius layui-btn layui-btn-lg layui-btn-normal">
|
||||
开 门
|
||||
</button>
|
||||
<button id="myRecord" type="button" class="button layui-btn-radius layui-btn layui-btn-lg layui-btn-normal">
|
||||
语 音
|
||||
</button>
|
||||
</div>
|
||||
<div id="footer"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
</body>
|
||||
<script src="/layui/layui.js"></script>
|
||||
<script src="/js/jquery-3.2.1.js"></script>
|
||||
<script src="/js/myjs.js"></script>
|
||||
<script src="/js/recordmp3.js"></script>
|
||||
<script src="https://cdn.bootcss.com/video.js/6.6.2/video.js"></script>
|
||||
<script src="https://cdn.bootcss.com/videojs-contrib-hls/5.15.0/videojs-contrib-hls.min.js"></script>
|
||||
</script>
|
||||
<script>
|
||||
$('#header').load("/html/header.html");
|
||||
$('#footer').load("/html/footer.html");
|
||||
$('#side').load("/html/body/nas/side.html");
|
||||
let token = getParam('token');
|
||||
|
||||
let myVideo= videojs('myVideo', {
|
||||
|
||||
bigPlayButton: true,
|
||||
|
||||
textTrackDisplay: false,
|
||||
|
||||
posterImage: false,
|
||||
|
||||
errorDisplay: false,
|
||||
|
||||
})
|
||||
|
||||
|
||||
|
||||
$('#myButton').click(function () {
|
||||
|
||||
$.get('/door/set.do?status=open', function (ret) {
|
||||
if (ret === "1") {
|
||||
let index = layer.load(2, {shade: [0.45, '#57606f']});
|
||||
load(index)
|
||||
}
|
||||
})
|
||||
})
|
||||
$('#myRecord').mousedown(function () {
|
||||
console.log("down")
|
||||
startRecording()
|
||||
})
|
||||
$('#myRecord').mouseup(function () {
|
||||
console.log("up")
|
||||
stopRecording()
|
||||
})
|
||||
|
||||
function load(index) {
|
||||
$.get("/door/status.do", function (ret) {
|
||||
if (ret === "1") {
|
||||
layer.close(index)
|
||||
layer.msg("已开门")
|
||||
} else {
|
||||
load(index)
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
var audio_context;
|
||||
var recorder;
|
||||
|
||||
function startUserMedia(stream) {
|
||||
var input = audio_context.createMediaStreamSource(stream);
|
||||
__log('Media stream created.');
|
||||
__log("input sample rate " + input.context.sampleRate);
|
||||
|
||||
// Feedback!
|
||||
//input.connect(audio_context.destination);
|
||||
__log('Input connected to audio context destination.');
|
||||
|
||||
recorder = new Recorder(input, {
|
||||
numChannels: 1
|
||||
});
|
||||
__log('Recorder initialised.');
|
||||
}
|
||||
|
||||
function startRecording() {
|
||||
recorder && recorder.record();
|
||||
__log('Recording...');
|
||||
}
|
||||
|
||||
function stopRecording() {
|
||||
recorder && recorder.stop();
|
||||
__log('Stopped recording.');
|
||||
|
||||
// create WAV download link using audio data blob
|
||||
createDownloadLink();
|
||||
|
||||
recorder.clear();
|
||||
}
|
||||
|
||||
function createDownloadLink() {
|
||||
console.log("check audio...")
|
||||
recorder && recorder.exportWAV(function (blob) {
|
||||
console.log('get vudio')
|
||||
|
||||
var formData = new FormData()
|
||||
console.log(Object.prototype.toString.call(blob))
|
||||
formData.append('audio', blob, new Date().toISOString() + '.wav')
|
||||
$.ajax({
|
||||
url: '/door/audio.do',
|
||||
type: 'POST',
|
||||
//contentType: 'application/octet-stream',
|
||||
contentType: false,
|
||||
processData: false, // 增加这一行,不处理参数
|
||||
data: formData,
|
||||
success: function (result) {
|
||||
console.log(result)
|
||||
}
|
||||
})
|
||||
// var url = URL.createObjectURL(blob);
|
||||
// var hf = document.createElement('a');
|
||||
// hf.href = url;
|
||||
// hf.download = new Date().toISOString() + '.wav';
|
||||
// hf.innerHTML = hf.download;
|
||||
// hf.click()
|
||||
// console.log(url)
|
||||
});
|
||||
}
|
||||
|
||||
function __log(log) {
|
||||
console.log(log)
|
||||
}
|
||||
|
||||
window.onload = function init() {
|
||||
try {
|
||||
// webkit shim
|
||||
window.AudioContext = window.AudioContext || window.webkitAudioContext;
|
||||
navigator.getUserMedia = (navigator.getUserMedia ||
|
||||
navigator.webkitGetUserMedia ||
|
||||
navigator.mozGetUserMedia ||
|
||||
navigator.msGetUserMedia);
|
||||
window.URL = window.URL || window.webkitURL;
|
||||
|
||||
audio_context = new AudioContext;
|
||||
__log('Audio context set up.');
|
||||
__log('navigator.getUserMedia ' + (navigator.getUserMedia ? 'available.' : 'not present!'));
|
||||
} catch (e) {
|
||||
alert('No web audio support in this browser!');
|
||||
}
|
||||
|
||||
navigator.getUserMedia({audio: true}, startUserMedia, function (e) {
|
||||
__log('No live audio input: ' + e);
|
||||
});
|
||||
myVideo.load()
|
||||
myVideo.play() // 视频播放
|
||||
};
|
||||
</script>
|
||||
<style>
|
||||
.myDiy {
|
||||
width: 20%;
|
||||
height: 300px;
|
||||
margin-top: 10px;
|
||||
margin-left: 15%;
|
||||
}
|
||||
|
||||
.button {
|
||||
width: 100px;
|
||||
height: 100px;
|
||||
font-size: 1em;
|
||||
}
|
||||
</style>
|
||||
|
||||
</html>
|
@ -31,6 +31,7 @@
|
||||
<dd><a href="http://bt.yutou233.cn" target="_blank">BT下载</a></dd>
|
||||
<dd><a href="http://jellyfin.yutou233.cn:7800/" target="_blank">jellyfin</a></dd>
|
||||
<dd><a href="/html/body/nas/music.html">NAS音乐播放器</a></dd>
|
||||
<dd><a href="/html/body/nas/cctv.html">监控</a></dd>
|
||||
</dl>
|
||||
</li>
|
||||
<li class="layui-nav-item" id='icon'>
|
||||
|
1446
web/js/libmp3lame.min.js
vendored
Normal file
1446
web/js/libmp3lame.min.js
vendored
Normal file
File diff suppressed because it is too large
Load Diff
41
web/js/mp3Worker.js
Normal file
41
web/js/mp3Worker.js
Normal file
@ -0,0 +1,41 @@
|
||||
importScripts('libmp3lame.min.js');
|
||||
|
||||
var mp3codec;
|
||||
|
||||
self.onmessage = function(e) {
|
||||
switch (e.data.cmd) {
|
||||
case 'init':
|
||||
if (!e.data.config) {
|
||||
e.data.config = { };
|
||||
}
|
||||
mp3codec = Lame.init();
|
||||
|
||||
Lame.set_mode(mp3codec, e.data.config.mode || Lame.JOINT_STEREO);
|
||||
Lame.set_num_channels(mp3codec, e.data.config.channels || 2);
|
||||
Lame.set_num_samples(mp3codec, e.data.config.samples || -1);
|
||||
Lame.set_in_samplerate(mp3codec, e.data.config.samplerate || 44100);
|
||||
Lame.set_out_samplerate(mp3codec, e.data.config.samplerate || 44100);
|
||||
Lame.set_bitrate(mp3codec, e.data.config.bitrate || 128);
|
||||
|
||||
Lame.init_params(mp3codec);
|
||||
console.log('Version :', Lame.get_version() + ' / ',
|
||||
'Mode: '+Lame.get_mode(mp3codec) + ' / ',
|
||||
'Samples: '+Lame.get_num_samples(mp3codec) + ' / ',
|
||||
'Channels: '+Lame.get_num_channels(mp3codec) + ' / ',
|
||||
'Input Samplate: '+ Lame.get_in_samplerate(mp3codec) + ' / ',
|
||||
'Output Samplate: '+ Lame.get_in_samplerate(mp3codec) + ' / ',
|
||||
'Bitlate :' +Lame.get_bitrate(mp3codec) + ' / ',
|
||||
'VBR :' + Lame.get_VBR(mp3codec));
|
||||
break;
|
||||
case 'encode':
|
||||
var mp3data = Lame.encode_buffer_ieee_float(mp3codec, e.data.buf, e.data.buf);
|
||||
self.postMessage({cmd: 'data', buf: mp3data.data});
|
||||
break;
|
||||
case 'finish':
|
||||
var mp3data = Lame.encode_flush(mp3codec);
|
||||
self.postMessage({cmd: 'end', buf: mp3data.data});
|
||||
Lame.close(mp3codec);
|
||||
mp3codec = null;
|
||||
break;
|
||||
}
|
||||
};
|
147
web/js/recorderWorker.js
Normal file
147
web/js/recorderWorker.js
Normal file
@ -0,0 +1,147 @@
|
||||
var recLength = 0,
|
||||
recBuffers = [],
|
||||
sampleRate,
|
||||
numChannels;
|
||||
|
||||
this.onmessage = function(e){
|
||||
switch(e.data.command){
|
||||
case 'init':
|
||||
init(e.data.config);
|
||||
break;
|
||||
case 'record':
|
||||
record(e.data.buffer);
|
||||
break;
|
||||
case 'exportWAV':
|
||||
exportWAV(e.data.type);
|
||||
break;
|
||||
case 'getBuffer':
|
||||
getBuffer();
|
||||
break;
|
||||
case 'clear':
|
||||
clear();
|
||||
break;
|
||||
}
|
||||
};
|
||||
|
||||
function init(config){
|
||||
sampleRate = config.sampleRate;
|
||||
numChannels = config.numChannels;
|
||||
initBuffers();
|
||||
}
|
||||
|
||||
function record(inputBuffer){
|
||||
for (var channel = 0; channel < numChannels; channel++){
|
||||
recBuffers[channel].push(inputBuffer[channel]);
|
||||
}
|
||||
recLength += inputBuffer[0].length;
|
||||
}
|
||||
|
||||
function exportWAV(type){
|
||||
var buffers = [];
|
||||
for (var channel = 0; channel < numChannels; channel++){
|
||||
buffers.push(mergeBuffers(recBuffers[channel], recLength));
|
||||
}
|
||||
if (numChannels === 2){
|
||||
var interleaved = interleave(buffers[0], buffers[1]);
|
||||
} else {
|
||||
var interleaved = buffers[0];
|
||||
}
|
||||
var dataview = encodeWAV(interleaved);
|
||||
var audioBlob = new Blob([dataview], { type: type });
|
||||
|
||||
this.postMessage(audioBlob);
|
||||
}
|
||||
|
||||
function getBuffer(){
|
||||
var buffers = [];
|
||||
for (var channel = 0; channel < numChannels; channel++){
|
||||
buffers.push(mergeBuffers(recBuffers[channel], recLength));
|
||||
}
|
||||
this.postMessage(buffers);
|
||||
}
|
||||
|
||||
function clear(){
|
||||
recLength = 0;
|
||||
recBuffers = [];
|
||||
initBuffers();
|
||||
}
|
||||
|
||||
function initBuffers(){
|
||||
for (var channel = 0; channel < numChannels; channel++){
|
||||
recBuffers[channel] = [];
|
||||
}
|
||||
}
|
||||
|
||||
function mergeBuffers(recBuffers, recLength){
|
||||
var result = new Float32Array(recLength);
|
||||
var offset = 0;
|
||||
for (var i = 0; i < recBuffers.length; i++){
|
||||
result.set(recBuffers[i], offset);
|
||||
offset += recBuffers[i].length;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
function interleave(inputL, inputR){
|
||||
var length = inputL.length + inputR.length;
|
||||
var result = new Float32Array(length);
|
||||
|
||||
var index = 0,
|
||||
inputIndex = 0;
|
||||
|
||||
while (index < length){
|
||||
result[index++] = inputL[inputIndex];
|
||||
result[index++] = inputR[inputIndex];
|
||||
inputIndex++;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
function floatTo16BitPCM(output, offset, input){
|
||||
for (var i = 0; i < input.length; i++, offset+=2){
|
||||
var s = Math.max(-1, Math.min(1, input[i]));
|
||||
output.setInt16(offset, s < 0 ? s * 0x8000 : s * 0x7FFF, true);
|
||||
}
|
||||
}
|
||||
|
||||
function writeString(view, offset, string){
|
||||
for (var i = 0; i < string.length; i++){
|
||||
view.setUint8(offset + i, string.charCodeAt(i));
|
||||
}
|
||||
}
|
||||
|
||||
function encodeWAV(samples){
|
||||
var buffer = new ArrayBuffer(44 + samples.length * 2);
|
||||
var view = new DataView(buffer);
|
||||
|
||||
/* RIFF identifier */
|
||||
writeString(view, 0, 'RIFF');
|
||||
/* RIFF chunk length */
|
||||
view.setUint32(4, 36 + samples.length * 2, true);
|
||||
/* RIFF type */
|
||||
writeString(view, 8, 'WAVE');
|
||||
/* format chunk identifier */
|
||||
writeString(view, 12, 'fmt ');
|
||||
/* format chunk length */
|
||||
view.setUint32(16, 16, true);
|
||||
/* sample format (raw) */
|
||||
view.setUint16(20, 1, true);
|
||||
/* channel count */
|
||||
view.setUint16(22, numChannels, true);
|
||||
/* sample rate */
|
||||
view.setUint32(24, sampleRate, true);
|
||||
/* byte rate (sample rate * block align) */
|
||||
view.setUint32(28, sampleRate * 4, true);
|
||||
/* block align (channel count * bytes per sample) */
|
||||
view.setUint16(32, numChannels * 2, true);
|
||||
/* bits per sample */
|
||||
view.setUint16(34, 16, true);
|
||||
/* data chunk identifier */
|
||||
writeString(view, 36, 'data');
|
||||
/* data chunk length */
|
||||
view.setUint32(40, samples.length * 2, true);
|
||||
|
||||
floatTo16BitPCM(view, 44, samples);
|
||||
|
||||
return view;
|
||||
}
|
Loading…
Reference in New Issue
Block a user