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.8 KiB
2 lines
7.8 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 o(n){if(t[n])return t[n].exports;var r=t[n]={i:n,l:!1,exports:{}};return e[n].call(r.exports,r,r.exports,o),r.l=!0,r.exports}return o.m=e,o.c=t,o.d=function(e,t,n){o.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},o.r=function(e){"undefined"!==typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},o.t=function(e,t){if(1&t&&(e=o(e)),8&t)return e;if(4&t&&"object"===typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(o.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var r in e)o.d(n,r,function(t){return e[t]}.bind(null,r));return n},o.n=function(e){var t=e&&e.__esModule?function(){return e["default"]}:function(){return e};return o.d(t,"a",t),t},o.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},o.p="",o(o.s="fb15")}({2871:function(e,t,o){"use strict";var n=o("c2ab"),r=o.n(n);r.a},8875:function(e,t,o){var n,r,a;(function(o,i){r=[],n=i,a="function"===typeof n?n.apply(t,r):n,void 0===a||(e.exports=a)})("undefined"!==typeof self&&self,(function(){function e(){if(document.currentScript)return document.currentScript;try{throw new Error}catch(d){var e,t,o,n=/.*at [^(]*\((.*):(.+):(.+)\)$/gi,r=/@([^@]*):(\d+):(\d+)\s*$/gi,a=n.exec(d.stack)||r.exec(d.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"),o=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()===o)return l[u]}return null}}return e}))},c2ab:function(e,t,o){},fb15:function(e,t,o){"use strict";if(o.r(t),"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 e=this,t=e.$createElement,o=e._self._c||t;return o("div",[0==e.$parent.titleTabActive?o("div",[o("mu-text-field",{attrs:{label:"streamPath"},model:{value:e.streamPath,callback:function(t){e.streamPath=t},expression:"streamPath"}}),e.remoteSDP?o("m-button",{on:{click:e.stopSession}},[e._v("Stop")]):o("m-button",{on:{click:e.publish}},[e._v("Publish")]),e.remoteSDP?o("mu-badge",[o("a",{attrs:{slot:"content",href:e.remoteSDPURL,download:"remoteSDP.txt"},slot:"content"},[e._v("remoteSDP")])]):e._e(),e.localSDP?o("mu-badge",[o("a",{attrs:{slot:"content",href:e.localSDPURL,download:"localSDP.txt"},slot:"content"},[e._v("localSDP")])]):e._e(),o("br"),o("video",{ref:"video1",attrs:{width:"640",height:"480",autoplay:"",muted:""},domProps:{srcObject:e.stream,muted:!0}})],1):1==e.$parent.titleTabActive?o("stream-table",{scopedSlots:e._u([{key:"default",fn:function(t){return[o("m-button",{on:{click:function(o){return e.preview(t)}}},[e._v("Play")]),void 0]}}])}):2==e.$parent.titleTabActive?o("pre",[e._v(e._s(e.localSDP))]):3==e.$parent.titleTabActive?o("pre",[e._v(e._s(e.remoteSDP))]):e._e(),o("webrtc-player",{ref:"player",model:{value:e.previewStreamPath,callback:function(t){e.previewStreamPath=t},expression:"previewStreamPath"}})],1)},c=[],s=function(){var e=this,t=e.$createElement,o=e._self._c||t;return o("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),[o("video",{ref:"webrtc",attrs:{width:"488",height:"275",autoplay:"",muted:"",controls:""},domProps:{srcObject:e.stream,muted:!0}}),o("div",{attrs:{slot:"footer"},slot:"footer"},[e.remoteSDP?o("mu-badge",[o("a",{attrs:{slot:"content",href:e.remoteSDPURL,download:"remoteSDP.txt"},slot:"content"},[e._v("remoteSDP")])]):e._e(),e.localSDP?o("mu-badge",[o("a",{attrs:{slot:"content",href:e.localSDPURL,download:"localSDP.txt"},slot:"content"},[e._v("localSDP")])]):e._e()],1)])},l=[];let u=null;var d={data(){return{iceConnectionState:u&&u.iceConnectionState,stream:null,localSDP:"",remoteSDP:"",remoteSDPURL:"",localSDPURL:"",streamPath:""}},methods:{async play(e){u=new RTCPeerConnection,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()}}},p=d;function f(e,t,o,n,r,a,i,c){var s,l="function"===typeof e?e.options:e;if(t&&(l.render=t,l.staticRenderFns=o,l._compiled=!0),n&&(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 d=l.beforeCreate;l.beforeCreate=d?[].concat(d,s):[s]}return{exports:e,options:l}}var m=f(p,s,l,!1,null,null,null),h=m.exports;const S={iceServers:[]};let P=new RTCPeerConnection(S);var v=null,b="live/rtc",D={components:{WebrtcPlayer:h},data(){return{localSDP:P&&P.localDescription&&P.localDescription.sdp,remoteSDP:P&&P.remoteDescription&&P.remoteDescription.sdp,streamPath:b,iceConnectionState:P&&P.iceConnectionState,stream:v,previewStreamPath:!1,localSDPURL:"",remoteSDPURL:""}},methods:{async publish(){P.addStream(v),await P.setLocalDescription(await P.createOffer()),this.localSDP=P.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(P.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"})),P.setRemoteDescription(new RTCSessionDescription(e))):this.$toast.error(e)},stopSession(){P.close(),P=new RTCPeerConnection(S),this.remoteSDP="",this.localSDP=""},preview({row:e}){this.previewStreamPath=!0,this.$nextTick(()=>this.$refs.player.play(e.StreamPath))}},async mounted(){P.onsignalingstatechange=e=>{console.log(e)},P.oniceconnectionstatechange=e=>{this.$toast.info(P.iceConnectionState),this.iceConnectionState=P.iceConnectionState},P.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=(o("2871"),f(y,i,c,!1,null,"50fea0bc",null)),_=w.exports;t["default"]=_}})["default"]}));
|
|
//# sourceMappingURL=plugin-webrtc.umd.min.js.map
|