You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
1 line
7.0 KiB
JavaScript
1 line
7.0 KiB
JavaScript
(window["webpackJsonp"]=window["webpackJsonp"]||[]).push([["chunk-dfe57506"],{"0e85":function(e,t,n){"use strict";var i=n("7710"),c=n.n(i);c.a},7710:function(e,t,n){var i=n("7bdd");"string"===typeof i&&(i=[[e.i,i,""]]),i.locals&&(e.exports=i.locals);var c=n("499e").default;c("8761e2f0",i,!0,{sourceMap:!1,shadowMode:!1})},"7abc":function(e,t,n){"use strict";n("4160"),n("d3b7"),n("159b"),n("96cf");var i=n("1da1");function c(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}function s(e,t,n){return t&&o(e.prototype,t),n&&o(e,n),e}var r=n("ade3"),l=function(){function e(t,n){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};c(this,e),Object(r["a"])(this,"webrtc",null),Object(r["a"])(this,"video",null),Object(r["a"])(this,"server",null),Object(r["a"])(this,"codecLink",null),Object(r["a"])(this,"rsdpLink",null),Object(r["a"])(this,"stream",new MediaStream),Object(r["a"])(this,"uuid",null),Object(r["a"])(this,"options",{onStatusChange:null}),console.log("new uuid:"+n),this.server=e.server,this.video=t,this.uuid=n,Object.assign(this.options,i),this.createLinks(),this.play()}return s(e,[{key:"createLinks",value:function(){this.codecLink="//"+this.server+"/stream/codec/"+this.uuid,this.rsdpLink="//"+this.server+"/stream/receiver/"+this.uuid}},{key:"play",value:function(){var e=this;this.webrtc=new RTCPeerConnection({iceServers:[{urls:["stun:stun.l.google.com:19302"]}]}),this.webrtc||console.log("no"),this.webrtc.onnegotiationneeded=this.handleNegotiationNeeded.bind(this),this.webrtc.ontrack=this.onTrack.bind(this),fetch(this.codecLink).then((function(t){t.json().then((function(t){t.forEach((function(t,n){e.webrtc.addTransceiver(t.Type,{direction:"sendrecv"})}))}))})).catch((function(e){console.log(e)})),this.webrtc.onconnectionstatechange=function(){"connected"==e.webrtc.connectionState||"connecting"==e.webrtc.connectionState?console.log("uuid:"+e.uuid+" status:"+e.webrtc.connectionState):(console.log(e.webrtc.connectionState),e.load(e.uuid))}}},{key:"handleNegotiationNeeded",value:function(){var e=Object(i["a"])(regeneratorRuntime.mark((function e(){var t,n,i=this;return regeneratorRuntime.wrap((function(e){while(1)switch(e.prev=e.next){case 0:return e.next=2,this.webrtc.createOffer();case 2:return t=e.sent,e.next=5,this.webrtc.setLocalDescription(t);case 5:n=new FormData,n.append("suuid",this.uuid),n.append("data",btoa(this.webrtc.localDescription.sdp)),fetch(this.rsdpLink,{method:"POST",body:n}).then((function(e){e.text().then((function(e){i.webrtc.setRemoteDescription(new RTCSessionDescription({type:"answer",sdp:atob(e)}))}))})).catch((function(e){}));case 9:case"end":return e.stop()}}),e,this)})));function t(){return e.apply(this,arguments)}return t}()},{key:"onTrack",value:function(e){this.stream.addTrack(e.track),this.video.srcObject=this.stream,this.video.play()}},{key:"load",value:function(e){this.destroy(),this.uuid=e,this.createLinks(),this.play()}},{key:"destroy",value:function(){console.log("destroy uuid:"+this.uuid),this.webrtc.close(),this.webrtc=null,this.video.srcObject=null,this.stream=new MediaStream}},{key:"getImageUrl",value:function(){var e=document.createElement("canvas");e.width=this.video.videoWidth,e.height=this.video.videoHeight,e.getContext("2d").drawImage(video,0,0,e.width,e.height);var t=e.toDataURL();return e.remove(),t}}],[{key:"setServer",value:function(e){this.server=e}}]),e}();Object(r["a"])(l,"server","127.0.0.1:8083");t["a"]=l},"7bdd":function(e,t,n){var i=n("24fb");t=i(!1),t.push([e.i,"",""]),e.exports=t},"7e7c":function(e,t,n){"use strict";n.r(t);var i=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("div",{attrs:{id:"videos"}},[e.isFullscreen?e._e():n("a-button",{attrs:{type:"primary"},on:{click:e.full}},[e._v(" 全屏"),n("a-icon",{attrs:{type:"right"}})],1),e.isFullscreen?n("a-button",{attrs:{type:"primary"},on:{click:e.full}},[n("a-icon",{attrs:{type:"left"}}),e._v(" 退出全屏 ")],1):e._e(),e._l(e.row,(function(t){return n("a-row",{key:t},e._l(e.column,(function(i){return n("a-col",{key:i,style:{height:e.videoHeight},attrs:{span:24/e.column}},[n("video",{staticClass:"camera",style:{height:"100%",width:"100%","object-fit":"fill"},attrs:{id:t+"-"+i,autoplay:"",muted:"",controls:""},domProps:{muted:!0}})])})),1)}))],2)},c=[],o=n("7abc"),s={name:"top",components:{},props:{id:{type:String,default:function(){return""}}},data:function(){return{row:0,column:0,a:0,clientHeight:0,videoH:0,isFullscreen:!1,originHeight:0,fullHeight:0}},computed:{videoHeight:function(){return this.clientHeight/this.row+"px"}},mounted:function(){var e=this;this.getWallStyle(),this.$nextTick((function(){e.getAllCameras()}));var t=document.fullscreenElement||document.mozFullScreenElement||document.webkitFullscreenElement||document.fullScreen||document.mozFullScreen||document.webkitIsFullScreen;this.isFullscreen=!!t;var n=this;document.addEventListener("fullscreenchange",(function(){n.isFullscreen=!n.isFullscreen})),document.addEventListener("mozfullscreenchange",(function(){n.isFullscreen=!n.isFullscreen})),document.addEventListener("webkitfullscreenchange",(function(){n.isFullscreen=!n.isFullscreen})),document.addEventListener("msfullscreenchange",(function(){n.isFullscreen=!n.isFullscreen}))},methods:{getWallStyle:function(){var e=this;this.$api.httpApi.getWallStyle({data:{}}).then((function(t){200==t.code&&(e.row=t.data[0],e.column=t.data[1],e.getClientHeight(),sessionStorage.setItem("originHeight",e.clientHeight))})).catch((function(e){console.log(e)}))},getClientHeight:function(){this.clientHeight=this.$el.clientHeight-40,console.log("clientHeight:"+this.clientHeight)},getAllCameras:function(){var e=this;this.$api.httpApi.getAllCameras({data:{}}).then((function(t){if(200==t.code)for(var n=t.data,i=1;i<=n.length;i++){var c=Math.floor((i-1)/e.column)+1;if(c>e.row)return;var s=i%e.column;0==s&&(s=e.column);var r=c+"-"+s;console.log("idName:"+r);var l=document.getElementById(r),u=new o["a"](l,"camera"+n[i-1].id);u.play("camera"+n[i-1].id)}})).catch((function(e){console.log(e)}))},full:function(){this.isFullscreen?this.exitfullscreen():this.enterfullscreen()},enterfullscreen:function(){var e=this,t=document.getElementById("videos");t.requestFullscreen?t.requestFullscreen():t.mozRequestFullScreen?t.mozRequestFullScreen():t.webkitRequestFullScreen?t.webkitRequestFullScreen():elem.msRequestFullscreen&&elem.msRequestFullscreen(),this.$nextTick((function(){e.clientHeight=document.body.clientHeight,console.log("full:"+document.body.clientHeight)}))},exitfullscreen:function(){var e=this;console.log("tuichu"),document.exitFullscreen?document.exitFullscreen():document.mozCancelFullScreen?document.mozCancelFullScreen():document.webkitCancelFullScreen?document.webkitCancelFullScreen():document.msExitFullscreen&&document.msExitFullscreen(),this.$nextTick((function(){var t=sessionStorage.getItem("originHeight");t?e.clientHeight=t:e.getClientHeight()}))}}},r=s,l=(n("0e85"),n("2877")),u=Object(l["a"])(r,i,c,!1,null,null,null);t["default"]=u.exports}}]); |