quickvo-player 0.1.5 → 0.1.7
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 +222 -226
- 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) {
|
|
@@ -25,13 +25,13 @@ function L(h) {
|
|
|
25
25
|
);
|
|
26
26
|
}
|
|
27
27
|
}
|
|
28
|
-
class
|
|
28
|
+
class F {
|
|
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) => {
|
|
@@ -53,9 +53,9 @@ class N {
|
|
|
53
53
|
};
|
|
54
54
|
}
|
|
55
55
|
}
|
|
56
|
-
const S = `(function(){"use strict";class
|
|
56
|
+
const S = `(function(){"use strict";class c{pattern="flv";audioDecoderConfig;audioDecoder;videoDecoderConfig;videoDecoder;hasKeyFrame=!1;baseTime=0;pendingChunks=[];isProcessing=!1;decodeTimer=0;frameTrack=!1;isFrameTrack=!1;fameTrackOption={flv:[20,50],hls:[200,300],dash:[50,100],rtmp:[50,100]};decodingSpeed=16;fps=0;firstVideoChunkTimestamp;secondVideoChunkTimestamp;decodingSpeedRatio=1;maxDecodingSpeedRatio=2;lastRenderTime;nextRenderTime;on={audio:{},video:{}};constructor(){}init=e=>{this.destroy(),this.pattern=e,this.baseTime=new Date().getTime()-performance.now(),this.initDecodeInterval()};setFrameTrack=e=>{this.frameTrack=e,this.frameTrack===!1&&(this.decodingSpeedRatio=1)};initDecodeInterval=()=>{let e=this.decodingSpeed/this.decodingSpeedRatio;const i=this.baseTime+performance.now();if(this.lastRenderTime||(this.lastRenderTime=i),this.fps=Math.round(1e3/(i-this.lastRenderTime)),this.lastRenderTime=i,this.nextRenderTime){const t=this.lastRenderTime-this.nextRenderTime;e-=t}this.nextRenderTime=this.lastRenderTime+e,this.decodeTimer=setTimeout(()=>{this.decode(),this.initDecodeInterval()},e)};decode=()=>{if(this.isProcessing!==!0){for(this.isProcessing=!0;;){const e=this.pendingChunks.shift(),i=this.pendingChunks.length;if(this.frameTrack){const[n,r]=this.fameTrackOption[this.pattern];if(i<=n&&(this.isFrameTrack=!1),i>=r&&(this.isFrameTrack=!0),this.isFrameTrack){const a=Math.min(1+(i-n)/100,this.maxDecodingSpeedRatio);this.decodingSpeedRatio=Number(a.toFixed(1))}else this.decodingSpeedRatio=1}if(this.on.debug){const{decodingSpeed:n,decodingSpeedRatio:r,fps:a}=this;this.on.debug({decodingSpeed:n,decodingSpeedRatio:r,fps:a})}if(!e)break;const{type:t,init:o}=e;switch(t){case"audio":this.decodeAudio(o);break;case"video":this.decodeVideo(o);break}if(t==="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)}};destroy=()=>{this.audio.destroy(),this.video.destroy(),clearInterval(this.decodeTimer)};audio={init:e=>{this.audio.destroy(),this.audioDecoderConfig={...e},this.audioDecoder=new AudioDecoder({output:i=>{const t=this.decodingSpeedRatio;this.on.audio.decode&&this.on.audio.decode({audioData:i,playbackRate:t})},error:i=>{this.on.audio.error&&this.on.audio.error(i)}}),this.audioDecoder.configure(this.audioDecoderConfig)},push:e=>{this.pendingChunks.push({type:"audio",init:e})},flush:()=>{this.audioDecoder?.flush()},destroy:()=>{this.audioDecoderConfig=void 0,this.audioDecoder?.close(),this.audioDecoder=void 0}};video={init:e=>{this.video.destroy(),this.videoDecoderConfig={...e},this.videoDecoder=new VideoDecoder({output:async i=>{const t=i.timestamp+this.baseTime*1e3,o=await createImageBitmap(i);i.close(),o.width>0&&o.height>0?this.on.video.decode&&this.on.video.decode({timestamp:t,bitmap:o}):o.close()},error:i=>{this.on.video.error&&this.on.video.error(i)}}),this.videoDecoder.configure(this.videoDecoderConfig)},push:e=>{this.pendingChunks.push({type:"video",init:e})},flush:()=>{this.videoDecoder?.flush()},destroy:()=>{this.videoDecoderConfig=void 0,this.videoDecoder?.close(),this.videoDecoder=void 0,this.hasKeyFrame=!1}}}const d=new c;d.on.audio.decode=s=>postMessage({type:"audio",action:"onDecode",data:s}),d.on.audio.error=s=>postMessage({type:"audio",action:"onError",data:s}),d.on.video.decode=s=>postMessage({type:"video",action:"onDecode",data:s}),d.on.video.error=s=>postMessage({type:"video",action:"onError",data:s}),onmessage=s=>{const{type:e,action:i,data:t}=s.data;if(e){const o=d[e][i];o&&o(t)}else{const o=d[i];o&&o(t)}}})();
|
|
57
57
|
`, v = typeof self < "u" && self.Blob && new Blob(["(self.URL || self.webkitURL).revokeObjectURL(self.location.href);", S], { type: "text/javascript;charset=utf-8" });
|
|
58
|
-
function
|
|
58
|
+
function V(h) {
|
|
59
59
|
let o;
|
|
60
60
|
try {
|
|
61
61
|
if (o = v && (self.URL || self.webkitURL).createObjectURL(v), !o) throw "";
|
|
@@ -74,13 +74,13 @@ function F(h) {
|
|
|
74
74
|
);
|
|
75
75
|
}
|
|
76
76
|
}
|
|
77
|
-
class
|
|
77
|
+
class N {
|
|
78
78
|
constructor() {
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
79
|
+
g(this, "worker", new V());
|
|
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) => {
|
|
@@ -112,8 +112,8 @@ class B {
|
|
|
112
112
|
};
|
|
113
113
|
}
|
|
114
114
|
}
|
|
115
|
-
var
|
|
116
|
-
class
|
|
115
|
+
var B = Object.defineProperty, E = (h, o, a) => o in h ? B(h, o, { enumerable: !0, configurable: !0, writable: !0, value: a }) : h[o] = a, y = (h, o, a) => E(h, typeof o != "symbol" ? o + "" : o, a);
|
|
116
|
+
class G {
|
|
117
117
|
constructor(o, a) {
|
|
118
118
|
y(this, "inputStream", new MediaStream()), y(this, "outputStream", new MediaStream()), y(this, "inputGain", 1), y(this, "enhanceGain", 1), y(this, "bgsGain", 1), y(this, "bgmGain", 1), y(this, "outputGain", 1), y(this, "mixAudioMap", /* @__PURE__ */ new Map()), y(this, "audioContext", new AudioContext()), y(this, "sourceNode"), y(this, "inputGainNode"), y(this, "enhanceGainNode"), y(this, "bgsGainNode"), y(this, "bgmGainNode"), y(this, "analyserNode"), y(this, "analyserArrayData"), y(this, "outputGainNode"), y(this, "destinationNode"), y(this, "filterStream", (u) => u), y(this, "stop", () => {
|
|
119
119
|
{
|
|
@@ -167,7 +167,7 @@ class O {
|
|
|
167
167
|
this.setMute(!0), this.audioContext.resume();
|
|
168
168
|
}
|
|
169
169
|
}
|
|
170
|
-
const
|
|
170
|
+
const O = async (h, o) => {
|
|
171
171
|
try {
|
|
172
172
|
const { format: a, numberOfChannels: u, numberOfFrames: r, sampleRate: n } = o, i = h.createBuffer(u, r, n);
|
|
173
173
|
for (let t = 0; t < u; t++) {
|
|
@@ -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
|
-
|
|
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
|
|
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
|
+
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 G(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
|
});
|
|
@@ -223,7 +223,7 @@ class W {
|
|
|
223
223
|
const { audioData: a, playbackRate: u = 1 } = o;
|
|
224
224
|
try {
|
|
225
225
|
if (!this.audioContext || !this.destination) return;
|
|
226
|
-
let r = await
|
|
226
|
+
let r = await O(this.audioContext, a);
|
|
227
227
|
if (!r) return;
|
|
228
228
|
const n = this.audioContext.createBufferSource();
|
|
229
229
|
n.buffer = r, n.playbackRate.value = u;
|
|
@@ -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
|
}
|
|
@@ -278,20 +278,20 @@ class z {
|
|
|
278
278
|
const q = (h) => {
|
|
279
279
|
const o = h.toLowerCase();
|
|
280
280
|
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";
|
|
281
|
-
},
|
|
281
|
+
}, R = (h) => {
|
|
282
282
|
const o = (h == null ? void 0 : h.getTracks()) || [];
|
|
283
283
|
for (const a of o)
|
|
284
284
|
a.stop();
|
|
285
285
|
}, A = () => {
|
|
286
286
|
const h = new MediaStreamTrackGenerator({ kind: "video" }), o = new MediaStream([h]), a = new z();
|
|
287
287
|
return a.init({ writable: h.writable }), { worker: a, stream: o, destroy: () => {
|
|
288
|
-
a.destroy(),
|
|
288
|
+
a.destroy(), R(o);
|
|
289
289
|
} };
|
|
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()];
|
|
@@ -338,10 +338,10 @@ const Y = (h) => {
|
|
|
338
338
|
}
|
|
339
339
|
return { size: u, header: r, data: n };
|
|
340
340
|
};
|
|
341
|
-
var
|
|
341
|
+
var P, U;
|
|
342
342
|
class C {
|
|
343
343
|
constructor(o = {}) {
|
|
344
|
-
J(this,
|
|
344
|
+
J(this, P, {
|
|
345
345
|
timeout: 5 * 1e3,
|
|
346
346
|
check: !1
|
|
347
347
|
});
|
|
@@ -351,13 +351,13 @@ 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(() => {
|
|
358
358
|
var t;
|
|
359
359
|
(t = I(this, U)) == null || t.abort("Timeout."), r({ status: "timeout", reason: "" });
|
|
360
|
-
}, I(this,
|
|
360
|
+
}, I(this, P).timeout);
|
|
361
361
|
try {
|
|
362
362
|
const t = await fetch(o, { ...a, method: "HEAD", signal: (i = I(this, U)) == null ? void 0 : i.signal });
|
|
363
363
|
t.status === 200 ? u({ status: "successed", reason: "" }) : r({ status: "failed", reason: `${t.status}` });
|
|
@@ -371,10 +371,10 @@ 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
|
-
I(this,
|
|
377
|
+
I(this, P).check && await this.check(o, a), H(this, U, new AbortController());
|
|
378
378
|
const i = await fetch(o, { ...a, signal: (n = I(this, U)) == null ? void 0 : n.signal });
|
|
379
379
|
u(i);
|
|
380
380
|
} catch (i) {
|
|
@@ -384,47 +384,41 @@ 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
|
});
|
|
391
|
-
H(this,
|
|
391
|
+
H(this, P, { ...I(this, P), ...o });
|
|
392
392
|
}
|
|
393
393
|
}
|
|
394
|
-
|
|
394
|
+
P = 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
|
-
|
|
413
|
-
/**
|
|
414
|
-
* 初始化
|
|
415
|
-
*/
|
|
416
|
-
m(this, "init", () => {
|
|
417
|
-
this.initDecoder(), this.initRender(), this.audioPlayer = new W(), this.audioPlayer.init();
|
|
418
|
-
});
|
|
412
|
+
g(this, "trackGenerator");
|
|
419
413
|
/**
|
|
420
414
|
* 开始播放
|
|
421
415
|
* @param url : string
|
|
422
416
|
*/
|
|
423
|
-
|
|
424
|
-
this.stop(), this.url = o
|
|
417
|
+
g(this, "start", async (o) => {
|
|
418
|
+
this.stop(), this.url = o;
|
|
425
419
|
const a = q(o);
|
|
426
420
|
if (a === "unknown") throw new Error("This address cannot be parsed.");
|
|
427
|
-
switch (this.
|
|
421
|
+
switch (this.init(a), a) {
|
|
428
422
|
case "flv":
|
|
429
423
|
this.flv.start();
|
|
430
424
|
break;
|
|
@@ -436,7 +430,7 @@ class et {
|
|
|
436
430
|
/**
|
|
437
431
|
* 停止
|
|
438
432
|
*/
|
|
439
|
-
|
|
433
|
+
g(this, "stop", async () => {
|
|
440
434
|
var a, u, r, n, i;
|
|
441
435
|
try {
|
|
442
436
|
clearInterval(this.hls.getSegmentsTimer), this.prFetch.stop();
|
|
@@ -447,17 +441,17 @@ class et {
|
|
|
447
441
|
const o = [...this.cutRenders.keys()];
|
|
448
442
|
for (const t of o)
|
|
449
443
|
(n = this.cutRenders.get(t)) == null || n.worker.destroy(), this.cutRenders.delete(t);
|
|
450
|
-
|
|
444
|
+
R(this.stream), (i = this.audioPlayer) == null || i.destroy();
|
|
451
445
|
});
|
|
452
446
|
/**
|
|
453
447
|
* 获取媒体流
|
|
454
448
|
*/
|
|
455
|
-
|
|
449
|
+
g(this, "getStream", () => this.stream);
|
|
456
450
|
/**
|
|
457
451
|
* 设置暂停
|
|
458
452
|
* @param pause: boolean
|
|
459
453
|
*/
|
|
460
|
-
|
|
454
|
+
g(this, "setPause", (o) => {
|
|
461
455
|
var a;
|
|
462
456
|
(a = this.renderWorker) == null || a.setPause(o);
|
|
463
457
|
});
|
|
@@ -465,7 +459,7 @@ class et {
|
|
|
465
459
|
* 是否静音 默认为true
|
|
466
460
|
* @param state?: boolean
|
|
467
461
|
*/
|
|
468
|
-
|
|
462
|
+
g(this, "setMute", (o) => {
|
|
469
463
|
var a, u;
|
|
470
464
|
return (u = (a = this.audioPlayer) == null ? void 0 : a.prAudioStream) == null ? void 0 : u.setMute(o);
|
|
471
465
|
});
|
|
@@ -473,31 +467,65 @@ class et {
|
|
|
473
467
|
* 是否开启追帧
|
|
474
468
|
* @param frameTrack?: boolean
|
|
475
469
|
*/
|
|
476
|
-
|
|
470
|
+
g(this, "setFrameTrack", (o) => {
|
|
477
471
|
var a;
|
|
478
472
|
(a = this.decoderWorker) == null || a.setFrameTrack(o);
|
|
479
473
|
});
|
|
480
474
|
/**
|
|
481
475
|
* 是否已准备好
|
|
482
476
|
*/
|
|
483
|
-
|
|
477
|
+
g(this, "isReady", () => {
|
|
484
478
|
const o = () => {
|
|
485
479
|
var a;
|
|
486
480
|
return ((a = this.stream) == null ? void 0 : a.active) === !0;
|
|
487
481
|
};
|
|
488
482
|
return this.prResolves.add("isReady", o);
|
|
489
483
|
});
|
|
484
|
+
g(this, "cut", {
|
|
485
|
+
/**
|
|
486
|
+
* 创建剪切
|
|
487
|
+
*/
|
|
488
|
+
create: (o, a) => {
|
|
489
|
+
let u = this.cutRenders.get(o);
|
|
490
|
+
return u ? (u.worker.setCut(a), u.worker.setPause(!1), u) : (u = A(), u.worker.setCut(a), this.cutRenders.set(o, u), u);
|
|
491
|
+
},
|
|
492
|
+
/**
|
|
493
|
+
* 获取媒体流
|
|
494
|
+
*/
|
|
495
|
+
getStream: (o) => {
|
|
496
|
+
var a;
|
|
497
|
+
return (a = this.cutRenders.get(o)) == null ? void 0 : a.stream;
|
|
498
|
+
},
|
|
499
|
+
/**
|
|
500
|
+
* 设置暂停
|
|
501
|
+
* @param pause: boolean
|
|
502
|
+
*/
|
|
503
|
+
setPause: (o, a) => {
|
|
504
|
+
var u;
|
|
505
|
+
(u = this.cutRenders.get(o)) == null || u.worker.setPause(a);
|
|
506
|
+
},
|
|
507
|
+
/**
|
|
508
|
+
* 移除剪切
|
|
509
|
+
*/
|
|
510
|
+
remove: (o) => {
|
|
511
|
+
var a;
|
|
512
|
+
(a = this.cutRenders.get(o)) == null || a.destroy(), this.cutRenders.delete(o);
|
|
513
|
+
}
|
|
514
|
+
});
|
|
515
|
+
/**
|
|
516
|
+
* 初始化
|
|
517
|
+
*/
|
|
518
|
+
g(this, "init", (o) => {
|
|
519
|
+
this.initDecoder(o), this.initRender(), this.initDemuxer(o), this.audioPlayer = new W(), this.audioPlayer.init();
|
|
520
|
+
});
|
|
490
521
|
/**
|
|
491
522
|
* 初始化解复器
|
|
492
523
|
*/
|
|
493
|
-
|
|
494
|
-
this.demuxerWorker = new
|
|
524
|
+
g(this, "initDemuxer", (o) => {
|
|
525
|
+
this.demuxerWorker = new F(), this.demuxerWorker.init(o), this.demuxerWorker.on.debug = (a) => {
|
|
495
526
|
this.option.debug && console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", "------->pr-player: debug", a);
|
|
496
527
|
}, this.demuxerWorker.on.info = (a) => {
|
|
497
|
-
|
|
498
|
-
this.option.debug && console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", "------->pr-player: info", a);
|
|
499
|
-
const { framerate: u = 25 } = a, r = 1e3 / u;
|
|
500
|
-
(n = this.decoderWorker) == null || n.init({ decodingSpeed: r }), this.on.demuxer.info && this.on.demuxer.info(a);
|
|
528
|
+
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);
|
|
501
529
|
}, this.demuxerWorker.on.config = (a) => {
|
|
502
530
|
var r, n;
|
|
503
531
|
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);
|
|
@@ -543,62 +571,33 @@ class et {
|
|
|
543
571
|
/**
|
|
544
572
|
* 初始化解码器
|
|
545
573
|
*/
|
|
546
|
-
|
|
547
|
-
this.decoderWorker = new
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
this.
|
|
552
|
-
}, this.decoderWorker.on.
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
this.
|
|
574
|
+
g(this, "initDecoder", (o) => {
|
|
575
|
+
this.decoderWorker = new N(), this.decoderWorker.init(o), this.decoderWorker.on.debug = (a) => {
|
|
576
|
+
this.option.debug && console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", "------->pr-player: debug", a);
|
|
577
|
+
}, this.decoderWorker.on.audio.decode = (a) => {
|
|
578
|
+
var u;
|
|
579
|
+
(u = this.audioPlayer) == null || u.push(a), this.on.decoder.audio && this.on.decoder.audio(a);
|
|
580
|
+
}, this.decoderWorker.on.audio.error = (a) => {
|
|
581
|
+
this.option.debug && console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", "------->pr-player: audio.error ", a), this.on.error && this.on.error(a);
|
|
582
|
+
}, this.decoderWorker.on.video.decode = async (a) => {
|
|
583
|
+
var r, n;
|
|
584
|
+
(r = this.renderWorker) == null || r.push(a);
|
|
585
|
+
const u = [...this.cutRenders.keys()];
|
|
586
|
+
for (const i of u)
|
|
587
|
+
(n = this.cutRenders.get(i)) == null || n.worker.push(a);
|
|
588
|
+
this.on.decoder.video && this.on.decoder.video(a), a.bitmap.close();
|
|
589
|
+
}, this.decoderWorker.on.video.error = (a) => {
|
|
590
|
+
this.stop(), this.on.error && this.on.error(a);
|
|
561
591
|
};
|
|
562
592
|
});
|
|
563
593
|
/**
|
|
564
594
|
* 初始化渲染器
|
|
565
595
|
*/
|
|
566
|
-
|
|
596
|
+
g(this, "initRender", () => {
|
|
567
597
|
const { worker: o, stream: a } = A();
|
|
568
598
|
this.renderWorker = o, this.stream = a, this.renderWorker.setPause(!1);
|
|
569
599
|
});
|
|
570
|
-
|
|
571
|
-
/**
|
|
572
|
-
* 创建剪切
|
|
573
|
-
*/
|
|
574
|
-
create: (o, a) => {
|
|
575
|
-
let u = this.cutRenders.get(o);
|
|
576
|
-
return u ? (u.worker.setCut(a), u.worker.setPause(!1), u) : (u = A(), u.worker.setCut(a), this.cutRenders.set(o, u), u);
|
|
577
|
-
},
|
|
578
|
-
/**
|
|
579
|
-
* 获取媒体流
|
|
580
|
-
*/
|
|
581
|
-
getStream: (o) => {
|
|
582
|
-
var a;
|
|
583
|
-
return (a = this.cutRenders.get(o)) == null ? void 0 : a.stream;
|
|
584
|
-
},
|
|
585
|
-
/**
|
|
586
|
-
* 设置暂停
|
|
587
|
-
* @param pause: boolean
|
|
588
|
-
*/
|
|
589
|
-
setPause: (o, a) => {
|
|
590
|
-
var u;
|
|
591
|
-
(u = this.cutRenders.get(o)) == null || u.worker.setPause(a);
|
|
592
|
-
},
|
|
593
|
-
/**
|
|
594
|
-
* 移除剪切
|
|
595
|
-
*/
|
|
596
|
-
remove: (o) => {
|
|
597
|
-
var a;
|
|
598
|
-
(a = this.cutRenders.get(o)) == null || a.destroy(), this.cutRenders.delete(o);
|
|
599
|
-
}
|
|
600
|
-
});
|
|
601
|
-
m(this, "flv", {
|
|
600
|
+
g(this, "flv", {
|
|
602
601
|
start: async () => {
|
|
603
602
|
var o, a;
|
|
604
603
|
try {
|
|
@@ -616,7 +615,7 @@ class et {
|
|
|
616
615
|
}
|
|
617
616
|
}
|
|
618
617
|
});
|
|
619
|
-
|
|
618
|
+
g(this, "hls", {
|
|
620
619
|
isLive: !1,
|
|
621
620
|
urls: [],
|
|
622
621
|
url: "",
|
|
@@ -896,8 +895,8 @@ function requireFloat() {
|
|
|
896
895
|
}
|
|
897
896
|
n.writeDoubleLE = i.bind(null, o, 0, 4), n.writeDoubleBE = i.bind(null, a, 4, 0);
|
|
898
897
|
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 ?
|
|
898
|
+
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;
|
|
899
|
+
return b === 2047 ? m ? NaN : w * (1 / 0) : b === 0 ? w * 5e-324 * m : w * Math.pow(2, b - 1075) * (m + 4503599627370496);
|
|
901
900
|
}
|
|
902
901
|
n.readDoubleLE = t.bind(null, u, 0, 4), n.readDoubleBE = t.bind(null, r, 4, 0);
|
|
903
902
|
}(), n;
|
|
@@ -1170,8 +1169,8 @@ function requireWriter() {
|
|
|
1170
1169
|
if (hasRequiredWriter) return writer;
|
|
1171
1170
|
hasRequiredWriter = 1, writer = e;
|
|
1172
1171
|
var h = requireMinimal$1(), o, a = h.LongBits, u = h.base64, r = h.utf8;
|
|
1173
|
-
function n(b,
|
|
1174
|
-
this.fn = b, this.len =
|
|
1172
|
+
function n(b, m, k) {
|
|
1173
|
+
this.fn = b, this.len = m, this.next = void 0, this.val = k;
|
|
1175
1174
|
}
|
|
1176
1175
|
function i() {
|
|
1177
1176
|
}
|
|
@@ -1190,89 +1189,89 @@ function requireWriter() {
|
|
|
1190
1189
|
return new e();
|
|
1191
1190
|
};
|
|
1192
1191
|
};
|
|
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(
|
|
1192
|
+
e.create = s(), e.alloc = function(m) {
|
|
1193
|
+
return new h.Array(m);
|
|
1194
|
+
}, h.Array !== Array && (e.alloc = h.pool(e.alloc, h.Array.prototype.subarray)), e.prototype._push = function(m, k, _) {
|
|
1195
|
+
return this.tail = this.tail.next = new n(m, k, _), this.len += k, this;
|
|
1197
1196
|
};
|
|
1198
|
-
function l(b,
|
|
1199
|
-
|
|
1197
|
+
function l(b, m, k) {
|
|
1198
|
+
m[k] = b & 255;
|
|
1200
1199
|
}
|
|
1201
|
-
function c(b,
|
|
1200
|
+
function c(b, m, k) {
|
|
1202
1201
|
for (; b > 127; )
|
|
1203
|
-
|
|
1204
|
-
|
|
1202
|
+
m[k++] = b & 127 | 128, b >>>= 7;
|
|
1203
|
+
m[k] = b;
|
|
1205
1204
|
}
|
|
1206
|
-
function d(b,
|
|
1207
|
-
this.len = b, this.next = void 0, this.val =
|
|
1205
|
+
function d(b, m) {
|
|
1206
|
+
this.len = b, this.next = void 0, this.val = m;
|
|
1208
1207
|
}
|
|
1209
|
-
d.prototype = Object.create(n.prototype), d.prototype.fn = c, e.prototype.uint32 = function(
|
|
1208
|
+
d.prototype = Object.create(n.prototype), d.prototype.fn = c, e.prototype.uint32 = function(m) {
|
|
1210
1209
|
return this.len += (this.tail = this.tail.next = new d(
|
|
1211
|
-
(
|
|
1212
|
-
|
|
1210
|
+
(m = m >>> 0) < 128 ? 1 : m < 16384 ? 2 : m < 2097152 ? 3 : m < 268435456 ? 4 : 5,
|
|
1211
|
+
m
|
|
1213
1212
|
)).len, this;
|
|
1214
|
-
}, e.prototype.int32 = function(
|
|
1215
|
-
return
|
|
1216
|
-
}, e.prototype.sint32 = function(
|
|
1217
|
-
return this.uint32((
|
|
1213
|
+
}, e.prototype.int32 = function(m) {
|
|
1214
|
+
return m < 0 ? this._push(p, 10, a.fromNumber(m)) : this.uint32(m);
|
|
1215
|
+
}, e.prototype.sint32 = function(m) {
|
|
1216
|
+
return this.uint32((m << 1 ^ m >> 31) >>> 0);
|
|
1218
1217
|
};
|
|
1219
|
-
function p(b,
|
|
1218
|
+
function p(b, m, k) {
|
|
1220
1219
|
for (; b.hi; )
|
|
1221
|
-
|
|
1220
|
+
m[k++] = b.lo & 127 | 128, b.lo = (b.lo >>> 7 | b.hi << 25) >>> 0, b.hi >>>= 7;
|
|
1222
1221
|
for (; b.lo > 127; )
|
|
1223
|
-
|
|
1224
|
-
|
|
1222
|
+
m[k++] = b.lo & 127 | 128, b.lo = b.lo >>> 7;
|
|
1223
|
+
m[k++] = b.lo;
|
|
1225
1224
|
}
|
|
1226
|
-
e.prototype.uint64 = function(
|
|
1227
|
-
var k = a.from(
|
|
1225
|
+
e.prototype.uint64 = function(m) {
|
|
1226
|
+
var k = a.from(m);
|
|
1228
1227
|
return this._push(p, k.length(), k);
|
|
1229
|
-
}, e.prototype.int64 = e.prototype.uint64, e.prototype.sint64 = function(
|
|
1230
|
-
var k = a.from(
|
|
1228
|
+
}, e.prototype.int64 = e.prototype.uint64, e.prototype.sint64 = function(m) {
|
|
1229
|
+
var k = a.from(m).zzEncode();
|
|
1231
1230
|
return this._push(p, k.length(), k);
|
|
1232
|
-
}, e.prototype.bool = function(
|
|
1233
|
-
return this._push(l, 1,
|
|
1231
|
+
}, e.prototype.bool = function(m) {
|
|
1232
|
+
return this._push(l, 1, m ? 1 : 0);
|
|
1234
1233
|
};
|
|
1235
|
-
function f(b,
|
|
1236
|
-
|
|
1234
|
+
function f(b, m, k) {
|
|
1235
|
+
m[k] = b & 255, m[k + 1] = b >>> 8 & 255, m[k + 2] = b >>> 16 & 255, m[k + 3] = b >>> 24;
|
|
1237
1236
|
}
|
|
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(
|
|
1237
|
+
e.prototype.fixed32 = function(m) {
|
|
1238
|
+
return this._push(f, 4, m >>> 0);
|
|
1239
|
+
}, e.prototype.sfixed32 = e.prototype.fixed32, e.prototype.fixed64 = function(m) {
|
|
1240
|
+
var k = a.from(m);
|
|
1242
1241
|
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,
|
|
1242
|
+
}, e.prototype.sfixed64 = e.prototype.fixed64, e.prototype.float = function(m) {
|
|
1243
|
+
return this._push(h.float.writeFloatLE, 4, m);
|
|
1244
|
+
}, e.prototype.double = function(m) {
|
|
1245
|
+
return this._push(h.float.writeDoubleLE, 8, m);
|
|
1247
1246
|
};
|
|
1248
|
-
var w = h.Array.prototype.set ? function(
|
|
1249
|
-
k.set(
|
|
1250
|
-
} : function(
|
|
1251
|
-
for (var K = 0; K <
|
|
1252
|
-
k[_ + K] =
|
|
1247
|
+
var w = h.Array.prototype.set ? function(m, k, _) {
|
|
1248
|
+
k.set(m, _);
|
|
1249
|
+
} : function(m, k, _) {
|
|
1250
|
+
for (var K = 0; K < m.length; ++K)
|
|
1251
|
+
k[_ + K] = m[K];
|
|
1253
1252
|
};
|
|
1254
|
-
return e.prototype.bytes = function(
|
|
1255
|
-
var k =
|
|
1253
|
+
return e.prototype.bytes = function(m) {
|
|
1254
|
+
var k = m.length >>> 0;
|
|
1256
1255
|
if (!k)
|
|
1257
1256
|
return this._push(l, 1, 0);
|
|
1258
|
-
if (h.isString(
|
|
1259
|
-
var _ = e.alloc(k = u.length(
|
|
1260
|
-
u.decode(
|
|
1257
|
+
if (h.isString(m)) {
|
|
1258
|
+
var _ = e.alloc(k = u.length(m));
|
|
1259
|
+
u.decode(m, _, 0), m = _;
|
|
1261
1260
|
}
|
|
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,
|
|
1261
|
+
return this.uint32(k)._push(w, k, m);
|
|
1262
|
+
}, e.prototype.string = function(m) {
|
|
1263
|
+
var k = r.length(m);
|
|
1264
|
+
return k ? this.uint32(k)._push(r.write, k, m) : this._push(l, 1, 0);
|
|
1266
1265
|
}, e.prototype.fork = function() {
|
|
1267
1266
|
return this.states = new t(this), this.head = this.tail = new n(i, 0, 0), this.len = 0, this;
|
|
1268
1267
|
}, e.prototype.reset = function() {
|
|
1269
1268
|
return this.states ? (this.head = this.states.head, this.tail = this.states.tail, this.len = this.states.len, this.states = this.states.next) : (this.head = this.tail = new n(i, 0, 0), this.len = 0), this;
|
|
1270
1269
|
}, e.prototype.ldelim = function() {
|
|
1271
|
-
var
|
|
1272
|
-
return this.reset().uint32(_), _ && (this.tail.next =
|
|
1270
|
+
var m = this.head, k = this.tail, _ = this.len;
|
|
1271
|
+
return this.reset().uint32(_), _ && (this.tail.next = m.next, this.tail = k, this.len += _), this;
|
|
1273
1272
|
}, e.prototype.finish = function() {
|
|
1274
|
-
for (var
|
|
1275
|
-
|
|
1273
|
+
for (var m = this.head.next, k = this.constructor.alloc(this.len), _ = 0; m; )
|
|
1274
|
+
m.fn(m.val, k, _), _ += m.len, m = m.next;
|
|
1276
1275
|
return k;
|
|
1277
1276
|
}, e._configure = function(b) {
|
|
1278
1277
|
o = b, e.create = s(), o._configure();
|
|
@@ -2340,21 +2339,21 @@ const $Reader = minimalExports.Reader, $Writer = minimalExports.Writer, $util =
|
|
|
2340
2339
|
});
|
|
2341
2340
|
class RoomUser {
|
|
2342
2341
|
constructor() {
|
|
2343
|
-
|
|
2344
|
-
|
|
2342
|
+
g(this, "userId", "");
|
|
2343
|
+
g(this, "mc_audio");
|
|
2345
2344
|
// 麦克风
|
|
2346
|
-
|
|
2345
|
+
g(this, "mc_video");
|
|
2347
2346
|
// 摄像头
|
|
2348
|
-
|
|
2347
|
+
g(this, "ss_audio");
|
|
2349
2348
|
// 屏幕共享视频
|
|
2350
|
-
|
|
2349
|
+
g(this, "ss_video");
|
|
2351
2350
|
// 屏幕共享音频
|
|
2352
|
-
|
|
2353
|
-
|
|
2351
|
+
g(this, "updateTime", 0);
|
|
2352
|
+
g(this, "getUpdateTimeKey", () => {
|
|
2354
2353
|
const o = [];
|
|
2355
2354
|
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
2355
|
});
|
|
2357
|
-
|
|
2356
|
+
g(this, "init", (o) => {
|
|
2358
2357
|
var t, e, s, l;
|
|
2359
2358
|
const { id: a, audios: u = [], videos: r = [] } = o;
|
|
2360
2359
|
this.userId = a;
|
|
@@ -2378,18 +2377,18 @@ class RoomUser {
|
|
|
2378
2377
|
}
|
|
2379
2378
|
}
|
|
2380
2379
|
for (const c of r) {
|
|
2381
|
-
const { type: d = 0, isEnable: p, isMute: f, updateTime: w, width: b, height:
|
|
2380
|
+
const { type: d = 0, isEnable: p, isMute: f, updateTime: w, width: b, height: m, x: k, y: _ } = c;
|
|
2382
2381
|
switch (d) {
|
|
2383
2382
|
case 0:
|
|
2384
2383
|
{
|
|
2385
2384
|
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 =
|
|
2385
|
+
this.mc_video.isEnable = !!p, this.mc_video.isMute = !!f, this.mc_video.updateTime = Number(w) || 0, this.mc_video.sx = k || 0, this.mc_video.sy = _ || 0, this.mc_video.sw = b || 0, this.mc_video.sh = m || 0;
|
|
2387
2386
|
}
|
|
2388
2387
|
break;
|
|
2389
2388
|
case 1:
|
|
2390
2389
|
{
|
|
2391
2390
|
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 =
|
|
2391
|
+
this.ss_video.isEnable = !!p, this.ss_video.isMute = !!f, this.ss_video.updateTime = Number(w) || 0, this.ss_video.sx = k || 0, this.ss_video.sy = _ || 0, this.ss_video.sw = b || 0, this.ss_video.sh = m || 0;
|
|
2393
2392
|
}
|
|
2394
2393
|
break;
|
|
2395
2394
|
}
|
|
@@ -2398,7 +2397,7 @@ class RoomUser {
|
|
|
2398
2397
|
const i = this.getUpdateTimeKey();
|
|
2399
2398
|
n !== i && (this.updateTime = (/* @__PURE__ */ new Date()).getTime());
|
|
2400
2399
|
});
|
|
2401
|
-
|
|
2400
|
+
g(this, "destroy", () => {
|
|
2402
2401
|
var o, a;
|
|
2403
2402
|
(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
2403
|
});
|
|
@@ -2433,39 +2432,36 @@ const parseSEI = (h) => {
|
|
|
2433
2432
|
};
|
|
2434
2433
|
class QuickVoPlayer {
|
|
2435
2434
|
constructor(o = {}) {
|
|
2436
|
-
|
|
2435
|
+
g(this, "option", {
|
|
2437
2436
|
debug: !1
|
|
2438
2437
|
});
|
|
2439
|
-
|
|
2440
|
-
|
|
2441
|
-
|
|
2442
|
-
|
|
2438
|
+
g(this, "displayMode", "original");
|
|
2439
|
+
g(this, "prPlayer");
|
|
2440
|
+
g(this, "dom");
|
|
2441
|
+
g(this, "room", {
|
|
2443
2442
|
roomId: "",
|
|
2444
2443
|
updateTime: "",
|
|
2445
2444
|
author: "",
|
|
2446
2445
|
version: ""
|
|
2447
2446
|
});
|
|
2448
|
-
|
|
2449
|
-
|
|
2447
|
+
g(this, "usersMap", /* @__PURE__ */ new Map());
|
|
2448
|
+
g(this, "on", {
|
|
2450
2449
|
users: (o) => {
|
|
2451
2450
|
}
|
|
2452
2451
|
});
|
|
2453
|
-
|
|
2454
|
-
|
|
2455
|
-
});
|
|
2456
|
-
m(this, "start", async (o) => (this.stop(), this.prPlayer.start(o)));
|
|
2457
|
-
m(this, "stop", () => {
|
|
2452
|
+
g(this, "start", async (o) => (this.stop(), this.prPlayer.start(o)));
|
|
2453
|
+
g(this, "stop", () => {
|
|
2458
2454
|
this.prPlayer.stop(), this.usersMap = /* @__PURE__ */ new Map(), this.room.roomId = "", this.room.author = "", this.room.updateTime = "", this.room.version = "";
|
|
2459
2455
|
});
|
|
2460
|
-
|
|
2456
|
+
g(this, "setMute", (o) => {
|
|
2461
2457
|
this.prPlayer.setMute(o);
|
|
2462
2458
|
});
|
|
2463
|
-
|
|
2464
|
-
|
|
2459
|
+
g(this, "getStream", () => this.prPlayer.getStream());
|
|
2460
|
+
g(this, "getAllUseUpdateKey", () => {
|
|
2465
2461
|
const o = [...this.usersMap.values()];
|
|
2466
2462
|
return Array.from(o, (u) => u.updateTime).join("_");
|
|
2467
2463
|
});
|
|
2468
|
-
|
|
2464
|
+
g(this, "checkAndCreateUser", (o, a) => {
|
|
2469
2465
|
var u, r;
|
|
2470
2466
|
if (this.usersMap.has(o)) {
|
|
2471
2467
|
const n = this.usersMap.get(o);
|
|
@@ -2498,10 +2494,10 @@ class QuickVoPlayer {
|
|
|
2498
2494
|
/**
|
|
2499
2495
|
* 监听SEI信息
|
|
2500
2496
|
*/
|
|
2501
|
-
|
|
2497
|
+
g(this, "onSEI", (o) => {
|
|
2502
2498
|
try {
|
|
2503
2499
|
const a = parseSEI(o);
|
|
2504
|
-
if (!a) return;
|
|
2500
|
+
if (console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", "------->Breathe: onSEI", a), !a) return;
|
|
2505
2501
|
const { event: u, data: r } = a;
|
|
2506
2502
|
switch (u) {
|
|
2507
2503
|
case 0:
|
|
@@ -2520,7 +2516,7 @@ class QuickVoPlayer {
|
|
|
2520
2516
|
}
|
|
2521
2517
|
const s = this.getAllUseUpdateKey();
|
|
2522
2518
|
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:
|
|
2519
|
+
const l = [...this.usersMap.values()], c = Array.from(l, ({ userId: d, mc_audio: p, mc_video: f, ss_audio: w, ss_video: b, updateTime: m }) => ({ userId: d, mc_audio: p, mc_video: f, ss_audio: w, ss_video: b, updateTime: m }));
|
|
2524
2520
|
this.on.users(c);
|
|
2525
2521
|
}
|
|
2526
2522
|
}
|
|
@@ -2536,7 +2532,7 @@ class QuickVoPlayer {
|
|
|
2536
2532
|
console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", "------->onSEI: error", a);
|
|
2537
2533
|
}
|
|
2538
2534
|
});
|
|
2539
|
-
|
|
2535
|
+
g(this, "setDisplayMode", (o) => {
|
|
2540
2536
|
var a, u, r, n, i, t, e, s;
|
|
2541
2537
|
switch (this.displayMode = o, o) {
|
|
2542
2538
|
case "original":
|