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.5 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(r){if(e[r])return e[r].exports;var o=e[r]={i:r,l:!1,exports:{}};return t[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},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 r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var o in t)n.d(r,o,function(e){return t[e]}.bind(null,o));return r},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")}({8875:function(t,e,n){var r,o,i;(function(n,a){o=[],r=a,i="function"===typeof r?r.apply(e,o):r,void 0===i||(t.exports=i)})("undefined"!==typeof self&&self,(function(){function t(){if(document.currentScript)return document.currentScript;try{throw new Error}catch(d){var t,e,n,r=/.*at [^(]*\((.*):(.+):(.+)\)$/gi,o=/@([^@]*):(\d+):(\d+)\s*$/gi,i=r.exec(d.stack)||o.exec(d.stack),a=i&&i[1]||!1,s=i&&i[2]||!1,c=document.location.href.replace(document.location.hash,""),l=document.getElementsByTagName("script");a===c&&(t=document.documentElement.outerHTML,e=new RegExp("(?:[^\\n]+?\\n){0,"+(s-2)+"}[^<]*<script>([\\d\\D]*?)<\\/script>[\\d\\D]*","i"),n=t.replace(e,"$1").trim());for(var u=0;u<l.length;u++){if("interactive"===l[u].readyState)return l[u];if(l[u].src===a)return l[u];if(a===c&&l[u].innerHTML&&l[u].innerHTML.trim()===n)return l[u]}return null}}return t}))},"8e55":function(t,e,n){},e91a:function(t,e,n){"use strict";var r=n("8e55"),o=n.n(r);o.a},fb15:function(t,e,n){"use strict";if(n.r(e),"undefined"!==typeof window){var r=window.document.currentScript,o=n("8875");r=o(),"currentScript"in document||Object.defineProperty(document,"currentScript",{get:o});var i=r&&r.src.match(/(.+\/)[^/]+\.js(\?.*)?$/);i&&(n.p=i[1])}var a=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")]):t._e(),[n("m-button",{on:{click:function(e){return t.startSession("publish")}}},[t._v("Publish")]),n("m-button",{on:{click:function(e){return t.startSession("play")}}},[t._v("Play")])],n("m-button",{on:{click:t.stopSession}},[t._v("Stop")]),n("br"),n("video",{ref:"video1",attrs:{width:"640",height:"480",autoplay:"",muted:""},domProps:{srcObject:t.stream,muted:!0}})],2)])},s=[];const c={iceServers:[]};let l=new RTCPeerConnection(c);var u=null,d="live/rtc",p={data(){return{localSDP:l&&l.localDescription&&l.localDescription.sdp,remoteSDP:l&&l.remoteDescription&&l.remoteDescription.sdp,streamPath:d,iceConnectionState:l&&l.iceConnectionState,stream:u,type:"",ask:!1}},methods:{async startSession(t){this.type=t,this.ask=!0;const e=await this.ajax({type:"POST",processData:!1,data:JSON.stringify(l.localDescription),url:"/webrtc/"+t+"?streamPath="+this.streamPath,dataType:"json"});this.ask=!1,e.errmsg?this.$toast.error(e.errmsg):(d=this.streamPath,this.remoteSDP=e.sdp,this.$parent.titleTabs=["摄像头","localSDP","remoteSDP"],l.setRemoteDescription(new RTCSessionDescription(e))),"publish"==t?(l.addStream(u),this.localSDP=(await l.setLocalDescription(await l.createOffer())).sdp):l.ontrack=t=>{"monibuca"==t.streams[0].id&&(this.stream=u=t.streams[0])}},stopSession(){l.close(),l=new RTCPeerConnection(c),this.remoteSDP="",this.localSDP="",this.type=""}},async mounted(){if(l.onsignalingstatechange=t=>{console.log(t)},l.oniceconnectionstatechange=t=>{this.$toast.info(l.iceConnectionState),this.iceConnectionState=l.iceConnectionState},l.onicecandidate=t=>{null===t.candidate&&(this.$parent.titleTabs=["摄像头","localSDP"])},this.localSDP){let t=["摄像头"];this.localSDP&&t.push("localSDP"),this.remoteSDP&&t.push("remoteSDP"),this.$parent.titleTabs=t}else try{this.stream||(this.stream=u=await navigator.mediaDevices.getUserMedia({video:!0,audio:!0}))}catch(t){this.$toast.error(t.message)}}},f=p;n("e91a");function m(t,e,n,r,o,i,a,s){var c,l="function"===typeof t?t.options:t;if(e&&(l.render=e,l.staticRenderFns=n,l._compiled=!0),r&&(l.functional=!0),i&&(l._scopeId="data-v-"+i),a?(c=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__),o&&o.call(this,t),t&&t._registeredComponents&&t._registeredComponents.add(a)},l._ssrRegister=c):o&&(c=s?function(){o.call(this,(l.functional?this.parent:this).$root.$options.shadowRoot)}:o),c)if(l.functional){l._injectStyles=c;var u=l.render;l.render=function(t,e){return c.call(e),u(t,e)}}else{var d=l.beforeCreate;l.beforeCreate=d?[].concat(d,c):[c]}return{exports:t,options:l}}var h=m(f,a,s,!1,null,"03ea1df8",null),S=h.exports;e["default"]=S}})["default"]}));
//# sourceMappingURL=plugin-webrtc.umd.min.js.map