From 71dbac60afa54d2642c3471c080686da56579ca0 Mon Sep 17 00:00:00 2001 From: ‘liusuyi’ <1951119284@qq.com> Date: 星期六, 09 九月 2023 16:37:13 +0800 Subject: [PATCH] 流媒体优化 --- ard-work/src/main/resources/templates/test.html | 91 +++++++++++++++++++++++---------------------- 1 files changed, 46 insertions(+), 45 deletions(-) diff --git a/ard-work/src/main/resources/templates/test.html b/ard-work/src/main/resources/templates/test.html index a55bf5e..25ea102 100644 --- a/ard-work/src/main/resources/templates/test.html +++ b/ard-work/src/main/resources/templates/test.html @@ -13,20 +13,6 @@ margin-top: 10px; } </style> - <!-- 瀵煎叆 ECMAScript 妯″潡 --> - <script th:type="module" th:src="@{/js/WHEPClient.js}"></script> - <!-- 鍐呰仈鑴氭湰鍧楋紝鍙互浣跨敤妯″潡涓殑鍐呭 --> - <script th:inline="javascript"> - /*<![CDATA[*/ - // 鍦ㄨ繖閲屼娇鐢� WHEPClient 妯″潡涓殑鍐呭 - $("#play").click(function webrtcClient(){ - const url = "http://127.0.0.1:8889/165"; // add the webRTC URL from your live input here - console.log(url) - const videoElement = document.getElementById("remote-video"); - const client = new WHEPClient(url, videoElement); - }) - /*]]>*/ - </script> <body> <div class="container"> <div class="row "> @@ -141,15 +127,12 @@ <div class="row top-buffer"> <video id="video" muted autoplay loop controls style="width: 800px; height: 100%; object-fit: fill;"/> </div> - <div class="row top-buffer"> - <button id="play" type="button" class="btn btn-default" >鎾斁</button> - <video id="remote-video" controls autoplay muted></video> - </div> </div> </div> </div> -<script th:inline="javascript"> - var cameraId, opt,optOpen,optClose, token; +<script th:inline="javascript" th:type="module"> + + var cameraId, opt, optOpen, optClose, token; window.onload = function () { $.ajax({ url: "../hik/list", @@ -179,7 +162,6 @@ } } }) - opt = {"username": "admin", "password": "admin123"}; $.ajax({ headers: { @@ -326,7 +308,7 @@ $("#setPreset").click(function () { cameraId = $('#select option:selected').val(); - opt = {"cameraId": cameraId, "channelNum": 1, "speed": 8, "presetIndex": 1}; + opt = {"cameraId": cameraId, "chanNo": 1, "speed": 8, "presetIndex": 1}; $.ajax({ headers: { 'Accept': 'application/json', @@ -344,7 +326,7 @@ }) $("#gotoPreset").click(function () { cameraId = $('#select option:selected').val(); - opt = {"cameraId": cameraId, "channelNum": 1, "speed": 8, "presetIndex": 1}; + opt = {"cameraId": cameraId, "chanNo": 1, "speed": 8, "presetIndex": 1}; $.ajax({ headers: { 'Accept': 'application/json', @@ -362,7 +344,7 @@ }) $("#getPTZ").click(function () { cameraId = $('#select option:selected').val(); - opt = {"cameraId": cameraId, "channelNum": 1}; + opt = {"cameraId": cameraId, "chanNo": 1}; $.ajax({ headers: { 'Accept': 'application/json', @@ -388,7 +370,7 @@ var z = $('#z').val(); //瀹氫箟涓�涓甫鏈塎ap瀛楁鐨勫疄浣撳璞� var myEntity = { - channelNum: 1, + chanNo: 1, cameraId: cameraId, ptzMap: { p: p, @@ -419,7 +401,7 @@ var targetP = $('#targetPostion').val(); //瀹氫箟涓�涓甫鏈塎ap瀛楁鐨勫疄浣撳璞� var myEntity = { - channelNum: 1, + chanNo: 1, cameraId: cameraId, targetPosition: targetP, camPosition: camP, @@ -442,7 +424,7 @@ }) $("#setZeroPTZ").click(function () { cameraId = $('#select option:selected').val(); - opt = {"cameraId": cameraId, "channelNum": 1}; + opt = {"cameraId": cameraId, "chanNo": 1}; $.ajax({ headers: { 'Accept': 'application/json', @@ -460,7 +442,7 @@ }) $("#WiperPwron").click(function () { cameraId = $('#select option:selected').val(); - opt = {"cameraId": cameraId, "channelNum": 1, "speed": 8, "enable": true, "code": 16}; + opt = {"cameraId": cameraId, "chanNo": 1, "speed": 8, "enable": true, "code": 16}; $.ajax({ headers: { 'Accept': 'application/json', @@ -479,8 +461,8 @@ var defogflag = true; $("#Defogcfg").click(function () { cameraId = $('#select option:selected').val(); - optOpen = {"cameraId": cameraId, "channelNum": 1, "enable": true}; - optClose = {"cameraId": cameraId, "channelNum": 1, "enable": false}; + optOpen = {"cameraId": cameraId, "chanNo": 1, "enable": true}; + optClose = {"cameraId": cameraId, "chanNo": 1, "enable": false}; if (defogflag) { $(this).text("鍏抽棴閫忛浘"); defogflag = false; @@ -521,8 +503,8 @@ var infrareflag = true; $("#Infrarecfg").click(function () { cameraId = $('#select option:selected').val(); - optOpen = {"cameraId": cameraId, "channelNum": 1, "enable": true}; - optClose = {"cameraId": cameraId, "channelNum": 1, "enable": false}; + optOpen = {"cameraId": cameraId, "chanNo": 1, "enable": true}; + optClose = {"cameraId": cameraId, "chanNo": 1, "enable": false}; if (infrareflag) { $(this).text("鍏抽棴绾㈠"); infrareflag = false; @@ -563,8 +545,8 @@ var focusModeflag = true; $("#FocusMode").click(function () { cameraId = $('#select option:selected').val(); - optOpen = {"cameraId": cameraId, "channelNum": 1, "enable": true}; - optClose = {"cameraId": cameraId, "channelNum": 1, "enable": false}; + optOpen = {"cameraId": cameraId, "chanNo": 1, "enable": true}; + optClose = {"cameraId": cameraId, "chanNo": 1, "enable": false}; if (focusModeflag) { $(this).text("鑷姩鑱氱劍"); focusModeflag = false; @@ -601,11 +583,30 @@ }) } }) + $("#getFocusPos").click(function () { + cameraId = $('#select option:selected').val(); + opt = {"cameraId": cameraId, "chanNo": 1}; + $.ajax({ + headers: { + 'Accept': 'application/json', + 'Content-Type': 'application/json', + 'Authorization': token + }, + url: "../hik/getFocusPos", + type: "post", + dataType: "json", + data: JSON.stringify(opt), + success: function (datas) { + console.log(datas); + $("#focus").val(datas.data.dwFocus); + } + }) + }) var heateRpwronflag = true; $("#HeateRpwron").click(function () { cameraId = $('#select option:selected').val(); - optOpen = {"cameraId": cameraId, "channelNum": 1, "enable": true}; - optClose = {"cameraId": cameraId, "channelNum": 1, "enable": false}; + optOpen = {"cameraId": cameraId, "chanNo": 1, "enable": true}; + optClose = {"cameraId": cameraId, "chanNo": 1, "enable": false}; if (heateRpwronflag) { $(this).text("鍏抽棴浜戝彴鍔犵儹"); heateRpwronflag = false; @@ -645,8 +646,8 @@ var CameraDeicingflag = true; $("#CameraDeicing").click(function () { cameraId = $('#select option:selected').val(); - optOpen = {"cameraId": cameraId, "channelNum": 1, "enable": true}; - optClose = {"cameraId": cameraId, "channelNum": 1, "enable": false}; + optOpen = {"cameraId": cameraId, "chanNo": 1, "enable": true}; + optClose = {"cameraId": cameraId, "chanNo": 1, "enable": false}; if (CameraDeicingflag) { $(this).text("鍏抽棴闀滃ご鍔犵儹"); CameraDeicingflag = false; @@ -684,7 +685,7 @@ }) $("#realCutPic").click(function () { cameraId = $('#select option:selected').val(); - opt = {"cameraId": cameraId, "channelNum": 1}; + opt = {"cameraId": cameraId, "chanNo": 1}; $.ajax({ headers: { 'Accept': 'application/json', @@ -703,7 +704,7 @@ }) $("#saveCutPic").click(function () { cameraId = $('#select option:selected').val(); - opt = {"cameraId": cameraId, "channelNum": 1}; + opt = {"cameraId": cameraId, "chanNo": 1}; $.ajax({ headers: { 'Accept': 'application/json', @@ -723,8 +724,8 @@ var recordflag = true; $("#record").click(function () { cameraId = $('#select option:selected').val(); - optOpen = {"cameraId": cameraId, "channelNum": 1, "enable": true}; - optClose = {"cameraId": cameraId, "channelNum": 1, "enable": false}; + optOpen = {"cameraId": cameraId, "chanNo": 1, "enable": true}; + optClose = {"cameraId": cameraId, "chanNo": 1, "enable": false}; if (recordflag) { $(this).text("鍋滄褰曞儚"); recordflag = false; @@ -767,7 +768,7 @@ /*浜戝彴鍏叡鏂规硶*/ function commondMethod(url, code, enable) { cameraId = $('#select option:selected').val(); - opt = {"cameraId": cameraId, "channelNum": 1, "speed": 8, "enable": enable, "code": code}; + opt = {"cameraId": cameraId, "chanNo": 1, "speed": 8, "enable": enable, "code": code}; $.ajax({ headers: { 'Accept': 'application/json', @@ -807,7 +808,8 @@ //棰勮娴峰悍鐩告満 function realViewHik(serverip, elem, username, password, ipaddr, port) { - webRtcServer = new WebRtcStreamer(elem, "http://" + serverip + ":8000"); + // webRtcServer = new WebRtcStreamer(elem, "http://" + serverip + ":8000"); + webRtcServer = new WebRtcStreamer(elem, "http://192.168.1.227:8000"); let rtspUrl = "rtsp://" + username + ":" + password + "@" + ipaddr + ":" + port + "/ch1/main/av_stream"; let option = "rtptransport=tcp"; console.log("rtsp鍦板潃锛�" + rtspUrl); @@ -846,6 +848,5 @@ webRtcServer.disconnect(); } </script> - </body> </html> \ No newline at end of file -- Gitblit v1.9.3