quickvo-player 0.2.2 → 0.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/QuickVoPlayer.d.ts +1 -0
- package/dist/index.js +10 -8
- package/dist/index.umd.cjs +4 -4
- package/package.json +2 -2
package/dist/QuickVoPlayer.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -5,7 +5,7 @@ var X = (h) => {
|
|
|
5
5
|
var tt = (h, o, a) => o in h ? Q(h, o, { enumerable: !0, configurable: !0, writable: !0, value: a }) : h[o] = a;
|
|
6
6
|
var m = (h, o, a) => tt(h, typeof o != "symbol" ? o + "" : o, a), Z = (h, o, a) => o.has(h) || X("Cannot " + a);
|
|
7
7
|
var I = (h, o, a) => (Z(h, o, "read from private field"), a ? a.call(h) : o.get(h)), J = (h, o, a) => o.has(h) ? X("Cannot add the same private member more than once") : o instanceof WeakSet ? o.add(h) : o.set(h, a), H = (h, o, a, u) => (Z(h, o, "write to private field"), u ? u.call(h, a) : o.set(h, a), a);
|
|
8
|
-
const D = '(function(){"use strict";class P{pendingPayloads=[];payload=new Uint8Array(0);chunks=[];push=t=>{this.pendingPayloads.push(t)};next=(t=0)=>{this.payload=this.payload.slice(t);const s=this.pendingPayloads.shift();if(!s)return!1;const e=new Uint8Array(this.payload.byteLength+s.byteLength);return e.set(this.payload,0),e.set(s,this.payload.byteLength),this.payload=e,new DataView(this.payload.buffer)};pushChunk=t=>{this.chunks.push(t),this.chunks.length>1e3&&this.chunks.shift()};destroy=()=>{this.pendingPayloads=[],this.payload=new Uint8Array(0),this.chunks=[]}}const I=(y,t)=>{const s=new Uint8Array(y),e=new Uint8Array(t),n=new Uint8Array(11+s.length+e.length);let a=0;return n[a++]=1,n[a++]=s[1],n[a++]=s[2],n[a++]=s[3],n[a++]=255,n[a++]=225,n[a++]=s.length>>8&255,n[a++]=s.length&255,n.set(s,a),a+=s.length,n[a++]=1,n[a++]=e.length>>8&255,n[a++]=e.length&255,n.set(e,a),n},T=y=>{let t=0;const s=new DataView(y.buffer),e=s.getUint8(t);if(t=t+1,e!==1)throw new Error("Invalid AVC version");const n=s.getUint8(t)&255;t=t+1;const a=s.getUint8(t)&255;t=t+1;const o=s.getUint8(t)&255;t=t+1;const c=`avc1.${Array.from([n,a,o],U=>U.toString(16).padStart(2,"0")).join("")}`,r=(s.getUint8(t)&3)-1;t=t+1;const g=s.getUint8(t)&31;t=t+1;const p=s.getUint16(t,!1);t=t+2;const h=new Uint8Array(s.buffer.slice(t,t+p));t=t+p;const d=s.getUint8(t)&31;t=t+1;const u=s.getUint16(t,!1);t=t+2;const f=new Uint8Array(s.buffer.slice(t,t+u));return t=t+u,{version:e,codec:c,profile:n,compatibility:a,level:o,lengthSizeMinusOne:r,numOfSequenceParameterSets:g,sequenceParameterSetLength:p,sps:h,numOfPictureParameterSets:d,pictureParameterSetLength:u,pps:f}},M=y=>{const t=new Uint8Array(4+y.length);return new DataView(t.buffer).setUint32(0,y.length,!1),t.set(y,4),t},C=y=>{let t=0;for(const n of y)t+=n.length;const s=new Uint8Array(t);let e=0;for(const n of y){const a=n;s.set(a,e),e+=a.length}return s},D=y=>{let t="unknown";switch(y){case 1:case 2:case 27:case 36:t="video";break;case 3:case 4:case 15:t="audio";break;case 6:t="subtitle";break;case 134:t="ad";break}return t};class x{pat;pmt;audioConfig;videoConfig;payloadMap=new Map;on={};constructor(){}parse=async t=>{let s=0;for(;!(s+188>t.byteLength);){if(t.getInt8(s)!=71){s++;continue}await this.parsePacket(t,s),s+=188}return s};parsePacket=async(t,s)=>{if(s+188>t.byteLength)throw new Error("Invalid TS packet");if(t.getUint8(s)!==71)throw new Error("Invalid TS packet");let e=s;const n=this.parseHeader(t,e);e+=4;const{transport_error_indicator:a,pid:o,payload_unit_start_indicator:l,adaptation_field_control:i}=n;if(a===1||o===void 0)return;let c=184;if(i===2||i===3){const r=t.getUint8(e);e+=1,this.parseAdaptationField(t,e),e+=r,c-=r}if(i===3&&(c-=1),i===1||i===3){const r=new Uint8Array(t.buffer.slice(e,e+c));if(o===0)return this.parsePAT(t,e);{const{programs:h=[]}=this.pat||{};if(h.find(u=>u.pmt_pid===o))return this.parsePMT(t,e)}const{streams:g=[]}=this.pmt||{},p=g.find(h=>h.elementary_pid===o);if(p){if(l===1){const h=this.payloadMap.get(o);if(h){switch(p.kind){case"audio":{const d=await this.parseAudio(h);this.on.chunk&&this.on.chunk(d)}break;case"video":{const d=await this.parseVideo(h);this.on.chunk&&this.on.chunk(d),await new Promise(u=>setTimeout(()=>u(!0),0))}break}this.payloadMap.delete(o)}}{this.payloadMap.has(o)||this.payloadMap.set(o,new Uint8Array);const h=this.payloadMap.get(o),d=new Uint8Array(h.byteLength+r.byteLength);d.set(h,0),d.set(r,h.byteLength),this.payloadMap.set(o,d)}}}};parseHeader=(t,s)=>{let e=s;const n=t.getUint8(e),a=t.getUint8(e+1),o=t.getUint8(e+2),l=t.getUint8(e+3),i=(a&128)>>7;if(i===1)return{sync_byte:n,transport_error_indicator:i};const c=(a&64)>>6,r=(a&32)>>5,g=(a&31)<<8|o,p=(l&192)>>6,h=l>>4&3,d=l&15;return{sync_byte:n,transport_error_indicator:i,payload_unit_start_indicator:c,transport_priority:r,pid:g,transport_scrambling_control:p,adaptation_field_control:h,continuity_counter:d}};parsePAT=(t,s)=>{let e=s,n;{const l=t.getUint8(e);e+=1;const i=t.getUint8(e);if(e+=1,i!==0)throw new Error("Invalid PAT table_id");const c=t.getUint16(e)&4095;e+=2;const r=t.getUint16(e);e+=2;const g=(t.getUint8(e)&62)>>1,p=t.getUint8(e)&1;e+=1;const h=t.getUint8(e);e+=1;const d=t.getUint8(e);e+=1,n={pointer_field:l,table_id:i,section_length:c,transport_stream_id:r,version_number:g,current_next_indicator:p,section_number:h,last_section_number:d}}const a=[];{const l=n.section_length-5-4,i=e+l;for(;e<i;){const c=t.getUint16(e),r=t.getUint16(e+2)&8191;e+=4,c!==0&&r>=32&&r<=8190&&a.push({program_number:c,pmt_pid:r})}}const o=t.getUint32(e);this.pat={header:n,programs:a,crc32:o},this.on.debug&&this.on.debug({pat:this.pat})};parsePMT=(t,s)=>{let e=s,n;{const l=t.getUint8(e);e+=1;const i=t.getUint8(e);if(e+=1,i!==2)throw new Error("Invalid PMT table_id");const c=t.getUint16(e)&4095;e+=2;const r=t.getUint16(e);e+=2;const g=(t.getUint8(e)&62)>>1,p=t.getUint8(e)&1;e+=1;const h=t.getUint8(e);e+=1;const d=t.getUint8(e);e+=1;const u=t.getUint16(e)&8191;e+=2;const f=t.getUint16(e)&4095;e+=2,n={pointer_field:l,table_id:i,section_length:c,transport_stream_id:r,version_number:g,current_next_indicator:p,section_number:h,last_section_number:d,pcr_pid:u,program_info_length:f}}const a=[];{const l=n.section_length-9-4,i=e+l;for(;e<i;){const c=t.getUint8(e),r=D(c),g=t.getUint16(e+1)&8191,p=t.getUint16(e+3)&4095;if(e+=5,g<32||g>8190){console.warn(`Invalid elementary_pid: 0x${g.toString(16)}`);continue}a.push({kind:r,stream_type:c,elementary_pid:g,es_info_length:p})}}const o=t.getUint32(e);this.pmt={header:n,streams:a,crc32:o},this.on.debug&&this.on.debug({pmt:this.pmt})};parseAdaptationField=(t,s)=>{let e=s,n,a,o,l;const i=t.getUint8(e),c=!!(i&128),r=!!(i&64),g=!!(i&32),p=!!(i&16),h=!!(i&8),d=!!(i&4),u=!!(i&2),f=!!(i&1);e+=1;const U=(_,b)=>{let m=BigInt(0);m|=BigInt(_.getUint16(b))<<25n,m|=BigInt(_.getUint16(b+1))<<17n,m|=BigInt(_.getUint16(b+2))<<9n,m|=BigInt(_.getUint16(b+3))<<1n,m|=BigInt(_.getUint16(b+4)>>7);const S=(_.getUint16(b+4)&1)<<8|_.getUint16(b+5);return m=m*300n+BigInt(S),m};if(p&&(n=U(t,e),e+=6),h&&(a=U(t,e),e+=6),d&&(o=t.getInt8(e),e+=1),u){const _=t.getUint8(e);e+=1,l=new Uint8Array(t.buffer,e,_),e+=_}return{discontinuity_indicator:c,random_access_indicator:r,elementary_stream_priority_indicator:g,pcr_flag:p,opcr_flag:h,splicing_point_flag:d,transport_private_data_flag:u,adaptation_field_extension_flag:f,pcr:n,opcr:a,splice_countdown:o,transport_private_data:l}};parseAudio=async t=>{const s=new DataView(t.buffer);let e=0,n,a;{const o=s.getUint8(e)===0&&s.getUint8(e+1)===0&&s.getUint8(e+2)===1;if(e+=3,!o)throw new Error("invalid ts audio payload.");const l=s.getUint8(e);e+=1;const i=s.getUint8(e)<<8|s.getUint8(e+1);e+=2;let c,r,g,p,h;{const f=s.getUint8(e);e+=1,c=f>>4&3,r=(f>>3&1)===1,g=(f>>2&1)===1,p=(f>>1&1)===1,h=(f&1)===1}let d,u;{const f=s.getUint8(e);e+=1;const U=f>>6,_=s.getUint8(e);e+=1,(U&2)===2&&(d=this.parsePtsDts(s,e)),(U&1)===1?u=this.parsePtsDts(s,e+5):u=d,e+=_}n={stream_id:l,pes_packet_length:i,scrambling_control:c,priority:r,data_alignment:g,copyright:p,original_copy:h,pts:d,dts:u}}a=t.slice(e);{if(!this.audioConfig&&s.getUint8(e)===255){const g=s.getUint8(e+2),p=s.getUint8(e+3);let h,d;d=g>>2&15,h=(g&1)<<2|p>>6;const u=`mp4a.40.${h}`,U=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350][d];this.audioConfig={kind:"audio",codec:u,sampleRate:U,numberOfChannels:h},this.on.config&&this.on.config(this.audioConfig)}const{dts:o=0,pts:l=0}=n,i=l-o,c=a.slice(7);return{kind:"audio",type:"key",dts:o,pts:l,cts:i,data:c}}};parseVideo=async t=>{const s=new DataView(t.buffer);let e=0,n,a;{const o=s.getUint8(e)===0&&s.getUint8(e+1)===0&&s.getUint8(e+2)===1;if(e+=3,!o)throw new Error("invalid ts video payload.");const l=s.getUint8(e);e+=1;const i=s.getUint8(e)<<8|s.getUint8(e+1);e+=2;let c,r,g,p,h;{const f=s.getUint8(e);e+=1,c=f>>4&3,r=(f>>3&1)===1,g=(f>>2&1)===1,p=(f>>1&1)===1,h=(f&1)===1}let d,u;{const f=s.getUint8(e);e+=1;const U=f>>6,_=s.getUint8(e);e+=1,(U&2)===2&&(d=this.parsePtsDts(s,e)),(U&1)===1?u=this.parsePtsDts(s,e+5):u=d,e+=_}n={stream_id:l,pes_packet_length:i,scrambling_control:c,priority:r,data_alignment:g,copyright:p,original_copy:h,pts:d,dts:u}}a=t.slice(e);{const o=this.getNalus(a);if(!this.videoConfig){let h,d;if(h=o.find(f=>f.type===7)?.nalu.slice(4),d=o.find(f=>f.type===8)?.nalu.slice(4),h&&d){const u=I(h,d),{codec:f}=T(u);this.videoConfig={kind:"video",codec:f,description:u,sps:h,pps:d},this.on.config&&this.on.config(this.videoConfig)}}const l=[];let i="delta";for(const h of o){const{type:d,nalu:u}=h;switch(d){case 6:case 9:l.push(u);break;case 1:i="delta",l.push(u);break;case 5:i="key",l.push(u);break}}const c=C(l),{dts:r=0,pts:g=0}=n,p=g-r;return{kind:"video",type:i,dts:r,pts:g,cts:p,data:c,nalus:l}}};parsePtsDts(t,s){const e=t.getUint8(s),n=t.getUint8(s+1),a=t.getUint8(s+2),o=t.getUint8(s+3),l=t.getUint8(s+4),i=(BigInt(e)&0b00001110n)<<29n|(BigInt(n)&0b11111111n)<<22n|(BigInt(a)&0b11111110n)<<14n|(BigInt(o)&0b11111111n)<<7n|(BigInt(l)&0b11111110n)>>1n;return Number(i)/90}getNalus=t=>{const s=[];let e=0;for(;!(e+4>t.byteLength);){if(t[e]!==0||t[e+1]!==0||t[e+2]!==1){e+=1;continue}e+=3;let n=e;const a=t[e]&31;for(e+=1;!(e+1>t.byteLength);){if(t[e]!==0||t[e+1]!==0||t[e+2]!==1){e+=1;continue}break}let o=e-n;if(t[e-1]===0&&(o-=1),o!==0){const l=t.slice(n,n+o),i=M(l);s.push({type:a,nalu:i})}}return s}}const k=(y,t)=>y.getUint8(t)<<16|y.getUint8(t+1)<<8|y.getUint8(t+2);class L{audioConfig;videoConfig;header;textDecoder=new TextDecoder("utf-8");on={};constructor(){}parse=async t=>{let s=0;for(this.header||(this.parseHeader(t,s),s+=9);this.isSurplusTag(t,s)!==!1;){const n=this.parseTagHeader(t,s+4),{tagType:a,dataSize:o,timestamp:l}=n;if(a){const i=this.parseTagBody(a,t,s+4+11,o);switch(a){case"script":this.on.info&&this.on.info(i);break;case"audio":{const{accPacketType:c}=i;if(c===0){const{codec:r,sampleRate:g,channelConfiguration:p}=i;this.audioConfig={kind:"audio",codec:r,sampleRate:g,numberOfChannels:p},this.on.config&&this.on.config(this.audioConfig)}else{const{cts:r,data:g}=i,p="key",h=r===void 0?void 0:r+l;this.on.chunk&&this.on.chunk({kind:"audio",type:p,dts:l,pts:h,cts:r,data:g})}}break;case"video":{const{avcPacketType:c}=i;if(c===0){const{codec:r,sps:g,pps:p,data:h}=i;this.videoConfig={kind:"video",codec:r,description:h,sps:g,pps:p},this.on.config&&this.on.config(this.videoConfig)}else{const{frameType:r,cts:g,data:p,nalus:h}=i,d=r===1?"key":"delta",u=g===void 0?void 0:g+l;this.on.chunk&&this.on.chunk({kind:"video",type:d,dts:l,pts:u,cts:g,data:p,nalus:h})}}break}s=s+4+11+o}await new Promise(i=>setTimeout(()=>i(!0),8))}return s};parseHeader=(t,s)=>{let e,n,a,o;e=t.getUint8(s)<<16|t.getUint8(s+1)<<8|t.getUint8(s+2),n=t.getUint8(3);{const i=t.getUint8(0).toString(2).padStart(5,"0").split(""),[,,c,,r]=i;a={audio:r==="1",video:c==="1"}}o=t.getUint32(5),this.header={signature:e,version:n,flags:a,dataOffset:o}};isSurplusTag=(t,s)=>{let e=!0;const n=t.byteLength;if(s+4>n)e=!1;else if(s+4+11>n)e=!1;else{const a=k(t,s+4+1);s+4+11+a>n&&(e=!1)}return e};parseTagHeader=(t,s)=>{let e,n,a,o,l;{const i=t.getUint8(s);let c;switch(i){case 18:c="script";break;case 8:c="audio";break;case 9:c="video";break}e=c}return n=k(t,s+1),a=k(t,s+4),o=t.getUint8(s+7),l=k(t,s+8),{tagType:e,dataSize:n,timestamp:a,timestampExtended:o,streamID:l}};parseTagBody=(t,s,e,n)=>{let a;switch(t){case"script":a=this.parseMetaData(s,e);break;case"audio":a=this.parseAudio(s,e,n);break;case"video":a=this.parseVideo(s,e,n);break}return a};parseMetaData=(t,s)=>{let e=s;{if(t.getUint8(e)!==2)throw new Error("Invalid AMF type for onMetaData (expected 0x02)");e=e+1}const n=t.getUint16(e,!1);e=e+2;{const l=new Int8Array(t.buffer.slice(e,e+n));if((this.textDecoder?.decode(l)||"")!=="onMetaData")throw new Error("Expected \'onMetaData\' string");e=e+n}const a=this.getAmfType(t,e);return e=e+1,this.getAMFValue(t,e,a).value};parseAudio=(t,s,e)=>{let n=s;const a=t.getUint8(n),o=a>>4&15,l=a>>2&3,i=a>>1&1,c=a&1;n=n+1;const r=t.getUint8(n);n=n+1;const g=e,p=new Uint8Array(t.buffer.slice(n,n+g));if(o===10&&r===0){const h=t.getUint8(n),d=t.getUint8(n+1),u=h>>3&31,f=(h&7)<<1|d>>7,U=d>>3&15,_=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350],b=`mp4a.40.${u}`,m=_[f];return{soundFormat:o,soundRate:l,soundSize:i,soundType:c,accPacketType:r,data:p,samplingFrequencyIndex:f,channelConfiguration:U,codec:b,sampleRate:m}}return{soundFormat:o,soundRate:l,soundSize:i,soundType:c,accPacketType:r,data:p}};parseVideo=(t,s,e)=>{let n=s;const a=t.getUint8(n),o=a>>4&15,l=a&15;n=n+1;const i=t.getUint8(n);n=n+1;const c=k(t,n);n=n+3;const r=e-5,g=new Uint8Array(t.buffer.slice(n,n+r));switch(l){case 7:if(i===0){const p=T(g);return{frameType:o,codecID:l,avcPacketType:i,cts:c,data:g,...p}}else if(i===1){const p=[],h=n+e-5;for(;!(n+4>h);){const d=t.getUint32(n,!1),u=new Uint8Array(t.buffer.slice(n,n+4+d));n+=4+d,p.push(u)}return{frameType:o,codecID:l,avcPacketType:i,cts:c,data:g,nalus:p}}break;default:throw new Error("Unsupported codecID")}return{frameType:o,codecID:l,avcPacketType:i,cts:c,data:g}};getAmfType=(t,s)=>t.getUint8(s);getAMFName=(t,s,e)=>{const n=new Uint8Array(t.buffer.slice(s,s+e));return this.textDecoder?.decode(n)||""};getAMFValue=(t,s,e)=>{let n=s,a,o=0;switch(e){case 0:a=t.getFloat64(n,!1),o=8;break;case 1:a=!!t.getUint8(n),o=1;break;case 2:{a="";const i=t.getUint16(n,!1);n=n+2;const c=new Int8Array(t.buffer,n,i).filter(g=>g!==0);a=(this.textDecoder?.decode(c)||"").trim(),o=2+i}break;case 3:for(a={};n<t.byteLength;){const i=t.getUint16(n,!1);if(i===0)break;n=n+2;const c=this.getAMFName(t,n,i);n=n+i;const r=this.getAmfType(t,n);if(r===6)break;n=n+1;const g=this.getAMFValue(t,n,r);n=n+g.length,a[c]=g.value,o=2+i+1+g.length}break;case 8:{a={};const i=t.getUint32(n,!1);n=n+4;for(let c=0;c<i;c++){const r=t.getUint16(n,!1);n=n+2;const g=this.getAMFName(t,n,r);n=n+r;const p=this.getAmfType(t,n);n=n+1;const h=this.getAMFValue(t,n,p);n=n+h.length,a[g]=h.value,o=2+r+1+h.length}}break;case 10:{a=[];const i=t.getUint32(n,!1);n=n+4;for(let c=0;c<i;c++){const r=this.getAmfType(t,n);n=n+1;const g=this.getAMFValue(t,n,r);n=n+g.length,a.push(g.value),o=1+g.length}}break}return{amfType:e,length:o,value:a}}}class O{pattern;cacher=new P;isParseing=!1;offset=0;on={};parser;constructor(){}init=t=>{switch(this.destroy(),this.pattern=t,this.pattern){case"flv":this.parser=new L;break;case"hls":this.parser=new x;break;default:throw new Error("is error pattern.")}this.parser.on.debug=s=>this.on.debug&&this.on.debug(s),this.parser.on.info=s=>this.on.info&&this.on.info(s),this.parser.on.config=s=>this.on.config&&this.on.config(s),this.parser.on.chunk=s=>{this.cacher.pushChunk(s),this.on.chunk&&this.on.chunk(s)}};push=t=>{this.cacher.push(t),this.isParseing===!1&&this.parse()};destroy=()=>{this.cacher.destroy(),this.isParseing=!1,this.offset=0};parse=async()=>{try{if(this.isParseing=!0,!this.pattern)throw new Error("You need to set the pattern.");if(!this.parser)throw new Error("You need to init parser.");for(;;){const t=this.cacher.next(this.offset);if(this.offset=0,!t)break;this.offset=await this.parser.parse(t)}this.isParseing=!1}catch{this.destroy()}}}const A=new O;A.on.info=y=>postMessage({action:"on.info",data:y}),A.on.config=y=>postMessage({action:"on.config",data:y}),A.on.chunk=y=>postMessage({action:"on.chunk",data:y}),A.on.debug=y=>postMessage({action:"on.debug",data:y}),onmessage=y=>{const{action:t,data:s}=y.data,e=A[t];e&&e(s)}})();\n', _ = typeof self < "u" && self.Blob && new Blob(["(self.URL || self.webkitURL).revokeObjectURL(self.location.href);", D], { type: "text/javascript;charset=utf-8" });
|
|
8
|
+
const D = '(function(){"use strict";class P{pendingPayloads=[];payload=new Uint8Array(0);chunks=[];push=t=>{this.pendingPayloads.push(t)};next=(t=0)=>{this.payload=this.payload.slice(t);const s=this.pendingPayloads.shift();if(!s)return!1;const e=new Uint8Array(this.payload.byteLength+s.byteLength);return e.set(this.payload,0),e.set(s,this.payload.byteLength),this.payload=e,new DataView(this.payload.buffer)};pushChunk=t=>{this.chunks.push(t),this.chunks.length>1e3&&this.chunks.shift()};destroy=()=>{this.pendingPayloads=[],this.payload=new Uint8Array(0),this.chunks=[]}}const I=(y,t)=>{const s=new Uint8Array(y),e=new Uint8Array(t),n=new Uint8Array(11+s.length+e.length);let a=0;return n[a++]=1,n[a++]=s[1],n[a++]=s[2],n[a++]=s[3],n[a++]=255,n[a++]=225,n[a++]=s.length>>8&255,n[a++]=s.length&255,n.set(s,a),a+=s.length,n[a++]=1,n[a++]=e.length>>8&255,n[a++]=e.length&255,n.set(e,a),n},T=y=>{let t=0;const s=new DataView(y.buffer),e=s.getUint8(t);if(t=t+1,e!==1)throw new Error("Invalid AVC version");const n=s.getUint8(t)&255;t=t+1;const a=s.getUint8(t)&255;t=t+1;const o=s.getUint8(t)&255;t=t+1;const c=`avc1.${Array.from([n,a,o],U=>U.toString(16).padStart(2,"0")).join("")}`,r=(s.getUint8(t)&3)-1;t=t+1;const g=s.getUint8(t)&31;t=t+1;const p=s.getUint16(t,!1);t=t+2;const h=new Uint8Array(s.buffer.slice(t,t+p));t=t+p;const d=s.getUint8(t)&31;t=t+1;const u=s.getUint16(t,!1);t=t+2;const f=new Uint8Array(s.buffer.slice(t,t+u));return t=t+u,{version:e,codec:c,profile:n,compatibility:a,level:o,lengthSizeMinusOne:r,numOfSequenceParameterSets:g,sequenceParameterSetLength:p,sps:h,numOfPictureParameterSets:d,pictureParameterSetLength:u,pps:f}},M=y=>{const t=new Uint8Array(4+y.length);return new DataView(t.buffer).setUint32(0,y.length,!1),t.set(y,4),t},C=y=>{let t=0;for(const n of y)t+=n.length;const s=new Uint8Array(t);let e=0;for(const n of y){const a=n;s.set(a,e),e+=a.length}return s},D=y=>{let t="unknown";switch(y){case 1:case 2:case 27:case 36:t="video";break;case 3:case 4:case 15:t="audio";break;case 6:t="subtitle";break;case 134:t="ad";break}return t};class x{pat;pmt;audioConfig;videoConfig;payloadMap=new Map;on={};constructor(){}parse=async t=>{let s=0;for(;!(s+188>t.byteLength);){if(t.getInt8(s)!=71){s++;continue}await this.parsePacket(t,s),s+=188}return s};parsePacket=async(t,s)=>{if(s+188>t.byteLength)throw new Error("Invalid TS packet");if(t.getUint8(s)!==71)throw new Error("Invalid TS packet");let e=s;const n=this.parseHeader(t,e);e+=4;const{transport_error_indicator:a,pid:o,payload_unit_start_indicator:l,adaptation_field_control:i}=n;if(a===1||o===void 0)return;let c=184;if(i===2||i===3){const r=t.getUint8(e);e+=1,this.parseAdaptationField(t,e),e+=r,c-=r}if(i===3&&(c-=1),i===1||i===3){const r=new Uint8Array(t.buffer.slice(e,e+c));if(o===0)return this.parsePAT(t,e);{const{programs:h=[]}=this.pat||{};if(h.find(u=>u.pmt_pid===o))return this.parsePMT(t,e)}const{streams:g=[]}=this.pmt||{},p=g.find(h=>h.elementary_pid===o);if(p){if(l===1){const h=this.payloadMap.get(o);if(h){switch(p.kind){case"audio":{const d=await this.parseAudio(h);this.on.chunk&&this.on.chunk(d)}break;case"video":{const d=await this.parseVideo(h);this.on.chunk&&this.on.chunk(d),await new Promise(u=>setTimeout(()=>u(!0),0))}break}this.payloadMap.delete(o)}}{this.payloadMap.has(o)||this.payloadMap.set(o,new Uint8Array);const h=this.payloadMap.get(o),d=new Uint8Array(h.byteLength+r.byteLength);d.set(h,0),d.set(r,h.byteLength),this.payloadMap.set(o,d)}}}};parseHeader=(t,s)=>{let e=s;const n=t.getUint8(e),a=t.getUint8(e+1),o=t.getUint8(e+2),l=t.getUint8(e+3),i=(a&128)>>7;if(i===1)return{sync_byte:n,transport_error_indicator:i};const c=(a&64)>>6,r=(a&32)>>5,g=(a&31)<<8|o,p=(l&192)>>6,h=l>>4&3,d=l&15;return{sync_byte:n,transport_error_indicator:i,payload_unit_start_indicator:c,transport_priority:r,pid:g,transport_scrambling_control:p,adaptation_field_control:h,continuity_counter:d}};parsePAT=(t,s)=>{let e=s,n;{const l=t.getUint8(e);e+=1;const i=t.getUint8(e);if(e+=1,i!==0)throw new Error("Invalid PAT table_id");const c=t.getUint16(e)&4095;e+=2;const r=t.getUint16(e);e+=2;const g=(t.getUint8(e)&62)>>1,p=t.getUint8(e)&1;e+=1;const h=t.getUint8(e);e+=1;const d=t.getUint8(e);e+=1,n={pointer_field:l,table_id:i,section_length:c,transport_stream_id:r,version_number:g,current_next_indicator:p,section_number:h,last_section_number:d}}const a=[];{const l=n.section_length-5-4,i=e+l;for(;e<i;){const c=t.getUint16(e),r=t.getUint16(e+2)&8191;e+=4,c!==0&&r>=32&&r<=8190&&a.push({program_number:c,pmt_pid:r})}}const o=t.getUint32(e);this.pat={header:n,programs:a,crc32:o},this.on.debug&&this.on.debug({pat:this.pat})};parsePMT=(t,s)=>{let e=s,n;{const l=t.getUint8(e);e+=1;const i=t.getUint8(e);if(e+=1,i!==2)throw new Error("Invalid PMT table_id");const c=t.getUint16(e)&4095;e+=2;const r=t.getUint16(e);e+=2;const g=(t.getUint8(e)&62)>>1,p=t.getUint8(e)&1;e+=1;const h=t.getUint8(e);e+=1;const d=t.getUint8(e);e+=1;const u=t.getUint16(e)&8191;e+=2;const f=t.getUint16(e)&4095;e+=2,n={pointer_field:l,table_id:i,section_length:c,transport_stream_id:r,version_number:g,current_next_indicator:p,section_number:h,last_section_number:d,pcr_pid:u,program_info_length:f}}const a=[];{const l=n.section_length-9-4,i=e+l;for(;e<i;){const c=t.getUint8(e),r=D(c),g=t.getUint16(e+1)&8191,p=t.getUint16(e+3)&4095;if(e+=5,g<32||g>8190){console.warn(`Invalid elementary_pid: 0x${g.toString(16)}`);continue}a.push({kind:r,stream_type:c,elementary_pid:g,es_info_length:p})}}const o=t.getUint32(e);this.pmt={header:n,streams:a,crc32:o},this.on.debug&&this.on.debug({pmt:this.pmt})};parseAdaptationField=(t,s)=>{let e=s,n,a,o,l;const i=t.getUint8(e),c=!!(i&128),r=!!(i&64),g=!!(i&32),p=!!(i&16),h=!!(i&8),d=!!(i&4),u=!!(i&2),f=!!(i&1);e+=1;const U=(_,b)=>{let m=BigInt(0);m|=BigInt(_.getUint16(b))<<25n,m|=BigInt(_.getUint16(b+1))<<17n,m|=BigInt(_.getUint16(b+2))<<9n,m|=BigInt(_.getUint16(b+3))<<1n,m|=BigInt(_.getUint16(b+4)>>7);const S=(_.getUint16(b+4)&1)<<8|_.getUint16(b+5);return m=m*300n+BigInt(S),m};if(p&&(n=U(t,e),e+=6),h&&(a=U(t,e),e+=6),d&&(o=t.getInt8(e),e+=1),u){const _=t.getUint8(e);e+=1,l=new Uint8Array(t.buffer,e,_),e+=_}return{discontinuity_indicator:c,random_access_indicator:r,elementary_stream_priority_indicator:g,pcr_flag:p,opcr_flag:h,splicing_point_flag:d,transport_private_data_flag:u,adaptation_field_extension_flag:f,pcr:n,opcr:a,splice_countdown:o,transport_private_data:l}};parseAudio=async t=>{const s=new DataView(t.buffer);let e=0,n,a;{const o=s.getUint8(e)===0&&s.getUint8(e+1)===0&&s.getUint8(e+2)===1;if(e+=3,!o)throw new Error("invalid ts audio payload.");const l=s.getUint8(e);e+=1;const i=s.getUint8(e)<<8|s.getUint8(e+1);e+=2;let c,r,g,p,h;{const f=s.getUint8(e);e+=1,c=f>>4&3,r=(f>>3&1)===1,g=(f>>2&1)===1,p=(f>>1&1)===1,h=(f&1)===1}let d,u;{const f=s.getUint8(e);e+=1;const U=f>>6,_=s.getUint8(e);e+=1,(U&2)===2&&(d=this.parsePtsDts(s,e)),(U&1)===1?u=this.parsePtsDts(s,e+5):u=d,e+=_}n={stream_id:l,pes_packet_length:i,scrambling_control:c,priority:r,data_alignment:g,copyright:p,original_copy:h,pts:d,dts:u}}a=t.slice(e);{if(!this.audioConfig&&s.getUint8(e)===255){const g=s.getUint8(e+2),p=s.getUint8(e+3);let h,d;d=g>>2&15,h=(g&1)<<2|p>>6;const u=`mp4a.40.${h}`,U=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350][d];this.audioConfig={kind:"audio",codec:u,sampleRate:U,numberOfChannels:h},this.on.config&&this.on.config(this.audioConfig)}const{dts:o=0,pts:l=0}=n,i=l-o,c=a.slice(7);return{kind:"audio",type:"key",dts:o,pts:l,cts:i,data:c}}};parseVideo=async t=>{const s=new DataView(t.buffer);let e=0,n,a;{const o=s.getUint8(e)===0&&s.getUint8(e+1)===0&&s.getUint8(e+2)===1;if(e+=3,!o)throw new Error("invalid ts video payload.");const l=s.getUint8(e);e+=1;const i=s.getUint8(e)<<8|s.getUint8(e+1);e+=2;let c,r,g,p,h;{const f=s.getUint8(e);e+=1,c=f>>4&3,r=(f>>3&1)===1,g=(f>>2&1)===1,p=(f>>1&1)===1,h=(f&1)===1}let d,u;{const f=s.getUint8(e);e+=1;const U=f>>6,_=s.getUint8(e);e+=1,(U&2)===2&&(d=this.parsePtsDts(s,e)),(U&1)===1?u=this.parsePtsDts(s,e+5):u=d,e+=_}n={stream_id:l,pes_packet_length:i,scrambling_control:c,priority:r,data_alignment:g,copyright:p,original_copy:h,pts:d,dts:u}}a=t.slice(e);{const o=this.getNalus(a);if(!this.videoConfig){let h,d;if(h=o.find(f=>f.type===7)?.nalu.slice(4),d=o.find(f=>f.type===8)?.nalu.slice(4),h&&d){const u=I(h,d),{codec:f}=T(u);this.videoConfig={kind:"video",codec:f,description:u,sps:h,pps:d},this.on.config&&this.on.config(this.videoConfig)}}const l=[];let i="delta";for(const h of o){const{type:d,nalu:u}=h;switch(d){case 6:case 9:l.push(u);break;case 1:i="delta",l.push(u);break;case 5:i="key",l.push(u);break}}const c=C(l),{dts:r=0,pts:g=0}=n,p=g-r;return{kind:"video",type:i,dts:r,pts:g,cts:p,data:c,nalus:l}}};parsePtsDts(t,s){const e=t.getUint8(s),n=t.getUint8(s+1),a=t.getUint8(s+2),o=t.getUint8(s+3),l=t.getUint8(s+4),i=(BigInt(e)&0b00001110n)<<29n|(BigInt(n)&0b11111111n)<<22n|(BigInt(a)&0b11111110n)<<14n|(BigInt(o)&0b11111111n)<<7n|(BigInt(l)&0b11111110n)>>1n;return Number(i)/90}getNalus=t=>{const s=[];let e=0;for(;!(e+4>t.byteLength);){if(t[e]!==0||t[e+1]!==0||t[e+2]!==1){e+=1;continue}e+=3;let n=e;const a=t[e]&31;for(e+=1;!(e+1>t.byteLength);){if(t[e]!==0||t[e+1]!==0||t[e+2]!==1){e+=1;continue}break}let o=e-n;if(t[e-1]===0&&(o-=1),o!==0){const l=t.slice(n,n+o),i=M(l);s.push({type:a,nalu:i})}}return s}}const k=(y,t)=>y.getUint8(t)<<16|y.getUint8(t+1)<<8|y.getUint8(t+2);class L{audioConfig;videoConfig;header;textDecoder=new TextDecoder("utf-8");on={};constructor(){}parse=async t=>{let s=0;for(this.header||(this.parseHeader(t,s),s+=9);this.isSurplusTag(t,s)!==!1;){const n=this.parseTagHeader(t,s+4),{tagType:a,dataSize:o,timestamp:l}=n;if(a){const i=this.parseTagBody(a,t,s+4+11,o);switch(a){case"script":this.on.info&&this.on.info(i);break;case"audio":{const{accPacketType:c}=i;if(c===0){const{codec:r,sampleRate:g,channelConfiguration:p}=i;this.audioConfig={kind:"audio",codec:r,sampleRate:g,numberOfChannels:p},this.on.config&&this.on.config(this.audioConfig)}else{const{cts:r,data:g}=i,p="key",h=r===void 0?void 0:r+l;this.on.chunk&&this.on.chunk({kind:"audio",type:p,dts:l,pts:h,cts:r,data:g})}}break;case"video":{const{avcPacketType:c}=i;if(c===0){const{codec:r,sps:g,pps:p,data:h}=i;this.videoConfig={kind:"video",codec:r,description:h,sps:g,pps:p},this.on.config&&this.on.config(this.videoConfig)}else{const{frameType:r,cts:g,data:p,nalus:h}=i,d=r===1?"key":"delta",u=g===void 0?void 0:g+l;this.on.chunk&&this.on.chunk({kind:"video",type:d,dts:l,pts:u,cts:g,data:p,nalus:h})}}break}s=s+4+11+o}await new Promise(i=>setTimeout(()=>i(!0),8))}return s};parseHeader=(t,s)=>{let e,n,a,o;e=t.getUint8(s)<<16|t.getUint8(s+1)<<8|t.getUint8(s+2),n=t.getUint8(3);{const i=t.getUint8(0).toString(2).padStart(5,"0").split(""),[,,c,,r]=i;a={audio:r==="1",video:c==="1"}}o=t.getUint32(5),this.header={signature:e,version:n,flags:a,dataOffset:o}};isSurplusTag=(t,s)=>{let e=!0;const n=t.byteLength;if(s+4>n)e=!1;else if(s+4+11>n)e=!1;else{const a=k(t,s+4+1);s+4+11+a>n&&(e=!1)}return e};parseTagHeader=(t,s)=>{let e,n,a,o,l;{const i=t.getUint8(s);let c;switch(i){case 18:c="script";break;case 8:c="audio";break;case 9:c="video";break}e=c}return n=k(t,s+1),a=k(t,s+4),o=t.getUint8(s+7),l=k(t,s+8),{tagType:e,dataSize:n,timestamp:a,timestampExtended:o,streamID:l}};parseTagBody=(t,s,e,n)=>{let a;switch(t){case"script":a=this.parseMetaData(s,e);break;case"audio":a=this.parseAudio(s,e,n);break;case"video":a=this.parseVideo(s,e,n);break}return a};parseMetaData=(t,s)=>{let e=s;{if(t.getUint8(e)!==2)throw new Error("Invalid AMF type for onMetaData (expected 0x02)");e=e+1}const n=t.getUint16(e,!1);e=e+2;{const l=new Int8Array(t.buffer.slice(e,e+n));if((this.textDecoder?.decode(l)||"")!=="onMetaData")throw new Error("Expected \'onMetaData\' string");e=e+n}const a=this.getAmfType(t,e);return e=e+1,this.getAMFValue(t,e,a).value};parseAudio=(t,s,e)=>{let n=s;const a=t.getUint8(n),o=a>>4&15,l=a>>2&3,i=a>>1&1,c=a&1;n=n+1;const r=t.getUint8(n);n=n+1;const g=e,p=new Uint8Array(t.buffer.slice(n,n+g));if(o===10&&r===0){const h=t.getUint8(n),d=t.getUint8(n+1),u=h>>3&31,f=(h&7)<<1|d>>7,U=d>>3&15,_=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350],b=`mp4a.40.${u}`,m=_[f];return{soundFormat:o,soundRate:l,soundSize:i,soundType:c,accPacketType:r,data:p,samplingFrequencyIndex:f,channelConfiguration:U,codec:b,sampleRate:m}}return{soundFormat:o,soundRate:l,soundSize:i,soundType:c,accPacketType:r,data:p}};parseVideo=(t,s,e)=>{let n=s;const a=t.getUint8(n),o=a>>4&15,l=a&15;n=n+1;const i=t.getUint8(n);n=n+1;const c=k(t,n);n=n+3;const r=e-5,g=new Uint8Array(t.buffer.slice(n,n+r));switch(l){case 7:if(i===0){const p=T(g);return{frameType:o,codecID:l,avcPacketType:i,cts:c,data:g,...p}}else if(i===1){const p=[],h=n+e-5;for(;!(n+4>h);){const d=t.getUint32(n,!1),u=new Uint8Array(t.buffer.slice(n,n+4+d));n+=4+d,p.push(u)}return{frameType:o,codecID:l,avcPacketType:i,cts:c,data:g,nalus:p}}break;default:throw new Error("Unsupported codecID")}return{frameType:o,codecID:l,avcPacketType:i,cts:c,data:g}};getAmfType=(t,s)=>t.getUint8(s);getAMFName=(t,s,e)=>{const n=new Uint8Array(t.buffer.slice(s,s+e));return this.textDecoder?.decode(n)||""};getAMFValue=(t,s,e)=>{let n=s,a,o=0;switch(e){case 0:a=t.getFloat64(n,!1),o=8;break;case 1:a=!!t.getUint8(n),o=1;break;case 2:{a="";const i=t.getUint16(n,!1);n=n+2;const c=new Int8Array(t.buffer,n,i).filter(g=>g!==0);a=(this.textDecoder?.decode(c)||"").trim(),o=2+i}break;case 3:for(a={};n<t.byteLength;){const i=t.getUint16(n,!1);if(i===0)break;n=n+2;const c=this.getAMFName(t,n,i);n=n+i;const r=this.getAmfType(t,n);if(r===6)break;n=n+1;const g=this.getAMFValue(t,n,r);n=n+g.length,a[c]=g.value,o=2+i+1+g.length}break;case 8:{a={};const i=t.getUint32(n,!1);n=n+4;for(let c=0;c<i;c++){const r=t.getUint16(n,!1);n=n+2;const g=this.getAMFName(t,n,r);n=n+r;const p=this.getAmfType(t,n);n=n+1;const h=this.getAMFValue(t,n,p);n=n+h.length,a[g]=h.value,o=2+r+1+h.length}}break;case 10:{a=[];const i=t.getUint32(n,!1);n=n+4;for(let c=0;c<i;c++){const r=this.getAmfType(t,n);n=n+1;const g=this.getAMFValue(t,n,r);n=n+g.length,a.push(g.value),o=1+g.length}}break}return{amfType:e,length:o,value:a}}}class O{pattern;cacher=new P;isParseing=!1;offset=0;parser;on={};constructor(){}init=t=>{switch(this.destroy(),this.pattern=t,this.pattern){case"flv":this.parser=new L;break;case"hls":this.parser=new x;break;default:throw new Error("is error pattern.")}this.parser.on.debug=s=>this.on.debug&&this.on.debug(s),this.parser.on.info=s=>this.on.info&&this.on.info(s),this.parser.on.config=s=>this.on.config&&this.on.config(s),this.parser.on.chunk=s=>{this.cacher.pushChunk(s),this.on.chunk&&this.on.chunk(s)}};push=t=>{this.cacher.push(t),this.isParseing===!1&&this.parse()};destroy=()=>{this.cacher.destroy(),this.isParseing=!1,this.offset=0};parse=async()=>{try{if(this.isParseing=!0,!this.pattern)throw new Error("You need to set the pattern.");if(!this.parser)throw new Error("You need to init parser.");for(;;){const t=this.cacher.next(this.offset);if(this.offset=0,!t)break;this.offset=await this.parser.parse(t)}this.isParseing=!1}catch{this.destroy()}}}const A=new O;A.on.info=y=>postMessage({action:"on.info",data:y}),A.on.config=y=>postMessage({action:"on.config",data:y}),A.on.chunk=y=>postMessage({action:"on.chunk",data:y}),A.on.debug=y=>postMessage({action:"on.debug",data:y}),onmessage=y=>{const{action:t,data:s}=y.data,e=A[t];e&&e(s)}})();\n', _ = typeof self < "u" && self.Blob && new Blob(["(self.URL || self.webkitURL).revokeObjectURL(self.location.href);", D], { type: "text/javascript;charset=utf-8" });
|
|
9
9
|
function L(h) {
|
|
10
10
|
let o;
|
|
11
11
|
try {
|
|
@@ -53,7 +53,7 @@ class V {
|
|
|
53
53
|
};
|
|
54
54
|
}
|
|
55
55
|
}
|
|
56
|
-
const S = `(function(){"use strict";class
|
|
56
|
+
const S = `(function(){"use strict";class r{pattern="flv";audioDecoderConfig;audioDecoder;videoDecoderConfig;videoDecoder;hasKeyFrame=!1;baseTime=0;pendingChunks=[];currentChunk;isProcessing=!1;decodeTimer=0;frameTrack=!1;isFrameTrack=!1;fameTrackOption={flv:[30,50],hls:[200,300],dash:[50,100],rtmp:[50,100]};decodingSpeedRatio=1;maxDecodingSpeedRatio=2;decodingSpeed=16;fps=0;firstVideoChunkTimestamp;secondVideoChunkTimestamp;frameStartTime;lastRenderTime;nextRenderTime;on={audio:{},video:{}};constructor(){}init=e=>{this.destroy(),this.pattern=e,this.baseTime=new Date().getTime()-performance.now(),this.initDecodeInterval()};initAudio=e=>{this.audio.destroy(),this.audioDecoderConfig={...e},this.audioDecoder=new AudioDecoder({output:i=>{const o=this.decodingSpeedRatio;this.on.audio.decode&&this.on.audio.decode({audioData:i,playbackRate:o})},error:i=>{this.on.audio.error&&this.on.audio.error(i)}}),this.audioDecoder.configure(this.audioDecoderConfig)};initVideo=e=>{this.video.destroy(),this.videoDecoderConfig={...e},this.videoDecoder=new VideoDecoder({output:async i=>{this.frameStartTime||(this.frameStartTime=i.timestamp);const o=i.timestamp-this.frameStartTime+this.baseTime*1e3,s=await createImageBitmap(i);i.close(),s.width>0&&s.height>0?(this.on.video.decode&&this.on.video.decode({timestamp:o,bitmap:s}),this.currentChunk&&this.currentChunk.kind==="video"&&this.currentChunk.nalus&&this.on.nalus&&this.on.nalus(this.currentChunk.nalus)):s.close()},error:i=>{this.on.video.error&&this.on.video.error(i)}}),this.videoDecoder.configure(this.videoDecoderConfig)};setFrameTrack=e=>{this.frameTrack=e,this.frameTrack===!1&&(this.decodingSpeedRatio=1)};push=e=>{this.pendingChunks.push(e)};destroy=()=>{this.audio.destroy(),this.video.destroy(),this.pendingChunks=[],this.firstVideoChunkTimestamp=void 0,this.secondVideoChunkTimestamp=void 0,this.frameStartTime=void 0,this.lastRenderTime=void 0,this.nextRenderTime=void 0,clearInterval(this.decodeTimer)};initDecodeInterval=()=>{let e=this.decodingSpeed/this.decodingSpeedRatio;const i=this.baseTime+performance.now();if(this.lastRenderTime||(this.lastRenderTime=i),this.fps=Math.round(1e3/(i-this.lastRenderTime)),this.lastRenderTime=i,this.nextRenderTime){const o=this.lastRenderTime-this.nextRenderTime;e-=o}this.nextRenderTime=this.lastRenderTime+e,this.decodeTimer=setTimeout(()=>{this.decode(),this.initDecodeInterval()},e)};decode=()=>{if(this.isProcessing!==!0){for(this.isProcessing=!0;;){this.currentChunk=this.pendingChunks.shift();const e=this.pendingChunks.length;if(this.frameTrack){const[s,n]=this.fameTrackOption[this.pattern];if(e<=s&&(this.isFrameTrack=!1),e>=n&&(this.isFrameTrack=!0),this.isFrameTrack){const a=Math.min(1+(e-s)/100,this.maxDecodingSpeedRatio);this.decodingSpeedRatio=Number(a.toFixed(1))}else this.decodingSpeedRatio=1}if(this.on.analysis){const{decodingSpeed:s,decodingSpeedRatio:n,fps:a}=this;this.on.analysis({decodingSpeed:s,decodingSpeedRatio:n,fps:a,cacheLength:e})}if(!this.currentChunk)break;const{kind:i,init:o}=this.currentChunk;switch(i){case"audio":this.decodeAudio(o);break;case"video":this.decodeVideo(o);break}if(i==="video")break}this.isProcessing=!1}};decodeAudio=e=>{if(!this.audioDecoder)return;const i=new EncodedAudioChunk(e);this.audioDecoder.decode(i)};decodeVideo=e=>{if(this.videoDecoder&&(e.type==="key"&&(this.hasKeyFrame=!0),this.firstVideoChunkTimestamp?this.secondVideoChunkTimestamp||(this.secondVideoChunkTimestamp=e.timestamp,this.decodingSpeed=(this.secondVideoChunkTimestamp-this.firstVideoChunkTimestamp)/1e3):this.firstVideoChunkTimestamp=e.timestamp,this.hasKeyFrame)){const i=new EncodedVideoChunk(e);this.videoDecoder.decode(i)}};audio={flush:()=>{this.audioDecoder?.flush()},destroy:()=>{this.audioDecoderConfig=void 0,this.audioDecoder?.close(),this.audioDecoder=void 0}};video={flush:()=>{this.videoDecoder?.flush()},destroy:()=>{this.videoDecoderConfig=void 0,this.videoDecoder?.close(),this.videoDecoder=void 0,this.hasKeyFrame=!1}}}const d=new r;d.on.audio.decode=t=>postMessage({action:"on.audio.decode",data:t}),d.on.audio.error=t=>postMessage({action:"on.audio.error",data:t}),d.on.video.decode=t=>postMessage({action:"on.video.decode",data:t}),d.on.video.error=t=>postMessage({action:"on.video.error",data:t}),d.on.nalus=t=>postMessage({action:"on.nalus",data:t}),d.on.analysis=t=>postMessage({action:"on.analysis",data:t}),onmessage=t=>{const{action:e,data:i}=t.data,o=d[e];o&&o(i)}})();
|
|
57
57
|
`, C = typeof self < "u" && self.Blob && new Blob(["(self.URL || self.webkitURL).revokeObjectURL(self.location.href);", S], { type: "text/javascript;charset=utf-8" });
|
|
58
58
|
function F(h) {
|
|
59
59
|
let o;
|
|
@@ -104,8 +104,8 @@ class N {
|
|
|
104
104
|
case "on.nalus":
|
|
105
105
|
this.on.nalus && this.on.nalus(u);
|
|
106
106
|
break;
|
|
107
|
-
case "on.
|
|
108
|
-
this.on.
|
|
107
|
+
case "on.analysis":
|
|
108
|
+
this.on.analysis && this.on.analysis(u);
|
|
109
109
|
break;
|
|
110
110
|
}
|
|
111
111
|
};
|
|
@@ -568,9 +568,7 @@ class et {
|
|
|
568
568
|
m(this, "initDecoder", (o) => {
|
|
569
569
|
this.decoderWorker = new N(), this.decoderWorker.init(o);
|
|
570
570
|
const { frameTrack: a = !1 } = this.option;
|
|
571
|
-
this.decoderWorker.setFrameTrack(a), this.decoderWorker.on.
|
|
572
|
-
this.option.debug && console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", "------->pr-player: debug", u);
|
|
573
|
-
}, this.decoderWorker.on.audio.decode = (u) => {
|
|
571
|
+
this.decoderWorker.setFrameTrack(a), this.decoderWorker.on.audio.decode = (u) => {
|
|
574
572
|
var r;
|
|
575
573
|
(r = this.audioPlayer) == null || r.push(u), this.on.decoder.audio && this.on.decoder.audio(u);
|
|
576
574
|
}, this.decoderWorker.on.audio.error = (u) => {
|
|
@@ -590,6 +588,8 @@ class et {
|
|
|
590
588
|
const { header: n, data: i } = Y(r), { nal_unit_type: t } = n;
|
|
591
589
|
t === 6 && this.on.decoder.sei && this.on.decoder.sei(i);
|
|
592
590
|
}
|
|
591
|
+
}, this.decoderWorker.on.analysis = (u) => {
|
|
592
|
+
this.on.decoder.analysis && this.on.decoder.analysis(u);
|
|
593
593
|
};
|
|
594
594
|
});
|
|
595
595
|
/**
|
|
@@ -2450,6 +2450,8 @@ class QuickVoPlayer {
|
|
|
2450
2450
|
m(this, "usersMap", /* @__PURE__ */ new Map());
|
|
2451
2451
|
m(this, "on", {
|
|
2452
2452
|
users: (o) => {
|
|
2453
|
+
},
|
|
2454
|
+
analysis: (o) => {
|
|
2453
2455
|
}
|
|
2454
2456
|
});
|
|
2455
2457
|
m(this, "start", async (o) => (this.stop(), this.prPlayer.start(o)));
|
|
@@ -2558,7 +2560,7 @@ class QuickVoPlayer {
|
|
|
2558
2560
|
});
|
|
2559
2561
|
const { debug: a = !1 } = o;
|
|
2560
2562
|
this.option.debug = a, this.prPlayer = new et({ debug: a }), this.prPlayer.on.demuxer.chunk = (u) => {
|
|
2561
|
-
}, this.prPlayer.on.decoder.sei = this.onSEI;
|
|
2563
|
+
}, this.prPlayer.on.decoder.sei = this.onSEI, this.prPlayer.on.decoder.analysis = this.on.analysis;
|
|
2562
2564
|
}
|
|
2563
2565
|
}
|
|
2564
2566
|
export {
|
package/dist/index.umd.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(U,T){typeof exports=="object"&&typeof module<"u"?T(exports):typeof define=="function"&&define.amd?define(["exports"],T):(U=typeof globalThis<"u"?globalThis:U||self,T(U["quickvo-player"]={}))})(this,function(exports){"use strict";var Z=Object.defineProperty;var X=U=>{throw TypeError(U)};var tt=(U,T,h)=>T in U?Z(U,T,{enumerable:!0,configurable:!0,writable:!0,value:h}):U[T]=h;var m=(U,T,h)=>tt(U,typeof T!="symbol"?T+"":T,h),Q=(U,T,h)=>T.has(U)||X("Cannot "+h);var P=(U,T,h)=>(Q(U,T,"read from private field"),h?h.call(U):T.get(U)),J=(U,T,h)=>T.has(U)?X("Cannot add the same private member more than once"):T instanceof WeakSet?T.add(U):T.set(U,h),H=(U,T,h,r)=>(Q(U,T,"write to private field"),r?r.call(U,h):T.set(U,h),h);var U,T;const D='(function(){"use strict";class P{pendingPayloads=[];payload=new Uint8Array(0);chunks=[];push=t=>{this.pendingPayloads.push(t)};next=(t=0)=>{this.payload=this.payload.slice(t);const s=this.pendingPayloads.shift();if(!s)return!1;const e=new Uint8Array(this.payload.byteLength+s.byteLength);return e.set(this.payload,0),e.set(s,this.payload.byteLength),this.payload=e,new DataView(this.payload.buffer)};pushChunk=t=>{this.chunks.push(t),this.chunks.length>1e3&&this.chunks.shift()};destroy=()=>{this.pendingPayloads=[],this.payload=new Uint8Array(0),this.chunks=[]}}const I=(y,t)=>{const s=new Uint8Array(y),e=new Uint8Array(t),n=new Uint8Array(11+s.length+e.length);let a=0;return n[a++]=1,n[a++]=s[1],n[a++]=s[2],n[a++]=s[3],n[a++]=255,n[a++]=225,n[a++]=s.length>>8&255,n[a++]=s.length&255,n.set(s,a),a+=s.length,n[a++]=1,n[a++]=e.length>>8&255,n[a++]=e.length&255,n.set(e,a),n},T=y=>{let t=0;const s=new DataView(y.buffer),e=s.getUint8(t);if(t=t+1,e!==1)throw new Error("Invalid AVC version");const n=s.getUint8(t)&255;t=t+1;const a=s.getUint8(t)&255;t=t+1;const o=s.getUint8(t)&255;t=t+1;const c=`avc1.${Array.from([n,a,o],U=>U.toString(16).padStart(2,"0")).join("")}`,r=(s.getUint8(t)&3)-1;t=t+1;const g=s.getUint8(t)&31;t=t+1;const p=s.getUint16(t,!1);t=t+2;const h=new Uint8Array(s.buffer.slice(t,t+p));t=t+p;const d=s.getUint8(t)&31;t=t+1;const u=s.getUint16(t,!1);t=t+2;const f=new Uint8Array(s.buffer.slice(t,t+u));return t=t+u,{version:e,codec:c,profile:n,compatibility:a,level:o,lengthSizeMinusOne:r,numOfSequenceParameterSets:g,sequenceParameterSetLength:p,sps:h,numOfPictureParameterSets:d,pictureParameterSetLength:u,pps:f}},M=y=>{const t=new Uint8Array(4+y.length);return new DataView(t.buffer).setUint32(0,y.length,!1),t.set(y,4),t},C=y=>{let t=0;for(const n of y)t+=n.length;const s=new Uint8Array(t);let e=0;for(const n of y){const a=n;s.set(a,e),e+=a.length}return s},D=y=>{let t="unknown";switch(y){case 1:case 2:case 27:case 36:t="video";break;case 3:case 4:case 15:t="audio";break;case 6:t="subtitle";break;case 134:t="ad";break}return t};class x{pat;pmt;audioConfig;videoConfig;payloadMap=new Map;on={};constructor(){}parse=async t=>{let s=0;for(;!(s+188>t.byteLength);){if(t.getInt8(s)!=71){s++;continue}await this.parsePacket(t,s),s+=188}return s};parsePacket=async(t,s)=>{if(s+188>t.byteLength)throw new Error("Invalid TS packet");if(t.getUint8(s)!==71)throw new Error("Invalid TS packet");let e=s;const n=this.parseHeader(t,e);e+=4;const{transport_error_indicator:a,pid:o,payload_unit_start_indicator:l,adaptation_field_control:i}=n;if(a===1||o===void 0)return;let c=184;if(i===2||i===3){const r=t.getUint8(e);e+=1,this.parseAdaptationField(t,e),e+=r,c-=r}if(i===3&&(c-=1),i===1||i===3){const r=new Uint8Array(t.buffer.slice(e,e+c));if(o===0)return this.parsePAT(t,e);{const{programs:h=[]}=this.pat||{};if(h.find(u=>u.pmt_pid===o))return this.parsePMT(t,e)}const{streams:g=[]}=this.pmt||{},p=g.find(h=>h.elementary_pid===o);if(p){if(l===1){const h=this.payloadMap.get(o);if(h){switch(p.kind){case"audio":{const d=await this.parseAudio(h);this.on.chunk&&this.on.chunk(d)}break;case"video":{const d=await this.parseVideo(h);this.on.chunk&&this.on.chunk(d),await new Promise(u=>setTimeout(()=>u(!0),0))}break}this.payloadMap.delete(o)}}{this.payloadMap.has(o)||this.payloadMap.set(o,new Uint8Array);const h=this.payloadMap.get(o),d=new Uint8Array(h.byteLength+r.byteLength);d.set(h,0),d.set(r,h.byteLength),this.payloadMap.set(o,d)}}}};parseHeader=(t,s)=>{let e=s;const n=t.getUint8(e),a=t.getUint8(e+1),o=t.getUint8(e+2),l=t.getUint8(e+3),i=(a&128)>>7;if(i===1)return{sync_byte:n,transport_error_indicator:i};const c=(a&64)>>6,r=(a&32)>>5,g=(a&31)<<8|o,p=(l&192)>>6,h=l>>4&3,d=l&15;return{sync_byte:n,transport_error_indicator:i,payload_unit_start_indicator:c,transport_priority:r,pid:g,transport_scrambling_control:p,adaptation_field_control:h,continuity_counter:d}};parsePAT=(t,s)=>{let e=s,n;{const l=t.getUint8(e);e+=1;const i=t.getUint8(e);if(e+=1,i!==0)throw new Error("Invalid PAT table_id");const c=t.getUint16(e)&4095;e+=2;const r=t.getUint16(e);e+=2;const g=(t.getUint8(e)&62)>>1,p=t.getUint8(e)&1;e+=1;const h=t.getUint8(e);e+=1;const d=t.getUint8(e);e+=1,n={pointer_field:l,table_id:i,section_length:c,transport_stream_id:r,version_number:g,current_next_indicator:p,section_number:h,last_section_number:d}}const a=[];{const l=n.section_length-5-4,i=e+l;for(;e<i;){const c=t.getUint16(e),r=t.getUint16(e+2)&8191;e+=4,c!==0&&r>=32&&r<=8190&&a.push({program_number:c,pmt_pid:r})}}const o=t.getUint32(e);this.pat={header:n,programs:a,crc32:o},this.on.debug&&this.on.debug({pat:this.pat})};parsePMT=(t,s)=>{let e=s,n;{const l=t.getUint8(e);e+=1;const i=t.getUint8(e);if(e+=1,i!==2)throw new Error("Invalid PMT table_id");const c=t.getUint16(e)&4095;e+=2;const r=t.getUint16(e);e+=2;const g=(t.getUint8(e)&62)>>1,p=t.getUint8(e)&1;e+=1;const h=t.getUint8(e);e+=1;const d=t.getUint8(e);e+=1;const u=t.getUint16(e)&8191;e+=2;const f=t.getUint16(e)&4095;e+=2,n={pointer_field:l,table_id:i,section_length:c,transport_stream_id:r,version_number:g,current_next_indicator:p,section_number:h,last_section_number:d,pcr_pid:u,program_info_length:f}}const a=[];{const l=n.section_length-9-4,i=e+l;for(;e<i;){const c=t.getUint8(e),r=D(c),g=t.getUint16(e+1)&8191,p=t.getUint16(e+3)&4095;if(e+=5,g<32||g>8190){console.warn(`Invalid elementary_pid: 0x${g.toString(16)}`);continue}a.push({kind:r,stream_type:c,elementary_pid:g,es_info_length:p})}}const o=t.getUint32(e);this.pmt={header:n,streams:a,crc32:o},this.on.debug&&this.on.debug({pmt:this.pmt})};parseAdaptationField=(t,s)=>{let e=s,n,a,o,l;const i=t.getUint8(e),c=!!(i&128),r=!!(i&64),g=!!(i&32),p=!!(i&16),h=!!(i&8),d=!!(i&4),u=!!(i&2),f=!!(i&1);e+=1;const U=(_,b)=>{let m=BigInt(0);m|=BigInt(_.getUint16(b))<<25n,m|=BigInt(_.getUint16(b+1))<<17n,m|=BigInt(_.getUint16(b+2))<<9n,m|=BigInt(_.getUint16(b+3))<<1n,m|=BigInt(_.getUint16(b+4)>>7);const S=(_.getUint16(b+4)&1)<<8|_.getUint16(b+5);return m=m*300n+BigInt(S),m};if(p&&(n=U(t,e),e+=6),h&&(a=U(t,e),e+=6),d&&(o=t.getInt8(e),e+=1),u){const _=t.getUint8(e);e+=1,l=new Uint8Array(t.buffer,e,_),e+=_}return{discontinuity_indicator:c,random_access_indicator:r,elementary_stream_priority_indicator:g,pcr_flag:p,opcr_flag:h,splicing_point_flag:d,transport_private_data_flag:u,adaptation_field_extension_flag:f,pcr:n,opcr:a,splice_countdown:o,transport_private_data:l}};parseAudio=async t=>{const s=new DataView(t.buffer);let e=0,n,a;{const o=s.getUint8(e)===0&&s.getUint8(e+1)===0&&s.getUint8(e+2)===1;if(e+=3,!o)throw new Error("invalid ts audio payload.");const l=s.getUint8(e);e+=1;const i=s.getUint8(e)<<8|s.getUint8(e+1);e+=2;let c,r,g,p,h;{const f=s.getUint8(e);e+=1,c=f>>4&3,r=(f>>3&1)===1,g=(f>>2&1)===1,p=(f>>1&1)===1,h=(f&1)===1}let d,u;{const f=s.getUint8(e);e+=1;const U=f>>6,_=s.getUint8(e);e+=1,(U&2)===2&&(d=this.parsePtsDts(s,e)),(U&1)===1?u=this.parsePtsDts(s,e+5):u=d,e+=_}n={stream_id:l,pes_packet_length:i,scrambling_control:c,priority:r,data_alignment:g,copyright:p,original_copy:h,pts:d,dts:u}}a=t.slice(e);{if(!this.audioConfig&&s.getUint8(e)===255){const g=s.getUint8(e+2),p=s.getUint8(e+3);let h,d;d=g>>2&15,h=(g&1)<<2|p>>6;const u=`mp4a.40.${h}`,U=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350][d];this.audioConfig={kind:"audio",codec:u,sampleRate:U,numberOfChannels:h},this.on.config&&this.on.config(this.audioConfig)}const{dts:o=0,pts:l=0}=n,i=l-o,c=a.slice(7);return{kind:"audio",type:"key",dts:o,pts:l,cts:i,data:c}}};parseVideo=async t=>{const s=new DataView(t.buffer);let e=0,n,a;{const o=s.getUint8(e)===0&&s.getUint8(e+1)===0&&s.getUint8(e+2)===1;if(e+=3,!o)throw new Error("invalid ts video payload.");const l=s.getUint8(e);e+=1;const i=s.getUint8(e)<<8|s.getUint8(e+1);e+=2;let c,r,g,p,h;{const f=s.getUint8(e);e+=1,c=f>>4&3,r=(f>>3&1)===1,g=(f>>2&1)===1,p=(f>>1&1)===1,h=(f&1)===1}let d,u;{const f=s.getUint8(e);e+=1;const U=f>>6,_=s.getUint8(e);e+=1,(U&2)===2&&(d=this.parsePtsDts(s,e)),(U&1)===1?u=this.parsePtsDts(s,e+5):u=d,e+=_}n={stream_id:l,pes_packet_length:i,scrambling_control:c,priority:r,data_alignment:g,copyright:p,original_copy:h,pts:d,dts:u}}a=t.slice(e);{const o=this.getNalus(a);if(!this.videoConfig){let h,d;if(h=o.find(f=>f.type===7)?.nalu.slice(4),d=o.find(f=>f.type===8)?.nalu.slice(4),h&&d){const u=I(h,d),{codec:f}=T(u);this.videoConfig={kind:"video",codec:f,description:u,sps:h,pps:d},this.on.config&&this.on.config(this.videoConfig)}}const l=[];let i="delta";for(const h of o){const{type:d,nalu:u}=h;switch(d){case 6:case 9:l.push(u);break;case 1:i="delta",l.push(u);break;case 5:i="key",l.push(u);break}}const c=C(l),{dts:r=0,pts:g=0}=n,p=g-r;return{kind:"video",type:i,dts:r,pts:g,cts:p,data:c,nalus:l}}};parsePtsDts(t,s){const e=t.getUint8(s),n=t.getUint8(s+1),a=t.getUint8(s+2),o=t.getUint8(s+3),l=t.getUint8(s+4),i=(BigInt(e)&0b00001110n)<<29n|(BigInt(n)&0b11111111n)<<22n|(BigInt(a)&0b11111110n)<<14n|(BigInt(o)&0b11111111n)<<7n|(BigInt(l)&0b11111110n)>>1n;return Number(i)/90}getNalus=t=>{const s=[];let e=0;for(;!(e+4>t.byteLength);){if(t[e]!==0||t[e+1]!==0||t[e+2]!==1){e+=1;continue}e+=3;let n=e;const a=t[e]&31;for(e+=1;!(e+1>t.byteLength);){if(t[e]!==0||t[e+1]!==0||t[e+2]!==1){e+=1;continue}break}let o=e-n;if(t[e-1]===0&&(o-=1),o!==0){const l=t.slice(n,n+o),i=M(l);s.push({type:a,nalu:i})}}return s}}const k=(y,t)=>y.getUint8(t)<<16|y.getUint8(t+1)<<8|y.getUint8(t+2);class L{audioConfig;videoConfig;header;textDecoder=new TextDecoder("utf-8");on={};constructor(){}parse=async t=>{let s=0;for(this.header||(this.parseHeader(t,s),s+=9);this.isSurplusTag(t,s)!==!1;){const n=this.parseTagHeader(t,s+4),{tagType:a,dataSize:o,timestamp:l}=n;if(a){const i=this.parseTagBody(a,t,s+4+11,o);switch(a){case"script":this.on.info&&this.on.info(i);break;case"audio":{const{accPacketType:c}=i;if(c===0){const{codec:r,sampleRate:g,channelConfiguration:p}=i;this.audioConfig={kind:"audio",codec:r,sampleRate:g,numberOfChannels:p},this.on.config&&this.on.config(this.audioConfig)}else{const{cts:r,data:g}=i,p="key",h=r===void 0?void 0:r+l;this.on.chunk&&this.on.chunk({kind:"audio",type:p,dts:l,pts:h,cts:r,data:g})}}break;case"video":{const{avcPacketType:c}=i;if(c===0){const{codec:r,sps:g,pps:p,data:h}=i;this.videoConfig={kind:"video",codec:r,description:h,sps:g,pps:p},this.on.config&&this.on.config(this.videoConfig)}else{const{frameType:r,cts:g,data:p,nalus:h}=i,d=r===1?"key":"delta",u=g===void 0?void 0:g+l;this.on.chunk&&this.on.chunk({kind:"video",type:d,dts:l,pts:u,cts:g,data:p,nalus:h})}}break}s=s+4+11+o}await new Promise(i=>setTimeout(()=>i(!0),8))}return s};parseHeader=(t,s)=>{let e,n,a,o;e=t.getUint8(s)<<16|t.getUint8(s+1)<<8|t.getUint8(s+2),n=t.getUint8(3);{const i=t.getUint8(0).toString(2).padStart(5,"0").split(""),[,,c,,r]=i;a={audio:r==="1",video:c==="1"}}o=t.getUint32(5),this.header={signature:e,version:n,flags:a,dataOffset:o}};isSurplusTag=(t,s)=>{let e=!0;const n=t.byteLength;if(s+4>n)e=!1;else if(s+4+11>n)e=!1;else{const a=k(t,s+4+1);s+4+11+a>n&&(e=!1)}return e};parseTagHeader=(t,s)=>{let e,n,a,o,l;{const i=t.getUint8(s);let c;switch(i){case 18:c="script";break;case 8:c="audio";break;case 9:c="video";break}e=c}return n=k(t,s+1),a=k(t,s+4),o=t.getUint8(s+7),l=k(t,s+8),{tagType:e,dataSize:n,timestamp:a,timestampExtended:o,streamID:l}};parseTagBody=(t,s,e,n)=>{let a;switch(t){case"script":a=this.parseMetaData(s,e);break;case"audio":a=this.parseAudio(s,e,n);break;case"video":a=this.parseVideo(s,e,n);break}return a};parseMetaData=(t,s)=>{let e=s;{if(t.getUint8(e)!==2)throw new Error("Invalid AMF type for onMetaData (expected 0x02)");e=e+1}const n=t.getUint16(e,!1);e=e+2;{const l=new Int8Array(t.buffer.slice(e,e+n));if((this.textDecoder?.decode(l)||"")!=="onMetaData")throw new Error("Expected \'onMetaData\' string");e=e+n}const a=this.getAmfType(t,e);return e=e+1,this.getAMFValue(t,e,a).value};parseAudio=(t,s,e)=>{let n=s;const a=t.getUint8(n),o=a>>4&15,l=a>>2&3,i=a>>1&1,c=a&1;n=n+1;const r=t.getUint8(n);n=n+1;const g=e,p=new Uint8Array(t.buffer.slice(n,n+g));if(o===10&&r===0){const h=t.getUint8(n),d=t.getUint8(n+1),u=h>>3&31,f=(h&7)<<1|d>>7,U=d>>3&15,_=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350],b=`mp4a.40.${u}`,m=_[f];return{soundFormat:o,soundRate:l,soundSize:i,soundType:c,accPacketType:r,data:p,samplingFrequencyIndex:f,channelConfiguration:U,codec:b,sampleRate:m}}return{soundFormat:o,soundRate:l,soundSize:i,soundType:c,accPacketType:r,data:p}};parseVideo=(t,s,e)=>{let n=s;const a=t.getUint8(n),o=a>>4&15,l=a&15;n=n+1;const i=t.getUint8(n);n=n+1;const c=k(t,n);n=n+3;const r=e-5,g=new Uint8Array(t.buffer.slice(n,n+r));switch(l){case 7:if(i===0){const p=T(g);return{frameType:o,codecID:l,avcPacketType:i,cts:c,data:g,...p}}else if(i===1){const p=[],h=n+e-5;for(;!(n+4>h);){const d=t.getUint32(n,!1),u=new Uint8Array(t.buffer.slice(n,n+4+d));n+=4+d,p.push(u)}return{frameType:o,codecID:l,avcPacketType:i,cts:c,data:g,nalus:p}}break;default:throw new Error("Unsupported codecID")}return{frameType:o,codecID:l,avcPacketType:i,cts:c,data:g}};getAmfType=(t,s)=>t.getUint8(s);getAMFName=(t,s,e)=>{const n=new Uint8Array(t.buffer.slice(s,s+e));return this.textDecoder?.decode(n)||""};getAMFValue=(t,s,e)=>{let n=s,a,o=0;switch(e){case 0:a=t.getFloat64(n,!1),o=8;break;case 1:a=!!t.getUint8(n),o=1;break;case 2:{a="";const i=t.getUint16(n,!1);n=n+2;const c=new Int8Array(t.buffer,n,i).filter(g=>g!==0);a=(this.textDecoder?.decode(c)||"").trim(),o=2+i}break;case 3:for(a={};n<t.byteLength;){const i=t.getUint16(n,!1);if(i===0)break;n=n+2;const c=this.getAMFName(t,n,i);n=n+i;const r=this.getAmfType(t,n);if(r===6)break;n=n+1;const g=this.getAMFValue(t,n,r);n=n+g.length,a[c]=g.value,o=2+i+1+g.length}break;case 8:{a={};const i=t.getUint32(n,!1);n=n+4;for(let c=0;c<i;c++){const r=t.getUint16(n,!1);n=n+2;const g=this.getAMFName(t,n,r);n=n+r;const p=this.getAmfType(t,n);n=n+1;const h=this.getAMFValue(t,n,p);n=n+h.length,a[g]=h.value,o=2+r+1+h.length}}break;case 10:{a=[];const i=t.getUint32(n,!1);n=n+4;for(let c=0;c<i;c++){const r=this.getAmfType(t,n);n=n+1;const g=this.getAMFValue(t,n,r);n=n+g.length,a.push(g.value),o=1+g.length}}break}return{amfType:e,length:o,value:a}}}class O{pattern;cacher=new P;isParseing=!1;offset=0;on={};parser;constructor(){}init=t=>{switch(this.destroy(),this.pattern=t,this.pattern){case"flv":this.parser=new L;break;case"hls":this.parser=new x;break;default:throw new Error("is error pattern.")}this.parser.on.debug=s=>this.on.debug&&this.on.debug(s),this.parser.on.info=s=>this.on.info&&this.on.info(s),this.parser.on.config=s=>this.on.config&&this.on.config(s),this.parser.on.chunk=s=>{this.cacher.pushChunk(s),this.on.chunk&&this.on.chunk(s)}};push=t=>{this.cacher.push(t),this.isParseing===!1&&this.parse()};destroy=()=>{this.cacher.destroy(),this.isParseing=!1,this.offset=0};parse=async()=>{try{if(this.isParseing=!0,!this.pattern)throw new Error("You need to set the pattern.");if(!this.parser)throw new Error("You need to init parser.");for(;;){const t=this.cacher.next(this.offset);if(this.offset=0,!t)break;this.offset=await this.parser.parse(t)}this.isParseing=!1}catch{this.destroy()}}}const A=new O;A.on.info=y=>postMessage({action:"on.info",data:y}),A.on.config=y=>postMessage({action:"on.config",data:y}),A.on.chunk=y=>postMessage({action:"on.chunk",data:y}),A.on.debug=y=>postMessage({action:"on.debug",data:y}),onmessage=y=>{const{action:t,data:s}=y.data,e=A[t];e&&e(s)}})();\n',_=typeof self<"u"&&self.Blob&&new Blob(["(self.URL || self.webkitURL).revokeObjectURL(self.location.href);",D],{type:"text/javascript;charset=utf-8"});function L(h){let r;try{if(r=_&&(self.URL||self.webkitURL).createObjectURL(_),!r)throw"";const u=new Worker(r,{name:h==null?void 0:h.name});return u.addEventListener("error",()=>{(self.URL||self.webkitURL).revokeObjectURL(r)}),u}catch{return new Worker("data:text/javascript;charset=utf-8,"+encodeURIComponent(D),{name:h==null?void 0:h.name})}}class V{constructor(){m(this,"worker",new L);m(this,"on",{});m(this,"init",r=>this.worker.postMessage({action:"init",data:r}));m(this,"push",r=>this.worker.postMessage({action:"push",data:r}));m(this,"destroy",()=>{this.worker.postMessage({action:"destroy",data:{}}),this.worker.terminate()});this.worker.onmessage=r=>{const{action:u,data:a}=r.data;switch(u){case"on.info":this.on.info&&this.on.info(a);break;case"on.config":this.on.config&&this.on.config(a);break;case"on.chunk":this.on.chunk&&this.on.chunk(a);break;case"on.debug":this.on.debug&&this.on.debug(a);break}}}}const S=`(function(){"use strict";class a{pattern="flv";audioDecoderConfig;audioDecoder;videoDecoderConfig;videoDecoder;hasKeyFrame=!1;baseTime=0;pendingChunks=[];currentChunk;isProcessing=!1;decodeTimer=0;frameTrack=!1;isFrameTrack=!1;fameTrackOption={flv:[30,50],hls:[200,300],dash:[50,100],rtmp:[50,100]};decodingSpeedRatio=1;maxDecodingSpeedRatio=2;decodingSpeed=16;fps=0;firstVideoChunkTimestamp;secondVideoChunkTimestamp;frameStartTime;lastRenderTime;nextRenderTime;on={audio:{},video:{}};constructor(){}init=e=>{this.destroy(),this.pattern=e,this.baseTime=new Date().getTime()-performance.now(),this.initDecodeInterval()};initAudio=e=>{this.audio.destroy(),this.audioDecoderConfig={...e},this.audioDecoder=new AudioDecoder({output:i=>{const o=this.decodingSpeedRatio;this.on.audio.decode&&this.on.audio.decode({audioData:i,playbackRate:o})},error:i=>{this.on.audio.error&&this.on.audio.error(i)}}),this.audioDecoder.configure(this.audioDecoderConfig)};initVideo=e=>{this.video.destroy(),this.videoDecoderConfig={...e},this.videoDecoder=new VideoDecoder({output:async i=>{this.frameStartTime||(this.frameStartTime=i.timestamp);const o=i.timestamp-this.frameStartTime+this.baseTime*1e3,s=await createImageBitmap(i);i.close(),s.width>0&&s.height>0?(this.on.video.decode&&this.on.video.decode({timestamp:o,bitmap:s}),this.currentChunk&&this.currentChunk.kind==="video"&&this.currentChunk.nalus&&this.on.nalus&&this.on.nalus(this.currentChunk.nalus)):s.close()},error:i=>{this.on.video.error&&this.on.video.error(i)}}),this.videoDecoder.configure(this.videoDecoderConfig)};setFrameTrack=e=>{this.frameTrack=e,this.frameTrack===!1&&(this.decodingSpeedRatio=1)};push=e=>{this.pendingChunks.push(e)};destroy=()=>{this.audio.destroy(),this.video.destroy(),this.pendingChunks=[],this.firstVideoChunkTimestamp=void 0,this.secondVideoChunkTimestamp=void 0,this.frameStartTime=void 0,this.lastRenderTime=void 0,this.nextRenderTime=void 0,clearInterval(this.decodeTimer)};initDecodeInterval=()=>{let e=this.decodingSpeed/this.decodingSpeedRatio;const i=this.baseTime+performance.now();if(this.lastRenderTime||(this.lastRenderTime=i),this.fps=Math.round(1e3/(i-this.lastRenderTime)),this.lastRenderTime=i,this.nextRenderTime){const o=this.lastRenderTime-this.nextRenderTime;e-=o}this.nextRenderTime=this.lastRenderTime+e,this.decodeTimer=setTimeout(()=>{this.decode(),this.initDecodeInterval()},e)};decode=()=>{if(this.isProcessing!==!0){for(this.isProcessing=!0;;){this.currentChunk=this.pendingChunks.shift();const e=this.pendingChunks.length;if(this.frameTrack){const[s,n]=this.fameTrackOption[this.pattern];if(e<=s&&(this.isFrameTrack=!1),e>=n&&(this.isFrameTrack=!0),this.isFrameTrack){const r=Math.min(1+(e-s)/100,this.maxDecodingSpeedRatio);this.decodingSpeedRatio=Number(r.toFixed(1))}else this.decodingSpeedRatio=1}if(this.on.debug){const{decodingSpeed:s,decodingSpeedRatio:n,fps:r}=this;this.on.debug({decodingSpeed:s,decodingSpeedRatio:n,fps:r,cacheLength:e})}if(!this.currentChunk)break;const{kind:i,init:o}=this.currentChunk;switch(i){case"audio":this.decodeAudio(o);break;case"video":this.decodeVideo(o);break}if(i==="video")break}this.isProcessing=!1}};decodeAudio=e=>{if(!this.audioDecoder)return;const i=new EncodedAudioChunk(e);this.audioDecoder.decode(i)};decodeVideo=e=>{if(this.videoDecoder&&(e.type==="key"&&(this.hasKeyFrame=!0),this.firstVideoChunkTimestamp?this.secondVideoChunkTimestamp||(this.secondVideoChunkTimestamp=e.timestamp,this.decodingSpeed=(this.secondVideoChunkTimestamp-this.firstVideoChunkTimestamp)/1e3):this.firstVideoChunkTimestamp=e.timestamp,this.hasKeyFrame)){const i=new EncodedVideoChunk(e);this.videoDecoder.decode(i)}};audio={flush:()=>{this.audioDecoder?.flush()},destroy:()=>{this.audioDecoderConfig=void 0,this.audioDecoder?.close(),this.audioDecoder=void 0}};video={flush:()=>{this.videoDecoder?.flush()},destroy:()=>{this.videoDecoderConfig=void 0,this.videoDecoder?.close(),this.videoDecoder=void 0,this.hasKeyFrame=!1}}}const d=new a;d.on.audio.decode=t=>postMessage({action:"on.audio.decode",data:t}),d.on.audio.error=t=>postMessage({action:"on.audio.error",data:t}),d.on.video.decode=t=>postMessage({action:"on.video.decode",data:t}),d.on.video.error=t=>postMessage({action:"on.video.error",data:t}),d.on.nalus=t=>postMessage({action:"on.nalus",data:t}),d.on.debug=t=>postMessage({action:"on.debug",data:t}),onmessage=t=>{const{action:e,data:i}=t.data,o=d[e];o&&o(i)}})();
|
|
2
|
-
`,C=typeof self<"u"&&self.Blob&&new Blob(["(self.URL || self.webkitURL).revokeObjectURL(self.location.href);",S],{type:"text/javascript;charset=utf-8"});function F(h){let r;try{if(r=C&&(self.URL||self.webkitURL).createObjectURL(C),!r)throw"";const u=new Worker(r,{name:h==null?void 0:h.name});return u.addEventListener("error",()=>{(self.URL||self.webkitURL).revokeObjectURL(r)}),u}catch{return new Worker("data:text/javascript;charset=utf-8,"+encodeURIComponent(S),{name:h==null?void 0:h.name})}}class N{constructor(){m(this,"worker",new F);m(this,"on",{audio:{},video:{}});m(this,"init",r=>this.worker.postMessage({action:"init",data:r}));m(this,"initAudio",r=>this.worker.postMessage({action:"initAudio",data:r}));m(this,"initVideo",r=>this.worker.postMessage({action:"initVideo",data:r}));m(this,"push",r=>this.worker.postMessage({action:"push",data:r}));m(this,"setFrameTrack",r=>this.worker.postMessage({action:"setFrameTrack",data:r}));m(this,"destroy",()=>{this.worker.postMessage({action:"destroy"}),this.worker.terminate()});this.worker.onmessage=r=>{const{action:u,data:a}=r.data;switch(u){case"on.audio.decode":this.on.audio.decode&&this.on.audio.decode(a);break;case"on.audio.error":this.on.audio.error&&this.on.audio.error(a);break;case"on.video.decode":this.on.video.decode&&this.on.video.decode(a);break;case"on.video.error":this.on.video.error&&this.on.video.error(a);break;case"on.nalus":this.on.nalus&&this.on.nalus(a);break;case"on.
|
|
3
|
-
`,v=typeof self<"u"&&self.Blob&&new Blob(["(self.URL || self.webkitURL).revokeObjectURL(self.location.href);",R],{type:"text/javascript;charset=utf-8"});function j(h){let r;try{if(r=v&&(self.URL||self.webkitURL).createObjectURL(v),!r)throw"";const u=new Worker(r,{name:h==null?void 0:h.name});return u.addEventListener("error",()=>{(self.URL||self.webkitURL).revokeObjectURL(r)}),u}catch{return new Worker("data:text/javascript;charset=utf-8,"+encodeURIComponent(R),{name:h==null?void 0:h.name})}}class z{constructor(){m(this,"worker",new j);m(this,"init",({writable:r})=>this.worker.postMessage({action:"init",data:{writable:r}},[r]));m(this,"push",r=>this.worker.postMessage({action:"push",data:r}));m(this,"setCut",async r=>this.worker.postMessage({action:"setCut",data:r}));m(this,"setPause",r=>this.worker.postMessage({action:"setPause",data:r}));m(this,"destroy",()=>{this.worker.postMessage({action:"destroy",data:{}}),this.worker.terminate()})}}const q=h=>{const r=h.toLowerCase();return r.includes(".m3u8")||r.includes("hls")||r.includes("master.m3u8")||r.match(/index\d*\.m3u8/)?"hls":r.includes(".mpd")||r.includes("dash")?"dash":r.startsWith("rtmp://")||r.startsWith("rtmps://")?"rtmp":r.includes(".flv")||r.includes("flv")&&!r.includes("flash")?"flv":"unknown"},M=h=>{const r=(h==null?void 0:h.getTracks())||[];for(const u of r)u.stop()},A=()=>{const h=new MediaStreamTrackGenerator({kind:"video"}),r=new MediaStream([h]),u=new z;return u.init({writable:h.writable}),{worker:u,stream:r,destroy:()=>{u.destroy(),M(r)}}};class ${constructor(){m(this,"resolvesMap",new Map);m(this,"index",0);m(this,"add",(r,u=()=>!1,a=0)=>new Promise(n=>{var t,e;if(u())return n(!0);this.resolvesMap.has(r)||this.resolvesMap.set(r,new Map),this.index++;const o=`${this.index}`;if(a=Math.max(0,a),a===0){(t=this.resolvesMap.get(r))==null||t.set(o,{resolve:n,timer:0});return}const i=window.setTimeout(()=>{this.emit(r)},a);(e=this.resolvesMap.get(r))==null||e.set(o,{resolve:n,timer:i})}));m(this,"emit",async r=>{const u=this.resolvesMap.get(r);if(!u)return;const a=[...u.keys()];for(const n of a){const o=u.get(n);o&&(clearTimeout(o.timer),o.resolve(),u.delete(n))}})}}const Y=h=>{const r=new DataView(h.buffer);let u=0,a,n,o;a=r.getUint32(u,!1),u+=4;{const i=r.getUint8(u),t=i>>7&1,e=i>>5&3,s=i&31;n={forbidden_zero_bit:t,nal_ref_idc:e,nal_unit_type:s},u+=1}{const i=a-1;o=new Uint8Array(r.buffer.slice(u,u+i))}return{size:a,header:n,data:o}};class x{constructor(r={}){J(this,U,{timeout:5*1e3,check:!1});J(this,T);m(this,"check",(r,u)=>new Promise(async(a,n)=>{var i;this.stop(),H(this,T,new AbortController);const o=window.setTimeout(()=>{var t;(t=P(this,T))==null||t.abort("Timeout."),n({status:"timeout",reason:""})},P(this,U).timeout);try{const t=await fetch(r,{...u,method:"HEAD",signal:(i=P(this,T))==null?void 0:i.signal});t.status===200?a({status:"successed",reason:""}):n({status:"failed",reason:`${t.status}`})}catch(t){n({status:"error",reason:t.message})}clearTimeout(o)}));m(this,"request",async(r,u)=>new Promise(async(a,n)=>{var o;try{P(this,U).check&&await this.check(r,u),H(this,T,new AbortController);const i=await fetch(r,{...u,signal:(o=P(this,T))==null?void 0:o.signal});a(i)}catch(i){this.stop(),n(i)}}));m(this,"stop",()=>{var r;((r=P(this,T))==null?void 0:r.signal.aborted)===!1&&P(this,T).abort("Actively stop.")});H(this,U,{...P(this,U),...r})}}U=new WeakMap,T=new WeakMap;class et{constructor(r={}){m(this,"option",{debug:!1,frameTrack:!1});m(this,"prFetch",new x);m(this,"prResolves",new $);m(this,"url","");m(this,"demuxerWorker");m(this,"decoderWorker");m(this,"audioPlayer");m(this,"renderWorker");m(this,"stream");m(this,"on",{demuxer:{},decoder:{}});m(this,"cutRenders",new Map);m(this,"trackGenerator");m(this,"start",async r=>{this.stop(),this.url=r;const u=q(r);if(u==="unknown")throw new Error("This address cannot be parsed.");switch(this.init(u),u){case"flv":this.flv.start();break;case"hls":this.hls.start();break}});m(this,"stop",async()=>{var u,a,n,o,i;try{clearInterval(this.hls.getSegmentsTimer),this.prFetch.stop()}catch(t){console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m","color:#0097ff;","------->pr-player: error",t)}(u=this.demuxerWorker)==null||u.destroy(),(a=this.decoderWorker)==null||a.destroy(),(n=this.renderWorker)==null||n.destroy();const r=[...this.cutRenders.keys()];for(const t of r)(o=this.cutRenders.get(t))==null||o.worker.destroy(),this.cutRenders.delete(t);M(this.stream),(i=this.audioPlayer)==null||i.destroy()});m(this,"getStream",()=>this.stream);m(this,"setPause",r=>{var u;(u=this.renderWorker)==null||u.setPause(r)});m(this,"setMute",r=>{var u,a;return(a=(u=this.audioPlayer)==null?void 0:u.prAudioStream)==null?void 0:a.setMute(r)});m(this,"setFrameTrack",r=>{var u;this.option.frameTrack=r,(u=this.decoderWorker)==null||u.setFrameTrack(r)});m(this,"isReady",()=>{const r=()=>{var u;return((u=this.stream)==null?void 0:u.active)===!0};return this.prResolves.add("isReady",r)});m(this,"cut",{create:(r,u)=>{let a=this.cutRenders.get(r);return a?(a.worker.setCut(u),a.worker.setPause(!1),a):(a=A(),a.worker.setCut(u),this.cutRenders.set(r,a),a)},getStream:r=>{var u;return(u=this.cutRenders.get(r))==null?void 0:u.stream},setPause:(r,u)=>{var a;(a=this.cutRenders.get(r))==null||a.worker.setPause(u)},remove:r=>{var u;(u=this.cutRenders.get(r))==null||u.destroy(),this.cutRenders.delete(r)}});m(this,"init",r=>{this.initDecoder(r),this.initRender(),this.initDemuxer(r),this.audioPlayer=new W,this.audioPlayer.init()});m(this,"initDemuxer",r=>{this.demuxerWorker=new V,this.demuxerWorker.init(r),this.demuxerWorker.on.debug=u=>{this.option.debug&&this.on.debug&&this.on.debug(u)},this.demuxerWorker.on.info=u=>{this.option.debug&&console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m","color:#0097ff;","------->pr-player: info",u),this.on.demuxer.info&&this.on.demuxer.info(u)},this.demuxerWorker.on.config=u=>{var n,o;this.option.debug&&console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m","color:#0097ff;","------->pr-player: config",u),this.on.demuxer.config&&this.on.demuxer.config(u);const{kind:a}=u;switch(a){case"audio":{const{codec:i,sampleRate:t,numberOfChannels:e}=u;(n=this.decoderWorker)==null||n.initAudio({codec:i,sampleRate:t,numberOfChannels:e})}break;case"video":{const{codec:i,description:t}=u;(o=this.decoderWorker)==null||o.initVideo({codec:i,description:t})}break}},this.demuxerWorker.on.chunk=u=>{if(this.on.demuxer.chunk&&this.on.demuxer.chunk(u),!this.decoderWorker)return;const{kind:a}=u;switch(a){case"audio":{const{type:n,dts:o,data:i}=u,t=o*1e3;this.decoderWorker.push({kind:a,init:{type:n,timestamp:t,data:i}})}break;case"video":{const{type:n,dts:o,data:i,nalus:t=[]}=u,e=o*1e3;this.decoderWorker.push({kind:a,init:{type:n,timestamp:e,data:i},nalus:t})}break}}});m(this,"initDecoder",r=>{this.decoderWorker=new N,this.decoderWorker.init(r);const{frameTrack:u=!1}=this.option;this.decoderWorker.setFrameTrack(u),this.decoderWorker.on.
|
|
4
|
-
`).map(e=>e.replace("\r","")),a=this.url.substring(0,this.url.lastIndexOf("/")+1);let n=4,o=0,i=!1;const t=[];for(const e of u)e.startsWith("#EXTINF:")?n=parseFloat(e.split(":")[1].split(",")[0]):e.startsWith("#EXT-X-TARGETDURATION:")?o=parseInt(e.split(":")[1]):e.startsWith("#EXT-X-ENDLIST")?i=!1:e.startsWith("#EXT-X-MEDIA-SEQUENCE:")?i=!0:e.includes(".ts")&&!e.startsWith("#")&&t.push({url:e.startsWith("http")?e:a+e,duration:n,isLive:i});return{baseUrl:a,targetDuration:o,isLive:i,segments:t}},getSegments:async()=>{var r;try{const u=new x;let a=await u.request(this.url);if(a.status!==200&&(await new Promise(o=>setTimeout(()=>o(!0),500)),a=await u.request(this.url)),a.status!==200&&(await new Promise(o=>setTimeout(()=>o(!0),500)),a=await u.request(this.url)),a.status!==200)throw new Error("request is error.");const n=(r=a.body)==null?void 0:r.getReader();if(!n)throw new Error("reader is error.");for(;;){const{done:o,value:i}=await n.read();if(i){const t=await this.hls.parse(i),{segments:e=[],isLive:s=!1}=t;this.hls.isLive=s,s===!1&&(this.option.frameTrack=!1);let l=Array.from(e,d=>d.url);const c=l.findIndex(d=>d===this.hls.url);c!==-1&&(l=l.slice(c+1)),this.hls.urls=l}if(o)break}}catch(u){this.on.error&&this.on.error(u)}},start:async()=>{var r,u,a;try{for(await this.hls.getSegments(),this.hls.getSegmentsTimer=window.setInterval(this.hls.getSegments,500),this.hls.isLive===!1&&(clearInterval(this.hls.getSegmentsTimer),(r=this.decoderWorker)==null?void 0:r.setFrameTrack(!1));;){const n=this.hls.urls.shift();if(n){this.hls.url=n;const o=(u=(await this.prFetch.request(n)).body)==null?void 0:u.getReader();if(!o)throw new Error("segment reader is error.");for(;;){const{done:i,value:t}=await o.read();if(t&&((a=this.demuxerWorker)==null||a.push(t)),i)break}}else await new Promise(o=>setTimeout(()=>o(!0),300))}}catch(n){if((n==null?void 0:n.name)!=="AbortError")throw Error(n)}}});const{debug:u=!1}=r;this.option.debug=u}}var commonjsGlobal=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},indexMinimal={},minimal$1={},aspromise,hasRequiredAspromise;function requireAspromise(){if(hasRequiredAspromise)return aspromise;hasRequiredAspromise=1,aspromise=h;function h(r,u){for(var a=new Array(arguments.length-1),n=0,o=2,i=!0;o<arguments.length;)a[n++]=arguments[o++];return new Promise(function(e,s){a[n]=function(c){if(i)if(i=!1,c)s(c);else{for(var d=new Array(arguments.length-1),p=0;p<d.length;)d[p++]=arguments[p];e.apply(null,d)}};try{r.apply(u||null,a)}catch(l){i&&(i=!1,s(l))}})}return aspromise}var base64={},hasRequiredBase64;function requireBase64(){return hasRequiredBase64||(hasRequiredBase64=1,function(h){var r=h;r.length=function(t){var e=t.length;if(!e)return 0;for(var s=0;--e%4>1&&t.charAt(e)==="=";)++s;return Math.ceil(t.length*3)/4-s};for(var u=new Array(64),a=new Array(123),n=0;n<64;)a[u[n]=n<26?n+65:n<52?n+71:n<62?n-4:n-59|43]=n++;r.encode=function(t,e,s){for(var l=null,c=[],d=0,p=0,f;e<s;){var w=t[e++];switch(p){case 0:c[d++]=u[w>>2],f=(w&3)<<4,p=1;break;case 1:c[d++]=u[f|w>>4],f=(w&15)<<2,p=2;break;case 2:c[d++]=u[f|w>>6],c[d++]=u[w&63],p=0;break}d>8191&&((l||(l=[])).push(String.fromCharCode.apply(String,c)),d=0)}return p&&(c[d++]=u[f],c[d++]=61,p===1&&(c[d++]=61)),l?(d&&l.push(String.fromCharCode.apply(String,c.slice(0,d))),l.join("")):String.fromCharCode.apply(String,c.slice(0,d))};var o="invalid encoding";r.decode=function(t,e,s){for(var l=s,c=0,d,p=0;p<t.length;){var f=t.charCodeAt(p++);if(f===61&&c>1)break;if((f=a[f])===void 0)throw Error(o);switch(c){case 0:d=f,c=1;break;case 1:e[s++]=d<<2|(f&48)>>4,d=f,c=2;break;case 2:e[s++]=(d&15)<<4|(f&60)>>2,d=f,c=3;break;case 3:e[s++]=(d&3)<<6|f,c=0;break}}if(c===1)throw Error(o);return s-l},r.test=function(t){return/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(t)}}(base64)),base64}var eventemitter,hasRequiredEventemitter;function requireEventemitter(){if(hasRequiredEventemitter)return eventemitter;hasRequiredEventemitter=1,eventemitter=h;function h(){this._listeners={}}return h.prototype.on=function(u,a,n){return(this._listeners[u]||(this._listeners[u]=[])).push({fn:a,ctx:n||this}),this},h.prototype.off=function(u,a){if(u===void 0)this._listeners={};else if(a===void 0)this._listeners[u]=[];else for(var n=this._listeners[u],o=0;o<n.length;)n[o].fn===a?n.splice(o,1):++o;return this},h.prototype.emit=function(u){var a=this._listeners[u];if(a){for(var n=[],o=1;o<arguments.length;)n.push(arguments[o++]);for(o=0;o<a.length;)a[o].fn.apply(a[o++].ctx,n)}return this},eventemitter}var float,hasRequiredFloat;function requireFloat(){if(hasRequiredFloat)return float;hasRequiredFloat=1,float=h(h);function h(o){return typeof Float32Array<"u"?function(){var i=new Float32Array([-0]),t=new Uint8Array(i.buffer),e=t[3]===128;function s(p,f,w){i[0]=p,f[w]=t[0],f[w+1]=t[1],f[w+2]=t[2],f[w+3]=t[3]}function l(p,f,w){i[0]=p,f[w]=t[3],f[w+1]=t[2],f[w+2]=t[1],f[w+3]=t[0]}o.writeFloatLE=e?s:l,o.writeFloatBE=e?l:s;function c(p,f){return t[0]=p[f],t[1]=p[f+1],t[2]=p[f+2],t[3]=p[f+3],i[0]}function d(p,f){return t[3]=p[f],t[2]=p[f+1],t[1]=p[f+2],t[0]=p[f+3],i[0]}o.readFloatLE=e?c:d,o.readFloatBE=e?d:c}():function(){function i(e,s,l,c){var d=s<0?1:0;if(d&&(s=-s),s===0)e(1/s>0?0:2147483648,l,c);else if(isNaN(s))e(2143289344,l,c);else if(s>34028234663852886e22)e((d<<31|2139095040)>>>0,l,c);else if(s<11754943508222875e-54)e((d<<31|Math.round(s/1401298464324817e-60))>>>0,l,c);else{var p=Math.floor(Math.log(s)/Math.LN2),f=Math.round(s*Math.pow(2,-p)*8388608)&8388607;e((d<<31|p+127<<23|f)>>>0,l,c)}}o.writeFloatLE=i.bind(null,r),o.writeFloatBE=i.bind(null,u);function t(e,s,l){var c=e(s,l),d=(c>>31)*2+1,p=c>>>23&255,f=c&8388607;return p===255?f?NaN:d*(1/0):p===0?d*1401298464324817e-60*f:d*Math.pow(2,p-150)*(f+8388608)}o.readFloatLE=t.bind(null,a),o.readFloatBE=t.bind(null,n)}(),typeof Float64Array<"u"?function(){var i=new Float64Array([-0]),t=new Uint8Array(i.buffer),e=t[7]===128;function s(p,f,w){i[0]=p,f[w]=t[0],f[w+1]=t[1],f[w+2]=t[2],f[w+3]=t[3],f[w+4]=t[4],f[w+5]=t[5],f[w+6]=t[6],f[w+7]=t[7]}function l(p,f,w){i[0]=p,f[w]=t[7],f[w+1]=t[6],f[w+2]=t[5],f[w+3]=t[4],f[w+4]=t[3],f[w+5]=t[2],f[w+6]=t[1],f[w+7]=t[0]}o.writeDoubleLE=e?s:l,o.writeDoubleBE=e?l:s;function c(p,f){return t[0]=p[f],t[1]=p[f+1],t[2]=p[f+2],t[3]=p[f+3],t[4]=p[f+4],t[5]=p[f+5],t[6]=p[f+6],t[7]=p[f+7],i[0]}function d(p,f){return t[7]=p[f],t[6]=p[f+1],t[5]=p[f+2],t[4]=p[f+3],t[3]=p[f+4],t[2]=p[f+5],t[1]=p[f+6],t[0]=p[f+7],i[0]}o.readDoubleLE=e?c:d,o.readDoubleBE=e?d:c}():function(){function i(e,s,l,c,d,p){var f=c<0?1:0;if(f&&(c=-c),c===0)e(0,d,p+s),e(1/c>0?0:2147483648,d,p+l);else if(isNaN(c))e(0,d,p+s),e(2146959360,d,p+l);else if(c>17976931348623157e292)e(0,d,p+s),e((f<<31|2146435072)>>>0,d,p+l);else{var w;if(c<22250738585072014e-324)w=c/5e-324,e(w>>>0,d,p+s),e((f<<31|w/4294967296)>>>0,d,p+l);else{var b=Math.floor(Math.log(c)/Math.LN2);b===1024&&(b=1023),w=c*Math.pow(2,-b),e(w*4503599627370496>>>0,d,p+s),e((f<<31|b+1023<<20|w*1048576&1048575)>>>0,d,p+l)}}}o.writeDoubleLE=i.bind(null,r,0,4),o.writeDoubleBE=i.bind(null,u,4,0);function t(e,s,l,c,d){var p=e(c,d+s),f=e(c,d+l),w=(f>>31)*2+1,b=f>>>20&2047,g=4294967296*(f&1048575)+p;return b===2047?g?NaN:w*(1/0):b===0?w*5e-324*g:w*Math.pow(2,b-1075)*(g+4503599627370496)}o.readDoubleLE=t.bind(null,a,0,4),o.readDoubleBE=t.bind(null,n,4,0)}(),o}function r(o,i,t){i[t]=o&255,i[t+1]=o>>>8&255,i[t+2]=o>>>16&255,i[t+3]=o>>>24}function u(o,i,t){i[t]=o>>>24,i[t+1]=o>>>16&255,i[t+2]=o>>>8&255,i[t+3]=o&255}function a(o,i){return(o[i]|o[i+1]<<8|o[i+2]<<16|o[i+3]<<24)>>>0}function n(o,i){return(o[i]<<24|o[i+1]<<16|o[i+2]<<8|o[i+3])>>>0}return float}var inquire_1,hasRequiredInquire;function requireInquire(){if(hasRequiredInquire)return inquire_1;hasRequiredInquire=1,inquire_1=inquire;function inquire(moduleName){try{var mod=eval("quire".replace(/^/,"re"))(moduleName);if(mod&&(mod.length||Object.keys(mod).length))return mod}catch(h){}return null}return inquire_1}var utf8={},hasRequiredUtf8;function requireUtf8(){return hasRequiredUtf8||(hasRequiredUtf8=1,function(h){var r=h;r.length=function(a){for(var n=0,o=0,i=0;i<a.length;++i)o=a.charCodeAt(i),o<128?n+=1:o<2048?n+=2:(o&64512)===55296&&(a.charCodeAt(i+1)&64512)===56320?(++i,n+=4):n+=3;return n},r.read=function(a,n,o){var i=o-n;if(i<1)return"";for(var t=null,e=[],s=0,l;n<o;)l=a[n++],l<128?e[s++]=l:l>191&&l<224?e[s++]=(l&31)<<6|a[n++]&63:l>239&&l<365?(l=((l&7)<<18|(a[n++]&63)<<12|(a[n++]&63)<<6|a[n++]&63)-65536,e[s++]=55296+(l>>10),e[s++]=56320+(l&1023)):e[s++]=(l&15)<<12|(a[n++]&63)<<6|a[n++]&63,s>8191&&((t||(t=[])).push(String.fromCharCode.apply(String,e)),s=0);return t?(s&&t.push(String.fromCharCode.apply(String,e.slice(0,s))),t.join("")):String.fromCharCode.apply(String,e.slice(0,s))},r.write=function(a,n,o){for(var i=o,t,e,s=0;s<a.length;++s)t=a.charCodeAt(s),t<128?n[o++]=t:t<2048?(n[o++]=t>>6|192,n[o++]=t&63|128):(t&64512)===55296&&((e=a.charCodeAt(s+1))&64512)===56320?(t=65536+((t&1023)<<10)+(e&1023),++s,n[o++]=t>>18|240,n[o++]=t>>12&63|128,n[o++]=t>>6&63|128,n[o++]=t&63|128):(n[o++]=t>>12|224,n[o++]=t>>6&63|128,n[o++]=t&63|128);return o-i}}(utf8)),utf8}var pool_1,hasRequiredPool;function requirePool(){if(hasRequiredPool)return pool_1;hasRequiredPool=1,pool_1=h;function h(r,u,a){var n=a||8192,o=n>>>1,i=null,t=n;return function(s){if(s<1||s>o)return r(s);t+s>n&&(i=r(n),t=0);var l=u.call(i,t,t+=s);return t&7&&(t=(t|7)+1),l}}return pool_1}var longbits,hasRequiredLongbits;function requireLongbits(){if(hasRequiredLongbits)return longbits;hasRequiredLongbits=1,longbits=r;var h=requireMinimal$1();function r(o,i){this.lo=o>>>0,this.hi=i>>>0}var u=r.zero=new r(0,0);u.toNumber=function(){return 0},u.zzEncode=u.zzDecode=function(){return this},u.length=function(){return 1};var a=r.zeroHash="\0\0\0\0\0\0\0\0";r.fromNumber=function(i){if(i===0)return u;var t=i<0;t&&(i=-i);var e=i>>>0,s=(i-e)/4294967296>>>0;return t&&(s=~s>>>0,e=~e>>>0,++e>4294967295&&(e=0,++s>4294967295&&(s=0))),new r(e,s)},r.from=function(i){if(typeof i=="number")return r.fromNumber(i);if(h.isString(i))if(h.Long)i=h.Long.fromString(i);else return r.fromNumber(parseInt(i,10));return i.low||i.high?new r(i.low>>>0,i.high>>>0):u},r.prototype.toNumber=function(i){if(!i&&this.hi>>>31){var t=~this.lo+1>>>0,e=~this.hi>>>0;return t||(e=e+1>>>0),-(t+e*4294967296)}return this.lo+this.hi*4294967296},r.prototype.toLong=function(i){return h.Long?new h.Long(this.lo|0,this.hi|0,!!i):{low:this.lo|0,high:this.hi|0,unsigned:!!i}};var n=String.prototype.charCodeAt;return r.fromHash=function(i){return i===a?u:new r((n.call(i,0)|n.call(i,1)<<8|n.call(i,2)<<16|n.call(i,3)<<24)>>>0,(n.call(i,4)|n.call(i,5)<<8|n.call(i,6)<<16|n.call(i,7)<<24)>>>0)},r.prototype.toHash=function(){return String.fromCharCode(this.lo&255,this.lo>>>8&255,this.lo>>>16&255,this.lo>>>24,this.hi&255,this.hi>>>8&255,this.hi>>>16&255,this.hi>>>24)},r.prototype.zzEncode=function(){var i=this.hi>>31;return this.hi=((this.hi<<1|this.lo>>>31)^i)>>>0,this.lo=(this.lo<<1^i)>>>0,this},r.prototype.zzDecode=function(){var i=-(this.lo&1);return this.lo=((this.lo>>>1|this.hi<<31)^i)>>>0,this.hi=(this.hi>>>1^i)>>>0,this},r.prototype.length=function(){var i=this.lo,t=(this.lo>>>28|this.hi<<4)>>>0,e=this.hi>>>24;return e===0?t===0?i<16384?i<128?1:2:i<2097152?3:4:t<16384?t<128?5:6:t<2097152?7:8:e<128?9:10},longbits}var hasRequiredMinimal$1;function requireMinimal$1(){return hasRequiredMinimal$1||(hasRequiredMinimal$1=1,function(h){var r=h;r.asPromise=requireAspromise(),r.base64=requireBase64(),r.EventEmitter=requireEventemitter(),r.float=requireFloat(),r.inquire=requireInquire(),r.utf8=requireUtf8(),r.pool=requirePool(),r.LongBits=requireLongbits(),r.isNode=!!(typeof commonjsGlobal<"u"&&commonjsGlobal&&commonjsGlobal.process&&commonjsGlobal.process.versions&&commonjsGlobal.process.versions.node),r.global=r.isNode&&commonjsGlobal||typeof window<"u"&&window||typeof self<"u"&&self||minimal$1,r.emptyArray=Object.freeze?Object.freeze([]):[],r.emptyObject=Object.freeze?Object.freeze({}):{},r.isInteger=Number.isInteger||function(o){return typeof o=="number"&&isFinite(o)&&Math.floor(o)===o},r.isString=function(o){return typeof o=="string"||o instanceof String},r.isObject=function(o){return o&&typeof o=="object"},r.isset=r.isSet=function(o,i){var t=o[i];return t!=null&&o.hasOwnProperty(i)?typeof t!="object"||(Array.isArray(t)?t.length:Object.keys(t).length)>0:!1},r.Buffer=function(){try{var n=r.inquire("buffer").Buffer;return n.prototype.utf8Write?n:null}catch{return null}}(),r._Buffer_from=null,r._Buffer_allocUnsafe=null,r.newBuffer=function(o){return typeof o=="number"?r.Buffer?r._Buffer_allocUnsafe(o):new r.Array(o):r.Buffer?r._Buffer_from(o):typeof Uint8Array>"u"?o:new Uint8Array(o)},r.Array=typeof Uint8Array<"u"?Uint8Array:Array,r.Long=r.global.dcodeIO&&r.global.dcodeIO.Long||r.global.Long||r.inquire("long"),r.key2Re=/^true|false|0|1$/,r.key32Re=/^-?(?:0|[1-9][0-9]*)$/,r.key64Re=/^(?:[\\x00-\\xff]{8}|-?(?:0|[1-9][0-9]*))$/,r.longToHash=function(o){return o?r.LongBits.from(o).toHash():r.LongBits.zeroHash},r.longFromHash=function(o,i){var t=r.LongBits.fromHash(o);return r.Long?r.Long.fromBits(t.lo,t.hi,i):t.toNumber(!!i)};function u(n,o,i){for(var t=Object.keys(o),e=0;e<t.length;++e)(n[t[e]]===void 0||!i)&&(n[t[e]]=o[t[e]]);return n}r.merge=u,r.lcFirst=function(o){return o.charAt(0).toLowerCase()+o.substring(1)};function a(n){function o(i,t){if(!(this instanceof o))return new o(i,t);Object.defineProperty(this,"message",{get:function(){return i}}),Error.captureStackTrace?Error.captureStackTrace(this,o):Object.defineProperty(this,"stack",{value:new Error().stack||""}),t&&u(this,t)}return o.prototype=Object.create(Error.prototype,{constructor:{value:o,writable:!0,enumerable:!1,configurable:!0},name:{get:function(){return n},set:void 0,enumerable:!1,configurable:!0},toString:{value:function(){return this.name+": "+this.message},writable:!0,enumerable:!1,configurable:!0}}),o}r.newError=a,r.ProtocolError=a("ProtocolError"),r.oneOfGetter=function(o){for(var i={},t=0;t<o.length;++t)i[o[t]]=1;return function(){for(var e=Object.keys(this),s=e.length-1;s>-1;--s)if(i[e[s]]===1&&this[e[s]]!==void 0&&this[e[s]]!==null)return e[s]}},r.oneOfSetter=function(o){return function(i){for(var t=0;t<o.length;++t)o[t]!==i&&delete this[o[t]]}},r.toJSONOptions={longs:String,enums:String,bytes:String,json:!0},r._configure=function(){var n=r.Buffer;if(!n){r._Buffer_from=r._Buffer_allocUnsafe=null;return}r._Buffer_from=n.from!==Uint8Array.from&&n.from||function(i,t){return new n(i,t)},r._Buffer_allocUnsafe=n.allocUnsafe||function(i){return new n(i)}}}(minimal$1)),minimal$1}var writer,hasRequiredWriter;function requireWriter(){if(hasRequiredWriter)return writer;hasRequiredWriter=1,writer=e;var h=requireMinimal$1(),r,u=h.LongBits,a=h.base64,n=h.utf8;function o(b,g,k){this.fn=b,this.len=g,this.next=void 0,this.val=k}function i(){}function t(b){this.head=b.head,this.tail=b.tail,this.len=b.len,this.next=b.states}function e(){this.len=0,this.head=new o(i,0,0),this.tail=this.head,this.states=null}var s=function(){return h.Buffer?function(){return(e.create=function(){return new r})()}:function(){return new e}};e.create=s(),e.alloc=function(g){return new h.Array(g)},h.Array!==Array&&(e.alloc=h.pool(e.alloc,h.Array.prototype.subarray)),e.prototype._push=function(g,k,I){return this.tail=this.tail.next=new o(g,k,I),this.len+=k,this};function l(b,g,k){g[k]=b&255}function c(b,g,k){for(;b>127;)g[k++]=b&127|128,b>>>=7;g[k]=b}function d(b,g){this.len=b,this.next=void 0,this.val=g}d.prototype=Object.create(o.prototype),d.prototype.fn=c,e.prototype.uint32=function(g){return this.len+=(this.tail=this.tail.next=new d((g=g>>>0)<128?1:g<16384?2:g<2097152?3:g<268435456?4:5,g)).len,this},e.prototype.int32=function(g){return g<0?this._push(p,10,u.fromNumber(g)):this.uint32(g)},e.prototype.sint32=function(g){return this.uint32((g<<1^g>>31)>>>0)};function p(b,g,k){for(;b.hi;)g[k++]=b.lo&127|128,b.lo=(b.lo>>>7|b.hi<<25)>>>0,b.hi>>>=7;for(;b.lo>127;)g[k++]=b.lo&127|128,b.lo=b.lo>>>7;g[k++]=b.lo}e.prototype.uint64=function(g){var k=u.from(g);return this._push(p,k.length(),k)},e.prototype.int64=e.prototype.uint64,e.prototype.sint64=function(g){var k=u.from(g).zzEncode();return this._push(p,k.length(),k)},e.prototype.bool=function(g){return this._push(l,1,g?1:0)};function f(b,g,k){g[k]=b&255,g[k+1]=b>>>8&255,g[k+2]=b>>>16&255,g[k+3]=b>>>24}e.prototype.fixed32=function(g){return this._push(f,4,g>>>0)},e.prototype.sfixed32=e.prototype.fixed32,e.prototype.fixed64=function(g){var k=u.from(g);return this._push(f,4,k.lo)._push(f,4,k.hi)},e.prototype.sfixed64=e.prototype.fixed64,e.prototype.float=function(g){return this._push(h.float.writeFloatLE,4,g)},e.prototype.double=function(g){return this._push(h.float.writeDoubleLE,8,g)};var w=h.Array.prototype.set?function(g,k,I){k.set(g,I)}:function(g,k,I){for(var K=0;K<g.length;++K)k[I+K]=g[K]};return e.prototype.bytes=function(g){var k=g.length>>>0;if(!k)return this._push(l,1,0);if(h.isString(g)){var I=e.alloc(k=a.length(g));a.decode(g,I,0),g=I}return this.uint32(k)._push(w,k,g)},e.prototype.string=function(g){var k=n.length(g);return k?this.uint32(k)._push(n.write,k,g):this._push(l,1,0)},e.prototype.fork=function(){return this.states=new t(this),this.head=this.tail=new o(i,0,0),this.len=0,this},e.prototype.reset=function(){return this.states?(this.head=this.states.head,this.tail=this.states.tail,this.len=this.states.len,this.states=this.states.next):(this.head=this.tail=new o(i,0,0),this.len=0),this},e.prototype.ldelim=function(){var g=this.head,k=this.tail,I=this.len;return this.reset().uint32(I),I&&(this.tail.next=g.next,this.tail=k,this.len+=I),this},e.prototype.finish=function(){for(var g=this.head.next,k=this.constructor.alloc(this.len),I=0;g;)g.fn(g.val,k,I),I+=g.len,g=g.next;return k},e._configure=function(b){r=b,e.create=s(),r._configure()},writer}var writer_buffer,hasRequiredWriter_buffer;function requireWriter_buffer(){if(hasRequiredWriter_buffer)return writer_buffer;hasRequiredWriter_buffer=1,writer_buffer=u;var h=requireWriter();(u.prototype=Object.create(h.prototype)).constructor=u;var r=requireMinimal$1();function u(){h.call(this)}u._configure=function(){u.alloc=r._Buffer_allocUnsafe,u.writeBytesBuffer=r.Buffer&&r.Buffer.prototype instanceof Uint8Array&&r.Buffer.prototype.set.name==="set"?function(o,i,t){i.set(o,t)}:function(o,i,t){if(o.copy)o.copy(i,t,0,o.length);else for(var e=0;e<o.length;)i[t++]=o[e++]}},u.prototype.bytes=function(o){r.isString(o)&&(o=r._Buffer_from(o,"base64"));var i=o.length>>>0;return this.uint32(i),i&&this._push(u.writeBytesBuffer,i,o),this};function a(n,o,i){n.length<40?r.utf8.write(n,o,i):o.utf8Write?o.utf8Write(n,i):o.write(n,i)}return u.prototype.string=function(o){var i=r.Buffer.byteLength(o);return this.uint32(i),i&&this._push(a,i,o),this},u._configure(),writer_buffer}var reader,hasRequiredReader;function requireReader(){if(hasRequiredReader)return reader;hasRequiredReader=1,reader=o;var h=requireMinimal$1(),r,u=h.LongBits,a=h.utf8;function n(c,d){return RangeError("index out of range: "+c.pos+" + "+(d||1)+" > "+c.len)}function o(c){this.buf=c,this.pos=0,this.len=c.length}var i=typeof Uint8Array<"u"?function(d){if(d instanceof Uint8Array||Array.isArray(d))return new o(d);throw Error("illegal buffer")}:function(d){if(Array.isArray(d))return new o(d);throw Error("illegal buffer")},t=function(){return h.Buffer?function(p){return(o.create=function(w){return h.Buffer.isBuffer(w)?new r(w):i(w)})(p)}:i};o.create=t(),o.prototype._slice=h.Array.prototype.subarray||h.Array.prototype.slice,o.prototype.uint32=function(){var d=4294967295;return function(){if(d=(this.buf[this.pos]&127)>>>0,this.buf[this.pos++]<128||(d=(d|(this.buf[this.pos]&127)<<7)>>>0,this.buf[this.pos++]<128)||(d=(d|(this.buf[this.pos]&127)<<14)>>>0,this.buf[this.pos++]<128)||(d=(d|(this.buf[this.pos]&127)<<21)>>>0,this.buf[this.pos++]<128)||(d=(d|(this.buf[this.pos]&15)<<28)>>>0,this.buf[this.pos++]<128))return d;if((this.pos+=5)>this.len)throw this.pos=this.len,n(this,10);return d}}(),o.prototype.int32=function(){return this.uint32()|0},o.prototype.sint32=function(){var d=this.uint32();return d>>>1^-(d&1)|0};function e(){var c=new u(0,0),d=0;if(this.len-this.pos>4){for(;d<4;++d)if(c.lo=(c.lo|(this.buf[this.pos]&127)<<d*7)>>>0,this.buf[this.pos++]<128)return c;if(c.lo=(c.lo|(this.buf[this.pos]&127)<<28)>>>0,c.hi=(c.hi|(this.buf[this.pos]&127)>>4)>>>0,this.buf[this.pos++]<128)return c;d=0}else{for(;d<3;++d){if(this.pos>=this.len)throw n(this);if(c.lo=(c.lo|(this.buf[this.pos]&127)<<d*7)>>>0,this.buf[this.pos++]<128)return c}return c.lo=(c.lo|(this.buf[this.pos++]&127)<<d*7)>>>0,c}if(this.len-this.pos>4){for(;d<5;++d)if(c.hi=(c.hi|(this.buf[this.pos]&127)<<d*7+3)>>>0,this.buf[this.pos++]<128)return c}else for(;d<5;++d){if(this.pos>=this.len)throw n(this);if(c.hi=(c.hi|(this.buf[this.pos]&127)<<d*7+3)>>>0,this.buf[this.pos++]<128)return c}throw Error("invalid varint encoding")}o.prototype.bool=function(){return this.uint32()!==0};function s(c,d){return(c[d-4]|c[d-3]<<8|c[d-2]<<16|c[d-1]<<24)>>>0}o.prototype.fixed32=function(){if(this.pos+4>this.len)throw n(this,4);return s(this.buf,this.pos+=4)},o.prototype.sfixed32=function(){if(this.pos+4>this.len)throw n(this,4);return s(this.buf,this.pos+=4)|0};function l(){if(this.pos+8>this.len)throw n(this,8);return new u(s(this.buf,this.pos+=4),s(this.buf,this.pos+=4))}return o.prototype.float=function(){if(this.pos+4>this.len)throw n(this,4);var d=h.float.readFloatLE(this.buf,this.pos);return this.pos+=4,d},o.prototype.double=function(){if(this.pos+8>this.len)throw n(this,4);var d=h.float.readDoubleLE(this.buf,this.pos);return this.pos+=8,d},o.prototype.bytes=function(){var d=this.uint32(),p=this.pos,f=this.pos+d;if(f>this.len)throw n(this,d);if(this.pos+=d,Array.isArray(this.buf))return this.buf.slice(p,f);if(p===f){var w=h.Buffer;return w?w.alloc(0):new this.buf.constructor(0)}return this._slice.call(this.buf,p,f)},o.prototype.string=function(){var d=this.bytes();return a.read(d,0,d.length)},o.prototype.skip=function(d){if(typeof d=="number"){if(this.pos+d>this.len)throw n(this,d);this.pos+=d}else do if(this.pos>=this.len)throw n(this);while(this.buf[this.pos++]&128);return this},o.prototype.skipType=function(c){switch(c){case 0:this.skip();break;case 1:this.skip(8);break;case 2:this.skip(this.uint32());break;case 3:for(;(c=this.uint32()&7)!==4;)this.skipType(c);break;case 5:this.skip(4);break;default:throw Error("invalid wire type "+c+" at offset "+this.pos)}return this},o._configure=function(c){r=c,o.create=t(),r._configure();var d=h.Long?"toLong":"toNumber";h.merge(o.prototype,{int64:function(){return e.call(this)[d](!1)},uint64:function(){return e.call(this)[d](!0)},sint64:function(){return e.call(this).zzDecode()[d](!1)},fixed64:function(){return l.call(this)[d](!0)},sfixed64:function(){return l.call(this)[d](!1)}})},reader}var reader_buffer,hasRequiredReader_buffer;function requireReader_buffer(){if(hasRequiredReader_buffer)return reader_buffer;hasRequiredReader_buffer=1,reader_buffer=u;var h=requireReader();(u.prototype=Object.create(h.prototype)).constructor=u;var r=requireMinimal$1();function u(a){h.call(this,a)}return u._configure=function(){r.Buffer&&(u.prototype._slice=r.Buffer.prototype.slice)},u.prototype.string=function(){var n=this.uint32();return this.buf.utf8Slice?this.buf.utf8Slice(this.pos,this.pos=Math.min(this.pos+n,this.len)):this.buf.toString("utf-8",this.pos,this.pos=Math.min(this.pos+n,this.len))},u._configure(),reader_buffer}var rpc={},service,hasRequiredService;function requireService(){if(hasRequiredService)return service;hasRequiredService=1,service=r;var h=requireMinimal$1();(r.prototype=Object.create(h.EventEmitter.prototype)).constructor=r;function r(u,a,n){if(typeof u!="function")throw TypeError("rpcImpl must be a function");h.EventEmitter.call(this),this.rpcImpl=u,this.requestDelimited=!!a,this.responseDelimited=!!n}return r.prototype.rpcCall=function u(a,n,o,i,t){if(!i)throw TypeError("request must be specified");var e=this;if(!t)return h.asPromise(u,e,a,n,o,i);if(!e.rpcImpl){setTimeout(function(){t(Error("already ended"))},0);return}try{return e.rpcImpl(a,n[e.requestDelimited?"encodeDelimited":"encode"](i).finish(),function(l,c){if(l)return e.emit("error",l,a),t(l);if(c===null){e.end(!0);return}if(!(c instanceof o))try{c=o[e.responseDelimited?"decodeDelimited":"decode"](c)}catch(d){return e.emit("error",d,a),t(d)}return e.emit("data",c,a),t(null,c)})}catch(s){e.emit("error",s,a),setTimeout(function(){t(s)},0);return}},r.prototype.end=function(a){return this.rpcImpl&&(a||this.rpcImpl(null,null,null),this.rpcImpl=null,this.emit("end").off()),this},service}var hasRequiredRpc;function requireRpc(){return hasRequiredRpc||(hasRequiredRpc=1,function(h){var r=h;r.Service=requireService()}(rpc)),rpc}var roots,hasRequiredRoots;function requireRoots(){return hasRequiredRoots||(hasRequiredRoots=1,roots={}),roots}var hasRequiredIndexMinimal;function requireIndexMinimal(){return hasRequiredIndexMinimal||(hasRequiredIndexMinimal=1,function(h){var r=h;r.build="minimal",r.Writer=requireWriter(),r.BufferWriter=requireWriter_buffer(),r.Reader=requireReader(),r.BufferReader=requireReader_buffer(),r.util=requireMinimal$1(),r.rpc=requireRpc(),r.roots=requireRoots(),r.configure=u;function u(){r.util._configure(),r.Writer._configure(r.BufferWriter),r.Reader._configure(r.BufferReader)}u()}(indexMinimal)),indexMinimal}var minimal,hasRequiredMinimal;function requireMinimal(){return hasRequiredMinimal||(hasRequiredMinimal=1,minimal=requireIndexMinimal()),minimal}var minimalExports=requireMinimal();const $Reader=minimalExports.Reader,$Writer=minimalExports.Writer,$util=minimalExports.util,$root=minimalExports.roots.default||(minimalExports.roots.default={}),com=$root.com=(()=>{const h={};return h.quick=function(){const r={};return r.voice=function(){const u={};return u.proto=function(){const a={};return a.SeiData=function(){function n(o){if(o)for(let i=Object.keys(o),t=0;t<i.length;++t)o[i[t]]!=null&&(this[i[t]]=o[i[t]])}return n.prototype.event=0,n.prototype.data=$util.newBuffer([]),n.prototype.compress=!1,n.prototype.version=0,n.create=function(i){return new n(i)},n.encode=function(i,t){return t||(t=$Writer.create()),i.event!=null&&Object.hasOwnProperty.call(i,"event")&&t.uint32(8).int32(i.event),i.data!=null&&Object.hasOwnProperty.call(i,"data")&&t.uint32(18).bytes(i.data),i.compress!=null&&Object.hasOwnProperty.call(i,"compress")&&t.uint32(24).bool(i.compress),i.version!=null&&Object.hasOwnProperty.call(i,"version")&&t.uint32(32).int32(i.version),t},n.encodeDelimited=function(i,t){return this.encode(i,t).ldelim()},n.decode=function(i,t,e){i instanceof $Reader||(i=$Reader.create(i));let s=t===void 0?i.len:i.pos+t,l=new $root.com.quick.voice.proto.SeiData;for(;i.pos<s;){let c=i.uint32();if(c===e)break;switch(c>>>3){case 1:{l.event=i.int32();break}case 2:{l.data=i.bytes();break}case 3:{l.compress=i.bool();break}case 4:{l.version=i.int32();break}default:i.skipType(c&7);break}}return l},n.decodeDelimited=function(i){return i instanceof $Reader||(i=new $Reader(i)),this.decode(i,i.uint32())},n.verify=function(i){if(typeof i!="object"||i===null)return"object expected";if(i.event!=null&&i.hasOwnProperty("event"))switch(i.event){default:return"event: enum value expected";case 0:case 1:break}return i.data!=null&&i.hasOwnProperty("data")&&!(i.data&&typeof i.data.length=="number"||$util.isString(i.data))?"data: buffer expected":i.compress!=null&&i.hasOwnProperty("compress")&&typeof i.compress!="boolean"?"compress: boolean expected":i.version!=null&&i.hasOwnProperty("version")&&!$util.isInteger(i.version)?"version: integer expected":null},n.fromObject=function(i){if(i instanceof $root.com.quick.voice.proto.SeiData)return i;let t=new $root.com.quick.voice.proto.SeiData;switch(i.event){default:if(typeof i.event=="number"){t.event=i.event;break}break;case"Layout":case 0:t.event=0;break;case"Custom":case 1:t.event=1;break}return i.data!=null&&(typeof i.data=="string"?$util.base64.decode(i.data,t.data=$util.newBuffer($util.base64.length(i.data)),0):i.data.length>=0&&(t.data=i.data)),i.compress!=null&&(t.compress=!!i.compress),i.version!=null&&(t.version=i.version|0),t},n.toObject=function(i,t){t||(t={});let e={};return t.defaults&&(e.event=t.enums===String?"Layout":0,t.bytes===String?e.data="":(e.data=[],t.bytes!==Array&&(e.data=$util.newBuffer(e.data))),e.compress=!1,e.version=0),i.event!=null&&i.hasOwnProperty("event")&&(e.event=t.enums===String?$root.com.quick.voice.proto.EventType[i.event]===void 0?i.event:$root.com.quick.voice.proto.EventType[i.event]:i.event),i.data!=null&&i.hasOwnProperty("data")&&(e.data=t.bytes===String?$util.base64.encode(i.data,0,i.data.length):t.bytes===Array?Array.prototype.slice.call(i.data):i.data),i.compress!=null&&i.hasOwnProperty("compress")&&(e.compress=i.compress),i.version!=null&&i.hasOwnProperty("version")&&(e.version=i.version),e},n.prototype.toJSON=function(){return this.constructor.toObject(this,minimalExports.util.toJSONOptions)},n.getTypeUrl=function(i){return i===void 0&&(i="type.googleapis.com"),i+"/com.quick.voice.proto.SeiData"},n}(),a.EventType=function(){const n={},o=Object.create(n);return o[n[0]="Layout"]=0,o[n[1]="Custom"]=1,o}(),a.LayoutData=function(){function n(i){if(this.userMap={},i)for(let t=Object.keys(i),e=0;e<t.length;++e)i[t[e]]!=null&&(this[t[e]]=i[t[e]])}n.prototype.roomId="",n.prototype.type=0,n.prototype.userMap=$util.emptyObject,n.prototype.globalCustom=null;let o;return Object.defineProperty(n.prototype,"_globalCustom",{get:$util.oneOfGetter(o=["globalCustom"]),set:$util.oneOfSetter(o)}),n.create=function(t){return new n(t)},n.encode=function(t,e){if(e||(e=$Writer.create()),t.roomId!=null&&Object.hasOwnProperty.call(t,"roomId")&&e.uint32(10).string(t.roomId),t.type!=null&&Object.hasOwnProperty.call(t,"type")&&e.uint32(16).int32(t.type),t.userMap!=null&&Object.hasOwnProperty.call(t,"userMap"))for(let s=Object.keys(t.userMap),l=0;l<s.length;++l)e.uint32(26).fork().uint32(10).string(s[l]),$root.com.quick.voice.proto.UserInfo.encode(t.userMap[s[l]],e.uint32(18).fork()).ldelim().ldelim();return t.globalCustom!=null&&Object.hasOwnProperty.call(t,"globalCustom")&&$root.com.quick.voice.proto.CustomInfo.encode(t.globalCustom,e.uint32(34).fork()).ldelim(),e},n.encodeDelimited=function(t,e){return this.encode(t,e).ldelim()},n.decode=function(t,e,s){t instanceof $Reader||(t=$Reader.create(t));let l=e===void 0?t.len:t.pos+e,c=new $root.com.quick.voice.proto.LayoutData,d,p;for(;t.pos<l;){let f=t.uint32();if(f===s)break;switch(f>>>3){case 1:{c.roomId=t.string();break}case 2:{c.type=t.int32();break}case 3:{c.userMap===$util.emptyObject&&(c.userMap={});let w=t.uint32()+t.pos;for(d="",p=null;t.pos<w;){let b=t.uint32();switch(b>>>3){case 1:d=t.string();break;case 2:p=$root.com.quick.voice.proto.UserInfo.decode(t,t.uint32());break;default:t.skipType(b&7);break}}c.userMap[d]=p;break}case 4:{c.globalCustom=$root.com.quick.voice.proto.CustomInfo.decode(t,t.uint32());break}default:t.skipType(f&7);break}}return c},n.decodeDelimited=function(t){return t instanceof $Reader||(t=new $Reader(t)),this.decode(t,t.uint32())},n.verify=function(t){if(typeof t!="object"||t===null)return"object expected";if(t.roomId!=null&&t.hasOwnProperty("roomId")&&!$util.isString(t.roomId))return"roomId: string expected";if(t.type!=null&&t.hasOwnProperty("type"))switch(t.type){default:return"type: enum value expected";case 0:case 1:case 2:break}if(t.userMap!=null&&t.hasOwnProperty("userMap")){if(!$util.isObject(t.userMap))return"userMap: object expected";let e=Object.keys(t.userMap);for(let s=0;s<e.length;++s){let l=$root.com.quick.voice.proto.UserInfo.verify(t.userMap[e[s]]);if(l)return"userMap."+l}}if(t.globalCustom!=null&&t.hasOwnProperty("globalCustom")){let e=$root.com.quick.voice.proto.CustomInfo.verify(t.globalCustom);if(e)return"globalCustom."+e}return null},n.fromObject=function(t){if(t instanceof $root.com.quick.voice.proto.LayoutData)return t;let e=new $root.com.quick.voice.proto.LayoutData;switch(t.roomId!=null&&(e.roomId=String(t.roomId)),t.type){default:if(typeof t.type=="number"){e.type=t.type;break}break;case"AudioAndVideo":case 0:e.type=0;break;case"OnlyAudio":case 1:e.type=1;break;case"OnlyVideo":case 2:e.type=2;break}if(t.userMap){if(typeof t.userMap!="object")throw TypeError(".com.quick.voice.proto.LayoutData.userMap: object expected");e.userMap={};for(let s=Object.keys(t.userMap),l=0;l<s.length;++l){if(typeof t.userMap[s[l]]!="object")throw TypeError(".com.quick.voice.proto.LayoutData.userMap: object expected");e.userMap[s[l]]=$root.com.quick.voice.proto.UserInfo.fromObject(t.userMap[s[l]])}}if(t.globalCustom!=null){if(typeof t.globalCustom!="object")throw TypeError(".com.quick.voice.proto.LayoutData.globalCustom: object expected");e.globalCustom=$root.com.quick.voice.proto.CustomInfo.fromObject(t.globalCustom)}return e},n.toObject=function(t,e){e||(e={});let s={};(e.objects||e.defaults)&&(s.userMap={}),e.defaults&&(s.roomId="",s.type=e.enums===String?"AudioAndVideo":0),t.roomId!=null&&t.hasOwnProperty("roomId")&&(s.roomId=t.roomId),t.type!=null&&t.hasOwnProperty("type")&&(s.type=e.enums===String?$root.com.quick.voice.proto.LayoutType[t.type]===void 0?t.type:$root.com.quick.voice.proto.LayoutType[t.type]:t.type);let l;if(t.userMap&&(l=Object.keys(t.userMap)).length){s.userMap={};for(let c=0;c<l.length;++c)s.userMap[l[c]]=$root.com.quick.voice.proto.UserInfo.toObject(t.userMap[l[c]],e)}return t.globalCustom!=null&&t.hasOwnProperty("globalCustom")&&(s.globalCustom=$root.com.quick.voice.proto.CustomInfo.toObject(t.globalCustom,e),e.oneofs&&(s._globalCustom="globalCustom")),s},n.prototype.toJSON=function(){return this.constructor.toObject(this,minimalExports.util.toJSONOptions)},n.getTypeUrl=function(t){return t===void 0&&(t="type.googleapis.com"),t+"/com.quick.voice.proto.LayoutData"},n}(),a.UserInfo=function(){function n(i){if(this.audios=[],this.videos=[],i)for(let t=Object.keys(i),e=0;e<t.length;++e)i[t[e]]!=null&&(this[t[e]]=i[t[e]])}n.prototype.id="",n.prototype.audios=$util.emptyArray,n.prototype.videos=$util.emptyArray,n.prototype.custom=null;let o;return Object.defineProperty(n.prototype,"_custom",{get:$util.oneOfGetter(o=["custom"]),set:$util.oneOfSetter(o)}),n.create=function(t){return new n(t)},n.encode=function(t,e){if(e||(e=$Writer.create()),t.id!=null&&Object.hasOwnProperty.call(t,"id")&&e.uint32(10).string(t.id),t.audios!=null&&t.audios.length)for(let s=0;s<t.audios.length;++s)$root.com.quick.voice.proto.AudioInfo.encode(t.audios[s],e.uint32(18).fork()).ldelim();if(t.videos!=null&&t.videos.length)for(let s=0;s<t.videos.length;++s)$root.com.quick.voice.proto.VideoInfo.encode(t.videos[s],e.uint32(26).fork()).ldelim();return t.custom!=null&&Object.hasOwnProperty.call(t,"custom")&&$root.com.quick.voice.proto.CustomInfo.encode(t.custom,e.uint32(34).fork()).ldelim(),e},n.encodeDelimited=function(t,e){return this.encode(t,e).ldelim()},n.decode=function(t,e,s){t instanceof $Reader||(t=$Reader.create(t));let l=e===void 0?t.len:t.pos+e,c=new $root.com.quick.voice.proto.UserInfo;for(;t.pos<l;){let d=t.uint32();if(d===s)break;switch(d>>>3){case 1:{c.id=t.string();break}case 2:{c.audios&&c.audios.length||(c.audios=[]),c.audios.push($root.com.quick.voice.proto.AudioInfo.decode(t,t.uint32()));break}case 3:{c.videos&&c.videos.length||(c.videos=[]),c.videos.push($root.com.quick.voice.proto.VideoInfo.decode(t,t.uint32()));break}case 4:{c.custom=$root.com.quick.voice.proto.CustomInfo.decode(t,t.uint32());break}default:t.skipType(d&7);break}}return c},n.decodeDelimited=function(t){return t instanceof $Reader||(t=new $Reader(t)),this.decode(t,t.uint32())},n.verify=function(t){if(typeof t!="object"||t===null)return"object expected";if(t.id!=null&&t.hasOwnProperty("id")&&!$util.isString(t.id))return"id: string expected";if(t.audios!=null&&t.hasOwnProperty("audios")){if(!Array.isArray(t.audios))return"audios: array expected";for(let e=0;e<t.audios.length;++e){let s=$root.com.quick.voice.proto.AudioInfo.verify(t.audios[e]);if(s)return"audios."+s}}if(t.videos!=null&&t.hasOwnProperty("videos")){if(!Array.isArray(t.videos))return"videos: array expected";for(let e=0;e<t.videos.length;++e){let s=$root.com.quick.voice.proto.VideoInfo.verify(t.videos[e]);if(s)return"videos."+s}}if(t.custom!=null&&t.hasOwnProperty("custom")){let e=$root.com.quick.voice.proto.CustomInfo.verify(t.custom);if(e)return"custom."+e}return null},n.fromObject=function(t){if(t instanceof $root.com.quick.voice.proto.UserInfo)return t;let e=new $root.com.quick.voice.proto.UserInfo;if(t.id!=null&&(e.id=String(t.id)),t.audios){if(!Array.isArray(t.audios))throw TypeError(".com.quick.voice.proto.UserInfo.audios: array expected");e.audios=[];for(let s=0;s<t.audios.length;++s){if(typeof t.audios[s]!="object")throw TypeError(".com.quick.voice.proto.UserInfo.audios: object expected");e.audios[s]=$root.com.quick.voice.proto.AudioInfo.fromObject(t.audios[s])}}if(t.videos){if(!Array.isArray(t.videos))throw TypeError(".com.quick.voice.proto.UserInfo.videos: array expected");e.videos=[];for(let s=0;s<t.videos.length;++s){if(typeof t.videos[s]!="object")throw TypeError(".com.quick.voice.proto.UserInfo.videos: object expected");e.videos[s]=$root.com.quick.voice.proto.VideoInfo.fromObject(t.videos[s])}}if(t.custom!=null){if(typeof t.custom!="object")throw TypeError(".com.quick.voice.proto.UserInfo.custom: object expected");e.custom=$root.com.quick.voice.proto.CustomInfo.fromObject(t.custom)}return e},n.toObject=function(t,e){e||(e={});let s={};if((e.arrays||e.defaults)&&(s.audios=[],s.videos=[]),e.defaults&&(s.id=""),t.id!=null&&t.hasOwnProperty("id")&&(s.id=t.id),t.audios&&t.audios.length){s.audios=[];for(let l=0;l<t.audios.length;++l)s.audios[l]=$root.com.quick.voice.proto.AudioInfo.toObject(t.audios[l],e)}if(t.videos&&t.videos.length){s.videos=[];for(let l=0;l<t.videos.length;++l)s.videos[l]=$root.com.quick.voice.proto.VideoInfo.toObject(t.videos[l],e)}return t.custom!=null&&t.hasOwnProperty("custom")&&(s.custom=$root.com.quick.voice.proto.CustomInfo.toObject(t.custom,e),e.oneofs&&(s._custom="custom")),s},n.prototype.toJSON=function(){return this.constructor.toObject(this,minimalExports.util.toJSONOptions)},n.getTypeUrl=function(t){return t===void 0&&(t="type.googleapis.com"),t+"/com.quick.voice.proto.UserInfo"},n}(),a.AudioInfo=function(){function n(i){if(i)for(let t=Object.keys(i),e=0;e<t.length;++e)i[t[e]]!=null&&(this[t[e]]=i[t[e]])}n.prototype.type=0,n.prototype.isEnable=!1,n.prototype.isMute=!1,n.prototype.volume=0,n.prototype.updateTime=null;let o;return Object.defineProperty(n.prototype,"_updateTime",{get:$util.oneOfGetter(o=["updateTime"]),set:$util.oneOfSetter(o)}),n.create=function(t){return new n(t)},n.encode=function(t,e){return e||(e=$Writer.create()),t.type!=null&&Object.hasOwnProperty.call(t,"type")&&e.uint32(8).int32(t.type),t.isEnable!=null&&Object.hasOwnProperty.call(t,"isEnable")&&e.uint32(16).bool(t.isEnable),t.isMute!=null&&Object.hasOwnProperty.call(t,"isMute")&&e.uint32(24).bool(t.isMute),t.volume!=null&&Object.hasOwnProperty.call(t,"volume")&&e.uint32(33).double(t.volume),t.updateTime!=null&&Object.hasOwnProperty.call(t,"updateTime")&&e.uint32(40).int64(t.updateTime),e},n.encodeDelimited=function(t,e){return this.encode(t,e).ldelim()},n.decode=function(t,e,s){t instanceof $Reader||(t=$Reader.create(t));let l=e===void 0?t.len:t.pos+e,c=new $root.com.quick.voice.proto.AudioInfo;for(;t.pos<l;){let d=t.uint32();if(d===s)break;switch(d>>>3){case 1:{c.type=t.int32();break}case 2:{c.isEnable=t.bool();break}case 3:{c.isMute=t.bool();break}case 4:{c.volume=t.double();break}case 5:{c.updateTime=t.int64();break}default:t.skipType(d&7);break}}return c},n.decodeDelimited=function(t){return t instanceof $Reader||(t=new $Reader(t)),this.decode(t,t.uint32())},n.verify=function(t){if(typeof t!="object"||t===null)return"object expected";if(t.type!=null&&t.hasOwnProperty("type"))switch(t.type){default:return"type: enum value expected";case 0:case 1:break}return t.isEnable!=null&&t.hasOwnProperty("isEnable")&&typeof t.isEnable!="boolean"?"isEnable: boolean expected":t.isMute!=null&&t.hasOwnProperty("isMute")&&typeof t.isMute!="boolean"?"isMute: boolean expected":t.volume!=null&&t.hasOwnProperty("volume")&&typeof t.volume!="number"?"volume: number expected":t.updateTime!=null&&t.hasOwnProperty("updateTime")&&!$util.isInteger(t.updateTime)&&!(t.updateTime&&$util.isInteger(t.updateTime.low)&&$util.isInteger(t.updateTime.high))?"updateTime: integer|Long expected":null},n.fromObject=function(t){if(t instanceof $root.com.quick.voice.proto.AudioInfo)return t;let e=new $root.com.quick.voice.proto.AudioInfo;switch(t.type){default:if(typeof t.type=="number"){e.type=t.type;break}break;case"Microphone":case 0:e.type=0;break;case"SystemVoice":case 1:e.type=1;break}return t.isEnable!=null&&(e.isEnable=!!t.isEnable),t.isMute!=null&&(e.isMute=!!t.isMute),t.volume!=null&&(e.volume=Number(t.volume)),t.updateTime!=null&&($util.Long?(e.updateTime=$util.Long.fromValue(t.updateTime)).unsigned=!1:typeof t.updateTime=="string"?e.updateTime=parseInt(t.updateTime,10):typeof t.updateTime=="number"?e.updateTime=t.updateTime:typeof t.updateTime=="object"&&(e.updateTime=new $util.LongBits(t.updateTime.low>>>0,t.updateTime.high>>>0).toNumber())),e},n.toObject=function(t,e){e||(e={});let s={};return e.defaults&&(s.type=e.enums===String?"Microphone":0,s.isEnable=!1,s.isMute=!1,s.volume=0),t.type!=null&&t.hasOwnProperty("type")&&(s.type=e.enums===String?$root.com.quick.voice.proto.AudioType[t.type]===void 0?t.type:$root.com.quick.voice.proto.AudioType[t.type]:t.type),t.isEnable!=null&&t.hasOwnProperty("isEnable")&&(s.isEnable=t.isEnable),t.isMute!=null&&t.hasOwnProperty("isMute")&&(s.isMute=t.isMute),t.volume!=null&&t.hasOwnProperty("volume")&&(s.volume=e.json&&!isFinite(t.volume)?String(t.volume):t.volume),t.updateTime!=null&&t.hasOwnProperty("updateTime")&&(typeof t.updateTime=="number"?s.updateTime=e.longs===String?String(t.updateTime):t.updateTime:s.updateTime=e.longs===String?$util.Long.prototype.toString.call(t.updateTime):e.longs===Number?new $util.LongBits(t.updateTime.low>>>0,t.updateTime.high>>>0).toNumber():t.updateTime,e.oneofs&&(s._updateTime="updateTime")),s},n.prototype.toJSON=function(){return this.constructor.toObject(this,minimalExports.util.toJSONOptions)},n.getTypeUrl=function(t){return t===void 0&&(t="type.googleapis.com"),t+"/com.quick.voice.proto.AudioInfo"},n}(),a.VideoInfo=function(){function n(i){if(i)for(let t=Object.keys(i),e=0;e<t.length;++e)i[t[e]]!=null&&(this[t[e]]=i[t[e]])}n.prototype.type=0,n.prototype.isEnable=!1,n.prototype.isMute=!1,n.prototype.width=0,n.prototype.height=0,n.prototype.x=0,n.prototype.y=0,n.prototype.updateTime=null;let o;return Object.defineProperty(n.prototype,"_updateTime",{get:$util.oneOfGetter(o=["updateTime"]),set:$util.oneOfSetter(o)}),n.create=function(t){return new n(t)},n.encode=function(t,e){return e||(e=$Writer.create()),t.type!=null&&Object.hasOwnProperty.call(t,"type")&&e.uint32(8).int32(t.type),t.isEnable!=null&&Object.hasOwnProperty.call(t,"isEnable")&&e.uint32(16).bool(t.isEnable),t.isMute!=null&&Object.hasOwnProperty.call(t,"isMute")&&e.uint32(24).bool(t.isMute),t.width!=null&&Object.hasOwnProperty.call(t,"width")&&e.uint32(32).int32(t.width),t.height!=null&&Object.hasOwnProperty.call(t,"height")&&e.uint32(40).int32(t.height),t.x!=null&&Object.hasOwnProperty.call(t,"x")&&e.uint32(48).int32(t.x),t.y!=null&&Object.hasOwnProperty.call(t,"y")&&e.uint32(56).int32(t.y),t.updateTime!=null&&Object.hasOwnProperty.call(t,"updateTime")&&e.uint32(64).int64(t.updateTime),e},n.encodeDelimited=function(t,e){return this.encode(t,e).ldelim()},n.decode=function(t,e,s){t instanceof $Reader||(t=$Reader.create(t));let l=e===void 0?t.len:t.pos+e,c=new $root.com.quick.voice.proto.VideoInfo;for(;t.pos<l;){let d=t.uint32();if(d===s)break;switch(d>>>3){case 1:{c.type=t.int32();break}case 2:{c.isEnable=t.bool();break}case 3:{c.isMute=t.bool();break}case 4:{c.width=t.int32();break}case 5:{c.height=t.int32();break}case 6:{c.x=t.int32();break}case 7:{c.y=t.int32();break}case 8:{c.updateTime=t.int64();break}default:t.skipType(d&7);break}}return c},n.decodeDelimited=function(t){return t instanceof $Reader||(t=new $Reader(t)),this.decode(t,t.uint32())},n.verify=function(t){if(typeof t!="object"||t===null)return"object expected";if(t.type!=null&&t.hasOwnProperty("type"))switch(t.type){default:return"type: enum value expected";case 0:case 1:break}return t.isEnable!=null&&t.hasOwnProperty("isEnable")&&typeof t.isEnable!="boolean"?"isEnable: boolean expected":t.isMute!=null&&t.hasOwnProperty("isMute")&&typeof t.isMute!="boolean"?"isMute: boolean expected":t.width!=null&&t.hasOwnProperty("width")&&!$util.isInteger(t.width)?"width: integer expected":t.height!=null&&t.hasOwnProperty("height")&&!$util.isInteger(t.height)?"height: integer expected":t.x!=null&&t.hasOwnProperty("x")&&!$util.isInteger(t.x)?"x: integer expected":t.y!=null&&t.hasOwnProperty("y")&&!$util.isInteger(t.y)?"y: integer expected":t.updateTime!=null&&t.hasOwnProperty("updateTime")&&!$util.isInteger(t.updateTime)&&!(t.updateTime&&$util.isInteger(t.updateTime.low)&&$util.isInteger(t.updateTime.high))?"updateTime: integer|Long expected":null},n.fromObject=function(t){if(t instanceof $root.com.quick.voice.proto.VideoInfo)return t;let e=new $root.com.quick.voice.proto.VideoInfo;switch(t.type){default:if(typeof t.type=="number"){e.type=t.type;break}break;case"Camera":case 0:e.type=0;break;case"Screen":case 1:e.type=1;break}return t.isEnable!=null&&(e.isEnable=!!t.isEnable),t.isMute!=null&&(e.isMute=!!t.isMute),t.width!=null&&(e.width=t.width|0),t.height!=null&&(e.height=t.height|0),t.x!=null&&(e.x=t.x|0),t.y!=null&&(e.y=t.y|0),t.updateTime!=null&&($util.Long?(e.updateTime=$util.Long.fromValue(t.updateTime)).unsigned=!1:typeof t.updateTime=="string"?e.updateTime=parseInt(t.updateTime,10):typeof t.updateTime=="number"?e.updateTime=t.updateTime:typeof t.updateTime=="object"&&(e.updateTime=new $util.LongBits(t.updateTime.low>>>0,t.updateTime.high>>>0).toNumber())),e},n.toObject=function(t,e){e||(e={});let s={};return e.defaults&&(s.type=e.enums===String?"Camera":0,s.isEnable=!1,s.isMute=!1,s.width=0,s.height=0,s.x=0,s.y=0),t.type!=null&&t.hasOwnProperty("type")&&(s.type=e.enums===String?$root.com.quick.voice.proto.VideoType[t.type]===void 0?t.type:$root.com.quick.voice.proto.VideoType[t.type]:t.type),t.isEnable!=null&&t.hasOwnProperty("isEnable")&&(s.isEnable=t.isEnable),t.isMute!=null&&t.hasOwnProperty("isMute")&&(s.isMute=t.isMute),t.width!=null&&t.hasOwnProperty("width")&&(s.width=t.width),t.height!=null&&t.hasOwnProperty("height")&&(s.height=t.height),t.x!=null&&t.hasOwnProperty("x")&&(s.x=t.x),t.y!=null&&t.hasOwnProperty("y")&&(s.y=t.y),t.updateTime!=null&&t.hasOwnProperty("updateTime")&&(typeof t.updateTime=="number"?s.updateTime=e.longs===String?String(t.updateTime):t.updateTime:s.updateTime=e.longs===String?$util.Long.prototype.toString.call(t.updateTime):e.longs===Number?new $util.LongBits(t.updateTime.low>>>0,t.updateTime.high>>>0).toNumber():t.updateTime,e.oneofs&&(s._updateTime="updateTime")),s},n.prototype.toJSON=function(){return this.constructor.toObject(this,minimalExports.util.toJSONOptions)},n.getTypeUrl=function(t){return t===void 0&&(t="type.googleapis.com"),t+"/com.quick.voice.proto.VideoInfo"},n}(),a.CustomInfo=function(){function n(i){if(this.customKeyMap={},i)for(let t=Object.keys(i),e=0;e<t.length;++e)i[t[e]]!=null&&(this[t[e]]=i[t[e]])}n.prototype.roomId="",n.prototype.customKeyMap=$util.emptyObject,n.prototype.updateTime=null;let o;return Object.defineProperty(n.prototype,"_updateTime",{get:$util.oneOfGetter(o=["updateTime"]),set:$util.oneOfSetter(o)}),n.create=function(t){return new n(t)},n.encode=function(t,e){if(e||(e=$Writer.create()),t.roomId!=null&&Object.hasOwnProperty.call(t,"roomId")&&e.uint32(10).string(t.roomId),t.customKeyMap!=null&&Object.hasOwnProperty.call(t,"customKeyMap"))for(let s=Object.keys(t.customKeyMap),l=0;l<s.length;++l)e.uint32(18).fork().uint32(10).string(s[l]).uint32(18).string(t.customKeyMap[s[l]]).ldelim();return t.updateTime!=null&&Object.hasOwnProperty.call(t,"updateTime")&&e.uint32(24).int64(t.updateTime),e},n.encodeDelimited=function(t,e){return this.encode(t,e).ldelim()},n.decode=function(t,e,s){t instanceof $Reader||(t=$Reader.create(t));let l=e===void 0?t.len:t.pos+e,c=new $root.com.quick.voice.proto.CustomInfo,d,p;for(;t.pos<l;){let f=t.uint32();if(f===s)break;switch(f>>>3){case 1:{c.roomId=t.string();break}case 2:{c.customKeyMap===$util.emptyObject&&(c.customKeyMap={});let w=t.uint32()+t.pos;for(d="",p="";t.pos<w;){let b=t.uint32();switch(b>>>3){case 1:d=t.string();break;case 2:p=t.string();break;default:t.skipType(b&7);break}}c.customKeyMap[d]=p;break}case 3:{c.updateTime=t.int64();break}default:t.skipType(f&7);break}}return c},n.decodeDelimited=function(t){return t instanceof $Reader||(t=new $Reader(t)),this.decode(t,t.uint32())},n.verify=function(t){if(typeof t!="object"||t===null)return"object expected";if(t.roomId!=null&&t.hasOwnProperty("roomId")&&!$util.isString(t.roomId))return"roomId: string expected";if(t.customKeyMap!=null&&t.hasOwnProperty("customKeyMap")){if(!$util.isObject(t.customKeyMap))return"customKeyMap: object expected";let e=Object.keys(t.customKeyMap);for(let s=0;s<e.length;++s)if(!$util.isString(t.customKeyMap[e[s]]))return"customKeyMap: string{k:string} expected"}return t.updateTime!=null&&t.hasOwnProperty("updateTime")&&!$util.isInteger(t.updateTime)&&!(t.updateTime&&$util.isInteger(t.updateTime.low)&&$util.isInteger(t.updateTime.high))?"updateTime: integer|Long expected":null},n.fromObject=function(t){if(t instanceof $root.com.quick.voice.proto.CustomInfo)return t;let e=new $root.com.quick.voice.proto.CustomInfo;if(t.roomId!=null&&(e.roomId=String(t.roomId)),t.customKeyMap){if(typeof t.customKeyMap!="object")throw TypeError(".com.quick.voice.proto.CustomInfo.customKeyMap: object expected");e.customKeyMap={};for(let s=Object.keys(t.customKeyMap),l=0;l<s.length;++l)e.customKeyMap[s[l]]=String(t.customKeyMap[s[l]])}return t.updateTime!=null&&($util.Long?(e.updateTime=$util.Long.fromValue(t.updateTime)).unsigned=!1:typeof t.updateTime=="string"?e.updateTime=parseInt(t.updateTime,10):typeof t.updateTime=="number"?e.updateTime=t.updateTime:typeof t.updateTime=="object"&&(e.updateTime=new $util.LongBits(t.updateTime.low>>>0,t.updateTime.high>>>0).toNumber())),e},n.toObject=function(t,e){e||(e={});let s={};(e.objects||e.defaults)&&(s.customKeyMap={}),e.defaults&&(s.roomId=""),t.roomId!=null&&t.hasOwnProperty("roomId")&&(s.roomId=t.roomId);let l;if(t.customKeyMap&&(l=Object.keys(t.customKeyMap)).length){s.customKeyMap={};for(let c=0;c<l.length;++c)s.customKeyMap[l[c]]=t.customKeyMap[l[c]]}return t.updateTime!=null&&t.hasOwnProperty("updateTime")&&(typeof t.updateTime=="number"?s.updateTime=e.longs===String?String(t.updateTime):t.updateTime:s.updateTime=e.longs===String?$util.Long.prototype.toString.call(t.updateTime):e.longs===Number?new $util.LongBits(t.updateTime.low>>>0,t.updateTime.high>>>0).toNumber():t.updateTime,e.oneofs&&(s._updateTime="updateTime")),s},n.prototype.toJSON=function(){return this.constructor.toObject(this,minimalExports.util.toJSONOptions)},n.getTypeUrl=function(t){return t===void 0&&(t="type.googleapis.com"),t+"/com.quick.voice.proto.CustomInfo"},n}(),a.LayoutType=function(){const n={},o=Object.create(n);return o[n[0]="AudioAndVideo"]=0,o[n[1]="OnlyAudio"]=1,o[n[2]="OnlyVideo"]=2,o}(),a.AudioType=function(){const n={},o=Object.create(n);return o[n[0]="Microphone"]=0,o[n[1]="SystemVoice"]=1,o}(),a.VideoType=function(){const n={},o=Object.create(n);return o[n[0]="Camera"]=0,o[n[1]="Screen"]=1,o}(),a}(),u}(),r}(),h})(),createAudioInfo=()=>({remove:!1,isEnable:!1,updateTime:0,isMute:!1,volume:0}),createVideoInfo=()=>({remove:!1,isEnable:!1,updateTime:0,isMute:!1,sx:0,sy:0,sw:0,sh:0});class RoomUser{constructor(){m(this,"userId","");m(this,"mc_audio");m(this,"mc_video");m(this,"ss_audio");m(this,"ss_video");m(this,"updateTime",0);m(this,"getUpdateTimeKey",()=>{const r=[];return this.mc_audio&&r.push(this.mc_audio.updateTime),this.mc_video&&r.push(this.mc_video.updateTime),this.ss_audio&&r.push(this.ss_audio.updateTime),this.ss_video&&r.push(this.ss_video.updateTime),r.join("_")});m(this,"init",r=>{var t,e,s,l;const{id:u,audios:a=[],videos:n=[]}=r;this.userId=u;const o=this.getUpdateTimeKey();this.mc_audio&&(this.mc_audio.remove=!0),this.mc_video&&(this.mc_video.remove=!0),this.ss_audio&&(this.ss_audio.remove=!0),this.ss_video&&(this.ss_video.remove=!0);for(const c of a){const{type:d=0,isEnable:p=!1,isMute:f=!1,updateTime:w,volume:b=0}=c;switch(d){case 0:{if(this.mc_audio||(this.mc_audio=createAudioInfo()),this.mc_audio.remove=!1,this.mc_audio.updateTime===w)break;this.mc_audio.isEnable=!!p,this.mc_audio.isMute=!!f,this.mc_audio.updateTime=Number(w),this.mc_audio.volume=Number(b)}break;case 1:{if(this.ss_audio||(this.ss_audio=createAudioInfo()),this.ss_audio.remove=!1,this.ss_audio.updateTime===w)break;this.ss_audio.isEnable=!!p,this.ss_audio.isMute=!!f,this.ss_audio.updateTime=Number(w),this.ss_audio.volume=Number(b)}break}}for(const c of n){const{type:d=0,isEnable:p,isMute:f,updateTime:w,width:b,height:g,x:k,y:I}=c;switch(d){case 0:{if(this.mc_video||(this.mc_video=createVideoInfo()),this.mc_video.remove=!1,this.mc_video.updateTime===w)break;this.mc_video.isEnable=!!p,this.mc_video.isMute=!!f,this.mc_video.updateTime=Number(w)||0,this.mc_video.sx=k||0,this.mc_video.sy=I||0,this.mc_video.sw=b||0,this.mc_video.sh=g||0}break;case 1:{if(this.ss_video||(this.ss_video=createVideoInfo()),this.ss_video.remove=!1,this.ss_video.updateTime===w)break;this.ss_video.isEnable=!!p,this.ss_video.isMute=!!f,this.ss_video.updateTime=Number(w)||0,this.ss_video.sx=k||0,this.ss_video.sy=I||0,this.ss_video.sw=b||0,this.ss_video.sh=g||0}break}}(t=this.mc_audio)!=null&&t.remove&&(this.mc_audio=void 0),(e=this.mc_video)!=null&&e.remove&&(this.mc_video=void 0),(s=this.ss_audio)!=null&&s.remove&&(this.ss_audio=void 0),(l=this.ss_video)!=null&&l.remove&&(this.ss_video=void 0);const i=this.getUpdateTimeKey();o!==i&&(this.updateTime=new Date().getTime())});m(this,"destroy",()=>{var r,u;(r=this.mc_video)!=null&&r.destroy&&this.mc_video.destroy(),(u=this.ss_video)!=null&&u.destroy&&this.ss_video.destroy(),this.mc_audio=void 0,this.mc_video=void 0,this.ss_audio=void 0,this.ss_video=void 0})}}const parseSEI=h=>{let r=0,u=0;for(;;){const n=h[r];if(u=u+n,r=r+1,n!==255)break}let a=0;for(;;){const n=h[r];if(a=a+n,r=r+1,n!==255)break}if(u===5){const n=h.slice(r,r+16),i=Array.from(n,f=>f.toString(16).padStart(2,"0")).join("");r=r+16;const t=a-16,e=h.slice(r,r+t),s=com.quick.voice.proto.SeiData.decode(e),{event:l=0}=s,c=s.data;let d;switch(l){case 0:d=com.quick.voice.proto.LayoutData.decode(s.data);break;case 1:d=com.quick.voice.proto.CustomInfo.decode(s.data);break}return{uuid:i,...s,event:l,data_remote:c,data:d}}};class QuickVoPlayer{constructor(r={}){m(this,"option",{debug:!1,ws:"wss://livep2p.devplay.cc/websocket"});m(this,"displayMode","original");m(this,"prPlayer");m(this,"dom");m(this,"room",{roomId:"",updateTime:"",author:"",version:""});m(this,"usersMap",new Map);m(this,"on",{users:r=>{}});m(this,"start",async r=>(this.stop(),this.prPlayer.start(r)));m(this,"stop",()=>{this.prPlayer.stop(),this.usersMap=new Map,this.room.roomId="",this.room.author="",this.room.updateTime="",this.room.version=""});m(this,"setMute",r=>{this.prPlayer.setMute(r)});m(this,"getStream",()=>this.prPlayer.getStream());m(this,"getAllUseUpdateKey",()=>{const r=[...this.usersMap.values()];return Array.from(r,a=>a.updateTime).join("_")});m(this,"checkAndCreateUser",(r,u)=>{var a,n;if(this.usersMap.has(r)){const o=this.usersMap.get(r);if(o==null||o.init(u),o!=null&&o.mc_video){const{sx:i,sy:t,sw:e,sh:s}=o.mc_video;(a=o==null?void 0:o.mc_video.worker)==null||a.setCut({sx:i,sy:t,sw:e,sh:s})}if(o!=null&&o.ss_video){const{sx:i,sy:t,sw:e,sh:s}=o.ss_video;(n=o==null?void 0:o.ss_video.worker)==null||n.setCut({sx:i,sy:t,sw:e,sh:s})}}else{const o=new RoomUser;if(this.usersMap.set(r,o),o.init(u),o){if(o.mc_video){const{sx:i,sy:t,sw:e,sh:s}=o.mc_video,l=`${o.userId}_mc_video`,{worker:c,stream:d,destroy:p}=this.prPlayer.cut.create(l,{sx:i,sy:t,sw:e,sh:s});o.mc_video.worker=c,this.displayMode==="original"&&c.setPause(!0),o.mc_video.stream=d,o.mc_video.destroy=()=>{p(),this.prPlayer.cut.remove(l),this.usersMap.delete(o.userId)}}if(o.ss_video){const{sx:i,sy:t,sw:e,sh:s}=o.ss_video,l=`${o.userId}_ss_video`,{worker:c,stream:d,destroy:p}=this.prPlayer.cut.create(l,{sx:i,sy:t,sw:e,sh:s});o.ss_video.worker=c,this.displayMode==="original"&&c.setPause(!0),o.ss_video.stream=d,o.ss_video.destroy=()=>{p(),this.prPlayer.cut.remove(l),this.usersMap.delete(o.userId)}}}}});m(this,"onSEI",r=>{try{const u=parseSEI(r);if(!u)return;const{event:a,data:n}=u;switch(a){case 0:{const{roomId:o,userMap:i}=n;if(o!==this.room.roomId)return;const t=this.getAllUseUpdateKey(),e=Object.keys(i);{const l=[...this.usersMap.values()];for(const c of l)e.includes(c.userId)||c==null||c.destroy()}for(const l of e){const c=i[l];this.checkAndCreateUser(l,c)}const s=this.getAllUseUpdateKey();if(t!==s&&this.on.users){const l=[...this.usersMap.values()],c=Array.from(l,({userId:d,mc_audio:p,mc_video:f,ss_audio:w,ss_video:b,updateTime:g})=>({userId:d,mc_audio:p,mc_video:f,ss_audio:w,ss_video:b,updateTime:g}));this.on.users(c)}}break;case 1:{const{roomId:o,updateTime:i}=n,{author:t,version:e}=n.customKeyMap;this.room.roomId=o,this.room.updateTime=i,this.room.author=t,this.room.version=e}break}}catch(u){console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m","color:#0097ff;","------->onSEI: error",u)}});m(this,"setDisplayMode",r=>{var u,a,n,o,i,t,e,s;switch(this.displayMode=r,r){case"original":{this.prPlayer.setPause(!1);const l=[...this.usersMap.values()];for(const c of l)(a=(u=c.mc_video)==null?void 0:u.worker)==null||a.setPause(!0),(o=(n=c.ss_video)==null?void 0:n.worker)==null||o.setPause(!0)}break;case"cut":{this.prPlayer.setPause(!0);const l=[...this.usersMap.values()];for(const c of l)(t=(i=c.mc_video)==null?void 0:i.worker)==null||t.setPause(!1),(s=(e=c.ss_video)==null?void 0:e.worker)==null||s.setPause(!1)}break}});const{debug:u=!1}=r;this.option.debug=u,this.prPlayer=new et({debug:u}),this.prPlayer.on.demuxer.chunk=a=>{},this.prPlayer.on.decoder.sei=this.onSEI}}exports.QuickVoPlayer=QuickVoPlayer,Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"})});
|
|
1
|
+
(function(U,T){typeof exports=="object"&&typeof module<"u"?T(exports):typeof define=="function"&&define.amd?define(["exports"],T):(U=typeof globalThis<"u"?globalThis:U||self,T(U["quickvo-player"]={}))})(this,function(exports){"use strict";var Z=Object.defineProperty;var X=U=>{throw TypeError(U)};var tt=(U,T,h)=>T in U?Z(U,T,{enumerable:!0,configurable:!0,writable:!0,value:h}):U[T]=h;var m=(U,T,h)=>tt(U,typeof T!="symbol"?T+"":T,h),Q=(U,T,h)=>T.has(U)||X("Cannot "+h);var P=(U,T,h)=>(Q(U,T,"read from private field"),h?h.call(U):T.get(U)),J=(U,T,h)=>T.has(U)?X("Cannot add the same private member more than once"):T instanceof WeakSet?T.add(U):T.set(U,h),H=(U,T,h,r)=>(Q(U,T,"write to private field"),r?r.call(U,h):T.set(U,h),h);var U,T;const D='(function(){"use strict";class P{pendingPayloads=[];payload=new Uint8Array(0);chunks=[];push=t=>{this.pendingPayloads.push(t)};next=(t=0)=>{this.payload=this.payload.slice(t);const s=this.pendingPayloads.shift();if(!s)return!1;const e=new Uint8Array(this.payload.byteLength+s.byteLength);return e.set(this.payload,0),e.set(s,this.payload.byteLength),this.payload=e,new DataView(this.payload.buffer)};pushChunk=t=>{this.chunks.push(t),this.chunks.length>1e3&&this.chunks.shift()};destroy=()=>{this.pendingPayloads=[],this.payload=new Uint8Array(0),this.chunks=[]}}const I=(y,t)=>{const s=new Uint8Array(y),e=new Uint8Array(t),n=new Uint8Array(11+s.length+e.length);let a=0;return n[a++]=1,n[a++]=s[1],n[a++]=s[2],n[a++]=s[3],n[a++]=255,n[a++]=225,n[a++]=s.length>>8&255,n[a++]=s.length&255,n.set(s,a),a+=s.length,n[a++]=1,n[a++]=e.length>>8&255,n[a++]=e.length&255,n.set(e,a),n},T=y=>{let t=0;const s=new DataView(y.buffer),e=s.getUint8(t);if(t=t+1,e!==1)throw new Error("Invalid AVC version");const n=s.getUint8(t)&255;t=t+1;const a=s.getUint8(t)&255;t=t+1;const o=s.getUint8(t)&255;t=t+1;const c=`avc1.${Array.from([n,a,o],U=>U.toString(16).padStart(2,"0")).join("")}`,r=(s.getUint8(t)&3)-1;t=t+1;const g=s.getUint8(t)&31;t=t+1;const p=s.getUint16(t,!1);t=t+2;const h=new Uint8Array(s.buffer.slice(t,t+p));t=t+p;const d=s.getUint8(t)&31;t=t+1;const u=s.getUint16(t,!1);t=t+2;const f=new Uint8Array(s.buffer.slice(t,t+u));return t=t+u,{version:e,codec:c,profile:n,compatibility:a,level:o,lengthSizeMinusOne:r,numOfSequenceParameterSets:g,sequenceParameterSetLength:p,sps:h,numOfPictureParameterSets:d,pictureParameterSetLength:u,pps:f}},M=y=>{const t=new Uint8Array(4+y.length);return new DataView(t.buffer).setUint32(0,y.length,!1),t.set(y,4),t},C=y=>{let t=0;for(const n of y)t+=n.length;const s=new Uint8Array(t);let e=0;for(const n of y){const a=n;s.set(a,e),e+=a.length}return s},D=y=>{let t="unknown";switch(y){case 1:case 2:case 27:case 36:t="video";break;case 3:case 4:case 15:t="audio";break;case 6:t="subtitle";break;case 134:t="ad";break}return t};class x{pat;pmt;audioConfig;videoConfig;payloadMap=new Map;on={};constructor(){}parse=async t=>{let s=0;for(;!(s+188>t.byteLength);){if(t.getInt8(s)!=71){s++;continue}await this.parsePacket(t,s),s+=188}return s};parsePacket=async(t,s)=>{if(s+188>t.byteLength)throw new Error("Invalid TS packet");if(t.getUint8(s)!==71)throw new Error("Invalid TS packet");let e=s;const n=this.parseHeader(t,e);e+=4;const{transport_error_indicator:a,pid:o,payload_unit_start_indicator:l,adaptation_field_control:i}=n;if(a===1||o===void 0)return;let c=184;if(i===2||i===3){const r=t.getUint8(e);e+=1,this.parseAdaptationField(t,e),e+=r,c-=r}if(i===3&&(c-=1),i===1||i===3){const r=new Uint8Array(t.buffer.slice(e,e+c));if(o===0)return this.parsePAT(t,e);{const{programs:h=[]}=this.pat||{};if(h.find(u=>u.pmt_pid===o))return this.parsePMT(t,e)}const{streams:g=[]}=this.pmt||{},p=g.find(h=>h.elementary_pid===o);if(p){if(l===1){const h=this.payloadMap.get(o);if(h){switch(p.kind){case"audio":{const d=await this.parseAudio(h);this.on.chunk&&this.on.chunk(d)}break;case"video":{const d=await this.parseVideo(h);this.on.chunk&&this.on.chunk(d),await new Promise(u=>setTimeout(()=>u(!0),0))}break}this.payloadMap.delete(o)}}{this.payloadMap.has(o)||this.payloadMap.set(o,new Uint8Array);const h=this.payloadMap.get(o),d=new Uint8Array(h.byteLength+r.byteLength);d.set(h,0),d.set(r,h.byteLength),this.payloadMap.set(o,d)}}}};parseHeader=(t,s)=>{let e=s;const n=t.getUint8(e),a=t.getUint8(e+1),o=t.getUint8(e+2),l=t.getUint8(e+3),i=(a&128)>>7;if(i===1)return{sync_byte:n,transport_error_indicator:i};const c=(a&64)>>6,r=(a&32)>>5,g=(a&31)<<8|o,p=(l&192)>>6,h=l>>4&3,d=l&15;return{sync_byte:n,transport_error_indicator:i,payload_unit_start_indicator:c,transport_priority:r,pid:g,transport_scrambling_control:p,adaptation_field_control:h,continuity_counter:d}};parsePAT=(t,s)=>{let e=s,n;{const l=t.getUint8(e);e+=1;const i=t.getUint8(e);if(e+=1,i!==0)throw new Error("Invalid PAT table_id");const c=t.getUint16(e)&4095;e+=2;const r=t.getUint16(e);e+=2;const g=(t.getUint8(e)&62)>>1,p=t.getUint8(e)&1;e+=1;const h=t.getUint8(e);e+=1;const d=t.getUint8(e);e+=1,n={pointer_field:l,table_id:i,section_length:c,transport_stream_id:r,version_number:g,current_next_indicator:p,section_number:h,last_section_number:d}}const a=[];{const l=n.section_length-5-4,i=e+l;for(;e<i;){const c=t.getUint16(e),r=t.getUint16(e+2)&8191;e+=4,c!==0&&r>=32&&r<=8190&&a.push({program_number:c,pmt_pid:r})}}const o=t.getUint32(e);this.pat={header:n,programs:a,crc32:o},this.on.debug&&this.on.debug({pat:this.pat})};parsePMT=(t,s)=>{let e=s,n;{const l=t.getUint8(e);e+=1;const i=t.getUint8(e);if(e+=1,i!==2)throw new Error("Invalid PMT table_id");const c=t.getUint16(e)&4095;e+=2;const r=t.getUint16(e);e+=2;const g=(t.getUint8(e)&62)>>1,p=t.getUint8(e)&1;e+=1;const h=t.getUint8(e);e+=1;const d=t.getUint8(e);e+=1;const u=t.getUint16(e)&8191;e+=2;const f=t.getUint16(e)&4095;e+=2,n={pointer_field:l,table_id:i,section_length:c,transport_stream_id:r,version_number:g,current_next_indicator:p,section_number:h,last_section_number:d,pcr_pid:u,program_info_length:f}}const a=[];{const l=n.section_length-9-4,i=e+l;for(;e<i;){const c=t.getUint8(e),r=D(c),g=t.getUint16(e+1)&8191,p=t.getUint16(e+3)&4095;if(e+=5,g<32||g>8190){console.warn(`Invalid elementary_pid: 0x${g.toString(16)}`);continue}a.push({kind:r,stream_type:c,elementary_pid:g,es_info_length:p})}}const o=t.getUint32(e);this.pmt={header:n,streams:a,crc32:o},this.on.debug&&this.on.debug({pmt:this.pmt})};parseAdaptationField=(t,s)=>{let e=s,n,a,o,l;const i=t.getUint8(e),c=!!(i&128),r=!!(i&64),g=!!(i&32),p=!!(i&16),h=!!(i&8),d=!!(i&4),u=!!(i&2),f=!!(i&1);e+=1;const U=(_,b)=>{let m=BigInt(0);m|=BigInt(_.getUint16(b))<<25n,m|=BigInt(_.getUint16(b+1))<<17n,m|=BigInt(_.getUint16(b+2))<<9n,m|=BigInt(_.getUint16(b+3))<<1n,m|=BigInt(_.getUint16(b+4)>>7);const S=(_.getUint16(b+4)&1)<<8|_.getUint16(b+5);return m=m*300n+BigInt(S),m};if(p&&(n=U(t,e),e+=6),h&&(a=U(t,e),e+=6),d&&(o=t.getInt8(e),e+=1),u){const _=t.getUint8(e);e+=1,l=new Uint8Array(t.buffer,e,_),e+=_}return{discontinuity_indicator:c,random_access_indicator:r,elementary_stream_priority_indicator:g,pcr_flag:p,opcr_flag:h,splicing_point_flag:d,transport_private_data_flag:u,adaptation_field_extension_flag:f,pcr:n,opcr:a,splice_countdown:o,transport_private_data:l}};parseAudio=async t=>{const s=new DataView(t.buffer);let e=0,n,a;{const o=s.getUint8(e)===0&&s.getUint8(e+1)===0&&s.getUint8(e+2)===1;if(e+=3,!o)throw new Error("invalid ts audio payload.");const l=s.getUint8(e);e+=1;const i=s.getUint8(e)<<8|s.getUint8(e+1);e+=2;let c,r,g,p,h;{const f=s.getUint8(e);e+=1,c=f>>4&3,r=(f>>3&1)===1,g=(f>>2&1)===1,p=(f>>1&1)===1,h=(f&1)===1}let d,u;{const f=s.getUint8(e);e+=1;const U=f>>6,_=s.getUint8(e);e+=1,(U&2)===2&&(d=this.parsePtsDts(s,e)),(U&1)===1?u=this.parsePtsDts(s,e+5):u=d,e+=_}n={stream_id:l,pes_packet_length:i,scrambling_control:c,priority:r,data_alignment:g,copyright:p,original_copy:h,pts:d,dts:u}}a=t.slice(e);{if(!this.audioConfig&&s.getUint8(e)===255){const g=s.getUint8(e+2),p=s.getUint8(e+3);let h,d;d=g>>2&15,h=(g&1)<<2|p>>6;const u=`mp4a.40.${h}`,U=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350][d];this.audioConfig={kind:"audio",codec:u,sampleRate:U,numberOfChannels:h},this.on.config&&this.on.config(this.audioConfig)}const{dts:o=0,pts:l=0}=n,i=l-o,c=a.slice(7);return{kind:"audio",type:"key",dts:o,pts:l,cts:i,data:c}}};parseVideo=async t=>{const s=new DataView(t.buffer);let e=0,n,a;{const o=s.getUint8(e)===0&&s.getUint8(e+1)===0&&s.getUint8(e+2)===1;if(e+=3,!o)throw new Error("invalid ts video payload.");const l=s.getUint8(e);e+=1;const i=s.getUint8(e)<<8|s.getUint8(e+1);e+=2;let c,r,g,p,h;{const f=s.getUint8(e);e+=1,c=f>>4&3,r=(f>>3&1)===1,g=(f>>2&1)===1,p=(f>>1&1)===1,h=(f&1)===1}let d,u;{const f=s.getUint8(e);e+=1;const U=f>>6,_=s.getUint8(e);e+=1,(U&2)===2&&(d=this.parsePtsDts(s,e)),(U&1)===1?u=this.parsePtsDts(s,e+5):u=d,e+=_}n={stream_id:l,pes_packet_length:i,scrambling_control:c,priority:r,data_alignment:g,copyright:p,original_copy:h,pts:d,dts:u}}a=t.slice(e);{const o=this.getNalus(a);if(!this.videoConfig){let h,d;if(h=o.find(f=>f.type===7)?.nalu.slice(4),d=o.find(f=>f.type===8)?.nalu.slice(4),h&&d){const u=I(h,d),{codec:f}=T(u);this.videoConfig={kind:"video",codec:f,description:u,sps:h,pps:d},this.on.config&&this.on.config(this.videoConfig)}}const l=[];let i="delta";for(const h of o){const{type:d,nalu:u}=h;switch(d){case 6:case 9:l.push(u);break;case 1:i="delta",l.push(u);break;case 5:i="key",l.push(u);break}}const c=C(l),{dts:r=0,pts:g=0}=n,p=g-r;return{kind:"video",type:i,dts:r,pts:g,cts:p,data:c,nalus:l}}};parsePtsDts(t,s){const e=t.getUint8(s),n=t.getUint8(s+1),a=t.getUint8(s+2),o=t.getUint8(s+3),l=t.getUint8(s+4),i=(BigInt(e)&0b00001110n)<<29n|(BigInt(n)&0b11111111n)<<22n|(BigInt(a)&0b11111110n)<<14n|(BigInt(o)&0b11111111n)<<7n|(BigInt(l)&0b11111110n)>>1n;return Number(i)/90}getNalus=t=>{const s=[];let e=0;for(;!(e+4>t.byteLength);){if(t[e]!==0||t[e+1]!==0||t[e+2]!==1){e+=1;continue}e+=3;let n=e;const a=t[e]&31;for(e+=1;!(e+1>t.byteLength);){if(t[e]!==0||t[e+1]!==0||t[e+2]!==1){e+=1;continue}break}let o=e-n;if(t[e-1]===0&&(o-=1),o!==0){const l=t.slice(n,n+o),i=M(l);s.push({type:a,nalu:i})}}return s}}const k=(y,t)=>y.getUint8(t)<<16|y.getUint8(t+1)<<8|y.getUint8(t+2);class L{audioConfig;videoConfig;header;textDecoder=new TextDecoder("utf-8");on={};constructor(){}parse=async t=>{let s=0;for(this.header||(this.parseHeader(t,s),s+=9);this.isSurplusTag(t,s)!==!1;){const n=this.parseTagHeader(t,s+4),{tagType:a,dataSize:o,timestamp:l}=n;if(a){const i=this.parseTagBody(a,t,s+4+11,o);switch(a){case"script":this.on.info&&this.on.info(i);break;case"audio":{const{accPacketType:c}=i;if(c===0){const{codec:r,sampleRate:g,channelConfiguration:p}=i;this.audioConfig={kind:"audio",codec:r,sampleRate:g,numberOfChannels:p},this.on.config&&this.on.config(this.audioConfig)}else{const{cts:r,data:g}=i,p="key",h=r===void 0?void 0:r+l;this.on.chunk&&this.on.chunk({kind:"audio",type:p,dts:l,pts:h,cts:r,data:g})}}break;case"video":{const{avcPacketType:c}=i;if(c===0){const{codec:r,sps:g,pps:p,data:h}=i;this.videoConfig={kind:"video",codec:r,description:h,sps:g,pps:p},this.on.config&&this.on.config(this.videoConfig)}else{const{frameType:r,cts:g,data:p,nalus:h}=i,d=r===1?"key":"delta",u=g===void 0?void 0:g+l;this.on.chunk&&this.on.chunk({kind:"video",type:d,dts:l,pts:u,cts:g,data:p,nalus:h})}}break}s=s+4+11+o}await new Promise(i=>setTimeout(()=>i(!0),8))}return s};parseHeader=(t,s)=>{let e,n,a,o;e=t.getUint8(s)<<16|t.getUint8(s+1)<<8|t.getUint8(s+2),n=t.getUint8(3);{const i=t.getUint8(0).toString(2).padStart(5,"0").split(""),[,,c,,r]=i;a={audio:r==="1",video:c==="1"}}o=t.getUint32(5),this.header={signature:e,version:n,flags:a,dataOffset:o}};isSurplusTag=(t,s)=>{let e=!0;const n=t.byteLength;if(s+4>n)e=!1;else if(s+4+11>n)e=!1;else{const a=k(t,s+4+1);s+4+11+a>n&&(e=!1)}return e};parseTagHeader=(t,s)=>{let e,n,a,o,l;{const i=t.getUint8(s);let c;switch(i){case 18:c="script";break;case 8:c="audio";break;case 9:c="video";break}e=c}return n=k(t,s+1),a=k(t,s+4),o=t.getUint8(s+7),l=k(t,s+8),{tagType:e,dataSize:n,timestamp:a,timestampExtended:o,streamID:l}};parseTagBody=(t,s,e,n)=>{let a;switch(t){case"script":a=this.parseMetaData(s,e);break;case"audio":a=this.parseAudio(s,e,n);break;case"video":a=this.parseVideo(s,e,n);break}return a};parseMetaData=(t,s)=>{let e=s;{if(t.getUint8(e)!==2)throw new Error("Invalid AMF type for onMetaData (expected 0x02)");e=e+1}const n=t.getUint16(e,!1);e=e+2;{const l=new Int8Array(t.buffer.slice(e,e+n));if((this.textDecoder?.decode(l)||"")!=="onMetaData")throw new Error("Expected \'onMetaData\' string");e=e+n}const a=this.getAmfType(t,e);return e=e+1,this.getAMFValue(t,e,a).value};parseAudio=(t,s,e)=>{let n=s;const a=t.getUint8(n),o=a>>4&15,l=a>>2&3,i=a>>1&1,c=a&1;n=n+1;const r=t.getUint8(n);n=n+1;const g=e,p=new Uint8Array(t.buffer.slice(n,n+g));if(o===10&&r===0){const h=t.getUint8(n),d=t.getUint8(n+1),u=h>>3&31,f=(h&7)<<1|d>>7,U=d>>3&15,_=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350],b=`mp4a.40.${u}`,m=_[f];return{soundFormat:o,soundRate:l,soundSize:i,soundType:c,accPacketType:r,data:p,samplingFrequencyIndex:f,channelConfiguration:U,codec:b,sampleRate:m}}return{soundFormat:o,soundRate:l,soundSize:i,soundType:c,accPacketType:r,data:p}};parseVideo=(t,s,e)=>{let n=s;const a=t.getUint8(n),o=a>>4&15,l=a&15;n=n+1;const i=t.getUint8(n);n=n+1;const c=k(t,n);n=n+3;const r=e-5,g=new Uint8Array(t.buffer.slice(n,n+r));switch(l){case 7:if(i===0){const p=T(g);return{frameType:o,codecID:l,avcPacketType:i,cts:c,data:g,...p}}else if(i===1){const p=[],h=n+e-5;for(;!(n+4>h);){const d=t.getUint32(n,!1),u=new Uint8Array(t.buffer.slice(n,n+4+d));n+=4+d,p.push(u)}return{frameType:o,codecID:l,avcPacketType:i,cts:c,data:g,nalus:p}}break;default:throw new Error("Unsupported codecID")}return{frameType:o,codecID:l,avcPacketType:i,cts:c,data:g}};getAmfType=(t,s)=>t.getUint8(s);getAMFName=(t,s,e)=>{const n=new Uint8Array(t.buffer.slice(s,s+e));return this.textDecoder?.decode(n)||""};getAMFValue=(t,s,e)=>{let n=s,a,o=0;switch(e){case 0:a=t.getFloat64(n,!1),o=8;break;case 1:a=!!t.getUint8(n),o=1;break;case 2:{a="";const i=t.getUint16(n,!1);n=n+2;const c=new Int8Array(t.buffer,n,i).filter(g=>g!==0);a=(this.textDecoder?.decode(c)||"").trim(),o=2+i}break;case 3:for(a={};n<t.byteLength;){const i=t.getUint16(n,!1);if(i===0)break;n=n+2;const c=this.getAMFName(t,n,i);n=n+i;const r=this.getAmfType(t,n);if(r===6)break;n=n+1;const g=this.getAMFValue(t,n,r);n=n+g.length,a[c]=g.value,o=2+i+1+g.length}break;case 8:{a={};const i=t.getUint32(n,!1);n=n+4;for(let c=0;c<i;c++){const r=t.getUint16(n,!1);n=n+2;const g=this.getAMFName(t,n,r);n=n+r;const p=this.getAmfType(t,n);n=n+1;const h=this.getAMFValue(t,n,p);n=n+h.length,a[g]=h.value,o=2+r+1+h.length}}break;case 10:{a=[];const i=t.getUint32(n,!1);n=n+4;for(let c=0;c<i;c++){const r=this.getAmfType(t,n);n=n+1;const g=this.getAMFValue(t,n,r);n=n+g.length,a.push(g.value),o=1+g.length}}break}return{amfType:e,length:o,value:a}}}class O{pattern;cacher=new P;isParseing=!1;offset=0;parser;on={};constructor(){}init=t=>{switch(this.destroy(),this.pattern=t,this.pattern){case"flv":this.parser=new L;break;case"hls":this.parser=new x;break;default:throw new Error("is error pattern.")}this.parser.on.debug=s=>this.on.debug&&this.on.debug(s),this.parser.on.info=s=>this.on.info&&this.on.info(s),this.parser.on.config=s=>this.on.config&&this.on.config(s),this.parser.on.chunk=s=>{this.cacher.pushChunk(s),this.on.chunk&&this.on.chunk(s)}};push=t=>{this.cacher.push(t),this.isParseing===!1&&this.parse()};destroy=()=>{this.cacher.destroy(),this.isParseing=!1,this.offset=0};parse=async()=>{try{if(this.isParseing=!0,!this.pattern)throw new Error("You need to set the pattern.");if(!this.parser)throw new Error("You need to init parser.");for(;;){const t=this.cacher.next(this.offset);if(this.offset=0,!t)break;this.offset=await this.parser.parse(t)}this.isParseing=!1}catch{this.destroy()}}}const A=new O;A.on.info=y=>postMessage({action:"on.info",data:y}),A.on.config=y=>postMessage({action:"on.config",data:y}),A.on.chunk=y=>postMessage({action:"on.chunk",data:y}),A.on.debug=y=>postMessage({action:"on.debug",data:y}),onmessage=y=>{const{action:t,data:s}=y.data,e=A[t];e&&e(s)}})();\n',_=typeof self<"u"&&self.Blob&&new Blob(["(self.URL || self.webkitURL).revokeObjectURL(self.location.href);",D],{type:"text/javascript;charset=utf-8"});function L(h){let r;try{if(r=_&&(self.URL||self.webkitURL).createObjectURL(_),!r)throw"";const u=new Worker(r,{name:h==null?void 0:h.name});return u.addEventListener("error",()=>{(self.URL||self.webkitURL).revokeObjectURL(r)}),u}catch{return new Worker("data:text/javascript;charset=utf-8,"+encodeURIComponent(D),{name:h==null?void 0:h.name})}}class V{constructor(){m(this,"worker",new L);m(this,"on",{});m(this,"init",r=>this.worker.postMessage({action:"init",data:r}));m(this,"push",r=>this.worker.postMessage({action:"push",data:r}));m(this,"destroy",()=>{this.worker.postMessage({action:"destroy",data:{}}),this.worker.terminate()});this.worker.onmessage=r=>{const{action:u,data:a}=r.data;switch(u){case"on.info":this.on.info&&this.on.info(a);break;case"on.config":this.on.config&&this.on.config(a);break;case"on.chunk":this.on.chunk&&this.on.chunk(a);break;case"on.debug":this.on.debug&&this.on.debug(a);break}}}}const S=`(function(){"use strict";class r{pattern="flv";audioDecoderConfig;audioDecoder;videoDecoderConfig;videoDecoder;hasKeyFrame=!1;baseTime=0;pendingChunks=[];currentChunk;isProcessing=!1;decodeTimer=0;frameTrack=!1;isFrameTrack=!1;fameTrackOption={flv:[30,50],hls:[200,300],dash:[50,100],rtmp:[50,100]};decodingSpeedRatio=1;maxDecodingSpeedRatio=2;decodingSpeed=16;fps=0;firstVideoChunkTimestamp;secondVideoChunkTimestamp;frameStartTime;lastRenderTime;nextRenderTime;on={audio:{},video:{}};constructor(){}init=e=>{this.destroy(),this.pattern=e,this.baseTime=new Date().getTime()-performance.now(),this.initDecodeInterval()};initAudio=e=>{this.audio.destroy(),this.audioDecoderConfig={...e},this.audioDecoder=new AudioDecoder({output:i=>{const o=this.decodingSpeedRatio;this.on.audio.decode&&this.on.audio.decode({audioData:i,playbackRate:o})},error:i=>{this.on.audio.error&&this.on.audio.error(i)}}),this.audioDecoder.configure(this.audioDecoderConfig)};initVideo=e=>{this.video.destroy(),this.videoDecoderConfig={...e},this.videoDecoder=new VideoDecoder({output:async i=>{this.frameStartTime||(this.frameStartTime=i.timestamp);const o=i.timestamp-this.frameStartTime+this.baseTime*1e3,s=await createImageBitmap(i);i.close(),s.width>0&&s.height>0?(this.on.video.decode&&this.on.video.decode({timestamp:o,bitmap:s}),this.currentChunk&&this.currentChunk.kind==="video"&&this.currentChunk.nalus&&this.on.nalus&&this.on.nalus(this.currentChunk.nalus)):s.close()},error:i=>{this.on.video.error&&this.on.video.error(i)}}),this.videoDecoder.configure(this.videoDecoderConfig)};setFrameTrack=e=>{this.frameTrack=e,this.frameTrack===!1&&(this.decodingSpeedRatio=1)};push=e=>{this.pendingChunks.push(e)};destroy=()=>{this.audio.destroy(),this.video.destroy(),this.pendingChunks=[],this.firstVideoChunkTimestamp=void 0,this.secondVideoChunkTimestamp=void 0,this.frameStartTime=void 0,this.lastRenderTime=void 0,this.nextRenderTime=void 0,clearInterval(this.decodeTimer)};initDecodeInterval=()=>{let e=this.decodingSpeed/this.decodingSpeedRatio;const i=this.baseTime+performance.now();if(this.lastRenderTime||(this.lastRenderTime=i),this.fps=Math.round(1e3/(i-this.lastRenderTime)),this.lastRenderTime=i,this.nextRenderTime){const o=this.lastRenderTime-this.nextRenderTime;e-=o}this.nextRenderTime=this.lastRenderTime+e,this.decodeTimer=setTimeout(()=>{this.decode(),this.initDecodeInterval()},e)};decode=()=>{if(this.isProcessing!==!0){for(this.isProcessing=!0;;){this.currentChunk=this.pendingChunks.shift();const e=this.pendingChunks.length;if(this.frameTrack){const[s,n]=this.fameTrackOption[this.pattern];if(e<=s&&(this.isFrameTrack=!1),e>=n&&(this.isFrameTrack=!0),this.isFrameTrack){const a=Math.min(1+(e-s)/100,this.maxDecodingSpeedRatio);this.decodingSpeedRatio=Number(a.toFixed(1))}else this.decodingSpeedRatio=1}if(this.on.analysis){const{decodingSpeed:s,decodingSpeedRatio:n,fps:a}=this;this.on.analysis({decodingSpeed:s,decodingSpeedRatio:n,fps:a,cacheLength:e})}if(!this.currentChunk)break;const{kind:i,init:o}=this.currentChunk;switch(i){case"audio":this.decodeAudio(o);break;case"video":this.decodeVideo(o);break}if(i==="video")break}this.isProcessing=!1}};decodeAudio=e=>{if(!this.audioDecoder)return;const i=new EncodedAudioChunk(e);this.audioDecoder.decode(i)};decodeVideo=e=>{if(this.videoDecoder&&(e.type==="key"&&(this.hasKeyFrame=!0),this.firstVideoChunkTimestamp?this.secondVideoChunkTimestamp||(this.secondVideoChunkTimestamp=e.timestamp,this.decodingSpeed=(this.secondVideoChunkTimestamp-this.firstVideoChunkTimestamp)/1e3):this.firstVideoChunkTimestamp=e.timestamp,this.hasKeyFrame)){const i=new EncodedVideoChunk(e);this.videoDecoder.decode(i)}};audio={flush:()=>{this.audioDecoder?.flush()},destroy:()=>{this.audioDecoderConfig=void 0,this.audioDecoder?.close(),this.audioDecoder=void 0}};video={flush:()=>{this.videoDecoder?.flush()},destroy:()=>{this.videoDecoderConfig=void 0,this.videoDecoder?.close(),this.videoDecoder=void 0,this.hasKeyFrame=!1}}}const d=new r;d.on.audio.decode=t=>postMessage({action:"on.audio.decode",data:t}),d.on.audio.error=t=>postMessage({action:"on.audio.error",data:t}),d.on.video.decode=t=>postMessage({action:"on.video.decode",data:t}),d.on.video.error=t=>postMessage({action:"on.video.error",data:t}),d.on.nalus=t=>postMessage({action:"on.nalus",data:t}),d.on.analysis=t=>postMessage({action:"on.analysis",data:t}),onmessage=t=>{const{action:e,data:i}=t.data,o=d[e];o&&o(i)}})();
|
|
2
|
+
`,C=typeof self<"u"&&self.Blob&&new Blob(["(self.URL || self.webkitURL).revokeObjectURL(self.location.href);",S],{type:"text/javascript;charset=utf-8"});function F(h){let r;try{if(r=C&&(self.URL||self.webkitURL).createObjectURL(C),!r)throw"";const u=new Worker(r,{name:h==null?void 0:h.name});return u.addEventListener("error",()=>{(self.URL||self.webkitURL).revokeObjectURL(r)}),u}catch{return new Worker("data:text/javascript;charset=utf-8,"+encodeURIComponent(S),{name:h==null?void 0:h.name})}}class N{constructor(){m(this,"worker",new F);m(this,"on",{audio:{},video:{}});m(this,"init",r=>this.worker.postMessage({action:"init",data:r}));m(this,"initAudio",r=>this.worker.postMessage({action:"initAudio",data:r}));m(this,"initVideo",r=>this.worker.postMessage({action:"initVideo",data:r}));m(this,"push",r=>this.worker.postMessage({action:"push",data:r}));m(this,"setFrameTrack",r=>this.worker.postMessage({action:"setFrameTrack",data:r}));m(this,"destroy",()=>{this.worker.postMessage({action:"destroy"}),this.worker.terminate()});this.worker.onmessage=r=>{const{action:u,data:a}=r.data;switch(u){case"on.audio.decode":this.on.audio.decode&&this.on.audio.decode(a);break;case"on.audio.error":this.on.audio.error&&this.on.audio.error(a);break;case"on.video.decode":this.on.video.decode&&this.on.video.decode(a);break;case"on.video.error":this.on.video.error&&this.on.video.error(a);break;case"on.nalus":this.on.nalus&&this.on.nalus(a);break;case"on.analysis":this.on.analysis&&this.on.analysis(a);break}}}}var B=Object.defineProperty,G=(h,r,u)=>r in h?B(h,r,{enumerable:!0,configurable:!0,writable:!0,value:u}):h[r]=u,y=(h,r,u)=>G(h,typeof r!="symbol"?r+"":r,u);class O{constructor(r,u){y(this,"inputStream",new MediaStream),y(this,"outputStream",new MediaStream),y(this,"inputGain",1),y(this,"enhanceGain",1),y(this,"bgsGain",1),y(this,"bgmGain",1),y(this,"outputGain",1),y(this,"mixAudioMap",new Map),y(this,"audioContext",new AudioContext),y(this,"sourceNode"),y(this,"inputGainNode"),y(this,"enhanceGainNode"),y(this,"bgsGainNode"),y(this,"bgmGainNode"),y(this,"analyserNode"),y(this,"analyserArrayData"),y(this,"outputGainNode"),y(this,"destinationNode"),y(this,"filterStream",a=>a),y(this,"stop",()=>{{const a=this.inputStream.getTracks();for(const n of a)n.stop(),this.inputStream.removeTrack(n)}}),y(this,"getStream",()=>this.filterStream(this.outputStream)),y(this,"setMute",(a=!0)=>{a?this.analyserNode.disconnect(this.outputGainNode):this.analyserNode.connect(this.outputGainNode)}),y(this,"setInputGain",a=>{this.inputGain=a,this.inputGainNode.gain.setValueAtTime(a,this.audioContext.currentTime)}),y(this,"setEnhanceGain",async a=>{this.enhanceGain=a+1,this.enhanceGainNode.gain.setValueAtTime(this.enhanceGain,this.audioContext.currentTime)}),y(this,"setBgsGain",a=>{this.bgsGain=a,this.bgsGainNode.gain.setValueAtTime(a,this.audioContext.currentTime)}),y(this,"setBgmGain",a=>{this.bgmGain=a,this.bgmGainNode.gain.setValueAtTime(a,this.audioContext.currentTime)}),y(this,"setOutputGain",a=>{this.outputGain=a,this.outputGainNode.gain.setValueAtTime(this.outputGain,this.audioContext.currentTime)}),y(this,"getVolume",()=>{const{analyserNode:a,analyserArrayData:n}=this;a.getByteFrequencyData(n);let o=0;for(let i=0;i<n.length;i++)o+=n[i];return Math.ceil(o/n.length)}),y(this,"mixAudio",(a,n="bgm")=>new Promise(async(o,i)=>{try{{const s=this.mixAudioMap.get(n);s&&s.stop()}const t=n==="bgs"?this.bgsGainNode:this.bgmGainNode,e=this.audioContext.createBufferSource();this.mixAudioMap.set(n,e),e.buffer=a,e.connect(t),e.onended=()=>{e.disconnect(t),this.mixAudioMap.delete(n),o(!0)},e.start(0)}catch(t){i(t)}})),y(this,"mixAudioStop",a=>{const n=this.mixAudioMap.get(a);n==null||n.stop()}),y(this,"changeMix",(a,n)=>{const o=a==="bgs"?this.bgsGainNode:this.bgmGainNode;n?o.connect(this.destinationNode):o.disconnect(this.destinationNode)}),u&&(this.audioContext=u),this.inputStream=r,this.sourceNode=this.audioContext.createMediaStreamSource(this.inputStream),this.inputGainNode=this.audioContext.createGain(),this.inputGainNode.gain.setValueAtTime(this.inputGain,this.audioContext.currentTime),this.enhanceGainNode=this.audioContext.createGain(),this.enhanceGainNode.gain.setValueAtTime(this.enhanceGain,this.audioContext.currentTime),this.bgsGainNode=this.audioContext.createGain(),this.bgsGainNode.gain.setValueAtTime(this.bgsGain,this.audioContext.currentTime),this.bgmGainNode=this.audioContext.createGain(),this.bgmGainNode.gain.setValueAtTime(this.bgmGain,this.audioContext.currentTime),this.analyserNode=this.audioContext.createAnalyser(),this.analyserNode.fftSize=512,this.analyserArrayData=new Uint8Array(this.analyserNode.frequencyBinCount),this.outputGainNode=this.audioContext.createGain(),this.outputGainNode.gain.setValueAtTime(this.outputGain,this.audioContext.currentTime),this.destinationNode=this.audioContext.createMediaStreamDestination(),this.outputStream=this.destinationNode.stream;{const{sourceNode:a,inputGainNode:n,enhanceGainNode:o,bgsGainNode:i,bgmGainNode:t,analyserNode:e,outputGainNode:s,destinationNode:l}=this;a.connect(n),n.connect(o),o.connect(e),i.connect(e),t.connect(e),o.connect(l),i.connect(l),t.connect(l),e.connect(s),s.connect(this.audioContext.destination)}this.setMute(!0),this.audioContext.resume()}}const E=async(h,r)=>{try{const{format:u,numberOfChannels:a,numberOfFrames:n,sampleRate:o}=r,i=h.createBuffer(a,n,o);for(let t=0;t<a;t++){const e=r.allocationSize({planeIndex:t}),s=new Uint8Array(e);r.copyTo(s,{planeIndex:t});const l=new DataView(s.buffer),c=i.getChannelData(t);for(let d=0;d<n;d++){let p;switch(u){case"s16":case"s16-planar":p=l.getInt16(d*2,!0)/32768;break;case"f32":case"f32-planar":p=l.getFloat32(d*4,!0);break;case"u8":case"u8-planar":p=(l.getUint8(d)-128)/128;break;default:throw new Error(`Unsupported audio format: ${u}`)}c[d]=Math.max(-1,Math.min(1,p))}}return i}catch(u){throw console.error("Failed to convert AudioData to AudioBuffer:",u),u}};class W{constructor(){m(this,"prAudioStream");m(this,"audioContext");m(this,"destination");m(this,"stream",new MediaStream);m(this,"nextStartTime",0);m(this,"pendingSources",[]);m(this,"init",r=>{r||(r=new(window.AudioContext||window.webkitAudioContext)),this.audioContext=r,this.destination=this.audioContext.createMediaStreamDestination(),this.stream=new MediaStream,this.stream.addTrack(this.destination.stream.getAudioTracks()[0]),this.prAudioStream=new O(this.stream,this.audioContext),this.nextStartTime=0,this.pendingSources=[]});m(this,"getStream",()=>{var r;return(r=this.prAudioStream)==null?void 0:r.getStream()})}async push(r){const{audioData:u,playbackRate:a=1}=r;try{if(!this.audioContext||!this.destination)return;let n=await E(this.audioContext,u);if(!n)return;const o=this.audioContext.createBufferSource();o.buffer=n,o.playbackRate.value=a;const i=-1200*Math.log2(a);o.detune.value=i,o.connect(this.destination);const t=Math.max(this.nextStartTime,this.audioContext.currentTime),e=n.duration/a;this.nextStartTime=t+e,o.start(t),this.pendingSources.push(o),o.onended=()=>{this.pendingSources=this.pendingSources.filter(s=>s!==o)},this.audioContext.state==="suspended"&&await this.audioContext.resume()}finally{u.close()}}destroy(){var r,u;(r=this.audioContext)==null||r.close(),this.audioContext=void 0,this.destination=void 0,this.nextStartTime=0,(u=this.prAudioStream)==null||u.stop(),this.pendingSources.forEach(a=>a.stop()),this.pendingSources=[]}}const R=`(function(){"use strict";class o{writable;writer;cutOption;pause=!1;constructor(){}init=({writable:t})=>{this.destroy(),this.writable=t,this.writer=this.writable.getWriter()};push=async t=>{if(this.pause)return;const{timestamp:s}=t;let{bitmap:i}=t;if(this.cutOption){const{sx:n=0,sy:c=0,sw:h=i.width,sh:u=i.height}=this.cutOption;i=await createImageBitmap(i,n,c,h,u)}const r=new VideoFrame(i,{timestamp:s});this.cutOption&&i.close(),this.writer.write(r),r.close()};setCut=t=>{this.cutOption=t};setPause=t=>{this.pause=t};destroy=()=>{this.writable=void 0,this.writer=void 0,this.cutOption=void 0}}const a=new o;onmessage=e=>{const{action:t,data:s}=e.data,i=a[t];i&&i(s)}})();
|
|
3
|
+
`,v=typeof self<"u"&&self.Blob&&new Blob(["(self.URL || self.webkitURL).revokeObjectURL(self.location.href);",R],{type:"text/javascript;charset=utf-8"});function j(h){let r;try{if(r=v&&(self.URL||self.webkitURL).createObjectURL(v),!r)throw"";const u=new Worker(r,{name:h==null?void 0:h.name});return u.addEventListener("error",()=>{(self.URL||self.webkitURL).revokeObjectURL(r)}),u}catch{return new Worker("data:text/javascript;charset=utf-8,"+encodeURIComponent(R),{name:h==null?void 0:h.name})}}class z{constructor(){m(this,"worker",new j);m(this,"init",({writable:r})=>this.worker.postMessage({action:"init",data:{writable:r}},[r]));m(this,"push",r=>this.worker.postMessage({action:"push",data:r}));m(this,"setCut",async r=>this.worker.postMessage({action:"setCut",data:r}));m(this,"setPause",r=>this.worker.postMessage({action:"setPause",data:r}));m(this,"destroy",()=>{this.worker.postMessage({action:"destroy",data:{}}),this.worker.terminate()})}}const q=h=>{const r=h.toLowerCase();return r.includes(".m3u8")||r.includes("hls")||r.includes("master.m3u8")||r.match(/index\d*\.m3u8/)?"hls":r.includes(".mpd")||r.includes("dash")?"dash":r.startsWith("rtmp://")||r.startsWith("rtmps://")?"rtmp":r.includes(".flv")||r.includes("flv")&&!r.includes("flash")?"flv":"unknown"},M=h=>{const r=(h==null?void 0:h.getTracks())||[];for(const u of r)u.stop()},A=()=>{const h=new MediaStreamTrackGenerator({kind:"video"}),r=new MediaStream([h]),u=new z;return u.init({writable:h.writable}),{worker:u,stream:r,destroy:()=>{u.destroy(),M(r)}}};class ${constructor(){m(this,"resolvesMap",new Map);m(this,"index",0);m(this,"add",(r,u=()=>!1,a=0)=>new Promise(n=>{var t,e;if(u())return n(!0);this.resolvesMap.has(r)||this.resolvesMap.set(r,new Map),this.index++;const o=`${this.index}`;if(a=Math.max(0,a),a===0){(t=this.resolvesMap.get(r))==null||t.set(o,{resolve:n,timer:0});return}const i=window.setTimeout(()=>{this.emit(r)},a);(e=this.resolvesMap.get(r))==null||e.set(o,{resolve:n,timer:i})}));m(this,"emit",async r=>{const u=this.resolvesMap.get(r);if(!u)return;const a=[...u.keys()];for(const n of a){const o=u.get(n);o&&(clearTimeout(o.timer),o.resolve(),u.delete(n))}})}}const Y=h=>{const r=new DataView(h.buffer);let u=0,a,n,o;a=r.getUint32(u,!1),u+=4;{const i=r.getUint8(u),t=i>>7&1,e=i>>5&3,s=i&31;n={forbidden_zero_bit:t,nal_ref_idc:e,nal_unit_type:s},u+=1}{const i=a-1;o=new Uint8Array(r.buffer.slice(u,u+i))}return{size:a,header:n,data:o}};class x{constructor(r={}){J(this,U,{timeout:5*1e3,check:!1});J(this,T);m(this,"check",(r,u)=>new Promise(async(a,n)=>{var i;this.stop(),H(this,T,new AbortController);const o=window.setTimeout(()=>{var t;(t=P(this,T))==null||t.abort("Timeout."),n({status:"timeout",reason:""})},P(this,U).timeout);try{const t=await fetch(r,{...u,method:"HEAD",signal:(i=P(this,T))==null?void 0:i.signal});t.status===200?a({status:"successed",reason:""}):n({status:"failed",reason:`${t.status}`})}catch(t){n({status:"error",reason:t.message})}clearTimeout(o)}));m(this,"request",async(r,u)=>new Promise(async(a,n)=>{var o;try{P(this,U).check&&await this.check(r,u),H(this,T,new AbortController);const i=await fetch(r,{...u,signal:(o=P(this,T))==null?void 0:o.signal});a(i)}catch(i){this.stop(),n(i)}}));m(this,"stop",()=>{var r;((r=P(this,T))==null?void 0:r.signal.aborted)===!1&&P(this,T).abort("Actively stop.")});H(this,U,{...P(this,U),...r})}}U=new WeakMap,T=new WeakMap;class et{constructor(r={}){m(this,"option",{debug:!1,frameTrack:!1});m(this,"prFetch",new x);m(this,"prResolves",new $);m(this,"url","");m(this,"demuxerWorker");m(this,"decoderWorker");m(this,"audioPlayer");m(this,"renderWorker");m(this,"stream");m(this,"on",{demuxer:{},decoder:{}});m(this,"cutRenders",new Map);m(this,"trackGenerator");m(this,"start",async r=>{this.stop(),this.url=r;const u=q(r);if(u==="unknown")throw new Error("This address cannot be parsed.");switch(this.init(u),u){case"flv":this.flv.start();break;case"hls":this.hls.start();break}});m(this,"stop",async()=>{var u,a,n,o,i;try{clearInterval(this.hls.getSegmentsTimer),this.prFetch.stop()}catch(t){console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m","color:#0097ff;","------->pr-player: error",t)}(u=this.demuxerWorker)==null||u.destroy(),(a=this.decoderWorker)==null||a.destroy(),(n=this.renderWorker)==null||n.destroy();const r=[...this.cutRenders.keys()];for(const t of r)(o=this.cutRenders.get(t))==null||o.worker.destroy(),this.cutRenders.delete(t);M(this.stream),(i=this.audioPlayer)==null||i.destroy()});m(this,"getStream",()=>this.stream);m(this,"setPause",r=>{var u;(u=this.renderWorker)==null||u.setPause(r)});m(this,"setMute",r=>{var u,a;return(a=(u=this.audioPlayer)==null?void 0:u.prAudioStream)==null?void 0:a.setMute(r)});m(this,"setFrameTrack",r=>{var u;this.option.frameTrack=r,(u=this.decoderWorker)==null||u.setFrameTrack(r)});m(this,"isReady",()=>{const r=()=>{var u;return((u=this.stream)==null?void 0:u.active)===!0};return this.prResolves.add("isReady",r)});m(this,"cut",{create:(r,u)=>{let a=this.cutRenders.get(r);return a?(a.worker.setCut(u),a.worker.setPause(!1),a):(a=A(),a.worker.setCut(u),this.cutRenders.set(r,a),a)},getStream:r=>{var u;return(u=this.cutRenders.get(r))==null?void 0:u.stream},setPause:(r,u)=>{var a;(a=this.cutRenders.get(r))==null||a.worker.setPause(u)},remove:r=>{var u;(u=this.cutRenders.get(r))==null||u.destroy(),this.cutRenders.delete(r)}});m(this,"init",r=>{this.initDecoder(r),this.initRender(),this.initDemuxer(r),this.audioPlayer=new W,this.audioPlayer.init()});m(this,"initDemuxer",r=>{this.demuxerWorker=new V,this.demuxerWorker.init(r),this.demuxerWorker.on.debug=u=>{this.option.debug&&this.on.debug&&this.on.debug(u)},this.demuxerWorker.on.info=u=>{this.option.debug&&console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m","color:#0097ff;","------->pr-player: info",u),this.on.demuxer.info&&this.on.demuxer.info(u)},this.demuxerWorker.on.config=u=>{var n,o;this.option.debug&&console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m","color:#0097ff;","------->pr-player: config",u),this.on.demuxer.config&&this.on.demuxer.config(u);const{kind:a}=u;switch(a){case"audio":{const{codec:i,sampleRate:t,numberOfChannels:e}=u;(n=this.decoderWorker)==null||n.initAudio({codec:i,sampleRate:t,numberOfChannels:e})}break;case"video":{const{codec:i,description:t}=u;(o=this.decoderWorker)==null||o.initVideo({codec:i,description:t})}break}},this.demuxerWorker.on.chunk=u=>{if(this.on.demuxer.chunk&&this.on.demuxer.chunk(u),!this.decoderWorker)return;const{kind:a}=u;switch(a){case"audio":{const{type:n,dts:o,data:i}=u,t=o*1e3;this.decoderWorker.push({kind:a,init:{type:n,timestamp:t,data:i}})}break;case"video":{const{type:n,dts:o,data:i,nalus:t=[]}=u,e=o*1e3;this.decoderWorker.push({kind:a,init:{type:n,timestamp:e,data:i},nalus:t})}break}}});m(this,"initDecoder",r=>{this.decoderWorker=new N,this.decoderWorker.init(r);const{frameTrack:u=!1}=this.option;this.decoderWorker.setFrameTrack(u),this.decoderWorker.on.audio.decode=a=>{var n;(n=this.audioPlayer)==null||n.push(a),this.on.decoder.audio&&this.on.decoder.audio(a)},this.decoderWorker.on.audio.error=a=>{this.option.debug&&console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m","color:#0097ff;","------->pr-player: audio.error ",a),this.on.error&&this.on.error(a)},this.decoderWorker.on.video.decode=async a=>{var o,i;(o=this.renderWorker)==null||o.push(a);const n=[...this.cutRenders.keys()];for(const t of n)(i=this.cutRenders.get(t))==null||i.worker.push(a);this.on.decoder.video&&this.on.decoder.video(a),a.bitmap.close()},this.decoderWorker.on.video.error=a=>{this.stop(),this.on.error&&this.on.error(a)},this.decoderWorker.on.nalus=async a=>{for(const n of a){if(n.byteLength<=4)continue;const{header:o,data:i}=Y(n),{nal_unit_type:t}=o;t===6&&this.on.decoder.sei&&this.on.decoder.sei(i)}},this.decoderWorker.on.analysis=a=>{this.on.decoder.analysis&&this.on.decoder.analysis(a)}});m(this,"initRender",()=>{const{worker:r,stream:u}=A();this.renderWorker=r,this.stream=u,this.renderWorker.setPause(!1)});m(this,"flv",{start:async()=>{var r,u;try{let a=await this.prFetch.request(this.url);if(a.status!==200&&(await new Promise(o=>setTimeout(()=>o(!0),500)),a=await this.prFetch.request(this.url)),a.status!==200&&(await new Promise(o=>setTimeout(()=>o(!0),500)),a=await this.prFetch.request(this.url)),a.status!==200)throw new Error("request is error.");const n=(r=a.body)==null?void 0:r.getReader();if(!n)throw new Error("reader is error.");for(;;){const{done:o,value:i}=await n.read();if(i&&((u=this.demuxerWorker)==null||u.push(i)),o)break}}catch(a){if((a==null?void 0:a.name)!=="AbortError")throw Error(a);this.on.error&&this.on.error(a)}}});m(this,"hls",{isLive:!1,urls:[],url:"",getSegmentsTimer:0,parse:async r=>{const u=new TextDecoder("utf-8").decode(r).split(`
|
|
4
|
+
`).map(e=>e.replace("\r","")),a=this.url.substring(0,this.url.lastIndexOf("/")+1);let n=4,o=0,i=!1;const t=[];for(const e of u)e.startsWith("#EXTINF:")?n=parseFloat(e.split(":")[1].split(",")[0]):e.startsWith("#EXT-X-TARGETDURATION:")?o=parseInt(e.split(":")[1]):e.startsWith("#EXT-X-ENDLIST")?i=!1:e.startsWith("#EXT-X-MEDIA-SEQUENCE:")?i=!0:e.includes(".ts")&&!e.startsWith("#")&&t.push({url:e.startsWith("http")?e:a+e,duration:n,isLive:i});return{baseUrl:a,targetDuration:o,isLive:i,segments:t}},getSegments:async()=>{var r;try{const u=new x;let a=await u.request(this.url);if(a.status!==200&&(await new Promise(o=>setTimeout(()=>o(!0),500)),a=await u.request(this.url)),a.status!==200&&(await new Promise(o=>setTimeout(()=>o(!0),500)),a=await u.request(this.url)),a.status!==200)throw new Error("request is error.");const n=(r=a.body)==null?void 0:r.getReader();if(!n)throw new Error("reader is error.");for(;;){const{done:o,value:i}=await n.read();if(i){const t=await this.hls.parse(i),{segments:e=[],isLive:s=!1}=t;this.hls.isLive=s,s===!1&&(this.option.frameTrack=!1);let l=Array.from(e,d=>d.url);const c=l.findIndex(d=>d===this.hls.url);c!==-1&&(l=l.slice(c+1)),this.hls.urls=l}if(o)break}}catch(u){this.on.error&&this.on.error(u)}},start:async()=>{var r,u,a;try{for(await this.hls.getSegments(),this.hls.getSegmentsTimer=window.setInterval(this.hls.getSegments,500),this.hls.isLive===!1&&(clearInterval(this.hls.getSegmentsTimer),(r=this.decoderWorker)==null?void 0:r.setFrameTrack(!1));;){const n=this.hls.urls.shift();if(n){this.hls.url=n;const o=(u=(await this.prFetch.request(n)).body)==null?void 0:u.getReader();if(!o)throw new Error("segment reader is error.");for(;;){const{done:i,value:t}=await o.read();if(t&&((a=this.demuxerWorker)==null||a.push(t)),i)break}}else await new Promise(o=>setTimeout(()=>o(!0),300))}}catch(n){if((n==null?void 0:n.name)!=="AbortError")throw Error(n)}}});const{debug:u=!1}=r;this.option.debug=u}}var commonjsGlobal=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},indexMinimal={},minimal$1={},aspromise,hasRequiredAspromise;function requireAspromise(){if(hasRequiredAspromise)return aspromise;hasRequiredAspromise=1,aspromise=h;function h(r,u){for(var a=new Array(arguments.length-1),n=0,o=2,i=!0;o<arguments.length;)a[n++]=arguments[o++];return new Promise(function(e,s){a[n]=function(c){if(i)if(i=!1,c)s(c);else{for(var d=new Array(arguments.length-1),p=0;p<d.length;)d[p++]=arguments[p];e.apply(null,d)}};try{r.apply(u||null,a)}catch(l){i&&(i=!1,s(l))}})}return aspromise}var base64={},hasRequiredBase64;function requireBase64(){return hasRequiredBase64||(hasRequiredBase64=1,function(h){var r=h;r.length=function(t){var e=t.length;if(!e)return 0;for(var s=0;--e%4>1&&t.charAt(e)==="=";)++s;return Math.ceil(t.length*3)/4-s};for(var u=new Array(64),a=new Array(123),n=0;n<64;)a[u[n]=n<26?n+65:n<52?n+71:n<62?n-4:n-59|43]=n++;r.encode=function(t,e,s){for(var l=null,c=[],d=0,p=0,f;e<s;){var w=t[e++];switch(p){case 0:c[d++]=u[w>>2],f=(w&3)<<4,p=1;break;case 1:c[d++]=u[f|w>>4],f=(w&15)<<2,p=2;break;case 2:c[d++]=u[f|w>>6],c[d++]=u[w&63],p=0;break}d>8191&&((l||(l=[])).push(String.fromCharCode.apply(String,c)),d=0)}return p&&(c[d++]=u[f],c[d++]=61,p===1&&(c[d++]=61)),l?(d&&l.push(String.fromCharCode.apply(String,c.slice(0,d))),l.join("")):String.fromCharCode.apply(String,c.slice(0,d))};var o="invalid encoding";r.decode=function(t,e,s){for(var l=s,c=0,d,p=0;p<t.length;){var f=t.charCodeAt(p++);if(f===61&&c>1)break;if((f=a[f])===void 0)throw Error(o);switch(c){case 0:d=f,c=1;break;case 1:e[s++]=d<<2|(f&48)>>4,d=f,c=2;break;case 2:e[s++]=(d&15)<<4|(f&60)>>2,d=f,c=3;break;case 3:e[s++]=(d&3)<<6|f,c=0;break}}if(c===1)throw Error(o);return s-l},r.test=function(t){return/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(t)}}(base64)),base64}var eventemitter,hasRequiredEventemitter;function requireEventemitter(){if(hasRequiredEventemitter)return eventemitter;hasRequiredEventemitter=1,eventemitter=h;function h(){this._listeners={}}return h.prototype.on=function(u,a,n){return(this._listeners[u]||(this._listeners[u]=[])).push({fn:a,ctx:n||this}),this},h.prototype.off=function(u,a){if(u===void 0)this._listeners={};else if(a===void 0)this._listeners[u]=[];else for(var n=this._listeners[u],o=0;o<n.length;)n[o].fn===a?n.splice(o,1):++o;return this},h.prototype.emit=function(u){var a=this._listeners[u];if(a){for(var n=[],o=1;o<arguments.length;)n.push(arguments[o++]);for(o=0;o<a.length;)a[o].fn.apply(a[o++].ctx,n)}return this},eventemitter}var float,hasRequiredFloat;function requireFloat(){if(hasRequiredFloat)return float;hasRequiredFloat=1,float=h(h);function h(o){return typeof Float32Array<"u"?function(){var i=new Float32Array([-0]),t=new Uint8Array(i.buffer),e=t[3]===128;function s(p,f,w){i[0]=p,f[w]=t[0],f[w+1]=t[1],f[w+2]=t[2],f[w+3]=t[3]}function l(p,f,w){i[0]=p,f[w]=t[3],f[w+1]=t[2],f[w+2]=t[1],f[w+3]=t[0]}o.writeFloatLE=e?s:l,o.writeFloatBE=e?l:s;function c(p,f){return t[0]=p[f],t[1]=p[f+1],t[2]=p[f+2],t[3]=p[f+3],i[0]}function d(p,f){return t[3]=p[f],t[2]=p[f+1],t[1]=p[f+2],t[0]=p[f+3],i[0]}o.readFloatLE=e?c:d,o.readFloatBE=e?d:c}():function(){function i(e,s,l,c){var d=s<0?1:0;if(d&&(s=-s),s===0)e(1/s>0?0:2147483648,l,c);else if(isNaN(s))e(2143289344,l,c);else if(s>34028234663852886e22)e((d<<31|2139095040)>>>0,l,c);else if(s<11754943508222875e-54)e((d<<31|Math.round(s/1401298464324817e-60))>>>0,l,c);else{var p=Math.floor(Math.log(s)/Math.LN2),f=Math.round(s*Math.pow(2,-p)*8388608)&8388607;e((d<<31|p+127<<23|f)>>>0,l,c)}}o.writeFloatLE=i.bind(null,r),o.writeFloatBE=i.bind(null,u);function t(e,s,l){var c=e(s,l),d=(c>>31)*2+1,p=c>>>23&255,f=c&8388607;return p===255?f?NaN:d*(1/0):p===0?d*1401298464324817e-60*f:d*Math.pow(2,p-150)*(f+8388608)}o.readFloatLE=t.bind(null,a),o.readFloatBE=t.bind(null,n)}(),typeof Float64Array<"u"?function(){var i=new Float64Array([-0]),t=new Uint8Array(i.buffer),e=t[7]===128;function s(p,f,w){i[0]=p,f[w]=t[0],f[w+1]=t[1],f[w+2]=t[2],f[w+3]=t[3],f[w+4]=t[4],f[w+5]=t[5],f[w+6]=t[6],f[w+7]=t[7]}function l(p,f,w){i[0]=p,f[w]=t[7],f[w+1]=t[6],f[w+2]=t[5],f[w+3]=t[4],f[w+4]=t[3],f[w+5]=t[2],f[w+6]=t[1],f[w+7]=t[0]}o.writeDoubleLE=e?s:l,o.writeDoubleBE=e?l:s;function c(p,f){return t[0]=p[f],t[1]=p[f+1],t[2]=p[f+2],t[3]=p[f+3],t[4]=p[f+4],t[5]=p[f+5],t[6]=p[f+6],t[7]=p[f+7],i[0]}function d(p,f){return t[7]=p[f],t[6]=p[f+1],t[5]=p[f+2],t[4]=p[f+3],t[3]=p[f+4],t[2]=p[f+5],t[1]=p[f+6],t[0]=p[f+7],i[0]}o.readDoubleLE=e?c:d,o.readDoubleBE=e?d:c}():function(){function i(e,s,l,c,d,p){var f=c<0?1:0;if(f&&(c=-c),c===0)e(0,d,p+s),e(1/c>0?0:2147483648,d,p+l);else if(isNaN(c))e(0,d,p+s),e(2146959360,d,p+l);else if(c>17976931348623157e292)e(0,d,p+s),e((f<<31|2146435072)>>>0,d,p+l);else{var w;if(c<22250738585072014e-324)w=c/5e-324,e(w>>>0,d,p+s),e((f<<31|w/4294967296)>>>0,d,p+l);else{var b=Math.floor(Math.log(c)/Math.LN2);b===1024&&(b=1023),w=c*Math.pow(2,-b),e(w*4503599627370496>>>0,d,p+s),e((f<<31|b+1023<<20|w*1048576&1048575)>>>0,d,p+l)}}}o.writeDoubleLE=i.bind(null,r,0,4),o.writeDoubleBE=i.bind(null,u,4,0);function t(e,s,l,c,d){var p=e(c,d+s),f=e(c,d+l),w=(f>>31)*2+1,b=f>>>20&2047,g=4294967296*(f&1048575)+p;return b===2047?g?NaN:w*(1/0):b===0?w*5e-324*g:w*Math.pow(2,b-1075)*(g+4503599627370496)}o.readDoubleLE=t.bind(null,a,0,4),o.readDoubleBE=t.bind(null,n,4,0)}(),o}function r(o,i,t){i[t]=o&255,i[t+1]=o>>>8&255,i[t+2]=o>>>16&255,i[t+3]=o>>>24}function u(o,i,t){i[t]=o>>>24,i[t+1]=o>>>16&255,i[t+2]=o>>>8&255,i[t+3]=o&255}function a(o,i){return(o[i]|o[i+1]<<8|o[i+2]<<16|o[i+3]<<24)>>>0}function n(o,i){return(o[i]<<24|o[i+1]<<16|o[i+2]<<8|o[i+3])>>>0}return float}var inquire_1,hasRequiredInquire;function requireInquire(){if(hasRequiredInquire)return inquire_1;hasRequiredInquire=1,inquire_1=inquire;function inquire(moduleName){try{var mod=eval("quire".replace(/^/,"re"))(moduleName);if(mod&&(mod.length||Object.keys(mod).length))return mod}catch(h){}return null}return inquire_1}var utf8={},hasRequiredUtf8;function requireUtf8(){return hasRequiredUtf8||(hasRequiredUtf8=1,function(h){var r=h;r.length=function(a){for(var n=0,o=0,i=0;i<a.length;++i)o=a.charCodeAt(i),o<128?n+=1:o<2048?n+=2:(o&64512)===55296&&(a.charCodeAt(i+1)&64512)===56320?(++i,n+=4):n+=3;return n},r.read=function(a,n,o){var i=o-n;if(i<1)return"";for(var t=null,e=[],s=0,l;n<o;)l=a[n++],l<128?e[s++]=l:l>191&&l<224?e[s++]=(l&31)<<6|a[n++]&63:l>239&&l<365?(l=((l&7)<<18|(a[n++]&63)<<12|(a[n++]&63)<<6|a[n++]&63)-65536,e[s++]=55296+(l>>10),e[s++]=56320+(l&1023)):e[s++]=(l&15)<<12|(a[n++]&63)<<6|a[n++]&63,s>8191&&((t||(t=[])).push(String.fromCharCode.apply(String,e)),s=0);return t?(s&&t.push(String.fromCharCode.apply(String,e.slice(0,s))),t.join("")):String.fromCharCode.apply(String,e.slice(0,s))},r.write=function(a,n,o){for(var i=o,t,e,s=0;s<a.length;++s)t=a.charCodeAt(s),t<128?n[o++]=t:t<2048?(n[o++]=t>>6|192,n[o++]=t&63|128):(t&64512)===55296&&((e=a.charCodeAt(s+1))&64512)===56320?(t=65536+((t&1023)<<10)+(e&1023),++s,n[o++]=t>>18|240,n[o++]=t>>12&63|128,n[o++]=t>>6&63|128,n[o++]=t&63|128):(n[o++]=t>>12|224,n[o++]=t>>6&63|128,n[o++]=t&63|128);return o-i}}(utf8)),utf8}var pool_1,hasRequiredPool;function requirePool(){if(hasRequiredPool)return pool_1;hasRequiredPool=1,pool_1=h;function h(r,u,a){var n=a||8192,o=n>>>1,i=null,t=n;return function(s){if(s<1||s>o)return r(s);t+s>n&&(i=r(n),t=0);var l=u.call(i,t,t+=s);return t&7&&(t=(t|7)+1),l}}return pool_1}var longbits,hasRequiredLongbits;function requireLongbits(){if(hasRequiredLongbits)return longbits;hasRequiredLongbits=1,longbits=r;var h=requireMinimal$1();function r(o,i){this.lo=o>>>0,this.hi=i>>>0}var u=r.zero=new r(0,0);u.toNumber=function(){return 0},u.zzEncode=u.zzDecode=function(){return this},u.length=function(){return 1};var a=r.zeroHash="\0\0\0\0\0\0\0\0";r.fromNumber=function(i){if(i===0)return u;var t=i<0;t&&(i=-i);var e=i>>>0,s=(i-e)/4294967296>>>0;return t&&(s=~s>>>0,e=~e>>>0,++e>4294967295&&(e=0,++s>4294967295&&(s=0))),new r(e,s)},r.from=function(i){if(typeof i=="number")return r.fromNumber(i);if(h.isString(i))if(h.Long)i=h.Long.fromString(i);else return r.fromNumber(parseInt(i,10));return i.low||i.high?new r(i.low>>>0,i.high>>>0):u},r.prototype.toNumber=function(i){if(!i&&this.hi>>>31){var t=~this.lo+1>>>0,e=~this.hi>>>0;return t||(e=e+1>>>0),-(t+e*4294967296)}return this.lo+this.hi*4294967296},r.prototype.toLong=function(i){return h.Long?new h.Long(this.lo|0,this.hi|0,!!i):{low:this.lo|0,high:this.hi|0,unsigned:!!i}};var n=String.prototype.charCodeAt;return r.fromHash=function(i){return i===a?u:new r((n.call(i,0)|n.call(i,1)<<8|n.call(i,2)<<16|n.call(i,3)<<24)>>>0,(n.call(i,4)|n.call(i,5)<<8|n.call(i,6)<<16|n.call(i,7)<<24)>>>0)},r.prototype.toHash=function(){return String.fromCharCode(this.lo&255,this.lo>>>8&255,this.lo>>>16&255,this.lo>>>24,this.hi&255,this.hi>>>8&255,this.hi>>>16&255,this.hi>>>24)},r.prototype.zzEncode=function(){var i=this.hi>>31;return this.hi=((this.hi<<1|this.lo>>>31)^i)>>>0,this.lo=(this.lo<<1^i)>>>0,this},r.prototype.zzDecode=function(){var i=-(this.lo&1);return this.lo=((this.lo>>>1|this.hi<<31)^i)>>>0,this.hi=(this.hi>>>1^i)>>>0,this},r.prototype.length=function(){var i=this.lo,t=(this.lo>>>28|this.hi<<4)>>>0,e=this.hi>>>24;return e===0?t===0?i<16384?i<128?1:2:i<2097152?3:4:t<16384?t<128?5:6:t<2097152?7:8:e<128?9:10},longbits}var hasRequiredMinimal$1;function requireMinimal$1(){return hasRequiredMinimal$1||(hasRequiredMinimal$1=1,function(h){var r=h;r.asPromise=requireAspromise(),r.base64=requireBase64(),r.EventEmitter=requireEventemitter(),r.float=requireFloat(),r.inquire=requireInquire(),r.utf8=requireUtf8(),r.pool=requirePool(),r.LongBits=requireLongbits(),r.isNode=!!(typeof commonjsGlobal<"u"&&commonjsGlobal&&commonjsGlobal.process&&commonjsGlobal.process.versions&&commonjsGlobal.process.versions.node),r.global=r.isNode&&commonjsGlobal||typeof window<"u"&&window||typeof self<"u"&&self||minimal$1,r.emptyArray=Object.freeze?Object.freeze([]):[],r.emptyObject=Object.freeze?Object.freeze({}):{},r.isInteger=Number.isInteger||function(o){return typeof o=="number"&&isFinite(o)&&Math.floor(o)===o},r.isString=function(o){return typeof o=="string"||o instanceof String},r.isObject=function(o){return o&&typeof o=="object"},r.isset=r.isSet=function(o,i){var t=o[i];return t!=null&&o.hasOwnProperty(i)?typeof t!="object"||(Array.isArray(t)?t.length:Object.keys(t).length)>0:!1},r.Buffer=function(){try{var n=r.inquire("buffer").Buffer;return n.prototype.utf8Write?n:null}catch{return null}}(),r._Buffer_from=null,r._Buffer_allocUnsafe=null,r.newBuffer=function(o){return typeof o=="number"?r.Buffer?r._Buffer_allocUnsafe(o):new r.Array(o):r.Buffer?r._Buffer_from(o):typeof Uint8Array>"u"?o:new Uint8Array(o)},r.Array=typeof Uint8Array<"u"?Uint8Array:Array,r.Long=r.global.dcodeIO&&r.global.dcodeIO.Long||r.global.Long||r.inquire("long"),r.key2Re=/^true|false|0|1$/,r.key32Re=/^-?(?:0|[1-9][0-9]*)$/,r.key64Re=/^(?:[\\x00-\\xff]{8}|-?(?:0|[1-9][0-9]*))$/,r.longToHash=function(o){return o?r.LongBits.from(o).toHash():r.LongBits.zeroHash},r.longFromHash=function(o,i){var t=r.LongBits.fromHash(o);return r.Long?r.Long.fromBits(t.lo,t.hi,i):t.toNumber(!!i)};function u(n,o,i){for(var t=Object.keys(o),e=0;e<t.length;++e)(n[t[e]]===void 0||!i)&&(n[t[e]]=o[t[e]]);return n}r.merge=u,r.lcFirst=function(o){return o.charAt(0).toLowerCase()+o.substring(1)};function a(n){function o(i,t){if(!(this instanceof o))return new o(i,t);Object.defineProperty(this,"message",{get:function(){return i}}),Error.captureStackTrace?Error.captureStackTrace(this,o):Object.defineProperty(this,"stack",{value:new Error().stack||""}),t&&u(this,t)}return o.prototype=Object.create(Error.prototype,{constructor:{value:o,writable:!0,enumerable:!1,configurable:!0},name:{get:function(){return n},set:void 0,enumerable:!1,configurable:!0},toString:{value:function(){return this.name+": "+this.message},writable:!0,enumerable:!1,configurable:!0}}),o}r.newError=a,r.ProtocolError=a("ProtocolError"),r.oneOfGetter=function(o){for(var i={},t=0;t<o.length;++t)i[o[t]]=1;return function(){for(var e=Object.keys(this),s=e.length-1;s>-1;--s)if(i[e[s]]===1&&this[e[s]]!==void 0&&this[e[s]]!==null)return e[s]}},r.oneOfSetter=function(o){return function(i){for(var t=0;t<o.length;++t)o[t]!==i&&delete this[o[t]]}},r.toJSONOptions={longs:String,enums:String,bytes:String,json:!0},r._configure=function(){var n=r.Buffer;if(!n){r._Buffer_from=r._Buffer_allocUnsafe=null;return}r._Buffer_from=n.from!==Uint8Array.from&&n.from||function(i,t){return new n(i,t)},r._Buffer_allocUnsafe=n.allocUnsafe||function(i){return new n(i)}}}(minimal$1)),minimal$1}var writer,hasRequiredWriter;function requireWriter(){if(hasRequiredWriter)return writer;hasRequiredWriter=1,writer=e;var h=requireMinimal$1(),r,u=h.LongBits,a=h.base64,n=h.utf8;function o(b,g,k){this.fn=b,this.len=g,this.next=void 0,this.val=k}function i(){}function t(b){this.head=b.head,this.tail=b.tail,this.len=b.len,this.next=b.states}function e(){this.len=0,this.head=new o(i,0,0),this.tail=this.head,this.states=null}var s=function(){return h.Buffer?function(){return(e.create=function(){return new r})()}:function(){return new e}};e.create=s(),e.alloc=function(g){return new h.Array(g)},h.Array!==Array&&(e.alloc=h.pool(e.alloc,h.Array.prototype.subarray)),e.prototype._push=function(g,k,I){return this.tail=this.tail.next=new o(g,k,I),this.len+=k,this};function l(b,g,k){g[k]=b&255}function c(b,g,k){for(;b>127;)g[k++]=b&127|128,b>>>=7;g[k]=b}function d(b,g){this.len=b,this.next=void 0,this.val=g}d.prototype=Object.create(o.prototype),d.prototype.fn=c,e.prototype.uint32=function(g){return this.len+=(this.tail=this.tail.next=new d((g=g>>>0)<128?1:g<16384?2:g<2097152?3:g<268435456?4:5,g)).len,this},e.prototype.int32=function(g){return g<0?this._push(p,10,u.fromNumber(g)):this.uint32(g)},e.prototype.sint32=function(g){return this.uint32((g<<1^g>>31)>>>0)};function p(b,g,k){for(;b.hi;)g[k++]=b.lo&127|128,b.lo=(b.lo>>>7|b.hi<<25)>>>0,b.hi>>>=7;for(;b.lo>127;)g[k++]=b.lo&127|128,b.lo=b.lo>>>7;g[k++]=b.lo}e.prototype.uint64=function(g){var k=u.from(g);return this._push(p,k.length(),k)},e.prototype.int64=e.prototype.uint64,e.prototype.sint64=function(g){var k=u.from(g).zzEncode();return this._push(p,k.length(),k)},e.prototype.bool=function(g){return this._push(l,1,g?1:0)};function f(b,g,k){g[k]=b&255,g[k+1]=b>>>8&255,g[k+2]=b>>>16&255,g[k+3]=b>>>24}e.prototype.fixed32=function(g){return this._push(f,4,g>>>0)},e.prototype.sfixed32=e.prototype.fixed32,e.prototype.fixed64=function(g){var k=u.from(g);return this._push(f,4,k.lo)._push(f,4,k.hi)},e.prototype.sfixed64=e.prototype.fixed64,e.prototype.float=function(g){return this._push(h.float.writeFloatLE,4,g)},e.prototype.double=function(g){return this._push(h.float.writeDoubleLE,8,g)};var w=h.Array.prototype.set?function(g,k,I){k.set(g,I)}:function(g,k,I){for(var K=0;K<g.length;++K)k[I+K]=g[K]};return e.prototype.bytes=function(g){var k=g.length>>>0;if(!k)return this._push(l,1,0);if(h.isString(g)){var I=e.alloc(k=a.length(g));a.decode(g,I,0),g=I}return this.uint32(k)._push(w,k,g)},e.prototype.string=function(g){var k=n.length(g);return k?this.uint32(k)._push(n.write,k,g):this._push(l,1,0)},e.prototype.fork=function(){return this.states=new t(this),this.head=this.tail=new o(i,0,0),this.len=0,this},e.prototype.reset=function(){return this.states?(this.head=this.states.head,this.tail=this.states.tail,this.len=this.states.len,this.states=this.states.next):(this.head=this.tail=new o(i,0,0),this.len=0),this},e.prototype.ldelim=function(){var g=this.head,k=this.tail,I=this.len;return this.reset().uint32(I),I&&(this.tail.next=g.next,this.tail=k,this.len+=I),this},e.prototype.finish=function(){for(var g=this.head.next,k=this.constructor.alloc(this.len),I=0;g;)g.fn(g.val,k,I),I+=g.len,g=g.next;return k},e._configure=function(b){r=b,e.create=s(),r._configure()},writer}var writer_buffer,hasRequiredWriter_buffer;function requireWriter_buffer(){if(hasRequiredWriter_buffer)return writer_buffer;hasRequiredWriter_buffer=1,writer_buffer=u;var h=requireWriter();(u.prototype=Object.create(h.prototype)).constructor=u;var r=requireMinimal$1();function u(){h.call(this)}u._configure=function(){u.alloc=r._Buffer_allocUnsafe,u.writeBytesBuffer=r.Buffer&&r.Buffer.prototype instanceof Uint8Array&&r.Buffer.prototype.set.name==="set"?function(o,i,t){i.set(o,t)}:function(o,i,t){if(o.copy)o.copy(i,t,0,o.length);else for(var e=0;e<o.length;)i[t++]=o[e++]}},u.prototype.bytes=function(o){r.isString(o)&&(o=r._Buffer_from(o,"base64"));var i=o.length>>>0;return this.uint32(i),i&&this._push(u.writeBytesBuffer,i,o),this};function a(n,o,i){n.length<40?r.utf8.write(n,o,i):o.utf8Write?o.utf8Write(n,i):o.write(n,i)}return u.prototype.string=function(o){var i=r.Buffer.byteLength(o);return this.uint32(i),i&&this._push(a,i,o),this},u._configure(),writer_buffer}var reader,hasRequiredReader;function requireReader(){if(hasRequiredReader)return reader;hasRequiredReader=1,reader=o;var h=requireMinimal$1(),r,u=h.LongBits,a=h.utf8;function n(c,d){return RangeError("index out of range: "+c.pos+" + "+(d||1)+" > "+c.len)}function o(c){this.buf=c,this.pos=0,this.len=c.length}var i=typeof Uint8Array<"u"?function(d){if(d instanceof Uint8Array||Array.isArray(d))return new o(d);throw Error("illegal buffer")}:function(d){if(Array.isArray(d))return new o(d);throw Error("illegal buffer")},t=function(){return h.Buffer?function(p){return(o.create=function(w){return h.Buffer.isBuffer(w)?new r(w):i(w)})(p)}:i};o.create=t(),o.prototype._slice=h.Array.prototype.subarray||h.Array.prototype.slice,o.prototype.uint32=function(){var d=4294967295;return function(){if(d=(this.buf[this.pos]&127)>>>0,this.buf[this.pos++]<128||(d=(d|(this.buf[this.pos]&127)<<7)>>>0,this.buf[this.pos++]<128)||(d=(d|(this.buf[this.pos]&127)<<14)>>>0,this.buf[this.pos++]<128)||(d=(d|(this.buf[this.pos]&127)<<21)>>>0,this.buf[this.pos++]<128)||(d=(d|(this.buf[this.pos]&15)<<28)>>>0,this.buf[this.pos++]<128))return d;if((this.pos+=5)>this.len)throw this.pos=this.len,n(this,10);return d}}(),o.prototype.int32=function(){return this.uint32()|0},o.prototype.sint32=function(){var d=this.uint32();return d>>>1^-(d&1)|0};function e(){var c=new u(0,0),d=0;if(this.len-this.pos>4){for(;d<4;++d)if(c.lo=(c.lo|(this.buf[this.pos]&127)<<d*7)>>>0,this.buf[this.pos++]<128)return c;if(c.lo=(c.lo|(this.buf[this.pos]&127)<<28)>>>0,c.hi=(c.hi|(this.buf[this.pos]&127)>>4)>>>0,this.buf[this.pos++]<128)return c;d=0}else{for(;d<3;++d){if(this.pos>=this.len)throw n(this);if(c.lo=(c.lo|(this.buf[this.pos]&127)<<d*7)>>>0,this.buf[this.pos++]<128)return c}return c.lo=(c.lo|(this.buf[this.pos++]&127)<<d*7)>>>0,c}if(this.len-this.pos>4){for(;d<5;++d)if(c.hi=(c.hi|(this.buf[this.pos]&127)<<d*7+3)>>>0,this.buf[this.pos++]<128)return c}else for(;d<5;++d){if(this.pos>=this.len)throw n(this);if(c.hi=(c.hi|(this.buf[this.pos]&127)<<d*7+3)>>>0,this.buf[this.pos++]<128)return c}throw Error("invalid varint encoding")}o.prototype.bool=function(){return this.uint32()!==0};function s(c,d){return(c[d-4]|c[d-3]<<8|c[d-2]<<16|c[d-1]<<24)>>>0}o.prototype.fixed32=function(){if(this.pos+4>this.len)throw n(this,4);return s(this.buf,this.pos+=4)},o.prototype.sfixed32=function(){if(this.pos+4>this.len)throw n(this,4);return s(this.buf,this.pos+=4)|0};function l(){if(this.pos+8>this.len)throw n(this,8);return new u(s(this.buf,this.pos+=4),s(this.buf,this.pos+=4))}return o.prototype.float=function(){if(this.pos+4>this.len)throw n(this,4);var d=h.float.readFloatLE(this.buf,this.pos);return this.pos+=4,d},o.prototype.double=function(){if(this.pos+8>this.len)throw n(this,4);var d=h.float.readDoubleLE(this.buf,this.pos);return this.pos+=8,d},o.prototype.bytes=function(){var d=this.uint32(),p=this.pos,f=this.pos+d;if(f>this.len)throw n(this,d);if(this.pos+=d,Array.isArray(this.buf))return this.buf.slice(p,f);if(p===f){var w=h.Buffer;return w?w.alloc(0):new this.buf.constructor(0)}return this._slice.call(this.buf,p,f)},o.prototype.string=function(){var d=this.bytes();return a.read(d,0,d.length)},o.prototype.skip=function(d){if(typeof d=="number"){if(this.pos+d>this.len)throw n(this,d);this.pos+=d}else do if(this.pos>=this.len)throw n(this);while(this.buf[this.pos++]&128);return this},o.prototype.skipType=function(c){switch(c){case 0:this.skip();break;case 1:this.skip(8);break;case 2:this.skip(this.uint32());break;case 3:for(;(c=this.uint32()&7)!==4;)this.skipType(c);break;case 5:this.skip(4);break;default:throw Error("invalid wire type "+c+" at offset "+this.pos)}return this},o._configure=function(c){r=c,o.create=t(),r._configure();var d=h.Long?"toLong":"toNumber";h.merge(o.prototype,{int64:function(){return e.call(this)[d](!1)},uint64:function(){return e.call(this)[d](!0)},sint64:function(){return e.call(this).zzDecode()[d](!1)},fixed64:function(){return l.call(this)[d](!0)},sfixed64:function(){return l.call(this)[d](!1)}})},reader}var reader_buffer,hasRequiredReader_buffer;function requireReader_buffer(){if(hasRequiredReader_buffer)return reader_buffer;hasRequiredReader_buffer=1,reader_buffer=u;var h=requireReader();(u.prototype=Object.create(h.prototype)).constructor=u;var r=requireMinimal$1();function u(a){h.call(this,a)}return u._configure=function(){r.Buffer&&(u.prototype._slice=r.Buffer.prototype.slice)},u.prototype.string=function(){var n=this.uint32();return this.buf.utf8Slice?this.buf.utf8Slice(this.pos,this.pos=Math.min(this.pos+n,this.len)):this.buf.toString("utf-8",this.pos,this.pos=Math.min(this.pos+n,this.len))},u._configure(),reader_buffer}var rpc={},service,hasRequiredService;function requireService(){if(hasRequiredService)return service;hasRequiredService=1,service=r;var h=requireMinimal$1();(r.prototype=Object.create(h.EventEmitter.prototype)).constructor=r;function r(u,a,n){if(typeof u!="function")throw TypeError("rpcImpl must be a function");h.EventEmitter.call(this),this.rpcImpl=u,this.requestDelimited=!!a,this.responseDelimited=!!n}return r.prototype.rpcCall=function u(a,n,o,i,t){if(!i)throw TypeError("request must be specified");var e=this;if(!t)return h.asPromise(u,e,a,n,o,i);if(!e.rpcImpl){setTimeout(function(){t(Error("already ended"))},0);return}try{return e.rpcImpl(a,n[e.requestDelimited?"encodeDelimited":"encode"](i).finish(),function(l,c){if(l)return e.emit("error",l,a),t(l);if(c===null){e.end(!0);return}if(!(c instanceof o))try{c=o[e.responseDelimited?"decodeDelimited":"decode"](c)}catch(d){return e.emit("error",d,a),t(d)}return e.emit("data",c,a),t(null,c)})}catch(s){e.emit("error",s,a),setTimeout(function(){t(s)},0);return}},r.prototype.end=function(a){return this.rpcImpl&&(a||this.rpcImpl(null,null,null),this.rpcImpl=null,this.emit("end").off()),this},service}var hasRequiredRpc;function requireRpc(){return hasRequiredRpc||(hasRequiredRpc=1,function(h){var r=h;r.Service=requireService()}(rpc)),rpc}var roots,hasRequiredRoots;function requireRoots(){return hasRequiredRoots||(hasRequiredRoots=1,roots={}),roots}var hasRequiredIndexMinimal;function requireIndexMinimal(){return hasRequiredIndexMinimal||(hasRequiredIndexMinimal=1,function(h){var r=h;r.build="minimal",r.Writer=requireWriter(),r.BufferWriter=requireWriter_buffer(),r.Reader=requireReader(),r.BufferReader=requireReader_buffer(),r.util=requireMinimal$1(),r.rpc=requireRpc(),r.roots=requireRoots(),r.configure=u;function u(){r.util._configure(),r.Writer._configure(r.BufferWriter),r.Reader._configure(r.BufferReader)}u()}(indexMinimal)),indexMinimal}var minimal,hasRequiredMinimal;function requireMinimal(){return hasRequiredMinimal||(hasRequiredMinimal=1,minimal=requireIndexMinimal()),minimal}var minimalExports=requireMinimal();const $Reader=minimalExports.Reader,$Writer=minimalExports.Writer,$util=minimalExports.util,$root=minimalExports.roots.default||(minimalExports.roots.default={}),com=$root.com=(()=>{const h={};return h.quick=function(){const r={};return r.voice=function(){const u={};return u.proto=function(){const a={};return a.SeiData=function(){function n(o){if(o)for(let i=Object.keys(o),t=0;t<i.length;++t)o[i[t]]!=null&&(this[i[t]]=o[i[t]])}return n.prototype.event=0,n.prototype.data=$util.newBuffer([]),n.prototype.compress=!1,n.prototype.version=0,n.create=function(i){return new n(i)},n.encode=function(i,t){return t||(t=$Writer.create()),i.event!=null&&Object.hasOwnProperty.call(i,"event")&&t.uint32(8).int32(i.event),i.data!=null&&Object.hasOwnProperty.call(i,"data")&&t.uint32(18).bytes(i.data),i.compress!=null&&Object.hasOwnProperty.call(i,"compress")&&t.uint32(24).bool(i.compress),i.version!=null&&Object.hasOwnProperty.call(i,"version")&&t.uint32(32).int32(i.version),t},n.encodeDelimited=function(i,t){return this.encode(i,t).ldelim()},n.decode=function(i,t,e){i instanceof $Reader||(i=$Reader.create(i));let s=t===void 0?i.len:i.pos+t,l=new $root.com.quick.voice.proto.SeiData;for(;i.pos<s;){let c=i.uint32();if(c===e)break;switch(c>>>3){case 1:{l.event=i.int32();break}case 2:{l.data=i.bytes();break}case 3:{l.compress=i.bool();break}case 4:{l.version=i.int32();break}default:i.skipType(c&7);break}}return l},n.decodeDelimited=function(i){return i instanceof $Reader||(i=new $Reader(i)),this.decode(i,i.uint32())},n.verify=function(i){if(typeof i!="object"||i===null)return"object expected";if(i.event!=null&&i.hasOwnProperty("event"))switch(i.event){default:return"event: enum value expected";case 0:case 1:break}return i.data!=null&&i.hasOwnProperty("data")&&!(i.data&&typeof i.data.length=="number"||$util.isString(i.data))?"data: buffer expected":i.compress!=null&&i.hasOwnProperty("compress")&&typeof i.compress!="boolean"?"compress: boolean expected":i.version!=null&&i.hasOwnProperty("version")&&!$util.isInteger(i.version)?"version: integer expected":null},n.fromObject=function(i){if(i instanceof $root.com.quick.voice.proto.SeiData)return i;let t=new $root.com.quick.voice.proto.SeiData;switch(i.event){default:if(typeof i.event=="number"){t.event=i.event;break}break;case"Layout":case 0:t.event=0;break;case"Custom":case 1:t.event=1;break}return i.data!=null&&(typeof i.data=="string"?$util.base64.decode(i.data,t.data=$util.newBuffer($util.base64.length(i.data)),0):i.data.length>=0&&(t.data=i.data)),i.compress!=null&&(t.compress=!!i.compress),i.version!=null&&(t.version=i.version|0),t},n.toObject=function(i,t){t||(t={});let e={};return t.defaults&&(e.event=t.enums===String?"Layout":0,t.bytes===String?e.data="":(e.data=[],t.bytes!==Array&&(e.data=$util.newBuffer(e.data))),e.compress=!1,e.version=0),i.event!=null&&i.hasOwnProperty("event")&&(e.event=t.enums===String?$root.com.quick.voice.proto.EventType[i.event]===void 0?i.event:$root.com.quick.voice.proto.EventType[i.event]:i.event),i.data!=null&&i.hasOwnProperty("data")&&(e.data=t.bytes===String?$util.base64.encode(i.data,0,i.data.length):t.bytes===Array?Array.prototype.slice.call(i.data):i.data),i.compress!=null&&i.hasOwnProperty("compress")&&(e.compress=i.compress),i.version!=null&&i.hasOwnProperty("version")&&(e.version=i.version),e},n.prototype.toJSON=function(){return this.constructor.toObject(this,minimalExports.util.toJSONOptions)},n.getTypeUrl=function(i){return i===void 0&&(i="type.googleapis.com"),i+"/com.quick.voice.proto.SeiData"},n}(),a.EventType=function(){const n={},o=Object.create(n);return o[n[0]="Layout"]=0,o[n[1]="Custom"]=1,o}(),a.LayoutData=function(){function n(i){if(this.userMap={},i)for(let t=Object.keys(i),e=0;e<t.length;++e)i[t[e]]!=null&&(this[t[e]]=i[t[e]])}n.prototype.roomId="",n.prototype.type=0,n.prototype.userMap=$util.emptyObject,n.prototype.globalCustom=null;let o;return Object.defineProperty(n.prototype,"_globalCustom",{get:$util.oneOfGetter(o=["globalCustom"]),set:$util.oneOfSetter(o)}),n.create=function(t){return new n(t)},n.encode=function(t,e){if(e||(e=$Writer.create()),t.roomId!=null&&Object.hasOwnProperty.call(t,"roomId")&&e.uint32(10).string(t.roomId),t.type!=null&&Object.hasOwnProperty.call(t,"type")&&e.uint32(16).int32(t.type),t.userMap!=null&&Object.hasOwnProperty.call(t,"userMap"))for(let s=Object.keys(t.userMap),l=0;l<s.length;++l)e.uint32(26).fork().uint32(10).string(s[l]),$root.com.quick.voice.proto.UserInfo.encode(t.userMap[s[l]],e.uint32(18).fork()).ldelim().ldelim();return t.globalCustom!=null&&Object.hasOwnProperty.call(t,"globalCustom")&&$root.com.quick.voice.proto.CustomInfo.encode(t.globalCustom,e.uint32(34).fork()).ldelim(),e},n.encodeDelimited=function(t,e){return this.encode(t,e).ldelim()},n.decode=function(t,e,s){t instanceof $Reader||(t=$Reader.create(t));let l=e===void 0?t.len:t.pos+e,c=new $root.com.quick.voice.proto.LayoutData,d,p;for(;t.pos<l;){let f=t.uint32();if(f===s)break;switch(f>>>3){case 1:{c.roomId=t.string();break}case 2:{c.type=t.int32();break}case 3:{c.userMap===$util.emptyObject&&(c.userMap={});let w=t.uint32()+t.pos;for(d="",p=null;t.pos<w;){let b=t.uint32();switch(b>>>3){case 1:d=t.string();break;case 2:p=$root.com.quick.voice.proto.UserInfo.decode(t,t.uint32());break;default:t.skipType(b&7);break}}c.userMap[d]=p;break}case 4:{c.globalCustom=$root.com.quick.voice.proto.CustomInfo.decode(t,t.uint32());break}default:t.skipType(f&7);break}}return c},n.decodeDelimited=function(t){return t instanceof $Reader||(t=new $Reader(t)),this.decode(t,t.uint32())},n.verify=function(t){if(typeof t!="object"||t===null)return"object expected";if(t.roomId!=null&&t.hasOwnProperty("roomId")&&!$util.isString(t.roomId))return"roomId: string expected";if(t.type!=null&&t.hasOwnProperty("type"))switch(t.type){default:return"type: enum value expected";case 0:case 1:case 2:break}if(t.userMap!=null&&t.hasOwnProperty("userMap")){if(!$util.isObject(t.userMap))return"userMap: object expected";let e=Object.keys(t.userMap);for(let s=0;s<e.length;++s){let l=$root.com.quick.voice.proto.UserInfo.verify(t.userMap[e[s]]);if(l)return"userMap."+l}}if(t.globalCustom!=null&&t.hasOwnProperty("globalCustom")){let e=$root.com.quick.voice.proto.CustomInfo.verify(t.globalCustom);if(e)return"globalCustom."+e}return null},n.fromObject=function(t){if(t instanceof $root.com.quick.voice.proto.LayoutData)return t;let e=new $root.com.quick.voice.proto.LayoutData;switch(t.roomId!=null&&(e.roomId=String(t.roomId)),t.type){default:if(typeof t.type=="number"){e.type=t.type;break}break;case"AudioAndVideo":case 0:e.type=0;break;case"OnlyAudio":case 1:e.type=1;break;case"OnlyVideo":case 2:e.type=2;break}if(t.userMap){if(typeof t.userMap!="object")throw TypeError(".com.quick.voice.proto.LayoutData.userMap: object expected");e.userMap={};for(let s=Object.keys(t.userMap),l=0;l<s.length;++l){if(typeof t.userMap[s[l]]!="object")throw TypeError(".com.quick.voice.proto.LayoutData.userMap: object expected");e.userMap[s[l]]=$root.com.quick.voice.proto.UserInfo.fromObject(t.userMap[s[l]])}}if(t.globalCustom!=null){if(typeof t.globalCustom!="object")throw TypeError(".com.quick.voice.proto.LayoutData.globalCustom: object expected");e.globalCustom=$root.com.quick.voice.proto.CustomInfo.fromObject(t.globalCustom)}return e},n.toObject=function(t,e){e||(e={});let s={};(e.objects||e.defaults)&&(s.userMap={}),e.defaults&&(s.roomId="",s.type=e.enums===String?"AudioAndVideo":0),t.roomId!=null&&t.hasOwnProperty("roomId")&&(s.roomId=t.roomId),t.type!=null&&t.hasOwnProperty("type")&&(s.type=e.enums===String?$root.com.quick.voice.proto.LayoutType[t.type]===void 0?t.type:$root.com.quick.voice.proto.LayoutType[t.type]:t.type);let l;if(t.userMap&&(l=Object.keys(t.userMap)).length){s.userMap={};for(let c=0;c<l.length;++c)s.userMap[l[c]]=$root.com.quick.voice.proto.UserInfo.toObject(t.userMap[l[c]],e)}return t.globalCustom!=null&&t.hasOwnProperty("globalCustom")&&(s.globalCustom=$root.com.quick.voice.proto.CustomInfo.toObject(t.globalCustom,e),e.oneofs&&(s._globalCustom="globalCustom")),s},n.prototype.toJSON=function(){return this.constructor.toObject(this,minimalExports.util.toJSONOptions)},n.getTypeUrl=function(t){return t===void 0&&(t="type.googleapis.com"),t+"/com.quick.voice.proto.LayoutData"},n}(),a.UserInfo=function(){function n(i){if(this.audios=[],this.videos=[],i)for(let t=Object.keys(i),e=0;e<t.length;++e)i[t[e]]!=null&&(this[t[e]]=i[t[e]])}n.prototype.id="",n.prototype.audios=$util.emptyArray,n.prototype.videos=$util.emptyArray,n.prototype.custom=null;let o;return Object.defineProperty(n.prototype,"_custom",{get:$util.oneOfGetter(o=["custom"]),set:$util.oneOfSetter(o)}),n.create=function(t){return new n(t)},n.encode=function(t,e){if(e||(e=$Writer.create()),t.id!=null&&Object.hasOwnProperty.call(t,"id")&&e.uint32(10).string(t.id),t.audios!=null&&t.audios.length)for(let s=0;s<t.audios.length;++s)$root.com.quick.voice.proto.AudioInfo.encode(t.audios[s],e.uint32(18).fork()).ldelim();if(t.videos!=null&&t.videos.length)for(let s=0;s<t.videos.length;++s)$root.com.quick.voice.proto.VideoInfo.encode(t.videos[s],e.uint32(26).fork()).ldelim();return t.custom!=null&&Object.hasOwnProperty.call(t,"custom")&&$root.com.quick.voice.proto.CustomInfo.encode(t.custom,e.uint32(34).fork()).ldelim(),e},n.encodeDelimited=function(t,e){return this.encode(t,e).ldelim()},n.decode=function(t,e,s){t instanceof $Reader||(t=$Reader.create(t));let l=e===void 0?t.len:t.pos+e,c=new $root.com.quick.voice.proto.UserInfo;for(;t.pos<l;){let d=t.uint32();if(d===s)break;switch(d>>>3){case 1:{c.id=t.string();break}case 2:{c.audios&&c.audios.length||(c.audios=[]),c.audios.push($root.com.quick.voice.proto.AudioInfo.decode(t,t.uint32()));break}case 3:{c.videos&&c.videos.length||(c.videos=[]),c.videos.push($root.com.quick.voice.proto.VideoInfo.decode(t,t.uint32()));break}case 4:{c.custom=$root.com.quick.voice.proto.CustomInfo.decode(t,t.uint32());break}default:t.skipType(d&7);break}}return c},n.decodeDelimited=function(t){return t instanceof $Reader||(t=new $Reader(t)),this.decode(t,t.uint32())},n.verify=function(t){if(typeof t!="object"||t===null)return"object expected";if(t.id!=null&&t.hasOwnProperty("id")&&!$util.isString(t.id))return"id: string expected";if(t.audios!=null&&t.hasOwnProperty("audios")){if(!Array.isArray(t.audios))return"audios: array expected";for(let e=0;e<t.audios.length;++e){let s=$root.com.quick.voice.proto.AudioInfo.verify(t.audios[e]);if(s)return"audios."+s}}if(t.videos!=null&&t.hasOwnProperty("videos")){if(!Array.isArray(t.videos))return"videos: array expected";for(let e=0;e<t.videos.length;++e){let s=$root.com.quick.voice.proto.VideoInfo.verify(t.videos[e]);if(s)return"videos."+s}}if(t.custom!=null&&t.hasOwnProperty("custom")){let e=$root.com.quick.voice.proto.CustomInfo.verify(t.custom);if(e)return"custom."+e}return null},n.fromObject=function(t){if(t instanceof $root.com.quick.voice.proto.UserInfo)return t;let e=new $root.com.quick.voice.proto.UserInfo;if(t.id!=null&&(e.id=String(t.id)),t.audios){if(!Array.isArray(t.audios))throw TypeError(".com.quick.voice.proto.UserInfo.audios: array expected");e.audios=[];for(let s=0;s<t.audios.length;++s){if(typeof t.audios[s]!="object")throw TypeError(".com.quick.voice.proto.UserInfo.audios: object expected");e.audios[s]=$root.com.quick.voice.proto.AudioInfo.fromObject(t.audios[s])}}if(t.videos){if(!Array.isArray(t.videos))throw TypeError(".com.quick.voice.proto.UserInfo.videos: array expected");e.videos=[];for(let s=0;s<t.videos.length;++s){if(typeof t.videos[s]!="object")throw TypeError(".com.quick.voice.proto.UserInfo.videos: object expected");e.videos[s]=$root.com.quick.voice.proto.VideoInfo.fromObject(t.videos[s])}}if(t.custom!=null){if(typeof t.custom!="object")throw TypeError(".com.quick.voice.proto.UserInfo.custom: object expected");e.custom=$root.com.quick.voice.proto.CustomInfo.fromObject(t.custom)}return e},n.toObject=function(t,e){e||(e={});let s={};if((e.arrays||e.defaults)&&(s.audios=[],s.videos=[]),e.defaults&&(s.id=""),t.id!=null&&t.hasOwnProperty("id")&&(s.id=t.id),t.audios&&t.audios.length){s.audios=[];for(let l=0;l<t.audios.length;++l)s.audios[l]=$root.com.quick.voice.proto.AudioInfo.toObject(t.audios[l],e)}if(t.videos&&t.videos.length){s.videos=[];for(let l=0;l<t.videos.length;++l)s.videos[l]=$root.com.quick.voice.proto.VideoInfo.toObject(t.videos[l],e)}return t.custom!=null&&t.hasOwnProperty("custom")&&(s.custom=$root.com.quick.voice.proto.CustomInfo.toObject(t.custom,e),e.oneofs&&(s._custom="custom")),s},n.prototype.toJSON=function(){return this.constructor.toObject(this,minimalExports.util.toJSONOptions)},n.getTypeUrl=function(t){return t===void 0&&(t="type.googleapis.com"),t+"/com.quick.voice.proto.UserInfo"},n}(),a.AudioInfo=function(){function n(i){if(i)for(let t=Object.keys(i),e=0;e<t.length;++e)i[t[e]]!=null&&(this[t[e]]=i[t[e]])}n.prototype.type=0,n.prototype.isEnable=!1,n.prototype.isMute=!1,n.prototype.volume=0,n.prototype.updateTime=null;let o;return Object.defineProperty(n.prototype,"_updateTime",{get:$util.oneOfGetter(o=["updateTime"]),set:$util.oneOfSetter(o)}),n.create=function(t){return new n(t)},n.encode=function(t,e){return e||(e=$Writer.create()),t.type!=null&&Object.hasOwnProperty.call(t,"type")&&e.uint32(8).int32(t.type),t.isEnable!=null&&Object.hasOwnProperty.call(t,"isEnable")&&e.uint32(16).bool(t.isEnable),t.isMute!=null&&Object.hasOwnProperty.call(t,"isMute")&&e.uint32(24).bool(t.isMute),t.volume!=null&&Object.hasOwnProperty.call(t,"volume")&&e.uint32(33).double(t.volume),t.updateTime!=null&&Object.hasOwnProperty.call(t,"updateTime")&&e.uint32(40).int64(t.updateTime),e},n.encodeDelimited=function(t,e){return this.encode(t,e).ldelim()},n.decode=function(t,e,s){t instanceof $Reader||(t=$Reader.create(t));let l=e===void 0?t.len:t.pos+e,c=new $root.com.quick.voice.proto.AudioInfo;for(;t.pos<l;){let d=t.uint32();if(d===s)break;switch(d>>>3){case 1:{c.type=t.int32();break}case 2:{c.isEnable=t.bool();break}case 3:{c.isMute=t.bool();break}case 4:{c.volume=t.double();break}case 5:{c.updateTime=t.int64();break}default:t.skipType(d&7);break}}return c},n.decodeDelimited=function(t){return t instanceof $Reader||(t=new $Reader(t)),this.decode(t,t.uint32())},n.verify=function(t){if(typeof t!="object"||t===null)return"object expected";if(t.type!=null&&t.hasOwnProperty("type"))switch(t.type){default:return"type: enum value expected";case 0:case 1:break}return t.isEnable!=null&&t.hasOwnProperty("isEnable")&&typeof t.isEnable!="boolean"?"isEnable: boolean expected":t.isMute!=null&&t.hasOwnProperty("isMute")&&typeof t.isMute!="boolean"?"isMute: boolean expected":t.volume!=null&&t.hasOwnProperty("volume")&&typeof t.volume!="number"?"volume: number expected":t.updateTime!=null&&t.hasOwnProperty("updateTime")&&!$util.isInteger(t.updateTime)&&!(t.updateTime&&$util.isInteger(t.updateTime.low)&&$util.isInteger(t.updateTime.high))?"updateTime: integer|Long expected":null},n.fromObject=function(t){if(t instanceof $root.com.quick.voice.proto.AudioInfo)return t;let e=new $root.com.quick.voice.proto.AudioInfo;switch(t.type){default:if(typeof t.type=="number"){e.type=t.type;break}break;case"Microphone":case 0:e.type=0;break;case"SystemVoice":case 1:e.type=1;break}return t.isEnable!=null&&(e.isEnable=!!t.isEnable),t.isMute!=null&&(e.isMute=!!t.isMute),t.volume!=null&&(e.volume=Number(t.volume)),t.updateTime!=null&&($util.Long?(e.updateTime=$util.Long.fromValue(t.updateTime)).unsigned=!1:typeof t.updateTime=="string"?e.updateTime=parseInt(t.updateTime,10):typeof t.updateTime=="number"?e.updateTime=t.updateTime:typeof t.updateTime=="object"&&(e.updateTime=new $util.LongBits(t.updateTime.low>>>0,t.updateTime.high>>>0).toNumber())),e},n.toObject=function(t,e){e||(e={});let s={};return e.defaults&&(s.type=e.enums===String?"Microphone":0,s.isEnable=!1,s.isMute=!1,s.volume=0),t.type!=null&&t.hasOwnProperty("type")&&(s.type=e.enums===String?$root.com.quick.voice.proto.AudioType[t.type]===void 0?t.type:$root.com.quick.voice.proto.AudioType[t.type]:t.type),t.isEnable!=null&&t.hasOwnProperty("isEnable")&&(s.isEnable=t.isEnable),t.isMute!=null&&t.hasOwnProperty("isMute")&&(s.isMute=t.isMute),t.volume!=null&&t.hasOwnProperty("volume")&&(s.volume=e.json&&!isFinite(t.volume)?String(t.volume):t.volume),t.updateTime!=null&&t.hasOwnProperty("updateTime")&&(typeof t.updateTime=="number"?s.updateTime=e.longs===String?String(t.updateTime):t.updateTime:s.updateTime=e.longs===String?$util.Long.prototype.toString.call(t.updateTime):e.longs===Number?new $util.LongBits(t.updateTime.low>>>0,t.updateTime.high>>>0).toNumber():t.updateTime,e.oneofs&&(s._updateTime="updateTime")),s},n.prototype.toJSON=function(){return this.constructor.toObject(this,minimalExports.util.toJSONOptions)},n.getTypeUrl=function(t){return t===void 0&&(t="type.googleapis.com"),t+"/com.quick.voice.proto.AudioInfo"},n}(),a.VideoInfo=function(){function n(i){if(i)for(let t=Object.keys(i),e=0;e<t.length;++e)i[t[e]]!=null&&(this[t[e]]=i[t[e]])}n.prototype.type=0,n.prototype.isEnable=!1,n.prototype.isMute=!1,n.prototype.width=0,n.prototype.height=0,n.prototype.x=0,n.prototype.y=0,n.prototype.updateTime=null;let o;return Object.defineProperty(n.prototype,"_updateTime",{get:$util.oneOfGetter(o=["updateTime"]),set:$util.oneOfSetter(o)}),n.create=function(t){return new n(t)},n.encode=function(t,e){return e||(e=$Writer.create()),t.type!=null&&Object.hasOwnProperty.call(t,"type")&&e.uint32(8).int32(t.type),t.isEnable!=null&&Object.hasOwnProperty.call(t,"isEnable")&&e.uint32(16).bool(t.isEnable),t.isMute!=null&&Object.hasOwnProperty.call(t,"isMute")&&e.uint32(24).bool(t.isMute),t.width!=null&&Object.hasOwnProperty.call(t,"width")&&e.uint32(32).int32(t.width),t.height!=null&&Object.hasOwnProperty.call(t,"height")&&e.uint32(40).int32(t.height),t.x!=null&&Object.hasOwnProperty.call(t,"x")&&e.uint32(48).int32(t.x),t.y!=null&&Object.hasOwnProperty.call(t,"y")&&e.uint32(56).int32(t.y),t.updateTime!=null&&Object.hasOwnProperty.call(t,"updateTime")&&e.uint32(64).int64(t.updateTime),e},n.encodeDelimited=function(t,e){return this.encode(t,e).ldelim()},n.decode=function(t,e,s){t instanceof $Reader||(t=$Reader.create(t));let l=e===void 0?t.len:t.pos+e,c=new $root.com.quick.voice.proto.VideoInfo;for(;t.pos<l;){let d=t.uint32();if(d===s)break;switch(d>>>3){case 1:{c.type=t.int32();break}case 2:{c.isEnable=t.bool();break}case 3:{c.isMute=t.bool();break}case 4:{c.width=t.int32();break}case 5:{c.height=t.int32();break}case 6:{c.x=t.int32();break}case 7:{c.y=t.int32();break}case 8:{c.updateTime=t.int64();break}default:t.skipType(d&7);break}}return c},n.decodeDelimited=function(t){return t instanceof $Reader||(t=new $Reader(t)),this.decode(t,t.uint32())},n.verify=function(t){if(typeof t!="object"||t===null)return"object expected";if(t.type!=null&&t.hasOwnProperty("type"))switch(t.type){default:return"type: enum value expected";case 0:case 1:break}return t.isEnable!=null&&t.hasOwnProperty("isEnable")&&typeof t.isEnable!="boolean"?"isEnable: boolean expected":t.isMute!=null&&t.hasOwnProperty("isMute")&&typeof t.isMute!="boolean"?"isMute: boolean expected":t.width!=null&&t.hasOwnProperty("width")&&!$util.isInteger(t.width)?"width: integer expected":t.height!=null&&t.hasOwnProperty("height")&&!$util.isInteger(t.height)?"height: integer expected":t.x!=null&&t.hasOwnProperty("x")&&!$util.isInteger(t.x)?"x: integer expected":t.y!=null&&t.hasOwnProperty("y")&&!$util.isInteger(t.y)?"y: integer expected":t.updateTime!=null&&t.hasOwnProperty("updateTime")&&!$util.isInteger(t.updateTime)&&!(t.updateTime&&$util.isInteger(t.updateTime.low)&&$util.isInteger(t.updateTime.high))?"updateTime: integer|Long expected":null},n.fromObject=function(t){if(t instanceof $root.com.quick.voice.proto.VideoInfo)return t;let e=new $root.com.quick.voice.proto.VideoInfo;switch(t.type){default:if(typeof t.type=="number"){e.type=t.type;break}break;case"Camera":case 0:e.type=0;break;case"Screen":case 1:e.type=1;break}return t.isEnable!=null&&(e.isEnable=!!t.isEnable),t.isMute!=null&&(e.isMute=!!t.isMute),t.width!=null&&(e.width=t.width|0),t.height!=null&&(e.height=t.height|0),t.x!=null&&(e.x=t.x|0),t.y!=null&&(e.y=t.y|0),t.updateTime!=null&&($util.Long?(e.updateTime=$util.Long.fromValue(t.updateTime)).unsigned=!1:typeof t.updateTime=="string"?e.updateTime=parseInt(t.updateTime,10):typeof t.updateTime=="number"?e.updateTime=t.updateTime:typeof t.updateTime=="object"&&(e.updateTime=new $util.LongBits(t.updateTime.low>>>0,t.updateTime.high>>>0).toNumber())),e},n.toObject=function(t,e){e||(e={});let s={};return e.defaults&&(s.type=e.enums===String?"Camera":0,s.isEnable=!1,s.isMute=!1,s.width=0,s.height=0,s.x=0,s.y=0),t.type!=null&&t.hasOwnProperty("type")&&(s.type=e.enums===String?$root.com.quick.voice.proto.VideoType[t.type]===void 0?t.type:$root.com.quick.voice.proto.VideoType[t.type]:t.type),t.isEnable!=null&&t.hasOwnProperty("isEnable")&&(s.isEnable=t.isEnable),t.isMute!=null&&t.hasOwnProperty("isMute")&&(s.isMute=t.isMute),t.width!=null&&t.hasOwnProperty("width")&&(s.width=t.width),t.height!=null&&t.hasOwnProperty("height")&&(s.height=t.height),t.x!=null&&t.hasOwnProperty("x")&&(s.x=t.x),t.y!=null&&t.hasOwnProperty("y")&&(s.y=t.y),t.updateTime!=null&&t.hasOwnProperty("updateTime")&&(typeof t.updateTime=="number"?s.updateTime=e.longs===String?String(t.updateTime):t.updateTime:s.updateTime=e.longs===String?$util.Long.prototype.toString.call(t.updateTime):e.longs===Number?new $util.LongBits(t.updateTime.low>>>0,t.updateTime.high>>>0).toNumber():t.updateTime,e.oneofs&&(s._updateTime="updateTime")),s},n.prototype.toJSON=function(){return this.constructor.toObject(this,minimalExports.util.toJSONOptions)},n.getTypeUrl=function(t){return t===void 0&&(t="type.googleapis.com"),t+"/com.quick.voice.proto.VideoInfo"},n}(),a.CustomInfo=function(){function n(i){if(this.customKeyMap={},i)for(let t=Object.keys(i),e=0;e<t.length;++e)i[t[e]]!=null&&(this[t[e]]=i[t[e]])}n.prototype.roomId="",n.prototype.customKeyMap=$util.emptyObject,n.prototype.updateTime=null;let o;return Object.defineProperty(n.prototype,"_updateTime",{get:$util.oneOfGetter(o=["updateTime"]),set:$util.oneOfSetter(o)}),n.create=function(t){return new n(t)},n.encode=function(t,e){if(e||(e=$Writer.create()),t.roomId!=null&&Object.hasOwnProperty.call(t,"roomId")&&e.uint32(10).string(t.roomId),t.customKeyMap!=null&&Object.hasOwnProperty.call(t,"customKeyMap"))for(let s=Object.keys(t.customKeyMap),l=0;l<s.length;++l)e.uint32(18).fork().uint32(10).string(s[l]).uint32(18).string(t.customKeyMap[s[l]]).ldelim();return t.updateTime!=null&&Object.hasOwnProperty.call(t,"updateTime")&&e.uint32(24).int64(t.updateTime),e},n.encodeDelimited=function(t,e){return this.encode(t,e).ldelim()},n.decode=function(t,e,s){t instanceof $Reader||(t=$Reader.create(t));let l=e===void 0?t.len:t.pos+e,c=new $root.com.quick.voice.proto.CustomInfo,d,p;for(;t.pos<l;){let f=t.uint32();if(f===s)break;switch(f>>>3){case 1:{c.roomId=t.string();break}case 2:{c.customKeyMap===$util.emptyObject&&(c.customKeyMap={});let w=t.uint32()+t.pos;for(d="",p="";t.pos<w;){let b=t.uint32();switch(b>>>3){case 1:d=t.string();break;case 2:p=t.string();break;default:t.skipType(b&7);break}}c.customKeyMap[d]=p;break}case 3:{c.updateTime=t.int64();break}default:t.skipType(f&7);break}}return c},n.decodeDelimited=function(t){return t instanceof $Reader||(t=new $Reader(t)),this.decode(t,t.uint32())},n.verify=function(t){if(typeof t!="object"||t===null)return"object expected";if(t.roomId!=null&&t.hasOwnProperty("roomId")&&!$util.isString(t.roomId))return"roomId: string expected";if(t.customKeyMap!=null&&t.hasOwnProperty("customKeyMap")){if(!$util.isObject(t.customKeyMap))return"customKeyMap: object expected";let e=Object.keys(t.customKeyMap);for(let s=0;s<e.length;++s)if(!$util.isString(t.customKeyMap[e[s]]))return"customKeyMap: string{k:string} expected"}return t.updateTime!=null&&t.hasOwnProperty("updateTime")&&!$util.isInteger(t.updateTime)&&!(t.updateTime&&$util.isInteger(t.updateTime.low)&&$util.isInteger(t.updateTime.high))?"updateTime: integer|Long expected":null},n.fromObject=function(t){if(t instanceof $root.com.quick.voice.proto.CustomInfo)return t;let e=new $root.com.quick.voice.proto.CustomInfo;if(t.roomId!=null&&(e.roomId=String(t.roomId)),t.customKeyMap){if(typeof t.customKeyMap!="object")throw TypeError(".com.quick.voice.proto.CustomInfo.customKeyMap: object expected");e.customKeyMap={};for(let s=Object.keys(t.customKeyMap),l=0;l<s.length;++l)e.customKeyMap[s[l]]=String(t.customKeyMap[s[l]])}return t.updateTime!=null&&($util.Long?(e.updateTime=$util.Long.fromValue(t.updateTime)).unsigned=!1:typeof t.updateTime=="string"?e.updateTime=parseInt(t.updateTime,10):typeof t.updateTime=="number"?e.updateTime=t.updateTime:typeof t.updateTime=="object"&&(e.updateTime=new $util.LongBits(t.updateTime.low>>>0,t.updateTime.high>>>0).toNumber())),e},n.toObject=function(t,e){e||(e={});let s={};(e.objects||e.defaults)&&(s.customKeyMap={}),e.defaults&&(s.roomId=""),t.roomId!=null&&t.hasOwnProperty("roomId")&&(s.roomId=t.roomId);let l;if(t.customKeyMap&&(l=Object.keys(t.customKeyMap)).length){s.customKeyMap={};for(let c=0;c<l.length;++c)s.customKeyMap[l[c]]=t.customKeyMap[l[c]]}return t.updateTime!=null&&t.hasOwnProperty("updateTime")&&(typeof t.updateTime=="number"?s.updateTime=e.longs===String?String(t.updateTime):t.updateTime:s.updateTime=e.longs===String?$util.Long.prototype.toString.call(t.updateTime):e.longs===Number?new $util.LongBits(t.updateTime.low>>>0,t.updateTime.high>>>0).toNumber():t.updateTime,e.oneofs&&(s._updateTime="updateTime")),s},n.prototype.toJSON=function(){return this.constructor.toObject(this,minimalExports.util.toJSONOptions)},n.getTypeUrl=function(t){return t===void 0&&(t="type.googleapis.com"),t+"/com.quick.voice.proto.CustomInfo"},n}(),a.LayoutType=function(){const n={},o=Object.create(n);return o[n[0]="AudioAndVideo"]=0,o[n[1]="OnlyAudio"]=1,o[n[2]="OnlyVideo"]=2,o}(),a.AudioType=function(){const n={},o=Object.create(n);return o[n[0]="Microphone"]=0,o[n[1]="SystemVoice"]=1,o}(),a.VideoType=function(){const n={},o=Object.create(n);return o[n[0]="Camera"]=0,o[n[1]="Screen"]=1,o}(),a}(),u}(),r}(),h})(),createAudioInfo=()=>({remove:!1,isEnable:!1,updateTime:0,isMute:!1,volume:0}),createVideoInfo=()=>({remove:!1,isEnable:!1,updateTime:0,isMute:!1,sx:0,sy:0,sw:0,sh:0});class RoomUser{constructor(){m(this,"userId","");m(this,"mc_audio");m(this,"mc_video");m(this,"ss_audio");m(this,"ss_video");m(this,"updateTime",0);m(this,"getUpdateTimeKey",()=>{const r=[];return this.mc_audio&&r.push(this.mc_audio.updateTime),this.mc_video&&r.push(this.mc_video.updateTime),this.ss_audio&&r.push(this.ss_audio.updateTime),this.ss_video&&r.push(this.ss_video.updateTime),r.join("_")});m(this,"init",r=>{var t,e,s,l;const{id:u,audios:a=[],videos:n=[]}=r;this.userId=u;const o=this.getUpdateTimeKey();this.mc_audio&&(this.mc_audio.remove=!0),this.mc_video&&(this.mc_video.remove=!0),this.ss_audio&&(this.ss_audio.remove=!0),this.ss_video&&(this.ss_video.remove=!0);for(const c of a){const{type:d=0,isEnable:p=!1,isMute:f=!1,updateTime:w,volume:b=0}=c;switch(d){case 0:{if(this.mc_audio||(this.mc_audio=createAudioInfo()),this.mc_audio.remove=!1,this.mc_audio.updateTime===w)break;this.mc_audio.isEnable=!!p,this.mc_audio.isMute=!!f,this.mc_audio.updateTime=Number(w),this.mc_audio.volume=Number(b)}break;case 1:{if(this.ss_audio||(this.ss_audio=createAudioInfo()),this.ss_audio.remove=!1,this.ss_audio.updateTime===w)break;this.ss_audio.isEnable=!!p,this.ss_audio.isMute=!!f,this.ss_audio.updateTime=Number(w),this.ss_audio.volume=Number(b)}break}}for(const c of n){const{type:d=0,isEnable:p,isMute:f,updateTime:w,width:b,height:g,x:k,y:I}=c;switch(d){case 0:{if(this.mc_video||(this.mc_video=createVideoInfo()),this.mc_video.remove=!1,this.mc_video.updateTime===w)break;this.mc_video.isEnable=!!p,this.mc_video.isMute=!!f,this.mc_video.updateTime=Number(w)||0,this.mc_video.sx=k||0,this.mc_video.sy=I||0,this.mc_video.sw=b||0,this.mc_video.sh=g||0}break;case 1:{if(this.ss_video||(this.ss_video=createVideoInfo()),this.ss_video.remove=!1,this.ss_video.updateTime===w)break;this.ss_video.isEnable=!!p,this.ss_video.isMute=!!f,this.ss_video.updateTime=Number(w)||0,this.ss_video.sx=k||0,this.ss_video.sy=I||0,this.ss_video.sw=b||0,this.ss_video.sh=g||0}break}}(t=this.mc_audio)!=null&&t.remove&&(this.mc_audio=void 0),(e=this.mc_video)!=null&&e.remove&&(this.mc_video=void 0),(s=this.ss_audio)!=null&&s.remove&&(this.ss_audio=void 0),(l=this.ss_video)!=null&&l.remove&&(this.ss_video=void 0);const i=this.getUpdateTimeKey();o!==i&&(this.updateTime=new Date().getTime())});m(this,"destroy",()=>{var r,u;(r=this.mc_video)!=null&&r.destroy&&this.mc_video.destroy(),(u=this.ss_video)!=null&&u.destroy&&this.ss_video.destroy(),this.mc_audio=void 0,this.mc_video=void 0,this.ss_audio=void 0,this.ss_video=void 0})}}const parseSEI=h=>{let r=0,u=0;for(;;){const n=h[r];if(u=u+n,r=r+1,n!==255)break}let a=0;for(;;){const n=h[r];if(a=a+n,r=r+1,n!==255)break}if(u===5){const n=h.slice(r,r+16),i=Array.from(n,f=>f.toString(16).padStart(2,"0")).join("");r=r+16;const t=a-16,e=h.slice(r,r+t),s=com.quick.voice.proto.SeiData.decode(e),{event:l=0}=s,c=s.data;let d;switch(l){case 0:d=com.quick.voice.proto.LayoutData.decode(s.data);break;case 1:d=com.quick.voice.proto.CustomInfo.decode(s.data);break}return{uuid:i,...s,event:l,data_remote:c,data:d}}};class QuickVoPlayer{constructor(r={}){m(this,"option",{debug:!1,ws:"wss://livep2p.devplay.cc/websocket"});m(this,"displayMode","original");m(this,"prPlayer");m(this,"dom");m(this,"room",{roomId:"",updateTime:"",author:"",version:""});m(this,"usersMap",new Map);m(this,"on",{users:r=>{},analysis:r=>{}});m(this,"start",async r=>(this.stop(),this.prPlayer.start(r)));m(this,"stop",()=>{this.prPlayer.stop(),this.usersMap=new Map,this.room.roomId="",this.room.author="",this.room.updateTime="",this.room.version=""});m(this,"setMute",r=>{this.prPlayer.setMute(r)});m(this,"getStream",()=>this.prPlayer.getStream());m(this,"getAllUseUpdateKey",()=>{const r=[...this.usersMap.values()];return Array.from(r,a=>a.updateTime).join("_")});m(this,"checkAndCreateUser",(r,u)=>{var a,n;if(this.usersMap.has(r)){const o=this.usersMap.get(r);if(o==null||o.init(u),o!=null&&o.mc_video){const{sx:i,sy:t,sw:e,sh:s}=o.mc_video;(a=o==null?void 0:o.mc_video.worker)==null||a.setCut({sx:i,sy:t,sw:e,sh:s})}if(o!=null&&o.ss_video){const{sx:i,sy:t,sw:e,sh:s}=o.ss_video;(n=o==null?void 0:o.ss_video.worker)==null||n.setCut({sx:i,sy:t,sw:e,sh:s})}}else{const o=new RoomUser;if(this.usersMap.set(r,o),o.init(u),o){if(o.mc_video){const{sx:i,sy:t,sw:e,sh:s}=o.mc_video,l=`${o.userId}_mc_video`,{worker:c,stream:d,destroy:p}=this.prPlayer.cut.create(l,{sx:i,sy:t,sw:e,sh:s});o.mc_video.worker=c,this.displayMode==="original"&&c.setPause(!0),o.mc_video.stream=d,o.mc_video.destroy=()=>{p(),this.prPlayer.cut.remove(l),this.usersMap.delete(o.userId)}}if(o.ss_video){const{sx:i,sy:t,sw:e,sh:s}=o.ss_video,l=`${o.userId}_ss_video`,{worker:c,stream:d,destroy:p}=this.prPlayer.cut.create(l,{sx:i,sy:t,sw:e,sh:s});o.ss_video.worker=c,this.displayMode==="original"&&c.setPause(!0),o.ss_video.stream=d,o.ss_video.destroy=()=>{p(),this.prPlayer.cut.remove(l),this.usersMap.delete(o.userId)}}}}});m(this,"onSEI",r=>{try{const u=parseSEI(r);if(!u)return;const{event:a,data:n}=u;switch(a){case 0:{const{roomId:o,userMap:i}=n;if(o!==this.room.roomId)return;const t=this.getAllUseUpdateKey(),e=Object.keys(i);{const l=[...this.usersMap.values()];for(const c of l)e.includes(c.userId)||c==null||c.destroy()}for(const l of e){const c=i[l];this.checkAndCreateUser(l,c)}const s=this.getAllUseUpdateKey();if(t!==s&&this.on.users){const l=[...this.usersMap.values()],c=Array.from(l,({userId:d,mc_audio:p,mc_video:f,ss_audio:w,ss_video:b,updateTime:g})=>({userId:d,mc_audio:p,mc_video:f,ss_audio:w,ss_video:b,updateTime:g}));this.on.users(c)}}break;case 1:{const{roomId:o,updateTime:i}=n,{author:t,version:e}=n.customKeyMap;this.room.roomId=o,this.room.updateTime=i,this.room.author=t,this.room.version=e}break}}catch(u){console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m","color:#0097ff;","------->onSEI: error",u)}});m(this,"setDisplayMode",r=>{var u,a,n,o,i,t,e,s;switch(this.displayMode=r,r){case"original":{this.prPlayer.setPause(!1);const l=[...this.usersMap.values()];for(const c of l)(a=(u=c.mc_video)==null?void 0:u.worker)==null||a.setPause(!0),(o=(n=c.ss_video)==null?void 0:n.worker)==null||o.setPause(!0)}break;case"cut":{this.prPlayer.setPause(!0);const l=[...this.usersMap.values()];for(const c of l)(t=(i=c.mc_video)==null?void 0:i.worker)==null||t.setPause(!1),(s=(e=c.ss_video)==null?void 0:e.worker)==null||s.setPause(!1)}break}});const{debug:u=!1}=r;this.option.debug=u,this.prPlayer=new et({debug:u}),this.prPlayer.on.demuxer.chunk=a=>{},this.prPlayer.on.decoder.sei=this.onSEI,this.prPlayer.on.decoder.analysis=this.on.analysis}}exports.QuickVoPlayer=QuickVoPlayer,Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"})});
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "quickvo-player",
|
|
3
3
|
"description": "基于web-codecs解码flv视频流并输出帧数据。",
|
|
4
|
-
"version": "0.2.
|
|
4
|
+
"version": "0.2.3",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"files": [
|
|
7
7
|
"dist"
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"build": "tsc && vite build"
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"pr-player": "^0.2.
|
|
22
|
+
"pr-player": "^0.2.11",
|
|
23
23
|
"pr-ws": "^0.3.3",
|
|
24
24
|
"protobufjs": "^7.5.4"
|
|
25
25
|
},
|