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
7.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 o(n){if(e[n])return e[n].exports;var r=e[n]={i:n,l:!1,exports:{}};return t[n].call(r.exports,r,r.exports,o),r.l=!0,r.exports}return o.m=t,o.c=e,o.d=function(t,e,n){o.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},o.r=function(t){"undefined"!==typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},o.t=function(t,e){if(1&e&&(t=o(t)),8&e)return t;if(4&e&&"object"===typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(o.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var r in t)o.d(n,r,function(e){return t[e]}.bind(null,r));return n},o.n=function(t){var e=t&&t.__esModule?function(){return t["default"]}:function(){return t};return o.d(e,"a",e),e},o.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},o.p="",o(o.s="fb15")}({2871:function(t,e,o){"use strict";var n=o("c2ab"),r=o.n(n);r.a},8875:function(t,e,o){var n,r,a;(function(o,i){r=[],n=i,a="function"===typeof n?n.apply(e,r):n,void 0===a||(t.exports=a)})("undefined"!==typeof self&&self,(function(){function t(){if(document.currentScript)return document.currentScript;try{throw new Error}catch(p){var t,e,o,n=/.*at [^(]*\((.*):(.+):(.+)\)$/gi,r=/@([^@]*):(\d+):(\d+)\s*$/gi,a=n.exec(p.stack)||r.exec(p.stack),i=a&&a[1]||!1,s=a&&a[2]||!1,c=document.location.href.replace(document.location.hash,""),l=document.getElementsByTagName("script");i===c&&(t=document.documentElement.outerHTML,e=new RegExp("(?:[^\\n]+?\\n){0,"+(s-2)+"}[^<]*<script>([\\d\\D]*?)<\\/script>[\\d\\D]*","i"),o=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===i)return l[u];if(i===c&&l[u].innerHTML&&l[u].innerHTML.trim()===o)return l[u]}return null}}return t}))},c2ab:function(t,e,o){},fb15:function(t,e,o){"use strict";if(o.r(e),"undefined"!==typeof window){var n=window.document.currentScript,r=o("8875");n=r(),"currentScript"in document||Object.defineProperty(document,"currentScript",{get:r});var a=n&&n.src.match(/(.+\/)[^/]+\.js(\?.*)?$/);a&&(o.p=a[1])}var i=function(){var t=this,e=t.$createElement,o=t._self._c||e;return o("div",[0==t.$parent.titleTabActive?o("div",[o("mu-text-field",{attrs:{label:"streamPath"},model:{value:t.streamPath,callback:function(e){t.streamPath=e},expression:"streamPath"}}),t.remoteSDP?o("m-button",{on:{click:t.stopSession}},[t._v("Stop")]):o("m-button",{on:{click:t.publish}},[t._v("Publish")]),t.remoteSDP?o("mu-badge",[o("a",{attrs:{slot:"content",href:t.remoteSDPURL,download:"remoteSDP.txt"},slot:"content"},[t._v("remoteSDP")])]):t._e(),t.localSDP?o("mu-badge",[o("a",{attrs:{slot:"content",href:t.localSDPURL,download:"localSDP.txt"},slot:"content"},[t._v("localSDP")])]):t._e(),o("br"),o("video",{ref:"video1",attrs:{width:"640",height:"480",autoplay:"",muted:""},domProps:{srcObject:t.stream,muted:!0}})],1):1==t.$parent.titleTabActive?o("stream-table",{scopedSlots:t._u([{key:"default",fn:function(e){return[o("m-button",{on:{click:function(o){return t.preview(e)}}},[t._v("Play")]),void 0]}}])}):2==t.$parent.titleTabActive?o("pre",[t._v(t._s(t.localSDP))]):3==t.$parent.titleTabActive?o("pre",[t._v(t._s(t.remoteSDP))]):t._e(),o("webrtc-player",{ref:"player",model:{value:t.previewStreamPath,callback:function(e){t.previewStreamPath=e},expression:"previewStreamPath"}})],1)},s=[],c=function(){var t=this,e=t.$createElement,o=t._self._c||e;return o("Modal",t._g(t._b({attrs:{draggable:"",title:t.streamPath},on:{"on-ok":t.onClosePreview,"on-cancel":t.onClosePreview}},"Modal",t.$attrs,!1),t.$listeners),[o("video",{ref:"webrtc",attrs:{width:"488",height:"275",autoplay:"",muted:"",controls:""},domProps:{srcObject:t.stream,muted:!0}}),o("div",{attrs:{slot:"footer"},slot:"footer"},[t.remoteSDP?o("mu-badge",[o("a",{attrs:{slot:"content",href:t.remoteSDPURL,download:"remoteSDP.txt"},slot:"content"},[t._v("remoteSDP")])]):t._e(),t.localSDP?o("mu-badge",[o("a",{attrs:{slot:"content",href:t.localSDPURL,download:"localSDP.txt"},slot:"content"},[t._v("localSDP")])]):t._e()],1)])},l=[];let u=null;var p={data(){return{iceConnectionState:u&&u.iceConnectionState,stream:null,localSDP:"",remoteSDP:"",remoteSDPURL:"",localSDPURL:"",streamPath:""}},methods:{async play(t){u=new RTCPeerConnection,this.streamPath=t,u.onsignalingstatechange=t=>{console.log(t)},u.oniceconnectionstatechange=t=>{this.$toast.info(u.iceConnectionState),this.iceConnectionState=u.iceConnectionState},u.onicecandidate=t=>{};const e=await this.ajax({url:"/webrtc/preparePlay?streamPath="+this.streamPath,dataType:"json"});e.errmsg?this.$toast.error(e.errmsg):(this.remoteSDP=e.sdp,this.remoteSDPURL=URL.createObjectURL(new Blob([this.remoteSDP],{type:"text/plain"})),u.ontrack=t=>{console.log(t),"monibuca"==t.streams[0].id&&(this.stream=t.streams[0])},await u.setRemoteDescription(new RTCSessionDescription(e)),await u.setLocalDescription(await u.createAnswer()),this.localSDP=u.localDescription.sdp,this.localSDPURL=URL.createObjectURL(new Blob([this.localSDP],{type:"text/plain"})),e=await this.ajax({type:"POST",processData:!1,data:JSON.stringify(u.localDescription),url:"/webrtc/play?streamPath="+this.streamPath,dataType:"json"}),"success"!=e&&this.$toast.error(e.errmsg||e))},onClosePreview(){u.close()}}},d=p;function m(t,e,o,n,r,a,i,s){var c,l="function"===typeof t?t.options:t;if(e&&(l.render=e,l.staticRenderFns=o,l._compiled=!0),n&&(l.functional=!0),a&&(l._scopeId="data-v-"+a),i?(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__),r&&r.call(this,t),t&&t._registeredComponents&&t._registeredComponents.add(i)},l._ssrRegister=c):r&&(c=s?function(){r.call(this,(l.functional?this.parent:this).$root.$options.shadowRoot)}:r),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 p=l.beforeCreate;l.beforeCreate=p?[].concat(p,c):[c]}return{exports:t,options:l}}var f=m(d,c,l,!1,null,null,null),h=f.exports;const S={iceServers:[]};let P=new RTCPeerConnection(S);var b=null,v="live/rtc",D={components:{WebrtcPlayer:h},data(){return{localSDP:P&&P.localDescription&&P.localDescription.sdp,remoteSDP:P&&P.remoteDescription&&P.remoteDescription.sdp,streamPath:v,iceConnectionState:P&&P.iceConnectionState,stream:b,previewStreamPath:!1,localSDPURL:"",remoteSDPURL:""}},methods:{async publish(){P.addStream(b),await P.setLocalDescription(await P.createOffer()),this.localSDP=P.localDescription.sdp,this.localSDPURL=URL.createObjectURL(new Blob([this.localSDP],{type:"text/plain"}));const t=await this.ajax({type:"POST",processData:!1,data:JSON.stringify(P.localDescription),url:"/webrtc/publish?streamPath="+this.streamPath,dataType:"json"});console.log(t),"string"!=typeof t?(v=this.streamPath,this.remoteSDP=t.sdp,this.remoteSDPURL=URL.createObjectURL(new Blob([this.remoteSDP],{type:"text/plain"})),P.setRemoteDescription(new RTCSessionDescription(t))):this.$toast.error(t)},stopSession(){P.close(),P=new RTCPeerConnection(S),this.remoteSDP="",this.localSDP=""},preview({row:t}){this.previewStreamPath=!0,this.$nextTick(()=>this.$refs.player.play(t.StreamPath))}},async mounted(){P.onsignalingstatechange=t=>{console.log(t)},P.oniceconnectionstatechange=t=>{this.$toast.info(P.iceConnectionState),this.iceConnectionState=P.iceConnectionState},P.onicecandidate=t=>{},this.$parent.titleTabs=["publish","play"];try{this.stream||(this.stream=b=await navigator.mediaDevices.getUserMedia({video:!0,audio:!0}))}catch(t){this.$toast.error(t.message)}}},y=D,w=(o("2871"),m(y,i,s,!1,null,"50fea0bc",null)),g=w.exports;e["default"]=g}})["default"]}));
//# sourceMappingURL=plugin-webrtc.umd.min.js.map