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

4 years ago
(window["webpackJsonp"]=window["webpackJsonp"]||[]).push([["chunk-7e66e84e"],{"0b60":function(t,o,e){var i=e("ebcf");"string"===typeof i&&(i=[[t.i,i,""]]),i.locals&&(t.exports=i.locals);var n=e("499e").default;n("3c4d9820",i,!0,{sourceMap:!1,shadowMode:!1})},"1bf8":function(t,o,e){"use strict";var i=e("0b60"),n=e.n(i);n.a},"3ea2":function(t,o,e){"use strict";e("4160"),e("d3b7"),e("159b"),e("96cf");var i=e("1da1");function n(t,o){if(!(t instanceof o))throw new TypeError("Cannot call a class as a function")}function a(t,o){for(var e=0;e<o.length;e++){var i=o[e];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}function s(t,o,e){return o&&a(t.prototype,o),e&&a(t,e),t}var c=e("ade3"),r=function(){function t(o,e){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};n(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:"+e),this.server=t.server,this.video=o,this.uuid=e,Object.assign(this.options,i),this.createLinks(),this.play()}return s(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(o){o.json().then((function(o){o.forEach((function(o,e){t.webrtc.addTransceiver(o.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 o,e,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 o=t.sent,t.next=5,this.webrtc.setLocalDescription(o);case 5:e=new FormData,e.append("suuid",this.uuid),e.append("data",btoa(this.webrtc.localDescription.sdp)),fetch(this.rsdpLink,{method:"POST",body:e}).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 o(){return t.apply(this,arguments)}return o}()},{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 o=t.toDataURL();return t.remove(),o}}],[{key:"setServer",value:function(t){this.server=t}}]),t}();Object(c["a"])(r,"server","127.0.0.1:8083");o["a"]=r},9545:function(t,o,e){"use strict";e.r(o);var i=function(){var t=this,o=t.$createElement,e=t._self._c||o;return t.isShow?e("div",["add"==t.type||"edit"==t.type?[e("a-modal",{staticClass:"add-edit-model",attrs:{title:["add"==t.type?"新增球机":"编辑球机"],closable:t.closable,"ok-text":"确认","cancel-text":"取消"},on:{ok:t.handleOk,cancel:t.handleCancel},model:{value:t.isShow,callback:function(o){t.isShow=o},expression:"isShow"}},[e("a-form",{attrs:{f