From f06f3826c54a34aa533b95484b9b4275a0d18527 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=8D=E7=88=B1=E5=AD=A6=E4=B9=A0=E7=9A=84=E7=9F=B3?= =?UTF-8?q?=E5=90=8C=E5=AD=A6?= <2936013465@qq.com> Date: Fri, 3 Jan 2025 11:25:12 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A4=A7=E5=B1=8F=E6=97=B6=E9=97=B4=E9=80=89?= =?UTF-8?q?=E4=B8=AD=E6=94=B9=E4=B8=BA=E6=9C=80=E8=BF=9112=E4=B8=AA?= =?UTF-8?q?=E6=9C=88=E7=9A=84=E6=97=B6=E9=97=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .idea/misc.xml | 1 - package.json | 9 +- src/api/mv/VideoComponent.vue | 54 +- src/api/mv/tool.js | 718 ++++++++++++++++++ src/router/routes.ts | 3 +- src/views/datav/AuditSuper.vue | 11 +- src/views/datav/CaseVerif.vue | 4 +- src/views/datav/Gobal.vue | 7 +- src/views/datav/MailVisits.vue | 2 +- src/views/datav/RightsComfort.vue | 2 +- src/views/datav/SceneInsp.vue | 2 +- src/views/datav/VideoInsp.vue | 19 +- .../datav/subonedatav/SubOneAuditSuper.vue | 11 +- .../datav/subonedatav/SubOneCaseVerif.vue | 2 +- src/views/datav/subonedatav/SubOneGlobal.vue | 11 +- .../datav/subonedatav/SubOneMailVisits.vue | 2 +- .../datav/subonedatav/SubOneRightsComfort.vue | 2 +- .../datav/subonedatav/SubOneSceneInsp.vue | 2 +- .../datav/subonedatav/SubOneVideoInsp.vue | 2 +- 19 files changed, 796 insertions(+), 68 deletions(-) create mode 100644 src/api/mv/tool.js diff --git a/.idea/misc.xml b/.idea/misc.xml index 304da04..bbd5d45 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -1,4 +1,3 @@ - diff --git a/package.json b/package.json index af052e6..3ef0098 100644 --- a/package.json +++ b/package.json @@ -36,6 +36,8 @@ "crypto-js": "^4.2.0", "echarts": "^5.4.3", "element-plus": "^2.8.8", + "flv.js": "^1.6.2", + "hls.js": "^1.5.18", "install": "^0.13.0", "lodash": "^4.17.21", "moment": "^2.30.1", @@ -43,10 +45,15 @@ "perfect-scrollbar": "^1.5.6", "pinia": "^2.1.7", "typescript": "^5.3.3", + "video.js": "^7.21.6", + "videojs-flash": "^2.2.1", "vue": "^3.3.11", "vue-echarts": "^6.6.8", + "vue-media-player": "^1.0.3", "vue-perfect-scrollbar": "^0.2.1", - "vue-router": "^4.2.5" + "vue-router": "^4.2.5", + "vue-video-player": "^6.0.0", + "webrtc-adapter": "^9.0.1" }, "devDependencies": { "@univerjs/vite-plugin": "^0.5.0", diff --git a/src/api/mv/VideoComponent.vue b/src/api/mv/VideoComponent.vue index 9e1793e..f14bdaa 100644 --- a/src/api/mv/VideoComponent.vue +++ b/src/api/mv/VideoComponent.vue @@ -1,41 +1,41 @@ - diff --git a/src/api/mv/tool.js b/src/api/mv/tool.js new file mode 100644 index 0000000..4213085 --- /dev/null +++ b/src/api/mv/tool.js @@ -0,0 +1,718 @@ + +// +// Copyright (c) 2013-2021 Winlin +// +// SPDX-License-Identifier: MIT +// + +'use strict'; + +function SrsError(name, message) { + this.name = name; + this.message = message; + this.stack = (new Error()).stack; +} +SrsError.prototype = Object.create(Error.prototype); +SrsError.prototype.constructor = SrsError; + +// Depends on adapter-7.4.0.min.js from https://github.com/webrtc/adapter +// Async-awat-prmise based SRS RTC Publisher. +function SrsRtcPublisherAsync() { + var self = {}; + + // https://developer.mozilla.org/en-US/docs/Web/API/MediaDevices/getUserMedia + self.constraints = { + audio: true, + video: { + width: {ideal: 320, max: 576} + } + }; + + // @see https://github.com/rtcdn/rtcdn-draft + // @url The WebRTC url to play with, for example: + // webrtc://r.ossrs.net/live/livestream + // or specifies the API port: + // webrtc://r.ossrs.net:11985/live/livestream + // or autostart the publish: + // webrtc://r.ossrs.net/live/livestream?autostart=true + // or change the app from live to myapp: + // webrtc://r.ossrs.net:11985/myapp/livestream + // or change the stream from livestream to mystream: + // webrtc://r.ossrs.net:11985/live/mystream + // or set the api server to myapi.domain.com: + // webrtc://myapi.domain.com/live/livestream + // or set the candidate(eip) of answer: + // webrtc://r.ossrs.net/live/livestream?candidate=39.107.238.185 + // or force to access https API: + // webrtc://r.ossrs.net/live/livestream?schema=https + // or use plaintext, without SRTP: + // webrtc://r.ossrs.net/live/livestream?encrypt=false + // or any other information, will pass-by in the query: + // webrtc://r.ossrs.net/live/livestream?vhost=xxx + // webrtc://r.ossrs.net/live/livestream?token=xxx + self.publish = async function (url) { + var conf = self.__internal.prepareUrl(url); + self.pc.addTransceiver("audio", {direction: "sendonly"}); + self.pc.addTransceiver("video", {direction: "sendonly"}); + //self.pc.addTransceiver("video", {direction: "sendonly"}); + //self.pc.addTransceiver("audio", {direction: "sendonly"}); + + if (!navigator.mediaDevices && window.location.protocol === 'http:' && window.location.hostname !== 'localhost') { + throw new SrsError('HttpsRequiredError', `Please use HTTPS or localhost to publish, read https://github.com/ossrs/srs/issues/2762#issuecomment-983147576`); + } + var stream = await navigator.mediaDevices.getUserMedia(self.constraints); + + // @see https://developer.mozilla.org/en-US/docs/Web/API/RTCPeerConnection/addStream#Migrating_to_addTrack + stream.getTracks().forEach(function (track) { + self.pc.addTrack(track); + + // Notify about local track when stream is ok. + self.ontrack && self.ontrack({track: track}); + }); + + var offer = await self.pc.createOffer(); + await self.pc.setLocalDescription(offer); + var session = await new Promise(function (resolve, reject) { + // @see https://github.com/rtcdn/rtcdn-draft + var data = { + api: conf.apiUrl, tid: conf.tid, streamurl: conf.streamUrl, + clientip: null, sdp: offer.sdp + }; + console.log("Generated offer: ", data); + + const xhr = new XMLHttpRequest(); + xhr.onload = function() { + if (xhr.readyState !== xhr.DONE) return; + if (xhr.status !== 200 && xhr.status !== 201) return reject(xhr); + const data = JSON.parse(xhr.responseText); + console.log("Got answer: ", data); + return data.code ? reject(xhr) : resolve(data); + } + xhr.open('POST', conf.apiUrl, true); + xhr.setRequestHeader('Content-type', 'application/json'); + xhr.send(JSON.stringify(data)); + }); + await self.pc.setRemoteDescription( + new RTCSessionDescription({type: 'answer', sdp: session.sdp}) + ); + session.simulator = conf.schema + '//' + conf.urlObject.server + ':' + conf.port + '/rtc/v1/nack/'; + + return session; + }; + + // Close the publisher. + self.close = function () { + self.pc && self.pc.close(); + self.pc = null; + }; + + // The callback when got local stream. + // @see https://developer.mozilla.org/en-US/docs/Web/API/RTCPeerConnection/addStream#Migrating_to_addTrack + self.ontrack = function (event) { + // Add track to stream of SDK. + self.stream.addTrack(event.track); + }; + + // Internal APIs. + self.__internal = { + defaultPath: '/rtc/v1/publish/', + prepareUrl: function (webrtcUrl) { + var urlObject = self.__internal.parse(webrtcUrl); + + // If user specifies the schema, use it as API schema. + var schema = urlObject.user_query.schema; + schema = schema ? schema + ':' : window.location.protocol; + + var port = urlObject.port || 1985; + if (schema === 'https:') { + port = urlObject.port || 443; + } + + // @see https://github.com/rtcdn/rtcdn-draft + var api = urlObject.user_query.play || self.__internal.defaultPath; + if (api.lastIndexOf('/') !== api.length - 1) { + api += '/'; + } + + var apiUrl = schema + '//' + urlObject.server + ':' + port + api; + for (var key in urlObject.user_query) { + if (key !== 'api' && key !== 'play') { + apiUrl += '&' + key + '=' + urlObject.user_query[key]; + } + } + // Replace /rtc/v1/play/&k=v to /rtc/v1/play/?k=v + apiUrl = apiUrl.replace(api + '&', api + '?'); + + var streamUrl = urlObject.url; + + return { + apiUrl: apiUrl, streamUrl: streamUrl, schema: schema, urlObject: urlObject, port: port, + tid: Number(parseInt(new Date().getTime()*Math.random()*100)).toString(16).slice(0, 7) + }; + }, + parse: function (url) { + // @see: http://stackoverflow.com/questions/10469575/how-to-use-location-object-to-parse-url-without-redirecting-the-page-in-javascri + var a = document.createElement("a"); + a.href = url.replace("rtmp://", "http://") + .replace("webrtc://", "http://") + .replace("rtc://", "http://"); + + var vhost = a.hostname; + var app = a.pathname.substring(1, a.pathname.lastIndexOf("/")); + var stream = a.pathname.slice(a.pathname.lastIndexOf("/") + 1); + + // parse the vhost in the params of app, that srs supports. + app = app.replace("...vhost...", "?vhost="); + if (app.indexOf("?") >= 0) { + var params = app.slice(app.indexOf("?")); + app = app.slice(0, app.indexOf("?")); + + if (params.indexOf("vhost=") > 0) { + vhost = params.slice(params.indexOf("vhost=") + "vhost=".length); + if (vhost.indexOf("&") > 0) { + vhost = vhost.slice(0, vhost.indexOf("&")); + } + } + } + + // when vhost equals to server, and server is ip, + // the vhost is __defaultVhost__ + if (a.hostname === vhost) { + var re = /^(\d+)\.(\d+)\.(\d+)\.(\d+)$/; + if (re.test(a.hostname)) { + vhost = "__defaultVhost__"; + } + } + + // parse the schema + var schema = "rtmp"; + if (url.indexOf("://") > 0) { + schema = url.slice(0, url.indexOf("://")); + } + + var port = a.port; + if (!port) { + // Finger out by webrtc url, if contains http or https port, to overwrite default 1985. + if (schema === 'webrtc' && url.indexOf(`webrtc://${a.host}:`) === 0) { + port = (url.indexOf(`webrtc://${a.host}:80`) === 0) ? 80 : 443; + } + + // Guess by schema. + if (schema === 'http') { + port = 80; + } else if (schema === 'https') { + port = 443; + } else if (schema === 'rtmp') { + port = 1935; + } + } + + var ret = { + url: url, + schema: schema, + server: a.hostname, port: port, + vhost: vhost, app: app, stream: stream + }; + self.__internal.fill_query(a.search, ret); + + // For webrtc API, we use 443 if page is https, or schema specified it. + if (!ret.port) { + if (schema === 'webrtc' || schema === 'rtc') { + if (ret.user_query.schema === 'https') { + ret.port = 443; + } else if (window.location.href.indexOf('https://') === 0) { + ret.port = 443; + } else { + // For WebRTC, SRS use 1985 as default API port. + ret.port = 1985; + } + } + } + + return ret; + }, + fill_query: function (query_string, obj) { + // pure user query object. + obj.user_query = {}; + + if (query_string.length === 0) { + return; + } + + // split again for angularjs. + if (query_string.indexOf("?") >= 0) { + query_string = query_string.split("?")[1]; + } + + var queries = query_string.split("&"); + for (var i = 0; i < queries.length; i++) { + var elem = queries[i]; + + var query = elem.split("="); + obj[query[0]] = query[1]; + obj.user_query[query[0]] = query[1]; + } + + // alias domain for vhost. + if (obj.domain) { + obj.vhost = obj.domain; + } + } + }; + + self.pc = new RTCPeerConnection(null); + + // To keep api consistent between player and publisher. + // @see https://developer.mozilla.org/en-US/docs/Web/API/RTCPeerConnection/addStream#Migrating_to_addTrack + // @see https://webrtc.org/getting-started/media-devices + self.stream = new MediaStream(); + + return self; +} + +// Depends on adapter-7.4.0.min.js from https://github.com/webrtc/adapter +// Async-await-promise based SRS RTC Player. +function SrsRtcPlayerAsync() { + var self = {}; + + // @see https://github.com/rtcdn/rtcdn-draft + // @url The WebRTC url to play with, for example: + // webrtc://r.ossrs.net/live/livestream + // or specifies the API port: + // webrtc://r.ossrs.net:11985/live/livestream + // webrtc://r.ossrs.net:80/live/livestream + // or autostart the play: + // webrtc://r.ossrs.net/live/livestream?autostart=true + // or change the app from live to myapp: + // webrtc://r.ossrs.net:11985/myapp/livestream + // or change the stream from livestream to mystream: + // webrtc://r.ossrs.net:11985/live/mystream + // or set the api server to myapi.domain.com: + // webrtc://myapi.domain.com/live/livestream + // or set the candidate(eip) of answer: + // webrtc://r.ossrs.net/live/livestream?candidate=39.107.238.185 + // or force to access https API: + // webrtc://r.ossrs.net/live/livestream?schema=https + // or use plaintext, without SRTP: + // webrtc://r.ossrs.net/live/livestream?encrypt=false + // or any other information, will pass-by in the query: + // webrtc://r.ossrs.net/live/livestream?vhost=xxx + // webrtc://r.ossrs.net/live/livestream?token=xxx + self.play = async function(url) { + var conf = self.__internal.prepareUrl(url); + self.pc.addTransceiver("audio", {direction: "recvonly"}); + self.pc.addTransceiver("video", {direction: "recvonly"}); + //self.pc.addTransceiver("video", {direction: "recvonly"}); + //self.pc.addTransceiver("audio", {direction: "recvonly"}); + + var offer = await self.pc.createOffer(); + await self.pc.setLocalDescription(offer); + var session = await new Promise(function(resolve, reject) { + // @see https://github.com/rtcdn/rtcdn-draft + var data = { + api: conf.apiUrl, tid: conf.tid, streamurl: conf.streamUrl, + clientip: null, sdp: offer.sdp + }; + console.log("Generated offer: ", data); + + const xhr = new XMLHttpRequest(); + xhr.onload = function() { + if (xhr.readyState !== xhr.DONE) return; + if (xhr.status !== 200 && xhr.status !== 201) return reject(xhr); + const data = JSON.parse(xhr.responseText); + console.log("Got answer: ", data); + return data.code ? reject(xhr) : resolve(data); + } + xhr.open('POST', conf.apiUrl, true); + xhr.setRequestHeader('Content-type', 'application/json'); + xhr.send(JSON.stringify(data)); + }); + await self.pc.setRemoteDescription( + new RTCSessionDescription({type: 'answer', sdp: session.sdp}) + ); + session.simulator = conf.schema + '//' + conf.urlObject.server + ':' + conf.port + '/rtc/v1/nack/'; + + return session; + }; + + // Close the player. + self.close = function() { + self.pc && self.pc.close(); + self.pc = null; + }; + + // The callback when got remote track. + // Note that the onaddstream is deprecated, @see https://developer.mozilla.org/en-US/docs/Web/API/RTCPeerConnection/onaddstream + self.ontrack = function (event) { + // https://webrtc.org/getting-started/remote-streams + self.stream.addTrack(event.track); + }; + + // Internal APIs. + self.__internal = { + defaultPath: '/rtc/v1/play/', + prepareUrl: function (webrtcUrl) { + var urlObject = self.__internal.parse(webrtcUrl); + + // If user specifies the schema, use it as API schema. + var schema = urlObject.user_query.schema; + schema = schema ? schema + ':' : window.location.protocol; + + var port = urlObject.port || 1985; + if (schema === 'https:') { + port = urlObject.port || 443; + } + + // @see https://github.com/rtcdn/rtcdn-draft + var api = urlObject.user_query.play || self.__internal.defaultPath; + if (api.lastIndexOf('/') !== api.length - 1) { + api += '/'; + } + + var apiUrl = schema + '//' + urlObject.server + ':' + port + api; + for (var key in urlObject.user_query) { + if (key !== 'api' && key !== 'play') { + apiUrl += '&' + key + '=' + urlObject.user_query[key]; + } + } + // Replace /rtc/v1/play/&k=v to /rtc/v1/play/?k=v + apiUrl = apiUrl.replace(api + '&', api + '?'); + + var streamUrl = urlObject.url; + + return { + apiUrl: apiUrl, streamUrl: streamUrl, schema: schema, urlObject: urlObject, port: port, + tid: Number(parseInt(new Date().getTime()*Math.random()*100)).toString(16).slice(0, 7) + }; + }, + parse: function (url) { + // @see: http://stackoverflow.com/questions/10469575/how-to-use-location-object-to-parse-url-without-redirecting-the-page-in-javascri + var a = document.createElement("a"); + a.href = url.replace("rtmp://", "http://") + .replace("webrtc://", "http://") + .replace("rtc://", "http://"); + + var vhost = a.hostname; + var app = a.pathname.substring(1, a.pathname.lastIndexOf("/")); + var stream = a.pathname.slice(a.pathname.lastIndexOf("/") + 1); + + // parse the vhost in the params of app, that srs supports. + app = app.replace("...vhost...", "?vhost="); + if (app.indexOf("?") >= 0) { + var params = app.slice(app.indexOf("?")); + app = app.slice(0, app.indexOf("?")); + + if (params.indexOf("vhost=") > 0) { + vhost = params.slice(params.indexOf("vhost=") + "vhost=".length); + if (vhost.indexOf("&") > 0) { + vhost = vhost.slice(0, vhost.indexOf("&")); + } + } + } + + // when vhost equals to server, and server is ip, + // the vhost is __defaultVhost__ + if (a.hostname === vhost) { + var re = /^(\d+)\.(\d+)\.(\d+)\.(\d+)$/; + if (re.test(a.hostname)) { + vhost = "__defaultVhost__"; + } + } + + // parse the schema + var schema = "rtmp"; + if (url.indexOf("://") > 0) { + schema = url.slice(0, url.indexOf("://")); + } + + var port = a.port; + if (!port) { + // Finger out by webrtc url, if contains http or https port, to overwrite default 1985. + if (schema === 'webrtc' && url.indexOf(`webrtc://${a.host}:`) === 0) { + port = (url.indexOf(`webrtc://${a.host}:80`) === 0) ? 80 : 443; + } + + // Guess by schema. + if (schema === 'http') { + port = 80; + } else if (schema === 'https') { + port = 443; + } else if (schema === 'rtmp') { + port = 1935; + } + } + + var ret = { + url: url, + schema: schema, + server: a.hostname, port: port, + vhost: vhost, app: app, stream: stream + }; + self.__internal.fill_query(a.search, ret); + + // For webrtc API, we use 443 if page is https, or schema specified it. + if (!ret.port) { + if (schema === 'webrtc' || schema === 'rtc') { + if (ret.user_query.schema === 'https') { + ret.port = 443; + } else if (window.location.href.indexOf('https://') === 0) { + ret.port = 443; + } else { + // For WebRTC, SRS use 1985 as default API port. + ret.port = 1985; + } + } + } + + return ret; + }, + fill_query: function (query_string, obj) { + // pure user query object. + obj.user_query = {}; + + if (query_string.length === 0) { + return; + } + + // split again for angularjs. + if (query_string.indexOf("?") >= 0) { + query_string = query_string.split("?")[1]; + } + + var queries = query_string.split("&"); + for (var i = 0; i < queries.length; i++) { + var elem = queries[i]; + + var query = elem.split("="); + obj[query[0]] = query[1]; + obj.user_query[query[0]] = query[1]; + } + + // alias domain for vhost. + if (obj.domain) { + obj.vhost = obj.domain; + } + } + }; + + self.pc = new RTCPeerConnection(null); + + // Create a stream to add track to the stream, @see https://webrtc.org/getting-started/remote-streams + self.stream = new MediaStream(); + + // https://developer.mozilla.org/en-US/docs/Web/API/RTCPeerConnection/ontrack + self.pc.ontrack = function(event) { + if (self.ontrack) { + self.ontrack(event); + } + }; + + return self; +} + +// Depends on adapter-7.4.0.min.js from https://github.com/webrtc/adapter +// Async-awat-prmise based SRS RTC Publisher by WHIP. +function SrsRtcWhipWhepAsync() { + var self = {}; + + // https://developer.mozilla.org/en-US/docs/Web/API/MediaDevices/getUserMedia + self.constraints = { + audio: true, + video: { + width: {ideal: 320, max: 576} + } + }; + + // See https://datatracker.ietf.org/doc/draft-ietf-wish-whip/ + // @url The WebRTC url to publish with, for example: + // http://localhost:1985/rtc/v1/whip/?app=live&stream=livestream + // @options The options to control playing, supports: + // camera: boolean, whether capture video from camera, default to true. + // screen: boolean, whether capture video from screen, default to false. + // audio: boolean, whether play audio, default to true. + self.publish = async function (url, options) { + if (url.indexOf('/whip/') === -1) throw new Error(`invalid WHIP url ${url}`); + const hasAudio = options?.audio ?? true; + const useCamera = options?.camera ?? true; + const useScreen = options?.screen ?? false; + + if (!hasAudio && !useCamera && !useScreen) throw new Error(`The camera, screen and audio can't be false at the same time`); + + if (hasAudio) { + self.pc.addTransceiver("audio", {direction: "sendonly"}); + } else { + self.constraints.audio = false; + } + + if (useCamera || useScreen) { + self.pc.addTransceiver("video", {direction: "sendonly"}); + } + + if (!useCamera) { + self.constraints.video = false; + } + + if (!navigator.mediaDevices && window.location.protocol === 'http:' && window.location.hostname !== 'localhost') { + throw new SrsError('HttpsRequiredError', `Please use HTTPS or localhost to publish, read https://github.com/ossrs/srs/issues/2762#issuecomment-983147576`); + } + + if (useScreen) { + const displayStream = await navigator.mediaDevices.getDisplayMedia({ + video: true + }); + // @see https://developer.mozilla.org/en-US/docs/Web/API/RTCPeerConnection/addStream#Migrating_to_addTrack + displayStream.getTracks().forEach(function (track) { + self.pc.addTrack(track); + // Notify about local track when stream is ok. + self.ontrack && self.ontrack({track: track}); + }); + } + + if (useCamera || hasAudio) { + const userStream = await navigator.mediaDevices.getUserMedia(self.constraints); + + userStream.getTracks().forEach(function (track) { + self.pc.addTrack(track); + // Notify about local track when stream is ok. + self.ontrack && self.ontrack({track: track}); + }); + } + + var offer = await self.pc.createOffer(); + await self.pc.setLocalDescription(offer); + const answer = await new Promise(function (resolve, reject) { + console.log(`Generated offer: ${offer.sdp}`); + + const xhr = new XMLHttpRequest(); + xhr.onload = function() { + if (xhr.readyState !== xhr.DONE) return; + if (xhr.status !== 200 && xhr.status !== 201) return reject(xhr); + const data = xhr.responseText; + console.log("Got answer: ", data); + return data.code ? reject(xhr) : resolve(data); + } + xhr.open('POST', url, true); + xhr.setRequestHeader('Content-type', 'application/sdp'); + xhr.send(offer.sdp); + }); + await self.pc.setRemoteDescription( + new RTCSessionDescription({type: 'answer', sdp: answer}) + ); + + return self.__internal.parseId(url, offer.sdp, answer); + }; + + // See https://datatracker.ietf.org/doc/draft-ietf-wish-whip/ + // @url The WebRTC url to play with, for example: + // http://localhost:1985/rtc/v1/whep/?app=live&stream=livestream + // @options The options to control playing, supports: + // videoOnly: boolean, whether only play video, default to false. + // audioOnly: boolean, whether only play audio, default to false. + self.play = async function(url, options) { + if (url.indexOf('/whip-play/') === -1 && url.indexOf('/whep/') === -1) throw new Error(`invalid WHEP url ${url}`); + if (options?.videoOnly && options?.audioOnly) throw new Error(`The videoOnly and audioOnly in options can't be true at the same time`); + + if (!options?.videoOnly) self.pc.addTransceiver("audio", {direction: "recvonly"}); + if (!options?.audioOnly) self.pc.addTransceiver("video", {direction: "recvonly"}); + + var offer = await self.pc.createOffer(); + await self.pc.setLocalDescription(offer); + const answer = await new Promise(function(resolve, reject) { + console.log(`Generated offer: ${offer.sdp}`); + + const xhr = new XMLHttpRequest(); + xhr.onload = function() { + if (xhr.readyState !== xhr.DONE) return; + if (xhr.status !== 200 && xhr.status !== 201) return reject(xhr); + const data = xhr.responseText; + console.log("Got answer: ", data); + return data.code ? reject(xhr) : resolve(data); + } + xhr.open('POST', url, true); + xhr.setRequestHeader('Content-type', 'application/sdp'); + xhr.send(offer.sdp); + }); + await self.pc.setRemoteDescription( + new RTCSessionDescription({type: 'answer', sdp: answer}) + ); + + return self.__internal.parseId(url, offer.sdp, answer); + }; + + // Close the publisher. + self.close = function () { + self.pc && self.pc.close(); + self.pc = null; + }; + + // The callback when got local stream. + // @see https://developer.mozilla.org/en-US/docs/Web/API/RTCPeerConnection/addStream#Migrating_to_addTrack + self.ontrack = function (event) { + // Add track to stream of SDK. + self.stream.addTrack(event.track); + }; + + self.pc = new RTCPeerConnection(null); + + // To keep api consistent between player and publisher. + // @see https://developer.mozilla.org/en-US/docs/Web/API/RTCPeerConnection/addStream#Migrating_to_addTrack + // @see https://webrtc.org/getting-started/media-devices + self.stream = new MediaStream(); + + // Internal APIs. + self.__internal = { + parseId: (url, offer, answer) => { + let sessionid = offer.substr(offer.indexOf('a=ice-ufrag:') + 'a=ice-ufrag:'.length); + sessionid = sessionid.substr(0, sessionid.indexOf('\n') - 1) + ':'; + sessionid += answer.substr(answer.indexOf('a=ice-ufrag:') + 'a=ice-ufrag:'.length); + sessionid = sessionid.substr(0, sessionid.indexOf('\n')); + + const a = document.createElement("a"); + a.href = url; + return { + sessionid: sessionid, // Should be ice-ufrag of answer:offer. + simulator: a.protocol + '//' + a.host + '/rtc/v1/nack/', + }; + }, + }; + + // https://developer.mozilla.org/en-US/docs/Web/API/RTCPeerConnection/ontrack + self.pc.ontrack = function(event) { + if (self.ontrack) { + self.ontrack(event); + } + }; + + return self; +} + +// Format the codec of RTCRtpSender, kind(audio/video) is optional filter. +// https://developer.mozilla.org/en-US/docs/Web/Media/Formats/WebRTC_codecs#getting_the_supported_codecs +function SrsRtcFormatSenders(senders, kind) { + var codecs = []; + senders.forEach(function (sender) { + var params = sender.getParameters(); + params && params.codecs && params.codecs.forEach(function(c) { + if (kind && sender.track.kind !== kind) { + return; + } + + if (c.mimeType.indexOf('/red') > 0 || c.mimeType.indexOf('/rtx') > 0 || c.mimeType.indexOf('/fec') > 0) { + return; + } + + var s = ''; + + s += c.mimeType.replace('audio/', '').replace('video/', ''); + s += ', ' + c.clockRate + 'HZ'; + if (sender.track.kind === "audio") { + s += ', channels: ' + c.channels; + } + s += ', pt: ' + c.payloadType; + + codecs.push(s); + }); + }); + return codecs.join(", "); +} +export default SrsRtcPlayerAsync \ No newline at end of file diff --git a/src/router/routes.ts b/src/router/routes.ts index fddb68a..7cfbc73 100644 --- a/src/router/routes.ts +++ b/src/router/routes.ts @@ -67,12 +67,10 @@ export const routes = [ path: '/datav/sub2', component: () => import('@/views/datav/Sub2.vue'), }, - { path: '/401', component: () => import('@/views/error/401.vue'), }, - { path: '/datav/subOneGlobal', component: () => import('@/views/datav/subonedatav/SubOneGlobal.vue'), @@ -104,6 +102,7 @@ export const routes = [ + ]; export const INDEX_ROUTE_NAME = Symbol() diff --git a/src/views/datav/AuditSuper.vue b/src/views/datav/AuditSuper.vue index 4018f86..9f21c64 100644 --- a/src/views/datav/AuditSuper.vue +++ b/src/views/datav/AuditSuper.vue @@ -36,10 +36,7 @@ -
- - 2024年01月01日 - 2024年08月30日 -
+
{ - const myCaseVerifProTrend = caseVerifProTrend.value.chart; + const myCaseVerifProTrend = caseVerifProTrend?.value?.chart; if (!myCaseVerifProTrend) return; const randomNum = Math.floor(Math.random() * 12); myCaseVerifProTrend.dispatchAction({ diff --git a/src/views/datav/Gobal.vue b/src/views/datav/Gobal.vue index cafc943..cd9b311 100644 --- a/src/views/datav/Gobal.vue +++ b/src/views/datav/Gobal.vue @@ -169,9 +169,11 @@ const overview = ref({ auditPro: 0, }); // 中央的概况数据 const time = ref([ - moment().startOf("year").format("YYYY-MM-DD"), + moment().subtract(1, "year").format("YYYY-MM-DD"), moment().format("YYYY-MM-DD"), -]); // 时间范围 +]); + + const globalTempMapVoList = ref([ { "name": "天心分局", @@ -290,7 +292,6 @@ const option = ref({
  • 信访投诉问题 0000
  • 民意感知问题 0000
  • 审计督察问题 0000
  • -
    diff --git a/src/views/datav/MailVisits.vue b/src/views/datav/MailVisits.vue index 75f26af..f827077 100644 --- a/src/views/datav/MailVisits.vue +++ b/src/views/datav/MailVisits.vue @@ -402,7 +402,7 @@ const bwzdEntanglementMailList = ref([]); // 部委缠闹 const bwzdMassMailList = ref([]); // 部委集访 const time = ref([ - moment().startOf("year").format("YYYY-MM-DD"), + moment().subtract(1, "year").format("YYYY-MM-DD"), moment().format("YYYY-MM-DD"), ]); const currentYear = new Date().getFullYear(); diff --git a/src/views/datav/RightsComfort.vue b/src/views/datav/RightsComfort.vue index 0cf927a..bd625e5 100644 --- a/src/views/datav/RightsComfort.vue +++ b/src/views/datav/RightsComfort.vue @@ -227,7 +227,7 @@ import { // region 所有变量 const router = useRouter(); const time = ref([ - moment().startOf("year").format("YYYY-MM-DD"), + moment().subtract(1, "year").format("YYYY-MM-DD"), moment().format("YYYY-MM-DD"), ]); const fxsjRightsRank = ref([ diff --git a/src/views/datav/SceneInsp.vue b/src/views/datav/SceneInsp.vue index b85ddd4..fc51308 100644 --- a/src/views/datav/SceneInsp.vue +++ b/src/views/datav/SceneInsp.vue @@ -917,7 +917,7 @@ const currentYear = new Date().getFullYear(); const years = ref([currentYear.toString(), (currentYear - 1).toString(), (currentYear - 2).toString()]); // 年份列表 const selectedYear = ref(currentYear); // 当前选中的年份 const time = ref([ - moment().startOf("year").format("YYYY-MM-DD"), + moment().subtract(1, "year").format("YYYY-MM-DD"), moment().format("YYYY-MM-DD"), ]); diff --git a/src/views/datav/VideoInsp.vue b/src/views/datav/VideoInsp.vue index e99c4c8..ce6189a 100644 --- a/src/views/datav/VideoInsp.vue +++ b/src/views/datav/VideoInsp.vue @@ -5,7 +5,6 @@
    -
    @@ -114,6 +113,7 @@ style="height: 250px" :option="proTrend" autoresize + ref="videoProTrend" />
    @@ -204,7 +204,7 @@ import moment from "moment/moment.js"; // region 所有变量 const router = useRouter(); const time = ref([ - moment().startOf("year").format("YYYY-MM-DD"), + moment().subtract(1, "year").format("YYYY-MM-DD"), moment().format("YYYY-MM-DD"), ]); const proRankTab = ref("1"); @@ -232,8 +232,9 @@ const currentYear = new Date().getFullYear(); const years = ref([currentYear.toString(), (currentYear - 1).toString(), (currentYear - 2).toString()]); // 年份列表 const selectedYear = ref(currentYear); // 当前选中的年份 const videoMap = ref(null); +const videoProTrend=ref(null); let videoMapIntervalId; -let sceneInspTrendIntervalId; +let videoInspTrendIntervalId; const colors = [ { color: "linear-gradient( 270deg, #FB002D 0%, #822232 100%)", @@ -248,6 +249,7 @@ const colors = [ percentage: 40, }, ]; +const videoUrl = 'webrtc://47.121.143.167/live/livestream'; // endregion // region 所有图表 @@ -537,23 +539,24 @@ const videoMapAnimation = () => { // 启动定时器,每隔 2 秒执行一次 videoMapIntervalId = setInterval(videoMapAnimation, 2000); -const SceneInspTrendAnimation = () => { - const mySceneInspProTrend = sceneInspProTrend.value.chart; - if (!mySceneInspProTrend) return; +const videoInspTrendAnimation = () => { + const myVideoProTrend = videoProTrend?.value?.chart; + if (!myVideoProTrend) return; const randomNum = Math.floor(Math.random() * 12); - mySceneInspProTrend.dispatchAction({ + myVideoProTrend.dispatchAction({ type: 'showTip', seriesIndex: 0, dataIndex: randomNum, }); } -sceneInspTrendIntervalId = setInterval(SceneInspTrendAnimation, 2000); +videoInspTrendIntervalId = setInterval(videoInspTrendAnimation, 2000); onMounted(() => { getData(); proCardAnimation(); setupEventListeners(); + }) // endregion diff --git a/src/views/datav/subonedatav/SubOneAuditSuper.vue b/src/views/datav/subonedatav/SubOneAuditSuper.vue index 4018f86..3ca5445 100644 --- a/src/views/datav/subonedatav/SubOneAuditSuper.vue +++ b/src/views/datav/subonedatav/SubOneAuditSuper.vue @@ -36,10 +36,7 @@ -
    - - 2024年01月01日 - 2024年08月30日 -
    +
    { getSubOneStrongProblemRateData(currentDepartId, time.value); getSubOneProblemBusinessRateData(currentDepartId, time.value); getMapJSON(currentDepartId); - }; // 卡片动画 const cardAnimation = () => { @@ -515,7 +514,7 @@ watch(time, () => { getData(); }); const setupEventListeners = () => { - const mySubOneGlobalMap = subOneGlobalMap.value.chart; + const mySubOneGlobalMap = subOneGlobalMap?.value?.chart; // 鼠标移入 mySubOneGlobalMap.on('mousemove', (e) => { // console.log(e.dataIndex); @@ -534,8 +533,8 @@ const setupEventListeners = () => { const handleClick = (params) => { const departId = params.data.departId; show.value = true; - tempDepartId.value=departId - // clearInterval(subOneGlobalMapIntervalId); + tempDepartId.value=2661 + clearInterval(subOneGlobalMapIntervalId); // alert(departId) } diff --git a/src/views/datav/subonedatav/SubOneMailVisits.vue b/src/views/datav/subonedatav/SubOneMailVisits.vue index fc8e040..4ef8d50 100644 --- a/src/views/datav/subonedatav/SubOneMailVisits.vue +++ b/src/views/datav/subonedatav/SubOneMailVisits.vue @@ -417,7 +417,7 @@ const bwzdLeaderReviewMailList = ref([]); // 分局领导督察 const bwzdEntanglementMailList = ref([]); // 部委缠闹 const bwzdMassMailList = ref([]); // 部委集访 const time = ref([ - moment().startOf("year").format("YYYY-MM-DD"), + moment().subtract(1, "year").format("YYYY-MM-DD"), moment().format("YYYY-MM-DD"), ]); const currentYear = new Date().getFullYear(); diff --git a/src/views/datav/subonedatav/SubOneRightsComfort.vue b/src/views/datav/subonedatav/SubOneRightsComfort.vue index 6dd96bb..714b511 100644 --- a/src/views/datav/subonedatav/SubOneRightsComfort.vue +++ b/src/views/datav/subonedatav/SubOneRightsComfort.vue @@ -237,7 +237,7 @@ const currentMapData = ref({}) const chart = ref(null); // 地图 const currentDepartId = route.query.departId; const time = ref([ - moment().startOf("year").format("YYYY-MM-DD"), + moment().subtract(1, "year").format("YYYY-MM-DD"), moment().format("YYYY-MM-DD"), ]); const fxsjRightsRank = ref([ diff --git a/src/views/datav/subonedatav/SubOneSceneInsp.vue b/src/views/datav/subonedatav/SubOneSceneInsp.vue index 9d33334..313dd43 100644 --- a/src/views/datav/subonedatav/SubOneSceneInsp.vue +++ b/src/views/datav/subonedatav/SubOneSceneInsp.vue @@ -924,7 +924,7 @@ const subOneSceneInspMapChart = ref(null); // 地图 const route = useRoute(); const currentDepartId = route.query.departId; const time = ref([ - moment().startOf("year").format("YYYY-MM-DD"), + moment().subtract(1, "year").format("YYYY-MM-DD"), moment().format("YYYY-MM-DD"), ]); const colors = [ diff --git a/src/views/datav/subonedatav/SubOneVideoInsp.vue b/src/views/datav/subonedatav/SubOneVideoInsp.vue index eece118..d763b6b 100644 --- a/src/views/datav/subonedatav/SubOneVideoInsp.vue +++ b/src/views/datav/subonedatav/SubOneVideoInsp.vue @@ -203,7 +203,7 @@ import { } from "@/api/screen/subScreen/subOneVideoSupervise.ts"; // region 所有变量 const time = ref([ - moment().startOf("year").format("YYYY-MM-DD"), + moment().subtract(1, "year").format("YYYY-MM-DD"), moment().format("YYYY-MM-DD"), ]); const fxsjRankList = ref([]);