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
9.5 KiB
JavaScript

(window["webpackJsonp"]=window["webpackJsonp"]||[]).push([["chunk-9009cff0"],{"7abc":function(t,e,n){"use strict";n("4160"),n("d3b7"),n("159b"),n("96cf");var i=n("1da1");function a(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function r(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}function o(t,e,n){return e&&r(t.prototype,e),n&&r(t,n),t}var c=n("ade3"),s=function(){function t(e,n){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};a(this,t),Object(c["a"])(this,"webrtc",null),Object(c["a"])(this,"video",null),Object(c["a"])(this,"server",null),Object(c["a"])(this,"codecLink",null),Object(c["a"])(this,"rsdpLink",null),Object(c["a"])(this,"stream",new MediaStream),Object(c["a"])(this,"uuid",null),Object(c["a"])(this,"options",{onStatusChange:null}),console.log("new uuid:"+n),this.server=t.server,this.video=e,this.uuid=n,Object.assign(this.options,i),this.createLinks(),this.play()}return o(t,[{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 t=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(e){e.json().then((function(e){e.forEach((function(e,n){t.webrtc.addTransceiver(e.Type,{direction:"sendrecv"})}))}))})).catch((function(t){console.log(t)})),this.webrtc.onconnectionstatechange=function(){"connected"==t.webrtc.connectionState||"connecting"==t.webrtc.connectionState?console.log("uuid:"+t.uuid+" status:"+t.webrtc.connectionState):(console.log(t.webrtc.connectionState),t.load(t.uuid))}}},{key:"handleNegotiationNeeded",value:function(){var t=Object(i["a"])(regeneratorRuntime.mark((function t(){var e,n,i=this;return regeneratorRuntime.wrap((function(t){while(1)switch(t.prev=t.next){case 0:return t.next=2,this.webrtc.createOffer();case 2:return e=t.sent,t.next=5,this.webrtc.setLocalDescription(e);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(t){t.text().then((function(t){i.webrtc.setRemoteDescription(new RTCSessionDescription({type:"answer",sdp:atob(t)}))}))})).catch((function(t){}));case 9:case"end":return t.stop()}}),t,this)})));function e(){return t.apply(this,arguments)}return e}()},{key:"onTrack",value:function(t){this.stream.addTrack(t.track),this.video.srcObject=this.stream,this.video.play()}},{key:"load",value:function(t){this.destroy(),this.uuid=t,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 t=document.createElement("canvas");t.width=this.video.videoWidth,t.height=this.video.videoHeight,t.getContext("2d").drawImage(video,0,0,t.width,t.height);var e=t.toDataURL();return t.remove(),e}}],[{key:"setServer",value:function(t){this.server=t}}]),t}();Object(c["a"])(s,"server","127.0.0.1:8083");e["a"]=s},a630:function(t,e,n){var i=n("23e7"),a=n("4df4"),r=n("1c7e"),o=!r((function(t){Array.from(t)}));i({target:"Array",stat:!0,forced:o},{from:a})},b85c:function(t,e,n){"use strict";n.d(e,"a",(function(){return r}));n("a4d3"),n("e01a"),n("d28b"),n("d3b7"),n("3ca3"),n("ddb0"),n("a630"),n("fb6a"),n("b0c0"),n("25f0");function i(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,i=new Array(e);n<e;n++)i[n]=t[n];return i}function a(t,e){if(t){if("string"===typeof t)return i(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?i(t,e):void 0}}function r(t,e){var n;if("undefined"===typeof Symbol||null==t[Symbol.iterator]){if(Array.isArray(t)||(n=a(t))||e&&t&&"number"===typeof t.length){n&&(t=n);var i=0,r=function(){};return{s:r,n:function(){return i>=t.length?{done:!0}:{done:!1,value:t[i++]}},e:function(t){throw t},f:r}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,c=!0,s=!1;return{s:function(){n=t[Symbol.iterator]()},n:function(){var t=n.next();return c=t.done,t},e:function(t){s=!0,o=t},f:function(){try{c||null==n["return"]||n["return"]()}finally{if(s)throw o}}}}},bc49:function(t,e,n){var i=n("24fb");e=i(!1),e.push([t.i,".alarm .ant-form-item-label[data-v-6b545f28]{text-align:left}.realTime[data-v-6b545f28]{padding:10px}",""]),t.exports=e},bf80:function(t,e,n){var i=n("bc49");"string"===typeof i&&(i=[[t.i,i,""]]),i.locals&&(t.exports=i.locals);var a=n("499e").default;a("c287a55c",i,!0,{sourceMap:!1,shadowMode:!1})},d28b:function(t,e,n){var i=n("746f");i("iterator")},d7ad:function(t,e,n){"use strict";n.r(e);var i=function(){var t=this,e=t.$createElement,n=t._self._c||e;return n("div",{staticClass:"realTime bg-white"},[n("a-tabs",{attrs:{slot:"headerContent","default-active-key":"1","padding:10px":""},on:{change:t.tabsChange},slot:"headerContent",model:{value:t.tabKey,callback:function(e){t.tabKey=e},expression:"tabKey"}},t._l(t.realTimeListData,(function(t){return n("a-tab-pane",{key:t.streetId.toString(),attrs:{tab:t.streetName}})})),1),n("a-row",{attrs:{gutter:20}},t._l(t.cameras.slice(0,t.selectTab.videoStyleRow*t.selectTab.videoStyleColumn),(function(e,i){return n("a-col",{key:i,style:{height:t.videoHeight,marginBottom:t.selectTab.videoStyleRow*t.selectTab.videoStyleColumn-i-1>=t.selectTab.videoStyleColumn?"20px":0},attrs:{span:24/t.selectTab.videoStyleColumn}},[n("video",{style:{height:t.videoHeight},attrs:{id:"camera"+e.id,autoplay:"",muted:""},domProps:{muted:!0}})])})),1)],1)},a=[],r=(n("4de4"),n("d3b7"),n("25f0"),n("b85c")),o=n("7abc"),c={name:"realTimeMonitoring",components:{},data:function(){return{realTimeListData:[],url:"722e6f04-bb3c-34b1-bcc7-ae9f6cd72e68",tabKey:"0",path:[],player:"",visible:!1,modelData:[],clientHeight:0,players:[]}},computed:{selectTab:function(){var t=this;return this.realTimeListData.filter((function(e){return e.streetId==t.tabKey}))[0]||{}},cameras:function(){return this.selectTab.cameras||[]},videoHeight:function(){return this.clientHeight/this.selectTab.videoStyleRow+"px"}},mounted:function(){this.getClientHeight(),this.setVideoServer(),this.getRealTimeList(),this.tabKey=sessionStorage.getItem("tabKey")},destroyed:function(){this.destory()},methods:{getClientHeight:function(){this.clientHeight=this.$el.clientHeight-80},getRealTimeList:function(){var t=this;this.$api.httpApi.getRealTimeList({data:{}}).then((function(e){200==e.code&&(t.realTimeListData=e.data.reverse(),null==sessionStorage.getItem("tabKey")&&(console.log("tabKey"+t.realTimeListData[0].id),sessionStorage.setItem("tabKey",t.realTimeListData[0].streetId),t.tabKey=sessionStorage.getItem("tabKey")),t.$nextTick((function(){t.autoPlay()})))})).catch((function(t){console.log(t)}))},tabsChange:function(t){var e=this;sessionStorage.setItem("tabKey",t),this.destory(),this.$nextTick((function(){e.autoPlay()}))},autoPlay:function(){this.players=[];var t,e=Object(r["a"])(this.realTimeListData);try{for(e.s();!(t=e.n()).done;){var n,i=t.value,a=Object(r["a"])(i.cameras);try{for(a.s();!(n=a.n()).done;){var c=n.value,s=document.getElementById("camera"+c.id);if(s){console.log("play:"+c.id);var l=new o["a"](s,"camera"+c.id);l.play("camera"+c.id),this.players.push(l)}}}catch(u){a.e(u)}finally{a.f()}}}catch(u){e.e(u)}finally{e.f()}},destory:function(){var t,e=Object(r["a"])(this.players);try{for(e.s();!(t=e.n()).done;){var n=t.value;console.log("stop"),n.destroy()}}catch(i){e.e(i)}finally{e.f()}},setVideoServer:function(){this.$api.httpApi.getVideoServer({data:{}}).then((function(t){200==t.code&&o["a"].setServer(t.data.toString())})).catch((function(t){console.log(t)}))}}},s=c,l=(n("f426"),n("2877")),u=Object(l["a"])(s,i,a,!1,null,"6b545f28",null);e["default"]=u.exports},e01a:function(t,e,n){"use strict";var i=n("23e7"),a=n("83ab"),r=n("da84"),o=n("5135"),c=n("861d"),s=n("9bf2").f,l=n("e893"),u=r.Symbol;if(a&&"function"==typeof u&&(!("description"in u.prototype)||void 0!==u().description)){var d={},h=function(){var t=arguments.length<1||void 0===arguments[0]?void 0:String(arguments[0]),e=this instanceof h?new u(t):void 0===t?u():u(t);return""===t&&(d[e]=!0),e};l(h,u);var f=h.prototype=u.prototype;f.constructor=h;var b=f.toString,v="Symbol(test)"==String(u("test")),y=/^Symbol\((.*)\)[^)]+$/;s(f,"description",{configurable:!0,get:function(){var t=c(this)?this.valueOf():this,e=b.call(t);if(o(d,t))return"";var n=v?e.slice(7,-1):e.replace(y,"$1");return""===n?void 0:n}}),i({global:!0,forced:!0},{Symbol:h})}},f426:function(t,e,n){"use strict";var i=n("bf80"),a=n.n(i);a.a},fb6a:function(t,e,n){"use strict";var i=n("23e7"),a=n("861d"),r=n("e8b5"),o=n("23cb"),c=n("50c4"),s=n("fc6a"),l=n("8418"),u=n("b622"),d=n("1dde"),h=n("ae40"),f=d("slice"),b=h("slice",{ACCESSORS:!0,0:0,1:2}),v=u("species"),y=[].slice,p=Math.max;i({target:"Array",proto:!0,forced:!f||!b},{slice:function(t,e){var n,i,u,d=s(this),h=c(d.length),f=o(t,h),b=o(void 0===e?h:e,h);if(r(d)&&(n=d.constructor,"function"!=typeof n||n!==Array&&!r(n.prototype)?a(n)&&(n=n[v],null===n&&(n=void 0)):n=void 0,n===Array||void 0===n))return y.call(d,f,b);for(i=new(void 0===n?Array:n)(p(b-f,0)),u=0;f<b;f++,u++)f in d&&l(i,u,d[f]);return i.length=u,i}})}}]);