filesbox/web/dist/design/designstatic/chatroom/video/flv.js

9 lines
168 KiB
JavaScript
Raw Permalink Normal View History

2024-07-26 06:10:54 +00:00
(function(fe){if(typeof exports=="object"&&typeof module!="undefined")module.exports=fe();else if(typeof define=="function"&&define.amd)define([],fe);else{var de;typeof window!="undefined"?de=window:typeof global!="undefined"?de=global:typeof self!="undefined"?de=self:de=this,de.flvjs=fe()}})(function(){var fe,de,ke;return function L(j,A,R){function F(h,t){if(!A[h]){if(!j[h]){var e=typeof require=="function"&&require;if(!t&&e)return e(h,!0);if(T)return T(h,!0);var n=new Error("Cannot find module '"+h+"'");throw n.code="MODULE_NOT_FOUND",n}var u=A[h]={exports:{}};j[h][0].call(u.exports,function(s){var i=j[h][1][s];return F(i||s)},u,u.exports,L,j,A,R)}return A[h].exports}for(var T=typeof require=="function"&&require,f=0;f<R.length;f++)F(R[f]);return F}({1:[function(L,j,A){(function(R,F){/*!
* @overview es6-promise - a tiny implementation of Promises/A+.
* @copyright Copyright (c) 2014 Yehuda Katz, Tom Dale, Stefan Penner and contributors (Conversion to ES6 API by Jake Archibald)
* @license Licensed under MIT license
* See https://raw.githubusercontent.com/stefanpenner/es6-promise/master/LICENSE
* @version 4.1.0
*/(function(T,f){typeof A=="object"&&typeof j!="undefined"?j.exports=f():typeof fe=="function"&&fe.amd?fe(f):T.ES6Promise=f()})(this,function(){"use strict";function T(w){return typeof w=="function"||typeof w=="object"&&w!==null}function f(w){return typeof w=="function"}var h=void 0;Array.isArray?h=Array.isArray:h=function(w){return Object.prototype.toString.call(w)==="[object Array]"};var t=h,e=0,n=void 0,u=void 0,s=function(M,B){k[e]=M,k[e+1]=B,e+=2,e===2&&(u?u(C):m())};function i(w){u=w}function E(w){s=w}var _=typeof window!="undefined"?window:void 0,v=_||{},d=v.MutationObserver||v.WebKitMutationObserver,a=typeof self=="undefined"&&typeof R!="undefined"&&{}.toString.call(R)==="[object process]",r=typeof Uint8ClampedArray!="undefined"&&typeof importScripts!="undefined"&&typeof MessageChannel!="undefined";function c(){return function(){return R.nextTick(C)}}function l(){return typeof n!="undefined"?function(){n(C)}:x()}function g(){var w=0,M=new d(C),B=document.createTextNode("");return M.observe(B,{characterData:!0}),function(){B.data=w=++w%2}}function y(){var w=new MessageChannel;return w.port1.onmessage=C,function(){return w.port2.postMessage(0)}}function x(){var w=setTimeout;return function(){return w(C,1)}}var k=new Array(1e3);function C(){for(var w=0;w<e;w+=2){var M=k[w],B=k[w+1];M(B),k[w]=void 0,k[w+1]=void 0}e=0}function S(){try{var w=L,M=w("vertx");return n=M.runOnLoop||M.runOnContext,l()}catch(B){return x()}}var m=void 0;a?m=c():d?m=g():r?m=y():_===void 0&&typeof L=="function"?m=S():m=x();function o(w,M){var B=arguments,z=this,Q=new this.constructor(O);Q[b]===void 0&&ve(Q);var Z=z._state;return Z?function(){var ae=B[Z-1];s(function(){return ue(Z,Q,ae,z._result)})}():se(z,Q,w,M),Q}function p(w){var M=this;if(w&&typeof w=="object"&&w.constructor===M)return w;var B=new M(O);return X(B,w),B}var b=Math.random().toString(36).substring(16);function O(){}var I=void 0,P=1,G=2,D=new ee;function V(){return new TypeError("You cannot resolve a promise with itself")}function U(){return new TypeError("A promises callback cannot return that same promise.")}function q(w){try{return w.then}catch(M){return D.error=M,D}}function N(w,M,B,z){try{w.call(M,B,z)}catch(Q){return Q}}function J(w,M,B){s(function(z){var Q=!1,Z=N(B,M,function(ae){Q||(Q=!0,M!==ae?X(z,ae):Y(z,ae))},function(ae){Q||(Q=!0,H(z,ae))},"Settle: "+(z._label||" unknown promise"));!Q&&Z&&(Q=!0,H(z,Z))},w)}function $(w,M){M._state===P?Y(w,M._result):M._state===G?H(w,M._result):se(M,void 0,function(B){return X(w,B)},function(B){return H(w,B)})}function W(w,M,B){M.constructor===w.constructor&&B===o&&M.constructor.resolve===p?$(w,M):B===D?(H(w,D.error),D.error=null):B===void 0?Y(w,M):f(B)?J(w,M,B):Y(w,M)}function X(w,M){w===M?H(w,V()):T(M)?W(w,M,q(M)):Y(w,M)}function K(w){w._onerror&&w._onerror(w._result),re(w)}function Y(w,M){w._state===I&&(w._result=M,w._state=P,w._subscribers.length!==0&&s(re,w))}function H(w,M){w._state===I&&(w._state=G,w._result=M,s(K,w))}function se(w,M,B,z){var Q=w._subscribers,Z=Q.length;w._onerror=null,Q[Z]=M,Q[Z+P]=B,Q[Z+G]=z,Z===0&&w._state&&s(re,w)}function re(w){var M=w._subscribers,B=w._state;if(M.length!==0){for(var z=void 0,Q=void 0,Z=w._result,ae=0;ae<M.length;ae+=3)z=M[ae],Q=M[ae+B],z?ue(B,z,Q,Z):Q(Z);w._subscribers.length=0}}function ee(){this.error=null}var ie=new ee;function he(w,M){try{return w(M)}catch(B){return ie.error=B,ie}}function ue(w,M,B,z){var Q=f(B),Z=void 0,ae=void 0,Se=void 0,be=void 0;if(Q){if(Z=he(B,z),Z===ie?(be=!0,ae=Z.error,Z.error=null):Se=!0,M===Z){H(M,U());return}}else Z=z,Se=!0;M._state!==I||(Q&&Se?X(M,Z):be?H(M,ae):w===P?Y(M,Z):w===G&&H(M,Z))}function te(w,M){try{M(function(z){X(w,z)},function(z){H(w,z)})}catch(B){H(w,B)}}var oe=0;function ce(){return oe++}function ve(w){w[b]=oe++,w._state=void 0,w._result=void 0,w._subscribers=[]}function le(w,M){this._instanceConstructor=w,this.promise=new w(O),this.promise[b]||ve(this.promise),t(M)?(this._input=M,this.length=M.length,this._remaining=M.length,this._result=new Array(this.length),this.length===0?Y(this.promise,this._result):(this.length=this.length||0,this._e
`+("dts: "+(ee+ie)+" ms, expected: "+(ee+Math.round(S))+" ms, ")+("delta: "+Math.round(ce)+" ms, generate: "+ve+" frames"));var _e=e.default.getSilentFrame(this._audioMeta.originalCodec,this._audioMeta.channelCount);_e==null&&(T.default.w(this.TAG,"Unable to generate silent frame for "+(this._audioMeta.originalCodec+" with "+this._audioMeta.channelCount+" channels, repeat last frame")),_e=se),oe=[];for(var ge=0;ge<ve;ge++){var me=Math.round(le);if(oe.length>0){var pe=oe[oe.length-1];pe.duration=me-pe.dts}var Ee={dts:me,pts:me,cts:0,unit:_e,size:_e.byteLength,duration:0,originalDts:re,flags:{isLeading:0,dependsOn:1,isDependedOn:0,hasRedundancy:0}};oe.push(Ee),I+=se.byteLength,le+=S}var ye=oe[oe.length-1];ye.duration=ee+ie-ye.dts,ie=Math.round(S)}K.push({dts:ee,pts:ee,cts:0,unit:H.unit,size:H.unit.byteLength,duration:ie,originalDts:re,flags:{isLeading:0,dependsOn:1,isDependedOn:0,hasRedundancy:0}}),te&&K.push.apply(K,oe)}m?O=new Uint8Array(I):(O=new Uint8Array(I),O[0]=I>>>24&255,O[1]=I>>>16&255,O[2]=I>>>8&255,O[3]=I&255,O.set(h.default.types.mdat,4));for(var ne=0;ne<K.length;ne++){var xe=K[ne].unit;O.set(xe,b),b+=xe.byteLength}var w=K[K.length-1];k=w.dts+w.duration,this._audioNextDts=k;var M=new s.MediaSegmentInfo;M.beginDts=x,M.endDts=k,M.beginPts=x,M.endPts=k,M.originalBeginDts=K[0].originalDts,M.originalEndDts=w.originalDts+w.duration,M.firstSample=new s.SampleInfo(K[0].dts,K[0].pts,K[0].duration,K[0].originalDts,!1),M.lastSample=new s.SampleInfo(w.dts,w.pts,w.duration,w.originalDts,!1),this._isLive||this._audioSegmentInfoList.append(M),l.samples=K,l.sequenceNumber++;var B=null;m?B=new Uint8Array:B=h.default.moof(l,x),l.samples=[],l.length=0;var z={type:"audio",data:this._mergeBoxes(B,O).buffer,sampleCount:K.length,info:M};m&&o&&(z.timestampOffset=x),this._onMediaSegment("audio",z)}}}},{key:"_remuxVideo",value:function(r,c){if(this._videoMeta!=null){var l=r,g=l.samples,y=void 0,x=-1,k=-1,C=-1,S=-1;if(!(!g||g.length===0)&&!(g.length===1&&!c)){var m=8,o=null,p=8+r.length,b=null;if(g.length>1&&(b=g.pop(),p-=b.length),this._videoStashedLastSample!=null){var O=this._videoStashedLastSample;this._videoStashedLastSample=null,g.unshift(O),p+=O.length}b!=null&&(this._videoStashedLastSample=b);var I=g[0].dts-this._dtsBase;if(this._videoNextDts)y=I-this._videoNextDts;else if(this._videoSegmentInfoList.isEmpty())y=0;else{var P=this._videoSegmentInfoList.getLastSampleBefore(I);if(P!=null){var G=I-(P.originalDts+P.duration);G<=3&&(G=0);var D=P.dts+P.duration+G;y=I-D}else y=0}for(var V=new s.MediaSegmentInfo,U=[],q=0;q<g.length;q++){var N=g[q],J=N.dts-this._dtsBase,$=N.isKeyframe,W=J-y,X=N.cts,K=W+X;x===-1&&(x=W,C=K);var Y=0;if(q!==g.length-1){var H=g[q+1].dts-this._dtsBase-y;Y=H-W}else if(b!=null){var se=b.dts-this._dtsBase-y;Y=se-W}else U.length>=1?Y=U[U.length-1].duration:Y=Math.floor(this._videoMeta.refSampleDuration);if($){var re=new s.SampleInfo(W,K,Y,N.dts,!0);re.fileposition=N.fileposition,V.appendSyncPoint(re)}U.push({dts:W,pts:K,cts:X,units:N.units,size:N.length,isKeyframe:$,duration:Y,originalDts:J,flags:{isLeading:0,dependsOn:$?2:1,isDependedOn:$?1:0,hasRedundancy:0,isNonSync:$?0:1}})}o=new Uint8Array(p),o[0]=p>>>24&255,o[1]=p>>>16&255,o[2]=p>>>8&255,o[3]=p&255,o.set(h.default.types.mdat,4);for(var ee=0;ee<U.length;ee++)for(var ie=U[ee].units;ie.length;){var he=ie.shift(),ue=he.data;o.set(ue,m),m+=ue.byteLength}var te=U[U.length-1];if(k=te.dts+te.duration,S=te.pts+te.duration,this._videoNextDts=k,V.beginDts=x,V.endDts=k,V.beginPts=C,V.endPts=S,V.originalBeginDts=U[0].originalDts,V.originalEndDts=te.originalDts+te.duration,V.firstSample=new s.SampleInfo(U[0].dts,U[0].pts,U[0].duration,U[0].originalDts,U[0].isKeyframe),V.lastSample=new s.SampleInfo(te.dts,te.pts,te.duration,te.originalDts,te.isKeyframe),this._isLive||this._videoSegmentInfoList.append(V),l.samples=U,l.sequenceNumber++,this._forceFirstIDR){var oe=U[0].flags;oe.dependsOn=2,oe.isNonSync=0}var ce=h.default.moof(l,x);l.samples=[],l.length=0,this._onMediaSegment("video",{type:"video",data:this._mergeBoxes(ce,o).buffer,sampleCount:U.length,info:V})}}}},{key:"_mergeB