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
1 line
21 KiB
JavaScript
|
4 years ago
|
(window["webpackJsonp"]=window["webpackJsonp"]||[]).push([["chunk-2e508108"],{"3ea2":function(t,o,i){"use strict";i("4160"),i("d3b7"),i("159b"),i("96cf");var e=i("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 i=0;i<o.length;i++){var e=o[i];e.enumerable=e.enumerable||!1,e.configurable=!0,"value"in e&&(e.writable=!0),Object.defineProperty(t,e.key,e)}}function s(t,o,i){return o&&a(t.prototype,o),i&&a(t,i),t}var c=i("ade3"),r=function(){function t(o,i){var e=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:"+i),this.server=t.server,this.video=o,this.uuid=i,Object.assign(this.options,e),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,i){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(e["a"])(regeneratorRuntime.mark((function t(){var o,i,e=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:i=new FormData,i.append("suuid",this.uuid),i.append("data",btoa(this.webrtc.localDescription.sdp)),fetch(this.rsdpLink,{method:"POST",body:i}).then((function(t){t.text().then((function(t){e.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},6002:function(t,o,i){var e=i("24fb");o=e(!1),o.push([t.i,".alarm .ant-form-item-label[data-v-8076da96]{text-align:left}.add-edit-model .across-layout[data-v-8076da96]{display:flex}.add-edit-model .ant-divider-horizontal[data-v-8076da96]{margin:6px 0}.test-model[data-v-8076da96]{position:fixed;top:0;bottom:0;left:0;right:0;background-color:rgba(0,0,0,.5);z-index:1000;display:flex;align-items:center;justify-content:center}.test-model #video-test[data-v-8076da96]{width:100%;height:100%}.test-model .video-close[data-v-8076da96]{position:absolute;right:20px;top:20px;color:#fff;font-size:24px;width:32px;height:32px;background:rgba(0,0,0,.5);border-radius:50%;display:flex;align-items:center;justify-content:c
|