content-75a4ceb8.js 26 KB

12
  1. import{bh as we,d as ye,aC as Se,c as V,r as te,Y as q,j as se,o as _e,cL as Ve,be,Z as R,a1 as Y,cI as Z,cJ as ee,n as _,T as y,cl as Te,a7 as K,ay as Ie,aV as Ee,bg as Pe,c9 as Le,at as $e,f as x,aI as De,h as W,Q as Ae,a0 as D,br as ie,a5 as H,bs as ae,$ as F,a9 as Q,a8 as J,a6 as re,aP as oe,a2 as Ne,a3 as Re,av as Oe,aJ as ne,cg as Me,cj as Ge,C as le,bb as ce}from"./index-8a67e3df.js";import"./dayjs-919e6097.js";import{W as We,a as de,A as ue,d as he,V as pe,e as Ue,F as ze,D as xe,f as me,C as Fe,b as X,g as Be,c as fe}from"./canvas-2aaf4e1d.js";import{m as He}from"./gb28181-a8ace5d9.js";import{A as Je}from"./index-f6e7ad63.js";const Ke=we({id:"screen-store",persist:{paths:["customInfo"]},state:()=>({curScreenNum:1,multiPlayRef:{webrtc:!1,streamList:[],updateItem:async(d,t)=>{},delItem:async d=>{},resetStreamList:async d=>{},resizeStreamList:async d=>{},closeAll:()=>{},preConnect:()=>Promise.resolve()},activeInfo:{parentId:"",deviceId:"",parentName:"",name:"",path:"",type:""},customInfo:{collapsed:!1,rowNum:1,screenNum:1,selectNum:0}}),getters:{getActiveInfo(){return this.activeInfo}},actions:{setCurScreenNum(d){this.curScreenNum=d},setMultiPlayRef(d){this.multiPlayRef=d},setActiveInfo(d){this.activeInfo=d},setCustomInfo(d){const t=Object.assign(this.customInfo,d);this.customInfo=t}}}),je={class:"video-container"},qe=["id","srcObject"],Qe=ye({__name:"batch",props:{path:{},format:{},stream:{},videoShadow:{},speed:{},pause:{type:Boolean},startTime:{}},emits:["postion","play"],setup(d,{emit:t}){const{t:e}=Se(),i=d;i.path,i.format,i.stream,new Date().toISOString();const a=t;let n,p=0,u=0;const I=V();let C,A;const T=V(),E=typeof VideoDecoder=="function",P=V();let $=null,O=null,r=null;function m(){return typeof WebAssembly>"u"?!1:WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,5,1,96,0,1,123,3,2,1,0,10,10,1,8,0,65,0,253,15,253,98,11]))}let l=null,h=null;const b=te(new We(""));let k=!1;q(()=>{I.value&&(I.value.addEventListener("playing",()=>{a("play",!0)}),I.value.addEventListener("pause",()=>{a("play","pause")}),I.value.addEventListener("ended",()=>{a("play","ended")}),I.value.addEventListener("error",()=>{a("play","error")}))});function M(w){const f=new w;return f.on(X.VideoCodecInfo,g=>{`${g.width}${g.height}`}),f.on(X.VideoFrame,g=>{A?A.write(g):$&&P.value&&(L.value=!1,$.writeVideo(g),g.close())}),f.on(X.Error,g=>{console.error(g),k=!1,l instanceof he&&(l=M(m()?Be:pe),l.initialize().then(()=>{r&&l&&l.configure({...r})}))}),f}function B(w){const f=new w;return f.on(fe.Error,g=>{console.error(g),f instanceof de&&(h=B(ue),h.initialize().then(()=>{O&&h&&h.configure({...O})}))}),f.on(fe.AudioFrame,g=>{C?C.write(g):$&&(L.value=!1,$.writeAudio(g))}),f}function U(){h?.close(),O=null}function z(){l?.close(),r=null}se(()=>{}),q(()=>{b.mediaStream&&(T.value=b.mediaStream)}),q(async()=>{if(i.path,i.format,i.stream,new Date().toISOString(),i.format==="ws-flv"&&i.path&&i.path.trim()!==""){i.path;try{n&&(i.path,U(),z(),await n.close()),i.path,h=B(E?de:ue),l=M(E?he:pe),await l.initialize(),await h.initialize(),n=new Ue(`${Pe("flv","","ws")}/${i.path}`),j(new ze(n,xe.PUSH)),await n.connect()}catch(w){Le.error({message:e("routes.screen.播放失败"),description:w instanceof Event?e("routes.screen.连接失败"):String(w)}),a("play","connect error")}}else i.format==="webrtc"?(i.stream&&(T.value=i.stream),n&&(U(),z(),await n.close(),n=null)):(i.path,i.format,n&&(U(),z(),await n.close(),n=null),T.value=void 0)});function j(w){if(E&&typeof MediaStreamTrackGenerator=="function"){const f=new MediaStreamTrackGenerator({kind:"audio"});C=f.writable.getWriter(),f.onmute=()=>{a("play","audio mute")};const g=new MediaStreamTrackGenerator({kind:"video"});A=g.writable.getWriter(),g.onmute=()=>{a("play","videomute")},T.value=new MediaStream([f,g])}w.on(me.VIDEO_ENCODER_CONFIG_CHANGED,f=>{r={...f},delete r.description,l&&l.state==="initialized"&&l.configure(r),!E&&P.value&&($=new Fe(P.value))}),w.on(me.AUDIO_ENCODER_CONFIG_CHANGED,f=>{O=f;try{h&&h.configure({...f})}catch(g){console.error(g)}}),w.gotVideo=f=>{try{if(!l||l.state!=="configured"){console.warn("Video decoder not configured yet, waiting...");return}if(!k&&f.type!=="key"){console.warn("Waiting for keyframe...");return}f.type==="key"&&(k||(k=!0)),l.decode(f),p=f.timestamp,i.startTime!==void 0&&i.startTime!==null&&a("postion",p-u+i.startTime)}catch(g){console.error(g,f)}},w.gotAudio=f=>{if(!h||h.state!=="configured"){console.warn("Audio decoder not configured yet, waiting...");return}h.decode(f)}}const L=V(!0);return _e(()=>{if(!E&&I.value){const w=document.createElement("canvas");w.style.width="100%",w.style.objectFit="cover",w.style.borderRadius="6px",i.videoShadow&&(w.style.boxShadow="4px 4px 8px 4px #dedede"),I.value.parentElement?.replaceChild(w,I.value),P.value=w}Ve(I.value,"canplay",()=>{L.value=!1}),i.path,i.format}),se(()=>{i.path,i.format}),be(()=>{i.path,i.format}),(w,f)=>(R(),Y("div",je,[Z(_(y(Te),{class:"loading",size:"large"},null,512),[[ee,L.value]]),K("video",{ref_key:"videoEle",ref:I,class:Ie(["video",{videoShadow:w.videoShadow}]),id:"video-"+w.path,srcObject:T.value,autoplay:"",playsinline:""},null,10,qe),Ee(w.$slots,"default",{},void 0,!0)]))}});const Xe=$e(Qe,[["__scopeId","data-v-04da3cf5"]]);class Ye{ws=null;pc=null;localStream=null;subscribedStreams=new Set;videoSenders=new Map;streamToTransceiver=new Map;eventListeners=new Map;wsUrl;pingInterval=null;constructor(t){const e=location.protocol==="https:"?"wss:":"ws:";this.wsUrl=t?`${e}//${t}/webrtc/batchv2`:`${e}//${location.host}/webrtc/batchv2`}async connect(){try{return this.log(`正在连接到 ${this.wsUrl}...`),this.ws=new WebSocket(this.wsUrl),new Promise((t,e)=>{if(!this.ws){e(new Error("WebSocket 未初始化"));return}this.ws.onopen=async()=>{this.log("WebSocket 连接已建立","success"),this.startPingInterval();const i={iceTransportPolicy:"all",bundlePolicy:"max-bundle",rtcpMuxPolicy:"require",iceCandidatePoolSize:1};this.pc=new RTCPeerConnection(i);const a=this.pc.addTransceiver("video",{direction:"sendrecv"});this.videoSenders.set("placeholder",a.sender),this.log("已向 PeerConnection 添加占位轨道","info"),this.setupPeerConnectionEventHandlers();const n=await this.pc.createOffer();await this.pc.setLocalDescription(n),this.sendMessage({type:"offer",sdp:this.pc.localDescription.sdp}),this.emit("connected",null),t()},this.ws.onmessage=this.handleWebSocketMessage.bind(this),this.ws.onclose=()=>{this.log("WebSocket 连接已关闭"),this.cleanup(),this.emit("disconnected",null),e(new Error("WebSocket 连接已关闭"))},this.ws.onerror=i=>{this.log(`WebSocket 错误: ${i}`,"error"),this.cleanup(),this.emit("error",{message:"WebSocket 错误"}),e(new Error("WebSocket 错误"))}})}catch(t){throw this.log(`连接错误: ${t.message}`,"error"),this.cleanup(),this.emit("error",{message:t.message}),t}}disconnect(){this.cleanup()}async startPublishing(t){try{if(!t)throw new Error("请输入有效的流路径");if(!this.pc||!this.ws)throw new Error("未连接到服务器");this.localStream=await navigator.mediaDevices.getUserMedia({video:!0,audio:!1});const e=this.localStream.getVideoTracks()[0],i=this.videoSenders.get("placeholder");i&&(await i.replaceTrack(e),this.log("已用真实轨道替换占位视频轨道","success")),this.videoSenders.delete("placeholder"),this.videoSenders.set(t,i);const a=await this.pc.createOffer();return await this.pc.setLocalDescription(a),await this.waitForIceGathering(),this.sendMessage({type:"publish",streamPath:t,offer:this.pc.localDescription.sdp}),this.log(`已开始发布到 ${t}`,"success"),this.emit("publishStarted",{streamPath:t}),Promise.resolve()}catch(e){throw this.log(`发布错误: ${e.message}`,"error"),this.emit("error",{message:e.message}),e}}async stopPublishing(t){try{if(!this.pc||!this.ws)throw new Error("未连接到服务器");const e=this.videoSenders.get(t);e&&(await e.replaceTrack(null),this.log("已移除视频轨道","info"),this.videoSenders.delete(t),this.videoSenders.set("placeholder",e)),this.localStream&&(this.localStream.getTracks().forEach(a=>a.stop()),this.localStream=null);const i=await this.pc.createOffer();return await this.pc.setLocalDescription(i),await this.waitForIceGathering(),this.sendMessage({type:"unpublish",streamPath:t}),this.log(`已停止发布到 ${t}`,"success"),this.emit("publishStopped",{streamPath:t}),Promise.resolve()}catch(e){throw this.log(`停止发布错误: ${e.message}`,"error"),this.emit("error",{message:e.message}),e}}getStreamList(){if(!this.ws){this.log("未连接到服务器","error");return}this.sendMessage({type:"getStreamList"}),this.log("已请求流列表","info")}async subscribeToStreams(t){try{if(!this.pc||!this.ws)throw new Error("未连接到服务器");if(t.length===0)throw new Error("请至少选择一个流");const e=new Set(this.subscribedStreams);this.subscribedStreams.clear(),t.forEach(n=>{n&&this.subscribedStreams.add(n)});const i=[];e.forEach(n=>{if(!this.subscribedStreams.has(n)){const p=this.streamToTransceiver.get(n);p&&(p.direction="inactive",this.log(`已将移除流 ${n} 的转接器设置为 inactive`,"info"),this.streamToTransceiver.delete(n)),i.push(n),this.emit("streamRemoved",{streamPath:n})}}),i.length>0&&await this.sendUnsubscribeSignal(i);const a=Array.from(this.subscribedStreams).filter(n=>!e.has(n));if(this.log(`新流路径: ${a.join(", ")}`,"info"),a.length>0){const n=this.pc.getTransceivers().filter(C=>C.direction==="inactive");this.log(`可用转接器数量: ${n.length}`,"info");const p=[...a];for(;p.length>0&&n.length>0;)p.pop(),n.pop().direction="recvonly";const u=p.length;if(u>0){this.log(`添加 ${u} 个新视频转接器`,"info");for(let C=0;C<u;C++)this.pc.addTransceiver("video",{direction:"recvonly"})}const I=await this.pc.createOffer();await this.pc.setLocalDescription(I),this.sendMessage({type:"subscribe",streamList:a,offer:this.pc.localDescription.sdp}),this.log(`订阅了 ${a.length} 个新流`,"success")}return this.log(`当前播放流总数: ${this.subscribedStreams.size}`,"success"),Promise.resolve()}catch(e){throw this.log(`播放流错误: ${e.message}`,"error"),this.emit("error",{message:e.message}),e}}async sendUnsubscribeSignal(t){if(!this.ws||!this.pc){this.log("未连接到服务器","error");return}if(t.length!==0)try{const e=await this.pc.createOffer();await this.pc.setLocalDescription(e),await this.waitForIceGathering(),this.sendMessage({type:"unsubscribe",streamList:t,offer:this.pc.localDescription.sdp}),this.log(`已为 ${t.length} 个流发送取消订阅信号`,"info")}catch(e){throw this.log(`发送取消订阅信号错误: ${e.message}`,"error"),e}}async unsubscribeFromStream(t){try{if(!this.pc||!this.ws)throw new Error("未连接到服务器");const e=this.streamToTransceiver.get(t);return e&&(e.direction="inactive",this.log(`已将 ${t} 的转接器设置为 inactive`,"info"),this.streamToTransceiver.delete(t),await this.sendUnsubscribeSignal([t])),this.subscribedStreams.delete(t),this.emit("streamRemoved",{streamPath:t}),this.log(`已从订阅列表移除 ${t}`,"info"),Promise.resolve()}catch(e){throw this.log(`取消订阅流错误: ${e.message}`,"error"),this.emit("error",{message:e.message}),e}}getLocalStream(){return this.localStream}getSubscribedStreams(){return Array.from(this.subscribedStreams)}on(t,e){this.eventListeners.has(t)||this.eventListeners.set(t,[]),this.eventListeners.get(t).push(e)}off(t,e){if(!this.eventListeners.has(t))return;const i=this.eventListeners.get(t),a=i.indexOf(e);a!==-1&&i.splice(a,1)}emit(t,e){if(!this.eventListeners.has(t))return;const i=this.eventListeners.get(t);for(const a of i)a(e)}log(t,e="info"){this.emit("log",{message:t,level:e,time:new Date})}setupPeerConnectionEventHandlers(){this.pc&&(this.pc.onicecandidate=t=>{t.candidate?this.log("ICE 候选: "+t.candidate.candidate):this.log("ICE 收集完成")},this.pc.onicegatheringstatechange=()=>{this.log(`ICE 收集状态: ${this.pc.iceGatheringState}`),this.emit("iceStateChange",{state:this.pc.iceGatheringState})},this.pc.oniceconnectionstatechange=()=>{this.log(`ICE 连接状态: ${this.pc.iceConnectionState}`),this.emit("iceStateChange",{state:this.pc.iceConnectionState}),this.pc.iceConnectionState==="failed"&&this.log("ICE 连接失败","error")},this.pc.onconnectionstatechange=()=>{this.log(`连接状态已变更: ${this.pc.connectionState}`),this.emit("connectionStateChange",{state:this.pc.connectionState}),this.pc.connectionState==="connected"&&this.log("PeerConnection 建立成功","success")},this.pc.ontrack=this.handleTrackEvent.bind(this))}handleTrackEvent(t){this.log(`收到轨道: ${t.track.kind}/${t.track.id}`,"success");const e=t.transceiver;e||this.log(`未找到轨道 ${t.track.id} 的转接器`,"warn");const i={};t.track.onunmute=()=>{this.log(`轨道已 unmute: ${t.track.kind}/${t.track.id}`,"success")};const a=setInterval(async()=>{if(!this.pc||this.pc.connectionState!=="connected"){this.log("连接状态变更,停止统计收集","info"),clearInterval(a);return}try{(await this.pc.getStats(t.track)).forEach(p=>{if(p.type==="inbound-rtp"&&p.kind===t.track.kind){const u=p.packetsReceived||0;(i[t.track.id]||0)!==u&&(i[t.track.id]=u)}})}catch(n){this.log(`获取统计信息错误: ${n.message}`,"error")}},5e3);if(t.track.kind==="video"&&t.streams[0]){const n=t.streams[0].id;this.streamToTransceiver.set(n,e),this.emit("streamAdded",{streamId:n,stream:t.streams[0],track:t.track})}}async handleWebSocketMessage(t){const e=JSON.parse(t.data);if(this.log(`收到消息: ${e.type}`),"type"in e)switch(e.type){case"pong":this.log("收到 pong 响应","debug");break;case"answer":const i=new RTCSessionDescription({type:"answer",sdp:e.sdp});await this.pc.setRemoteDescription(i),this.log("远端描述已设置","success");break;case"error":this.log(`错误: ${e.message}`,"error"),this.emit("error",{message:e.message});break;case"streamList":this.log(`收到流列表,共 ${e.streams.length} 个流`,"info"),this.emit("streamList",{streams:e.streams});break}}sendMessage(t){if(!this.ws){this.log("未连接到服务器","error");return}this.ws.send(JSON.stringify(t))}async waitForIceGathering(t=2e3){return this.pc?Promise.race([new Promise(e=>{if(this.pc.iceGatheringState==="complete")e();else{const i=()=>{this.pc.iceGatheringState==="complete"&&(this.pc.removeEventListener("icegatheringstatechange",i),e())};this.pc.addEventListener("icegatheringstatechange",i)}}),new Promise(e=>setTimeout(e,t))]):Promise.reject(new Error("PeerConnection 未初始化"))}startPingInterval(){this.stopPingInterval(),this.pingInterval=setInterval(()=>{this.sendPing()},5e3),this.log("已启动 ping 定时器","debug")}stopPingInterval(){this.pingInterval&&(clearInterval(this.pingInterval),this.pingInterval=null,this.log("已停止 ping 定时器","debug"))}sendPing(){this.ws&&this.ws.readyState===WebSocket.OPEN&&(this.sendMessage({type:"ping"}),this.log("已发送 ping 消息","debug"))}cleanup(){this.stopPingInterval(),this.ws&&(this.ws.close(),this.ws=null),this.pc&&(this.pc.close(),this.pc=null),this.localStream&&(this.localStream.getTracks().forEach(t=>t.stop()),this.localStream=null),this.subscribedStreams.clear(),this.videoSenders.clear(),this.streamToTransceiver.clear(),this.log("连接已清理","info")}}function ge(d=!1,t="webrtc"){const e=te([]),i=V([]);let a=null;const n=()=>e.map(r=>r.path),p=async()=>{if(t!=="ws-flv"&&a)try{await a.subscribeToStreams(n()),`${n().length}`}catch{}},u=async()=>{t!=="ws-flv"&&await C()},I=function(r){let m=String(r.getMilliseconds());return"padStart"in String.prototype&&(m=m.toString().padStart(3,"0")),`${r.toTimeString().replace(/.*(\d{2}:\d{2}:\d{2}).*/,"$1")}:${m}`},C=async()=>new Promise(async r=>{if(a)return r();const m=window.allEnv.media.startsWith(":")?`${location.protocol}//${location.hostname}${window.allEnv.media}`:window.allEnv.media;a=new Ye(m.startsWith("http")?m.replace("http://","").replace("https://",""):location.host+m),a.on("log",l=>console[["info","debug","warn","error"].indexOf(l.level)!==-1?l.level:"info"](I(l.time),l.message)),a.on("error",l=>console.log(`客户端错误: ${l.message}`)),a.on("connected",()=>{r()}),a.on("disconnected",()=>{a=null;const l=e.length;e.length=0,e.push(...new Array(l).fill(0).map(()=>({path:"",stream:void 0}))),i.value.length=0}),a.on("publishStarted",l=>{`${l.streamPath}`}),a.on("publishStopped",l=>{`${l.streamPath}`}),a.on("streamList",l=>{`${l.streams.length}`,l.streams.length===0&&(e.length=0)}),a.on("streamAdded",l=>{`${l.streamId}`,e.some(b=>b.path===l.streamId)&&(i.value.push({id:l.streamId,stream:l.stream}),P())}),a.on("streamRemoved",l=>{`${l.streamId}`});try{await a.connect()}catch{a=null}}),A=async({deviceItem:r,streamItem:m,path:l},h)=>{if(t==="ws-flv"){if(h>=0&&h<e.length){const b={path:l};if(d&&r){if(!r.parentId||!r.deviceId){console.error("GB28181设备信息不完整,无法更新流");return}b.deviceItem=r}else m&&(b.streamItem=m);e[h]={...b}}return}if(d&&r){if(!r.parentId||!r.deviceId){console.error("GB28181设备信息不完整,无法更新流");return}e[h].path=l,e[h].deviceItem=r}else m&&(e[h].path=l,e[h].streamItem=m);if(a||await u(),!i.value.some(b=>l===b.id)){await p();return}},T=async r=>{if(t==="ws-flv"){r>=0&&r<e.length&&(e[r]={path:"",deviceItem:d?{}:void 0,streamItem:d?void 0:{},stream:void 0});return}e[r].path="",delete e[r].deviceItem,delete e[r].streamItem,delete e[r].stream,await p()},E=async r=>{e.length,JSON.stringify(e,null,2);const m=e.length;if(r>m){const l=new Array(r-m).fill({}).map((h,b)=>d?{path:"",deviceItem:{},stream:void 0}:{path:"",streamItem:{},stream:void 0});e.push(...l)}else r<m&&e.splice(r).forEach((h,b)=>{h.stream&&h.path,h.path="",h.stream=void 0,d?h.deviceItem={}:h.streamItem={}});JSON.stringify(e,null,2),t==="webrtc"&&await p()},P=()=>{e.forEach(r=>{r.stream=i.value.find(m=>m.id===r.path)?.stream})};return{webrtc:t==="webrtc",streamList:e,updateItem:A,delItem:T,resetStreamList:async r=>{JSON.stringify(r,null,2),e.length=0,e.push(...r),t==="webrtc"&&(i.value.length=0,await p())},resizeStreamList:E,closeAll:()=>{if(t==="ws-flv"){e.forEach((r,m)=>{e[m]=d?{path:"",deviceItem:{},stream:void 0}:{path:"",streamItem:{},stream:void 0}});return}a&&(a.disconnect(),a=null,e.length=0,i.value.length=0)},preConnect:u}}const Ze=we({id:"app-group-store",state:()=>({groupTree:[],selectedChannel:[],curPlayGroupId:-2}),actions:{setCurPlayGroupId(d){this.curPlayGroupId=d},setGroupTree(d){this.groupTree=d},setSelChannel(d){this.selectedChannel=d},async fetchGroupTree(){const{data:d}=await He(-1),t=Ce(d);this.setGroupTree(t)}}});function Ce(d){return d.map(t=>{const e=Ce(t.children),i=t.channels.map(n=>({...n,key:`${n?.channelId}_${n?.deviceId}_${n.id}`,disabled:n.status==="OFF",isChannel:!0})),a=[...e.map(n=>({...n})),...i];return{...t,key:`${t?.key||t.id}`,children:a}})}const et={class:"screen-container"},tt={class:"flex items-center gap-2 mb-2"},st={class:"text-center"},it={class:"video-player-placeholder"},ve=16,at=ye({__name:"content",props:{type:{default:"device"}},setup(d){const{t}=Se(),e=V("ws-flv"),i=V(!1),a=d,n=Ze(),p=Ke(),u=x({get:()=>p.curScreenNum,set:c=>p.setCurScreenNum(c)}),I=x(()=>[{label:t("routes.screen.单屏"),value:1},{label:t("routes.screen.四分屏"),value:4},{label:t("routes.screen.九分屏"),value:9},{label:t("routes.screen.十六分屏"),value:16}]),C=x(()=>{switch(u.value){case 1:return 24;case 4:return 12;case 9:return 8;case 16:return 6;default:return 24}}),A=()=>document.querySelector(".screen-list"),T=V(),{toggle:E,isFullscreen:P}=De(T),$=V(!1),O=()=>{try{if($.value=!1,typeof RTCRtpReceiver<"u"&&RTCRtpReceiver.getCapabilities){const c=RTCRtpReceiver.getCapabilities("video");c&&c.codecs&&c.codecs.some(s=>s.mimeType.toLowerCase().includes("h265")||s.mimeType.toLowerCase().includes("hevc"))||($.value=!0)}else $.value=!0}catch(c){console.warn("检测 H265 支持时发生错误:",c),$.value=!0}},r=V(ge(a.type==="device","webrtc")),m=V(ge(a.type==="device","ws-flv")),l=async c=>{const o=new Array(u.value||1).fill({}).map(()=>a.type==="device"?{path:"",deviceItem:{},stream:void 0}:{path:"",streamItem:{},stream:void 0});await c.resetStreamList(o)};(async()=>{await Promise.all([l(r.value),l(m.value)])})();const b=x(()=>p.multiPlayRef),k=x(()=>p.multiPlayRef.streamList);W(k,(c,o)=>{if(e.value,c.length,o?.length,JSON.stringify(c,null,2),o&&(c.forEach((s,v)=>{const S=o[v];S?s.path!==S.path&&`${v}${S.path||"(空)"}${s.path||"(空)"}`:(`${v}`,s.path)}),o.length>c.length))for(let s=c.length;s<o.length;s++)`${s}`,o[s].path},{deep:!0,immediate:!1});const M=V(Array.from({length:ve},(c,o)=>({path:"",deviceItem:{},streamItem:{},stream:void 0,idx:o,isValid:!1,isVisible:!1,slotKey:`fixed-slot-${o}`,colSpanValue:24/1}))),B=()=>{u.value,e.value,JSON.stringify(k.value,null,2);const c=C.value;for(let o=0;o<ve;o++){const s=M.value[o],v=k.value[o],S=o<u.value;v&&"path"in v&&S?(s.path=v.path||"",s.deviceItem=v.deviceItem||{},s.streamItem=v.streamItem||{},s.stream=v.stream,s.isValid=!!(v.path&&v.path.trim().length>0),s.isVisible=!0):(s.path="",s.deviceItem={},s.streamItem={},s.stream=void 0,s.isValid=!1,s.isVisible=S),s.colSpanValue=c}M.value.slice(0,u.value).forEach((o,s)=>{`${s}${o.path||"(空)"}${o.isValid}${o.isVisible}${o.slotKey}`})};W([k,u,e,C],()=>{B()},{immediate:!0,deep:!0}),W(M,(c,o)=>{c.length,o?.length;const s=c.filter(S=>S.isVisible),v=o?.filter(S=>S.isVisible)||[];if(s.forEach((S,N)=>{const G=v[N];G?S.path!==G.path?`${N}${G.path||"(空)"}${S.path||"(空)"}`:S.isValid!==G.isValid&&`${N}${G.isValid}${S.isValid}`:(`${N}`,S.path)}),v.length>s.length)for(let S=s.length;S<v.length;S++)`${S}`,v[S].path},{deep:!0,immediate:!1});const U=(c,o)=>(`${e.value}${o}`,b.value.updateItem(c,o)),z=async c=>(`${e.value}`,await b.value.resetStreamList(c)),j=()=>{`${e.value}`,b.value.closeAll()},L=te({selectNum:1});W(u,async(c,o)=>{e.value,i.value=!0,L.selectNum=0;let s=[];if(s=[...b.value.streamList],JSON.stringify(s,null,2),a.type==="device"?(p.setActiveInfo({parentId:"",parentName:"",deviceId:"",name:""}),n.setCurPlayGroupId(-2)):p.setActiveInfo({path:"",type:""}),e.value==="webrtc"){const v=new Array(u.value).fill({}).map(()=>a.type==="device"?{path:"",deviceItem:{},stream:void 0}:{path:"",streamItem:{},stream:void 0});await z(v)}else{s.length>0&&await b.value.resetStreamList(s);const v=b.value.streamList.length;await le(),await b.value.resizeStreamList(u.value),u.value<v&&await le()}i.value=!1},{immediate:!0});let w=!1;const f=(c,o)=>{if(L.selectNum=o,a.type!=="stream"&&a.type==="device"&&c.deviceItem&&"deviceId"in c.deviceItem){const s=c.deviceItem;p.setActiveInfo({parentId:s.parentId??"",deviceId:s.deviceId??"",parentName:s.parentName??"",name:s.name??""}),w=!0}};be(()=>j());const{getActiveInfo:g}=Ae(p);return W([()=>g.value.deviceId,()=>g.value.parentId],([c,o],[s,v])=>{if(i.value)return;const S=`${v}/${s}`,N=`${o}/${c}`;if(a.type==="device"&&N!==S){const G=g.value;if(k.value.some(ke=>ke.path===N)&&!w)return ce.warn(t("routes.screen.当前设备已在分屏中"));U({path:N,deviceItem:G},L.selectNum)}w=!1},{immediate:!0}),W(()=>g.value.path,c=>{if(i.value)return;const o=g.value;if(a.type==="stream"&&c){if(k.value.some(s=>s.path===o.path))return ce.warn(t("routes.screen.当前流已在分屏中"));U({path:o.path,streamItem:o},L.selectNum)}}),W(e,async(c,o)=>{n.setCurPlayGroupId(-2);const s=[...b.value.streamList];JSON.stringify(s,null,2),c==="ws-flv"?(p.setMultiPlayRef(m.value),r.value.closeAll(),$.value=!1,m.value.streamList.length!==u.value&&await m.value.resizeStreamList(u.value),s.length>0&&await m.value.resetStreamList(s)):c==="webrtc"&&(p.setMultiPlayRef(r.value),O(),m.value.closeAll(),r.value.streamList.length!==u.value&&await r.value.resizeStreamList(u.value),s.length>0&&await r.value.resetStreamList(s))},{immediate:!0}),(c,o)=>(R(),Y("div",et,[K("div",tt,[_(y(ae),{value:e.value,"onUpdate:value":o[0]||(o[0]=s=>e.value=s),size:"small"},{default:D(()=>[_(y(ie),{value:"ws-flv"},{default:D(()=>o[3]||(o[3]=[H("WS-FLV")])),_:1}),_(y(ie),{value:"webrtc"},{default:D(()=>o[4]||(o[4]=[H("WebRTC")])),_:1})]),_:1},8,["value"])]),K("div",st,[$.value&&e.value==="webrtc"?(R(),F(y(Je),{key:0,type:"warning",message:y(t)("routes.screen.H265不支持警告"),description:y(t)("routes.screen.H265不支持描述"),"show-icon":"",closable:"",class:"mb-12px",onClose:o[1]||(o[1]=s=>$.value=!1)},null,8,["message","description"])):Q("",!0),_(y(ae),{value:u.value,"onUpdate:value":o[2]||(o[2]=s=>u.value=s),buttonStyle:"solid",options:I.value,optionType:"button"},null,8,["value","options"]),_(y(oe),{onClick:y(E)},{default:D(()=>[_(y(J),{icon:"ant-design:fullscreen-outlined",class:"v-text-bottom"}),H(re(y(t)("routes.screen.全屏")),1)]),_:1},8,["onClick"]),_(y(Ge),{gutter:4,class:"screen-list mt-10px",ref_key:"screenRef",ref:T},{default:D(()=>[y(P)?(R(),F(y(oe),{key:0,onClick:y(E),type:"link",class:"absolute right-2 top-2 z-10 text-white"},{default:D(()=>[_(y(J),{icon:"ant-design:fullscreen-exit-outlined",class:"v-text-bottom"}),H(" "+re(y(t)("routes.screen.退出全屏")),1)]),_:1},8,["onClick"])):Q("",!0),(R(!0),Y(Ne,null,Re(M.value,s=>Z((R(),F(y(Me),{key:s.slotKey,span:s.colSpanValue,class:Ie(["mt-4px flex-center",{active:u.value>1&&L.selectNum===s.idx&&!y(P),isFullscreen:y(P)}]),onClick:()=>{s.idx,s.path,f({path:s.path,deviceItem:s.deviceItem,streamItem:s.streamItem,stream:s.stream},s.idx)}},{default:D(()=>[(R(),F(Xe,{key:s.slotKey,path:s.isValid?s.path:"",format:e.value,stream:s.stream,style:Oe({display:s.isValid?"block":"none"}),onVnodeBeforeCreate:v=>console.log("🚀 VideoPlayer beforeCreate:",s.path,"key:",s.slotKey,"isValid:",s.isValid),onVnodeCreated:v=>console.log("✅ VideoPlayer created:",s.path,"key:",s.slotKey,"isValid:",s.isValid),onVnodeBeforeUnmount:v=>console.log("💀 VideoPlayer beforeUnmount:",s.path,"key:",s.slotKey,"isValid:",s.isValid),onVnodeUnmounted:v=>console.log("🗑️ VideoPlayer unmounted:",s.path,"key:",s.slotKey,"isValid:",s.isValid)},{default:D(()=>[s.path?(R(),F(y(ne),{key:0,class:"position-absolute bottom-0 left-50% cursor-pointer",title:s.path,getPopupContainer:A},{default:D(()=>[_(y(J),{icon:"octicon:ellipsis-16",size:20,color:"#dedede",hoverColor:"#a275d9"})]),_:2},1032,["title"])):Q("",!0)]),_:2},1032,["path","format","stream","style","onVnodeBeforeCreate","onVnodeCreated","onVnodeBeforeUnmount","onVnodeUnmounted"])),Z(K("div",it,[_(y(ne),{title:y(t)("routes.screen.当前无信号"),class:"no-stream-tip cursor-pointer",getPopupContainer:A,placement:"top"},{default:D(()=>[_(y(J),{icon:"pepicons-pop:television-play-off",size:u.value===1?50:24},null,8,["size"])]),_:1},8,["title"])],512),[[ee,!s.isValid]])]),_:2},1032,["span","class","onClick"])),[[ee,s.isVisible]])),128))]),_:1},512)])]))}});const dt=$e(at,[["__scopeId","data-v-dd7ef243"]]);export{dt as C,Ze as a,Ke as u};
  2. //# sourceMappingURL=content-75a4ceb8.js.map