quickvo-player 0.1.5 → 0.1.6
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 +11 -311
- package/dist/QuickVoPlayer.d.ts +0 -1
- package/dist/index.js +148 -151
- package/dist/index.umd.cjs +4 -4
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -3,7 +3,7 @@ var X = (h) => {
|
|
|
3
3
|
throw TypeError(h);
|
|
4
4
|
};
|
|
5
5
|
var tt = (h, o, a) => o in h ? Q(h, o, { enumerable: !0, configurable: !0, writable: !0, value: a }) : h[o] = a;
|
|
6
|
-
var
|
|
6
|
+
var g = (h, o, a) => tt(h, typeof o != "symbol" ? o + "" : o, a), Z = (h, o, a) => o.has(h) || X("Cannot " + a);
|
|
7
7
|
var I = (h, o, a) => (Z(h, o, "read from private field"), a ? a.call(h) : o.get(h)), J = (h, o, a) => o.has(h) ? X("Cannot add the same private member more than once") : o instanceof WeakSet ? o.add(h) : o.set(h, a), H = (h, o, a, u) => (Z(h, o, "write to private field"), u ? u.call(h, a) : o.set(h, a), a);
|
|
8
8
|
const D = '(function(){"use strict";class P{pendingPayloads=[];payload=new Uint8Array(0);chunks=[];push=t=>{this.pendingPayloads.push(t)};next=(t=0)=>{this.payload=this.payload.slice(t);const s=this.pendingPayloads.shift();if(!s)return!1;const e=new Uint8Array(this.payload.byteLength+s.byteLength);return e.set(this.payload,0),e.set(s,this.payload.byteLength),this.payload=e,new DataView(this.payload.buffer)};pushChunk=t=>{this.chunks.push(t),this.chunks.length>1e3&&this.chunks.shift()};destroy=()=>{this.pendingPayloads=[],this.payload=new Uint8Array(0),this.chunks=[]}}const I=(y,t)=>{const s=new Uint8Array(y),e=new Uint8Array(t),n=new Uint8Array(11+s.length+e.length);let a=0;return n[a++]=1,n[a++]=s[1],n[a++]=s[2],n[a++]=s[3],n[a++]=255,n[a++]=225,n[a++]=s.length>>8&255,n[a++]=s.length&255,n.set(s,a),a+=s.length,n[a++]=1,n[a++]=e.length>>8&255,n[a++]=e.length&255,n.set(e,a),n},T=y=>{let t=0;const s=new DataView(y.buffer),e=s.getUint8(t);if(t=t+1,e!==1)throw new Error("Invalid AVC version");const n=s.getUint8(t)&255;t=t+1;const a=s.getUint8(t)&255;t=t+1;const o=s.getUint8(t)&255;t=t+1;const c=`avc1.${Array.from([n,a,o],U=>U.toString(16).padStart(2,"0")).join("")}`,r=(s.getUint8(t)&3)-1;t=t+1;const g=s.getUint8(t)&31;t=t+1;const p=s.getUint16(t,!1);t=t+2;const h=new Uint8Array(s.buffer.slice(t,t+p));t=t+p;const d=s.getUint8(t)&31;t=t+1;const u=s.getUint16(t,!1);t=t+2;const f=new Uint8Array(s.buffer.slice(t,t+u));return t=t+u,{version:e,codec:c,profile:n,compatibility:a,level:o,lengthSizeMinusOne:r,numOfSequenceParameterSets:g,sequenceParameterSetLength:p,sps:h,numOfPictureParameterSets:d,pictureParameterSetLength:u,pps:f}},M=y=>{const t=new Uint8Array(4+y.length);return new DataView(t.buffer).setUint32(0,y.length,!1),t.set(y,4),t},C=y=>{let t=0;for(const n of y)t+=n.length;const s=new Uint8Array(t);let e=0;for(const n of y){const a=n;s.set(a,e),e+=a.length}return s},D=y=>{let t="unknown";switch(y){case 1:case 2:case 27:case 36:t="video";break;case 3:case 4:case 15:t="audio";break;case 6:t="subtitle";break;case 134:t="ad";break}return t};class x{pat;pmt;audioConfig;videoConfig;payloadMap=new Map;on={};constructor(){}parse=async t=>{let s=0;for(;!(s+188>t.byteLength);){if(t.getInt8(s)!=71){s++;continue}await this.parsePacket(t,s),s+=188}return s};parsePacket=async(t,s)=>{if(s+188>t.byteLength)throw new Error("Invalid TS packet");if(t.getUint8(s)!==71)throw new Error("Invalid TS packet");let e=s;const n=this.parseHeader(t,e);e+=4;const{transport_error_indicator:a,pid:o,payload_unit_start_indicator:l,adaptation_field_control:i}=n;if(a===1||o===void 0)return;let c=184;if(i===2||i===3){const r=t.getUint8(e);e+=1,this.parseAdaptationField(t,e),e+=r,c-=r}if(i===3&&(c-=1),i===1||i===3){const r=new Uint8Array(t.buffer.slice(e,e+c));if(o===0)return this.parsePAT(t,e);{const{programs:h=[]}=this.pat||{};if(h.find(u=>u.pmt_pid===o))return this.parsePMT(t,e)}const{streams:g=[]}=this.pmt||{},p=g.find(h=>h.elementary_pid===o);if(p){if(l===1){const h=this.payloadMap.get(o);if(h){switch(p.kind){case"audio":{const d=await this.parseAudio(h);this.on.chunk&&this.on.chunk(d)}break;case"video":{const d=await this.parseVideo(h);this.on.chunk&&this.on.chunk(d),await new Promise(u=>setTimeout(()=>u(!0),0))}break}this.payloadMap.delete(o)}}{this.payloadMap.has(o)||this.payloadMap.set(o,new Uint8Array);const h=this.payloadMap.get(o),d=new Uint8Array(h.byteLength+r.byteLength);d.set(h,0),d.set(r,h.byteLength),this.payloadMap.set(o,d)}}}};parseHeader=(t,s)=>{let e=s;const n=t.getUint8(e),a=t.getUint8(e+1),o=t.getUint8(e+2),l=t.getUint8(e+3),i=(a&128)>>7;if(i===1)return{sync_byte:n,transport_error_indicator:i};const c=(a&64)>>6,r=(a&32)>>5,g=(a&31)<<8|o,p=(l&192)>>6,h=l>>4&3,d=l&15;return{sync_byte:n,transport_error_indicator:i,payload_unit_start_indicator:c,transport_priority:r,pid:g,transport_scrambling_control:p,adaptation_field_control:h,continuity_counter:d}};parsePAT=(t,s)=>{let e=s,n;{const l=t.getUint8(e);e+=1;const i=t.getUint8(e);if(e+=1,i!==0)throw new Error("Invalid PAT table_id");const c=t.getUint16(e)&4095;e+=2;const r=t.getUint16(e);e+=2;const g=(t.getUint8(e)&62)>>1,p=t.getUint8(e)&1;e+=1;const h=t.getUint8(e);e+=1;const d=t.getUint8(e);e+=1,n={pointer_field:l,table_id:i,section_length:c,transport_stream_id:r,version_number:g,current_next_indicator:p,section_number:h,last_section_number:d}}const a=[];{const l=n.section_length-5-4,i=e+l;for(;e<i;){const c=t.getUint16(e),r=t.getUint16(e+2)&8191;e+=4,c!==0&&r>=32&&r<=8190&&a.push({program_number:c,pmt_pid:r})}}const o=t.getUint32(e);this.pat={header:n,programs:a,crc32:o},this.on.debug&&this.on.debug({pat:this.pat})};parsePMT=(t,s)=>{let e=s,n;{const l=t.getUint8(e);e+=1;const i=t.getUint8(e);if(e+=1,i!==2)throw new Error("Invalid PMT table_id");const c=t.getUint16(e)&4095;e+=2;const r=t.getUint16(e);e+=2;const g=(t.getUint8(e)&62)>>1,p=t.getUint8(e)&1;e+=1;const h=t.getUint8(e);e+=1;const d=t.getUint8(e);e+=1;const u=t.getUint16(e)&8191;e+=2;const f=t.getUint16(e)&4095;e+=2,n={pointer_field:l,table_id:i,section_length:c,transport_stream_id:r,version_number:g,current_next_indicator:p,section_number:h,last_section_number:d,pcr_pid:u,program_info_length:f}}const a=[];{const l=n.section_length-9-4,i=e+l;for(;e<i;){const c=t.getUint8(e),r=D(c),g=t.getUint16(e+1)&8191,p=t.getUint16(e+3)&4095;if(e+=5,g<32||g>8190){console.warn(`Invalid elementary_pid: 0x${g.toString(16)}`);continue}a.push({kind:r,stream_type:c,elementary_pid:g,es_info_length:p})}}const o=t.getUint32(e);this.pmt={header:n,streams:a,crc32:o},this.on.debug&&this.on.debug({pmt:this.pmt})};parseAdaptationField=(t,s)=>{let e=s,n,a,o,l;const i=t.getUint8(e),c=!!(i&128),r=!!(i&64),g=!!(i&32),p=!!(i&16),h=!!(i&8),d=!!(i&4),u=!!(i&2),f=!!(i&1);e+=1;const U=(_,b)=>{let m=BigInt(0);m|=BigInt(_.getUint16(b))<<25n,m|=BigInt(_.getUint16(b+1))<<17n,m|=BigInt(_.getUint16(b+2))<<9n,m|=BigInt(_.getUint16(b+3))<<1n,m|=BigInt(_.getUint16(b+4)>>7);const S=(_.getUint16(b+4)&1)<<8|_.getUint16(b+5);return m=m*300n+BigInt(S),m};if(p&&(n=U(t,e),e+=6),h&&(a=U(t,e),e+=6),d&&(o=t.getInt8(e),e+=1),u){const _=t.getUint8(e);e+=1,l=new Uint8Array(t.buffer,e,_),e+=_}return{discontinuity_indicator:c,random_access_indicator:r,elementary_stream_priority_indicator:g,pcr_flag:p,opcr_flag:h,splicing_point_flag:d,transport_private_data_flag:u,adaptation_field_extension_flag:f,pcr:n,opcr:a,splice_countdown:o,transport_private_data:l}};parseAudio=async t=>{const s=new DataView(t.buffer);let e=0,n,a;{const o=s.getUint8(e)===0&&s.getUint8(e+1)===0&&s.getUint8(e+2)===1;if(e+=3,!o)throw new Error("invalid ts audio payload.");const l=s.getUint8(e);e+=1;const i=s.getUint8(e)<<8|s.getUint8(e+1);e+=2;let c,r,g,p,h;{const f=s.getUint8(e);e+=1,c=f>>4&3,r=(f>>3&1)===1,g=(f>>2&1)===1,p=(f>>1&1)===1,h=(f&1)===1}let d,u;{const f=s.getUint8(e);e+=1;const U=f>>6,_=s.getUint8(e);e+=1,(U&2)===2&&(d=this.parsePtsDts(s,e)),(U&1)===1?u=this.parsePtsDts(s,e+5):u=d,e+=_}n={stream_id:l,pes_packet_length:i,scrambling_control:c,priority:r,data_alignment:g,copyright:p,original_copy:h,pts:d,dts:u}}a=t.slice(e);{if(!this.audioConfig&&s.getUint8(e)===255){const g=s.getUint8(e+2),p=s.getUint8(e+3);let h,d;d=g>>2&15,h=(g&1)<<2|p>>6;const u=`mp4a.40.${h}`,U=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350][d];this.audioConfig={kind:"audio",codec:u,sampleRate:U,numberOfChannels:h},this.on.config&&this.on.config(this.audioConfig)}const{dts:o=0,pts:l=0}=n,i=l-o,c=a.slice(7);return{kind:"audio",type:"key",dts:o,pts:l,cts:i,data:c}}};parseVideo=async t=>{const s=new DataView(t.buffer);let e=0,n,a;{const o=s.getUint8(e)===0&&s.getUint8(e+1)===0&&s.getUint8(e+2)===1;if(e+=3,!o)throw new Error("invalid ts video payload.");const l=s.getUint8(e);e+=1;const i=s.getUint8(e)<<8|s.getUint8(e+1);e+=2;let c,r,g,p,h;{const f=s.getUint8(e);e+=1,c=f>>4&3,r=(f>>3&1)===1,g=(f>>2&1)===1,p=(f>>1&1)===1,h=(f&1)===1}let d,u;{const f=s.getUint8(e);e+=1;const U=f>>6,_=s.getUint8(e);e+=1,(U&2)===2&&(d=this.parsePtsDts(s,e)),(U&1)===1?u=this.parsePtsDts(s,e+5):u=d,e+=_}n={stream_id:l,pes_packet_length:i,scrambling_control:c,priority:r,data_alignment:g,copyright:p,original_copy:h,pts:d,dts:u}}a=t.slice(e);{const o=this.getNalus(a);if(!this.videoConfig){let h,d;if(h=o.find(f=>f.type===7)?.nalu.slice(4),d=o.find(f=>f.type===8)?.nalu.slice(4),h&&d){const u=I(h,d),{codec:f}=T(u);this.videoConfig={kind:"video",codec:f,description:u,sps:h,pps:d},this.on.config&&this.on.config(this.videoConfig)}}const l=[];let i="delta";for(const h of o){const{type:d,nalu:u}=h;switch(d){case 6:case 9:l.push(u);break;case 1:i="delta",l.push(u);break;case 5:i="key",l.push(u);break}}const c=C(l),{dts:r=0,pts:g=0}=n,p=g-r;return{kind:"video",type:i,dts:r,pts:g,cts:p,data:c,nalus:l}}};parsePtsDts(t,s){const e=t.getUint8(s),n=t.getUint8(s+1),a=t.getUint8(s+2),o=t.getUint8(s+3),l=t.getUint8(s+4),i=(BigInt(e)&0b00001110n)<<29n|(BigInt(n)&0b11111111n)<<22n|(BigInt(a)&0b11111110n)<<14n|(BigInt(o)&0b11111111n)<<7n|(BigInt(l)&0b11111110n)>>1n;return Number(i)/90}getNalus=t=>{const s=[];let e=0;for(;!(e+4>t.byteLength);){if(t[e]!==0||t[e+1]!==0||t[e+2]!==1){e+=1;continue}e+=3;let n=e;const a=t[e]&31;for(e+=1;!(e+1>t.byteLength);){if(t[e]!==0||t[e+1]!==0||t[e+2]!==1){e+=1;continue}break}let o=e-n;if(t[e-1]===0&&(o-=1),o!==0){const l=t.slice(n,n+o),i=M(l);s.push({type:a,nalu:i})}}return s}}const k=(y,t)=>y.getUint8(t)<<16|y.getUint8(t+1)<<8|y.getUint8(t+2);class L{audioConfig;videoConfig;header;textDecoder=new TextDecoder("utf-8");on={};constructor(){}parse=async t=>{let s=0;for(this.header||(this.parseHeader(t,s),s+=9);this.isSurplusTag(t,s)!==!1;){const n=this.parseTagHeader(t,s+4),{tagType:a,dataSize:o,timestamp:l}=n;if(a){const i=this.parseTagBody(a,t,s+4+11,o);switch(a){case"script":this.on.info&&this.on.info(i);break;case"audio":{const{accPacketType:c}=i;if(c===0){const{codec:r,sampleRate:g,channelConfiguration:p}=i;this.audioConfig={kind:"audio",codec:r,sampleRate:g,numberOfChannels:p},this.on.config&&this.on.config(this.audioConfig)}else{const{cts:r,data:g}=i,p="key",h=r===void 0?void 0:r+l;this.on.chunk&&this.on.chunk({kind:"audio",type:p,dts:l,pts:h,cts:r,data:g})}}break;case"video":{const{avcPacketType:c}=i;if(c===0){const{codec:r,sps:g,pps:p,data:h}=i;this.videoConfig={kind:"video",codec:r,description:h,sps:g,pps:p},this.on.config&&this.on.config(this.videoConfig)}else{const{frameType:r,cts:g,data:p,nalus:h}=i,d=r===1?"key":"delta",u=g===void 0?void 0:g+l;this.on.chunk&&this.on.chunk({kind:"video",type:d,dts:l,pts:u,cts:g,data:p,nalus:h})}}break}s=s+4+11+o}await new Promise(i=>setTimeout(()=>i(!0),8))}return s};parseHeader=(t,s)=>{let e,n,a,o;e=t.getUint8(s)<<16|t.getUint8(s+1)<<8|t.getUint8(s+2),n=t.getUint8(3);{const i=t.getUint8(0).toString(2).padStart(5,"0").split(""),[,,c,,r]=i;a={audio:r==="1",video:c==="1"}}o=t.getUint32(5),this.header={signature:e,version:n,flags:a,dataOffset:o}};isSurplusTag=(t,s)=>{let e=!0;const n=t.byteLength;if(s+4>n)e=!1;else if(s+4+11>n)e=!1;else{const a=k(t,s+4+1);s+4+11+a>n&&(e=!1)}return e};parseTagHeader=(t,s)=>{let e,n,a,o,l;{const i=t.getUint8(s);let c;switch(i){case 18:c="script";break;case 8:c="audio";break;case 9:c="video";break}e=c}return n=k(t,s+1),a=k(t,s+4),o=t.getUint8(s+7),l=k(t,s+8),{tagType:e,dataSize:n,timestamp:a,timestampExtended:o,streamID:l}};parseTagBody=(t,s,e,n)=>{let a;switch(t){case"script":a=this.parseMetaData(s,e);break;case"audio":a=this.parseAudio(s,e,n);break;case"video":a=this.parseVideo(s,e,n);break}return a};parseMetaData=(t,s)=>{let e=s;{if(t.getUint8(e)!==2)throw new Error("Invalid AMF type for onMetaData (expected 0x02)");e=e+1}const n=t.getUint16(e,!1);e=e+2;{const l=new Int8Array(t.buffer.slice(e,e+n));if((this.textDecoder?.decode(l)||"")!=="onMetaData")throw new Error("Expected \'onMetaData\' string");e=e+n}const a=this.getAmfType(t,e);return e=e+1,this.getAMFValue(t,e,a).value};parseAudio=(t,s,e)=>{let n=s;const a=t.getUint8(n),o=a>>4&15,l=a>>2&3,i=a>>1&1,c=a&1;n=n+1;const r=t.getUint8(n);n=n+1;const g=e,p=new Uint8Array(t.buffer.slice(n,n+g));if(o===10&&r===0){const h=t.getUint8(n),d=t.getUint8(n+1),u=h>>3&31,f=(h&7)<<1|d>>7,U=d>>3&15,_=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350],b=`mp4a.40.${u}`,m=_[f];return{soundFormat:o,soundRate:l,soundSize:i,soundType:c,accPacketType:r,data:p,samplingFrequencyIndex:f,channelConfiguration:U,codec:b,sampleRate:m}}return{soundFormat:o,soundRate:l,soundSize:i,soundType:c,accPacketType:r,data:p}};parseVideo=(t,s,e)=>{let n=s;const a=t.getUint8(n),o=a>>4&15,l=a&15;n=n+1;const i=t.getUint8(n);n=n+1;const c=k(t,n);n=n+3;const r=e-5,g=new Uint8Array(t.buffer.slice(n,n+r));switch(l){case 7:if(i===0){const p=T(g);return{frameType:o,codecID:l,avcPacketType:i,cts:c,data:g,...p}}else if(i===1){const p=[],h=n+e-5;for(;!(n+4>h);){const d=t.getUint32(n,!1),u=new Uint8Array(t.buffer.slice(n,n+4+d));n+=4+d,p.push(u)}return{frameType:o,codecID:l,avcPacketType:i,cts:c,data:g,nalus:p}}break;default:throw new Error("Unsupported codecID")}return{frameType:o,codecID:l,avcPacketType:i,cts:c,data:g}};getAmfType=(t,s)=>t.getUint8(s);getAMFName=(t,s,e)=>{const n=new Uint8Array(t.buffer.slice(s,s+e));return this.textDecoder?.decode(n)||""};getAMFValue=(t,s,e)=>{let n=s,a,o=0;switch(e){case 0:a=t.getFloat64(n,!1),o=8;break;case 1:a=!!t.getUint8(n),o=1;break;case 2:{a="";const i=t.getUint16(n,!1);n=n+2;const c=new Int8Array(t.buffer,n,i).filter(g=>g!==0);a=(this.textDecoder?.decode(c)||"").trim(),o=2+i}break;case 3:for(a={};n<t.byteLength;){const i=t.getUint16(n,!1);if(i===0)break;n=n+2;const c=this.getAMFName(t,n,i);n=n+i;const r=this.getAmfType(t,n);if(r===6)break;n=n+1;const g=this.getAMFValue(t,n,r);n=n+g.length,a[c]=g.value,o=2+i+1+g.length}break;case 8:{a={};const i=t.getUint32(n,!1);n=n+4;for(let c=0;c<i;c++){const r=t.getUint16(n,!1);n=n+2;const g=this.getAMFName(t,n,r);n=n+r;const p=this.getAmfType(t,n);n=n+1;const h=this.getAMFValue(t,n,p);n=n+h.length,a[g]=h.value,o=2+r+1+h.length}}break;case 10:{a=[];const i=t.getUint32(n,!1);n=n+4;for(let c=0;c<i;c++){const r=this.getAmfType(t,n);n=n+1;const g=this.getAMFValue(t,n,r);n=n+g.length,a.push(g.value),o=1+g.length}}break}return{amfType:e,length:o,value:a}}}class O{pattern;cacher=new P;isParseing=!1;offset=0;on={};parser;constructor(){}init=t=>{switch(this.destroy(),this.pattern=t,this.pattern){case"flv":this.parser=new L;break;case"hls":this.parser=new x;break;default:throw new Error("is error pattern.")}this.parser.on.debug=s=>this.on.debug&&this.on.debug(s),this.parser.on.info=s=>this.on.info&&this.on.info(s),this.parser.on.config=s=>this.on.config&&this.on.config(s),this.parser.on.chunk=s=>{this.cacher.pushChunk(s),this.on.chunk&&this.on.chunk(s)}};push=t=>{this.cacher.push(t),this.isParseing===!1&&this.parse()};destroy=()=>{this.cacher.destroy(),this.isParseing=!1,this.offset=0};parse=async()=>{try{if(this.isParseing=!0,!this.pattern)throw new Error("You need to set the pattern.");if(!this.parser)throw new Error("You need to init parser.");for(;;){const t=this.cacher.next(this.offset);if(this.offset=0,!t)break;this.offset=await this.parser.parse(t)}this.isParseing=!1}catch{this.destroy()}}}const A=new O;A.on.debug=y=>postMessage({action:"onDebug",data:y}),A.on.info=y=>postMessage({action:"onInfo",data:y}),A.on.config=y=>postMessage({action:"onConfig",data:y}),A.on.chunk=y=>postMessage({action:"onChunk",data:y}),onmessage=y=>{const{action:t,data:s}=y.data,e=A[t];e&&e(s)}})();\n', T = typeof self < "u" && self.Blob && new Blob(["(self.URL || self.webkitURL).revokeObjectURL(self.location.href);", D], { type: "text/javascript;charset=utf-8" });
|
|
9
9
|
function L(h) {
|
|
@@ -27,11 +27,11 @@ function L(h) {
|
|
|
27
27
|
}
|
|
28
28
|
class N {
|
|
29
29
|
constructor() {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
30
|
+
g(this, "worker", new L());
|
|
31
|
+
g(this, "on", {});
|
|
32
|
+
g(this, "init", (o) => this.worker.postMessage({ action: "init", data: o }));
|
|
33
|
+
g(this, "push", (o) => this.worker.postMessage({ action: "push", data: o }));
|
|
34
|
+
g(this, "destroy", () => {
|
|
35
35
|
this.worker.postMessage({ action: "destroy", data: {} }), this.worker.terminate();
|
|
36
36
|
});
|
|
37
37
|
this.worker.onmessage = (o) => {
|
|
@@ -76,11 +76,11 @@ function F(h) {
|
|
|
76
76
|
}
|
|
77
77
|
class B {
|
|
78
78
|
constructor() {
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
79
|
+
g(this, "worker", new F());
|
|
80
|
+
g(this, "on", { audio: {}, video: {} });
|
|
81
|
+
g(this, "init", (o) => this.worker.postMessage({ action: "init", data: o }));
|
|
82
|
+
g(this, "setFrameTrack", (o) => this.worker.postMessage({ action: "setFrameTrack", data: o }));
|
|
83
|
+
g(this, "audio", {
|
|
84
84
|
init: (o) => this.worker.postMessage({ type: "audio", action: "init", data: o }),
|
|
85
85
|
push: (o) => this.worker.postMessage({ type: "audio", action: "push", data: o }),
|
|
86
86
|
flush: () => this.worker.postMessage({ type: "audio", action: "flush" }),
|
|
@@ -88,7 +88,7 @@ class B {
|
|
|
88
88
|
this.worker.postMessage({ type: "audio", action: "destroy" });
|
|
89
89
|
}
|
|
90
90
|
});
|
|
91
|
-
|
|
91
|
+
g(this, "video", {
|
|
92
92
|
init: (o) => this.worker.postMessage({ type: "video", action: "init", data: o }),
|
|
93
93
|
push: (o) => this.worker.postMessage({ type: "video", action: "push", data: o }),
|
|
94
94
|
flush: () => this.worker.postMessage({ type: "video", action: "flush" }),
|
|
@@ -96,7 +96,7 @@ class B {
|
|
|
96
96
|
this.worker.postMessage({ type: "video", action: "destroy", data: {} });
|
|
97
97
|
}
|
|
98
98
|
});
|
|
99
|
-
|
|
99
|
+
g(this, "destroy", () => {
|
|
100
100
|
this.worker.postMessage({ action: "destroy" }), this.worker.terminate();
|
|
101
101
|
});
|
|
102
102
|
this.worker.onmessage = (o) => {
|
|
@@ -205,16 +205,16 @@ const V = async (h, o) => {
|
|
|
205
205
|
};
|
|
206
206
|
class W {
|
|
207
207
|
constructor() {
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
208
|
+
g(this, "prAudioStream");
|
|
209
|
+
g(this, "audioContext");
|
|
210
|
+
g(this, "destination");
|
|
211
|
+
g(this, "stream", new MediaStream());
|
|
212
|
+
g(this, "nextStartTime", 0);
|
|
213
|
+
g(this, "pendingSources", []);
|
|
214
|
+
g(this, "init", (o) => {
|
|
215
215
|
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 O(this.stream, this.audioContext), this.nextStartTime = 0, this.pendingSources = [];
|
|
216
216
|
});
|
|
217
|
-
|
|
217
|
+
g(this, "getStream", () => {
|
|
218
218
|
var o;
|
|
219
219
|
return (o = this.prAudioStream) == null ? void 0 : o.getStream();
|
|
220
220
|
});
|
|
@@ -265,12 +265,12 @@ function j(h) {
|
|
|
265
265
|
}
|
|
266
266
|
class z {
|
|
267
267
|
constructor() {
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
268
|
+
g(this, "worker", new j());
|
|
269
|
+
g(this, "init", ({ writable: o }) => this.worker.postMessage({ action: "init", data: { writable: o } }, [o]));
|
|
270
|
+
g(this, "push", (o) => this.worker.postMessage({ action: "push", data: o }));
|
|
271
|
+
g(this, "setCut", async (o) => this.worker.postMessage({ action: "setCut", data: o }));
|
|
272
|
+
g(this, "setPause", (o) => this.worker.postMessage({ action: "setPause", data: o }));
|
|
273
|
+
g(this, "destroy", () => {
|
|
274
274
|
this.worker.postMessage({ action: "destroy", data: {} }), this.worker.terminate();
|
|
275
275
|
});
|
|
276
276
|
}
|
|
@@ -290,8 +290,8 @@ const q = (h) => {
|
|
|
290
290
|
};
|
|
291
291
|
class $ {
|
|
292
292
|
constructor() {
|
|
293
|
-
|
|
294
|
-
|
|
293
|
+
g(this, "resolvesMap", /* @__PURE__ */ new Map());
|
|
294
|
+
g(this, "index", 0);
|
|
295
295
|
/**
|
|
296
296
|
*
|
|
297
297
|
* @param eventKey 唯一key
|
|
@@ -299,7 +299,7 @@ class $ {
|
|
|
299
299
|
* @param timeout 超时时间 ms
|
|
300
300
|
* @returns
|
|
301
301
|
*/
|
|
302
|
-
|
|
302
|
+
g(this, "add", (o, a = () => !1, u = 0) => new Promise((r) => {
|
|
303
303
|
var t, e;
|
|
304
304
|
if (a()) return r(!0);
|
|
305
305
|
this.resolvesMap.has(o) || this.resolvesMap.set(o, /* @__PURE__ */ new Map()), this.index++;
|
|
@@ -313,7 +313,7 @@ class $ {
|
|
|
313
313
|
}, u);
|
|
314
314
|
(e = this.resolvesMap.get(o)) == null || e.set(n, { resolve: r, timer: i });
|
|
315
315
|
}));
|
|
316
|
-
|
|
316
|
+
g(this, "emit", async (o) => {
|
|
317
317
|
const a = this.resolvesMap.get(o);
|
|
318
318
|
if (!a) return;
|
|
319
319
|
const u = [...a.keys()];
|
|
@@ -351,7 +351,7 @@ class C {
|
|
|
351
351
|
* @param input string | URL | Request
|
|
352
352
|
* @param init RequestInit
|
|
353
353
|
*/
|
|
354
|
-
|
|
354
|
+
g(this, "check", (o, a) => new Promise(async (u, r) => {
|
|
355
355
|
var i;
|
|
356
356
|
this.stop(), H(this, U, new AbortController());
|
|
357
357
|
const n = window.setTimeout(() => {
|
|
@@ -371,7 +371,7 @@ class C {
|
|
|
371
371
|
* @param input string | URL | Request
|
|
372
372
|
* @param init RequestInit
|
|
373
373
|
*/
|
|
374
|
-
|
|
374
|
+
g(this, "request", async (o, a) => new Promise(async (u, r) => {
|
|
375
375
|
var n;
|
|
376
376
|
try {
|
|
377
377
|
I(this, R).check && await this.check(o, a), H(this, U, new AbortController());
|
|
@@ -384,7 +384,7 @@ class C {
|
|
|
384
384
|
/**
|
|
385
385
|
* stop
|
|
386
386
|
*/
|
|
387
|
-
|
|
387
|
+
g(this, "stop", () => {
|
|
388
388
|
var o;
|
|
389
389
|
((o = I(this, U)) == null ? void 0 : o.signal.aborted) === !1 && I(this, U).abort("Actively stop.");
|
|
390
390
|
});
|
|
@@ -394,33 +394,33 @@ class C {
|
|
|
394
394
|
R = new WeakMap(), U = new WeakMap();
|
|
395
395
|
class et {
|
|
396
396
|
constructor(o = {}) {
|
|
397
|
-
|
|
397
|
+
g(this, "option", {
|
|
398
398
|
debug: !1,
|
|
399
399
|
frameTrack: !1
|
|
400
400
|
});
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
401
|
+
g(this, "prFetch", new C());
|
|
402
|
+
g(this, "prResolves", new $());
|
|
403
|
+
g(this, "url", "");
|
|
404
|
+
g(this, "demuxerWorker");
|
|
405
|
+
g(this, "decoderWorker");
|
|
406
|
+
g(this, "audioPlayer");
|
|
407
|
+
g(this, "renderWorker");
|
|
408
|
+
g(this, "stream");
|
|
409
|
+
g(this, "on", { demuxer: {}, decoder: {} });
|
|
410
|
+
g(this, "cutRenders", /* @__PURE__ */ new Map());
|
|
411
411
|
// @ts-ignore
|
|
412
|
-
|
|
412
|
+
g(this, "trackGenerator");
|
|
413
413
|
/**
|
|
414
414
|
* 初始化
|
|
415
415
|
*/
|
|
416
|
-
|
|
416
|
+
g(this, "init", () => {
|
|
417
417
|
this.initDecoder(), this.initRender(), this.audioPlayer = new W(), this.audioPlayer.init();
|
|
418
418
|
});
|
|
419
419
|
/**
|
|
420
420
|
* 开始播放
|
|
421
421
|
* @param url : string
|
|
422
422
|
*/
|
|
423
|
-
|
|
423
|
+
g(this, "start", async (o) => {
|
|
424
424
|
this.stop(), this.url = o, this.init();
|
|
425
425
|
const a = q(o);
|
|
426
426
|
if (a === "unknown") throw new Error("This address cannot be parsed.");
|
|
@@ -436,7 +436,7 @@ class et {
|
|
|
436
436
|
/**
|
|
437
437
|
* 停止
|
|
438
438
|
*/
|
|
439
|
-
|
|
439
|
+
g(this, "stop", async () => {
|
|
440
440
|
var a, u, r, n, i;
|
|
441
441
|
try {
|
|
442
442
|
clearInterval(this.hls.getSegmentsTimer), this.prFetch.stop();
|
|
@@ -452,12 +452,12 @@ class et {
|
|
|
452
452
|
/**
|
|
453
453
|
* 获取媒体流
|
|
454
454
|
*/
|
|
455
|
-
|
|
455
|
+
g(this, "getStream", () => this.stream);
|
|
456
456
|
/**
|
|
457
457
|
* 设置暂停
|
|
458
458
|
* @param pause: boolean
|
|
459
459
|
*/
|
|
460
|
-
|
|
460
|
+
g(this, "setPause", (o) => {
|
|
461
461
|
var a;
|
|
462
462
|
(a = this.renderWorker) == null || a.setPause(o);
|
|
463
463
|
});
|
|
@@ -465,7 +465,7 @@ class et {
|
|
|
465
465
|
* 是否静音 默认为true
|
|
466
466
|
* @param state?: boolean
|
|
467
467
|
*/
|
|
468
|
-
|
|
468
|
+
g(this, "setMute", (o) => {
|
|
469
469
|
var a, u;
|
|
470
470
|
return (u = (a = this.audioPlayer) == null ? void 0 : a.prAudioStream) == null ? void 0 : u.setMute(o);
|
|
471
471
|
});
|
|
@@ -473,14 +473,14 @@ class et {
|
|
|
473
473
|
* 是否开启追帧
|
|
474
474
|
* @param frameTrack?: boolean
|
|
475
475
|
*/
|
|
476
|
-
|
|
476
|
+
g(this, "setFrameTrack", (o) => {
|
|
477
477
|
var a;
|
|
478
478
|
(a = this.decoderWorker) == null || a.setFrameTrack(o);
|
|
479
479
|
});
|
|
480
480
|
/**
|
|
481
481
|
* 是否已准备好
|
|
482
482
|
*/
|
|
483
|
-
|
|
483
|
+
g(this, "isReady", () => {
|
|
484
484
|
const o = () => {
|
|
485
485
|
var a;
|
|
486
486
|
return ((a = this.stream) == null ? void 0 : a.active) === !0;
|
|
@@ -490,7 +490,7 @@ class et {
|
|
|
490
490
|
/**
|
|
491
491
|
* 初始化解复器
|
|
492
492
|
*/
|
|
493
|
-
|
|
493
|
+
g(this, "initDemuxer", (o) => {
|
|
494
494
|
this.demuxerWorker = new N(), this.demuxerWorker.init(o), this.demuxerWorker.on.debug = (a) => {
|
|
495
495
|
this.option.debug && console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", "------->pr-player: debug", a);
|
|
496
496
|
}, this.demuxerWorker.on.info = (a) => {
|
|
@@ -543,7 +543,7 @@ class et {
|
|
|
543
543
|
/**
|
|
544
544
|
* 初始化解码器
|
|
545
545
|
*/
|
|
546
|
-
|
|
546
|
+
g(this, "initDecoder", () => {
|
|
547
547
|
this.decoderWorker = new B(), this.decoderWorker.on.audio.decode = (o) => {
|
|
548
548
|
var a;
|
|
549
549
|
(a = this.audioPlayer) == null || a.push(o), this.on.decoder.audio && this.on.decoder.audio(o);
|
|
@@ -563,11 +563,11 @@ class et {
|
|
|
563
563
|
/**
|
|
564
564
|
* 初始化渲染器
|
|
565
565
|
*/
|
|
566
|
-
|
|
566
|
+
g(this, "initRender", () => {
|
|
567
567
|
const { worker: o, stream: a } = A();
|
|
568
568
|
this.renderWorker = o, this.stream = a, this.renderWorker.setPause(!1);
|
|
569
569
|
});
|
|
570
|
-
|
|
570
|
+
g(this, "cut", {
|
|
571
571
|
/**
|
|
572
572
|
* 创建剪切
|
|
573
573
|
*/
|
|
@@ -598,7 +598,7 @@ class et {
|
|
|
598
598
|
(a = this.cutRenders.get(o)) == null || a.destroy(), this.cutRenders.delete(o);
|
|
599
599
|
}
|
|
600
600
|
});
|
|
601
|
-
|
|
601
|
+
g(this, "flv", {
|
|
602
602
|
start: async () => {
|
|
603
603
|
var o, a;
|
|
604
604
|
try {
|
|
@@ -616,7 +616,7 @@ class et {
|
|
|
616
616
|
}
|
|
617
617
|
}
|
|
618
618
|
});
|
|
619
|
-
|
|
619
|
+
g(this, "hls", {
|
|
620
620
|
isLive: !1,
|
|
621
621
|
urls: [],
|
|
622
622
|
url: "",
|
|
@@ -896,8 +896,8 @@ function requireFloat() {
|
|
|
896
896
|
}
|
|
897
897
|
n.writeDoubleLE = i.bind(null, o, 0, 4), n.writeDoubleBE = i.bind(null, a, 4, 0);
|
|
898
898
|
function t(e, s, l, c, d) {
|
|
899
|
-
var p = e(c, d + s), f = e(c, d + l), w = (f >> 31) * 2 + 1, b = f >>> 20 & 2047,
|
|
900
|
-
return b === 2047 ?
|
|
899
|
+
var p = e(c, d + s), f = e(c, d + l), w = (f >> 31) * 2 + 1, b = f >>> 20 & 2047, m = 4294967296 * (f & 1048575) + p;
|
|
900
|
+
return b === 2047 ? m ? NaN : w * (1 / 0) : b === 0 ? w * 5e-324 * m : w * Math.pow(2, b - 1075) * (m + 4503599627370496);
|
|
901
901
|
}
|
|
902
902
|
n.readDoubleLE = t.bind(null, u, 0, 4), n.readDoubleBE = t.bind(null, r, 4, 0);
|
|
903
903
|
}(), n;
|
|
@@ -1170,8 +1170,8 @@ function requireWriter() {
|
|
|
1170
1170
|
if (hasRequiredWriter) return writer;
|
|
1171
1171
|
hasRequiredWriter = 1, writer = e;
|
|
1172
1172
|
var h = requireMinimal$1(), o, a = h.LongBits, u = h.base64, r = h.utf8;
|
|
1173
|
-
function n(b,
|
|
1174
|
-
this.fn = b, this.len =
|
|
1173
|
+
function n(b, m, k) {
|
|
1174
|
+
this.fn = b, this.len = m, this.next = void 0, this.val = k;
|
|
1175
1175
|
}
|
|
1176
1176
|
function i() {
|
|
1177
1177
|
}
|
|
@@ -1190,89 +1190,89 @@ function requireWriter() {
|
|
|
1190
1190
|
return new e();
|
|
1191
1191
|
};
|
|
1192
1192
|
};
|
|
1193
|
-
e.create = s(), e.alloc = function(
|
|
1194
|
-
return new h.Array(
|
|
1195
|
-
}, h.Array !== Array && (e.alloc = h.pool(e.alloc, h.Array.prototype.subarray)), e.prototype._push = function(
|
|
1196
|
-
return this.tail = this.tail.next = new n(
|
|
1193
|
+
e.create = s(), e.alloc = function(m) {
|
|
1194
|
+
return new h.Array(m);
|
|
1195
|
+
}, h.Array !== Array && (e.alloc = h.pool(e.alloc, h.Array.prototype.subarray)), e.prototype._push = function(m, k, _) {
|
|
1196
|
+
return this.tail = this.tail.next = new n(m, k, _), this.len += k, this;
|
|
1197
1197
|
};
|
|
1198
|
-
function l(b,
|
|
1199
|
-
|
|
1198
|
+
function l(b, m, k) {
|
|
1199
|
+
m[k] = b & 255;
|
|
1200
1200
|
}
|
|
1201
|
-
function c(b,
|
|
1201
|
+
function c(b, m, k) {
|
|
1202
1202
|
for (; b > 127; )
|
|
1203
|
-
|
|
1204
|
-
|
|
1203
|
+
m[k++] = b & 127 | 128, b >>>= 7;
|
|
1204
|
+
m[k] = b;
|
|
1205
1205
|
}
|
|
1206
|
-
function d(b,
|
|
1207
|
-
this.len = b, this.next = void 0, this.val =
|
|
1206
|
+
function d(b, m) {
|
|
1207
|
+
this.len = b, this.next = void 0, this.val = m;
|
|
1208
1208
|
}
|
|
1209
|
-
d.prototype = Object.create(n.prototype), d.prototype.fn = c, e.prototype.uint32 = function(
|
|
1209
|
+
d.prototype = Object.create(n.prototype), d.prototype.fn = c, e.prototype.uint32 = function(m) {
|
|
1210
1210
|
return this.len += (this.tail = this.tail.next = new d(
|
|
1211
|
-
(
|
|
1212
|
-
|
|
1211
|
+
(m = m >>> 0) < 128 ? 1 : m < 16384 ? 2 : m < 2097152 ? 3 : m < 268435456 ? 4 : 5,
|
|
1212
|
+
m
|
|
1213
1213
|
)).len, this;
|
|
1214
|
-
}, e.prototype.int32 = function(
|
|
1215
|
-
return
|
|
1216
|
-
}, e.prototype.sint32 = function(
|
|
1217
|
-
return this.uint32((
|
|
1214
|
+
}, e.prototype.int32 = function(m) {
|
|
1215
|
+
return m < 0 ? this._push(p, 10, a.fromNumber(m)) : this.uint32(m);
|
|
1216
|
+
}, e.prototype.sint32 = function(m) {
|
|
1217
|
+
return this.uint32((m << 1 ^ m >> 31) >>> 0);
|
|
1218
1218
|
};
|
|
1219
|
-
function p(b,
|
|
1219
|
+
function p(b, m, k) {
|
|
1220
1220
|
for (; b.hi; )
|
|
1221
|
-
|
|
1221
|
+
m[k++] = b.lo & 127 | 128, b.lo = (b.lo >>> 7 | b.hi << 25) >>> 0, b.hi >>>= 7;
|
|
1222
1222
|
for (; b.lo > 127; )
|
|
1223
|
-
|
|
1224
|
-
|
|
1223
|
+
m[k++] = b.lo & 127 | 128, b.lo = b.lo >>> 7;
|
|
1224
|
+
m[k++] = b.lo;
|
|
1225
1225
|
}
|
|
1226
|
-
e.prototype.uint64 = function(
|
|
1227
|
-
var k = a.from(
|
|
1226
|
+
e.prototype.uint64 = function(m) {
|
|
1227
|
+
var k = a.from(m);
|
|
1228
1228
|
return this._push(p, k.length(), k);
|
|
1229
|
-
}, e.prototype.int64 = e.prototype.uint64, e.prototype.sint64 = function(
|
|
1230
|
-
var k = a.from(
|
|
1229
|
+
}, e.prototype.int64 = e.prototype.uint64, e.prototype.sint64 = function(m) {
|
|
1230
|
+
var k = a.from(m).zzEncode();
|
|
1231
1231
|
return this._push(p, k.length(), k);
|
|
1232
|
-
}, e.prototype.bool = function(
|
|
1233
|
-
return this._push(l, 1,
|
|
1232
|
+
}, e.prototype.bool = function(m) {
|
|
1233
|
+
return this._push(l, 1, m ? 1 : 0);
|
|
1234
1234
|
};
|
|
1235
|
-
function f(b,
|
|
1236
|
-
|
|
1235
|
+
function f(b, m, k) {
|
|
1236
|
+
m[k] = b & 255, m[k + 1] = b >>> 8 & 255, m[k + 2] = b >>> 16 & 255, m[k + 3] = b >>> 24;
|
|
1237
1237
|
}
|
|
1238
|
-
e.prototype.fixed32 = function(
|
|
1239
|
-
return this._push(f, 4,
|
|
1240
|
-
}, e.prototype.sfixed32 = e.prototype.fixed32, e.prototype.fixed64 = function(
|
|
1241
|
-
var k = a.from(
|
|
1238
|
+
e.prototype.fixed32 = function(m) {
|
|
1239
|
+
return this._push(f, 4, m >>> 0);
|
|
1240
|
+
}, e.prototype.sfixed32 = e.prototype.fixed32, e.prototype.fixed64 = function(m) {
|
|
1241
|
+
var k = a.from(m);
|
|
1242
1242
|
return this._push(f, 4, k.lo)._push(f, 4, k.hi);
|
|
1243
|
-
}, e.prototype.sfixed64 = e.prototype.fixed64, e.prototype.float = function(
|
|
1244
|
-
return this._push(h.float.writeFloatLE, 4,
|
|
1245
|
-
}, e.prototype.double = function(
|
|
1246
|
-
return this._push(h.float.writeDoubleLE, 8,
|
|
1243
|
+
}, e.prototype.sfixed64 = e.prototype.fixed64, e.prototype.float = function(m) {
|
|
1244
|
+
return this._push(h.float.writeFloatLE, 4, m);
|
|
1245
|
+
}, e.prototype.double = function(m) {
|
|
1246
|
+
return this._push(h.float.writeDoubleLE, 8, m);
|
|
1247
1247
|
};
|
|
1248
|
-
var w = h.Array.prototype.set ? function(
|
|
1249
|
-
k.set(
|
|
1250
|
-
} : function(
|
|
1251
|
-
for (var K = 0; K <
|
|
1252
|
-
k[_ + K] =
|
|
1248
|
+
var w = h.Array.prototype.set ? function(m, k, _) {
|
|
1249
|
+
k.set(m, _);
|
|
1250
|
+
} : function(m, k, _) {
|
|
1251
|
+
for (var K = 0; K < m.length; ++K)
|
|
1252
|
+
k[_ + K] = m[K];
|
|
1253
1253
|
};
|
|
1254
|
-
return e.prototype.bytes = function(
|
|
1255
|
-
var k =
|
|
1254
|
+
return e.prototype.bytes = function(m) {
|
|
1255
|
+
var k = m.length >>> 0;
|
|
1256
1256
|
if (!k)
|
|
1257
1257
|
return this._push(l, 1, 0);
|
|
1258
|
-
if (h.isString(
|
|
1259
|
-
var _ = e.alloc(k = u.length(
|
|
1260
|
-
u.decode(
|
|
1258
|
+
if (h.isString(m)) {
|
|
1259
|
+
var _ = e.alloc(k = u.length(m));
|
|
1260
|
+
u.decode(m, _, 0), m = _;
|
|
1261
1261
|
}
|
|
1262
|
-
return this.uint32(k)._push(w, k,
|
|
1263
|
-
}, e.prototype.string = function(
|
|
1264
|
-
var k = r.length(
|
|
1265
|
-
return k ? this.uint32(k)._push(r.write, k,
|
|
1262
|
+
return this.uint32(k)._push(w, k, m);
|
|
1263
|
+
}, e.prototype.string = function(m) {
|
|
1264
|
+
var k = r.length(m);
|
|
1265
|
+
return k ? this.uint32(k)._push(r.write, k, m) : this._push(l, 1, 0);
|
|
1266
1266
|
}, e.prototype.fork = function() {
|
|
1267
1267
|
return this.states = new t(this), this.head = this.tail = new n(i, 0, 0), this.len = 0, this;
|
|
1268
1268
|
}, e.prototype.reset = function() {
|
|
1269
1269
|
return this.states ? (this.head = this.states.head, this.tail = this.states.tail, this.len = this.states.len, this.states = this.states.next) : (this.head = this.tail = new n(i, 0, 0), this.len = 0), this;
|
|
1270
1270
|
}, e.prototype.ldelim = function() {
|
|
1271
|
-
var
|
|
1272
|
-
return this.reset().uint32(_), _ && (this.tail.next =
|
|
1271
|
+
var m = this.head, k = this.tail, _ = this.len;
|
|
1272
|
+
return this.reset().uint32(_), _ && (this.tail.next = m.next, this.tail = k, this.len += _), this;
|
|
1273
1273
|
}, e.prototype.finish = function() {
|
|
1274
|
-
for (var
|
|
1275
|
-
|
|
1274
|
+
for (var m = this.head.next, k = this.constructor.alloc(this.len), _ = 0; m; )
|
|
1275
|
+
m.fn(m.val, k, _), _ += m.len, m = m.next;
|
|
1276
1276
|
return k;
|
|
1277
1277
|
}, e._configure = function(b) {
|
|
1278
1278
|
o = b, e.create = s(), o._configure();
|
|
@@ -2340,21 +2340,21 @@ const $Reader = minimalExports.Reader, $Writer = minimalExports.Writer, $util =
|
|
|
2340
2340
|
});
|
|
2341
2341
|
class RoomUser {
|
|
2342
2342
|
constructor() {
|
|
2343
|
-
|
|
2344
|
-
|
|
2343
|
+
g(this, "userId", "");
|
|
2344
|
+
g(this, "mc_audio");
|
|
2345
2345
|
// 麦克风
|
|
2346
|
-
|
|
2346
|
+
g(this, "mc_video");
|
|
2347
2347
|
// 摄像头
|
|
2348
|
-
|
|
2348
|
+
g(this, "ss_audio");
|
|
2349
2349
|
// 屏幕共享视频
|
|
2350
|
-
|
|
2350
|
+
g(this, "ss_video");
|
|
2351
2351
|
// 屏幕共享音频
|
|
2352
|
-
|
|
2353
|
-
|
|
2352
|
+
g(this, "updateTime", 0);
|
|
2353
|
+
g(this, "getUpdateTimeKey", () => {
|
|
2354
2354
|
const o = [];
|
|
2355
2355
|
return this.mc_audio && o.push(this.mc_audio.updateTime), this.mc_video && o.push(this.mc_video.updateTime), this.ss_audio && o.push(this.ss_audio.updateTime), this.ss_video && o.push(this.ss_video.updateTime), o.join("_");
|
|
2356
2356
|
});
|
|
2357
|
-
|
|
2357
|
+
g(this, "init", (o) => {
|
|
2358
2358
|
var t, e, s, l;
|
|
2359
2359
|
const { id: a, audios: u = [], videos: r = [] } = o;
|
|
2360
2360
|
this.userId = a;
|
|
@@ -2378,18 +2378,18 @@ class RoomUser {
|
|
|
2378
2378
|
}
|
|
2379
2379
|
}
|
|
2380
2380
|
for (const c of r) {
|
|
2381
|
-
const { type: d = 0, isEnable: p, isMute: f, updateTime: w, width: b, height:
|
|
2381
|
+
const { type: d = 0, isEnable: p, isMute: f, updateTime: w, width: b, height: m, x: k, y: _ } = c;
|
|
2382
2382
|
switch (d) {
|
|
2383
2383
|
case 0:
|
|
2384
2384
|
{
|
|
2385
2385
|
if (this.mc_video || (this.mc_video = createVideoInfo()), this.mc_video.remove = !1, this.mc_video.updateTime === w) break;
|
|
2386
|
-
this.mc_video.isEnable = !!p, this.mc_video.isMute = !!f, this.mc_video.updateTime = Number(w) || 0, this.mc_video.sx = k || 0, this.mc_video.sy = _ || 0, this.mc_video.sw = b || 0, this.mc_video.sh =
|
|
2386
|
+
this.mc_video.isEnable = !!p, this.mc_video.isMute = !!f, this.mc_video.updateTime = Number(w) || 0, this.mc_video.sx = k || 0, this.mc_video.sy = _ || 0, this.mc_video.sw = b || 0, this.mc_video.sh = m || 0;
|
|
2387
2387
|
}
|
|
2388
2388
|
break;
|
|
2389
2389
|
case 1:
|
|
2390
2390
|
{
|
|
2391
2391
|
if (this.ss_video || (this.ss_video = createVideoInfo()), this.ss_video.remove = !1, this.ss_video.updateTime === w) break;
|
|
2392
|
-
this.ss_video.isEnable = !!p, this.ss_video.isMute = !!f, this.ss_video.updateTime = Number(w) || 0, this.ss_video.sx = k || 0, this.ss_video.sy = _ || 0, this.ss_video.sw = b || 0, this.ss_video.sh =
|
|
2392
|
+
this.ss_video.isEnable = !!p, this.ss_video.isMute = !!f, this.ss_video.updateTime = Number(w) || 0, this.ss_video.sx = k || 0, this.ss_video.sy = _ || 0, this.ss_video.sw = b || 0, this.ss_video.sh = m || 0;
|
|
2393
2393
|
}
|
|
2394
2394
|
break;
|
|
2395
2395
|
}
|
|
@@ -2398,7 +2398,7 @@ class RoomUser {
|
|
|
2398
2398
|
const i = this.getUpdateTimeKey();
|
|
2399
2399
|
n !== i && (this.updateTime = (/* @__PURE__ */ new Date()).getTime());
|
|
2400
2400
|
});
|
|
2401
|
-
|
|
2401
|
+
g(this, "destroy", () => {
|
|
2402
2402
|
var o, a;
|
|
2403
2403
|
(o = this.mc_video) != null && o.destroy && this.mc_video.destroy(), (a = this.ss_video) != null && a.destroy && this.ss_video.destroy(), this.mc_audio = void 0, this.mc_video = void 0, this.ss_audio = void 0, this.ss_video = void 0;
|
|
2404
2404
|
});
|
|
@@ -2433,39 +2433,36 @@ const parseSEI = (h) => {
|
|
|
2433
2433
|
};
|
|
2434
2434
|
class QuickVoPlayer {
|
|
2435
2435
|
constructor(o = {}) {
|
|
2436
|
-
|
|
2436
|
+
g(this, "option", {
|
|
2437
2437
|
debug: !1
|
|
2438
2438
|
});
|
|
2439
|
-
|
|
2440
|
-
|
|
2441
|
-
|
|
2442
|
-
|
|
2439
|
+
g(this, "displayMode", "original");
|
|
2440
|
+
g(this, "prPlayer");
|
|
2441
|
+
g(this, "dom");
|
|
2442
|
+
g(this, "room", {
|
|
2443
2443
|
roomId: "",
|
|
2444
2444
|
updateTime: "",
|
|
2445
2445
|
author: "",
|
|
2446
2446
|
version: ""
|
|
2447
2447
|
});
|
|
2448
|
-
|
|
2449
|
-
|
|
2448
|
+
g(this, "usersMap", /* @__PURE__ */ new Map());
|
|
2449
|
+
g(this, "on", {
|
|
2450
2450
|
users: (o) => {
|
|
2451
2451
|
}
|
|
2452
2452
|
});
|
|
2453
|
-
|
|
2454
|
-
|
|
2455
|
-
});
|
|
2456
|
-
m(this, "start", async (o) => (this.stop(), this.prPlayer.start(o)));
|
|
2457
|
-
m(this, "stop", () => {
|
|
2453
|
+
g(this, "start", async (o) => (this.stop(), this.prPlayer.start(o)));
|
|
2454
|
+
g(this, "stop", () => {
|
|
2458
2455
|
this.prPlayer.stop(), this.usersMap = /* @__PURE__ */ new Map(), this.room.roomId = "", this.room.author = "", this.room.updateTime = "", this.room.version = "";
|
|
2459
2456
|
});
|
|
2460
|
-
|
|
2457
|
+
g(this, "setMute", (o) => {
|
|
2461
2458
|
this.prPlayer.setMute(o);
|
|
2462
2459
|
});
|
|
2463
|
-
|
|
2464
|
-
|
|
2460
|
+
g(this, "getStream", () => this.prPlayer.getStream());
|
|
2461
|
+
g(this, "getAllUseUpdateKey", () => {
|
|
2465
2462
|
const o = [...this.usersMap.values()];
|
|
2466
2463
|
return Array.from(o, (u) => u.updateTime).join("_");
|
|
2467
2464
|
});
|
|
2468
|
-
|
|
2465
|
+
g(this, "checkAndCreateUser", (o, a) => {
|
|
2469
2466
|
var u, r;
|
|
2470
2467
|
if (this.usersMap.has(o)) {
|
|
2471
2468
|
const n = this.usersMap.get(o);
|
|
@@ -2498,7 +2495,7 @@ class QuickVoPlayer {
|
|
|
2498
2495
|
/**
|
|
2499
2496
|
* 监听SEI信息
|
|
2500
2497
|
*/
|
|
2501
|
-
|
|
2498
|
+
g(this, "onSEI", (o) => {
|
|
2502
2499
|
try {
|
|
2503
2500
|
const a = parseSEI(o);
|
|
2504
2501
|
if (!a) return;
|
|
@@ -2520,7 +2517,7 @@ class QuickVoPlayer {
|
|
|
2520
2517
|
}
|
|
2521
2518
|
const s = this.getAllUseUpdateKey();
|
|
2522
2519
|
if (t !== s && this.on.users) {
|
|
2523
|
-
const l = [...this.usersMap.values()], c = Array.from(l, ({ userId: d, mc_audio: p, mc_video: f, ss_audio: w, ss_video: b, updateTime:
|
|
2520
|
+
const l = [...this.usersMap.values()], c = Array.from(l, ({ userId: d, mc_audio: p, mc_video: f, ss_audio: w, ss_video: b, updateTime: m }) => ({ userId: d, mc_audio: p, mc_video: f, ss_audio: w, ss_video: b, updateTime: m }));
|
|
2524
2521
|
this.on.users(c);
|
|
2525
2522
|
}
|
|
2526
2523
|
}
|
|
@@ -2536,7 +2533,7 @@ class QuickVoPlayer {
|
|
|
2536
2533
|
console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", "------->onSEI: error", a);
|
|
2537
2534
|
}
|
|
2538
2535
|
});
|
|
2539
|
-
|
|
2536
|
+
g(this, "setDisplayMode", (o) => {
|
|
2540
2537
|
var a, u, r, n, i, t, e, s;
|
|
2541
2538
|
switch (this.displayMode = o, o) {
|
|
2542
2539
|
case "original":
|