quickvo-player 0.1.8 → 0.1.9
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/PeerAnalyzeStats.d.ts +44 -0
- package/dist/index.js +581 -581
- package/dist/index.umd.cjs +4 -4
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -2,19 +2,19 @@ var Q = Object.defineProperty;
|
|
|
2
2
|
var X = (h) => {
|
|
3
3
|
throw TypeError(h);
|
|
4
4
|
};
|
|
5
|
-
var tt = (h,
|
|
6
|
-
var
|
|
7
|
-
var I = (h,
|
|
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.debug=y=>postMessage({action:"onDebug",data:y}),A.on.info=y=>postMessage({action:"onInfo",data:y}),A.on.config=y=>postMessage({action:"onConfig",data:y}),A.on.chunk=y=>postMessage({action:"onChunk",data:y}),onmessage=y=>{const{action:t,data:s}=y.data,e=A[t];e&&e(s)}})();\n', T = typeof self < "u" && self.Blob && new Blob(["(self.URL || self.webkitURL).revokeObjectURL(self.location.href);", D], { type: "text/javascript;charset=utf-8" });
|
|
5
|
+
var tt = (h, n, a) => n in h ? Q(h, n, { enumerable: !0, configurable: !0, writable: !0, value: a }) : h[n] = a;
|
|
6
|
+
var m = (h, n, a) => tt(h, typeof n != "symbol" ? n + "" : n, a), Z = (h, n, a) => n.has(h) || X("Cannot " + a);
|
|
7
|
+
var I = (h, n, a) => (Z(h, n, "read from private field"), a ? a.call(h) : n.get(h)), J = (h, n, a) => n.has(h) ? X("Cannot add the same private member more than once") : n instanceof WeakSet ? n.add(h) : n.set(h, a), H = (h, n, a, u) => (Z(h, n, "write to private field"), u ? u.call(h, a) : n.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" });
|
|
9
9
|
function L(h) {
|
|
10
|
-
let
|
|
10
|
+
let n;
|
|
11
11
|
try {
|
|
12
|
-
if (
|
|
13
|
-
const a = new Worker(
|
|
12
|
+
if (n = _ && (self.URL || self.webkitURL).createObjectURL(_), !n) throw "";
|
|
13
|
+
const a = new Worker(n, {
|
|
14
14
|
name: h == null ? void 0 : h.name
|
|
15
15
|
});
|
|
16
16
|
return a.addEventListener("error", () => {
|
|
17
|
-
(self.URL || self.webkitURL).revokeObjectURL(
|
|
17
|
+
(self.URL || self.webkitURL).revokeObjectURL(n);
|
|
18
18
|
}), a;
|
|
19
19
|
} catch {
|
|
20
20
|
return new Worker(
|
|
@@ -25,45 +25,45 @@ function L(h) {
|
|
|
25
25
|
);
|
|
26
26
|
}
|
|
27
27
|
}
|
|
28
|
-
class
|
|
28
|
+
class V {
|
|
29
29
|
constructor() {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
30
|
+
m(this, "worker", new L());
|
|
31
|
+
m(this, "on", {});
|
|
32
|
+
m(this, "init", (n) => this.worker.postMessage({ action: "init", data: n }));
|
|
33
|
+
m(this, "push", (n) => this.worker.postMessage({ action: "push", data: n }));
|
|
34
|
+
m(this, "destroy", () => {
|
|
35
35
|
this.worker.postMessage({ action: "destroy", data: {} }), this.worker.terminate();
|
|
36
36
|
});
|
|
37
|
-
this.worker.onmessage = (
|
|
38
|
-
const { action: a, data: u } =
|
|
37
|
+
this.worker.onmessage = (n) => {
|
|
38
|
+
const { action: a, data: u } = n.data;
|
|
39
39
|
switch (a) {
|
|
40
|
-
case "
|
|
40
|
+
case "on.info":
|
|
41
41
|
this.on.info && this.on.info(u);
|
|
42
42
|
break;
|
|
43
|
-
case "
|
|
43
|
+
case "on.config":
|
|
44
44
|
this.on.config && this.on.config(u);
|
|
45
45
|
break;
|
|
46
|
-
case "
|
|
47
|
-
this.on.debug && this.on.debug(u);
|
|
48
|
-
break;
|
|
49
|
-
case "onChunk":
|
|
46
|
+
case "on.chunk":
|
|
50
47
|
this.on.chunk && this.on.chunk(u);
|
|
51
48
|
break;
|
|
49
|
+
case "on.debug":
|
|
50
|
+
this.on.debug && this.on.debug(u);
|
|
51
|
+
break;
|
|
52
52
|
}
|
|
53
53
|
};
|
|
54
54
|
}
|
|
55
55
|
}
|
|
56
|
-
const S = `(function(){"use strict";class
|
|
57
|
-
`,
|
|
58
|
-
function
|
|
59
|
-
let
|
|
56
|
+
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:[20,50],hls:[200,300],dash:[50,100],rtmp:[50,100]};decodingSpeed=16;fps=0;firstVideoChunkTimestamp;secondVideoChunkTimestamp;decodingSpeedRatio=1;maxDecodingSpeedRatio=2;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 t=this.decodingSpeedRatio;this.on.audio.decode&&this.on.audio.decode({audioData:i,playbackRate:t})},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 t=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:t,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(),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 t=this.lastRenderTime-this.nextRenderTime;e-=t}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:t}=this.currentChunk;switch(i){case"audio":this.decodeAudio(t);break;case"video":this.decodeVideo(t);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=o=>postMessage({action:"on.audio.decode",data:o}),d.on.audio.error=o=>postMessage({action:"on.audio.error",data:o}),d.on.video.decode=o=>postMessage({action:"on.video.decode",data:o}),d.on.video.error=o=>postMessage({action:"on.video.error",data:o}),d.on.nalus=o=>postMessage({action:"on.nalus",data:o}),d.on.debug=o=>postMessage({action:"on.debug",data:o}),onmessage=o=>{const{action:e,data:i}=o.data,t=d[e];t&&t(i)}})();
|
|
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
|
+
function F(h) {
|
|
59
|
+
let n;
|
|
60
60
|
try {
|
|
61
|
-
if (
|
|
62
|
-
const a = new Worker(
|
|
61
|
+
if (n = C && (self.URL || self.webkitURL).createObjectURL(C), !n) throw "";
|
|
62
|
+
const a = new Worker(n, {
|
|
63
63
|
name: h == null ? void 0 : h.name
|
|
64
64
|
});
|
|
65
65
|
return a.addEventListener("error", () => {
|
|
66
|
-
(self.URL || self.webkitURL).revokeObjectURL(
|
|
66
|
+
(self.URL || self.webkitURL).revokeObjectURL(n);
|
|
67
67
|
}), a;
|
|
68
68
|
} catch {
|
|
69
69
|
return new Worker(
|
|
@@ -76,45 +76,44 @@ function V(h) {
|
|
|
76
76
|
}
|
|
77
77
|
class N {
|
|
78
78
|
constructor() {
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
destroy: () => {
|
|
88
|
-
this.worker.postMessage({ type: "audio", action: "destroy" });
|
|
89
|
-
}
|
|
90
|
-
});
|
|
91
|
-
g(this, "video", {
|
|
92
|
-
init: (o) => this.worker.postMessage({ type: "video", action: "init", data: o }),
|
|
93
|
-
push: (o) => this.worker.postMessage({ type: "video", action: "push", data: o }),
|
|
94
|
-
flush: () => this.worker.postMessage({ type: "video", action: "flush" }),
|
|
95
|
-
destroy: () => {
|
|
96
|
-
this.worker.postMessage({ type: "video", action: "destroy", data: {} });
|
|
97
|
-
}
|
|
98
|
-
});
|
|
99
|
-
g(this, "destroy", () => {
|
|
79
|
+
m(this, "worker", new F());
|
|
80
|
+
m(this, "on", { audio: {}, video: {} });
|
|
81
|
+
m(this, "init", (n) => this.worker.postMessage({ action: "init", data: n }));
|
|
82
|
+
m(this, "initAudio", (n) => this.worker.postMessage({ action: "initAudio", data: n }));
|
|
83
|
+
m(this, "initVideo", (n) => this.worker.postMessage({ action: "initVideo", data: n }));
|
|
84
|
+
m(this, "push", (n) => this.worker.postMessage({ action: "push", data: n }));
|
|
85
|
+
m(this, "setFrameTrack", (n) => this.worker.postMessage({ action: "setFrameTrack", data: n }));
|
|
86
|
+
m(this, "destroy", () => {
|
|
100
87
|
this.worker.postMessage({ action: "destroy" }), this.worker.terminate();
|
|
101
88
|
});
|
|
102
|
-
this.worker.onmessage = (
|
|
103
|
-
const {
|
|
89
|
+
this.worker.onmessage = (n) => {
|
|
90
|
+
const { action: a, data: u } = n.data;
|
|
104
91
|
switch (a) {
|
|
105
|
-
case "audio":
|
|
106
|
-
|
|
92
|
+
case "on.audio.decode":
|
|
93
|
+
this.on.audio.decode && this.on.audio.decode(u);
|
|
94
|
+
break;
|
|
95
|
+
case "on.audio.error":
|
|
96
|
+
this.on.audio.error && this.on.audio.error(u);
|
|
97
|
+
break;
|
|
98
|
+
case "on.video.decode":
|
|
99
|
+
this.on.video.decode && this.on.video.decode(u);
|
|
107
100
|
break;
|
|
108
|
-
case "video":
|
|
109
|
-
|
|
101
|
+
case "on.video.error":
|
|
102
|
+
this.on.video.error && this.on.video.error(u);
|
|
103
|
+
break;
|
|
104
|
+
case "on.nalus":
|
|
105
|
+
this.on.nalus && this.on.nalus(u);
|
|
106
|
+
break;
|
|
107
|
+
case "on.debug":
|
|
108
|
+
this.on.debug && this.on.debug(u);
|
|
110
109
|
break;
|
|
111
110
|
}
|
|
112
111
|
};
|
|
113
112
|
}
|
|
114
113
|
}
|
|
115
|
-
var B = Object.defineProperty,
|
|
116
|
-
class
|
|
117
|
-
constructor(
|
|
114
|
+
var B = Object.defineProperty, G = (h, n, a) => n in h ? B(h, n, { enumerable: !0, configurable: !0, writable: !0, value: a }) : h[n] = a, y = (h, n, a) => G(h, typeof n != "symbol" ? n + "" : n, a);
|
|
115
|
+
class O {
|
|
116
|
+
constructor(n, a) {
|
|
118
117
|
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", /* @__PURE__ */ 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", (u) => u), y(this, "stop", () => {
|
|
119
118
|
{
|
|
120
119
|
const u = this.inputStream.getTracks();
|
|
@@ -136,11 +135,11 @@ class G {
|
|
|
136
135
|
}), y(this, "getVolume", () => {
|
|
137
136
|
const { analyserNode: u, analyserArrayData: r } = this;
|
|
138
137
|
u.getByteFrequencyData(r);
|
|
139
|
-
let
|
|
138
|
+
let o = 0;
|
|
140
139
|
for (let i = 0; i < r.length; i++)
|
|
141
|
-
|
|
142
|
-
return Math.ceil(
|
|
143
|
-
}), y(this, "mixAudio", (u, r = "bgm") => new Promise(async (
|
|
140
|
+
o += r[i];
|
|
141
|
+
return Math.ceil(o / r.length);
|
|
142
|
+
}), y(this, "mixAudio", (u, r = "bgm") => new Promise(async (o, i) => {
|
|
144
143
|
try {
|
|
145
144
|
{
|
|
146
145
|
const s = this.mixAudioMap.get(r);
|
|
@@ -148,7 +147,7 @@ class G {
|
|
|
148
147
|
}
|
|
149
148
|
const t = r === "bgs" ? this.bgsGainNode : this.bgmGainNode, e = this.audioContext.createBufferSource();
|
|
150
149
|
this.mixAudioMap.set(r, e), e.buffer = u, e.connect(t), e.onended = () => {
|
|
151
|
-
e.disconnect(t), this.mixAudioMap.delete(r),
|
|
150
|
+
e.disconnect(t), this.mixAudioMap.delete(r), o(!0);
|
|
152
151
|
}, e.start(0);
|
|
153
152
|
} catch (t) {
|
|
154
153
|
i(t);
|
|
@@ -157,22 +156,22 @@ class G {
|
|
|
157
156
|
const r = this.mixAudioMap.get(u);
|
|
158
157
|
r == null || r.stop();
|
|
159
158
|
}), y(this, "changeMix", (u, r) => {
|
|
160
|
-
const
|
|
161
|
-
r ?
|
|
162
|
-
}), a && (this.audioContext = a), this.inputStream =
|
|
159
|
+
const o = u === "bgs" ? this.bgsGainNode : this.bgmGainNode;
|
|
160
|
+
r ? o.connect(this.destinationNode) : o.disconnect(this.destinationNode);
|
|
161
|
+
}), a && (this.audioContext = a), this.inputStream = n, 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;
|
|
163
162
|
{
|
|
164
|
-
const { sourceNode: u, inputGainNode: r, enhanceGainNode:
|
|
165
|
-
u.connect(r), r.connect(
|
|
163
|
+
const { sourceNode: u, inputGainNode: r, enhanceGainNode: o, bgsGainNode: i, bgmGainNode: t, analyserNode: e, outputGainNode: s, destinationNode: l } = this;
|
|
164
|
+
u.connect(r), r.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);
|
|
166
165
|
}
|
|
167
166
|
this.setMute(!0), this.audioContext.resume();
|
|
168
167
|
}
|
|
169
168
|
}
|
|
170
|
-
const
|
|
169
|
+
const E = async (h, n) => {
|
|
171
170
|
try {
|
|
172
|
-
const { format: a, numberOfChannels: u, numberOfFrames: r, sampleRate:
|
|
171
|
+
const { format: a, numberOfChannels: u, numberOfFrames: r, sampleRate: o } = n, i = h.createBuffer(u, r, o);
|
|
173
172
|
for (let t = 0; t < u; t++) {
|
|
174
|
-
const e =
|
|
175
|
-
|
|
173
|
+
const e = n.allocationSize({ planeIndex: t }), s = new Uint8Array(e);
|
|
174
|
+
n.copyTo(s, { planeIndex: t });
|
|
176
175
|
const l = new DataView(s.buffer), c = i.getChannelData(t);
|
|
177
176
|
for (let d = 0; d < r; d++) {
|
|
178
177
|
let p;
|
|
@@ -205,54 +204,54 @@ const O = async (h, o) => {
|
|
|
205
204
|
};
|
|
206
205
|
class W {
|
|
207
206
|
constructor() {
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
207
|
+
m(this, "prAudioStream");
|
|
208
|
+
m(this, "audioContext");
|
|
209
|
+
m(this, "destination");
|
|
210
|
+
m(this, "stream", new MediaStream());
|
|
211
|
+
m(this, "nextStartTime", 0);
|
|
212
|
+
m(this, "pendingSources", []);
|
|
213
|
+
m(this, "init", (n) => {
|
|
214
|
+
n || (n = new (window.AudioContext || window.webkitAudioContext)()), this.audioContext = n, 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 = [];
|
|
216
215
|
});
|
|
217
|
-
|
|
218
|
-
var
|
|
219
|
-
return (
|
|
216
|
+
m(this, "getStream", () => {
|
|
217
|
+
var n;
|
|
218
|
+
return (n = this.prAudioStream) == null ? void 0 : n.getStream();
|
|
220
219
|
});
|
|
221
220
|
}
|
|
222
|
-
async push(
|
|
223
|
-
const { audioData: a, playbackRate: u = 1 } =
|
|
221
|
+
async push(n) {
|
|
222
|
+
const { audioData: a, playbackRate: u = 1 } = n;
|
|
224
223
|
try {
|
|
225
224
|
if (!this.audioContext || !this.destination) return;
|
|
226
|
-
let r = await
|
|
225
|
+
let r = await E(this.audioContext, a);
|
|
227
226
|
if (!r) return;
|
|
228
|
-
const
|
|
229
|
-
|
|
227
|
+
const o = this.audioContext.createBufferSource();
|
|
228
|
+
o.buffer = r, o.playbackRate.value = u;
|
|
230
229
|
const i = -1200 * Math.log2(u);
|
|
231
|
-
|
|
230
|
+
o.detune.value = i, o.connect(this.destination);
|
|
232
231
|
const t = Math.max(this.nextStartTime, this.audioContext.currentTime), e = r.duration / u;
|
|
233
|
-
this.nextStartTime = t + e,
|
|
234
|
-
this.pendingSources = this.pendingSources.filter((s) => s !==
|
|
232
|
+
this.nextStartTime = t + e, o.start(t), this.pendingSources.push(o), o.onended = () => {
|
|
233
|
+
this.pendingSources = this.pendingSources.filter((s) => s !== o);
|
|
235
234
|
}, this.audioContext.state === "suspended" && await this.audioContext.resume();
|
|
236
235
|
} finally {
|
|
237
236
|
a.close();
|
|
238
237
|
}
|
|
239
238
|
}
|
|
240
239
|
destroy() {
|
|
241
|
-
var
|
|
242
|
-
(
|
|
240
|
+
var n, a;
|
|
241
|
+
(n = this.audioContext) == null || n.close(), this.audioContext = void 0, this.destination = void 0, this.nextStartTime = 0, (a = this.prAudioStream) == null || a.stop(), this.pendingSources.forEach((u) => u.stop()), this.pendingSources = [];
|
|
243
242
|
}
|
|
244
243
|
}
|
|
245
244
|
const M = `(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)}})();
|
|
246
|
-
`,
|
|
245
|
+
`, A = typeof self < "u" && self.Blob && new Blob(["(self.URL || self.webkitURL).revokeObjectURL(self.location.href);", M], { type: "text/javascript;charset=utf-8" });
|
|
247
246
|
function j(h) {
|
|
248
|
-
let
|
|
247
|
+
let n;
|
|
249
248
|
try {
|
|
250
|
-
if (
|
|
251
|
-
const a = new Worker(
|
|
249
|
+
if (n = A && (self.URL || self.webkitURL).createObjectURL(A), !n) throw "";
|
|
250
|
+
const a = new Worker(n, {
|
|
252
251
|
name: h == null ? void 0 : h.name
|
|
253
252
|
});
|
|
254
253
|
return a.addEventListener("error", () => {
|
|
255
|
-
(self.URL || self.webkitURL).revokeObjectURL(
|
|
254
|
+
(self.URL || self.webkitURL).revokeObjectURL(n);
|
|
256
255
|
}), a;
|
|
257
256
|
} catch {
|
|
258
257
|
return new Worker(
|
|
@@ -265,33 +264,33 @@ function j(h) {
|
|
|
265
264
|
}
|
|
266
265
|
class z {
|
|
267
266
|
constructor() {
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
267
|
+
m(this, "worker", new j());
|
|
268
|
+
m(this, "init", ({ writable: n }) => this.worker.postMessage({ action: "init", data: { writable: n } }, [n]));
|
|
269
|
+
m(this, "push", (n) => this.worker.postMessage({ action: "push", data: n }));
|
|
270
|
+
m(this, "setCut", async (n) => this.worker.postMessage({ action: "setCut", data: n }));
|
|
271
|
+
m(this, "setPause", (n) => this.worker.postMessage({ action: "setPause", data: n }));
|
|
272
|
+
m(this, "destroy", () => {
|
|
274
273
|
this.worker.postMessage({ action: "destroy", data: {} }), this.worker.terminate();
|
|
275
274
|
});
|
|
276
275
|
}
|
|
277
276
|
}
|
|
278
277
|
const q = (h) => {
|
|
279
|
-
const
|
|
280
|
-
return
|
|
278
|
+
const n = h.toLowerCase();
|
|
279
|
+
return n.includes(".m3u8") || n.includes("hls") || n.includes("master.m3u8") || n.match(/index\d*\.m3u8/) ? "hls" : n.includes(".mpd") || n.includes("dash") ? "dash" : n.startsWith("rtmp://") || n.startsWith("rtmps://") ? "rtmp" : n.includes(".flv") || n.includes("flv") && !n.includes("flash") ? "flv" : "unknown";
|
|
281
280
|
}, R = (h) => {
|
|
282
|
-
const
|
|
283
|
-
for (const a of
|
|
281
|
+
const n = (h == null ? void 0 : h.getTracks()) || [];
|
|
282
|
+
for (const a of n)
|
|
284
283
|
a.stop();
|
|
285
|
-
},
|
|
286
|
-
const h = new MediaStreamTrackGenerator({ kind: "video" }),
|
|
287
|
-
return a.init({ writable: h.writable }), { worker: a, stream:
|
|
288
|
-
a.destroy(), R(
|
|
284
|
+
}, x = () => {
|
|
285
|
+
const h = new MediaStreamTrackGenerator({ kind: "video" }), n = new MediaStream([h]), a = new z();
|
|
286
|
+
return a.init({ writable: h.writable }), { worker: a, stream: n, destroy: () => {
|
|
287
|
+
a.destroy(), R(n);
|
|
289
288
|
} };
|
|
290
289
|
};
|
|
291
290
|
class $ {
|
|
292
291
|
constructor() {
|
|
293
|
-
|
|
294
|
-
|
|
292
|
+
m(this, "resolvesMap", /* @__PURE__ */ new Map());
|
|
293
|
+
m(this, "index", 0);
|
|
295
294
|
/**
|
|
296
295
|
*
|
|
297
296
|
* @param eventKey 唯一key
|
|
@@ -299,48 +298,48 @@ class $ {
|
|
|
299
298
|
* @param timeout 超时时间 ms
|
|
300
299
|
* @returns
|
|
301
300
|
*/
|
|
302
|
-
|
|
301
|
+
m(this, "add", (n, a = () => !1, u = 0) => new Promise((r) => {
|
|
303
302
|
var t, e;
|
|
304
303
|
if (a()) return r(!0);
|
|
305
|
-
this.resolvesMap.has(
|
|
306
|
-
const
|
|
304
|
+
this.resolvesMap.has(n) || this.resolvesMap.set(n, /* @__PURE__ */ new Map()), this.index++;
|
|
305
|
+
const o = `${this.index}`;
|
|
307
306
|
if (u = Math.max(0, u), u === 0) {
|
|
308
|
-
(t = this.resolvesMap.get(
|
|
307
|
+
(t = this.resolvesMap.get(n)) == null || t.set(o, { resolve: r, timer: 0 });
|
|
309
308
|
return;
|
|
310
309
|
}
|
|
311
310
|
const i = window.setTimeout(() => {
|
|
312
|
-
this.emit(
|
|
311
|
+
this.emit(n);
|
|
313
312
|
}, u);
|
|
314
|
-
(e = this.resolvesMap.get(
|
|
313
|
+
(e = this.resolvesMap.get(n)) == null || e.set(o, { resolve: r, timer: i });
|
|
315
314
|
}));
|
|
316
|
-
|
|
317
|
-
const a = this.resolvesMap.get(
|
|
315
|
+
m(this, "emit", async (n) => {
|
|
316
|
+
const a = this.resolvesMap.get(n);
|
|
318
317
|
if (!a) return;
|
|
319
318
|
const u = [...a.keys()];
|
|
320
319
|
for (const r of u) {
|
|
321
|
-
const
|
|
322
|
-
|
|
320
|
+
const o = a.get(r);
|
|
321
|
+
o && (clearTimeout(o.timer), o.resolve(), a.delete(r));
|
|
323
322
|
}
|
|
324
323
|
});
|
|
325
324
|
}
|
|
326
325
|
}
|
|
327
326
|
const Y = (h) => {
|
|
328
|
-
const
|
|
329
|
-
let a = 0, u, r,
|
|
330
|
-
u =
|
|
327
|
+
const n = new DataView(h.buffer);
|
|
328
|
+
let a = 0, u, r, o;
|
|
329
|
+
u = n.getUint32(a, !1), a += 4;
|
|
331
330
|
{
|
|
332
|
-
const i =
|
|
331
|
+
const i = n.getUint8(a), t = i >> 7 & 1, e = i >> 5 & 3, s = i & 31;
|
|
333
332
|
r = { forbidden_zero_bit: t, nal_ref_idc: e, nal_unit_type: s }, a += 1;
|
|
334
333
|
}
|
|
335
334
|
{
|
|
336
335
|
const i = u - 1;
|
|
337
|
-
|
|
336
|
+
o = new Uint8Array(n.buffer.slice(a, a + i));
|
|
338
337
|
}
|
|
339
|
-
return { size: u, header: r, data:
|
|
338
|
+
return { size: u, header: r, data: o };
|
|
340
339
|
};
|
|
341
340
|
var P, U;
|
|
342
|
-
class
|
|
343
|
-
constructor(
|
|
341
|
+
class v {
|
|
342
|
+
constructor(n = {}) {
|
|
344
343
|
J(this, P, {
|
|
345
344
|
timeout: 5 * 1e3,
|
|
346
345
|
check: !1
|
|
@@ -351,31 +350,31 @@ class C {
|
|
|
351
350
|
* @param input string | URL | Request
|
|
352
351
|
* @param init RequestInit
|
|
353
352
|
*/
|
|
354
|
-
|
|
353
|
+
m(this, "check", (n, a) => new Promise(async (u, r) => {
|
|
355
354
|
var i;
|
|
356
355
|
this.stop(), H(this, U, new AbortController());
|
|
357
|
-
const
|
|
356
|
+
const o = window.setTimeout(() => {
|
|
358
357
|
var t;
|
|
359
358
|
(t = I(this, U)) == null || t.abort("Timeout."), r({ status: "timeout", reason: "" });
|
|
360
359
|
}, I(this, P).timeout);
|
|
361
360
|
try {
|
|
362
|
-
const t = await fetch(
|
|
361
|
+
const t = await fetch(n, { ...a, method: "HEAD", signal: (i = I(this, U)) == null ? void 0 : i.signal });
|
|
363
362
|
t.status === 200 ? u({ status: "successed", reason: "" }) : r({ status: "failed", reason: `${t.status}` });
|
|
364
363
|
} catch (t) {
|
|
365
364
|
r({ status: "error", reason: t.message });
|
|
366
365
|
}
|
|
367
|
-
clearTimeout(
|
|
366
|
+
clearTimeout(o);
|
|
368
367
|
}));
|
|
369
368
|
/**
|
|
370
369
|
*
|
|
371
370
|
* @param input string | URL | Request
|
|
372
371
|
* @param init RequestInit
|
|
373
372
|
*/
|
|
374
|
-
|
|
375
|
-
var
|
|
373
|
+
m(this, "request", async (n, a) => new Promise(async (u, r) => {
|
|
374
|
+
var o;
|
|
376
375
|
try {
|
|
377
|
-
I(this, P).check && await this.check(
|
|
378
|
-
const i = await fetch(
|
|
376
|
+
I(this, P).check && await this.check(n, a), H(this, U, new AbortController());
|
|
377
|
+
const i = await fetch(n, { ...a, signal: (o = I(this, U)) == null ? void 0 : o.signal });
|
|
379
378
|
u(i);
|
|
380
379
|
} catch (i) {
|
|
381
380
|
this.stop(), r(i);
|
|
@@ -384,39 +383,39 @@ class C {
|
|
|
384
383
|
/**
|
|
385
384
|
* stop
|
|
386
385
|
*/
|
|
387
|
-
|
|
388
|
-
var
|
|
389
|
-
((
|
|
386
|
+
m(this, "stop", () => {
|
|
387
|
+
var n;
|
|
388
|
+
((n = I(this, U)) == null ? void 0 : n.signal.aborted) === !1 && I(this, U).abort("Actively stop.");
|
|
390
389
|
});
|
|
391
|
-
H(this, P, { ...I(this, P), ...
|
|
390
|
+
H(this, P, { ...I(this, P), ...n });
|
|
392
391
|
}
|
|
393
392
|
}
|
|
394
393
|
P = new WeakMap(), U = new WeakMap();
|
|
395
394
|
class et {
|
|
396
|
-
constructor(
|
|
397
|
-
|
|
395
|
+
constructor(n = {}) {
|
|
396
|
+
m(this, "option", {
|
|
398
397
|
debug: !1,
|
|
399
398
|
frameTrack: !1
|
|
400
399
|
});
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
400
|
+
m(this, "prFetch", new v());
|
|
401
|
+
m(this, "prResolves", new $());
|
|
402
|
+
m(this, "url", "");
|
|
403
|
+
m(this, "demuxerWorker");
|
|
404
|
+
m(this, "decoderWorker");
|
|
405
|
+
m(this, "audioPlayer");
|
|
406
|
+
m(this, "renderWorker");
|
|
407
|
+
m(this, "stream");
|
|
408
|
+
m(this, "on", { demuxer: {}, decoder: {} });
|
|
409
|
+
m(this, "cutRenders", /* @__PURE__ */ new Map());
|
|
411
410
|
// @ts-ignore
|
|
412
|
-
|
|
411
|
+
m(this, "trackGenerator");
|
|
413
412
|
/**
|
|
414
413
|
* 开始播放
|
|
415
414
|
* @param url : string
|
|
416
415
|
*/
|
|
417
|
-
|
|
418
|
-
this.stop(), this.url =
|
|
419
|
-
const a = q(
|
|
416
|
+
m(this, "start", async (n) => {
|
|
417
|
+
this.stop(), this.url = n;
|
|
418
|
+
const a = q(n);
|
|
420
419
|
if (a === "unknown") throw new Error("This address cannot be parsed.");
|
|
421
420
|
switch (this.init(a), a) {
|
|
422
421
|
case "flv":
|
|
@@ -430,117 +429,117 @@ class et {
|
|
|
430
429
|
/**
|
|
431
430
|
* 停止
|
|
432
431
|
*/
|
|
433
|
-
|
|
434
|
-
var a, u, r,
|
|
432
|
+
m(this, "stop", async () => {
|
|
433
|
+
var a, u, r, o, i;
|
|
435
434
|
try {
|
|
436
435
|
clearInterval(this.hls.getSegmentsTimer), this.prFetch.stop();
|
|
437
436
|
} catch (t) {
|
|
438
437
|
console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", "------->pr-player: error", t);
|
|
439
438
|
}
|
|
440
439
|
(a = this.demuxerWorker) == null || a.destroy(), (u = this.decoderWorker) == null || u.destroy(), (r = this.renderWorker) == null || r.destroy();
|
|
441
|
-
const
|
|
442
|
-
for (const t of
|
|
443
|
-
(
|
|
440
|
+
const n = [...this.cutRenders.keys()];
|
|
441
|
+
for (const t of n)
|
|
442
|
+
(o = this.cutRenders.get(t)) == null || o.worker.destroy(), this.cutRenders.delete(t);
|
|
444
443
|
R(this.stream), (i = this.audioPlayer) == null || i.destroy();
|
|
445
444
|
});
|
|
446
445
|
/**
|
|
447
446
|
* 获取媒体流
|
|
448
447
|
*/
|
|
449
|
-
|
|
448
|
+
m(this, "getStream", () => this.stream);
|
|
450
449
|
/**
|
|
451
450
|
* 设置暂停
|
|
452
451
|
* @param pause: boolean
|
|
453
452
|
*/
|
|
454
|
-
|
|
453
|
+
m(this, "setPause", (n) => {
|
|
455
454
|
var a;
|
|
456
|
-
(a = this.renderWorker) == null || a.setPause(
|
|
455
|
+
(a = this.renderWorker) == null || a.setPause(n);
|
|
457
456
|
});
|
|
458
457
|
/**
|
|
459
458
|
* 是否静音 默认为true
|
|
460
459
|
* @param state?: boolean
|
|
461
460
|
*/
|
|
462
|
-
|
|
461
|
+
m(this, "setMute", (n) => {
|
|
463
462
|
var a, u;
|
|
464
|
-
return (u = (a = this.audioPlayer) == null ? void 0 : a.prAudioStream) == null ? void 0 : u.setMute(
|
|
463
|
+
return (u = (a = this.audioPlayer) == null ? void 0 : a.prAudioStream) == null ? void 0 : u.setMute(n);
|
|
465
464
|
});
|
|
466
465
|
/**
|
|
467
466
|
* 是否开启追帧
|
|
468
467
|
* @param frameTrack?: boolean
|
|
469
468
|
*/
|
|
470
|
-
|
|
469
|
+
m(this, "setFrameTrack", (n) => {
|
|
471
470
|
var a;
|
|
472
|
-
(a = this.decoderWorker) == null || a.setFrameTrack(
|
|
471
|
+
(a = this.decoderWorker) == null || a.setFrameTrack(n);
|
|
473
472
|
});
|
|
474
473
|
/**
|
|
475
474
|
* 是否已准备好
|
|
476
475
|
*/
|
|
477
|
-
|
|
478
|
-
const
|
|
476
|
+
m(this, "isReady", () => {
|
|
477
|
+
const n = () => {
|
|
479
478
|
var a;
|
|
480
479
|
return ((a = this.stream) == null ? void 0 : a.active) === !0;
|
|
481
480
|
};
|
|
482
|
-
return this.prResolves.add("isReady",
|
|
481
|
+
return this.prResolves.add("isReady", n);
|
|
483
482
|
});
|
|
484
|
-
|
|
483
|
+
m(this, "cut", {
|
|
485
484
|
/**
|
|
486
485
|
* 创建剪切
|
|
487
486
|
*/
|
|
488
|
-
create: (
|
|
489
|
-
let u = this.cutRenders.get(
|
|
490
|
-
return u ? (u.worker.setCut(a), u.worker.setPause(!1), u) : (u =
|
|
487
|
+
create: (n, a) => {
|
|
488
|
+
let u = this.cutRenders.get(n);
|
|
489
|
+
return u ? (u.worker.setCut(a), u.worker.setPause(!1), u) : (u = x(), u.worker.setCut(a), this.cutRenders.set(n, u), u);
|
|
491
490
|
},
|
|
492
491
|
/**
|
|
493
492
|
* 获取媒体流
|
|
494
493
|
*/
|
|
495
|
-
getStream: (
|
|
494
|
+
getStream: (n) => {
|
|
496
495
|
var a;
|
|
497
|
-
return (a = this.cutRenders.get(
|
|
496
|
+
return (a = this.cutRenders.get(n)) == null ? void 0 : a.stream;
|
|
498
497
|
},
|
|
499
498
|
/**
|
|
500
499
|
* 设置暂停
|
|
501
500
|
* @param pause: boolean
|
|
502
501
|
*/
|
|
503
|
-
setPause: (
|
|
502
|
+
setPause: (n, a) => {
|
|
504
503
|
var u;
|
|
505
|
-
(u = this.cutRenders.get(
|
|
504
|
+
(u = this.cutRenders.get(n)) == null || u.worker.setPause(a);
|
|
506
505
|
},
|
|
507
506
|
/**
|
|
508
507
|
* 移除剪切
|
|
509
508
|
*/
|
|
510
|
-
remove: (
|
|
509
|
+
remove: (n) => {
|
|
511
510
|
var a;
|
|
512
|
-
(a = this.cutRenders.get(
|
|
511
|
+
(a = this.cutRenders.get(n)) == null || a.destroy(), this.cutRenders.delete(n);
|
|
513
512
|
}
|
|
514
513
|
});
|
|
515
514
|
/**
|
|
516
515
|
* 初始化
|
|
517
516
|
*/
|
|
518
|
-
|
|
519
|
-
this.initDecoder(
|
|
517
|
+
m(this, "init", (n) => {
|
|
518
|
+
this.initDecoder(n), this.initRender(), this.initDemuxer(n), this.audioPlayer = new W(), this.audioPlayer.init();
|
|
520
519
|
});
|
|
521
520
|
/**
|
|
522
521
|
* 初始化解复器
|
|
523
522
|
*/
|
|
524
|
-
|
|
525
|
-
this.demuxerWorker = new
|
|
523
|
+
m(this, "initDemuxer", (n) => {
|
|
524
|
+
this.demuxerWorker = new V(), this.demuxerWorker.init(n), this.demuxerWorker.on.debug = (a) => {
|
|
526
525
|
this.option.debug && console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", "------->pr-player: debug", a);
|
|
527
526
|
}, this.demuxerWorker.on.info = (a) => {
|
|
528
527
|
this.option.debug && console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", "------->pr-player: info", a), this.on.demuxer.info && this.on.demuxer.info(a);
|
|
529
528
|
}, this.demuxerWorker.on.config = (a) => {
|
|
530
|
-
var r,
|
|
529
|
+
var r, o;
|
|
531
530
|
this.option.debug && console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", "------->pr-player: config", a), this.on.demuxer.config && this.on.demuxer.config(a);
|
|
532
531
|
const { kind: u } = a;
|
|
533
532
|
switch (u) {
|
|
534
533
|
case "audio":
|
|
535
534
|
{
|
|
536
535
|
const { codec: i, sampleRate: t, numberOfChannels: e } = a;
|
|
537
|
-
(r = this.decoderWorker) == null || r.
|
|
536
|
+
(r = this.decoderWorker) == null || r.initAudio({ codec: i, sampleRate: t, numberOfChannels: e });
|
|
538
537
|
}
|
|
539
538
|
break;
|
|
540
539
|
case "video":
|
|
541
540
|
{
|
|
542
541
|
const { codec: i, description: t } = a;
|
|
543
|
-
(
|
|
542
|
+
(o = this.decoderWorker) == null || o.initVideo({ codec: i, description: t });
|
|
544
543
|
}
|
|
545
544
|
break;
|
|
546
545
|
}
|
|
@@ -550,19 +549,14 @@ class et {
|
|
|
550
549
|
switch (u) {
|
|
551
550
|
case "audio":
|
|
552
551
|
{
|
|
553
|
-
const { type: r, dts:
|
|
554
|
-
this.decoderWorker.
|
|
552
|
+
const { type: r, dts: o, data: i } = a, t = o * 1e3;
|
|
553
|
+
this.decoderWorker.push({ kind: u, init: { type: r, timestamp: t, data: i } });
|
|
555
554
|
}
|
|
556
555
|
break;
|
|
557
556
|
case "video":
|
|
558
557
|
{
|
|
559
|
-
const { type: r, dts:
|
|
560
|
-
this.decoderWorker.
|
|
561
|
-
for (const s of t) {
|
|
562
|
-
if (s.byteLength <= 4) continue;
|
|
563
|
-
const { header: l, data: c } = Y(s), { nal_unit_type: d } = l;
|
|
564
|
-
d === 6 && this.on.demuxer.sei && this.on.demuxer.sei(c);
|
|
565
|
-
}
|
|
558
|
+
const { type: r, dts: o, data: i, nalus: t = [] } = a, e = o * 1e3;
|
|
559
|
+
this.decoderWorker.push({ kind: u, init: { type: r, timestamp: e, data: i }, nalus: t });
|
|
566
560
|
}
|
|
567
561
|
break;
|
|
568
562
|
}
|
|
@@ -571,8 +565,8 @@ class et {
|
|
|
571
565
|
/**
|
|
572
566
|
* 初始化解码器
|
|
573
567
|
*/
|
|
574
|
-
|
|
575
|
-
this.decoderWorker = new N(), this.decoderWorker.init(
|
|
568
|
+
m(this, "initDecoder", (n) => {
|
|
569
|
+
this.decoderWorker = new N(), this.decoderWorker.init(n), this.decoderWorker.on.debug = (a) => {
|
|
576
570
|
this.option.debug && console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", "------->pr-player: debug", a);
|
|
577
571
|
}, this.decoderWorker.on.audio.decode = (a) => {
|
|
578
572
|
var u;
|
|
@@ -580,34 +574,40 @@ class et {
|
|
|
580
574
|
}, this.decoderWorker.on.audio.error = (a) => {
|
|
581
575
|
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);
|
|
582
576
|
}, this.decoderWorker.on.video.decode = async (a) => {
|
|
583
|
-
var r,
|
|
577
|
+
var r, o;
|
|
584
578
|
(r = this.renderWorker) == null || r.push(a);
|
|
585
579
|
const u = [...this.cutRenders.keys()];
|
|
586
580
|
for (const i of u)
|
|
587
|
-
(
|
|
581
|
+
(o = this.cutRenders.get(i)) == null || o.worker.push(a);
|
|
588
582
|
this.on.decoder.video && this.on.decoder.video(a), a.bitmap.close();
|
|
589
583
|
}, this.decoderWorker.on.video.error = (a) => {
|
|
590
584
|
this.stop(), this.on.error && this.on.error(a);
|
|
585
|
+
}, this.decoderWorker.on.nalus = async (a) => {
|
|
586
|
+
for (const u of a) {
|
|
587
|
+
if (u.byteLength <= 4) continue;
|
|
588
|
+
const { header: r, data: o } = Y(u), { nal_unit_type: i } = r;
|
|
589
|
+
i === 6 && this.on.decoder.sei && this.on.decoder.sei(o);
|
|
590
|
+
}
|
|
591
591
|
};
|
|
592
592
|
});
|
|
593
593
|
/**
|
|
594
594
|
* 初始化渲染器
|
|
595
595
|
*/
|
|
596
|
-
|
|
597
|
-
const { worker:
|
|
598
|
-
this.renderWorker =
|
|
596
|
+
m(this, "initRender", () => {
|
|
597
|
+
const { worker: n, stream: a } = x();
|
|
598
|
+
this.renderWorker = n, this.stream = a, this.renderWorker.setPause(!1);
|
|
599
599
|
});
|
|
600
|
-
|
|
600
|
+
m(this, "flv", {
|
|
601
601
|
start: async () => {
|
|
602
|
-
var
|
|
602
|
+
var n, a;
|
|
603
603
|
try {
|
|
604
604
|
let u = await this.prFetch.request(this.url);
|
|
605
|
-
if (u.status !== 200 && (await new Promise((
|
|
606
|
-
const r = (
|
|
605
|
+
if (u.status !== 200 && (await new Promise((o) => setTimeout(() => o(!0), 500)), u = await this.prFetch.request(this.url)), u.status !== 200 && (await new Promise((o) => setTimeout(() => o(!0), 500)), u = await this.prFetch.request(this.url)), u.status !== 200) throw new Error("request is error.");
|
|
606
|
+
const r = (n = u.body) == null ? void 0 : n.getReader();
|
|
607
607
|
if (!r) throw new Error("reader is error.");
|
|
608
608
|
for (; ; ) {
|
|
609
|
-
const { done:
|
|
610
|
-
if (i && ((a = this.demuxerWorker) == null || a.push(i)),
|
|
609
|
+
const { done: o, value: i } = await r.read();
|
|
610
|
+
if (i && ((a = this.demuxerWorker) == null || a.push(i)), o) break;
|
|
611
611
|
}
|
|
612
612
|
} catch (u) {
|
|
613
613
|
if ((u == null ? void 0 : u.name) !== "AbortError") throw Error(u);
|
|
@@ -615,34 +615,34 @@ class et {
|
|
|
615
615
|
}
|
|
616
616
|
}
|
|
617
617
|
});
|
|
618
|
-
|
|
618
|
+
m(this, "hls", {
|
|
619
619
|
isLive: !1,
|
|
620
620
|
urls: [],
|
|
621
621
|
url: "",
|
|
622
622
|
getSegmentsTimer: 0,
|
|
623
|
-
parse: async (
|
|
624
|
-
const a = new TextDecoder("utf-8").decode(
|
|
623
|
+
parse: async (n) => {
|
|
624
|
+
const a = new TextDecoder("utf-8").decode(n).split(`
|
|
625
625
|
`).map((e) => e.replace("\r", "")), u = this.url.substring(0, this.url.lastIndexOf("/") + 1);
|
|
626
|
-
let r = 4,
|
|
626
|
+
let r = 4, o = 0, i = !1;
|
|
627
627
|
const t = [];
|
|
628
628
|
for (const e of a)
|
|
629
|
-
e.startsWith("#EXTINF:") ? r = parseFloat(e.split(":")[1].split(",")[0]) : e.startsWith("#EXT-X-TARGETDURATION:") ?
|
|
629
|
+
e.startsWith("#EXTINF:") ? r = 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({
|
|
630
630
|
url: e.startsWith("http") ? e : u + e,
|
|
631
631
|
duration: r,
|
|
632
632
|
isLive: i
|
|
633
633
|
});
|
|
634
|
-
return { baseUrl: u, targetDuration:
|
|
634
|
+
return { baseUrl: u, targetDuration: o, isLive: i, segments: t };
|
|
635
635
|
},
|
|
636
636
|
getSegments: async () => {
|
|
637
|
-
var
|
|
637
|
+
var n;
|
|
638
638
|
try {
|
|
639
|
-
const a = new
|
|
639
|
+
const a = new v();
|
|
640
640
|
let u = await a.request(this.url);
|
|
641
|
-
if (u.status !== 200 && (await new Promise((
|
|
642
|
-
const r = (
|
|
641
|
+
if (u.status !== 200 && (await new Promise((o) => setTimeout(() => o(!0), 500)), u = await a.request(this.url)), u.status !== 200 && (await new Promise((o) => setTimeout(() => o(!0), 500)), u = await a.request(this.url)), u.status !== 200) throw new Error("request is error.");
|
|
642
|
+
const r = (n = u.body) == null ? void 0 : n.getReader();
|
|
643
643
|
if (!r) throw new Error("reader is error.");
|
|
644
644
|
for (; ; ) {
|
|
645
|
-
const { done:
|
|
645
|
+
const { done: o, value: i } = await r.read();
|
|
646
646
|
if (i) {
|
|
647
647
|
const t = await this.hls.parse(i), { segments: e = [], isLive: s = !1 } = t;
|
|
648
648
|
this.hls.isLive = s, s === !1 && (this.option.frameTrack = !1);
|
|
@@ -650,34 +650,34 @@ class et {
|
|
|
650
650
|
const c = l.findIndex((d) => d === this.hls.url);
|
|
651
651
|
c !== -1 && (l = l.slice(c + 1)), this.hls.urls = l;
|
|
652
652
|
}
|
|
653
|
-
if (
|
|
653
|
+
if (o) break;
|
|
654
654
|
}
|
|
655
655
|
} catch (a) {
|
|
656
656
|
this.on.error && this.on.error(a);
|
|
657
657
|
}
|
|
658
658
|
},
|
|
659
659
|
start: async () => {
|
|
660
|
-
var
|
|
660
|
+
var n, a, u;
|
|
661
661
|
try {
|
|
662
|
-
for (await this.hls.getSegments(), this.hls.getSegmentsTimer = window.setInterval(this.hls.getSegments, 500), this.hls.isLive === !1 && (clearInterval(this.hls.getSegmentsTimer), (
|
|
662
|
+
for (await this.hls.getSegments(), this.hls.getSegmentsTimer = window.setInterval(this.hls.getSegments, 500), this.hls.isLive === !1 && (clearInterval(this.hls.getSegmentsTimer), (n = this.decoderWorker) == null ? void 0 : n.setFrameTrack(!1)); ; ) {
|
|
663
663
|
const r = this.hls.urls.shift();
|
|
664
664
|
if (r) {
|
|
665
665
|
this.hls.url = r;
|
|
666
|
-
const
|
|
667
|
-
if (!
|
|
666
|
+
const o = (a = (await this.prFetch.request(r)).body) == null ? void 0 : a.getReader();
|
|
667
|
+
if (!o) throw new Error("segment reader is error.");
|
|
668
668
|
for (; ; ) {
|
|
669
|
-
const { done: i, value: t } = await
|
|
669
|
+
const { done: i, value: t } = await o.read();
|
|
670
670
|
if (t && ((u = this.demuxerWorker) == null || u.push(t)), i) break;
|
|
671
671
|
}
|
|
672
672
|
} else
|
|
673
|
-
await new Promise((
|
|
673
|
+
await new Promise((o) => setTimeout(() => o(!0), 300));
|
|
674
674
|
}
|
|
675
675
|
} catch (r) {
|
|
676
676
|
if ((r == null ? void 0 : r.name) !== "AbortError") throw Error(r);
|
|
677
677
|
}
|
|
678
678
|
}
|
|
679
679
|
});
|
|
680
|
-
const { debug: a = !1 } =
|
|
680
|
+
const { debug: a = !1 } = n;
|
|
681
681
|
this.option.debug = a;
|
|
682
682
|
}
|
|
683
683
|
}
|
|
@@ -685,9 +685,9 @@ var commonjsGlobal = typeof globalThis < "u" ? globalThis : typeof window < "u"
|
|
|
685
685
|
function requireAspromise() {
|
|
686
686
|
if (hasRequiredAspromise) return aspromise;
|
|
687
687
|
hasRequiredAspromise = 1, aspromise = h;
|
|
688
|
-
function h(
|
|
689
|
-
for (var u = new Array(arguments.length - 1), r = 0,
|
|
690
|
-
u[r++] = arguments[
|
|
688
|
+
function h(n, a) {
|
|
689
|
+
for (var u = new Array(arguments.length - 1), r = 0, o = 2, i = !0; o < arguments.length; )
|
|
690
|
+
u[r++] = arguments[o++];
|
|
691
691
|
return new Promise(function(e, s) {
|
|
692
692
|
u[r] = function(c) {
|
|
693
693
|
if (i)
|
|
@@ -700,7 +700,7 @@ function requireAspromise() {
|
|
|
700
700
|
}
|
|
701
701
|
};
|
|
702
702
|
try {
|
|
703
|
-
|
|
703
|
+
n.apply(a || null, u);
|
|
704
704
|
} catch (l) {
|
|
705
705
|
i && (i = !1, s(l));
|
|
706
706
|
}
|
|
@@ -711,8 +711,8 @@ function requireAspromise() {
|
|
|
711
711
|
var base64 = {}, hasRequiredBase64;
|
|
712
712
|
function requireBase64() {
|
|
713
713
|
return hasRequiredBase64 || (hasRequiredBase64 = 1, function(h) {
|
|
714
|
-
var
|
|
715
|
-
|
|
714
|
+
var n = h;
|
|
715
|
+
n.length = function(t) {
|
|
716
716
|
var e = t.length;
|
|
717
717
|
if (!e)
|
|
718
718
|
return 0;
|
|
@@ -722,7 +722,7 @@ function requireBase64() {
|
|
|
722
722
|
};
|
|
723
723
|
for (var a = new Array(64), u = new Array(123), r = 0; r < 64; )
|
|
724
724
|
u[a[r] = r < 26 ? r + 65 : r < 52 ? r + 71 : r < 62 ? r - 4 : r - 59 | 43] = r++;
|
|
725
|
-
|
|
725
|
+
n.encode = function(t, e, s) {
|
|
726
726
|
for (var l = null, c = [], d = 0, p = 0, f; e < s; ) {
|
|
727
727
|
var w = t[e++];
|
|
728
728
|
switch (p) {
|
|
@@ -740,14 +740,14 @@ function requireBase64() {
|
|
|
740
740
|
}
|
|
741
741
|
return p && (c[d++] = a[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));
|
|
742
742
|
};
|
|
743
|
-
var
|
|
744
|
-
|
|
743
|
+
var o = "invalid encoding";
|
|
744
|
+
n.decode = function(t, e, s) {
|
|
745
745
|
for (var l = s, c = 0, d, p = 0; p < t.length; ) {
|
|
746
746
|
var f = t.charCodeAt(p++);
|
|
747
747
|
if (f === 61 && c > 1)
|
|
748
748
|
break;
|
|
749
749
|
if ((f = u[f]) === void 0)
|
|
750
|
-
throw Error(
|
|
750
|
+
throw Error(o);
|
|
751
751
|
switch (c) {
|
|
752
752
|
case 0:
|
|
753
753
|
d = f, c = 1;
|
|
@@ -764,9 +764,9 @@ function requireBase64() {
|
|
|
764
764
|
}
|
|
765
765
|
}
|
|
766
766
|
if (c === 1)
|
|
767
|
-
throw Error(
|
|
767
|
+
throw Error(o);
|
|
768
768
|
return s - l;
|
|
769
|
-
},
|
|
769
|
+
}, n.test = function(t) {
|
|
770
770
|
return /^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(t);
|
|
771
771
|
};
|
|
772
772
|
}(base64)), base64;
|
|
@@ -789,16 +789,16 @@ function requireEventemitter() {
|
|
|
789
789
|
else if (u === void 0)
|
|
790
790
|
this._listeners[a] = [];
|
|
791
791
|
else
|
|
792
|
-
for (var r = this._listeners[a],
|
|
793
|
-
r[
|
|
792
|
+
for (var r = this._listeners[a], o = 0; o < r.length; )
|
|
793
|
+
r[o].fn === u ? r.splice(o, 1) : ++o;
|
|
794
794
|
return this;
|
|
795
795
|
}, h.prototype.emit = function(a) {
|
|
796
796
|
var u = this._listeners[a];
|
|
797
797
|
if (u) {
|
|
798
|
-
for (var r = [],
|
|
799
|
-
r.push(arguments[
|
|
800
|
-
for (
|
|
801
|
-
u[
|
|
798
|
+
for (var r = [], o = 1; o < arguments.length; )
|
|
799
|
+
r.push(arguments[o++]);
|
|
800
|
+
for (o = 0; o < u.length; )
|
|
801
|
+
u[o].fn.apply(u[o++].ctx, r);
|
|
802
802
|
}
|
|
803
803
|
return this;
|
|
804
804
|
}, eventemitter;
|
|
@@ -807,7 +807,7 @@ var float, hasRequiredFloat;
|
|
|
807
807
|
function requireFloat() {
|
|
808
808
|
if (hasRequiredFloat) return float;
|
|
809
809
|
hasRequiredFloat = 1, float = h(h);
|
|
810
|
-
function h(
|
|
810
|
+
function h(o) {
|
|
811
811
|
return typeof Float32Array < "u" ? function() {
|
|
812
812
|
var i = new Float32Array([-0]), t = new Uint8Array(i.buffer), e = t[3] === 128;
|
|
813
813
|
function s(p, f, w) {
|
|
@@ -816,14 +816,14 @@ function requireFloat() {
|
|
|
816
816
|
function l(p, f, w) {
|
|
817
817
|
i[0] = p, f[w] = t[3], f[w + 1] = t[2], f[w + 2] = t[1], f[w + 3] = t[0];
|
|
818
818
|
}
|
|
819
|
-
|
|
819
|
+
o.writeFloatLE = e ? s : l, o.writeFloatBE = e ? l : s;
|
|
820
820
|
function c(p, f) {
|
|
821
821
|
return t[0] = p[f], t[1] = p[f + 1], t[2] = p[f + 2], t[3] = p[f + 3], i[0];
|
|
822
822
|
}
|
|
823
823
|
function d(p, f) {
|
|
824
824
|
return t[3] = p[f], t[2] = p[f + 1], t[1] = p[f + 2], t[0] = p[f + 3], i[0];
|
|
825
825
|
}
|
|
826
|
-
|
|
826
|
+
o.readFloatLE = e ? c : d, o.readFloatBE = e ? d : c;
|
|
827
827
|
}() : function() {
|
|
828
828
|
function i(e, s, l, c) {
|
|
829
829
|
var d = s < 0 ? 1 : 0;
|
|
@@ -846,12 +846,12 @@ function requireFloat() {
|
|
|
846
846
|
e((d << 31 | p + 127 << 23 | f) >>> 0, l, c);
|
|
847
847
|
}
|
|
848
848
|
}
|
|
849
|
-
|
|
849
|
+
o.writeFloatLE = i.bind(null, n), o.writeFloatBE = i.bind(null, a);
|
|
850
850
|
function t(e, s, l) {
|
|
851
851
|
var c = e(s, l), d = (c >> 31) * 2 + 1, p = c >>> 23 & 255, f = c & 8388607;
|
|
852
852
|
return p === 255 ? f ? NaN : d * (1 / 0) : p === 0 ? d * 1401298464324817e-60 * f : d * Math.pow(2, p - 150) * (f + 8388608);
|
|
853
853
|
}
|
|
854
|
-
|
|
854
|
+
o.readFloatLE = t.bind(null, u), o.readFloatBE = t.bind(null, r);
|
|
855
855
|
}(), typeof Float64Array < "u" ? function() {
|
|
856
856
|
var i = new Float64Array([-0]), t = new Uint8Array(i.buffer), e = t[7] === 128;
|
|
857
857
|
function s(p, f, w) {
|
|
@@ -860,14 +860,14 @@ function requireFloat() {
|
|
|
860
860
|
function l(p, f, w) {
|
|
861
861
|
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];
|
|
862
862
|
}
|
|
863
|
-
|
|
863
|
+
o.writeDoubleLE = e ? s : l, o.writeDoubleBE = e ? l : s;
|
|
864
864
|
function c(p, f) {
|
|
865
865
|
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];
|
|
866
866
|
}
|
|
867
867
|
function d(p, f) {
|
|
868
868
|
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];
|
|
869
869
|
}
|
|
870
|
-
|
|
870
|
+
o.readDoubleLE = e ? c : d, o.readDoubleBE = e ? d : c;
|
|
871
871
|
}() : function() {
|
|
872
872
|
function i(e, s, l, c, d, p) {
|
|
873
873
|
var f = c < 0 ? 1 : 0;
|
|
@@ -893,25 +893,25 @@ function requireFloat() {
|
|
|
893
893
|
}
|
|
894
894
|
}
|
|
895
895
|
}
|
|
896
|
-
|
|
896
|
+
o.writeDoubleLE = i.bind(null, n, 0, 4), o.writeDoubleBE = i.bind(null, a, 4, 0);
|
|
897
897
|
function t(e, s, l, c, d) {
|
|
898
|
-
var p = e(c, d + s), f = e(c, d + l), w = (f >> 31) * 2 + 1, b = f >>> 20 & 2047,
|
|
899
|
-
return b === 2047 ?
|
|
898
|
+
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;
|
|
899
|
+
return b === 2047 ? g ? NaN : w * (1 / 0) : b === 0 ? w * 5e-324 * g : w * Math.pow(2, b - 1075) * (g + 4503599627370496);
|
|
900
900
|
}
|
|
901
|
-
|
|
902
|
-
}(),
|
|
901
|
+
o.readDoubleLE = t.bind(null, u, 0, 4), o.readDoubleBE = t.bind(null, r, 4, 0);
|
|
902
|
+
}(), o;
|
|
903
903
|
}
|
|
904
|
-
function o
|
|
905
|
-
i[t] =
|
|
904
|
+
function n(o, i, t) {
|
|
905
|
+
i[t] = o & 255, i[t + 1] = o >>> 8 & 255, i[t + 2] = o >>> 16 & 255, i[t + 3] = o >>> 24;
|
|
906
906
|
}
|
|
907
|
-
function a(
|
|
908
|
-
i[t] =
|
|
907
|
+
function a(o, i, t) {
|
|
908
|
+
i[t] = o >>> 24, i[t + 1] = o >>> 16 & 255, i[t + 2] = o >>> 8 & 255, i[t + 3] = o & 255;
|
|
909
909
|
}
|
|
910
|
-
function u(
|
|
911
|
-
return (
|
|
910
|
+
function u(o, i) {
|
|
911
|
+
return (o[i] | o[i + 1] << 8 | o[i + 2] << 16 | o[i + 3] << 24) >>> 0;
|
|
912
912
|
}
|
|
913
|
-
function r(
|
|
914
|
-
return (
|
|
913
|
+
function r(o, i) {
|
|
914
|
+
return (o[i] << 24 | o[i + 1] << 16 | o[i + 2] << 8 | o[i + 3]) >>> 0;
|
|
915
915
|
}
|
|
916
916
|
return float;
|
|
917
917
|
}
|
|
@@ -933,22 +933,22 @@ function requireInquire() {
|
|
|
933
933
|
var utf8 = {}, hasRequiredUtf8;
|
|
934
934
|
function requireUtf8() {
|
|
935
935
|
return hasRequiredUtf8 || (hasRequiredUtf8 = 1, function(h) {
|
|
936
|
-
var
|
|
937
|
-
|
|
938
|
-
for (var r = 0,
|
|
939
|
-
|
|
936
|
+
var n = h;
|
|
937
|
+
n.length = function(u) {
|
|
938
|
+
for (var r = 0, o = 0, i = 0; i < u.length; ++i)
|
|
939
|
+
o = u.charCodeAt(i), o < 128 ? r += 1 : o < 2048 ? r += 2 : (o & 64512) === 55296 && (u.charCodeAt(i + 1) & 64512) === 56320 ? (++i, r += 4) : r += 3;
|
|
940
940
|
return r;
|
|
941
|
-
},
|
|
942
|
-
var i =
|
|
941
|
+
}, n.read = function(u, r, o) {
|
|
942
|
+
var i = o - r;
|
|
943
943
|
if (i < 1)
|
|
944
944
|
return "";
|
|
945
|
-
for (var t = null, e = [], s = 0, l; r <
|
|
945
|
+
for (var t = null, e = [], s = 0, l; r < o; )
|
|
946
946
|
l = u[r++], l < 128 ? e[s++] = l : l > 191 && l < 224 ? e[s++] = (l & 31) << 6 | u[r++] & 63 : l > 239 && l < 365 ? (l = ((l & 7) << 18 | (u[r++] & 63) << 12 | (u[r++] & 63) << 6 | u[r++] & 63) - 65536, e[s++] = 55296 + (l >> 10), e[s++] = 56320 + (l & 1023)) : e[s++] = (l & 15) << 12 | (u[r++] & 63) << 6 | u[r++] & 63, s > 8191 && ((t || (t = [])).push(String.fromCharCode.apply(String, e)), s = 0);
|
|
947
947
|
return t ? (s && t.push(String.fromCharCode.apply(String, e.slice(0, s))), t.join("")) : String.fromCharCode.apply(String, e.slice(0, s));
|
|
948
|
-
},
|
|
949
|
-
for (var i =
|
|
950
|
-
t = u.charCodeAt(s), t < 128 ? r[
|
|
951
|
-
return
|
|
948
|
+
}, n.write = function(u, r, o) {
|
|
949
|
+
for (var i = o, t, e, s = 0; s < u.length; ++s)
|
|
950
|
+
t = u.charCodeAt(s), t < 128 ? r[o++] = t : t < 2048 ? (r[o++] = t >> 6 | 192, r[o++] = t & 63 | 128) : (t & 64512) === 55296 && ((e = u.charCodeAt(s + 1)) & 64512) === 56320 ? (t = 65536 + ((t & 1023) << 10) + (e & 1023), ++s, r[o++] = t >> 18 | 240, r[o++] = t >> 12 & 63 | 128, r[o++] = t >> 6 & 63 | 128, r[o++] = t & 63 | 128) : (r[o++] = t >> 12 | 224, r[o++] = t >> 6 & 63 | 128, r[o++] = t & 63 | 128);
|
|
951
|
+
return o - i;
|
|
952
952
|
};
|
|
953
953
|
}(utf8)), utf8;
|
|
954
954
|
}
|
|
@@ -956,12 +956,12 @@ var pool_1, hasRequiredPool;
|
|
|
956
956
|
function requirePool() {
|
|
957
957
|
if (hasRequiredPool) return pool_1;
|
|
958
958
|
hasRequiredPool = 1, pool_1 = h;
|
|
959
|
-
function h(
|
|
960
|
-
var r = u || 8192,
|
|
959
|
+
function h(n, a, u) {
|
|
960
|
+
var r = u || 8192, o = r >>> 1, i = null, t = r;
|
|
961
961
|
return function(s) {
|
|
962
|
-
if (s < 1 || s >
|
|
963
|
-
return
|
|
964
|
-
t + s > r && (i =
|
|
962
|
+
if (s < 1 || s > o)
|
|
963
|
+
return n(s);
|
|
964
|
+
t + s > r && (i = n(r), t = 0);
|
|
965
965
|
var l = a.call(i, t, t += s);
|
|
966
966
|
return t & 7 && (t = (t | 7) + 1), l;
|
|
967
967
|
};
|
|
@@ -971,12 +971,12 @@ function requirePool() {
|
|
|
971
971
|
var longbits, hasRequiredLongbits;
|
|
972
972
|
function requireLongbits() {
|
|
973
973
|
if (hasRequiredLongbits) return longbits;
|
|
974
|
-
hasRequiredLongbits = 1, longbits =
|
|
974
|
+
hasRequiredLongbits = 1, longbits = n;
|
|
975
975
|
var h = requireMinimal$1();
|
|
976
|
-
function o
|
|
977
|
-
this.lo =
|
|
976
|
+
function n(o, i) {
|
|
977
|
+
this.lo = o >>> 0, this.hi = i >>> 0;
|
|
978
978
|
}
|
|
979
|
-
var a =
|
|
979
|
+
var a = n.zero = new n(0, 0);
|
|
980
980
|
a.toNumber = function() {
|
|
981
981
|
return 0;
|
|
982
982
|
}, a.zzEncode = a.zzDecode = function() {
|
|
@@ -984,39 +984,39 @@ function requireLongbits() {
|
|
|
984
984
|
}, a.length = function() {
|
|
985
985
|
return 1;
|
|
986
986
|
};
|
|
987
|
-
var u =
|
|
988
|
-
|
|
987
|
+
var u = n.zeroHash = "\0\0\0\0\0\0\0\0";
|
|
988
|
+
n.fromNumber = function(i) {
|
|
989
989
|
if (i === 0)
|
|
990
990
|
return a;
|
|
991
991
|
var t = i < 0;
|
|
992
992
|
t && (i = -i);
|
|
993
993
|
var e = i >>> 0, s = (i - e) / 4294967296 >>> 0;
|
|
994
|
-
return t && (s = ~s >>> 0, e = ~e >>> 0, ++e > 4294967295 && (e = 0, ++s > 4294967295 && (s = 0))), new
|
|
995
|
-
},
|
|
994
|
+
return t && (s = ~s >>> 0, e = ~e >>> 0, ++e > 4294967295 && (e = 0, ++s > 4294967295 && (s = 0))), new n(e, s);
|
|
995
|
+
}, n.from = function(i) {
|
|
996
996
|
if (typeof i == "number")
|
|
997
|
-
return
|
|
997
|
+
return n.fromNumber(i);
|
|
998
998
|
if (h.isString(i))
|
|
999
999
|
if (h.Long)
|
|
1000
1000
|
i = h.Long.fromString(i);
|
|
1001
1001
|
else
|
|
1002
|
-
return
|
|
1003
|
-
return i.low || i.high ? new
|
|
1004
|
-
},
|
|
1002
|
+
return n.fromNumber(parseInt(i, 10));
|
|
1003
|
+
return i.low || i.high ? new n(i.low >>> 0, i.high >>> 0) : a;
|
|
1004
|
+
}, n.prototype.toNumber = function(i) {
|
|
1005
1005
|
if (!i && this.hi >>> 31) {
|
|
1006
1006
|
var t = ~this.lo + 1 >>> 0, e = ~this.hi >>> 0;
|
|
1007
1007
|
return t || (e = e + 1 >>> 0), -(t + e * 4294967296);
|
|
1008
1008
|
}
|
|
1009
1009
|
return this.lo + this.hi * 4294967296;
|
|
1010
|
-
},
|
|
1010
|
+
}, n.prototype.toLong = function(i) {
|
|
1011
1011
|
return h.Long ? new h.Long(this.lo | 0, this.hi | 0, !!i) : { low: this.lo | 0, high: this.hi | 0, unsigned: !!i };
|
|
1012
1012
|
};
|
|
1013
1013
|
var r = String.prototype.charCodeAt;
|
|
1014
|
-
return
|
|
1015
|
-
return i === u ? a : new
|
|
1014
|
+
return n.fromHash = function(i) {
|
|
1015
|
+
return i === u ? a : new n(
|
|
1016
1016
|
(r.call(i, 0) | r.call(i, 1) << 8 | r.call(i, 2) << 16 | r.call(i, 3) << 24) >>> 0,
|
|
1017
1017
|
(r.call(i, 4) | r.call(i, 5) << 8 | r.call(i, 6) << 16 | r.call(i, 7) << 24) >>> 0
|
|
1018
1018
|
);
|
|
1019
|
-
},
|
|
1019
|
+
}, n.prototype.toHash = function() {
|
|
1020
1020
|
return String.fromCharCode(
|
|
1021
1021
|
this.lo & 255,
|
|
1022
1022
|
this.lo >>> 8 & 255,
|
|
@@ -1027,13 +1027,13 @@ function requireLongbits() {
|
|
|
1027
1027
|
this.hi >>> 16 & 255,
|
|
1028
1028
|
this.hi >>> 24
|
|
1029
1029
|
);
|
|
1030
|
-
},
|
|
1030
|
+
}, n.prototype.zzEncode = function() {
|
|
1031
1031
|
var i = this.hi >> 31;
|
|
1032
1032
|
return this.hi = ((this.hi << 1 | this.lo >>> 31) ^ i) >>> 0, this.lo = (this.lo << 1 ^ i) >>> 0, this;
|
|
1033
|
-
},
|
|
1033
|
+
}, n.prototype.zzDecode = function() {
|
|
1034
1034
|
var i = -(this.lo & 1);
|
|
1035
1035
|
return this.lo = ((this.lo >>> 1 | this.hi << 31) ^ i) >>> 0, this.hi = (this.hi >>> 1 ^ i) >>> 0, this;
|
|
1036
|
-
},
|
|
1036
|
+
}, n.prototype.length = function() {
|
|
1037
1037
|
var i = this.lo, t = (this.lo >>> 28 | this.hi << 4) >>> 0, e = this.hi >>> 24;
|
|
1038
1038
|
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;
|
|
1039
1039
|
}, longbits;
|
|
@@ -1041,32 +1041,32 @@ function requireLongbits() {
|
|
|
1041
1041
|
var hasRequiredMinimal$1;
|
|
1042
1042
|
function requireMinimal$1() {
|
|
1043
1043
|
return hasRequiredMinimal$1 || (hasRequiredMinimal$1 = 1, function(h) {
|
|
1044
|
-
var
|
|
1045
|
-
|
|
1044
|
+
var n = h;
|
|
1045
|
+
n.asPromise = requireAspromise(), n.base64 = requireBase64(), n.EventEmitter = requireEventemitter(), n.float = requireFloat(), n.inquire = requireInquire(), n.utf8 = requireUtf8(), n.pool = requirePool(), n.LongBits = requireLongbits(), n.isNode = !!(typeof commonjsGlobal < "u" && commonjsGlobal && commonjsGlobal.process && commonjsGlobal.process.versions && commonjsGlobal.process.versions.node), n.global = n.isNode && commonjsGlobal || typeof window < "u" && window || typeof self < "u" && self || minimal$1, n.emptyArray = Object.freeze ? Object.freeze([]) : (
|
|
1046
1046
|
/* istanbul ignore next */
|
|
1047
1047
|
[]
|
|
1048
|
-
),
|
|
1048
|
+
), n.emptyObject = Object.freeze ? Object.freeze({}) : (
|
|
1049
1049
|
/* istanbul ignore next */
|
|
1050
1050
|
{}
|
|
1051
|
-
),
|
|
1052
|
-
function(
|
|
1053
|
-
return typeof
|
|
1054
|
-
},
|
|
1055
|
-
return typeof
|
|
1056
|
-
},
|
|
1057
|
-
return
|
|
1058
|
-
},
|
|
1051
|
+
), n.isInteger = Number.isInteger || /* istanbul ignore next */
|
|
1052
|
+
function(o) {
|
|
1053
|
+
return typeof o == "number" && isFinite(o) && Math.floor(o) === o;
|
|
1054
|
+
}, n.isString = function(o) {
|
|
1055
|
+
return typeof o == "string" || o instanceof String;
|
|
1056
|
+
}, n.isObject = function(o) {
|
|
1057
|
+
return o && typeof o == "object";
|
|
1058
|
+
}, n.isset = /**
|
|
1059
1059
|
* Checks if a property on a message is considered to be present.
|
|
1060
1060
|
* @param {Object} obj Plain object or message instance
|
|
1061
1061
|
* @param {string} prop Property name
|
|
1062
1062
|
* @returns {boolean} `true` if considered to be present, otherwise `false`
|
|
1063
1063
|
*/
|
|
1064
|
-
|
|
1065
|
-
var t =
|
|
1066
|
-
return t != null &&
|
|
1067
|
-
},
|
|
1064
|
+
n.isSet = function(o, i) {
|
|
1065
|
+
var t = o[i];
|
|
1066
|
+
return t != null && o.hasOwnProperty(i) ? typeof t != "object" || (Array.isArray(t) ? t.length : Object.keys(t).length) > 0 : !1;
|
|
1067
|
+
}, n.Buffer = function() {
|
|
1068
1068
|
try {
|
|
1069
|
-
var r =
|
|
1069
|
+
var r = n.inquire("buffer").Buffer;
|
|
1070
1070
|
return r.prototype.utf8Write ? r : (
|
|
1071
1071
|
/* istanbul ignore next */
|
|
1072
1072
|
null
|
|
@@ -1074,36 +1074,36 @@ function requireMinimal$1() {
|
|
|
1074
1074
|
} catch {
|
|
1075
1075
|
return null;
|
|
1076
1076
|
}
|
|
1077
|
-
}(),
|
|
1078
|
-
return typeof
|
|
1079
|
-
},
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
return
|
|
1084
|
-
},
|
|
1085
|
-
var t =
|
|
1086
|
-
return
|
|
1077
|
+
}(), n._Buffer_from = null, n._Buffer_allocUnsafe = null, n.newBuffer = function(o) {
|
|
1078
|
+
return typeof o == "number" ? n.Buffer ? n._Buffer_allocUnsafe(o) : new n.Array(o) : n.Buffer ? n._Buffer_from(o) : typeof Uint8Array > "u" ? o : new Uint8Array(o);
|
|
1079
|
+
}, n.Array = typeof Uint8Array < "u" ? Uint8Array : Array, n.Long = /* istanbul ignore next */
|
|
1080
|
+
n.global.dcodeIO && /* istanbul ignore next */
|
|
1081
|
+
n.global.dcodeIO.Long || /* istanbul ignore next */
|
|
1082
|
+
n.global.Long || n.inquire("long"), n.key2Re = /^true|false|0|1$/, n.key32Re = /^-?(?:0|[1-9][0-9]*)$/, n.key64Re = /^(?:[\\x00-\\xff]{8}|-?(?:0|[1-9][0-9]*))$/, n.longToHash = function(o) {
|
|
1083
|
+
return o ? n.LongBits.from(o).toHash() : n.LongBits.zeroHash;
|
|
1084
|
+
}, n.longFromHash = function(o, i) {
|
|
1085
|
+
var t = n.LongBits.fromHash(o);
|
|
1086
|
+
return n.Long ? n.Long.fromBits(t.lo, t.hi, i) : t.toNumber(!!i);
|
|
1087
1087
|
};
|
|
1088
|
-
function a(r,
|
|
1089
|
-
for (var t = Object.keys(
|
|
1090
|
-
(r[t[e]] === void 0 || !i) && (r[t[e]] =
|
|
1088
|
+
function a(r, o, i) {
|
|
1089
|
+
for (var t = Object.keys(o), e = 0; e < t.length; ++e)
|
|
1090
|
+
(r[t[e]] === void 0 || !i) && (r[t[e]] = o[t[e]]);
|
|
1091
1091
|
return r;
|
|
1092
1092
|
}
|
|
1093
|
-
|
|
1094
|
-
return
|
|
1093
|
+
n.merge = a, n.lcFirst = function(o) {
|
|
1094
|
+
return o.charAt(0).toLowerCase() + o.substring(1);
|
|
1095
1095
|
};
|
|
1096
1096
|
function u(r) {
|
|
1097
|
-
function
|
|
1098
|
-
if (!(this instanceof
|
|
1099
|
-
return new
|
|
1097
|
+
function o(i, t) {
|
|
1098
|
+
if (!(this instanceof o))
|
|
1099
|
+
return new o(i, t);
|
|
1100
1100
|
Object.defineProperty(this, "message", { get: function() {
|
|
1101
1101
|
return i;
|
|
1102
|
-
} }), Error.captureStackTrace ? Error.captureStackTrace(this,
|
|
1102
|
+
} }), Error.captureStackTrace ? Error.captureStackTrace(this, o) : Object.defineProperty(this, "stack", { value: new Error().stack || "" }), t && a(this, t);
|
|
1103
1103
|
}
|
|
1104
|
-
return
|
|
1104
|
+
return o.prototype = Object.create(Error.prototype, {
|
|
1105
1105
|
constructor: {
|
|
1106
|
-
value:
|
|
1106
|
+
value: o,
|
|
1107
1107
|
writable: !0,
|
|
1108
1108
|
enumerable: !1,
|
|
1109
1109
|
configurable: !0
|
|
@@ -1128,36 +1128,36 @@ function requireMinimal$1() {
|
|
|
1128
1128
|
enumerable: !1,
|
|
1129
1129
|
configurable: !0
|
|
1130
1130
|
}
|
|
1131
|
-
}),
|
|
1131
|
+
}), o;
|
|
1132
1132
|
}
|
|
1133
|
-
|
|
1134
|
-
for (var i = {}, t = 0; t <
|
|
1135
|
-
i[
|
|
1133
|
+
n.newError = u, n.ProtocolError = u("ProtocolError"), n.oneOfGetter = function(o) {
|
|
1134
|
+
for (var i = {}, t = 0; t < o.length; ++t)
|
|
1135
|
+
i[o[t]] = 1;
|
|
1136
1136
|
return function() {
|
|
1137
1137
|
for (var e = Object.keys(this), s = e.length - 1; s > -1; --s)
|
|
1138
1138
|
if (i[e[s]] === 1 && this[e[s]] !== void 0 && this[e[s]] !== null)
|
|
1139
1139
|
return e[s];
|
|
1140
1140
|
};
|
|
1141
|
-
},
|
|
1141
|
+
}, n.oneOfSetter = function(o) {
|
|
1142
1142
|
return function(i) {
|
|
1143
|
-
for (var t = 0; t <
|
|
1144
|
-
|
|
1143
|
+
for (var t = 0; t < o.length; ++t)
|
|
1144
|
+
o[t] !== i && delete this[o[t]];
|
|
1145
1145
|
};
|
|
1146
|
-
},
|
|
1146
|
+
}, n.toJSONOptions = {
|
|
1147
1147
|
longs: String,
|
|
1148
1148
|
enums: String,
|
|
1149
1149
|
bytes: String,
|
|
1150
1150
|
json: !0
|
|
1151
|
-
},
|
|
1152
|
-
var r =
|
|
1151
|
+
}, n._configure = function() {
|
|
1152
|
+
var r = n.Buffer;
|
|
1153
1153
|
if (!r) {
|
|
1154
|
-
|
|
1154
|
+
n._Buffer_from = n._Buffer_allocUnsafe = null;
|
|
1155
1155
|
return;
|
|
1156
1156
|
}
|
|
1157
|
-
|
|
1157
|
+
n._Buffer_from = r.from !== Uint8Array.from && r.from || /* istanbul ignore next */
|
|
1158
1158
|
function(i, t) {
|
|
1159
1159
|
return new r(i, t);
|
|
1160
|
-
},
|
|
1160
|
+
}, n._Buffer_allocUnsafe = r.allocUnsafe || /* istanbul ignore next */
|
|
1161
1161
|
function(i) {
|
|
1162
1162
|
return new r(i);
|
|
1163
1163
|
};
|
|
@@ -1168,9 +1168,9 @@ var writer, hasRequiredWriter;
|
|
|
1168
1168
|
function requireWriter() {
|
|
1169
1169
|
if (hasRequiredWriter) return writer;
|
|
1170
1170
|
hasRequiredWriter = 1, writer = e;
|
|
1171
|
-
var h = requireMinimal$1(),
|
|
1172
|
-
function
|
|
1173
|
-
this.fn = b, this.len =
|
|
1171
|
+
var h = requireMinimal$1(), n, a = h.LongBits, u = h.base64, r = h.utf8;
|
|
1172
|
+
function o(b, g, k) {
|
|
1173
|
+
this.fn = b, this.len = g, this.next = void 0, this.val = k;
|
|
1174
1174
|
}
|
|
1175
1175
|
function i() {
|
|
1176
1176
|
}
|
|
@@ -1178,103 +1178,103 @@ function requireWriter() {
|
|
|
1178
1178
|
this.head = b.head, this.tail = b.tail, this.len = b.len, this.next = b.states;
|
|
1179
1179
|
}
|
|
1180
1180
|
function e() {
|
|
1181
|
-
this.len = 0, this.head = new
|
|
1181
|
+
this.len = 0, this.head = new o(i, 0, 0), this.tail = this.head, this.states = null;
|
|
1182
1182
|
}
|
|
1183
1183
|
var s = function() {
|
|
1184
1184
|
return h.Buffer ? function() {
|
|
1185
1185
|
return (e.create = function() {
|
|
1186
|
-
return new
|
|
1186
|
+
return new n();
|
|
1187
1187
|
})();
|
|
1188
1188
|
} : function() {
|
|
1189
1189
|
return new e();
|
|
1190
1190
|
};
|
|
1191
1191
|
};
|
|
1192
|
-
e.create = s(), e.alloc = function(
|
|
1193
|
-
return new h.Array(
|
|
1194
|
-
}, h.Array !== Array && (e.alloc = h.pool(e.alloc, h.Array.prototype.subarray)), e.prototype._push = function(
|
|
1195
|
-
return this.tail = this.tail.next = new
|
|
1192
|
+
e.create = s(), e.alloc = function(g) {
|
|
1193
|
+
return new h.Array(g);
|
|
1194
|
+
}, h.Array !== Array && (e.alloc = h.pool(e.alloc, h.Array.prototype.subarray)), e.prototype._push = function(g, k, T) {
|
|
1195
|
+
return this.tail = this.tail.next = new o(g, k, T), this.len += k, this;
|
|
1196
1196
|
};
|
|
1197
|
-
function l(b,
|
|
1198
|
-
|
|
1197
|
+
function l(b, g, k) {
|
|
1198
|
+
g[k] = b & 255;
|
|
1199
1199
|
}
|
|
1200
|
-
function c(b,
|
|
1200
|
+
function c(b, g, k) {
|
|
1201
1201
|
for (; b > 127; )
|
|
1202
|
-
|
|
1203
|
-
|
|
1202
|
+
g[k++] = b & 127 | 128, b >>>= 7;
|
|
1203
|
+
g[k] = b;
|
|
1204
1204
|
}
|
|
1205
|
-
function d(b,
|
|
1206
|
-
this.len = b, this.next = void 0, this.val =
|
|
1205
|
+
function d(b, g) {
|
|
1206
|
+
this.len = b, this.next = void 0, this.val = g;
|
|
1207
1207
|
}
|
|
1208
|
-
d.prototype = Object.create(
|
|
1208
|
+
d.prototype = Object.create(o.prototype), d.prototype.fn = c, e.prototype.uint32 = function(g) {
|
|
1209
1209
|
return this.len += (this.tail = this.tail.next = new d(
|
|
1210
|
-
(
|
|
1211
|
-
|
|
1210
|
+
(g = g >>> 0) < 128 ? 1 : g < 16384 ? 2 : g < 2097152 ? 3 : g < 268435456 ? 4 : 5,
|
|
1211
|
+
g
|
|
1212
1212
|
)).len, this;
|
|
1213
|
-
}, e.prototype.int32 = function(
|
|
1214
|
-
return
|
|
1215
|
-
}, e.prototype.sint32 = function(
|
|
1216
|
-
return this.uint32((
|
|
1213
|
+
}, e.prototype.int32 = function(g) {
|
|
1214
|
+
return g < 0 ? this._push(p, 10, a.fromNumber(g)) : this.uint32(g);
|
|
1215
|
+
}, e.prototype.sint32 = function(g) {
|
|
1216
|
+
return this.uint32((g << 1 ^ g >> 31) >>> 0);
|
|
1217
1217
|
};
|
|
1218
|
-
function p(b,
|
|
1218
|
+
function p(b, g, k) {
|
|
1219
1219
|
for (; b.hi; )
|
|
1220
|
-
|
|
1220
|
+
g[k++] = b.lo & 127 | 128, b.lo = (b.lo >>> 7 | b.hi << 25) >>> 0, b.hi >>>= 7;
|
|
1221
1221
|
for (; b.lo > 127; )
|
|
1222
|
-
|
|
1223
|
-
|
|
1222
|
+
g[k++] = b.lo & 127 | 128, b.lo = b.lo >>> 7;
|
|
1223
|
+
g[k++] = b.lo;
|
|
1224
1224
|
}
|
|
1225
|
-
e.prototype.uint64 = function(
|
|
1226
|
-
var k = a.from(
|
|
1225
|
+
e.prototype.uint64 = function(g) {
|
|
1226
|
+
var k = a.from(g);
|
|
1227
1227
|
return this._push(p, k.length(), k);
|
|
1228
|
-
}, e.prototype.int64 = e.prototype.uint64, e.prototype.sint64 = function(
|
|
1229
|
-
var k = a.from(
|
|
1228
|
+
}, e.prototype.int64 = e.prototype.uint64, e.prototype.sint64 = function(g) {
|
|
1229
|
+
var k = a.from(g).zzEncode();
|
|
1230
1230
|
return this._push(p, k.length(), k);
|
|
1231
|
-
}, e.prototype.bool = function(
|
|
1232
|
-
return this._push(l, 1,
|
|
1231
|
+
}, e.prototype.bool = function(g) {
|
|
1232
|
+
return this._push(l, 1, g ? 1 : 0);
|
|
1233
1233
|
};
|
|
1234
|
-
function f(b,
|
|
1235
|
-
|
|
1234
|
+
function f(b, g, k) {
|
|
1235
|
+
g[k] = b & 255, g[k + 1] = b >>> 8 & 255, g[k + 2] = b >>> 16 & 255, g[k + 3] = b >>> 24;
|
|
1236
1236
|
}
|
|
1237
|
-
e.prototype.fixed32 = function(
|
|
1238
|
-
return this._push(f, 4,
|
|
1239
|
-
}, e.prototype.sfixed32 = e.prototype.fixed32, e.prototype.fixed64 = function(
|
|
1240
|
-
var k = a.from(
|
|
1237
|
+
e.prototype.fixed32 = function(g) {
|
|
1238
|
+
return this._push(f, 4, g >>> 0);
|
|
1239
|
+
}, e.prototype.sfixed32 = e.prototype.fixed32, e.prototype.fixed64 = function(g) {
|
|
1240
|
+
var k = a.from(g);
|
|
1241
1241
|
return this._push(f, 4, k.lo)._push(f, 4, k.hi);
|
|
1242
|
-
}, e.prototype.sfixed64 = e.prototype.fixed64, e.prototype.float = function(
|
|
1243
|
-
return this._push(h.float.writeFloatLE, 4,
|
|
1244
|
-
}, e.prototype.double = function(
|
|
1245
|
-
return this._push(h.float.writeDoubleLE, 8,
|
|
1242
|
+
}, e.prototype.sfixed64 = e.prototype.fixed64, e.prototype.float = function(g) {
|
|
1243
|
+
return this._push(h.float.writeFloatLE, 4, g);
|
|
1244
|
+
}, e.prototype.double = function(g) {
|
|
1245
|
+
return this._push(h.float.writeDoubleLE, 8, g);
|
|
1246
1246
|
};
|
|
1247
|
-
var w = h.Array.prototype.set ? function(
|
|
1248
|
-
k.set(
|
|
1249
|
-
} : function(
|
|
1250
|
-
for (var K = 0; K <
|
|
1251
|
-
k[
|
|
1247
|
+
var w = h.Array.prototype.set ? function(g, k, T) {
|
|
1248
|
+
k.set(g, T);
|
|
1249
|
+
} : function(g, k, T) {
|
|
1250
|
+
for (var K = 0; K < g.length; ++K)
|
|
1251
|
+
k[T + K] = g[K];
|
|
1252
1252
|
};
|
|
1253
|
-
return e.prototype.bytes = function(
|
|
1254
|
-
var k =
|
|
1253
|
+
return e.prototype.bytes = function(g) {
|
|
1254
|
+
var k = g.length >>> 0;
|
|
1255
1255
|
if (!k)
|
|
1256
1256
|
return this._push(l, 1, 0);
|
|
1257
|
-
if (h.isString(
|
|
1258
|
-
var
|
|
1259
|
-
u.decode(
|
|
1257
|
+
if (h.isString(g)) {
|
|
1258
|
+
var T = e.alloc(k = u.length(g));
|
|
1259
|
+
u.decode(g, T, 0), g = T;
|
|
1260
1260
|
}
|
|
1261
|
-
return this.uint32(k)._push(w, k,
|
|
1262
|
-
}, e.prototype.string = function(
|
|
1263
|
-
var k = r.length(
|
|
1264
|
-
return k ? this.uint32(k)._push(r.write, k,
|
|
1261
|
+
return this.uint32(k)._push(w, k, g);
|
|
1262
|
+
}, e.prototype.string = function(g) {
|
|
1263
|
+
var k = r.length(g);
|
|
1264
|
+
return k ? this.uint32(k)._push(r.write, k, g) : this._push(l, 1, 0);
|
|
1265
1265
|
}, e.prototype.fork = function() {
|
|
1266
|
-
return this.states = new t(this), this.head = this.tail = new
|
|
1266
|
+
return this.states = new t(this), this.head = this.tail = new o(i, 0, 0), this.len = 0, this;
|
|
1267
1267
|
}, e.prototype.reset = function() {
|
|
1268
|
-
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
|
|
1268
|
+
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;
|
|
1269
1269
|
}, e.prototype.ldelim = function() {
|
|
1270
|
-
var
|
|
1271
|
-
return this.reset().uint32(
|
|
1270
|
+
var g = this.head, k = this.tail, T = this.len;
|
|
1271
|
+
return this.reset().uint32(T), T && (this.tail.next = g.next, this.tail = k, this.len += T), this;
|
|
1272
1272
|
}, e.prototype.finish = function() {
|
|
1273
|
-
for (var
|
|
1274
|
-
|
|
1273
|
+
for (var g = this.head.next, k = this.constructor.alloc(this.len), T = 0; g; )
|
|
1274
|
+
g.fn(g.val, k, T), T += g.len, g = g.next;
|
|
1275
1275
|
return k;
|
|
1276
1276
|
}, e._configure = function(b) {
|
|
1277
|
-
|
|
1277
|
+
n = b, e.create = s(), n._configure();
|
|
1278
1278
|
}, writer;
|
|
1279
1279
|
}
|
|
1280
1280
|
var writer_buffer, hasRequiredWriter_buffer;
|
|
@@ -1283,60 +1283,60 @@ function requireWriter_buffer() {
|
|
|
1283
1283
|
hasRequiredWriter_buffer = 1, writer_buffer = a;
|
|
1284
1284
|
var h = requireWriter();
|
|
1285
1285
|
(a.prototype = Object.create(h.prototype)).constructor = a;
|
|
1286
|
-
var
|
|
1286
|
+
var n = requireMinimal$1();
|
|
1287
1287
|
function a() {
|
|
1288
1288
|
h.call(this);
|
|
1289
1289
|
}
|
|
1290
1290
|
a._configure = function() {
|
|
1291
|
-
a.alloc =
|
|
1292
|
-
i.set(
|
|
1293
|
-
} : function(
|
|
1294
|
-
if (
|
|
1295
|
-
|
|
1296
|
-
else for (var e = 0; e <
|
|
1297
|
-
i[t++] =
|
|
1291
|
+
a.alloc = n._Buffer_allocUnsafe, a.writeBytesBuffer = n.Buffer && n.Buffer.prototype instanceof Uint8Array && n.Buffer.prototype.set.name === "set" ? function(o, i, t) {
|
|
1292
|
+
i.set(o, t);
|
|
1293
|
+
} : function(o, i, t) {
|
|
1294
|
+
if (o.copy)
|
|
1295
|
+
o.copy(i, t, 0, o.length);
|
|
1296
|
+
else for (var e = 0; e < o.length; )
|
|
1297
|
+
i[t++] = o[e++];
|
|
1298
1298
|
};
|
|
1299
|
-
}, a.prototype.bytes = function(
|
|
1300
|
-
|
|
1301
|
-
var i =
|
|
1302
|
-
return this.uint32(i), i && this._push(a.writeBytesBuffer, i,
|
|
1299
|
+
}, a.prototype.bytes = function(o) {
|
|
1300
|
+
n.isString(o) && (o = n._Buffer_from(o, "base64"));
|
|
1301
|
+
var i = o.length >>> 0;
|
|
1302
|
+
return this.uint32(i), i && this._push(a.writeBytesBuffer, i, o), this;
|
|
1303
1303
|
};
|
|
1304
|
-
function u(r,
|
|
1305
|
-
r.length < 40 ?
|
|
1304
|
+
function u(r, o, i) {
|
|
1305
|
+
r.length < 40 ? n.utf8.write(r, o, i) : o.utf8Write ? o.utf8Write(r, i) : o.write(r, i);
|
|
1306
1306
|
}
|
|
1307
|
-
return a.prototype.string = function(
|
|
1308
|
-
var i =
|
|
1309
|
-
return this.uint32(i), i && this._push(u, i,
|
|
1307
|
+
return a.prototype.string = function(o) {
|
|
1308
|
+
var i = n.Buffer.byteLength(o);
|
|
1309
|
+
return this.uint32(i), i && this._push(u, i, o), this;
|
|
1310
1310
|
}, a._configure(), writer_buffer;
|
|
1311
1311
|
}
|
|
1312
1312
|
var reader, hasRequiredReader;
|
|
1313
1313
|
function requireReader() {
|
|
1314
1314
|
if (hasRequiredReader) return reader;
|
|
1315
|
-
hasRequiredReader = 1, reader =
|
|
1316
|
-
var h = requireMinimal$1(),
|
|
1315
|
+
hasRequiredReader = 1, reader = o;
|
|
1316
|
+
var h = requireMinimal$1(), n, a = h.LongBits, u = h.utf8;
|
|
1317
1317
|
function r(c, d) {
|
|
1318
1318
|
return RangeError("index out of range: " + c.pos + " + " + (d || 1) + " > " + c.len);
|
|
1319
1319
|
}
|
|
1320
|
-
function
|
|
1320
|
+
function o(c) {
|
|
1321
1321
|
this.buf = c, this.pos = 0, this.len = c.length;
|
|
1322
1322
|
}
|
|
1323
1323
|
var i = typeof Uint8Array < "u" ? function(d) {
|
|
1324
1324
|
if (d instanceof Uint8Array || Array.isArray(d))
|
|
1325
|
-
return new
|
|
1325
|
+
return new o(d);
|
|
1326
1326
|
throw Error("illegal buffer");
|
|
1327
1327
|
} : function(d) {
|
|
1328
1328
|
if (Array.isArray(d))
|
|
1329
|
-
return new
|
|
1329
|
+
return new o(d);
|
|
1330
1330
|
throw Error("illegal buffer");
|
|
1331
1331
|
}, t = function() {
|
|
1332
1332
|
return h.Buffer ? function(p) {
|
|
1333
|
-
return (
|
|
1334
|
-
return h.Buffer.isBuffer(w) ? new
|
|
1333
|
+
return (o.create = function(w) {
|
|
1334
|
+
return h.Buffer.isBuffer(w) ? new n(w) : i(w);
|
|
1335
1335
|
})(p);
|
|
1336
1336
|
} : i;
|
|
1337
1337
|
};
|
|
1338
|
-
|
|
1339
|
-
h.Array.prototype.slice,
|
|
1338
|
+
o.create = t(), o.prototype._slice = h.Array.prototype.subarray || /* istanbul ignore next */
|
|
1339
|
+
h.Array.prototype.slice, o.prototype.uint32 = /* @__PURE__ */ function() {
|
|
1340
1340
|
var d = 4294967295;
|
|
1341
1341
|
return function() {
|
|
1342
1342
|
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;
|
|
@@ -1344,9 +1344,9 @@ function requireReader() {
|
|
|
1344
1344
|
throw this.pos = this.len, r(this, 10);
|
|
1345
1345
|
return d;
|
|
1346
1346
|
};
|
|
1347
|
-
}(),
|
|
1347
|
+
}(), o.prototype.int32 = function() {
|
|
1348
1348
|
return this.uint32() | 0;
|
|
1349
|
-
},
|
|
1349
|
+
}, o.prototype.sint32 = function() {
|
|
1350
1350
|
var d = this.uint32();
|
|
1351
1351
|
return d >>> 1 ^ -(d & 1) | 0;
|
|
1352
1352
|
};
|
|
@@ -1381,17 +1381,17 @@ function requireReader() {
|
|
|
1381
1381
|
}
|
|
1382
1382
|
throw Error("invalid varint encoding");
|
|
1383
1383
|
}
|
|
1384
|
-
|
|
1384
|
+
o.prototype.bool = function() {
|
|
1385
1385
|
return this.uint32() !== 0;
|
|
1386
1386
|
};
|
|
1387
1387
|
function s(c, d) {
|
|
1388
1388
|
return (c[d - 4] | c[d - 3] << 8 | c[d - 2] << 16 | c[d - 1] << 24) >>> 0;
|
|
1389
1389
|
}
|
|
1390
|
-
|
|
1390
|
+
o.prototype.fixed32 = function() {
|
|
1391
1391
|
if (this.pos + 4 > this.len)
|
|
1392
1392
|
throw r(this, 4);
|
|
1393
1393
|
return s(this.buf, this.pos += 4);
|
|
1394
|
-
},
|
|
1394
|
+
}, o.prototype.sfixed32 = function() {
|
|
1395
1395
|
if (this.pos + 4 > this.len)
|
|
1396
1396
|
throw r(this, 4);
|
|
1397
1397
|
return s(this.buf, this.pos += 4) | 0;
|
|
@@ -1401,17 +1401,17 @@ function requireReader() {
|
|
|
1401
1401
|
throw r(this, 8);
|
|
1402
1402
|
return new a(s(this.buf, this.pos += 4), s(this.buf, this.pos += 4));
|
|
1403
1403
|
}
|
|
1404
|
-
return
|
|
1404
|
+
return o.prototype.float = function() {
|
|
1405
1405
|
if (this.pos + 4 > this.len)
|
|
1406
1406
|
throw r(this, 4);
|
|
1407
1407
|
var d = h.float.readFloatLE(this.buf, this.pos);
|
|
1408
1408
|
return this.pos += 4, d;
|
|
1409
|
-
},
|
|
1409
|
+
}, o.prototype.double = function() {
|
|
1410
1410
|
if (this.pos + 8 > this.len)
|
|
1411
1411
|
throw r(this, 4);
|
|
1412
1412
|
var d = h.float.readDoubleLE(this.buf, this.pos);
|
|
1413
1413
|
return this.pos += 8, d;
|
|
1414
|
-
},
|
|
1414
|
+
}, o.prototype.bytes = function() {
|
|
1415
1415
|
var d = this.uint32(), p = this.pos, f = this.pos + d;
|
|
1416
1416
|
if (f > this.len)
|
|
1417
1417
|
throw r(this, d);
|
|
@@ -1422,10 +1422,10 @@ function requireReader() {
|
|
|
1422
1422
|
return w ? w.alloc(0) : new this.buf.constructor(0);
|
|
1423
1423
|
}
|
|
1424
1424
|
return this._slice.call(this.buf, p, f);
|
|
1425
|
-
},
|
|
1425
|
+
}, o.prototype.string = function() {
|
|
1426
1426
|
var d = this.bytes();
|
|
1427
1427
|
return u.read(d, 0, d.length);
|
|
1428
|
-
},
|
|
1428
|
+
}, o.prototype.skip = function(d) {
|
|
1429
1429
|
if (typeof d == "number") {
|
|
1430
1430
|
if (this.pos + d > this.len)
|
|
1431
1431
|
throw r(this, d);
|
|
@@ -1436,7 +1436,7 @@ function requireReader() {
|
|
|
1436
1436
|
throw r(this);
|
|
1437
1437
|
while (this.buf[this.pos++] & 128);
|
|
1438
1438
|
return this;
|
|
1439
|
-
},
|
|
1439
|
+
}, o.prototype.skipType = function(c) {
|
|
1440
1440
|
switch (c) {
|
|
1441
1441
|
case 0:
|
|
1442
1442
|
this.skip();
|
|
@@ -1459,13 +1459,13 @@ function requireReader() {
|
|
|
1459
1459
|
throw Error("invalid wire type " + c + " at offset " + this.pos);
|
|
1460
1460
|
}
|
|
1461
1461
|
return this;
|
|
1462
|
-
},
|
|
1463
|
-
|
|
1462
|
+
}, o._configure = function(c) {
|
|
1463
|
+
n = c, o.create = t(), n._configure();
|
|
1464
1464
|
var d = h.Long ? "toLong" : (
|
|
1465
1465
|
/* istanbul ignore next */
|
|
1466
1466
|
"toNumber"
|
|
1467
1467
|
);
|
|
1468
|
-
h.merge(
|
|
1468
|
+
h.merge(o.prototype, {
|
|
1469
1469
|
int64: function() {
|
|
1470
1470
|
return e.call(this)[d](!1);
|
|
1471
1471
|
},
|
|
@@ -1490,12 +1490,12 @@ function requireReader_buffer() {
|
|
|
1490
1490
|
hasRequiredReader_buffer = 1, reader_buffer = a;
|
|
1491
1491
|
var h = requireReader();
|
|
1492
1492
|
(a.prototype = Object.create(h.prototype)).constructor = a;
|
|
1493
|
-
var
|
|
1493
|
+
var n = requireMinimal$1();
|
|
1494
1494
|
function a(u) {
|
|
1495
1495
|
h.call(this, u);
|
|
1496
1496
|
}
|
|
1497
1497
|
return a._configure = function() {
|
|
1498
|
-
|
|
1498
|
+
n.Buffer && (a.prototype._slice = n.Buffer.prototype.slice);
|
|
1499
1499
|
}, a.prototype.string = function() {
|
|
1500
1500
|
var r = this.uint32();
|
|
1501
1501
|
return this.buf.utf8Slice ? this.buf.utf8Slice(this.pos, this.pos = Math.min(this.pos + r, this.len)) : this.buf.toString("utf-8", this.pos, this.pos = Math.min(this.pos + r, this.len));
|
|
@@ -1504,20 +1504,20 @@ function requireReader_buffer() {
|
|
|
1504
1504
|
var rpc = {}, service, hasRequiredService;
|
|
1505
1505
|
function requireService() {
|
|
1506
1506
|
if (hasRequiredService) return service;
|
|
1507
|
-
hasRequiredService = 1, service =
|
|
1507
|
+
hasRequiredService = 1, service = n;
|
|
1508
1508
|
var h = requireMinimal$1();
|
|
1509
|
-
(
|
|
1510
|
-
function
|
|
1509
|
+
(n.prototype = Object.create(h.EventEmitter.prototype)).constructor = n;
|
|
1510
|
+
function n(a, u, r) {
|
|
1511
1511
|
if (typeof a != "function")
|
|
1512
1512
|
throw TypeError("rpcImpl must be a function");
|
|
1513
1513
|
h.EventEmitter.call(this), this.rpcImpl = a, this.requestDelimited = !!u, this.responseDelimited = !!r;
|
|
1514
1514
|
}
|
|
1515
|
-
return
|
|
1515
|
+
return n.prototype.rpcCall = function a(u, r, o, i, t) {
|
|
1516
1516
|
if (!i)
|
|
1517
1517
|
throw TypeError("request must be specified");
|
|
1518
1518
|
var e = this;
|
|
1519
1519
|
if (!t)
|
|
1520
|
-
return h.asPromise(a, e, u, r,
|
|
1520
|
+
return h.asPromise(a, e, u, r, o, i);
|
|
1521
1521
|
if (!e.rpcImpl) {
|
|
1522
1522
|
setTimeout(function() {
|
|
1523
1523
|
t(Error("already ended"));
|
|
@@ -1538,9 +1538,9 @@ function requireService() {
|
|
|
1538
1538
|
);
|
|
1539
1539
|
return;
|
|
1540
1540
|
}
|
|
1541
|
-
if (!(c instanceof
|
|
1541
|
+
if (!(c instanceof o))
|
|
1542
1542
|
try {
|
|
1543
|
-
c =
|
|
1543
|
+
c = o[e.responseDelimited ? "decodeDelimited" : "decode"](c);
|
|
1544
1544
|
} catch (d) {
|
|
1545
1545
|
return e.emit("error", d, u), t(d);
|
|
1546
1546
|
}
|
|
@@ -1553,15 +1553,15 @@ function requireService() {
|
|
|
1553
1553
|
}, 0);
|
|
1554
1554
|
return;
|
|
1555
1555
|
}
|
|
1556
|
-
},
|
|
1556
|
+
}, n.prototype.end = function(u) {
|
|
1557
1557
|
return this.rpcImpl && (u || this.rpcImpl(null, null, null), this.rpcImpl = null, this.emit("end").off()), this;
|
|
1558
1558
|
}, service;
|
|
1559
1559
|
}
|
|
1560
1560
|
var hasRequiredRpc;
|
|
1561
1561
|
function requireRpc() {
|
|
1562
1562
|
return hasRequiredRpc || (hasRequiredRpc = 1, function(h) {
|
|
1563
|
-
var
|
|
1564
|
-
|
|
1563
|
+
var n = h;
|
|
1564
|
+
n.Service = requireService();
|
|
1565
1565
|
}(rpc)), rpc;
|
|
1566
1566
|
}
|
|
1567
1567
|
var roots, hasRequiredRoots;
|
|
@@ -1571,10 +1571,10 @@ function requireRoots() {
|
|
|
1571
1571
|
var hasRequiredIndexMinimal;
|
|
1572
1572
|
function requireIndexMinimal() {
|
|
1573
1573
|
return hasRequiredIndexMinimal || (hasRequiredIndexMinimal = 1, function(h) {
|
|
1574
|
-
var
|
|
1575
|
-
|
|
1574
|
+
var n = h;
|
|
1575
|
+
n.build = "minimal", n.Writer = requireWriter(), n.BufferWriter = requireWriter_buffer(), n.Reader = requireReader(), n.BufferReader = requireReader_buffer(), n.util = requireMinimal$1(), n.rpc = requireRpc(), n.roots = requireRoots(), n.configure = a;
|
|
1576
1576
|
function a() {
|
|
1577
|
-
|
|
1577
|
+
n.util._configure(), n.Writer._configure(n.BufferWriter), n.Reader._configure(n.BufferReader);
|
|
1578
1578
|
}
|
|
1579
1579
|
a();
|
|
1580
1580
|
}(indexMinimal)), indexMinimal;
|
|
@@ -1587,14 +1587,14 @@ var minimalExports = requireMinimal();
|
|
|
1587
1587
|
const $Reader = minimalExports.Reader, $Writer = minimalExports.Writer, $util = minimalExports.util, $root = minimalExports.roots.default || (minimalExports.roots.default = {}), com = $root.com = (() => {
|
|
1588
1588
|
const h = {};
|
|
1589
1589
|
return h.quick = function() {
|
|
1590
|
-
const
|
|
1591
|
-
return
|
|
1590
|
+
const n = {};
|
|
1591
|
+
return n.voice = function() {
|
|
1592
1592
|
const a = {};
|
|
1593
1593
|
return a.proto = function() {
|
|
1594
1594
|
const u = {};
|
|
1595
1595
|
return u.SeiData = function() {
|
|
1596
|
-
function r(
|
|
1597
|
-
if (
|
|
1596
|
+
function r(o) {
|
|
1597
|
+
if (o) for (let i = Object.keys(o), t = 0; t < i.length; ++t) o[i[t]] != null && (this[i[t]] = o[i[t]]);
|
|
1598
1598
|
}
|
|
1599
1599
|
return r.prototype.event = 0, r.prototype.data = $util.newBuffer([]), r.prototype.compress = !1, r.prototype.version = 0, r.create = function(i) {
|
|
1600
1600
|
return new r(i);
|
|
@@ -1686,17 +1686,17 @@ const $Reader = minimalExports.Reader, $Writer = minimalExports.Writer, $util =
|
|
|
1686
1686
|
return i === void 0 && (i = "type.googleapis.com"), i + "/com.quick.voice.proto.SeiData";
|
|
1687
1687
|
}, r;
|
|
1688
1688
|
}(), u.EventType = function() {
|
|
1689
|
-
const r = {},
|
|
1690
|
-
return
|
|
1689
|
+
const r = {}, o = Object.create(r);
|
|
1690
|
+
return o[r[0] = "Layout"] = 0, o[r[1] = "Custom"] = 1, o;
|
|
1691
1691
|
}(), u.LayoutData = function() {
|
|
1692
1692
|
function r(i) {
|
|
1693
1693
|
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]]);
|
|
1694
1694
|
}
|
|
1695
1695
|
r.prototype.roomId = "", r.prototype.type = 0, r.prototype.userMap = $util.emptyObject, r.prototype.globalCustom = null;
|
|
1696
|
-
let
|
|
1696
|
+
let o;
|
|
1697
1697
|
return Object.defineProperty(r.prototype, "_globalCustom", {
|
|
1698
|
-
get: $util.oneOfGetter(
|
|
1699
|
-
set: $util.oneOfSetter(
|
|
1698
|
+
get: $util.oneOfGetter(o = ["globalCustom"]),
|
|
1699
|
+
set: $util.oneOfSetter(o)
|
|
1700
1700
|
}), r.create = function(t) {
|
|
1701
1701
|
return new r(t);
|
|
1702
1702
|
}, r.encode = function(t, e) {
|
|
@@ -1852,10 +1852,10 @@ const $Reader = minimalExports.Reader, $Writer = minimalExports.Writer, $util =
|
|
|
1852
1852
|
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]]);
|
|
1853
1853
|
}
|
|
1854
1854
|
r.prototype.id = "", r.prototype.audios = $util.emptyArray, r.prototype.videos = $util.emptyArray, r.prototype.custom = null;
|
|
1855
|
-
let
|
|
1855
|
+
let o;
|
|
1856
1856
|
return Object.defineProperty(r.prototype, "_custom", {
|
|
1857
|
-
get: $util.oneOfGetter(
|
|
1858
|
-
set: $util.oneOfSetter(
|
|
1857
|
+
get: $util.oneOfGetter(o = ["custom"]),
|
|
1858
|
+
set: $util.oneOfSetter(o)
|
|
1859
1859
|
}), r.create = function(t) {
|
|
1860
1860
|
return new r(t);
|
|
1861
1861
|
}, r.encode = function(t, e) {
|
|
@@ -1975,10 +1975,10 @@ const $Reader = minimalExports.Reader, $Writer = minimalExports.Writer, $util =
|
|
|
1975
1975
|
if (i) for (let t = Object.keys(i), e = 0; e < t.length; ++e) i[t[e]] != null && (this[t[e]] = i[t[e]]);
|
|
1976
1976
|
}
|
|
1977
1977
|
r.prototype.type = 0, r.prototype.isEnable = !1, r.prototype.isMute = !1, r.prototype.volume = 0, r.prototype.updateTime = null;
|
|
1978
|
-
let
|
|
1978
|
+
let o;
|
|
1979
1979
|
return Object.defineProperty(r.prototype, "_updateTime", {
|
|
1980
|
-
get: $util.oneOfGetter(
|
|
1981
|
-
set: $util.oneOfSetter(
|
|
1980
|
+
get: $util.oneOfGetter(o = ["updateTime"]),
|
|
1981
|
+
set: $util.oneOfSetter(o)
|
|
1982
1982
|
}), r.create = function(t) {
|
|
1983
1983
|
return new r(t);
|
|
1984
1984
|
}, r.encode = function(t, e) {
|
|
@@ -2080,10 +2080,10 @@ const $Reader = minimalExports.Reader, $Writer = minimalExports.Writer, $util =
|
|
|
2080
2080
|
if (i) for (let t = Object.keys(i), e = 0; e < t.length; ++e) i[t[e]] != null && (this[t[e]] = i[t[e]]);
|
|
2081
2081
|
}
|
|
2082
2082
|
r.prototype.type = 0, r.prototype.isEnable = !1, r.prototype.isMute = !1, r.prototype.width = 0, r.prototype.height = 0, r.prototype.x = 0, r.prototype.y = 0, r.prototype.updateTime = null;
|
|
2083
|
-
let
|
|
2083
|
+
let o;
|
|
2084
2084
|
return Object.defineProperty(r.prototype, "_updateTime", {
|
|
2085
|
-
get: $util.oneOfGetter(
|
|
2086
|
-
set: $util.oneOfSetter(
|
|
2085
|
+
get: $util.oneOfGetter(o = ["updateTime"]),
|
|
2086
|
+
set: $util.oneOfSetter(o)
|
|
2087
2087
|
}), r.create = function(t) {
|
|
2088
2088
|
return new r(t);
|
|
2089
2089
|
}, r.encode = function(t, e) {
|
|
@@ -2206,10 +2206,10 @@ const $Reader = minimalExports.Reader, $Writer = minimalExports.Writer, $util =
|
|
|
2206
2206
|
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]]);
|
|
2207
2207
|
}
|
|
2208
2208
|
r.prototype.roomId = "", r.prototype.customKeyMap = $util.emptyObject, r.prototype.updateTime = null;
|
|
2209
|
-
let
|
|
2209
|
+
let o;
|
|
2210
2210
|
return Object.defineProperty(r.prototype, "_updateTime", {
|
|
2211
|
-
get: $util.oneOfGetter(
|
|
2212
|
-
set: $util.oneOfSetter(
|
|
2211
|
+
get: $util.oneOfGetter(o = ["updateTime"]),
|
|
2212
|
+
set: $util.oneOfSetter(o)
|
|
2213
2213
|
}), r.create = function(t) {
|
|
2214
2214
|
return new r(t);
|
|
2215
2215
|
}, r.encode = function(t, e) {
|
|
@@ -2309,17 +2309,17 @@ const $Reader = minimalExports.Reader, $Writer = minimalExports.Writer, $util =
|
|
|
2309
2309
|
return t === void 0 && (t = "type.googleapis.com"), t + "/com.quick.voice.proto.CustomInfo";
|
|
2310
2310
|
}, r;
|
|
2311
2311
|
}(), u.LayoutType = function() {
|
|
2312
|
-
const r = {},
|
|
2313
|
-
return
|
|
2312
|
+
const r = {}, o = Object.create(r);
|
|
2313
|
+
return o[r[0] = "AudioAndVideo"] = 0, o[r[1] = "OnlyAudio"] = 1, o[r[2] = "OnlyVideo"] = 2, o;
|
|
2314
2314
|
}(), u.AudioType = function() {
|
|
2315
|
-
const r = {},
|
|
2316
|
-
return
|
|
2315
|
+
const r = {}, o = Object.create(r);
|
|
2316
|
+
return o[r[0] = "Microphone"] = 0, o[r[1] = "SystemVoice"] = 1, o;
|
|
2317
2317
|
}(), u.VideoType = function() {
|
|
2318
|
-
const r = {},
|
|
2319
|
-
return
|
|
2318
|
+
const r = {}, o = Object.create(r);
|
|
2319
|
+
return o[r[0] = "Camera"] = 0, o[r[1] = "Screen"] = 1, o;
|
|
2320
2320
|
}(), u;
|
|
2321
2321
|
}(), a;
|
|
2322
|
-
}(),
|
|
2322
|
+
}(), n;
|
|
2323
2323
|
}(), h;
|
|
2324
2324
|
})(), createAudioInfo = () => ({
|
|
2325
2325
|
remove: !1,
|
|
@@ -2339,25 +2339,25 @@ const $Reader = minimalExports.Reader, $Writer = minimalExports.Writer, $util =
|
|
|
2339
2339
|
});
|
|
2340
2340
|
class RoomUser {
|
|
2341
2341
|
constructor() {
|
|
2342
|
-
|
|
2343
|
-
|
|
2342
|
+
m(this, "userId", "");
|
|
2343
|
+
m(this, "mc_audio");
|
|
2344
2344
|
// 麦克风
|
|
2345
|
-
|
|
2345
|
+
m(this, "mc_video");
|
|
2346
2346
|
// 摄像头
|
|
2347
|
-
|
|
2347
|
+
m(this, "ss_audio");
|
|
2348
2348
|
// 屏幕共享视频
|
|
2349
|
-
|
|
2349
|
+
m(this, "ss_video");
|
|
2350
2350
|
// 屏幕共享音频
|
|
2351
|
-
|
|
2352
|
-
|
|
2353
|
-
const
|
|
2354
|
-
return this.mc_audio &&
|
|
2351
|
+
m(this, "updateTime", 0);
|
|
2352
|
+
m(this, "getUpdateTimeKey", () => {
|
|
2353
|
+
const n = [];
|
|
2354
|
+
return this.mc_audio && n.push(this.mc_audio.updateTime), this.mc_video && n.push(this.mc_video.updateTime), this.ss_audio && n.push(this.ss_audio.updateTime), this.ss_video && n.push(this.ss_video.updateTime), n.join("_");
|
|
2355
2355
|
});
|
|
2356
|
-
|
|
2356
|
+
m(this, "init", (n) => {
|
|
2357
2357
|
var t, e, s, l;
|
|
2358
|
-
const { id: a, audios: u = [], videos: r = [] } =
|
|
2358
|
+
const { id: a, audios: u = [], videos: r = [] } = n;
|
|
2359
2359
|
this.userId = a;
|
|
2360
|
-
const
|
|
2360
|
+
const o = this.getUpdateTimeKey();
|
|
2361
2361
|
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);
|
|
2362
2362
|
for (const c of u) {
|
|
2363
2363
|
const { type: d = 0, isEnable: p = !1, isMute: f = !1, updateTime: w, volume: b = 0 } = c;
|
|
@@ -2377,47 +2377,47 @@ class RoomUser {
|
|
|
2377
2377
|
}
|
|
2378
2378
|
}
|
|
2379
2379
|
for (const c of r) {
|
|
2380
|
-
const { type: d = 0, isEnable: p, isMute: f, updateTime: w, width: b, height:
|
|
2380
|
+
const { type: d = 0, isEnable: p, isMute: f, updateTime: w, width: b, height: g, x: k, y: T } = c;
|
|
2381
2381
|
switch (d) {
|
|
2382
2382
|
case 0:
|
|
2383
2383
|
{
|
|
2384
2384
|
if (this.mc_video || (this.mc_video = createVideoInfo()), this.mc_video.remove = !1, this.mc_video.updateTime === w) break;
|
|
2385
|
-
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 =
|
|
2385
|
+
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 = T || 0, this.mc_video.sw = b || 0, this.mc_video.sh = g || 0;
|
|
2386
2386
|
}
|
|
2387
2387
|
break;
|
|
2388
2388
|
case 1:
|
|
2389
2389
|
{
|
|
2390
2390
|
if (this.ss_video || (this.ss_video = createVideoInfo()), this.ss_video.remove = !1, this.ss_video.updateTime === w) break;
|
|
2391
|
-
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 =
|
|
2391
|
+
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 = T || 0, this.ss_video.sw = b || 0, this.ss_video.sh = g || 0;
|
|
2392
2392
|
}
|
|
2393
2393
|
break;
|
|
2394
2394
|
}
|
|
2395
2395
|
}
|
|
2396
2396
|
(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);
|
|
2397
2397
|
const i = this.getUpdateTimeKey();
|
|
2398
|
-
|
|
2398
|
+
o !== i && (this.updateTime = (/* @__PURE__ */ new Date()).getTime());
|
|
2399
2399
|
});
|
|
2400
|
-
|
|
2401
|
-
var
|
|
2402
|
-
(
|
|
2400
|
+
m(this, "destroy", () => {
|
|
2401
|
+
var n, a;
|
|
2402
|
+
(n = this.mc_video) != null && n.destroy && this.mc_video.destroy(), (a = this.ss_video) != null && a.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;
|
|
2403
2403
|
});
|
|
2404
2404
|
}
|
|
2405
2405
|
}
|
|
2406
2406
|
const parseSEI = (h) => {
|
|
2407
|
-
let
|
|
2407
|
+
let n = 0, a = 0;
|
|
2408
2408
|
for (; ; ) {
|
|
2409
|
-
const r = h[
|
|
2410
|
-
if (a = a + r,
|
|
2409
|
+
const r = h[n];
|
|
2410
|
+
if (a = a + r, n = n + 1, r !== 255) break;
|
|
2411
2411
|
}
|
|
2412
2412
|
let u = 0;
|
|
2413
2413
|
for (; ; ) {
|
|
2414
|
-
const r = h[
|
|
2415
|
-
if (u = u + r,
|
|
2414
|
+
const r = h[n];
|
|
2415
|
+
if (u = u + r, n = n + 1, r !== 255) break;
|
|
2416
2416
|
}
|
|
2417
2417
|
if (a === 5) {
|
|
2418
|
-
const r = h.slice(
|
|
2419
|
-
|
|
2420
|
-
const t = u - 16, e = h.slice(
|
|
2418
|
+
const r = h.slice(n, n + 16), i = Array.from(r, (f) => f.toString(16).padStart(2, "0")).join("");
|
|
2419
|
+
n = n + 16;
|
|
2420
|
+
const t = u - 16, e = h.slice(n, n + t), s = com.quick.voice.proto.SeiData.decode(e), { event: l = 0 } = s, c = s.data;
|
|
2421
2421
|
let d;
|
|
2422
2422
|
switch (l) {
|
|
2423
2423
|
case 0:
|
|
@@ -2431,61 +2431,61 @@ const parseSEI = (h) => {
|
|
|
2431
2431
|
}
|
|
2432
2432
|
};
|
|
2433
2433
|
class QuickVoPlayer {
|
|
2434
|
-
constructor(
|
|
2435
|
-
|
|
2434
|
+
constructor(n = {}) {
|
|
2435
|
+
m(this, "option", {
|
|
2436
2436
|
debug: !1
|
|
2437
2437
|
});
|
|
2438
|
-
|
|
2439
|
-
|
|
2440
|
-
|
|
2441
|
-
|
|
2438
|
+
m(this, "displayMode", "original");
|
|
2439
|
+
m(this, "prPlayer");
|
|
2440
|
+
m(this, "dom");
|
|
2441
|
+
m(this, "room", {
|
|
2442
2442
|
roomId: "",
|
|
2443
2443
|
updateTime: "",
|
|
2444
2444
|
author: "",
|
|
2445
2445
|
version: ""
|
|
2446
2446
|
});
|
|
2447
|
-
|
|
2448
|
-
|
|
2449
|
-
users: (
|
|
2447
|
+
m(this, "usersMap", /* @__PURE__ */ new Map());
|
|
2448
|
+
m(this, "on", {
|
|
2449
|
+
users: (n) => {
|
|
2450
2450
|
}
|
|
2451
2451
|
});
|
|
2452
|
-
|
|
2453
|
-
|
|
2452
|
+
m(this, "start", async (n) => (this.stop(), this.prPlayer.start(n)));
|
|
2453
|
+
m(this, "stop", () => {
|
|
2454
2454
|
this.prPlayer.stop(), this.usersMap = /* @__PURE__ */ new Map(), this.room.roomId = "", this.room.author = "", this.room.updateTime = "", this.room.version = "";
|
|
2455
2455
|
});
|
|
2456
|
-
|
|
2457
|
-
this.prPlayer.setMute(
|
|
2456
|
+
m(this, "setMute", (n) => {
|
|
2457
|
+
this.prPlayer.setMute(n);
|
|
2458
2458
|
});
|
|
2459
|
-
|
|
2460
|
-
|
|
2461
|
-
const
|
|
2462
|
-
return Array.from(
|
|
2459
|
+
m(this, "getStream", () => this.prPlayer.getStream());
|
|
2460
|
+
m(this, "getAllUseUpdateKey", () => {
|
|
2461
|
+
const n = [...this.usersMap.values()];
|
|
2462
|
+
return Array.from(n, (u) => u.updateTime).join("_");
|
|
2463
2463
|
});
|
|
2464
|
-
|
|
2464
|
+
m(this, "checkAndCreateUser", (n, a) => {
|
|
2465
2465
|
var u, r;
|
|
2466
|
-
if (this.usersMap.has(
|
|
2467
|
-
const
|
|
2468
|
-
if (
|
|
2469
|
-
const { sx: i, sy: t, sw: e, sh: s } =
|
|
2470
|
-
(u =
|
|
2466
|
+
if (this.usersMap.has(n)) {
|
|
2467
|
+
const o = this.usersMap.get(n);
|
|
2468
|
+
if (o == null || o.init(a), o != null && o.mc_video) {
|
|
2469
|
+
const { sx: i, sy: t, sw: e, sh: s } = o.mc_video;
|
|
2470
|
+
(u = o == null ? void 0 : o.mc_video.worker) == null || u.setCut({ sx: i, sy: t, sw: e, sh: s });
|
|
2471
2471
|
}
|
|
2472
|
-
if (
|
|
2473
|
-
const { sx: i, sy: t, sw: e, sh: s } =
|
|
2474
|
-
(r =
|
|
2472
|
+
if (o != null && o.ss_video) {
|
|
2473
|
+
const { sx: i, sy: t, sw: e, sh: s } = o.ss_video;
|
|
2474
|
+
(r = o == null ? void 0 : o.ss_video.worker) == null || r.setCut({ sx: i, sy: t, sw: e, sh: s });
|
|
2475
2475
|
}
|
|
2476
2476
|
} else {
|
|
2477
|
-
const
|
|
2478
|
-
if (this.usersMap.set(
|
|
2479
|
-
if (
|
|
2480
|
-
const { sx: i, sy: t, sw: e, sh: s } =
|
|
2481
|
-
|
|
2482
|
-
p(), this.prPlayer.cut.remove(l), this.usersMap.delete(
|
|
2477
|
+
const o = new RoomUser();
|
|
2478
|
+
if (this.usersMap.set(n, o), o.init(a), o) {
|
|
2479
|
+
if (o.mc_video) {
|
|
2480
|
+
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 });
|
|
2481
|
+
o.mc_video.worker = c, this.displayMode === "original" && c.setPause(!0), o.mc_video.stream = d, o.mc_video.destroy = () => {
|
|
2482
|
+
p(), this.prPlayer.cut.remove(l), this.usersMap.delete(o.userId);
|
|
2483
2483
|
};
|
|
2484
2484
|
}
|
|
2485
|
-
if (
|
|
2486
|
-
const { sx: i, sy: t, sw: e, sh: s } =
|
|
2487
|
-
|
|
2488
|
-
p(), this.prPlayer.cut.remove(l), this.usersMap.delete(
|
|
2485
|
+
if (o.ss_video) {
|
|
2486
|
+
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 });
|
|
2487
|
+
o.ss_video.worker = c, this.displayMode === "original" && c.setPause(!0), o.ss_video.stream = d, o.ss_video.destroy = () => {
|
|
2488
|
+
p(), this.prPlayer.cut.remove(l), this.usersMap.delete(o.userId);
|
|
2489
2489
|
};
|
|
2490
2490
|
}
|
|
2491
2491
|
}
|
|
@@ -2494,16 +2494,16 @@ class QuickVoPlayer {
|
|
|
2494
2494
|
/**
|
|
2495
2495
|
* 监听SEI信息
|
|
2496
2496
|
*/
|
|
2497
|
-
|
|
2497
|
+
m(this, "onSEI", (n) => {
|
|
2498
2498
|
try {
|
|
2499
|
-
const a = parseSEI(
|
|
2499
|
+
const a = parseSEI(n);
|
|
2500
2500
|
if (!a) return;
|
|
2501
2501
|
const { event: u, data: r } = a;
|
|
2502
2502
|
switch (u) {
|
|
2503
2503
|
case 0:
|
|
2504
2504
|
{
|
|
2505
|
-
const { roomId:
|
|
2506
|
-
if (
|
|
2505
|
+
const { roomId: o, userMap: i } = r;
|
|
2506
|
+
if (o !== this.room.roomId) return;
|
|
2507
2507
|
const t = this.getAllUseUpdateKey(), e = Object.keys(i);
|
|
2508
2508
|
{
|
|
2509
2509
|
const l = [...this.usersMap.values()];
|
|
@@ -2516,15 +2516,15 @@ class QuickVoPlayer {
|
|
|
2516
2516
|
}
|
|
2517
2517
|
const s = this.getAllUseUpdateKey();
|
|
2518
2518
|
if (t !== s && this.on.users) {
|
|
2519
|
-
const l = [...this.usersMap.values()], c = Array.from(l, ({ userId: d, mc_audio: p, mc_video: f, ss_audio: w, ss_video: b, updateTime:
|
|
2519
|
+
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 }));
|
|
2520
2520
|
this.on.users(c);
|
|
2521
2521
|
}
|
|
2522
2522
|
}
|
|
2523
2523
|
break;
|
|
2524
2524
|
case 1:
|
|
2525
2525
|
{
|
|
2526
|
-
const { roomId:
|
|
2527
|
-
this.room.roomId =
|
|
2526
|
+
const { roomId: o, updateTime: i } = r, { author: t, version: e } = r.customKeyMap;
|
|
2527
|
+
this.room.roomId = o, this.room.updateTime = i, this.room.author = t, this.room.version = e;
|
|
2528
2528
|
}
|
|
2529
2529
|
break;
|
|
2530
2530
|
}
|
|
@@ -2532,15 +2532,15 @@ class QuickVoPlayer {
|
|
|
2532
2532
|
console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", "------->onSEI: error", a);
|
|
2533
2533
|
}
|
|
2534
2534
|
});
|
|
2535
|
-
|
|
2536
|
-
var a, u, r,
|
|
2537
|
-
switch (this.displayMode =
|
|
2535
|
+
m(this, "setDisplayMode", (n) => {
|
|
2536
|
+
var a, u, r, o, i, t, e, s;
|
|
2537
|
+
switch (this.displayMode = n, n) {
|
|
2538
2538
|
case "original":
|
|
2539
2539
|
{
|
|
2540
2540
|
this.prPlayer.setPause(!1);
|
|
2541
2541
|
const l = [...this.usersMap.values()];
|
|
2542
2542
|
for (const c of l)
|
|
2543
|
-
(u = (a = c.mc_video) == null ? void 0 : a.worker) == null || u.setPause(!0), (
|
|
2543
|
+
(u = (a = c.mc_video) == null ? void 0 : a.worker) == null || u.setPause(!0), (o = (r = c.ss_video) == null ? void 0 : r.worker) == null || o.setPause(!0);
|
|
2544
2544
|
}
|
|
2545
2545
|
break;
|
|
2546
2546
|
case "cut":
|
|
@@ -2553,9 +2553,9 @@ class QuickVoPlayer {
|
|
|
2553
2553
|
break;
|
|
2554
2554
|
}
|
|
2555
2555
|
});
|
|
2556
|
-
const { debug: a = !1 } =
|
|
2557
|
-
this.option.debug = a, this.prPlayer = new et({ debug: a }), this.prPlayer.on.demuxer.
|
|
2558
|
-
};
|
|
2556
|
+
const { debug: a = !1 } = n;
|
|
2557
|
+
this.option.debug = a, this.prPlayer = new et({ debug: a }), this.prPlayer.on.demuxer.chunk = (u) => {
|
|
2558
|
+
}, this.prPlayer.on.decoder.sei = this.onSEI;
|
|
2559
2559
|
}
|
|
2560
2560
|
}
|
|
2561
2561
|
export {
|