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