quickvo-player 0.2.9 → 0.3.1
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/README.md +5 -24
- package/dist/QuickVoPlayer.d.ts +1 -0
- package/dist/RoomUser.d.ts +0 -3
- package/dist/index.js +492 -444
- package/dist/index.umd.cjs +4 -4
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -1,33 +1,33 @@
|
|
|
1
1
|
var Q = Object.defineProperty;
|
|
2
|
-
var
|
|
2
|
+
var J = (h) => {
|
|
3
3
|
throw TypeError(h);
|
|
4
4
|
};
|
|
5
|
-
var
|
|
6
|
-
var m = (h, o,
|
|
7
|
-
var
|
|
8
|
-
const D = '(function(){"use strict";class P{pendingPayloads=[];payload=new Uint8Array(0);chunks=[];push=t=>{this.pendingPayloads.push(t)};next=(t=0)=>{this.payload=this.payload.slice(t);const s=this.pendingPayloads.shift();if(!s)return!1;const e=new Uint8Array(this.payload.byteLength+s.byteLength);return e.set(this.payload,0),e.set(s,this.payload.byteLength),this.payload=e,new DataView(this.payload.buffer)};pushChunk=t=>{this.chunks.push(t),this.chunks.length>1e3&&this.chunks.shift()};destroy=()=>{this.pendingPayloads=[],this.payload=new Uint8Array(0),this.chunks=[]}}const I=(y,t)=>{const s=new Uint8Array(y),e=new Uint8Array(t),n=new Uint8Array(11+s.length+e.length);let a=0;return n[a++]=1,n[a++]=s[1],n[a++]=s[2],n[a++]=s[3],n[a++]=255,n[a++]=225,n[a++]=s.length>>8&255,n[a++]=s.length&255,n.set(s,a),a+=s.length,n[a++]=1,n[a++]=e.length>>8&255,n[a++]=e.length&255,n.set(e,a),n},T=y=>{let t=0;const s=new DataView(y.buffer),e=s.getUint8(t);if(t=t+1,e!==1)throw new Error("Invalid AVC version");const n=s.getUint8(t)&255;t=t+1;const a=s.getUint8(t)&255;t=t+1;const o=s.getUint8(t)&255;t=t+1;const c=`avc1.${Array.from([n,a,o],U=>U.toString(16).padStart(2,"0")).join("")}`,r=(s.getUint8(t)&3)-1;t=t+1;const g=s.getUint8(t)&31;t=t+1;const p=s.getUint16(t,!1);t=t+2;const h=new Uint8Array(s.buffer.slice(t,t+p));t=t+p;const d=s.getUint8(t)&31;t=t+1;const u=s.getUint16(t,!1);t=t+2;const f=new Uint8Array(s.buffer.slice(t,t+u));return t=t+u,{version:e,codec:c,profile:n,compatibility:a,level:o,lengthSizeMinusOne:r,numOfSequenceParameterSets:g,sequenceParameterSetLength:p,sps:h,numOfPictureParameterSets:d,pictureParameterSetLength:u,pps:f}},M=y=>{const t=new Uint8Array(4+y.length);return new DataView(t.buffer).setUint32(0,y.length,!1),t.set(y,4),t},C=y=>{let t=0;for(const n of y)t+=n.length;const s=new Uint8Array(t);let e=0;for(const n of y){const a=n;s.set(a,e),e+=a.length}return s},D=y=>{let t="unknown";switch(y){case 1:case 2:case 27:case 36:t="video";break;case 3:case 4:case 15:t="audio";break;case 6:t="subtitle";break;case 134:t="ad";break}return t};class x{pat;pmt;audioConfig;videoConfig;payloadMap=new Map;on={};constructor(){}parse=async t=>{let s=0;for(;!(s+188>t.byteLength);){if(t.getInt8(s)!=71){s++;continue}await this.parsePacket(t,s),s+=188}return s};parsePacket=async(t,s)=>{if(s+188>t.byteLength)throw new Error("Invalid TS packet");if(t.getUint8(s)!==71)throw new Error("Invalid TS packet");let e=s;const n=this.parseHeader(t,e);e+=4;const{transport_error_indicator:a,pid:o,payload_unit_start_indicator:l,adaptation_field_control:i}=n;if(a===1||o===void 0)return;let c=184;if(i===2||i===3){const r=t.getUint8(e);e+=1,this.parseAdaptationField(t,e),e+=r,c-=r}if(i===3&&(c-=1),i===1||i===3){const r=new Uint8Array(t.buffer.slice(e,e+c));if(o===0)return this.parsePAT(t,e);{const{programs:h=[]}=this.pat||{};if(h.find(u=>u.pmt_pid===o))return this.parsePMT(t,e)}const{streams:g=[]}=this.pmt||{},p=g.find(h=>h.elementary_pid===o);if(p){if(l===1){const h=this.payloadMap.get(o);if(h){switch(p.kind){case"audio":{const d=await this.parseAudio(h);this.on.chunk&&this.on.chunk(d)}break;case"video":{const d=await this.parseVideo(h);this.on.chunk&&this.on.chunk(d),await new Promise(u=>setTimeout(()=>u(!0),0))}break}this.payloadMap.delete(o)}}{this.payloadMap.has(o)||this.payloadMap.set(o,new Uint8Array);const h=this.payloadMap.get(o),d=new Uint8Array(h.byteLength+r.byteLength);d.set(h,0),d.set(r,h.byteLength),this.payloadMap.set(o,d)}}}};parseHeader=(t,s)=>{let e=s;const n=t.getUint8(e),a=t.getUint8(e+1),o=t.getUint8(e+2),l=t.getUint8(e+3),i=(a&128)>>7;if(i===1)return{sync_byte:n,transport_error_indicator:i};const c=(a&64)>>6,r=(a&32)>>5,g=(a&31)<<8|o,p=(l&192)>>6,h=l>>4&3,d=l&15;return{sync_byte:n,transport_error_indicator:i,payload_unit_start_indicator:c,transport_priority:r,pid:g,transport_scrambling_control:p,adaptation_field_control:h,continuity_counter:d}};parsePAT=(t,s)=>{let e=s,n;{const l=t.getUint8(e);e+=1;const i=t.getUint8(e);if(e+=1,i!==0)throw new Error("Invalid PAT table_id");const c=t.getUint16(e)&4095;e+=2;const r=t.getUint16(e);e+=2;const g=(t.getUint8(e)&62)>>1,p=t.getUint8(e)&1;e+=1;const h=t.getUint8(e);e+=1;const d=t.getUint8(e);e+=1,n={pointer_field:l,table_id:i,section_length:c,transport_stream_id:r,version_number:g,current_next_indicator:p,section_number:h,last_section_number:d}}const a=[];{const l=n.section_length-5-4,i=e+l;for(;e<i;){const c=t.getUint16(e),r=t.getUint16(e+2)&8191;e+=4,c!==0&&r>=32&&r<=8190&&a.push({program_number:c,pmt_pid:r})}}const o=t.getUint32(e);this.pat={header:n,programs:a,crc32:o},this.on.debug&&this.on.debug({pat:this.pat})};parsePMT=(t,s)=>{let e=s,n;{const l=t.getUint8(e);e+=1;const i=t.getUint8(e);if(e+=1,i!==2)throw new Error("Invalid PMT table_id");const c=t.getUint16(e)&4095;e+=2;const r=t.getUint16(e);e+=2;const g=(t.getUint8(e)&62)>>1,p=t.getUint8(e)&1;e+=1;const h=t.getUint8(e);e+=1;const d=t.getUint8(e);e+=1;const u=t.getUint16(e)&8191;e+=2;const f=t.getUint16(e)&4095;e+=2,n={pointer_field:l,table_id:i,section_length:c,transport_stream_id:r,version_number:g,current_next_indicator:p,section_number:h,last_section_number:d,pcr_pid:u,program_info_length:f}}const a=[];{const l=n.section_length-9-4,i=e+l;for(;e<i;){const c=t.getUint8(e),r=D(c),g=t.getUint16(e+1)&8191,p=t.getUint16(e+3)&4095;if(e+=5,g<32||g>8190){console.warn(`Invalid elementary_pid: 0x${g.toString(16)}`);continue}a.push({kind:r,stream_type:c,elementary_pid:g,es_info_length:p})}}const o=t.getUint32(e);this.pmt={header:n,streams:a,crc32:o},this.on.debug&&this.on.debug({pmt:this.pmt})};parseAdaptationField=(t,s)=>{let e=s,n,a,o,l;const i=t.getUint8(e),c=!!(i&128),r=!!(i&64),g=!!(i&32),p=!!(i&16),h=!!(i&8),d=!!(i&4),u=!!(i&2),f=!!(i&1);e+=1;const U=(_,b)=>{let m=BigInt(0);m|=BigInt(_.getUint16(b))<<25n,m|=BigInt(_.getUint16(b+1))<<17n,m|=BigInt(_.getUint16(b+2))<<9n,m|=BigInt(_.getUint16(b+3))<<1n,m|=BigInt(_.getUint16(b+4)>>7);const S=(_.getUint16(b+4)&1)<<8|_.getUint16(b+5);return m=m*300n+BigInt(S),m};if(p&&(n=U(t,e),e+=6),h&&(a=U(t,e),e+=6),d&&(o=t.getInt8(e),e+=1),u){const _=t.getUint8(e);e+=1,l=new Uint8Array(t.buffer,e,_),e+=_}return{discontinuity_indicator:c,random_access_indicator:r,elementary_stream_priority_indicator:g,pcr_flag:p,opcr_flag:h,splicing_point_flag:d,transport_private_data_flag:u,adaptation_field_extension_flag:f,pcr:n,opcr:a,splice_countdown:o,transport_private_data:l}};parseAudio=async t=>{const s=new DataView(t.buffer);let e=0,n,a;{const o=s.getUint8(e)===0&&s.getUint8(e+1)===0&&s.getUint8(e+2)===1;if(e+=3,!o)throw new Error("invalid ts audio payload.");const l=s.getUint8(e);e+=1;const i=s.getUint8(e)<<8|s.getUint8(e+1);e+=2;let c,r,g,p,h;{const f=s.getUint8(e);e+=1,c=f>>4&3,r=(f>>3&1)===1,g=(f>>2&1)===1,p=(f>>1&1)===1,h=(f&1)===1}let d,u;{const f=s.getUint8(e);e+=1;const U=f>>6,_=s.getUint8(e);e+=1,(U&2)===2&&(d=this.parsePtsDts(s,e)),(U&1)===1?u=this.parsePtsDts(s,e+5):u=d,e+=_}n={stream_id:l,pes_packet_length:i,scrambling_control:c,priority:r,data_alignment:g,copyright:p,original_copy:h,pts:d,dts:u}}a=t.slice(e);{if(!this.audioConfig&&s.getUint8(e)===255){const g=s.getUint8(e+2),p=s.getUint8(e+3);let h,d;d=g>>2&15,h=(g&1)<<2|p>>6;const u=`mp4a.40.${h}`,U=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350][d];this.audioConfig={kind:"audio",codec:u,sampleRate:U,numberOfChannels:h},this.on.config&&this.on.config(this.audioConfig)}const{dts:o=0,pts:l=0}=n,i=l-o,c=a.slice(7);return{kind:"audio",type:"key",dts:o,pts:l,cts:i,data:c}}};parseVideo=async t=>{const s=new DataView(t.buffer);let e=0,n,a;{const o=s.getUint8(e)===0&&s.getUint8(e+1)===0&&s.getUint8(e+2)===1;if(e+=3,!o)throw new Error("invalid ts video payload.");const l=s.getUint8(e);e+=1;const i=s.getUint8(e)<<8|s.getUint8(e+1);e+=2;let c,r,g,p,h;{const f=s.getUint8(e);e+=1,c=f>>4&3,r=(f>>3&1)===1,g=(f>>2&1)===1,p=(f>>1&1)===1,h=(f&1)===1}let d,u;{const f=s.getUint8(e);e+=1;const U=f>>6,_=s.getUint8(e);e+=1,(U&2)===2&&(d=this.parsePtsDts(s,e)),(U&1)===1?u=this.parsePtsDts(s,e+5):u=d,e+=_}n={stream_id:l,pes_packet_length:i,scrambling_control:c,priority:r,data_alignment:g,copyright:p,original_copy:h,pts:d,dts:u}}a=t.slice(e);{const o=this.getNalus(a);if(!this.videoConfig){let h,d;if(h=o.find(f=>f.type===7)?.nalu.slice(4),d=o.find(f=>f.type===8)?.nalu.slice(4),h&&d){const u=I(h,d),{codec:f}=T(u);this.videoConfig={kind:"video",codec:f,description:u,sps:h,pps:d},this.on.config&&this.on.config(this.videoConfig)}}const l=[];let i="delta";for(const h of o){const{type:d,nalu:u}=h;switch(d){case 6:case 9:l.push(u);break;case 1:i="delta",l.push(u);break;case 5:i="key",l.push(u);break}}const c=C(l),{dts:r=0,pts:g=0}=n,p=g-r;return{kind:"video",type:i,dts:r,pts:g,cts:p,data:c,nalus:l}}};parsePtsDts(t,s){const e=t.getUint8(s),n=t.getUint8(s+1),a=t.getUint8(s+2),o=t.getUint8(s+3),l=t.getUint8(s+4),i=(BigInt(e)&0b00001110n)<<29n|(BigInt(n)&0b11111111n)<<22n|(BigInt(a)&0b11111110n)<<14n|(BigInt(o)&0b11111111n)<<7n|(BigInt(l)&0b11111110n)>>1n;return Number(i)/90}getNalus=t=>{const s=[];let e=0;for(;!(e+4>t.byteLength);){if(t[e]!==0||t[e+1]!==0||t[e+2]!==1){e+=1;continue}e+=3;let n=e;const a=t[e]&31;for(e+=1;!(e+1>t.byteLength);){if(t[e]!==0||t[e+1]!==0||t[e+2]!==1){e+=1;continue}break}let o=e-n;if(t[e-1]===0&&(o-=1),o!==0){const l=t.slice(n,n+o),i=M(l);s.push({type:a,nalu:i})}}return s}}const k=(y,t)=>y.getUint8(t)<<16|y.getUint8(t+1)<<8|y.getUint8(t+2);class L{audioConfig;videoConfig;header;textDecoder=new TextDecoder("utf-8");on={};constructor(){}parse=async t=>{let s=0;for(this.header||(this.parseHeader(t,s),s+=9);this.isSurplusTag(t,s)!==!1;){const n=this.parseTagHeader(t,s+4),{tagType:a,dataSize:o,timestamp:l}=n;if(a){const i=this.parseTagBody(a,t,s+4+11,o);switch(a){case"script":this.on.info&&this.on.info(i);break;case"audio":{const{accPacketType:c}=i;if(c===0){const{codec:r,sampleRate:g,channelConfiguration:p}=i;this.audioConfig={kind:"audio",codec:r,sampleRate:g,numberOfChannels:p},this.on.config&&this.on.config(this.audioConfig)}else{const{cts:r,data:g}=i,p="key",h=r===void 0?void 0:r+l;this.on.chunk&&this.on.chunk({kind:"audio",type:p,dts:l,pts:h,cts:r,data:g})}}break;case"video":{const{avcPacketType:c}=i;if(c===0){const{codec:r,sps:g,pps:p,data:h}=i;this.videoConfig={kind:"video",codec:r,description:h,sps:g,pps:p},this.on.config&&this.on.config(this.videoConfig)}else{const{frameType:r,cts:g,data:p,nalus:h}=i,d=r===1?"key":"delta",u=g===void 0?void 0:g+l;this.on.chunk&&this.on.chunk({kind:"video",type:d,dts:l,pts:u,cts:g,data:p,nalus:h})}}break}s=s+4+11+o}await new Promise(i=>setTimeout(()=>i(!0),8))}return s};parseHeader=(t,s)=>{let e,n,a,o;e=t.getUint8(s)<<16|t.getUint8(s+1)<<8|t.getUint8(s+2),n=t.getUint8(3);{const i=t.getUint8(0).toString(2).padStart(5,"0").split(""),[,,c,,r]=i;a={audio:r==="1",video:c==="1"}}o=t.getUint32(5),this.header={signature:e,version:n,flags:a,dataOffset:o}};isSurplusTag=(t,s)=>{let e=!0;const n=t.byteLength;if(s+4>n)e=!1;else if(s+4+11>n)e=!1;else{const a=k(t,s+4+1);s+4+11+a>n&&(e=!1)}return e};parseTagHeader=(t,s)=>{let e,n,a,o,l;{const i=t.getUint8(s);let c;switch(i){case 18:c="script";break;case 8:c="audio";break;case 9:c="video";break}e=c}return n=k(t,s+1),a=k(t,s+4),o=t.getUint8(s+7),l=k(t,s+8),{tagType:e,dataSize:n,timestamp:a,timestampExtended:o,streamID:l}};parseTagBody=(t,s,e,n)=>{let a;switch(t){case"script":a=this.parseMetaData(s,e);break;case"audio":a=this.parseAudio(s,e,n);break;case"video":a=this.parseVideo(s,e,n);break}return a};parseMetaData=(t,s)=>{let e=s;{if(t.getUint8(e)!==2)throw new Error("Invalid AMF type for onMetaData (expected 0x02)");e=e+1}const n=t.getUint16(e,!1);e=e+2;{const l=new Int8Array(t.buffer.slice(e,e+n));if((this.textDecoder?.decode(l)||"")!=="onMetaData")throw new Error("Expected \'onMetaData\' string");e=e+n}const a=this.getAmfType(t,e);return e=e+1,this.getAMFValue(t,e,a).value};parseAudio=(t,s,e)=>{let n=s;const a=t.getUint8(n),o=a>>4&15,l=a>>2&3,i=a>>1&1,c=a&1;n=n+1;const r=t.getUint8(n);n=n+1;const g=e,p=new Uint8Array(t.buffer.slice(n,n+g));if(o===10&&r===0){const h=t.getUint8(n),d=t.getUint8(n+1),u=h>>3&31,f=(h&7)<<1|d>>7,U=d>>3&15,_=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350],b=`mp4a.40.${u}`,m=_[f];return{soundFormat:o,soundRate:l,soundSize:i,soundType:c,accPacketType:r,data:p,samplingFrequencyIndex:f,channelConfiguration:U,codec:b,sampleRate:m}}return{soundFormat:o,soundRate:l,soundSize:i,soundType:c,accPacketType:r,data:p}};parseVideo=(t,s,e)=>{let n=s;const a=t.getUint8(n),o=a>>4&15,l=a&15;n=n+1;const i=t.getUint8(n);n=n+1;const c=k(t,n);n=n+3;const r=e-5,g=new Uint8Array(t.buffer.slice(n,n+r));switch(l){case 7:if(i===0){const p=T(g);return{frameType:o,codecID:l,avcPacketType:i,cts:c,data:g,...p}}else if(i===1){const p=[],h=n+e-5;for(;!(n+4>h);){const d=t.getUint32(n,!1),u=new Uint8Array(t.buffer.slice(n,n+4+d));n+=4+d,p.push(u)}return{frameType:o,codecID:l,avcPacketType:i,cts:c,data:g,nalus:p}}break;default:throw new Error("Unsupported codecID")}return{frameType:o,codecID:l,avcPacketType:i,cts:c,data:g}};getAmfType=(t,s)=>t.getUint8(s);getAMFName=(t,s,e)=>{const n=new Uint8Array(t.buffer.slice(s,s+e));return this.textDecoder?.decode(n)||""};getAMFValue=(t,s,e)=>{let n=s,a,o=0;switch(e){case 0:a=t.getFloat64(n,!1),o=8;break;case 1:a=!!t.getUint8(n),o=1;break;case 2:{a="";const i=t.getUint16(n,!1);n=n+2;const c=new Int8Array(t.buffer,n,i).filter(g=>g!==0);a=(this.textDecoder?.decode(c)||"").trim(),o=2+i}break;case 3:for(a={};n<t.byteLength;){const i=t.getUint16(n,!1);if(i===0)break;n=n+2;const c=this.getAMFName(t,n,i);n=n+i;const r=this.getAmfType(t,n);if(r===6)break;n=n+1;const g=this.getAMFValue(t,n,r);n=n+g.length,a[c]=g.value,o=2+i+1+g.length}break;case 8:{a={};const i=t.getUint32(n,!1);n=n+4;for(let c=0;c<i;c++){const r=t.getUint16(n,!1);n=n+2;const g=this.getAMFName(t,n,r);n=n+r;const p=this.getAmfType(t,n);n=n+1;const h=this.getAMFValue(t,n,p);n=n+h.length,a[g]=h.value,o=2+r+1+h.length}}break;case 10:{a=[];const i=t.getUint32(n,!1);n=n+4;for(let c=0;c<i;c++){const r=this.getAmfType(t,n);n=n+1;const g=this.getAMFValue(t,n,r);n=n+g.length,a.push(g.value),o=1+g.length}}break}return{amfType:e,length:o,value:a}}}class O{pattern;cacher=new P;isParseing=!1;offset=0;parser;on={};constructor(){}init=t=>{switch(this.destroy(),this.pattern=t,this.pattern){case"flv":this.parser=new L;break;case"hls":this.parser=new x;break;default:throw new Error("is error pattern.")}this.parser.on.debug=s=>this.on.debug&&this.on.debug(s),this.parser.on.info=s=>this.on.info&&this.on.info(s),this.parser.on.config=s=>this.on.config&&this.on.config(s),this.parser.on.chunk=s=>{this.cacher.pushChunk(s),this.on.chunk&&this.on.chunk(s)}};push=t=>{this.cacher.push(t),this.isParseing===!1&&this.parse()};destroy=()=>{this.cacher.destroy(),this.isParseing=!1,this.offset=0};parse=async()=>{try{if(this.isParseing=!0,!this.pattern)throw new Error("You need to set the pattern.");if(!this.parser)throw new Error("You need to init parser.");for(;;){const t=this.cacher.next(this.offset);if(this.offset=0,!t)break;this.offset=await this.parser.parse(t)}this.isParseing=!1}catch{this.destroy()}}}const A=new O;A.on.info=y=>postMessage({action:"on.info",data:y}),A.on.config=y=>postMessage({action:"on.config",data:y}),A.on.chunk=y=>postMessage({action:"on.chunk",data:y}),A.on.debug=y=>postMessage({action:"on.debug",data:y}),onmessage=y=>{const{action:t,data:s}=y.data,e=A[t];e&&e(s)}})();\n', _ = typeof self < "u" && self.Blob && new Blob(["(self.URL || self.webkitURL).revokeObjectURL(self.location.href);", D], { type: "text/javascript;charset=utf-8" });
|
|
9
|
-
function
|
|
5
|
+
var Y = (h, o, a) => o in h ? Q(h, o, { enumerable: !0, configurable: !0, writable: !0, value: a }) : h[o] = a;
|
|
6
|
+
var m = (h, o, a) => Y(h, typeof o != "symbol" ? o + "" : o, a), Z = (h, o, a) => o.has(h) || J("Cannot " + a);
|
|
7
|
+
var R = (h, o, a) => (Z(h, o, "read from private field"), a ? a.call(h) : o.get(h)), H = (h, o, a) => o.has(h) ? J("Cannot add the same private member more than once") : o instanceof WeakSet ? o.add(h) : o.set(h, a), K = (h, o, a, u) => (Z(h, o, "write to private field"), u ? u.call(h, a) : o.set(h, a), a);
|
|
8
|
+
const A = '(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>100&&this.chunks.shift()};destroy=()=>{this.pendingPayloads=[],this.payload=new Uint8Array(0),this.chunks=[]}}const I=(y,t)=>{const s=new Uint8Array(y),e=new Uint8Array(t),n=new Uint8Array(11+s.length+e.length);let a=0;return n[a++]=1,n[a++]=s[1],n[a++]=s[2],n[a++]=s[3],n[a++]=255,n[a++]=225,n[a++]=s.length>>8&255,n[a++]=s.length&255,n.set(s,a),a+=s.length,n[a++]=1,n[a++]=e.length>>8&255,n[a++]=e.length&255,n.set(e,a),n},T=y=>{let t=0;const s=new DataView(y.buffer),e=s.getUint8(t);if(t=t+1,e!==1)throw new Error("Invalid AVC version");const n=s.getUint8(t)&255;t=t+1;const a=s.getUint8(t)&255;t=t+1;const o=s.getUint8(t)&255;t=t+1;const c=`avc1.${Array.from([n,a,o],U=>U.toString(16).padStart(2,"0")).join("")}`,r=(s.getUint8(t)&3)-1;t=t+1;const g=s.getUint8(t)&31;t=t+1;const p=s.getUint16(t,!1);t=t+2;const h=new Uint8Array(s.buffer.slice(t,t+p));t=t+p;const d=s.getUint8(t)&31;t=t+1;const u=s.getUint16(t,!1);t=t+2;const f=new Uint8Array(s.buffer.slice(t,t+u));return t=t+u,{version:e,codec:c,profile:n,compatibility:a,level:o,lengthSizeMinusOne:r,numOfSequenceParameterSets:g,sequenceParameterSetLength:p,sps:h,numOfPictureParameterSets:d,pictureParameterSetLength:u,pps:f}},M=y=>{const t=new Uint8Array(4+y.length);return new DataView(t.buffer).setUint32(0,y.length,!1),t.set(y,4),t},C=y=>{let t=0;for(const n of y)t+=n.length;const s=new Uint8Array(t);let e=0;for(const n of y){const a=n;s.set(a,e),e+=a.length}return s},D=y=>{let t="unknown";switch(y){case 1:case 2:case 27:case 36:t="video";break;case 3:case 4:case 15:t="audio";break;case 6:t="subtitle";break;case 134:t="ad";break}return t};class x{pat;pmt;audioConfig;videoConfig;payloadMap=new Map;on={};constructor(){}parse=async t=>{let s=0;for(;!(s+188>t.byteLength);){if(t.getInt8(s)!=71){s++;continue}await this.parsePacket(t,s),s+=188}return s};parsePacket=async(t,s)=>{if(s+188>t.byteLength)throw new Error("Invalid TS packet");if(t.getUint8(s)!==71)throw new Error("Invalid TS packet");let e=s;const n=this.parseHeader(t,e);e+=4;const{transport_error_indicator:a,pid:o,payload_unit_start_indicator:l,adaptation_field_control:i}=n;if(a===1||o===void 0)return;let c=184;if(i===2||i===3){const r=t.getUint8(e);e+=1,this.parseAdaptationField(t,e),e+=r,c-=r}if(i===3&&(c-=1),i===1||i===3){const r=new Uint8Array(t.buffer.slice(e,e+c));if(o===0)return this.parsePAT(t,e);{const{programs:h=[]}=this.pat||{};if(h.find(u=>u.pmt_pid===o))return this.parsePMT(t,e)}const{streams:g=[]}=this.pmt||{},p=g.find(h=>h.elementary_pid===o);if(p){if(l===1){const h=this.payloadMap.get(o);if(h){switch(p.kind){case"audio":{const d=await this.parseAudio(h);this.on.chunk&&this.on.chunk(d)}break;case"video":{const d=await this.parseVideo(h);this.on.chunk&&this.on.chunk(d),await new Promise(u=>setTimeout(()=>u(!0),0))}break}this.payloadMap.delete(o)}}{this.payloadMap.has(o)||this.payloadMap.set(o,new Uint8Array);const h=this.payloadMap.get(o),d=new Uint8Array(h.byteLength+r.byteLength);d.set(h,0),d.set(r,h.byteLength),this.payloadMap.set(o,d)}}}};parseHeader=(t,s)=>{let e=s;const n=t.getUint8(e),a=t.getUint8(e+1),o=t.getUint8(e+2),l=t.getUint8(e+3),i=(a&128)>>7;if(i===1)return{sync_byte:n,transport_error_indicator:i};const c=(a&64)>>6,r=(a&32)>>5,g=(a&31)<<8|o,p=(l&192)>>6,h=l>>4&3,d=l&15;return{sync_byte:n,transport_error_indicator:i,payload_unit_start_indicator:c,transport_priority:r,pid:g,transport_scrambling_control:p,adaptation_field_control:h,continuity_counter:d}};parsePAT=(t,s)=>{let e=s,n;{const l=t.getUint8(e);e+=1;const i=t.getUint8(e);if(e+=1,i!==0)throw new Error("Invalid PAT table_id");const c=t.getUint16(e)&4095;e+=2;const r=t.getUint16(e);e+=2;const g=(t.getUint8(e)&62)>>1,p=t.getUint8(e)&1;e+=1;const h=t.getUint8(e);e+=1;const d=t.getUint8(e);e+=1,n={pointer_field:l,table_id:i,section_length:c,transport_stream_id:r,version_number:g,current_next_indicator:p,section_number:h,last_section_number:d}}const a=[];{const l=n.section_length-5-4,i=e+l;for(;e<i;){const c=t.getUint16(e),r=t.getUint16(e+2)&8191;e+=4,c!==0&&r>=32&&r<=8190&&a.push({program_number:c,pmt_pid:r})}}const o=t.getUint32(e);this.pat={header:n,programs:a,crc32:o},this.on.debug&&this.on.debug({pat:this.pat})};parsePMT=(t,s)=>{let e=s,n;{const l=t.getUint8(e);e+=1;const i=t.getUint8(e);if(e+=1,i!==2)throw new Error("Invalid PMT table_id");const c=t.getUint16(e)&4095;e+=2;const r=t.getUint16(e);e+=2;const g=(t.getUint8(e)&62)>>1,p=t.getUint8(e)&1;e+=1;const h=t.getUint8(e);e+=1;const d=t.getUint8(e);e+=1;const u=t.getUint16(e)&8191;e+=2;const f=t.getUint16(e)&4095;e+=2,n={pointer_field:l,table_id:i,section_length:c,transport_stream_id:r,version_number:g,current_next_indicator:p,section_number:h,last_section_number:d,pcr_pid:u,program_info_length:f}}const a=[];{const l=n.section_length-9-4,i=e+l;for(;e<i;){const c=t.getUint8(e),r=D(c),g=t.getUint16(e+1)&8191,p=t.getUint16(e+3)&4095;if(e+=5,g<32||g>8190){console.warn(`Invalid elementary_pid: 0x${g.toString(16)}`);continue}a.push({kind:r,stream_type:c,elementary_pid:g,es_info_length:p})}}const o=t.getUint32(e);this.pmt={header:n,streams:a,crc32:o},this.on.debug&&this.on.debug({pmt:this.pmt})};parseAdaptationField=(t,s)=>{let e=s,n,a,o,l;const i=t.getUint8(e),c=!!(i&128),r=!!(i&64),g=!!(i&32),p=!!(i&16),h=!!(i&8),d=!!(i&4),u=!!(i&2),f=!!(i&1);e+=1;const U=(_,b)=>{let m=BigInt(0);m|=BigInt(_.getUint16(b))<<25n,m|=BigInt(_.getUint16(b+1))<<17n,m|=BigInt(_.getUint16(b+2))<<9n,m|=BigInt(_.getUint16(b+3))<<1n,m|=BigInt(_.getUint16(b+4)>>7);const S=(_.getUint16(b+4)&1)<<8|_.getUint16(b+5);return m=m*300n+BigInt(S),m};if(p&&(n=U(t,e),e+=6),h&&(a=U(t,e),e+=6),d&&(o=t.getInt8(e),e+=1),u){const _=t.getUint8(e);e+=1,l=new Uint8Array(t.buffer,e,_),e+=_}return{discontinuity_indicator:c,random_access_indicator:r,elementary_stream_priority_indicator:g,pcr_flag:p,opcr_flag:h,splicing_point_flag:d,transport_private_data_flag:u,adaptation_field_extension_flag:f,pcr:n,opcr:a,splice_countdown:o,transport_private_data:l}};parseAudio=async t=>{const s=new DataView(t.buffer);let e=0,n,a;{const o=s.getUint8(e)===0&&s.getUint8(e+1)===0&&s.getUint8(e+2)===1;if(e+=3,!o)throw new Error("invalid ts audio payload.");const l=s.getUint8(e);e+=1;const i=s.getUint8(e)<<8|s.getUint8(e+1);e+=2;let c,r,g,p,h;{const f=s.getUint8(e);e+=1,c=f>>4&3,r=(f>>3&1)===1,g=(f>>2&1)===1,p=(f>>1&1)===1,h=(f&1)===1}let d,u;{const f=s.getUint8(e);e+=1;const U=f>>6,_=s.getUint8(e);e+=1,(U&2)===2&&(d=this.parsePtsDts(s,e)),(U&1)===1?u=this.parsePtsDts(s,e+5):u=d,e+=_}n={stream_id:l,pes_packet_length:i,scrambling_control:c,priority:r,data_alignment:g,copyright:p,original_copy:h,pts:d,dts:u}}a=t.slice(e);{if(!this.audioConfig&&s.getUint8(e)===255){const g=s.getUint8(e+2),p=s.getUint8(e+3);let h,d;d=g>>2&15,h=(g&1)<<2|p>>6;const u=`mp4a.40.${h}`,U=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350][d];this.audioConfig={kind:"audio",codec:u,sampleRate:U,numberOfChannels:h},this.on.config&&this.on.config(this.audioConfig)}const{dts:o=0,pts:l=0}=n,i=l-o,c=a.slice(7);return{kind:"audio",type:"key",dts:o,pts:l,cts:i,data:c}}};parseVideo=async t=>{const s=new DataView(t.buffer);let e=0,n,a;{const o=s.getUint8(e)===0&&s.getUint8(e+1)===0&&s.getUint8(e+2)===1;if(e+=3,!o)throw new Error("invalid ts video payload.");const l=s.getUint8(e);e+=1;const i=s.getUint8(e)<<8|s.getUint8(e+1);e+=2;let c,r,g,p,h;{const f=s.getUint8(e);e+=1,c=f>>4&3,r=(f>>3&1)===1,g=(f>>2&1)===1,p=(f>>1&1)===1,h=(f&1)===1}let d,u;{const f=s.getUint8(e);e+=1;const U=f>>6,_=s.getUint8(e);e+=1,(U&2)===2&&(d=this.parsePtsDts(s,e)),(U&1)===1?u=this.parsePtsDts(s,e+5):u=d,e+=_}n={stream_id:l,pes_packet_length:i,scrambling_control:c,priority:r,data_alignment:g,copyright:p,original_copy:h,pts:d,dts:u}}a=t.slice(e);{const o=this.getNalus(a);if(!this.videoConfig){let h,d;if(h=o.find(f=>f.type===7)?.nalu.slice(4),d=o.find(f=>f.type===8)?.nalu.slice(4),h&&d){const u=I(h,d),{codec:f}=T(u);this.videoConfig={kind:"video",codec:f,description:u,sps:h,pps:d},this.on.config&&this.on.config(this.videoConfig)}}const l=[];let i="delta";for(const h of o){const{type:d,nalu:u}=h;switch(d){case 6:case 9:l.push(u);break;case 1:i="delta",l.push(u);break;case 5:i="key",l.push(u);break}}const c=C(l),{dts:r=0,pts:g=0}=n,p=g-r;return{kind:"video",type:i,dts:r,pts:g,cts:p,data:c,nalus:l}}};parsePtsDts(t,s){const e=t.getUint8(s),n=t.getUint8(s+1),a=t.getUint8(s+2),o=t.getUint8(s+3),l=t.getUint8(s+4),i=(BigInt(e)&0b00001110n)<<29n|(BigInt(n)&0b11111111n)<<22n|(BigInt(a)&0b11111110n)<<14n|(BigInt(o)&0b11111111n)<<7n|(BigInt(l)&0b11111110n)>>1n;return Number(i)/90}getNalus=t=>{const s=[];let e=0;for(;!(e+4>t.byteLength);){if(t[e]!==0||t[e+1]!==0||t[e+2]!==1){e+=1;continue}e+=3;let n=e;const a=t[e]&31;for(e+=1;!(e+1>t.byteLength);){if(t[e]!==0||t[e+1]!==0||t[e+2]!==1){e+=1;continue}break}let o=e-n;if(t[e-1]===0&&(o-=1),o!==0){const l=t.slice(n,n+o),i=M(l);s.push({type:a,nalu:i})}}return s}}const k=(y,t)=>y.getUint8(t)<<16|y.getUint8(t+1)<<8|y.getUint8(t+2);class L{audioConfig;videoConfig;header;textDecoder=new TextDecoder("utf-8");on={};constructor(){}parse=async t=>{let s=0;for(this.header||(this.parseHeader(t,s),s+=9);this.isSurplusTag(t,s)!==!1;){const n=this.parseTagHeader(t,s+4),{tagType:a,dataSize:o,timestamp:l}=n;if(a){const i=this.parseTagBody(a,t,s+4+11,o);switch(a){case"script":this.on.info&&this.on.info(i);break;case"audio":{const{accPacketType:c}=i;if(c===0){const{codec:r,sampleRate:g,channelConfiguration:p}=i;this.audioConfig={kind:"audio",codec:r,sampleRate:g,numberOfChannels:p},this.on.config&&this.on.config(this.audioConfig)}else{const{cts:r,data:g}=i,p="key",h=r===void 0?void 0:r+l;this.on.chunk&&this.on.chunk({kind:"audio",type:p,dts:l,pts:h,cts:r,data:g})}}break;case"video":{const{avcPacketType:c}=i;if(c===0){const{codec:r,sps:g,pps:p,data:h}=i;this.videoConfig={kind:"video",codec:r,description:h,sps:g,pps:p},this.on.config&&this.on.config(this.videoConfig)}else{const{frameType:r,cts:g,data:p,nalus:h}=i,d=r===1?"key":"delta",u=g===void 0?void 0:g+l;this.on.chunk&&this.on.chunk({kind:"video",type:d,dts:l,pts:u,cts:g,data:p,nalus:h})}}break}s=s+4+11+o}await new Promise(i=>setTimeout(()=>i(!0),8))}return s};parseHeader=(t,s)=>{let e,n,a,o;e=t.getUint8(s)<<16|t.getUint8(s+1)<<8|t.getUint8(s+2),n=t.getUint8(3);{const i=t.getUint8(0).toString(2).padStart(5,"0").split(""),[,,c,,r]=i;a={audio:r==="1",video:c==="1"}}o=t.getUint32(5),this.header={signature:e,version:n,flags:a,dataOffset:o}};isSurplusTag=(t,s)=>{let e=!0;const n=t.byteLength;if(s+4>n)e=!1;else if(s+4+11>n)e=!1;else{const a=k(t,s+4+1);s+4+11+a>n&&(e=!1)}return e};parseTagHeader=(t,s)=>{let e,n,a,o,l;{const i=t.getUint8(s);let c;switch(i){case 18:c="script";break;case 8:c="audio";break;case 9:c="video";break}e=c}return n=k(t,s+1),a=k(t,s+4),o=t.getUint8(s+7),l=k(t,s+8),{tagType:e,dataSize:n,timestamp:a,timestampExtended:o,streamID:l}};parseTagBody=(t,s,e,n)=>{let a;switch(t){case"script":a=this.parseMetaData(s,e);break;case"audio":a=this.parseAudio(s,e,n);break;case"video":a=this.parseVideo(s,e,n);break}return a};parseMetaData=(t,s)=>{let e=s;{if(t.getUint8(e)!==2)throw new Error("Invalid AMF type for onMetaData (expected 0x02)");e=e+1}const n=t.getUint16(e,!1);e=e+2;{const l=new Int8Array(t.buffer.slice(e,e+n));if((this.textDecoder?.decode(l)||"")!=="onMetaData")throw new Error("Expected \'onMetaData\' string");e=e+n}const a=this.getAmfType(t,e);return e=e+1,this.getAMFValue(t,e,a).value};parseAudio=(t,s,e)=>{let n=s;const a=t.getUint8(n),o=a>>4&15,l=a>>2&3,i=a>>1&1,c=a&1;n=n+1;const r=t.getUint8(n);n=n+1;const g=e,p=new Uint8Array(t.buffer.slice(n,n+g));if(o===10&&r===0){const h=t.getUint8(n),d=t.getUint8(n+1),u=h>>3&31,f=(h&7)<<1|d>>7,U=d>>3&15,_=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350],b=`mp4a.40.${u}`,m=_[f];return{soundFormat:o,soundRate:l,soundSize:i,soundType:c,accPacketType:r,data:p,samplingFrequencyIndex:f,channelConfiguration:U,codec:b,sampleRate:m}}return{soundFormat:o,soundRate:l,soundSize:i,soundType:c,accPacketType:r,data:p}};parseVideo=(t,s,e)=>{let n=s;const a=t.getUint8(n),o=a>>4&15,l=a&15;n=n+1;const i=t.getUint8(n);n=n+1;const c=k(t,n);n=n+3;const r=e-5,g=new Uint8Array(t.buffer.slice(n,n+r));switch(l){case 7:if(i===0){const p=T(g);return{frameType:o,codecID:l,avcPacketType:i,cts:c,data:g,...p}}else if(i===1){const p=[],h=n+e-5;for(;!(n+4>h);){const d=t.getUint32(n,!1),u=new Uint8Array(t.buffer.slice(n,n+4+d));n+=4+d,p.push(u)}return{frameType:o,codecID:l,avcPacketType:i,cts:c,data:g,nalus:p}}break;default:throw new Error("Unsupported codecID")}return{frameType:o,codecID:l,avcPacketType:i,cts:c,data:g}};getAmfType=(t,s)=>t.getUint8(s);getAMFName=(t,s,e)=>{const n=new Uint8Array(t.buffer.slice(s,s+e));return this.textDecoder?.decode(n)||""};getAMFValue=(t,s,e)=>{let n=s,a,o=0;switch(e){case 0:a=t.getFloat64(n,!1),o=8;break;case 1:a=!!t.getUint8(n),o=1;break;case 2:{a="";const i=t.getUint16(n,!1);n=n+2;const c=new Int8Array(t.buffer,n,i).filter(g=>g!==0);a=(this.textDecoder?.decode(c)||"").trim(),o=2+i}break;case 3:for(a={};n<t.byteLength;){const i=t.getUint16(n,!1);if(i===0)break;n=n+2;const c=this.getAMFName(t,n,i);n=n+i;const r=this.getAmfType(t,n);if(r===6)break;n=n+1;const g=this.getAMFValue(t,n,r);n=n+g.length,a[c]=g.value,o=2+i+1+g.length}break;case 8:{a={};const i=t.getUint32(n,!1);n=n+4;for(let c=0;c<i;c++){const r=t.getUint16(n,!1);n=n+2;const g=this.getAMFName(t,n,r);n=n+r;const p=this.getAmfType(t,n);n=n+1;const h=this.getAMFValue(t,n,p);n=n+h.length,a[g]=h.value,o=2+r+1+h.length}}break;case 10:{a=[];const i=t.getUint32(n,!1);n=n+4;for(let c=0;c<i;c++){const r=this.getAmfType(t,n);n=n+1;const g=this.getAMFValue(t,n,r);n=n+g.length,a.push(g.value),o=1+g.length}}break}return{amfType:e,length:o,value:a}}}class O{pattern;cacher=new P;isParseing=!1;offset=0;parser;on={};constructor(){}init=t=>{switch(this.destroy(),this.pattern=t,this.pattern){case"flv":this.parser=new L;break;case"hls":this.parser=new x;break;default:throw new Error("is error pattern.")}this.parser.on.debug=s=>this.on.debug&&this.on.debug(s),this.parser.on.info=s=>this.on.info&&this.on.info(s),this.parser.on.config=s=>this.on.config&&this.on.config(s),this.parser.on.chunk=s=>{this.cacher.pushChunk(s),this.on.chunk&&this.on.chunk(s)}};push=t=>{this.cacher.push(t),this.isParseing===!1&&this.parse()};destroy=()=>{this.cacher.destroy(),this.isParseing=!1,this.offset=0};parse=async()=>{try{if(this.isParseing=!0,!this.pattern)throw new Error("You need to set the pattern.");if(!this.parser)throw new Error("You need to init parser.");for(;;){const t=this.cacher.next(this.offset);if(this.offset=0,!t)break;this.offset=await this.parser.parse(t)}this.isParseing=!1}catch{this.destroy()}}}const A=new O;A.on.info=y=>postMessage({action:"on.info",data:y}),A.on.config=y=>postMessage({action:"on.config",data:y}),A.on.chunk=y=>postMessage({action:"on.chunk",data:y}),A.on.debug=y=>postMessage({action:"on.debug",data:y}),onmessage=y=>{const{action:t,data:s}=y.data,e=A[t];e&&e(s)}})();\n', _ = typeof self < "u" && self.Blob && new Blob(["(self.URL || self.webkitURL).revokeObjectURL(self.location.href);", A], { type: "text/javascript;charset=utf-8" });
|
|
9
|
+
function P(h) {
|
|
10
10
|
let o;
|
|
11
11
|
try {
|
|
12
12
|
if (o = _ && (self.URL || self.webkitURL).createObjectURL(_), !o) throw "";
|
|
13
|
-
const
|
|
13
|
+
const a = new Worker(o, {
|
|
14
14
|
name: h == null ? void 0 : h.name
|
|
15
15
|
});
|
|
16
|
-
return
|
|
16
|
+
return a.addEventListener("error", () => {
|
|
17
17
|
(self.URL || self.webkitURL).revokeObjectURL(o);
|
|
18
|
-
}),
|
|
18
|
+
}), a;
|
|
19
19
|
} catch {
|
|
20
20
|
return new Worker(
|
|
21
|
-
"data:text/javascript;charset=utf-8," + encodeURIComponent(
|
|
21
|
+
"data:text/javascript;charset=utf-8," + encodeURIComponent(A),
|
|
22
22
|
{
|
|
23
23
|
name: h == null ? void 0 : h.name
|
|
24
24
|
}
|
|
25
25
|
);
|
|
26
26
|
}
|
|
27
27
|
}
|
|
28
|
-
class
|
|
28
|
+
class I {
|
|
29
29
|
constructor() {
|
|
30
|
-
m(this, "worker", new
|
|
30
|
+
m(this, "worker", new P());
|
|
31
31
|
m(this, "on", {});
|
|
32
32
|
m(this, "init", (o) => this.worker.postMessage({ action: "init", data: o }));
|
|
33
33
|
m(this, "push", (o) => this.worker.postMessage({ action: "push", data: o }));
|
|
@@ -35,48 +35,48 @@ class V {
|
|
|
35
35
|
this.worker.postMessage({ action: "destroy", data: {} }), this.worker.terminate();
|
|
36
36
|
});
|
|
37
37
|
this.worker.onmessage = (o) => {
|
|
38
|
-
const { action:
|
|
39
|
-
switch (
|
|
38
|
+
const { action: a, data: u } = o.data;
|
|
39
|
+
switch (a) {
|
|
40
40
|
case "on.info":
|
|
41
|
-
this.on.info && this.on.info(
|
|
41
|
+
this.on.info && this.on.info(u);
|
|
42
42
|
break;
|
|
43
43
|
case "on.config":
|
|
44
|
-
this.on.config && this.on.config(
|
|
44
|
+
this.on.config && this.on.config(u);
|
|
45
45
|
break;
|
|
46
46
|
case "on.chunk":
|
|
47
|
-
this.on.chunk && this.on.chunk(
|
|
47
|
+
this.on.chunk && this.on.chunk(u);
|
|
48
48
|
break;
|
|
49
49
|
case "on.debug":
|
|
50
|
-
this.on.debug && this.on.debug(
|
|
50
|
+
this.on.debug && this.on.debug(u);
|
|
51
51
|
break;
|
|
52
52
|
}
|
|
53
53
|
};
|
|
54
54
|
}
|
|
55
55
|
}
|
|
56
|
-
const
|
|
57
|
-
`, C = typeof self < "u" && self.Blob && new Blob(["(self.URL || self.webkitURL).revokeObjectURL(self.location.href);",
|
|
58
|
-
function
|
|
56
|
+
const M = `(function(){"use strict";class a{pattern="flv";audioDecoderConfig;audioDecoder;videoDecoderConfig;videoDecoder;hasKeyFrame=!1;baseTime=0;pendingChunks=[];currentChunk;isProcessing=!1;decodeTimer=0;frameTrack=!1;isFrameTrack=!1;fameTrackOption={flv:[30,50],hls:[200,300],dash:[50,100],rtmp:[50,100]};decodingSpeedRatio=1;maxDecodingSpeedRatio=2;decodingSpeed=16;fps=0;firstVideoChunkTimestamp;secondVideoChunkTimestamp;frameStartTime;lastRenderTime;nextRenderTime;on={audio:{},video:{}};constructor(){}init=e=>{this.destroy(),this.pattern=e,this.baseTime=new Date().getTime()-performance.now(),this.initDecodeInterval()};initAudio=e=>{this.audio.destroy(),this.audioDecoderConfig={...e},this.audioDecoder=new AudioDecoder({output:i=>{const o=this.decodingSpeedRatio;this.on.audio.decode&&this.on.audio.decode({audioData:i,playbackRate:o})},error:i=>{this.on.audio.error&&this.on.audio.error(i)}}),this.audioDecoder.configure(this.audioDecoderConfig)};initVideo=e=>{this.video.destroy(),this.videoDecoderConfig={...e},this.videoDecoder=new VideoDecoder({output:async i=>{this.frameStartTime||(this.frameStartTime=i.timestamp);try{const o=i.timestamp-this.frameStartTime+this.baseTime*1e3,s=await createImageBitmap(i);if(i.close(),!s.width||!s.height)return s.close();this.on.video.decode&&this.on.video.decode({timestamp:o,bitmap:s}),this.currentChunk&&this.currentChunk.kind==="video"&&this.currentChunk.nalus&&this.on.nalus&&this.on.nalus(this.currentChunk.nalus)}catch{i.close()}},error:i=>{this.on.video.error&&this.on.video.error(i)}}),this.videoDecoder.configure(this.videoDecoderConfig)};setFrameTrack=e=>{this.frameTrack=e,this.frameTrack===!1&&(this.decodingSpeedRatio=1)};push=e=>{this.pendingChunks.push(e)};destroy=()=>{this.audio.destroy(),this.video.destroy(),this.pendingChunks=[],this.firstVideoChunkTimestamp=void 0,this.secondVideoChunkTimestamp=void 0,this.frameStartTime=void 0,this.lastRenderTime=void 0,this.nextRenderTime=void 0,clearInterval(this.decodeTimer)};initDecodeInterval=()=>{let e=this.decodingSpeed/this.decodingSpeedRatio;const i=this.baseTime+performance.now();if(this.lastRenderTime||(this.lastRenderTime=i),this.fps=Math.round(1e3/(i-this.lastRenderTime)),this.lastRenderTime=i,this.nextRenderTime){const o=this.lastRenderTime-this.nextRenderTime;e-=o}this.nextRenderTime=this.lastRenderTime+e,this.decodeTimer=setTimeout(()=>{this.decode(),this.initDecodeInterval()},e)};decode=()=>{if(this.isProcessing!==!0){for(this.isProcessing=!0;this.currentChunk=this.pendingChunks.shift(),!!this.currentChunk;){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.analysis){const{decodingSpeed:s,decodingSpeedRatio:n,fps:r}=this;this.on.analysis({decodingSpeed:s,decodingSpeedRatio:n,fps:r,cacheLength:e})}const{kind:i,init:o}=this.currentChunk;switch(i){case"audio":this.decodeAudio(o);break;case"video":this.decodeVideo(o);break}if(i==="video")break}this.isProcessing=!1}};decodeAudio=e=>{if(!this.audioDecoder)return;const i=new EncodedAudioChunk(e);this.audioDecoder.decode(i)};decodeVideo=e=>{if(this.videoDecoder&&(e.type==="key"&&(this.hasKeyFrame=!0),this.firstVideoChunkTimestamp?this.secondVideoChunkTimestamp||(this.secondVideoChunkTimestamp=e.timestamp,this.decodingSpeed=(this.secondVideoChunkTimestamp-this.firstVideoChunkTimestamp)/1e3):this.firstVideoChunkTimestamp=e.timestamp,this.hasKeyFrame)){const i=new EncodedVideoChunk(e);this.videoDecoder.decode(i)}};audio={flush:()=>{this.audioDecoder?.flush()},destroy:()=>{this.audioDecoderConfig=void 0,this.audioDecoder?.close(),this.audioDecoder=void 0}};video={flush:()=>{this.videoDecoder?.flush()},destroy:()=>{this.videoDecoderConfig=void 0,this.videoDecoder?.close(),this.videoDecoder=void 0,this.hasKeyFrame=!1}}}const d=new a;d.on.audio.decode=t=>postMessage({action:"on.audio.decode",data:t},[t.audioData]),d.on.audio.error=t=>postMessage({action:"on.audio.error",data:t}),d.on.video.decode=t=>postMessage({action:"on.video.decode",data:t},[t.bitmap]),d.on.video.error=t=>postMessage({action:"on.video.error",data:t}),d.on.nalus=t=>postMessage({action:"on.nalus",data:t}),d.on.analysis=t=>postMessage({action:"on.analysis",data:t}),onmessage=t=>{const{action:e,data:i}=t.data,o=d[e];o&&o(i)}})();
|
|
57
|
+
`, C = typeof self < "u" && self.Blob && new Blob(["(self.URL || self.webkitURL).revokeObjectURL(self.location.href);", M], { type: "text/javascript;charset=utf-8" });
|
|
58
|
+
function L(h) {
|
|
59
59
|
let o;
|
|
60
60
|
try {
|
|
61
61
|
if (o = C && (self.URL || self.webkitURL).createObjectURL(C), !o) throw "";
|
|
62
|
-
const
|
|
62
|
+
const a = new Worker(o, {
|
|
63
63
|
name: h == null ? void 0 : h.name
|
|
64
64
|
});
|
|
65
|
-
return
|
|
65
|
+
return a.addEventListener("error", () => {
|
|
66
66
|
(self.URL || self.webkitURL).revokeObjectURL(o);
|
|
67
|
-
}),
|
|
67
|
+
}), a;
|
|
68
68
|
} catch {
|
|
69
69
|
return new Worker(
|
|
70
|
-
"data:text/javascript;charset=utf-8," + encodeURIComponent(
|
|
70
|
+
"data:text/javascript;charset=utf-8," + encodeURIComponent(M),
|
|
71
71
|
{
|
|
72
72
|
name: h == null ? void 0 : h.name
|
|
73
73
|
}
|
|
74
74
|
);
|
|
75
75
|
}
|
|
76
76
|
}
|
|
77
|
-
class
|
|
77
|
+
class V {
|
|
78
78
|
constructor() {
|
|
79
|
-
m(this, "worker", new
|
|
79
|
+
m(this, "worker", new L());
|
|
80
80
|
m(this, "on", { audio: {}, video: {} });
|
|
81
81
|
m(this, "init", (o) => this.worker.postMessage({ action: "init", data: o }));
|
|
82
82
|
m(this, "initAudio", (o) => this.worker.postMessage({ action: "initAudio", data: o }));
|
|
@@ -87,95 +87,132 @@ class N {
|
|
|
87
87
|
this.worker.postMessage({ action: "destroy" }), this.worker.terminate();
|
|
88
88
|
});
|
|
89
89
|
this.worker.onmessage = (o) => {
|
|
90
|
-
const { action:
|
|
91
|
-
switch (
|
|
90
|
+
const { action: a, data: u } = o.data;
|
|
91
|
+
switch (a) {
|
|
92
92
|
case "on.audio.decode":
|
|
93
|
-
this.on.audio.decode && this.on.audio.decode(
|
|
93
|
+
this.on.audio.decode && this.on.audio.decode(u);
|
|
94
94
|
break;
|
|
95
95
|
case "on.audio.error":
|
|
96
|
-
this.on.audio.error && this.on.audio.error(
|
|
96
|
+
this.on.audio.error && this.on.audio.error(u);
|
|
97
97
|
break;
|
|
98
98
|
case "on.video.decode":
|
|
99
|
-
this.on.video.decode && this.on.video.decode(
|
|
99
|
+
this.on.video.decode && this.on.video.decode(u);
|
|
100
100
|
break;
|
|
101
101
|
case "on.video.error":
|
|
102
|
-
this.on.video.error && this.on.video.error(
|
|
102
|
+
this.on.video.error && this.on.video.error(u);
|
|
103
103
|
break;
|
|
104
104
|
case "on.nalus":
|
|
105
|
-
this.on.nalus && this.on.nalus(
|
|
105
|
+
this.on.nalus && this.on.nalus(u);
|
|
106
106
|
break;
|
|
107
107
|
case "on.analysis":
|
|
108
|
-
this.on.analysis && this.on.analysis(
|
|
108
|
+
this.on.analysis && this.on.analysis(u);
|
|
109
109
|
break;
|
|
110
110
|
}
|
|
111
111
|
};
|
|
112
112
|
}
|
|
113
113
|
}
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
114
|
+
const S = `(function(){"use strict";class l{renderMap=new Map;constructor(){}push=async t=>{const{timestamp:s}=t,{bitmap:e}=t;if(e.height===0||e.width===0)return e.close();try{const n=[...this.renderMap.keys()];for(const i of n){const a=this.renderMap.get(i);if(!a)continue;const{pause:y=!1,writer:h,offscreen:c,option:u}=a;if(y===!0)continue;const f=r=>{if(h){const o=new VideoFrame(r,{timestamp:s});try{o&&h.write(o)}catch{}o.close()}else c&&(c.width=r.width,c.height=r.height,c?.getContext("2d")?.drawImage(r,0,0))};if(i==="default")f(e);else if(u){const{sx:r=0,sy:o=0,sw:p=e.width,sh:g=e.height}=u,M=await createImageBitmap(e,r,o,p,g);f(M)}}}catch{}e.close()};addCut=t=>{const{key:s,writable:e,offscreen:n,option:i}={key:"default",...t};if(e){const a=e.getWriter();this.renderMap.set(s,{writer:a,option:i,pause:!1})}else this.renderMap.set(s,{offscreen:n,option:i,pause:!1})};delCut=t=>{this.renderMap.delete(t)};setCut=t=>{const{key:s,cutOption:e}={key:"default",...t},n=this.renderMap.get(s);n&&this.renderMap.set(s,{...n,option:e})};setPause=t=>{const{key:s,pause:e}={key:"default",...t},n=this.renderMap.get(s);n&&this.renderMap.set(s,{...n,pause:e})};destroy=()=>{this.renderMap=new Map}}const w=new l;onmessage=d=>{const{action:t,data:s}=d.data,e=w[t];e&&e(s)}})();
|
|
115
|
+
`, v = typeof self < "u" && self.Blob && new Blob(["(self.URL || self.webkitURL).revokeObjectURL(self.location.href);", S], { type: "text/javascript;charset=utf-8" });
|
|
116
|
+
function F(h) {
|
|
117
|
+
let o;
|
|
118
|
+
try {
|
|
119
|
+
if (o = v && (self.URL || self.webkitURL).createObjectURL(v), !o) throw "";
|
|
120
|
+
const a = new Worker(o, {
|
|
121
|
+
name: h == null ? void 0 : h.name
|
|
122
|
+
});
|
|
123
|
+
return a.addEventListener("error", () => {
|
|
124
|
+
(self.URL || self.webkitURL).revokeObjectURL(o);
|
|
125
|
+
}), a;
|
|
126
|
+
} catch {
|
|
127
|
+
return new Worker(
|
|
128
|
+
"data:text/javascript;charset=utf-8," + encodeURIComponent(S),
|
|
129
|
+
{
|
|
130
|
+
name: h == null ? void 0 : h.name
|
|
131
|
+
}
|
|
132
|
+
);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
class B {
|
|
136
|
+
constructor() {
|
|
137
|
+
m(this, "worker", new F());
|
|
138
|
+
m(this, "push", (o) => this.worker.postMessage({ action: "push", data: o }, [o.bitmap]));
|
|
139
|
+
m(this, "addCut", (o) => {
|
|
140
|
+
const a = [];
|
|
141
|
+
o.writable && a.push(o.writable), o.offscreen && a.push(o.offscreen), this.worker.postMessage({ action: "addCut", data: o }, a);
|
|
142
|
+
});
|
|
143
|
+
m(this, "delCut", (o) => this.worker.postMessage({ action: "delCut", data: o }));
|
|
144
|
+
m(this, "setCut", (o) => this.worker.postMessage({ action: "setCut", data: o }));
|
|
145
|
+
m(this, "setPause", (o) => this.worker.postMessage({ action: "setPause", data: o }));
|
|
146
|
+
m(this, "destroy", () => {
|
|
147
|
+
this.worker.postMessage({ action: "destroy", data: {} }), this.worker.terminate();
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
var N = Object.defineProperty, G = (h, o, a) => o in h ? N(h, o, { enumerable: !0, configurable: !0, writable: !0, value: a }) : h[o] = a, y = (h, o, a) => G(h, typeof o != "symbol" ? o + "" : o, a);
|
|
152
|
+
class W {
|
|
153
|
+
constructor(o, a) {
|
|
154
|
+
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", () => {
|
|
118
155
|
{
|
|
119
|
-
const
|
|
120
|
-
for (const n of
|
|
156
|
+
const u = this.inputStream.getTracks();
|
|
157
|
+
for (const n of u)
|
|
121
158
|
n.stop(), this.inputStream.removeTrack(n);
|
|
122
159
|
}
|
|
123
|
-
}), y(this, "getStream", () => this.filterStream(this.outputStream)), y(this, "setMute", (
|
|
124
|
-
|
|
125
|
-
}), y(this, "setInputGain", (
|
|
126
|
-
this.inputGain =
|
|
127
|
-
}), y(this, "setEnhanceGain", async (
|
|
128
|
-
this.enhanceGain =
|
|
129
|
-
}), y(this, "setBgsGain", (
|
|
130
|
-
this.bgsGain =
|
|
131
|
-
}), y(this, "setBgmGain", (
|
|
132
|
-
this.bgmGain =
|
|
133
|
-
}), y(this, "setOutputGain", (
|
|
134
|
-
this.outputGain =
|
|
160
|
+
}), y(this, "getStream", () => this.filterStream(this.outputStream)), y(this, "setMute", (u = !0) => {
|
|
161
|
+
u ? this.analyserNode.disconnect(this.outputGainNode) : this.analyserNode.connect(this.outputGainNode);
|
|
162
|
+
}), y(this, "setInputGain", (u) => {
|
|
163
|
+
this.inputGain = u, this.inputGainNode.gain.setValueAtTime(u, this.audioContext.currentTime);
|
|
164
|
+
}), y(this, "setEnhanceGain", async (u) => {
|
|
165
|
+
this.enhanceGain = u + 1, this.enhanceGainNode.gain.setValueAtTime(this.enhanceGain, this.audioContext.currentTime);
|
|
166
|
+
}), y(this, "setBgsGain", (u) => {
|
|
167
|
+
this.bgsGain = u, this.bgsGainNode.gain.setValueAtTime(u, this.audioContext.currentTime);
|
|
168
|
+
}), y(this, "setBgmGain", (u) => {
|
|
169
|
+
this.bgmGain = u, this.bgmGainNode.gain.setValueAtTime(u, this.audioContext.currentTime);
|
|
170
|
+
}), y(this, "setOutputGain", (u) => {
|
|
171
|
+
this.outputGain = u, this.outputGainNode.gain.setValueAtTime(this.outputGain, this.audioContext.currentTime);
|
|
135
172
|
}), y(this, "getVolume", () => {
|
|
136
|
-
const { analyserNode:
|
|
137
|
-
|
|
173
|
+
const { analyserNode: u, analyserArrayData: n } = this;
|
|
174
|
+
u.getByteFrequencyData(n);
|
|
138
175
|
let r = 0;
|
|
139
176
|
for (let i = 0; i < n.length; i++)
|
|
140
177
|
r += n[i];
|
|
141
178
|
return Math.ceil(r / n.length);
|
|
142
|
-
}), y(this, "mixAudio", (
|
|
179
|
+
}), y(this, "mixAudio", (u, n = "bgm") => new Promise(async (r, i) => {
|
|
143
180
|
try {
|
|
144
181
|
{
|
|
145
182
|
const s = this.mixAudioMap.get(n);
|
|
146
183
|
s && s.stop();
|
|
147
184
|
}
|
|
148
185
|
const t = n === "bgs" ? this.bgsGainNode : this.bgmGainNode, e = this.audioContext.createBufferSource();
|
|
149
|
-
this.mixAudioMap.set(n, e), e.buffer =
|
|
186
|
+
this.mixAudioMap.set(n, e), e.buffer = u, e.connect(t), e.onended = () => {
|
|
150
187
|
e.disconnect(t), this.mixAudioMap.delete(n), r(!0);
|
|
151
188
|
}, e.start(0);
|
|
152
189
|
} catch (t) {
|
|
153
190
|
i(t);
|
|
154
191
|
}
|
|
155
|
-
})), y(this, "mixAudioStop", (
|
|
156
|
-
const n = this.mixAudioMap.get(
|
|
192
|
+
})), y(this, "mixAudioStop", (u) => {
|
|
193
|
+
const n = this.mixAudioMap.get(u);
|
|
157
194
|
n == null || n.stop();
|
|
158
|
-
}), y(this, "changeMix", (
|
|
159
|
-
const r =
|
|
195
|
+
}), y(this, "changeMix", (u, n) => {
|
|
196
|
+
const r = u === "bgs" ? this.bgsGainNode : this.bgmGainNode;
|
|
160
197
|
n ? r.connect(this.destinationNode) : r.disconnect(this.destinationNode);
|
|
161
|
-
}),
|
|
198
|
+
}), a && (this.audioContext = a), this.inputStream = o, 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;
|
|
162
199
|
{
|
|
163
|
-
const { sourceNode:
|
|
164
|
-
|
|
200
|
+
const { sourceNode: u, inputGainNode: n, enhanceGainNode: r, bgsGainNode: i, bgmGainNode: t, analyserNode: e, outputGainNode: s, destinationNode: l } = this;
|
|
201
|
+
u.connect(n), n.connect(r), r.connect(e), i.connect(e), t.connect(e), r.connect(l), i.connect(l), t.connect(l), e.connect(s), s.connect(this.audioContext.destination);
|
|
165
202
|
}
|
|
166
203
|
this.setMute(!0), this.audioContext.resume();
|
|
167
204
|
}
|
|
168
205
|
}
|
|
169
206
|
const E = async (h, o) => {
|
|
170
207
|
try {
|
|
171
|
-
const { format:
|
|
172
|
-
for (let t = 0; t <
|
|
208
|
+
const { format: a, numberOfChannels: u, numberOfFrames: n, sampleRate: r } = o, i = h.createBuffer(u, n, r);
|
|
209
|
+
for (let t = 0; t < u; t++) {
|
|
173
210
|
const e = o.allocationSize({ planeIndex: t }), s = new Uint8Array(e);
|
|
174
211
|
o.copyTo(s, { planeIndex: t });
|
|
175
212
|
const l = new DataView(s.buffer), c = i.getChannelData(t);
|
|
176
213
|
for (let d = 0; d < n; d++) {
|
|
177
214
|
let p;
|
|
178
|
-
switch (
|
|
215
|
+
switch (a) {
|
|
179
216
|
case "s16":
|
|
180
217
|
// 16-bit signed PCM (范围: -32768 ~ 32767)
|
|
181
218
|
case "s16-planar":
|
|
@@ -192,17 +229,17 @@ const E = async (h, o) => {
|
|
|
192
229
|
p = (l.getUint8(d) - 128) / 128;
|
|
193
230
|
break;
|
|
194
231
|
default:
|
|
195
|
-
throw new Error(`Unsupported audio format: ${
|
|
232
|
+
throw new Error(`Unsupported audio format: ${a}`);
|
|
196
233
|
}
|
|
197
234
|
c[d] = Math.max(-1, Math.min(1, p));
|
|
198
235
|
}
|
|
199
236
|
}
|
|
200
237
|
return i;
|
|
201
|
-
} catch (
|
|
202
|
-
throw console.error("Failed to convert AudioData to AudioBuffer:",
|
|
238
|
+
} catch (a) {
|
|
239
|
+
throw console.error("Failed to convert AudioData to AudioBuffer:", a), a;
|
|
203
240
|
}
|
|
204
241
|
};
|
|
205
|
-
class
|
|
242
|
+
class O {
|
|
206
243
|
constructor() {
|
|
207
244
|
m(this, "prAudioStream");
|
|
208
245
|
m(this, "audioContext");
|
|
@@ -211,7 +248,7 @@ class W {
|
|
|
211
248
|
m(this, "nextStartTime", 0);
|
|
212
249
|
m(this, "pendingSources", []);
|
|
213
250
|
m(this, "init", (o) => {
|
|
214
|
-
o || (o = new (window.AudioContext || window.webkitAudioContext)()), this.audioContext = o, this.destination = this.audioContext.createMediaStreamDestination(), this.stream = new MediaStream(), this.stream.addTrack(this.destination.stream.getAudioTracks()[0]), this.prAudioStream = new
|
|
251
|
+
o || (o = new (window.AudioContext || window.webkitAudioContext)()), this.audioContext = o, this.destination = this.audioContext.createMediaStreamDestination(), this.stream = new MediaStream(), this.stream.addTrack(this.destination.stream.getAudioTracks()[0]), this.prAudioStream = new W(this.stream, this.audioContext), this.nextStartTime = 0, this.pendingSources = [];
|
|
215
252
|
});
|
|
216
253
|
m(this, "getStream", () => {
|
|
217
254
|
var o;
|
|
@@ -219,69 +256,31 @@ class W {
|
|
|
219
256
|
});
|
|
220
257
|
}
|
|
221
258
|
async push(o) {
|
|
222
|
-
const { audioData:
|
|
259
|
+
const { audioData: a, playbackRate: u = 1 } = o;
|
|
223
260
|
if (!this.audioContext || !this.destination) return;
|
|
224
|
-
let n = await E(this.audioContext,
|
|
225
|
-
if (
|
|
261
|
+
let n = await E(this.audioContext, a);
|
|
262
|
+
if (a.close(), !n) return;
|
|
226
263
|
const r = this.audioContext.createBufferSource();
|
|
227
|
-
r.buffer = n, r.playbackRate.value =
|
|
228
|
-
const i = -1200 * Math.log2(
|
|
264
|
+
r.buffer = n, r.playbackRate.value = u;
|
|
265
|
+
const i = -1200 * Math.log2(u);
|
|
229
266
|
r.detune.value = i, r.connect(this.destination);
|
|
230
|
-
const t = Math.max(this.nextStartTime, this.audioContext.currentTime), e = n.duration /
|
|
267
|
+
const t = Math.max(this.nextStartTime, this.audioContext.currentTime), e = n.duration / u;
|
|
231
268
|
this.nextStartTime = t + e, r.start(t), this.pendingSources.push(r), r.onended = () => {
|
|
232
269
|
this.pendingSources = this.pendingSources.filter((s) => s !== r);
|
|
233
270
|
}, this.audioContext.state === "suspended" && await this.audioContext.resume();
|
|
234
271
|
}
|
|
235
272
|
destroy() {
|
|
236
|
-
var o,
|
|
237
|
-
(o = this.audioContext) == null || o.close(), this.audioContext = void 0, this.destination = void 0, this.nextStartTime = 0, (
|
|
238
|
-
}
|
|
239
|
-
}
|
|
240
|
-
const R = `(function(){"use strict";class o{writable;writer;cutOption;pause=!1;constructor(){}init=({writable:t})=>{this.destroy(),this.writable=t,this.writer=this.writable.getWriter()};push=async t=>{if(this.pause)return;const{timestamp:s}=t;let{bitmap:i}=t;if(this.cutOption){const{sx:n=0,sy:c=0,sw:h=i.width,sh:u=i.height}=this.cutOption;i=await createImageBitmap(i,n,c,h,u)}const r=new VideoFrame(i,{timestamp:s});this.cutOption&&i.close(),this.writer.write(r),r.close()};setCut=t=>{this.cutOption=t};setPause=t=>{this.pause=t};destroy=()=>{this.writable=void 0,this.writer=void 0,this.cutOption=void 0}}const a=new o;onmessage=e=>{const{action:t,data:s}=e.data,i=a[t];i&&i(s)}})();
|
|
241
|
-
`, v = typeof self < "u" && self.Blob && new Blob(["(self.URL || self.webkitURL).revokeObjectURL(self.location.href);", R], { type: "text/javascript;charset=utf-8" });
|
|
242
|
-
function j(h) {
|
|
243
|
-
let o;
|
|
244
|
-
try {
|
|
245
|
-
if (o = v && (self.URL || self.webkitURL).createObjectURL(v), !o) throw "";
|
|
246
|
-
const u = new Worker(o, {
|
|
247
|
-
name: h == null ? void 0 : h.name
|
|
248
|
-
});
|
|
249
|
-
return u.addEventListener("error", () => {
|
|
250
|
-
(self.URL || self.webkitURL).revokeObjectURL(o);
|
|
251
|
-
}), u;
|
|
252
|
-
} catch {
|
|
253
|
-
return new Worker(
|
|
254
|
-
"data:text/javascript;charset=utf-8," + encodeURIComponent(R),
|
|
255
|
-
{
|
|
256
|
-
name: h == null ? void 0 : h.name
|
|
257
|
-
}
|
|
258
|
-
);
|
|
259
|
-
}
|
|
260
|
-
}
|
|
261
|
-
class z {
|
|
262
|
-
constructor() {
|
|
263
|
-
m(this, "worker", new j());
|
|
264
|
-
m(this, "init", ({ writable: o }) => this.worker.postMessage({ action: "init", data: { writable: o } }, [o]));
|
|
265
|
-
m(this, "push", (o) => this.worker.postMessage({ action: "push", data: o }));
|
|
266
|
-
m(this, "setCut", async (o) => this.worker.postMessage({ action: "setCut", data: o }));
|
|
267
|
-
m(this, "setPause", (o) => this.worker.postMessage({ action: "setPause", data: o }));
|
|
268
|
-
m(this, "destroy", () => {
|
|
269
|
-
this.worker.postMessage({ action: "destroy", data: {} }), this.worker.terminate();
|
|
270
|
-
});
|
|
273
|
+
var o, a;
|
|
274
|
+
(o = this.audioContext) == null || o.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 = [];
|
|
271
275
|
}
|
|
272
276
|
}
|
|
273
|
-
const
|
|
277
|
+
const j = (h) => {
|
|
274
278
|
const o = h.toLowerCase();
|
|
275
279
|
return o.includes(".m3u8") || o.includes("hls") || o.includes("master.m3u8") || o.match(/index\d*\.m3u8/) ? "hls" : o.includes(".mpd") || o.includes("dash") ? "dash" : o.startsWith("rtmp://") || o.startsWith("rtmps://") ? "rtmp" : o.includes(".flv") || o.includes("flv") && !o.includes("flash") ? "flv" : "unknown";
|
|
276
|
-
},
|
|
280
|
+
}, z = (h) => {
|
|
277
281
|
const o = (h == null ? void 0 : h.getTracks()) || [];
|
|
278
|
-
for (const
|
|
279
|
-
|
|
280
|
-
}, A = () => {
|
|
281
|
-
const h = new MediaStreamTrackGenerator({ kind: "video" }), o = new MediaStream([h]), u = new z();
|
|
282
|
-
return u.init({ writable: h.writable }), { worker: u, stream: o, destroy: () => {
|
|
283
|
-
u.destroy(), M(o);
|
|
284
|
-
} };
|
|
282
|
+
for (const a of o)
|
|
283
|
+
a.stop();
|
|
285
284
|
};
|
|
286
285
|
class $ {
|
|
287
286
|
constructor() {
|
|
@@ -294,67 +293,68 @@ class $ {
|
|
|
294
293
|
* @param timeout 超时时间 ms
|
|
295
294
|
* @returns
|
|
296
295
|
*/
|
|
297
|
-
m(this, "add", (o,
|
|
296
|
+
m(this, "add", (o, a = () => !1, u = 0) => new Promise((n) => {
|
|
298
297
|
var t, e;
|
|
299
|
-
if (
|
|
298
|
+
if (a()) return n(!0);
|
|
300
299
|
this.resolvesMap.has(o) || this.resolvesMap.set(o, /* @__PURE__ */ new Map()), this.index++;
|
|
301
300
|
const r = `${this.index}`;
|
|
302
|
-
if (
|
|
301
|
+
if (u = Math.max(0, u), u === 0) {
|
|
303
302
|
(t = this.resolvesMap.get(o)) == null || t.set(r, { resolve: n, timer: 0 });
|
|
304
303
|
return;
|
|
305
304
|
}
|
|
306
305
|
const i = window.setTimeout(() => {
|
|
307
306
|
this.emit(o);
|
|
308
|
-
},
|
|
307
|
+
}, u);
|
|
309
308
|
(e = this.resolvesMap.get(o)) == null || e.set(r, { resolve: n, timer: i });
|
|
310
309
|
}));
|
|
311
310
|
m(this, "emit", async (o) => {
|
|
312
|
-
const
|
|
313
|
-
if (!
|
|
314
|
-
const
|
|
315
|
-
for (const n of
|
|
316
|
-
const r =
|
|
317
|
-
r && (clearTimeout(r.timer), r.resolve(),
|
|
311
|
+
const a = this.resolvesMap.get(o);
|
|
312
|
+
if (!a) return;
|
|
313
|
+
const u = [...a.keys()];
|
|
314
|
+
for (const n of u) {
|
|
315
|
+
const r = a.get(n);
|
|
316
|
+
r && (clearTimeout(r.timer), r.resolve(), a.delete(n));
|
|
318
317
|
}
|
|
319
318
|
});
|
|
320
319
|
}
|
|
321
320
|
}
|
|
322
|
-
const
|
|
321
|
+
const X = (h) => {
|
|
323
322
|
const o = new DataView(h.buffer);
|
|
324
|
-
let
|
|
325
|
-
|
|
323
|
+
let a = 0, u, n, r;
|
|
324
|
+
u = o.getUint32(a, !1), a += 4;
|
|
326
325
|
{
|
|
327
|
-
const i = o.getUint8(
|
|
328
|
-
n = { forbidden_zero_bit: t, nal_ref_idc: e, nal_unit_type: s },
|
|
326
|
+
const i = o.getUint8(a), t = i >> 7 & 1, e = i >> 5 & 3, s = i & 31;
|
|
327
|
+
n = { forbidden_zero_bit: t, nal_ref_idc: e, nal_unit_type: s }, a += 1;
|
|
329
328
|
}
|
|
330
329
|
{
|
|
331
|
-
const i =
|
|
332
|
-
r = new Uint8Array(o.buffer.slice(
|
|
330
|
+
const i = u - 1;
|
|
331
|
+
r = new Uint8Array(o.buffer.slice(a, a + i));
|
|
333
332
|
}
|
|
334
|
-
return { size:
|
|
333
|
+
return { size: u, header: n, data: r };
|
|
335
334
|
};
|
|
336
|
-
var
|
|
335
|
+
var q, U;
|
|
337
336
|
class x {
|
|
338
337
|
constructor(o = {}) {
|
|
339
|
-
|
|
340
|
-
timeout: 5 * 1e3
|
|
338
|
+
H(this, q, {
|
|
339
|
+
timeout: 5 * 1e3,
|
|
340
|
+
check: !1
|
|
341
341
|
});
|
|
342
|
-
|
|
342
|
+
H(this, U);
|
|
343
343
|
/**
|
|
344
344
|
*
|
|
345
345
|
* @param input string | URL | Request
|
|
346
346
|
* @param init RequestInit
|
|
347
347
|
*/
|
|
348
|
-
m(this, "check", (o,
|
|
348
|
+
m(this, "check", (o, a) => new Promise(async (u, n) => {
|
|
349
349
|
var i;
|
|
350
|
-
this.stop(),
|
|
350
|
+
this.stop(), K(this, U, new AbortController());
|
|
351
351
|
const r = window.setTimeout(() => {
|
|
352
352
|
var t;
|
|
353
|
-
(t =
|
|
354
|
-
},
|
|
353
|
+
(t = R(this, U)) == null || t.abort("Timeout."), n({ status: "timeout", reason: "" });
|
|
354
|
+
}, R(this, q).timeout);
|
|
355
355
|
try {
|
|
356
|
-
const t = await fetch(o, { ...
|
|
357
|
-
t.status === 200 ?
|
|
356
|
+
const t = await fetch(o, { ...a, method: "HEAD", signal: (i = R(this, U)) == null ? void 0 : i.signal });
|
|
357
|
+
t.status === 200 ? u({ status: "successed", reason: "" }) : n({ status: "failed", reason: `${t.status}` });
|
|
358
358
|
} catch (t) {
|
|
359
359
|
n({ status: "error", reason: t.message });
|
|
360
360
|
}
|
|
@@ -365,12 +365,12 @@ class x {
|
|
|
365
365
|
* @param input string | URL | Request
|
|
366
366
|
* @param init RequestInit
|
|
367
367
|
*/
|
|
368
|
-
m(this, "request", async (o,
|
|
368
|
+
m(this, "request", async (o, a) => new Promise(async (u, n) => {
|
|
369
369
|
var r;
|
|
370
370
|
try {
|
|
371
|
-
await this.check(o,
|
|
372
|
-
const i = await fetch(o, { ...
|
|
373
|
-
|
|
371
|
+
R(this, q).check && await this.check(o, a), K(this, U, new AbortController());
|
|
372
|
+
const i = await fetch(o, { ...a, signal: (r = R(this, U)) == null ? void 0 : r.signal });
|
|
373
|
+
u(i);
|
|
374
374
|
} catch (i) {
|
|
375
375
|
this.stop(), n(i);
|
|
376
376
|
}
|
|
@@ -380,22 +380,25 @@ class x {
|
|
|
380
380
|
*/
|
|
381
381
|
m(this, "stop", () => {
|
|
382
382
|
var o;
|
|
383
|
-
((o =
|
|
383
|
+
((o = R(this, U)) == null ? void 0 : o.signal.aborted) === !1 && R(this, U).abort("Actively stop.");
|
|
384
384
|
});
|
|
385
|
-
|
|
385
|
+
K(this, q, { ...R(this, q), ...o });
|
|
386
386
|
}
|
|
387
387
|
}
|
|
388
|
-
|
|
389
|
-
class
|
|
388
|
+
q = new WeakMap(), U = new WeakMap();
|
|
389
|
+
class tt {
|
|
390
390
|
constructor(o = {}) {
|
|
391
391
|
m(this, "option", {
|
|
392
392
|
debug: !1,
|
|
393
393
|
frameTrack: !1
|
|
394
394
|
});
|
|
395
|
+
m(this, "converter", "MediaStreamTrackGenerator" in window ? "generator" : "canvas");
|
|
396
|
+
// 自动检测浏览器 使用哪一种模式转换生产视频流
|
|
395
397
|
m(this, "prFetch", new x());
|
|
396
398
|
m(this, "getSegmentsFetch", new x());
|
|
397
399
|
m(this, "prResolves", new $());
|
|
398
400
|
m(this, "url", "");
|
|
401
|
+
m(this, "start_resolve");
|
|
399
402
|
m(this, "demuxerWorker");
|
|
400
403
|
m(this, "decoderWorker");
|
|
401
404
|
m(this, "audioPlayer");
|
|
@@ -411,9 +414,9 @@ class et {
|
|
|
411
414
|
*/
|
|
412
415
|
m(this, "start", async (o) => {
|
|
413
416
|
await this.stop(), this.url = o;
|
|
414
|
-
const
|
|
415
|
-
if (
|
|
416
|
-
switch (this.init(
|
|
417
|
+
const a = j(o);
|
|
418
|
+
if (a === "unknown") throw new Error("This address cannot be parsed.");
|
|
419
|
+
switch (this.init(a), a) {
|
|
417
420
|
case "flv":
|
|
418
421
|
this.flv.start();
|
|
419
422
|
break;
|
|
@@ -426,17 +429,12 @@ class et {
|
|
|
426
429
|
* 停止
|
|
427
430
|
*/
|
|
428
431
|
m(this, "stop", async () => {
|
|
429
|
-
var
|
|
432
|
+
var o, a, u, n;
|
|
430
433
|
try {
|
|
431
|
-
this.url = "", clearInterval(this.hls.getSegmentsTimer), this.prFetch.stop(), this.getSegmentsFetch.stop();
|
|
432
|
-
} catch (
|
|
433
|
-
console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", "------->pr-player: error",
|
|
434
|
+
this.url = "", clearInterval(this.hls.getSegmentsTimer), this.prFetch.stop(), this.getSegmentsFetch.stop(), (o = this.demuxerWorker) == null || o.destroy(), (a = this.decoderWorker) == null || a.destroy(), (u = this.renderWorker) == null || u.destroy(), this.cutRenders = /* @__PURE__ */ new Map(), z(this.stream), (n = this.audioPlayer) == null || n.destroy();
|
|
435
|
+
} catch (r) {
|
|
436
|
+
console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", "------->pr-player: error", r);
|
|
434
437
|
}
|
|
435
|
-
(u = this.demuxerWorker) == null || u.destroy(), (a = this.decoderWorker) == null || a.destroy(), (n = this.renderWorker) == null || n.destroy();
|
|
436
|
-
const o = [...this.cutRenders.keys()];
|
|
437
|
-
for (const t of o)
|
|
438
|
-
(r = this.cutRenders.get(t)) == null || r.worker.destroy(), this.cutRenders.delete(t);
|
|
439
|
-
M(this.stream), (i = this.audioPlayer) == null || i.destroy();
|
|
440
438
|
});
|
|
441
439
|
/**
|
|
442
440
|
* 获取媒体流
|
|
@@ -447,32 +445,40 @@ class et {
|
|
|
447
445
|
* @param pause: boolean
|
|
448
446
|
*/
|
|
449
447
|
m(this, "setPause", (o) => {
|
|
450
|
-
var
|
|
451
|
-
(
|
|
448
|
+
var a;
|
|
449
|
+
(a = this.renderWorker) == null || a.setPause({ pause: o });
|
|
452
450
|
});
|
|
453
451
|
/**
|
|
454
452
|
* 是否静音 默认为true
|
|
455
453
|
* @param state?: boolean
|
|
456
454
|
*/
|
|
457
455
|
m(this, "setMute", (o) => {
|
|
458
|
-
var
|
|
459
|
-
return (
|
|
456
|
+
var a, u;
|
|
457
|
+
return (u = (a = this.audioPlayer) == null ? void 0 : a.prAudioStream) == null ? void 0 : u.setMute(o);
|
|
458
|
+
});
|
|
459
|
+
/**
|
|
460
|
+
* 设置输出音量
|
|
461
|
+
* @param gain
|
|
462
|
+
*/
|
|
463
|
+
m(this, "setOutputGain", (o) => {
|
|
464
|
+
var a, u;
|
|
465
|
+
(u = (a = this.audioPlayer) == null ? void 0 : a.prAudioStream) == null || u.setOutputGain(o);
|
|
460
466
|
});
|
|
461
467
|
/**
|
|
462
468
|
* 是否开启追帧
|
|
463
469
|
* @param frameTrack?: boolean
|
|
464
470
|
*/
|
|
465
471
|
m(this, "setFrameTrack", (o) => {
|
|
466
|
-
var
|
|
467
|
-
this.option.frameTrack = o, (
|
|
472
|
+
var a;
|
|
473
|
+
this.option.frameTrack = o, (a = this.decoderWorker) == null || a.setFrameTrack(o);
|
|
468
474
|
});
|
|
469
475
|
/**
|
|
470
476
|
* 是否已准备好
|
|
471
477
|
*/
|
|
472
478
|
m(this, "isReady", () => {
|
|
473
479
|
const o = () => {
|
|
474
|
-
var
|
|
475
|
-
return ((
|
|
480
|
+
var a;
|
|
481
|
+
return ((a = this.stream) == null ? void 0 : a.active) === !0;
|
|
476
482
|
};
|
|
477
483
|
return this.prResolves.add("isReady", o);
|
|
478
484
|
});
|
|
@@ -480,79 +486,91 @@ class et {
|
|
|
480
486
|
/**
|
|
481
487
|
* 创建剪切
|
|
482
488
|
*/
|
|
483
|
-
create: (o,
|
|
484
|
-
|
|
485
|
-
|
|
489
|
+
create: (o, a) => {
|
|
490
|
+
var i, t;
|
|
491
|
+
if (this.converter === "generator") {
|
|
492
|
+
const e = new MediaStreamTrackGenerator({ kind: "video" }), s = new MediaStream([e]);
|
|
493
|
+
return (i = this.renderWorker) == null || i.addCut({ key: o, writable: e.writable, option: a }), this.cutRenders.set(o, { stream: s }), s;
|
|
494
|
+
}
|
|
495
|
+
const u = document.createElement("canvas"), n = u.captureStream(), r = u.transferControlToOffscreen();
|
|
496
|
+
return (t = this.renderWorker) == null || t.addCut({ key: o, offscreen: r, option: a }), this.cutRenders.set(o, { stream: n }), n;
|
|
486
497
|
},
|
|
487
498
|
/**
|
|
488
|
-
*
|
|
499
|
+
* 设置剪切
|
|
489
500
|
*/
|
|
490
|
-
|
|
501
|
+
setCut: (o, a) => {
|
|
491
502
|
var u;
|
|
492
|
-
|
|
503
|
+
(u = this.renderWorker) == null || u.setCut({ key: o, cutOption: a });
|
|
493
504
|
},
|
|
494
505
|
/**
|
|
495
|
-
*
|
|
496
|
-
* @param pause: boolean
|
|
506
|
+
* 获取媒体流
|
|
497
507
|
*/
|
|
498
|
-
|
|
508
|
+
getStream: (o) => {
|
|
499
509
|
var a;
|
|
500
|
-
(a = this.cutRenders.get(o)) == null
|
|
510
|
+
return (a = this.cutRenders.get(o)) == null ? void 0 : a.stream;
|
|
501
511
|
},
|
|
502
512
|
/**
|
|
503
513
|
* 移除剪切
|
|
504
514
|
*/
|
|
505
515
|
remove: (o) => {
|
|
516
|
+
var a;
|
|
517
|
+
(a = this.renderWorker) == null || a.delCut(o), this.cutRenders.delete(o);
|
|
518
|
+
},
|
|
519
|
+
/**
|
|
520
|
+
* 设置暂停
|
|
521
|
+
* @param pause: boolean
|
|
522
|
+
*/
|
|
523
|
+
setPause: (o, a) => {
|
|
506
524
|
var u;
|
|
507
|
-
(u = this.
|
|
525
|
+
(u = this.renderWorker) == null || u.setPause({ key: o, pause: a });
|
|
508
526
|
}
|
|
509
527
|
});
|
|
510
528
|
/**
|
|
511
529
|
* 初始化
|
|
512
530
|
*/
|
|
513
531
|
m(this, "init", (o) => {
|
|
514
|
-
this.initDecoder(o), this.initRender(), this.initDemuxer(o), this.audioPlayer = new
|
|
532
|
+
this.initDecoder(o), this.initRender(), this.initDemuxer(o), this.audioPlayer = new O(), this.audioPlayer.init();
|
|
515
533
|
});
|
|
516
534
|
/**
|
|
517
535
|
* 初始化解复器
|
|
518
536
|
*/
|
|
519
537
|
m(this, "initDemuxer", (o) => {
|
|
520
|
-
this.demuxerWorker = new
|
|
521
|
-
this.option.debug && this.on.debug && this.on.debug(
|
|
522
|
-
}, this.demuxerWorker.on.info = (
|
|
523
|
-
this.option.debug && console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", "------->pr-player: info",
|
|
524
|
-
}, this.demuxerWorker.on.config = (
|
|
538
|
+
this.demuxerWorker = new I(), this.demuxerWorker.init(o), this.demuxerWorker.on.debug = (a) => {
|
|
539
|
+
this.option.debug && this.on.debug && this.on.debug(a);
|
|
540
|
+
}, this.demuxerWorker.on.info = (a) => {
|
|
541
|
+
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);
|
|
542
|
+
}, this.demuxerWorker.on.config = (a) => {
|
|
525
543
|
var n, r;
|
|
526
|
-
this.option.debug && console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", "------->pr-player: config",
|
|
527
|
-
const { kind:
|
|
528
|
-
switch (
|
|
544
|
+
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);
|
|
545
|
+
const { kind: u } = a;
|
|
546
|
+
switch (u) {
|
|
529
547
|
case "audio":
|
|
530
548
|
{
|
|
531
|
-
const { codec: i, sampleRate: t, numberOfChannels: e } =
|
|
549
|
+
const { codec: i, sampleRate: t, numberOfChannels: e } = a;
|
|
532
550
|
(n = this.decoderWorker) == null || n.initAudio({ codec: i, sampleRate: t, numberOfChannels: e });
|
|
533
551
|
}
|
|
534
552
|
break;
|
|
535
553
|
case "video":
|
|
536
554
|
{
|
|
537
|
-
const { codec: i, description: t } =
|
|
555
|
+
const { codec: i, description: t } = a;
|
|
538
556
|
(r = this.decoderWorker) == null || r.initVideo({ codec: i, description: t });
|
|
539
557
|
}
|
|
540
558
|
break;
|
|
541
559
|
}
|
|
542
|
-
}, this.demuxerWorker.on.chunk = (
|
|
543
|
-
if (this.on.demuxer.chunk && this.on.demuxer.chunk(
|
|
544
|
-
const { kind:
|
|
545
|
-
switch (
|
|
560
|
+
}, this.demuxerWorker.on.chunk = (a) => {
|
|
561
|
+
if (this.on.demuxer.chunk && this.on.demuxer.chunk(a), !this.decoderWorker) return;
|
|
562
|
+
const { kind: u } = a;
|
|
563
|
+
switch (u) {
|
|
546
564
|
case "audio":
|
|
547
565
|
{
|
|
548
|
-
const { type: n, dts: r, data: i } =
|
|
549
|
-
this.decoderWorker.push({ kind:
|
|
566
|
+
const { type: n, dts: r, data: i } = a, t = r * 1e3;
|
|
567
|
+
this.decoderWorker.push({ kind: u, init: { type: n, timestamp: t, data: i } });
|
|
550
568
|
}
|
|
551
569
|
break;
|
|
552
570
|
case "video":
|
|
553
571
|
{
|
|
554
|
-
const { type: n, dts: r, data: i, nalus: t = [] } =
|
|
555
|
-
this.decoderWorker.push({ kind:
|
|
572
|
+
const { type: n, dts: r, data: i, nalus: t = [] } = a, e = r * 1e3;
|
|
573
|
+
this.decoderWorker.push({ kind: u, init: { type: n, timestamp: e, data: i }, nalus: t });
|
|
556
574
|
}
|
|
557
575
|
break;
|
|
558
576
|
}
|
|
@@ -562,56 +580,69 @@ class et {
|
|
|
562
580
|
* 初始化解码器
|
|
563
581
|
*/
|
|
564
582
|
m(this, "initDecoder", (o) => {
|
|
565
|
-
this.decoderWorker = new
|
|
566
|
-
const { frameTrack:
|
|
567
|
-
this.decoderWorker.setFrameTrack(
|
|
583
|
+
this.decoderWorker = new V(), this.decoderWorker.init(o);
|
|
584
|
+
const { frameTrack: a = !1 } = this.option;
|
|
585
|
+
this.decoderWorker.setFrameTrack(a), this.decoderWorker.on.audio.decode = (u) => {
|
|
586
|
+
var n;
|
|
587
|
+
(n = this.audioPlayer) == null || n.push(u), this.on.decoder.audio && this.on.decoder.audio(u);
|
|
588
|
+
}, this.decoderWorker.on.audio.error = (u) => {
|
|
589
|
+
this.option.debug && console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", "------->pr-player: audio.error ", u), this.on.error && this.on.error(u);
|
|
590
|
+
}, this.decoderWorker.on.video.decode = async (u) => {
|
|
568
591
|
var n;
|
|
569
|
-
(n = this.
|
|
570
|
-
}, this.decoderWorker.on.
|
|
571
|
-
this.
|
|
572
|
-
}, this.decoderWorker.on.
|
|
573
|
-
|
|
574
|
-
(r = this.renderWorker) == null || r.push(a);
|
|
575
|
-
const n = [...this.cutRenders.keys()];
|
|
576
|
-
for (const t of n)
|
|
577
|
-
(i = this.cutRenders.get(t)) == null || i.worker.push(a);
|
|
578
|
-
this.on.decoder.video && this.on.decoder.video(a), a.bitmap.close();
|
|
579
|
-
}, this.decoderWorker.on.video.error = (a) => {
|
|
580
|
-
this.on.error && this.on.error(a);
|
|
581
|
-
}, this.decoderWorker.on.nalus = async (a) => {
|
|
582
|
-
for (const n of a) {
|
|
592
|
+
this.start_resolve && (this.start_resolve(!0), this.start_resolve = void 0), (n = this.renderWorker) == null || n.push(u), this.on.decoder.video && this.on.decoder.video(u);
|
|
593
|
+
}, this.decoderWorker.on.video.error = (u) => {
|
|
594
|
+
this.on.error && this.on.error(u);
|
|
595
|
+
}, this.decoderWorker.on.nalus = async (u) => {
|
|
596
|
+
for (const n of u) {
|
|
583
597
|
if (n.byteLength <= 4) continue;
|
|
584
|
-
const { header: r, data: i } =
|
|
598
|
+
const { header: r, data: i } = X(n), { nal_unit_type: t } = r;
|
|
585
599
|
t === 6 && this.on.decoder.sei && this.on.decoder.sei(i);
|
|
586
600
|
}
|
|
587
|
-
}, this.decoderWorker.on.analysis = (
|
|
588
|
-
this.on.decoder.analysis && this.on.decoder.analysis(
|
|
601
|
+
}, this.decoderWorker.on.analysis = (u) => {
|
|
602
|
+
this.on.decoder.analysis && this.on.decoder.analysis(u);
|
|
589
603
|
};
|
|
590
604
|
});
|
|
591
605
|
/**
|
|
592
606
|
* 初始化渲染器
|
|
593
607
|
*/
|
|
594
608
|
m(this, "initRender", () => {
|
|
595
|
-
|
|
596
|
-
this.renderWorker =
|
|
609
|
+
var o, a, u;
|
|
610
|
+
if (this.renderWorker = new B(), this.converter === "generator") {
|
|
611
|
+
const n = new MediaStreamTrackGenerator({ kind: "video" }), r = new MediaStream([n]);
|
|
612
|
+
(o = this.renderWorker) == null || o.addCut({ writable: n.writable }), this.stream = r;
|
|
613
|
+
} else {
|
|
614
|
+
const n = document.createElement("canvas"), r = n.captureStream(), i = n.transferControlToOffscreen();
|
|
615
|
+
(a = this.renderWorker) == null || a.addCut({ offscreen: i }), this.stream = r;
|
|
616
|
+
}
|
|
617
|
+
(u = this.renderWorker) == null || u.setPause({ pause: !1 });
|
|
597
618
|
});
|
|
598
619
|
m(this, "flv", {
|
|
599
|
-
start: async () => {
|
|
600
|
-
var
|
|
620
|
+
start: () => new Promise(async (o, a) => {
|
|
621
|
+
var u, n;
|
|
601
622
|
try {
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
const n = (o = a.body) == null ? void 0 : o.getReader();
|
|
605
|
-
if (!n) throw new Error("reader is error.");
|
|
623
|
+
this.start_resolve = o;
|
|
624
|
+
let r, i = 0;
|
|
606
625
|
for (; ; ) {
|
|
607
|
-
|
|
608
|
-
|
|
626
|
+
i += 1;
|
|
627
|
+
try {
|
|
628
|
+
r = await this.prFetch.request(this.url);
|
|
629
|
+
} catch (e) {
|
|
630
|
+
console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", "------->Breathe: error", e);
|
|
631
|
+
}
|
|
632
|
+
if ((r == null ? void 0 : r.status) === 200 || i === 3) break;
|
|
633
|
+
await new Promise((e) => setTimeout(() => e(!0), 500));
|
|
609
634
|
}
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
635
|
+
if (!r || r.status !== 200) return a("request is error.");
|
|
636
|
+
const t = (u = r.body) == null ? void 0 : u.getReader();
|
|
637
|
+
if (!t) return a("reader is error.");
|
|
638
|
+
for (; ; ) {
|
|
639
|
+
const { done: e, value: s } = await t.read();
|
|
640
|
+
if (s && ((n = this.demuxerWorker) == null || n.push(s)), e || this.url === "") break;
|
|
641
|
+
}
|
|
642
|
+
} catch (r) {
|
|
643
|
+
r.name !== "AbortError" && a(r);
|
|
613
644
|
}
|
|
614
|
-
}
|
|
645
|
+
})
|
|
615
646
|
});
|
|
616
647
|
m(this, "hls", {
|
|
617
648
|
isLive: !1,
|
|
@@ -619,74 +650,84 @@ class et {
|
|
|
619
650
|
url: "",
|
|
620
651
|
getSegmentsTimer: 0,
|
|
621
652
|
parse: async (o) => {
|
|
622
|
-
const
|
|
623
|
-
`).map((e) => e.replace("\r", "")),
|
|
653
|
+
const a = new TextDecoder("utf-8").decode(o).split(`
|
|
654
|
+
`).map((e) => e.replace("\r", "")), u = this.url.substring(0, this.url.lastIndexOf("/") + 1);
|
|
624
655
|
let n = 4, r = 0, i = !1;
|
|
625
656
|
const t = [];
|
|
626
|
-
for (const e of
|
|
657
|
+
for (const e of a)
|
|
627
658
|
e.startsWith("#EXTINF:") ? n = parseFloat(e.split(":")[1].split(",")[0]) : e.startsWith("#EXT-X-TARGETDURATION:") ? r = 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({
|
|
628
|
-
url: e.startsWith("http") ? e :
|
|
659
|
+
url: e.startsWith("http") ? e : u + e,
|
|
629
660
|
duration: n,
|
|
630
661
|
isLive: i
|
|
631
662
|
});
|
|
632
|
-
return { baseUrl:
|
|
663
|
+
return { baseUrl: u, targetDuration: r, isLive: i, segments: t };
|
|
633
664
|
},
|
|
634
665
|
getSegments: async () => {
|
|
635
666
|
var o;
|
|
636
667
|
try {
|
|
637
|
-
let u =
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
668
|
+
let a, u = 0;
|
|
669
|
+
for (; ; ) {
|
|
670
|
+
u += 1;
|
|
671
|
+
try {
|
|
672
|
+
a = await this.getSegmentsFetch.request(this.url);
|
|
673
|
+
} catch (r) {
|
|
674
|
+
console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", "------->Breathe: error", r);
|
|
675
|
+
}
|
|
676
|
+
if ((a == null ? void 0 : a.status) === 200 || u === 3) break;
|
|
677
|
+
await new Promise((r) => setTimeout(() => r(!0), 500));
|
|
678
|
+
}
|
|
679
|
+
if (!a || a.status !== 200) throw new Error("request is error.");
|
|
680
|
+
const n = (o = a.body) == null ? void 0 : o.getReader();
|
|
681
|
+
if (!n) throw new Error("reader is error.");
|
|
641
682
|
for (; ; ) {
|
|
642
|
-
const { done:
|
|
643
|
-
if (
|
|
644
|
-
const
|
|
645
|
-
this.hls.isLive =
|
|
646
|
-
let
|
|
647
|
-
const
|
|
648
|
-
|
|
683
|
+
const { done: r, value: i } = await n.read();
|
|
684
|
+
if (i) {
|
|
685
|
+
const t = await this.hls.parse(i), { segments: e = [], isLive: s = !1 } = t;
|
|
686
|
+
this.hls.isLive = s, s === !1 && (this.option.frameTrack = !1);
|
|
687
|
+
let l = Array.from(e, (d) => d.url);
|
|
688
|
+
const c = l.findIndex((d) => d === this.hls.url);
|
|
689
|
+
c !== -1 && (l = l.slice(c + 1)), this.hls.urls = l;
|
|
649
690
|
}
|
|
650
|
-
if (
|
|
691
|
+
if (r || this.url === "") break;
|
|
651
692
|
}
|
|
652
|
-
} catch (
|
|
653
|
-
this.on.error && this.on.error(
|
|
693
|
+
} catch (a) {
|
|
694
|
+
a.name !== "AbortError" && this.on.error && this.on.error(a);
|
|
654
695
|
}
|
|
655
696
|
},
|
|
656
|
-
start: async () => {
|
|
657
|
-
var
|
|
697
|
+
start: () => new Promise(async (o, a) => {
|
|
698
|
+
var u, n, r;
|
|
658
699
|
try {
|
|
659
|
-
for (await this.hls.getSegments(), this.hls.getSegmentsTimer = window.setInterval(this.hls.getSegments, 500), this.hls.isLive === !1 && (clearInterval(this.hls.getSegmentsTimer), (
|
|
660
|
-
const
|
|
661
|
-
if (
|
|
662
|
-
this.hls.url =
|
|
663
|
-
const
|
|
664
|
-
if (!
|
|
700
|
+
for (this.start_resolve = o, this.hls.url = "", this.hls.urls = [], await this.hls.getSegments(), this.hls.getSegmentsTimer = window.setInterval(this.hls.getSegments, 500), this.hls.isLive === !1 && (clearInterval(this.hls.getSegmentsTimer), (u = this.decoderWorker) == null ? void 0 : u.setFrameTrack(!1)); ; ) {
|
|
701
|
+
const i = this.hls.urls.shift();
|
|
702
|
+
if (i) {
|
|
703
|
+
this.hls.url = i;
|
|
704
|
+
const t = (n = (await this.prFetch.request(i)).body) == null ? void 0 : n.getReader();
|
|
705
|
+
if (!t) throw new Error("segment reader is error.");
|
|
665
706
|
for (; ; ) {
|
|
666
|
-
const { done:
|
|
667
|
-
if (
|
|
707
|
+
const { done: e, value: s } = await t.read();
|
|
708
|
+
if (s && ((r = this.demuxerWorker) == null || r.push(s)), e || this.url === "") break;
|
|
668
709
|
}
|
|
669
710
|
} else
|
|
670
|
-
await new Promise((
|
|
711
|
+
await new Promise((t) => setTimeout(() => t(!0), 300));
|
|
671
712
|
}
|
|
672
|
-
} catch (
|
|
673
|
-
|
|
713
|
+
} catch (i) {
|
|
714
|
+
i.name !== "AbortError" && a(i);
|
|
674
715
|
}
|
|
675
|
-
}
|
|
716
|
+
})
|
|
676
717
|
});
|
|
677
|
-
const { debug:
|
|
678
|
-
this.option.debug =
|
|
718
|
+
const { debug: a = !1 } = o;
|
|
719
|
+
this.option.debug = a;
|
|
679
720
|
}
|
|
680
721
|
}
|
|
681
722
|
var commonjsGlobal = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {}, indexMinimal = {}, minimal$1 = {}, aspromise, hasRequiredAspromise;
|
|
682
723
|
function requireAspromise() {
|
|
683
724
|
if (hasRequiredAspromise) return aspromise;
|
|
684
725
|
hasRequiredAspromise = 1, aspromise = h;
|
|
685
|
-
function h(o,
|
|
686
|
-
for (var
|
|
687
|
-
|
|
726
|
+
function h(o, a) {
|
|
727
|
+
for (var u = new Array(arguments.length - 1), n = 0, r = 2, i = !0; r < arguments.length; )
|
|
728
|
+
u[n++] = arguments[r++];
|
|
688
729
|
return new Promise(function(e, s) {
|
|
689
|
-
|
|
730
|
+
u[n] = function(c) {
|
|
690
731
|
if (i)
|
|
691
732
|
if (i = !1, c)
|
|
692
733
|
s(c);
|
|
@@ -697,7 +738,7 @@ function requireAspromise() {
|
|
|
697
738
|
}
|
|
698
739
|
};
|
|
699
740
|
try {
|
|
700
|
-
o.apply(
|
|
741
|
+
o.apply(a || null, u);
|
|
701
742
|
} catch (l) {
|
|
702
743
|
i && (i = !1, s(l));
|
|
703
744
|
}
|
|
@@ -717,25 +758,25 @@ function requireBase64() {
|
|
|
717
758
|
++s;
|
|
718
759
|
return Math.ceil(t.length * 3) / 4 - s;
|
|
719
760
|
};
|
|
720
|
-
for (var
|
|
721
|
-
a[
|
|
761
|
+
for (var a = new Array(64), u = new Array(123), n = 0; n < 64; )
|
|
762
|
+
u[a[n] = n < 26 ? n + 65 : n < 52 ? n + 71 : n < 62 ? n - 4 : n - 59 | 43] = n++;
|
|
722
763
|
o.encode = function(t, e, s) {
|
|
723
764
|
for (var l = null, c = [], d = 0, p = 0, f; e < s; ) {
|
|
724
765
|
var w = t[e++];
|
|
725
766
|
switch (p) {
|
|
726
767
|
case 0:
|
|
727
|
-
c[d++] =
|
|
768
|
+
c[d++] = a[w >> 2], f = (w & 3) << 4, p = 1;
|
|
728
769
|
break;
|
|
729
770
|
case 1:
|
|
730
|
-
c[d++] =
|
|
771
|
+
c[d++] = a[f | w >> 4], f = (w & 15) << 2, p = 2;
|
|
731
772
|
break;
|
|
732
773
|
case 2:
|
|
733
|
-
c[d++] =
|
|
774
|
+
c[d++] = a[f | w >> 6], c[d++] = a[w & 63], p = 0;
|
|
734
775
|
break;
|
|
735
776
|
}
|
|
736
777
|
d > 8191 && ((l || (l = [])).push(String.fromCharCode.apply(String, c)), d = 0);
|
|
737
778
|
}
|
|
738
|
-
return p && (c[d++] =
|
|
779
|
+
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));
|
|
739
780
|
};
|
|
740
781
|
var r = "invalid encoding";
|
|
741
782
|
o.decode = function(t, e, s) {
|
|
@@ -743,7 +784,7 @@ function requireBase64() {
|
|
|
743
784
|
var f = t.charCodeAt(p++);
|
|
744
785
|
if (f === 61 && c > 1)
|
|
745
786
|
break;
|
|
746
|
-
if ((f =
|
|
787
|
+
if ((f = u[f]) === void 0)
|
|
747
788
|
throw Error(r);
|
|
748
789
|
switch (c) {
|
|
749
790
|
case 0:
|
|
@@ -775,27 +816,27 @@ function requireEventemitter() {
|
|
|
775
816
|
function h() {
|
|
776
817
|
this._listeners = {};
|
|
777
818
|
}
|
|
778
|
-
return h.prototype.on = function(
|
|
779
|
-
return (this._listeners[
|
|
780
|
-
fn:
|
|
819
|
+
return h.prototype.on = function(a, u, n) {
|
|
820
|
+
return (this._listeners[a] || (this._listeners[a] = [])).push({
|
|
821
|
+
fn: u,
|
|
781
822
|
ctx: n || this
|
|
782
823
|
}), this;
|
|
783
|
-
}, h.prototype.off = function(
|
|
784
|
-
if (
|
|
824
|
+
}, h.prototype.off = function(a, u) {
|
|
825
|
+
if (a === void 0)
|
|
785
826
|
this._listeners = {};
|
|
786
|
-
else if (
|
|
787
|
-
this._listeners[
|
|
827
|
+
else if (u === void 0)
|
|
828
|
+
this._listeners[a] = [];
|
|
788
829
|
else
|
|
789
|
-
for (var n = this._listeners[
|
|
790
|
-
n[r].fn ===
|
|
830
|
+
for (var n = this._listeners[a], r = 0; r < n.length; )
|
|
831
|
+
n[r].fn === u ? n.splice(r, 1) : ++r;
|
|
791
832
|
return this;
|
|
792
|
-
}, h.prototype.emit = function(
|
|
793
|
-
var
|
|
794
|
-
if (
|
|
833
|
+
}, h.prototype.emit = function(a) {
|
|
834
|
+
var u = this._listeners[a];
|
|
835
|
+
if (u) {
|
|
795
836
|
for (var n = [], r = 1; r < arguments.length; )
|
|
796
837
|
n.push(arguments[r++]);
|
|
797
|
-
for (r = 0; r <
|
|
798
|
-
|
|
838
|
+
for (r = 0; r < u.length; )
|
|
839
|
+
u[r].fn.apply(u[r++].ctx, n);
|
|
799
840
|
}
|
|
800
841
|
return this;
|
|
801
842
|
}, eventemitter;
|
|
@@ -843,12 +884,12 @@ function requireFloat() {
|
|
|
843
884
|
e((d << 31 | p + 127 << 23 | f) >>> 0, l, c);
|
|
844
885
|
}
|
|
845
886
|
}
|
|
846
|
-
r.writeFloatLE = i.bind(null, o), r.writeFloatBE = i.bind(null,
|
|
887
|
+
r.writeFloatLE = i.bind(null, o), r.writeFloatBE = i.bind(null, a);
|
|
847
888
|
function t(e, s, l) {
|
|
848
889
|
var c = e(s, l), d = (c >> 31) * 2 + 1, p = c >>> 23 & 255, f = c & 8388607;
|
|
849
890
|
return p === 255 ? f ? NaN : d * (1 / 0) : p === 0 ? d * 1401298464324817e-60 * f : d * Math.pow(2, p - 150) * (f + 8388608);
|
|
850
891
|
}
|
|
851
|
-
r.readFloatLE = t.bind(null,
|
|
892
|
+
r.readFloatLE = t.bind(null, u), r.readFloatBE = t.bind(null, n);
|
|
852
893
|
}(), typeof Float64Array < "u" ? function() {
|
|
853
894
|
var i = new Float64Array([-0]), t = new Uint8Array(i.buffer), e = t[7] === 128;
|
|
854
895
|
function s(p, f, w) {
|
|
@@ -890,21 +931,21 @@ function requireFloat() {
|
|
|
890
931
|
}
|
|
891
932
|
}
|
|
892
933
|
}
|
|
893
|
-
r.writeDoubleLE = i.bind(null, o, 0, 4), r.writeDoubleBE = i.bind(null,
|
|
934
|
+
r.writeDoubleLE = i.bind(null, o, 0, 4), r.writeDoubleBE = i.bind(null, a, 4, 0);
|
|
894
935
|
function t(e, s, l, c, d) {
|
|
895
936
|
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;
|
|
896
937
|
return b === 2047 ? g ? NaN : w * (1 / 0) : b === 0 ? w * 5e-324 * g : w * Math.pow(2, b - 1075) * (g + 4503599627370496);
|
|
897
938
|
}
|
|
898
|
-
r.readDoubleLE = t.bind(null,
|
|
939
|
+
r.readDoubleLE = t.bind(null, u, 0, 4), r.readDoubleBE = t.bind(null, n, 4, 0);
|
|
899
940
|
}(), r;
|
|
900
941
|
}
|
|
901
942
|
function o(r, i, t) {
|
|
902
943
|
i[t] = r & 255, i[t + 1] = r >>> 8 & 255, i[t + 2] = r >>> 16 & 255, i[t + 3] = r >>> 24;
|
|
903
944
|
}
|
|
904
|
-
function
|
|
945
|
+
function a(r, i, t) {
|
|
905
946
|
i[t] = r >>> 24, i[t + 1] = r >>> 16 & 255, i[t + 2] = r >>> 8 & 255, i[t + 3] = r & 255;
|
|
906
947
|
}
|
|
907
|
-
function
|
|
948
|
+
function u(r, i) {
|
|
908
949
|
return (r[i] | r[i + 1] << 8 | r[i + 2] << 16 | r[i + 3] << 24) >>> 0;
|
|
909
950
|
}
|
|
910
951
|
function n(r, i) {
|
|
@@ -931,20 +972,20 @@ var utf8 = {}, hasRequiredUtf8;
|
|
|
931
972
|
function requireUtf8() {
|
|
932
973
|
return hasRequiredUtf8 || (hasRequiredUtf8 = 1, function(h) {
|
|
933
974
|
var o = h;
|
|
934
|
-
o.length = function(
|
|
935
|
-
for (var n = 0, r = 0, i = 0; i <
|
|
936
|
-
r =
|
|
975
|
+
o.length = function(u) {
|
|
976
|
+
for (var n = 0, r = 0, i = 0; i < u.length; ++i)
|
|
977
|
+
r = u.charCodeAt(i), r < 128 ? n += 1 : r < 2048 ? n += 2 : (r & 64512) === 55296 && (u.charCodeAt(i + 1) & 64512) === 56320 ? (++i, n += 4) : n += 3;
|
|
937
978
|
return n;
|
|
938
|
-
}, o.read = function(
|
|
979
|
+
}, o.read = function(u, n, r) {
|
|
939
980
|
var i = r - n;
|
|
940
981
|
if (i < 1)
|
|
941
982
|
return "";
|
|
942
983
|
for (var t = null, e = [], s = 0, l; n < r; )
|
|
943
|
-
l =
|
|
984
|
+
l = u[n++], l < 128 ? e[s++] = l : l > 191 && l < 224 ? e[s++] = (l & 31) << 6 | u[n++] & 63 : l > 239 && l < 365 ? (l = ((l & 7) << 18 | (u[n++] & 63) << 12 | (u[n++] & 63) << 6 | u[n++] & 63) - 65536, e[s++] = 55296 + (l >> 10), e[s++] = 56320 + (l & 1023)) : e[s++] = (l & 15) << 12 | (u[n++] & 63) << 6 | u[n++] & 63, s > 8191 && ((t || (t = [])).push(String.fromCharCode.apply(String, e)), s = 0);
|
|
944
985
|
return t ? (s && t.push(String.fromCharCode.apply(String, e.slice(0, s))), t.join("")) : String.fromCharCode.apply(String, e.slice(0, s));
|
|
945
|
-
}, o.write = function(
|
|
946
|
-
for (var i = r, t, e, s = 0; s <
|
|
947
|
-
t =
|
|
986
|
+
}, o.write = function(u, n, r) {
|
|
987
|
+
for (var i = r, t, e, s = 0; s < u.length; ++s)
|
|
988
|
+
t = u.charCodeAt(s), t < 128 ? n[r++] = t : t < 2048 ? (n[r++] = t >> 6 | 192, n[r++] = t & 63 | 128) : (t & 64512) === 55296 && ((e = u.charCodeAt(s + 1)) & 64512) === 56320 ? (t = 65536 + ((t & 1023) << 10) + (e & 1023), ++s, n[r++] = t >> 18 | 240, n[r++] = t >> 12 & 63 | 128, n[r++] = t >> 6 & 63 | 128, n[r++] = t & 63 | 128) : (n[r++] = t >> 12 | 224, n[r++] = t >> 6 & 63 | 128, n[r++] = t & 63 | 128);
|
|
948
989
|
return r - i;
|
|
949
990
|
};
|
|
950
991
|
}(utf8)), utf8;
|
|
@@ -953,13 +994,13 @@ var pool_1, hasRequiredPool;
|
|
|
953
994
|
function requirePool() {
|
|
954
995
|
if (hasRequiredPool) return pool_1;
|
|
955
996
|
hasRequiredPool = 1, pool_1 = h;
|
|
956
|
-
function h(o,
|
|
957
|
-
var n =
|
|
997
|
+
function h(o, a, u) {
|
|
998
|
+
var n = u || 8192, r = n >>> 1, i = null, t = n;
|
|
958
999
|
return function(s) {
|
|
959
1000
|
if (s < 1 || s > r)
|
|
960
1001
|
return o(s);
|
|
961
1002
|
t + s > n && (i = o(n), t = 0);
|
|
962
|
-
var l =
|
|
1003
|
+
var l = a.call(i, t, t += s);
|
|
963
1004
|
return t & 7 && (t = (t | 7) + 1), l;
|
|
964
1005
|
};
|
|
965
1006
|
}
|
|
@@ -973,18 +1014,18 @@ function requireLongbits() {
|
|
|
973
1014
|
function o(r, i) {
|
|
974
1015
|
this.lo = r >>> 0, this.hi = i >>> 0;
|
|
975
1016
|
}
|
|
976
|
-
var
|
|
977
|
-
|
|
1017
|
+
var a = o.zero = new o(0, 0);
|
|
1018
|
+
a.toNumber = function() {
|
|
978
1019
|
return 0;
|
|
979
|
-
},
|
|
1020
|
+
}, a.zzEncode = a.zzDecode = function() {
|
|
980
1021
|
return this;
|
|
981
|
-
},
|
|
1022
|
+
}, a.length = function() {
|
|
982
1023
|
return 1;
|
|
983
1024
|
};
|
|
984
|
-
var
|
|
1025
|
+
var u = o.zeroHash = "\0\0\0\0\0\0\0\0";
|
|
985
1026
|
o.fromNumber = function(i) {
|
|
986
1027
|
if (i === 0)
|
|
987
|
-
return
|
|
1028
|
+
return a;
|
|
988
1029
|
var t = i < 0;
|
|
989
1030
|
t && (i = -i);
|
|
990
1031
|
var e = i >>> 0, s = (i - e) / 4294967296 >>> 0;
|
|
@@ -997,7 +1038,7 @@ function requireLongbits() {
|
|
|
997
1038
|
i = h.Long.fromString(i);
|
|
998
1039
|
else
|
|
999
1040
|
return o.fromNumber(parseInt(i, 10));
|
|
1000
|
-
return i.low || i.high ? new o(i.low >>> 0, i.high >>> 0) :
|
|
1041
|
+
return i.low || i.high ? new o(i.low >>> 0, i.high >>> 0) : a;
|
|
1001
1042
|
}, o.prototype.toNumber = function(i) {
|
|
1002
1043
|
if (!i && this.hi >>> 31) {
|
|
1003
1044
|
var t = ~this.lo + 1 >>> 0, e = ~this.hi >>> 0;
|
|
@@ -1009,7 +1050,7 @@ function requireLongbits() {
|
|
|
1009
1050
|
};
|
|
1010
1051
|
var n = String.prototype.charCodeAt;
|
|
1011
1052
|
return o.fromHash = function(i) {
|
|
1012
|
-
return i ===
|
|
1053
|
+
return i === u ? a : new o(
|
|
1013
1054
|
(n.call(i, 0) | n.call(i, 1) << 8 | n.call(i, 2) << 16 | n.call(i, 3) << 24) >>> 0,
|
|
1014
1055
|
(n.call(i, 4) | n.call(i, 5) << 8 | n.call(i, 6) << 16 | n.call(i, 7) << 24) >>> 0
|
|
1015
1056
|
);
|
|
@@ -1082,21 +1123,21 @@ function requireMinimal$1() {
|
|
|
1082
1123
|
var t = o.LongBits.fromHash(r);
|
|
1083
1124
|
return o.Long ? o.Long.fromBits(t.lo, t.hi, i) : t.toNumber(!!i);
|
|
1084
1125
|
};
|
|
1085
|
-
function
|
|
1126
|
+
function a(n, r, i) {
|
|
1086
1127
|
for (var t = Object.keys(r), e = 0; e < t.length; ++e)
|
|
1087
1128
|
(n[t[e]] === void 0 || !i) && (n[t[e]] = r[t[e]]);
|
|
1088
1129
|
return n;
|
|
1089
1130
|
}
|
|
1090
|
-
o.merge =
|
|
1131
|
+
o.merge = a, o.lcFirst = function(r) {
|
|
1091
1132
|
return r.charAt(0).toLowerCase() + r.substring(1);
|
|
1092
1133
|
};
|
|
1093
|
-
function
|
|
1134
|
+
function u(n) {
|
|
1094
1135
|
function r(i, t) {
|
|
1095
1136
|
if (!(this instanceof r))
|
|
1096
1137
|
return new r(i, t);
|
|
1097
1138
|
Object.defineProperty(this, "message", { get: function() {
|
|
1098
1139
|
return i;
|
|
1099
|
-
} }), Error.captureStackTrace ? Error.captureStackTrace(this, r) : Object.defineProperty(this, "stack", { value: new Error().stack || "" }), t &&
|
|
1140
|
+
} }), Error.captureStackTrace ? Error.captureStackTrace(this, r) : Object.defineProperty(this, "stack", { value: new Error().stack || "" }), t && a(this, t);
|
|
1100
1141
|
}
|
|
1101
1142
|
return r.prototype = Object.create(Error.prototype, {
|
|
1102
1143
|
constructor: {
|
|
@@ -1127,7 +1168,7 @@ function requireMinimal$1() {
|
|
|
1127
1168
|
}
|
|
1128
1169
|
}), r;
|
|
1129
1170
|
}
|
|
1130
|
-
o.newError =
|
|
1171
|
+
o.newError = u, o.ProtocolError = u("ProtocolError"), o.oneOfGetter = function(r) {
|
|
1131
1172
|
for (var i = {}, t = 0; t < r.length; ++t)
|
|
1132
1173
|
i[r[t]] = 1;
|
|
1133
1174
|
return function() {
|
|
@@ -1165,7 +1206,7 @@ var writer, hasRequiredWriter;
|
|
|
1165
1206
|
function requireWriter() {
|
|
1166
1207
|
if (hasRequiredWriter) return writer;
|
|
1167
1208
|
hasRequiredWriter = 1, writer = e;
|
|
1168
|
-
var h = requireMinimal$1(), o,
|
|
1209
|
+
var h = requireMinimal$1(), o, a = h.LongBits, u = h.base64, n = h.utf8;
|
|
1169
1210
|
function r(b, g, k) {
|
|
1170
1211
|
this.fn = b, this.len = g, this.next = void 0, this.val = k;
|
|
1171
1212
|
}
|
|
@@ -1208,7 +1249,7 @@ function requireWriter() {
|
|
|
1208
1249
|
g
|
|
1209
1250
|
)).len, this;
|
|
1210
1251
|
}, e.prototype.int32 = function(g) {
|
|
1211
|
-
return g < 0 ? this._push(p, 10,
|
|
1252
|
+
return g < 0 ? this._push(p, 10, a.fromNumber(g)) : this.uint32(g);
|
|
1212
1253
|
}, e.prototype.sint32 = function(g) {
|
|
1213
1254
|
return this.uint32((g << 1 ^ g >> 31) >>> 0);
|
|
1214
1255
|
};
|
|
@@ -1220,10 +1261,10 @@ function requireWriter() {
|
|
|
1220
1261
|
g[k++] = b.lo;
|
|
1221
1262
|
}
|
|
1222
1263
|
e.prototype.uint64 = function(g) {
|
|
1223
|
-
var k =
|
|
1264
|
+
var k = a.from(g);
|
|
1224
1265
|
return this._push(p, k.length(), k);
|
|
1225
1266
|
}, e.prototype.int64 = e.prototype.uint64, e.prototype.sint64 = function(g) {
|
|
1226
|
-
var k =
|
|
1267
|
+
var k = a.from(g).zzEncode();
|
|
1227
1268
|
return this._push(p, k.length(), k);
|
|
1228
1269
|
}, e.prototype.bool = function(g) {
|
|
1229
1270
|
return this._push(l, 1, g ? 1 : 0);
|
|
@@ -1234,7 +1275,7 @@ function requireWriter() {
|
|
|
1234
1275
|
e.prototype.fixed32 = function(g) {
|
|
1235
1276
|
return this._push(f, 4, g >>> 0);
|
|
1236
1277
|
}, e.prototype.sfixed32 = e.prototype.fixed32, e.prototype.fixed64 = function(g) {
|
|
1237
|
-
var k =
|
|
1278
|
+
var k = a.from(g);
|
|
1238
1279
|
return this._push(f, 4, k.lo)._push(f, 4, k.hi);
|
|
1239
1280
|
}, e.prototype.sfixed64 = e.prototype.fixed64, e.prototype.float = function(g) {
|
|
1240
1281
|
return this._push(h.float.writeFloatLE, 4, g);
|
|
@@ -1244,16 +1285,16 @@ function requireWriter() {
|
|
|
1244
1285
|
var w = h.Array.prototype.set ? function(g, k, T) {
|
|
1245
1286
|
k.set(g, T);
|
|
1246
1287
|
} : function(g, k, T) {
|
|
1247
|
-
for (var
|
|
1248
|
-
k[T +
|
|
1288
|
+
for (var D = 0; D < g.length; ++D)
|
|
1289
|
+
k[T + D] = g[D];
|
|
1249
1290
|
};
|
|
1250
1291
|
return e.prototype.bytes = function(g) {
|
|
1251
1292
|
var k = g.length >>> 0;
|
|
1252
1293
|
if (!k)
|
|
1253
1294
|
return this._push(l, 1, 0);
|
|
1254
1295
|
if (h.isString(g)) {
|
|
1255
|
-
var T = e.alloc(k =
|
|
1256
|
-
|
|
1296
|
+
var T = e.alloc(k = u.length(g));
|
|
1297
|
+
u.decode(g, T, 0), g = T;
|
|
1257
1298
|
}
|
|
1258
1299
|
return this.uint32(k)._push(w, k, g);
|
|
1259
1300
|
}, e.prototype.string = function(g) {
|
|
@@ -1277,15 +1318,15 @@ function requireWriter() {
|
|
|
1277
1318
|
var writer_buffer, hasRequiredWriter_buffer;
|
|
1278
1319
|
function requireWriter_buffer() {
|
|
1279
1320
|
if (hasRequiredWriter_buffer) return writer_buffer;
|
|
1280
|
-
hasRequiredWriter_buffer = 1, writer_buffer =
|
|
1321
|
+
hasRequiredWriter_buffer = 1, writer_buffer = a;
|
|
1281
1322
|
var h = requireWriter();
|
|
1282
|
-
(
|
|
1323
|
+
(a.prototype = Object.create(h.prototype)).constructor = a;
|
|
1283
1324
|
var o = requireMinimal$1();
|
|
1284
|
-
function
|
|
1325
|
+
function a() {
|
|
1285
1326
|
h.call(this);
|
|
1286
1327
|
}
|
|
1287
|
-
|
|
1288
|
-
|
|
1328
|
+
a._configure = function() {
|
|
1329
|
+
a.alloc = o._Buffer_allocUnsafe, a.writeBytesBuffer = o.Buffer && o.Buffer.prototype instanceof Uint8Array && o.Buffer.prototype.set.name === "set" ? function(r, i, t) {
|
|
1289
1330
|
i.set(r, t);
|
|
1290
1331
|
} : function(r, i, t) {
|
|
1291
1332
|
if (r.copy)
|
|
@@ -1293,24 +1334,24 @@ function requireWriter_buffer() {
|
|
|
1293
1334
|
else for (var e = 0; e < r.length; )
|
|
1294
1335
|
i[t++] = r[e++];
|
|
1295
1336
|
};
|
|
1296
|
-
},
|
|
1337
|
+
}, a.prototype.bytes = function(r) {
|
|
1297
1338
|
o.isString(r) && (r = o._Buffer_from(r, "base64"));
|
|
1298
1339
|
var i = r.length >>> 0;
|
|
1299
|
-
return this.uint32(i), i && this._push(
|
|
1340
|
+
return this.uint32(i), i && this._push(a.writeBytesBuffer, i, r), this;
|
|
1300
1341
|
};
|
|
1301
|
-
function
|
|
1342
|
+
function u(n, r, i) {
|
|
1302
1343
|
n.length < 40 ? o.utf8.write(n, r, i) : r.utf8Write ? r.utf8Write(n, i) : r.write(n, i);
|
|
1303
1344
|
}
|
|
1304
|
-
return
|
|
1345
|
+
return a.prototype.string = function(r) {
|
|
1305
1346
|
var i = o.Buffer.byteLength(r);
|
|
1306
|
-
return this.uint32(i), i && this._push(
|
|
1307
|
-
},
|
|
1347
|
+
return this.uint32(i), i && this._push(u, i, r), this;
|
|
1348
|
+
}, a._configure(), writer_buffer;
|
|
1308
1349
|
}
|
|
1309
1350
|
var reader, hasRequiredReader;
|
|
1310
1351
|
function requireReader() {
|
|
1311
1352
|
if (hasRequiredReader) return reader;
|
|
1312
1353
|
hasRequiredReader = 1, reader = r;
|
|
1313
|
-
var h = requireMinimal$1(), o,
|
|
1354
|
+
var h = requireMinimal$1(), o, a = h.LongBits, u = h.utf8;
|
|
1314
1355
|
function n(c, d) {
|
|
1315
1356
|
return RangeError("index out of range: " + c.pos + " + " + (d || 1) + " > " + c.len);
|
|
1316
1357
|
}
|
|
@@ -1348,7 +1389,7 @@ function requireReader() {
|
|
|
1348
1389
|
return d >>> 1 ^ -(d & 1) | 0;
|
|
1349
1390
|
};
|
|
1350
1391
|
function e() {
|
|
1351
|
-
var c = new
|
|
1392
|
+
var c = new a(0, 0), d = 0;
|
|
1352
1393
|
if (this.len - this.pos > 4) {
|
|
1353
1394
|
for (; d < 4; ++d)
|
|
1354
1395
|
if (c.lo = (c.lo | (this.buf[this.pos] & 127) << d * 7) >>> 0, this.buf[this.pos++] < 128)
|
|
@@ -1396,7 +1437,7 @@ function requireReader() {
|
|
|
1396
1437
|
function l() {
|
|
1397
1438
|
if (this.pos + 8 > this.len)
|
|
1398
1439
|
throw n(this, 8);
|
|
1399
|
-
return new
|
|
1440
|
+
return new a(s(this.buf, this.pos += 4), s(this.buf, this.pos += 4));
|
|
1400
1441
|
}
|
|
1401
1442
|
return r.prototype.float = function() {
|
|
1402
1443
|
if (this.pos + 4 > this.len)
|
|
@@ -1421,7 +1462,7 @@ function requireReader() {
|
|
|
1421
1462
|
return this._slice.call(this.buf, p, f);
|
|
1422
1463
|
}, r.prototype.string = function() {
|
|
1423
1464
|
var d = this.bytes();
|
|
1424
|
-
return
|
|
1465
|
+
return u.read(d, 0, d.length);
|
|
1425
1466
|
}, r.prototype.skip = function(d) {
|
|
1426
1467
|
if (typeof d == "number") {
|
|
1427
1468
|
if (this.pos + d > this.len)
|
|
@@ -1484,19 +1525,19 @@ function requireReader() {
|
|
|
1484
1525
|
var reader_buffer, hasRequiredReader_buffer;
|
|
1485
1526
|
function requireReader_buffer() {
|
|
1486
1527
|
if (hasRequiredReader_buffer) return reader_buffer;
|
|
1487
|
-
hasRequiredReader_buffer = 1, reader_buffer =
|
|
1528
|
+
hasRequiredReader_buffer = 1, reader_buffer = a;
|
|
1488
1529
|
var h = requireReader();
|
|
1489
|
-
(
|
|
1530
|
+
(a.prototype = Object.create(h.prototype)).constructor = a;
|
|
1490
1531
|
var o = requireMinimal$1();
|
|
1491
|
-
function u
|
|
1492
|
-
h.call(this,
|
|
1532
|
+
function a(u) {
|
|
1533
|
+
h.call(this, u);
|
|
1493
1534
|
}
|
|
1494
|
-
return
|
|
1495
|
-
o.Buffer && (
|
|
1496
|
-
},
|
|
1535
|
+
return a._configure = function() {
|
|
1536
|
+
o.Buffer && (a.prototype._slice = o.Buffer.prototype.slice);
|
|
1537
|
+
}, a.prototype.string = function() {
|
|
1497
1538
|
var n = this.uint32();
|
|
1498
1539
|
return this.buf.utf8Slice ? this.buf.utf8Slice(this.pos, this.pos = Math.min(this.pos + n, this.len)) : this.buf.toString("utf-8", this.pos, this.pos = Math.min(this.pos + n, this.len));
|
|
1499
|
-
},
|
|
1540
|
+
}, a._configure(), reader_buffer;
|
|
1500
1541
|
}
|
|
1501
1542
|
var rpc = {}, service, hasRequiredService;
|
|
1502
1543
|
function requireService() {
|
|
@@ -1504,17 +1545,17 @@ function requireService() {
|
|
|
1504
1545
|
hasRequiredService = 1, service = o;
|
|
1505
1546
|
var h = requireMinimal$1();
|
|
1506
1547
|
(o.prototype = Object.create(h.EventEmitter.prototype)).constructor = o;
|
|
1507
|
-
function o(
|
|
1508
|
-
if (typeof
|
|
1548
|
+
function o(a, u, n) {
|
|
1549
|
+
if (typeof a != "function")
|
|
1509
1550
|
throw TypeError("rpcImpl must be a function");
|
|
1510
|
-
h.EventEmitter.call(this), this.rpcImpl =
|
|
1551
|
+
h.EventEmitter.call(this), this.rpcImpl = a, this.requestDelimited = !!u, this.responseDelimited = !!n;
|
|
1511
1552
|
}
|
|
1512
|
-
return o.prototype.rpcCall = function u
|
|
1553
|
+
return o.prototype.rpcCall = function a(u, n, r, i, t) {
|
|
1513
1554
|
if (!i)
|
|
1514
1555
|
throw TypeError("request must be specified");
|
|
1515
1556
|
var e = this;
|
|
1516
1557
|
if (!t)
|
|
1517
|
-
return h.asPromise(
|
|
1558
|
+
return h.asPromise(a, e, u, n, r, i);
|
|
1518
1559
|
if (!e.rpcImpl) {
|
|
1519
1560
|
setTimeout(function() {
|
|
1520
1561
|
t(Error("already ended"));
|
|
@@ -1523,11 +1564,11 @@ function requireService() {
|
|
|
1523
1564
|
}
|
|
1524
1565
|
try {
|
|
1525
1566
|
return e.rpcImpl(
|
|
1526
|
-
|
|
1567
|
+
u,
|
|
1527
1568
|
n[e.requestDelimited ? "encodeDelimited" : "encode"](i).finish(),
|
|
1528
1569
|
function(l, c) {
|
|
1529
1570
|
if (l)
|
|
1530
|
-
return e.emit("error", l,
|
|
1571
|
+
return e.emit("error", l, u), t(l);
|
|
1531
1572
|
if (c === null) {
|
|
1532
1573
|
e.end(
|
|
1533
1574
|
/* endedByRPC */
|
|
@@ -1539,19 +1580,19 @@ function requireService() {
|
|
|
1539
1580
|
try {
|
|
1540
1581
|
c = r[e.responseDelimited ? "decodeDelimited" : "decode"](c);
|
|
1541
1582
|
} catch (d) {
|
|
1542
|
-
return e.emit("error", d,
|
|
1583
|
+
return e.emit("error", d, u), t(d);
|
|
1543
1584
|
}
|
|
1544
|
-
return e.emit("data", c,
|
|
1585
|
+
return e.emit("data", c, u), t(null, c);
|
|
1545
1586
|
}
|
|
1546
1587
|
);
|
|
1547
1588
|
} catch (s) {
|
|
1548
|
-
e.emit("error", s,
|
|
1589
|
+
e.emit("error", s, u), setTimeout(function() {
|
|
1549
1590
|
t(s);
|
|
1550
1591
|
}, 0);
|
|
1551
1592
|
return;
|
|
1552
1593
|
}
|
|
1553
|
-
}, o.prototype.end = function(
|
|
1554
|
-
return this.rpcImpl && (
|
|
1594
|
+
}, o.prototype.end = function(u) {
|
|
1595
|
+
return this.rpcImpl && (u || this.rpcImpl(null, null, null), this.rpcImpl = null, this.emit("end").off()), this;
|
|
1555
1596
|
}, service;
|
|
1556
1597
|
}
|
|
1557
1598
|
var hasRequiredRpc;
|
|
@@ -1569,11 +1610,11 @@ var hasRequiredIndexMinimal;
|
|
|
1569
1610
|
function requireIndexMinimal() {
|
|
1570
1611
|
return hasRequiredIndexMinimal || (hasRequiredIndexMinimal = 1, function(h) {
|
|
1571
1612
|
var o = h;
|
|
1572
|
-
o.build = "minimal", o.Writer = requireWriter(), o.BufferWriter = requireWriter_buffer(), o.Reader = requireReader(), o.BufferReader = requireReader_buffer(), o.util = requireMinimal$1(), o.rpc = requireRpc(), o.roots = requireRoots(), o.configure =
|
|
1573
|
-
function
|
|
1613
|
+
o.build = "minimal", o.Writer = requireWriter(), o.BufferWriter = requireWriter_buffer(), o.Reader = requireReader(), o.BufferReader = requireReader_buffer(), o.util = requireMinimal$1(), o.rpc = requireRpc(), o.roots = requireRoots(), o.configure = a;
|
|
1614
|
+
function a() {
|
|
1574
1615
|
o.util._configure(), o.Writer._configure(o.BufferWriter), o.Reader._configure(o.BufferReader);
|
|
1575
1616
|
}
|
|
1576
|
-
|
|
1617
|
+
a();
|
|
1577
1618
|
}(indexMinimal)), indexMinimal;
|
|
1578
1619
|
}
|
|
1579
1620
|
var minimal, hasRequiredMinimal;
|
|
@@ -1586,10 +1627,10 @@ const $Reader = minimalExports.Reader, $Writer = minimalExports.Writer, $util =
|
|
|
1586
1627
|
return h.quick = function() {
|
|
1587
1628
|
const o = {};
|
|
1588
1629
|
return o.voice = function() {
|
|
1589
|
-
const
|
|
1590
|
-
return
|
|
1591
|
-
const
|
|
1592
|
-
return
|
|
1630
|
+
const a = {};
|
|
1631
|
+
return a.proto = function() {
|
|
1632
|
+
const u = {};
|
|
1633
|
+
return u.SeiData = function() {
|
|
1593
1634
|
function n(r) {
|
|
1594
1635
|
if (r) for (let i = Object.keys(r), t = 0; t < i.length; ++t) r[i[t]] != null && (this[i[t]] = r[i[t]]);
|
|
1595
1636
|
}
|
|
@@ -1682,10 +1723,10 @@ const $Reader = minimalExports.Reader, $Writer = minimalExports.Writer, $util =
|
|
|
1682
1723
|
}, n.getTypeUrl = function(i) {
|
|
1683
1724
|
return i === void 0 && (i = "type.googleapis.com"), i + "/com.quick.voice.proto.SeiData";
|
|
1684
1725
|
}, n;
|
|
1685
|
-
}(),
|
|
1726
|
+
}(), u.EventType = function() {
|
|
1686
1727
|
const n = {}, r = Object.create(n);
|
|
1687
1728
|
return r[n[0] = "Layout"] = 0, r[n[1] = "Custom"] = 1, r;
|
|
1688
|
-
}(),
|
|
1729
|
+
}(), u.LayoutData = function() {
|
|
1689
1730
|
function n(i) {
|
|
1690
1731
|
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]]);
|
|
1691
1732
|
}
|
|
@@ -1844,7 +1885,7 @@ const $Reader = minimalExports.Reader, $Writer = minimalExports.Writer, $util =
|
|
|
1844
1885
|
}, n.getTypeUrl = function(t) {
|
|
1845
1886
|
return t === void 0 && (t = "type.googleapis.com"), t + "/com.quick.voice.proto.LayoutData";
|
|
1846
1887
|
}, n;
|
|
1847
|
-
}(),
|
|
1888
|
+
}(), u.UserInfo = function() {
|
|
1848
1889
|
function n(i) {
|
|
1849
1890
|
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]]);
|
|
1850
1891
|
}
|
|
@@ -1967,7 +2008,7 @@ const $Reader = minimalExports.Reader, $Writer = minimalExports.Writer, $util =
|
|
|
1967
2008
|
}, n.getTypeUrl = function(t) {
|
|
1968
2009
|
return t === void 0 && (t = "type.googleapis.com"), t + "/com.quick.voice.proto.UserInfo";
|
|
1969
2010
|
}, n;
|
|
1970
|
-
}(),
|
|
2011
|
+
}(), u.AudioInfo = function() {
|
|
1971
2012
|
function n(i) {
|
|
1972
2013
|
if (i) for (let t = Object.keys(i), e = 0; e < t.length; ++e) i[t[e]] != null && (this[t[e]] = i[t[e]]);
|
|
1973
2014
|
}
|
|
@@ -2072,7 +2113,7 @@ const $Reader = minimalExports.Reader, $Writer = minimalExports.Writer, $util =
|
|
|
2072
2113
|
}, n.getTypeUrl = function(t) {
|
|
2073
2114
|
return t === void 0 && (t = "type.googleapis.com"), t + "/com.quick.voice.proto.AudioInfo";
|
|
2074
2115
|
}, n;
|
|
2075
|
-
}(),
|
|
2116
|
+
}(), u.VideoInfo = function() {
|
|
2076
2117
|
function n(i) {
|
|
2077
2118
|
if (i) for (let t = Object.keys(i), e = 0; e < t.length; ++e) i[t[e]] != null && (this[t[e]] = i[t[e]]);
|
|
2078
2119
|
}
|
|
@@ -2198,7 +2239,7 @@ const $Reader = minimalExports.Reader, $Writer = minimalExports.Writer, $util =
|
|
|
2198
2239
|
}, n.getTypeUrl = function(t) {
|
|
2199
2240
|
return t === void 0 && (t = "type.googleapis.com"), t + "/com.quick.voice.proto.VideoInfo";
|
|
2200
2241
|
}, n;
|
|
2201
|
-
}(),
|
|
2242
|
+
}(), u.CustomInfo = function() {
|
|
2202
2243
|
function n(i) {
|
|
2203
2244
|
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]]);
|
|
2204
2245
|
}
|
|
@@ -2305,17 +2346,17 @@ const $Reader = minimalExports.Reader, $Writer = minimalExports.Writer, $util =
|
|
|
2305
2346
|
}, n.getTypeUrl = function(t) {
|
|
2306
2347
|
return t === void 0 && (t = "type.googleapis.com"), t + "/com.quick.voice.proto.CustomInfo";
|
|
2307
2348
|
}, n;
|
|
2308
|
-
}(),
|
|
2349
|
+
}(), u.LayoutType = function() {
|
|
2309
2350
|
const n = {}, r = Object.create(n);
|
|
2310
2351
|
return r[n[0] = "AudioAndVideo"] = 0, r[n[1] = "OnlyAudio"] = 1, r[n[2] = "OnlyVideo"] = 2, r;
|
|
2311
|
-
}(),
|
|
2352
|
+
}(), u.AudioType = function() {
|
|
2312
2353
|
const n = {}, r = Object.create(n);
|
|
2313
2354
|
return r[n[0] = "Microphone"] = 0, r[n[1] = "SystemVoice"] = 1, r;
|
|
2314
|
-
}(),
|
|
2355
|
+
}(), u.VideoType = function() {
|
|
2315
2356
|
const n = {}, r = Object.create(n);
|
|
2316
2357
|
return r[n[0] = "Camera"] = 0, r[n[1] = "Screen"] = 1, r;
|
|
2317
|
-
}(),
|
|
2318
|
-
}(),
|
|
2358
|
+
}(), u;
|
|
2359
|
+
}(), a;
|
|
2319
2360
|
}(), o;
|
|
2320
2361
|
}(), h;
|
|
2321
2362
|
})(), createAudioInfo = () => ({
|
|
@@ -2352,11 +2393,11 @@ class RoomUser {
|
|
|
2352
2393
|
});
|
|
2353
2394
|
m(this, "init", (o) => {
|
|
2354
2395
|
var t, e, s, l;
|
|
2355
|
-
const { id:
|
|
2356
|
-
this.userId =
|
|
2396
|
+
const { id: a, audios: u = [], videos: n = [] } = o;
|
|
2397
|
+
this.userId = a;
|
|
2357
2398
|
const r = this.getUpdateTimeKey();
|
|
2358
2399
|
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);
|
|
2359
|
-
for (const c of
|
|
2400
|
+
for (const c of u) {
|
|
2360
2401
|
const { type: d = 0, isEnable: p = !1, isMute: f = !1, updateTime: w, volume: b = 0 } = c;
|
|
2361
2402
|
switch (d) {
|
|
2362
2403
|
case 0:
|
|
@@ -2395,26 +2436,25 @@ class RoomUser {
|
|
|
2395
2436
|
r !== i && (this.updateTime = (/* @__PURE__ */ new Date()).getTime());
|
|
2396
2437
|
});
|
|
2397
2438
|
m(this, "destroy", () => {
|
|
2398
|
-
|
|
2399
|
-
(o = this.mc_video) != null && o.destroy && this.mc_video.destroy(), (u = this.ss_video) != null && u.destroy && this.ss_video.destroy(), this.mc_audio = void 0, this.mc_video = void 0, this.ss_audio = void 0, this.ss_video = void 0;
|
|
2439
|
+
this.mc_audio = void 0, this.mc_video = void 0, this.ss_audio = void 0, this.ss_video = void 0;
|
|
2400
2440
|
});
|
|
2401
2441
|
}
|
|
2402
2442
|
}
|
|
2403
2443
|
const parseSEI = (h) => {
|
|
2404
|
-
let o = 0,
|
|
2444
|
+
let o = 0, a = 0;
|
|
2405
2445
|
for (; ; ) {
|
|
2406
2446
|
const n = h[o];
|
|
2407
|
-
if (
|
|
2447
|
+
if (a = a + n, o = o + 1, n !== 255) break;
|
|
2408
2448
|
}
|
|
2409
|
-
let
|
|
2449
|
+
let u = 0;
|
|
2410
2450
|
for (; ; ) {
|
|
2411
2451
|
const n = h[o];
|
|
2412
|
-
if (
|
|
2452
|
+
if (u = u + n, o = o + 1, n !== 255) break;
|
|
2413
2453
|
}
|
|
2414
|
-
if (
|
|
2454
|
+
if (a === 5) {
|
|
2415
2455
|
const n = h.slice(o, o + 16), i = Array.from(n, (f) => f.toString(16).padStart(2, "0")).join("");
|
|
2416
2456
|
o = o + 16;
|
|
2417
|
-
const t =
|
|
2457
|
+
const t = u - 16, e = h.slice(o, o + t), s = com.quick.voice.proto.SeiData.decode(e), { event: l = 0 } = s, c = s.data;
|
|
2418
2458
|
let d;
|
|
2419
2459
|
switch (l) {
|
|
2420
2460
|
case 0:
|
|
@@ -2456,55 +2496,53 @@ class QuickVoPlayer {
|
|
|
2456
2496
|
m(this, "setMute", (o) => {
|
|
2457
2497
|
this.prPlayer.setMute(o);
|
|
2458
2498
|
});
|
|
2499
|
+
m(this, "setOutputGain", (o) => {
|
|
2500
|
+
var a, u;
|
|
2501
|
+
(u = (a = this.prPlayer.audioPlayer) == null ? void 0 : a.prAudioStream) == null || u.setOutputGain(o);
|
|
2502
|
+
});
|
|
2459
2503
|
m(this, "getStream", () => this.prPlayer.getStream());
|
|
2460
2504
|
m(this, "getAllUseUpdateKey", () => {
|
|
2461
2505
|
const o = [...this.usersMap.values()];
|
|
2462
|
-
return Array.from(o, (
|
|
2506
|
+
return Array.from(o, (u) => u.updateTime).join("_");
|
|
2463
2507
|
});
|
|
2464
|
-
m(this, "checkAndCreateUser", (o,
|
|
2465
|
-
var n, r;
|
|
2508
|
+
m(this, "checkAndCreateUser", (o, a) => {
|
|
2466
2509
|
!this.usersMap.has(o) && this.usersMap.set(o, new RoomUser());
|
|
2467
|
-
const
|
|
2468
|
-
if (
|
|
2469
|
-
if (
|
|
2470
|
-
const { sx:
|
|
2471
|
-
|
|
2472
|
-
p(), this.prPlayer.cut.remove(l), a.mc_video = void 0;
|
|
2473
|
-
};
|
|
2510
|
+
const u = this.usersMap.get(o);
|
|
2511
|
+
if (u) {
|
|
2512
|
+
if (u.init(a), u.mc_video && u.mc_video.stream === void 0) {
|
|
2513
|
+
const { sx: n, sy: r, sw: i, sh: t } = u.mc_video, e = `${u.userId}_mc_video`, s = this.prPlayer.cut.create(e, { sx: n, sy: r, sw: i, sh: t });
|
|
2514
|
+
this.displayMode === "original" && this.prPlayer.cut.setPause(e, !0), u.mc_video.stream = s;
|
|
2474
2515
|
}
|
|
2475
|
-
if (
|
|
2476
|
-
const { sx:
|
|
2477
|
-
|
|
2478
|
-
p(), this.prPlayer.cut.remove(l), a.ss_video = void 0;
|
|
2479
|
-
};
|
|
2516
|
+
if (u.ss_video && u.ss_video.stream === void 0) {
|
|
2517
|
+
const { sx: n, sy: r, sw: i, sh: t } = u.ss_video, e = `${u.userId}_ss_video`, s = this.prPlayer.cut.create(e, { sx: n, sy: r, sw: i, sh: t });
|
|
2518
|
+
this.displayMode === "original" && this.prPlayer.cut.setPause(e, !0), u.ss_video.stream = s;
|
|
2480
2519
|
}
|
|
2481
|
-
if (
|
|
2482
|
-
const { sx:
|
|
2483
|
-
|
|
2520
|
+
if (u != null && u.mc_video) {
|
|
2521
|
+
const n = `${u.userId}_mc_video`, { sx: r, sy: i, sw: t, sh: e } = u.mc_video;
|
|
2522
|
+
this.prPlayer.cut.setCut(n, { sx: r, sy: i, sw: t, sh: e });
|
|
2484
2523
|
}
|
|
2485
|
-
if (
|
|
2486
|
-
const { sx:
|
|
2487
|
-
|
|
2524
|
+
if (u != null && u.ss_video) {
|
|
2525
|
+
const n = `${u.userId}_ss_video`, { sx: r, sy: i, sw: t, sh: e } = u.ss_video;
|
|
2526
|
+
this.prPlayer.cut.setCut(n, { sx: r, sy: i, sw: t, sh: e });
|
|
2488
2527
|
}
|
|
2489
2528
|
}
|
|
2490
2529
|
});
|
|
2491
2530
|
m(this, "setDisplayMode", (o) => {
|
|
2492
|
-
var u, a, n, r, i, t, e, s;
|
|
2493
2531
|
switch (this.displayMode = o, o) {
|
|
2494
2532
|
case "original":
|
|
2495
2533
|
{
|
|
2496
2534
|
this.prPlayer.setPause(!1);
|
|
2497
|
-
const
|
|
2498
|
-
for (const
|
|
2499
|
-
|
|
2535
|
+
const a = [...this.usersMap.keys()];
|
|
2536
|
+
for (const u of a)
|
|
2537
|
+
this.prPlayer.cut.setPause(`${u}_mc_video`, !0), this.prPlayer.cut.setPause(`${u}_ss_video`, !0);
|
|
2500
2538
|
}
|
|
2501
2539
|
break;
|
|
2502
2540
|
case "cut":
|
|
2503
2541
|
{
|
|
2504
2542
|
this.prPlayer.setPause(!0);
|
|
2505
|
-
const
|
|
2506
|
-
for (const
|
|
2507
|
-
|
|
2543
|
+
const a = [...this.usersMap.keys()];
|
|
2544
|
+
for (const u of a)
|
|
2545
|
+
this.prPlayer.cut.setPause(`${u}_mc_video`, !1), this.prPlayer.cut.setPause(`${u}_ss_video`, !1);
|
|
2508
2546
|
}
|
|
2509
2547
|
break;
|
|
2510
2548
|
}
|
|
@@ -2514,19 +2552,19 @@ class QuickVoPlayer {
|
|
|
2514
2552
|
*/
|
|
2515
2553
|
m(this, "onSEI", (o) => {
|
|
2516
2554
|
try {
|
|
2517
|
-
const
|
|
2518
|
-
if (!
|
|
2519
|
-
const { event:
|
|
2520
|
-
switch (
|
|
2555
|
+
const a = parseSEI(o);
|
|
2556
|
+
if (!a) return;
|
|
2557
|
+
const { event: u, data: n } = a;
|
|
2558
|
+
switch (u) {
|
|
2521
2559
|
case 0:
|
|
2522
2560
|
{
|
|
2523
2561
|
const { roomId: r, userMap: i } = n;
|
|
2524
2562
|
if (r !== this.room.roomId) return;
|
|
2525
2563
|
const t = this.getAllUseUpdateKey(), e = Object.keys(i);
|
|
2526
2564
|
{
|
|
2527
|
-
const l = [...this.usersMap.
|
|
2565
|
+
const l = [...this.usersMap.keys()];
|
|
2528
2566
|
for (const c of l)
|
|
2529
|
-
e.includes(c
|
|
2567
|
+
e.includes(c) || (this.prPlayer.cut.remove(`${c}_mc_video`), this.prPlayer.cut.remove(`${c}_ss_video`), this.usersMap.delete(c));
|
|
2530
2568
|
}
|
|
2531
2569
|
for (const l of e) {
|
|
2532
2570
|
const c = i[l];
|
|
@@ -2546,15 +2584,25 @@ class QuickVoPlayer {
|
|
|
2546
2584
|
}
|
|
2547
2585
|
break;
|
|
2548
2586
|
}
|
|
2549
|
-
} catch (
|
|
2550
|
-
console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", "------->onSEI: error",
|
|
2587
|
+
} catch (a) {
|
|
2588
|
+
console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", "------->onSEI: error", a);
|
|
2551
2589
|
}
|
|
2552
2590
|
});
|
|
2553
2591
|
m(this, "onAnalysis", (o) => {
|
|
2554
2592
|
this.on.analysis && this.on.analysis(o);
|
|
2555
2593
|
});
|
|
2556
|
-
const
|
|
2557
|
-
|
|
2594
|
+
const u = btoa(encodeURI(JSON.stringify({
|
|
2595
|
+
appId: "A6B499768801E248ACA11E5F842DB6DF",
|
|
2596
|
+
userId: "web_breathe",
|
|
2597
|
+
// "authId":"mobilePackageName" | "webRequestHostOrigin",
|
|
2598
|
+
platform: "web",
|
|
2599
|
+
version: "1.0.1"
|
|
2600
|
+
// 连接版本号
|
|
2601
|
+
}))), n = `${this.option.ws}?s=${u}&t=${Date.now()}`;
|
|
2602
|
+
let r = new WebSocket(n);
|
|
2603
|
+
console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", "------->Breathe: ws", r);
|
|
2604
|
+
const { debug: i = !1 } = o;
|
|
2605
|
+
this.option.debug = i, this.prPlayer = new tt({ debug: i }), this.prPlayer.on.demuxer.chunk = (t) => {
|
|
2558
2606
|
}, this.prPlayer.on.decoder.sei = this.onSEI, this.prPlayer.on.decoder.analysis = this.onAnalysis;
|
|
2559
2607
|
}
|
|
2560
2608
|
}
|