You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

2 lines
5.9 KiB

(function(t,e){"object"===typeof exports&&"object"===typeof module?module.exports=e():"function"===typeof define&&define.amd?define([],e):"object"===typeof exports?exports["plugin-webrtc"]=e():t["plugin-webrtc"]=e()})("undefined"!==typeof self?self:this,(function(){return function(t){var e={};function n(o){if(e[o])return e[o].exports;var r=e[o]={i:o,l:!1,exports:{}};return t[o].call(r.exports,r,r.exports,n),r.l=!0,r.exports}return n.m=t,n.c=e,n.d=function(t,e,o){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:o})},n.r=function(t){"undefined"!==typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"===typeof t&&t&&t.__esModule)return t;var o=Object.create(null);if(n.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var r in t)n.d(o,r,function(e){return t[e]}.bind(null,r));return o},n.n=function(t){var e=t&&t.__esModule?function(){return t["default"]}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s="fb15")}({"40b7":function(t,e,n){},5776:function(t,e,n){"use strict";var o=n("40b7"),r=n.n(o);r.a},8875:function(t,e,n){var o,r,s;(function(n,i){r=[],o=i,s="function"===typeof o?o.apply(e,r):o,void 0===s||(t.exports=s)})("undefined"!==typeof self&&self,(function(){function t(){if(document.currentScript)return document.currentScript;try{throw new Error}catch(d){var t,e,n,o=/.*at [^(]*\((.*):(.+):(.+)\)$/gi,r=/@([^@]*):(\d+):(\d+)\s*$/gi,s=o.exec(d.stack)||r.exec(d.stack),i=s&&s[1]||!1,c=s&&s[2]||!1,a=document.location.href.replace(document.location.hash,""),u=document.getElementsByTagName("script");i===a&&(t=document.documentElement.outerHTML,e=new RegExp("(?:[^\\n]+?\\n){0,"+(c-2)+"}[^<]*<script>([\\d\\D]*?)<\\/script>[\\d\\D]*","i"),n=t.replace(e,"$1").trim());for(var l=0;l<u.length;l++){if("interactive"===u[l].readyState)return u[l];if(u[l].src===i)return u[l];if(i===a&&u[l].innerHTML&&u[l].innerHTML.trim()===n)return u[l]}return null}}return t}))},fb15:function(t,e,n){"use strict";if(n.r(e),"undefined"!==typeof window){var o=window.document.currentScript,r=n("8875");o=r(),"currentScript"in document||Object.defineProperty(document,"currentScript",{get:r});var s=o&&o.src.match(/(.+\/)[^/]+\.js(\?.*)?$/);s&&(n.p=s[1])}var i=function(){var t=this,e=t.$createElement,n=t._self._c||e;return n("div",[1==t.$parent.titleTabActive?n("pre",[t._v(t._s(t.localSDP))]):2==t.$parent.titleTabActive?n("pre",[t._v(t._s(t.remoteSDP))]):n("div",[n("mu-text-field",{attrs:{label:"streamPath"},model:{value:t.streamPath,callback:function(e){t.streamPath=e},expression:"streamPath"}}),!t.localSDP||t.ask?n("span",{staticClass:"blink"},[t._v("Connecting")]):"connected"!=t.iceConnectionState?n("m-button",{on:{click:t.startSession}},[t._v("Start")]):"connected"==t.iceConnectionState?n("m-button",{on:{click:t.stopSession}},[t._v("Stop")]):t._e(),n("br"),n("video",{ref:"video1",attrs:{width:"640",height:"480",autoplay:"",muted:""},domProps:{srcObject:t.stream,muted:!0}})],1)])},c=[];const a={iceServers:[{urls:["stun:stun.ekiga.net","stun:stun.ideasip.com","stun:stun.schlund.de","stun:stun.stunprotocol.org:3478","stun:stun.voiparound.com","stun:stun.voipbuster.com","stun:stun.voipstunt.com","stun:stun.voxgratia.org","stun:stun.services.mozilla.com","stun:stun.xten.com","stun:stun.softjoys.com","stun:stunserver.org","stun:stun.schlund.de","stun:stun.rixtelecom.se","stun:stun.iptel.org","stun:stun.ideasip.com","stun:stun.fwdnet.net","stun:stun.ekiga.net","stun:stun01.sipphone.com"]}]};let u=new RTCPeerConnection(a);var l=null,d="live/rtc",p={data(){return{localSDP:u&&u.localDescription&&u.localDescription.sdp,remoteSDP:u&&u.remoteDescription&&u.remoteDescription.sdp,streamPath:d,iceConnectionState:u&&u.iceConnectionState,stream:l,ask:!1}},methods:{startSession(){this.ask=!0,this.ajax({type:"POST",processData:!1,data:JSON.stringify(u.localDescription),url:"/webrtc/answer?streamPath="+this.streamPath,dataType:"json"}).then(t=>{this.ask=!1,t.errmsg?this.$toast.error(t.errmsg):(d=this.streamPath,this.remoteSDP=t.sdp,this.$parent.titleTabs=["摄像头","localSDP","remoteSDP"],u.setRemoteDescription(new RTCSessionDescription(t)))})},stopSession(){u.close(),u=new RTCPeerConnection(a),this.remoteSDP="",this.localSDP="",this.connectICE().catch(t=>this.$toast.error(t.message))},async connectICE(){u.addStream(l),await u.setLocalDescription(await u.createOffer()),u.oniceconnectionstatechange=t=>{this.$toast.info(u.iceConnectionState),this.iceConnectionState=u.iceConnectionState},u.onicecandidate=t=>{null===t.candidate&&(this.localSDP=u.localDescription.sdp,this.$parent.titleTabs=["摄像头","localSDP"])}}},async mounted(){if(this.localSDP){let t=["摄像头"];this.localSDP&&t.push("localSDP"),this.remoteSDP&&t.push("remoteSDP"),this.$parent.titleTabs=t}else try{this.stream||(this.stream=l=await navigator.mediaDevices.getUserMedia({video:!0,audio:!0})),await this.connectICE()}catch(t){this.$toast.error(t.message)}}},f=p;n("5776");function m(t,e,n,o,r,s,i,c){var a,u="function"===typeof t?t.options:t;if(e&&(u.render=e,u.staticRenderFns=n,u._compiled=!0),o&&(u.functional=!0),s&&(u._scopeId="data-v-"+s),i?(a=function(t){t=t||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext,t||"undefined"===typeof __VUE_SSR_CONTEXT__||(t=__VUE_SSR_CONTEXT__),r&&r.call(this,t),t&&t._registeredComponents&&t._registeredComponents.add(i)},u._ssrRegister=a):r&&(a=c?function(){r.call(this,(u.functional?this.parent:this).$root.$options.shadowRoot)}:r),a)if(u.functional){u._injectStyles=a;var l=u.render;u.render=function(t,e){return a.call(e),l(t,e)}}else{var d=u.beforeCreate;u.beforeCreate=d?[].concat(d,a):[a]}return{exports:t,options:u}}var h=m(f,i,c,!1,null,"42a5fa69",null),v=h.exports;e["default"]=v}})["default"]}));
//# sourceMappingURL=plugin-webrtc.umd.min.js.map