jb4-5138f1a1.js 16 KB

12
  1. import{d as z,P as p,k as ve,l as _,cY as ge,n as g,v as ye,p as I,cN as Ce,d7 as Se,q as we,F as be,u as De,d8 as Pe,f as ee,d5 as _e,N as xe,m as ke,c as R,Y as te,h as Ee,o as Te,cL as Ie,be as Ae,Z as F,a1 as H,a0 as Ne,a2 as Oe,a3 as Ue,$ as Ve,T as ie,a9 as $e,cI as Me,cJ as Re,a7 as Be,ay as ze,aV as Fe,d9 as Ge,c9 as ne,bg as G,at as je}from"./index-8a67e3df.js";import{h as He,B as Le,i as We,f as B,d as L,g as se,V as W,b as Y,c as oe,a as q,A as J,j as Ye,F as K,D as j,e as ae,C as qe}from"./canvas-2aaf4e1d.js";import"./dayjs-919e6097.js";import{P as Je}from"./index-6a257713.js";var Ke=["prefixCls"];const Ze=z({compatConfig:{MODE:3},name:"Steps",props:{type:p.string.def("default"),prefixCls:p.string.def("vc-steps"),iconPrefix:p.string.def("vc"),direction:p.string.def("horizontal"),labelPlacement:p.string.def("horizontal"),status:p.string.def("process"),size:p.string.def(""),progressDot:p.oneOfType([p.looseBool,p.func]).def(void 0),initial:p.number.def(0),current:p.number.def(0),icons:p.shape({finish:p.any,error:p.any}).loose,stepIcon:Function},slots:["stepIcon","progressDot"],emits:["change"],setup:function(e,i){var t=i.slots,s=i.emit,y=function(c){var r=e.current;r!==c&&s("change",c)};return function(){var o,c,r=e.prefixCls,u=e.direction,m=e.type,w=e.labelPlacement,h=e.iconPrefix,v=e.status,x=e.size,l=e.current,C=e.progressDot,f=C===void 0?t.progressDot:C,T=e.initial,S=e.icons,b=e.stepIcon,E=b===void 0?t.stepIcon:b,D=m==="navigation",N=f?"vertical":w,V=ve(r,"".concat(r,"-").concat(u),(o={},_(o,"".concat(r,"-").concat(x),x),_(o,"".concat(r,"-label-").concat(N),u==="horizontal"),_(o,"".concat(r,"-dot"),!!f),_(o,"".concat(r,"-navigation"),D),o)),$=ge((c=t.default)===null||c===void 0?void 0:c.call(t));return g("div",{class:V},[$.map(function(M,O){var U=M.props||{},n=U.prefixCls,a=n===void 0?r:n,d=ye(U,Ke),k=T+O,P=I(I({},d),{},{stepNumber:k+1,stepIndex:k,key:k,prefixCls:a,iconPrefix:h,progressDot:f,icons:S,stepIcon:E,onStepClick:y});return v==="error"&&O===l-1&&(P.class="".concat(r,"-next-error")),d.status||(k===l?P.status=v:k<l?P.status="finish":P.status="wait"),P.active=k===l,Ce(M,P)})])}}});function re(A){return typeof A=="string"}function Qe(){}var me=function(){return{prefixCls:String,wrapperStyle:{type:Object,default:void 0},itemWidth:String,active:{type:Boolean,default:void 0},disabled:{type:Boolean,default:void 0},status:String,iconPrefix:String,icon:p.any,adjustMarginRight:String,stepNumber:Number,stepIndex:Number,description:p.any,title:p.any,subTitle:p.any,progressDot:Se(p.oneOfType([p.looseBool,p.func])),tailContent:p.any,icons:p.shape({finish:p.any,error:p.any}).loose,onClick:Function,onStepClick:Function,stepIcon:Function}};const Xe=z({compatConfig:{MODE:3},name:"Step",props:me(),slots:["title","subTitle","description","tailContent","stepIcon","progressDot"],emits:["click","stepClick"],setup:function(e,i){var t=i.slots,s=i.emit,y=function(r){s("click",r),s("stepClick",e.stepIndex)},o=function(r){var u,m=r.icon,w=r.title,h=r.description,v=e.prefixCls,x=e.stepNumber,l=e.status,C=e.iconPrefix,f=e.icons,T=e.progressDot,S=T===void 0?t.progressDot:T,b=e.stepIcon,E=b===void 0?t.stepIcon:b,D,N=(u={},_(u,"".concat(v,"-icon"),!0),_(u,"".concat(C,"icon"),!0),_(u,"".concat(C,"icon-").concat(m),m&&re(m)),_(u,"".concat(C,"icon-check"),!m&&l==="finish"&&f&&!f.finish),_(u,"".concat(C,"icon-close"),!m&&l==="error"&&f&&!f.error),u),V=g("span",{class:"".concat(v,"-icon-dot")},null);return S?typeof S=="function"?D=g("span",{class:"".concat(v,"-icon")},[S({iconDot:V,index:x-1,status:l,title:w,description:h,prefixCls:v})]):D=g("span",{class:"".concat(v,"-icon")},[V]):m&&!re(m)?D=g("span",{class:"".concat(v,"-icon")},[m]):f&&f.finish&&l==="finish"?D=g("span",{class:"".concat(v,"-icon")},[f.finish]):f&&f.error&&l==="error"?D=g("span",{class:"".concat(v,"-icon")},[f.error]):m||l==="finish"||l==="error"?D=g("span",{class:N},null):D=g("span",{class:"".concat(v,"-icon")},[x]),E&&(D=E({index:x-1,status:l,title:w,description:h,node:D})),D};return function(){var c,r,u,m,w,h=e.prefixCls,v=e.itemWidth,x=e.active,l=e.status,C=l===void 0?"wait":l,f=e.tailContent,T=e.adjustMarginRight,S=e.disabled,b=e.title,E=b===void 0?(c=t.title)===null||c===void 0?void 0:c.call(t):b,D=e.description,N=D===void 0?(r=t.description)===null||r===void 0?void 0:r.call(t):D,V=e.subTitle,$=V===void 0?(u=t.subTitle)===null||u===void 0?void 0:u.call(t):V,M=e.icon,O=M===void 0?(m=t.icon)===null||m===void 0?void 0:m.call(t):M,U=e.onClick,n=e.onStepClick,a=(w={},_(w,"".concat(h,"-item"),!0),_(w,"".concat(h,"-item-").concat(C),!0),_(w,"".concat(h,"-item-custom"),O),_(w,"".concat(h,"-item-active"),x),_(w,"".concat(h,"-item-disabled"),S===!0),w),d={class:a},k={};v&&(k.width=v),T&&(k.marginRight=T);var P={onClick:U||Qe};return n&&!S&&(P.role="button",P.tabindex=0,P.onClick=y),g("div",I(I({},d),{},{style:k}),[g("div",I(I({},P),{},{class:"".concat(h,"-item-container")}),[g("div",{class:"".concat(h,"-item-tail")},[f]),g("div",{class:"".concat(h,"-item-icon")},[o({icon:O,title:E,description:N})]),g("div",{class:"".concat(h,"-item-content")},[g("div",{class:"".concat(h,"-item-title")},[E,$&&g("div",{title:$,class:"".concat(h,"-item-subtitle")},[$])]),N&&g("div",{class:"".concat(h,"-item-description")},[N])])])])}}});var et=function(){return{prefixCls:String,iconPrefix:String,current:Number,initial:Number,percent:Number,responsive:{type:Boolean,default:void 0},labelPlacement:String,status:String,size:String,direction:String,progressDot:{type:[Boolean,Function],default:void 0},type:String,onChange:Function,"onUpdate:current":Function}},Z=z({compatConfig:{MODE:3},name:"ASteps",inheritAttrs:!1,props:be(et(),{current:0,responsive:!0,labelPlacement:"horizontal"}),slots:["progressDot"],setup:function(e,i){var t=i.attrs,s=i.slots,y=i.emit,o=De("steps",e),c=o.prefixCls,r=o.direction,u=o.configProvider,m=Pe(),w=ee(function(){return e.responsive&&m.value.xs?"vertical":e.direction}),h=ee(function(){return u.getPrefixCls("",e.iconPrefix)}),v=function(C){y("update:current",C),y("change",C)},x=function(C){var f=C.node,T=C.status;if(T==="process"&&e.percent!==void 0){var S=e.size==="small"?32:40,b=g("div",{class:"".concat(c,"-progress-icon")},[g(Je,{type:"circle",percent:e.percent,width:S,strokeWidth:4,format:function(){return null}},null),f]);return b}return f};return function(){var l,C=ve((l={},_(l,"".concat(c.value,"-rtl"),r.value==="rtl"),_(l,"".concat(c.value,"-with-progress"),e.percent!==void 0),l),t.class),f={finish:g(_e,{class:"".concat(c,"-finish-icon")},null),error:g(xe,{class:"".concat(c,"-error-icon")},null)};return g(Ze,I(I({icons:f},ke(e,["percent","responsive"])),{},{direction:w.value,prefixCls:c.value,iconPrefix:h.value,class:C,onChange:v}),I(I({},s),{},{stepIcon:x}))}}}),Q=z(I(I({compatConfig:{MODE:3}},Xe),{},{name:"AStep",props:me()}));const ce=we(Z,{Step:Q,install:function(e){return e.component(Z.name,Z),e.component(Q.name,Q),e}});class tt extends He{async _connect(){const e=await fetch(this.url,{...this.options.requestInit,signal:this.abortCtrl.signal});if(!e.body)throw new Error("no body");return e.body}}const le=442,de=444,ue=480,fe=448,pe=441,it=27,nt=36,st=15,ot=144,at=145;class rt extends Le{constructor(){super(...arguments),this.videoStreamType=0,this.audioStreamType=0,this.pts=0,this.dts=0,this.tmp8=new Uint8Array(4),this.dv=new DataView(this.tmp8.buffer),this.videoBuffer=[],this.videoBufferSize=0,this.currentPTS=0,this.startTime=0}async pull(){const e=this.tmp8,i=this.dv,t=this.source;switch(await t.read(e),i.getUint32(0)){case le:await t.read(9),await t.read(e.subarray(0,1));const y=i.getUint8(0)&7;await t.read(y);break;case de:await t.read(e.subarray(0,2)),this.decProgramStreamMap(await t.read(i.getUint16(0)));break;case ue:if(await t.read(e.subarray(0,2)),this.demuxVideo(await t.read(i.getUint16(0))))return;break;case fe:if(await t.read(e.subarray(0,2)),this.demuxAudio(await t.read(i.getUint16(0))))return;break;case pe:return;default:await t.read(e.subarray(0,2));const o=i.getUint16(0);await t.read(o)}return this.pull()}*demux(){const e=this.tmp8,i=this.dv;for(;;){yield e;const t=i.getUint32(0);switch(t.toString(16),t){case le:yield 9,yield e.subarray(0,1),yield i.getUint8(0)&7;break;case de:yield e.subarray(0,2);const o=yield i.getUint16(0);this.decProgramStreamMap(o);break;case ue:yield e.subarray(0,2),this.demuxVideo(yield i.getUint16(0));break;case fe:yield e.subarray(0,2),this.demuxAudio(yield i.getUint16(0));break;case pe:return;default:yield e.subarray(0,2),yield i.getUint16(0);break}}}demuxVideo(e){const i=this.parsePESPacket(e),t=this.videoBuffer;if(!this.startTime)if(this.videoDecoderConfig?.codec=="hevc")if((i[4]&126)>>1===32)this.startTime=Date.now(),this.currentPTS=this.pts;else return!1;else if((i[4]&15)==7)this.startTime=Date.now(),this.currentPTS=this.pts;else return!1;if(this.currentPTS==this.pts)return i[4]&15,this.videoBufferSize+=i.length,t.push(i.slice()),!1;if(t.length&&this.currentPTS!=this.pts){let s=0,y="key";return this.videoDecoderConfig?.codec=="hevc"?(t[0][4]&126)>>1!=32&&(y="delta"):(t[0][4]&15)==1&&(y="delta"),this.gotVideo?.({type:y,data:t.length==1?t[0]:t.reduce((o,c)=>(o.subarray(s).set(c),s+=c.length,o),new Uint8Array(this.videoBufferSize)),timestamp:(Date.now()-this.startTime)*1e3}),t.length=0,!0}return this.videoBufferSize+=i.length,t.push(i.slice()),this.currentPTS=this.pts,!1}demuxAudio(e){const i=this.parsePESPacket(e);if(this.audioDecoderConfig?.codec=="aac"&&!this.audioDecoderConfig?.description){const t=We(i.subarray(7));this.audioDecoderConfig={codec:"aac",description:t.audioSpecificConfig,sampleRate:t.sampleRate,numberOfChannels:t.channel},this.emit(B.AUDIO_ENCODER_CONFIG_CHANGED,this.audioDecoderConfig)}return this.gotAudio?.({type:"key",data:this.audioDecoderConfig?.codec=="aac"?i.subarray(7):i,timestamp:this.dts,duration:0}),!0}parsePESPacket(e){if(e.length<4)throw new Error("Short buffer");const i=e[1],t=i>>7==1,s=(i&64)>>6==1,y=e[2];if(e.length<y+3)throw new Error("Short buffer");const o=e.subarray(3,3+y);return t&&o.length>4&&(this.pts=(o[0]&14)<<29|o[1]<<22|(o[2]&254)<<14|o[3]<<7|o[4]>>1,s&&o.length>9?this.dts=(o[5]&14)<<29|o[6]<<22|(o[7]&254)<<14|o[8]<<7|o[9]>>1:this.dts=this.pts),e.subarray(3+y)}decProgramStreamMap(e){const i=new DataView(e.buffer,e.byteOffset,e.byteLength),t=e.length;let s=2;const y=i.getUint16(s);s+=2,s+=y;let o=i.getUint16(s);for(s+=2;o>0&&!(t<=s+1);){const c=e[s];s++;const r=e[s];if(s++,r>=224&&r<=239?(this.videoStreamType=c,this.videoDecoderConfig={codec:{[it]:"avc",[nt]:"hevc"}[c]||"unknown"},this.emit(B.VIDEO_ENCODER_CONFIG_CHANGED,this.videoDecoderConfig)):r>=192&&r<=223&&(this.audioStreamType=c,this.audioDecoderConfig={codec:{[st]:"aac",[ot]:"pcma",[at]:"pcmu"}[c]||"unknown",numberOfChannels:1,sampleRate:8e3},this.audioDecoderConfig.codec!="aac"&&this.emit(B.AUDIO_ENCODER_CONFIG_CHANGED,this.audioDecoderConfig)),t<=s+1)break;const u=i.getUint16(s);s+=2,s+=u,o-=4+u}}}const ct={class:"video-container"},lt={key:0,class:"loading-container"},dt=["srcObject"],ut=z({__name:"jb4",props:{videoShadow:{},streamPath:{},format:{},speed:{},pause:{type:Boolean},startTime:{}},emits:["postion","play"],setup(A,{emit:e}){const i=A,t=e;let s,y=0,o=0;const c=R();let r;const u=R();let m,w;const h=R(),v=typeof VideoDecoder=="function",x=R();let l=null,C=null,f=null;function T(){return typeof WebAssembly>"u"?!1:WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,5,1,96,0,1,123,3,2,1,0,10,10,1,8,0,65,0,253,15,253,98,11]))}let S=D(v?L:T()?se:W),b=N(v?q:J),E=!1;te(()=>{u.value&&(u.value.addEventListener("playing",()=>{t("play",!0)}),u.value.addEventListener("pause",()=>{t("play","pause")}),u.value.addEventListener("ended",()=>{t("play","ended")}),u.value.addEventListener("error",()=>{t("play","error")}))});function D(n){const a=new n;return a.on(Y.VideoCodecInfo,d=>{`${d.width}${d.height}`}),a.on(Y.VideoFrame,d=>{t("play",!0),w?w.write(d):l&&x.value&&(U.value=!1,l.writeVideo(d),d.close())}),a.on(Y.Error,d=>{console.error(d),E=!1,S instanceof L&&(S=D(T()?se:W),S.initialize().then(()=>{f&&S.configure({...f})}))}),a}function N(n){const a=new n;return a.on(oe.Error,d=>{console.error(d),a instanceof q&&(b=N(J),b.initialize().then(()=>{C&&b.configure({...C})}))}),a.on(oe.AudioFrame,d=>{m?m.write(d):l&&(U.value=!1,l.writeAudio(d))}),a}function V(){b?.close(),C=null}function $(){S?.close(),f=null}te(async()=>{if(i.streamPath&&i.format){r&&clearInterval(r),r=setInterval(async()=>{if(i.streamPath)try{const n=await Ge(i.streamPath);c.value=n,n.steps.some(a=>a.error)&&(ne.error({message:"播放失败",description:n.steps.find(a=>a.error)?.error}),t("play","error"),clearInterval(r))}catch{}},1e3);try{switch(s&&(V(),$(),await s.close()),b=N(v?q:J),S=D(v?L:W),await S.initialize(),await b.initialize(),i.format){case"ps":s=new ae(`${G("ps","","ws")}/${i.streamPath}`),O(new rt(s,j.PUSH));break;case"http-flv":s=new tt(`${G("flv","")}/${i.streamPath}`),O(new K(s,j.PUSH));break;case"ws-flv":s=new ae(`${G("flv","","ws")}/${i.streamPath}`),O(new K(s,j.PUSH));break;case"webrtc":const n=new RTCPeerConnection;n.ontrack=P=>{P.streams.length!==0&&(h.value=P.streams[0])},n.oniceconnectionstatechange=()=>{n.iceConnectionState},n.onicecandidate=P=>{P.candidate},n.addTransceiver("video",{direction:"recvonly"}),n.addTransceiver("audio",{direction:"recvonly"});const a=await n.createOffer();await n.setLocalDescription(a);const k=await(await fetch(`${G("webrtc","/play")}/${i.streamPath}`,{method:"POST",mode:"cors",cache:"no-cache",credentials:"include",redirect:"follow",referrerPolicy:"no-referrer",headers:{"Content-Type":"application/sdp"},body:a.sdp})).text();await n.setRemoteDescription(new RTCSessionDescription({type:"answer",sdp:k})),n.ondatachannel=P=>{const he=P.channel,X=new Ye(he);O(new K(X,j.PUSH)),X.connect()},s=n;return}await s.connect()}catch(n){ne.error({message:"播放失败",description:n instanceof Event?"连接失败":String(n)}),t("play","connect error")}}});const M="cmd".split("").map(n=>n.charCodeAt(0));Ee(()=>i.pause,n=>{i.format==="ws-flv"&&s.send(new Uint8Array([...M,n?1:2]))});function O(n){if(v&&typeof MediaStreamTrackGenerator=="function"){const a=new MediaStreamTrackGenerator({kind:"audio"});m=a.writable.getWriter(),a.onmute=()=>{t("play","audio mute")};const d=new MediaStreamTrackGenerator({kind:"video"});w=d.writable.getWriter(),d.onmute=()=>{t("play","videomute")},h.value=new MediaStream([a,d])}n.on(B.VIDEO_ENCODER_CONFIG_CHANGED,a=>{f={...a},delete f.description,S.state==="initialized"&&S.configure(f),!v&&x.value&&(l=new qe(x.value))}),n.on(B.AUDIO_ENCODER_CONFIG_CHANGED,a=>{C=a;try{b.configure({...a})}catch(d){console.error(d)}}),n.gotVideo=a=>{try{if(S.state!=="configured"){console.warn("Video decoder not configured yet, waiting...");return}if(!E&&a.type!=="key"){console.warn("Waiting for keyframe...");return}a.type==="key"&&(E||(E=!0)),S.decode(a),y=a.timestamp,i.startTime!==void 0&&i.startTime!==null&&t("postion",y-o+i.startTime)}catch(d){console.error(d,a)}},n.gotAudio=a=>{if(b.state!=="configured"){console.warn("Audio decoder not configured yet, waiting...");return}b.decode(a)}}const U=R(!0);return Te(()=>{if(!v&&u.value){const n=document.createElement("canvas");n.style.width="100%",n.style.objectFit="cover",n.style.borderRadius="6px",i.videoShadow&&(n.style.boxShadow="4px 4px 8px 4px #dedede"),u.value.parentElement?.replaceChild(n,u.value),x.value=n}Ie(u.value,"canplay",()=>{U.value=!1,clearInterval(r)})}),Ae(()=>{clearInterval(r),s?.close(),w&&w.close(),m&&m.close(),l&&(l=null)}),(n,a)=>(F(),H("div",ct,[U.value?(F(),H("div",lt,[g(ie(ce),{current:c.value?.currentStep,direction:"vertical",size:"small"},{default:Ne(()=>[(F(!0),H(Oe,null,Ue(c.value?.steps,(d,k)=>(F(),Ve(ie(ce).Step,{key:k,title:d.name,description:d.description,status:d.error?"error":k==c.value?.currentStep?"process":"wait"},null,8,["title","description","status"]))),128))]),_:1},8,["current"])])):$e("",!0),Me(Be("video",{ref_key:"videoEle",ref:u,class:ze(["video",{videoShadow:n.videoShadow}]),srcObject:h.value,autoplay:""},null,10,dt),[[Re,!U.value]]),Fe(n.$slots,"default",{},void 0,!0)]))}});const ht=je(ut,[["__scopeId","data-v-de0eabac"]]);export{ht as V};
  2. //# sourceMappingURL=jb4-5138f1a1.js.map