3 lines
166 KiB
JavaScript
3 lines
166 KiB
JavaScript
|
(function(ce){if(typeof exports=="object"&&typeof module!="undefined")module.exports=ce();else if(typeof define=="function"&&define.amd)define([],ce);else{var w;w=typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:this,w.flvjs=ce()}})(function(){var ce;return function w(j,R,k){function C(i,e){if(!R[i]){if(!j[i]){var t=typeof require=="function"&&require;if(!e&&t)return t(i,!0);if(I)return I(i,!0);var r=new Error("Cannot find module '"+i+"'");throw r.code="MODULE_NOT_FOUND",r}var s=R[i]={exports:{}};j[i][0].call(s.exports,function(c){var g=j[i][1][c];return C(g||c)},s,s.exports,w,j,R,k)}return R[i].exports}for(var I=typeof require=="function"&&require,a=0;a<k.length;a++)C(k[a]);return C}({1:[function(w,j,R){(function(k,C){(function(I,a){typeof R=="object"&&j!==void 0?j.exports=a():typeof ce=="function"&&ce.amd?ce(a):I.ES6Promise=a()})(this,function(){"use strict";function I(T){var x=typeof T;return T!==null&&(x==="object"||x==="function")}function a(T){return typeof T=="function"}function i(T){Q=T}function e(T){ne=T}function t(){return $!==void 0?function(){$(s)}:r()}function r(){var T=setTimeout;return function(){return T(s,1)}}function s(){for(var T=0;T<V;T+=2)(0,Y[T])(Y[T+1]),Y[T]=void 0,Y[T+1]=void 0;V=0}function c(T,x){var M=this,F=new this.constructor(d);F[ue]===void 0&&B(F);var G=M._state;if(G){var W=arguments[G-1];ne(function(){return O(G,F,W,M._result)})}else L(M,F,T,x);return F}function g(T){var x=this;if(T&&typeof T=="object"&&T.constructor===x)return T;var M=new x(d);return v(M,T),M}function d(){}function _(){return new TypeError("You cannot resolve a promise with itself")}function p(){return new TypeError("A promises callback cannot return that same promise.")}function f(T){try{return T.then}catch(x){return he.error=x,he}}function n(T,x,M,F){try{T.call(x,M,F)}catch(G){return G}}function m(T,x,M){ne(function(F){var G=!1,W=n(M,x,function(ie){G||(G=!0,x!==ie?v(F,ie):b(F,ie))},function(ie){G||(G=!0,S(F,ie))},"Settle: "+(F._label||" unknown promise"));!G&&W&&(G=!0,S(F,W))},T)}function o(T,x){x._state===se?b(T,x._result):x._state===de?S(T,x._result):L(x,void 0,function(M){return v(T,M)},function(M){return S(T,M)})}function u(T,x,M){x.constructor===T.constructor&&M===c&&x.constructor.resolve===g?o(T,x):M===he?(S(T,he.error),he.error=null):M===void 0?b(T,x):a(M)?m(T,x,M):b(T,x)}function v(T,x){T===x?S(T,_()):I(x)?u(T,x,f(x)):b(T,x)}function y(T){T._onerror&&T._onerror(T._result),l(T)}function b(T,x){T._state===le&&(T._result=x,T._state=se,T._subscribers.length!==0&&ne(l,T))}function S(T,x){T._state===le&&(T._state=de,T._result=x,ne(y,T))}function L(T,x,M,F){var G=T._subscribers,W=G.length;T._onerror=null,G[W]=x,G[W+se]=M,G[W+de]=F,W===0&&T._state&&ne(l,T)}function l(T){var x=T._subscribers,M=T._state;if(x.length!==0){for(var F=void 0,G=void 0,W=T._result,ie=0;ie<x.length;ie+=3)F=x[ie],G=x[ie+M],F?O(M,F,G,W):G(W);T._subscribers.length=0}}function h(){this.error=null}function E(T,x){try{return T(x)}catch(M){return _e.error=M,_e}}function O(T,x,M,F){var G=a(M),W=void 0,ie=void 0,me=void 0,ge=void 0;if(G){if(W=E(M,F),W===_e?(ge=!0,ie=W.error,W.error=null):me=!0,x===W)return void S(x,p())}else W=F,me=!0;x._state!==le||(G&&me?v(x,W):ge?S(x,ie):T===se?b(x,W):T===de&&S(x,W))}function A(T,x){try{x(function(M){v(T,M)},function(M){S(T,M)})}catch(M){S(T,M)}}function D(){return pe++}function B(T){T[ue]=pe++,T._state=void 0,T._result=void 0,T._subscribers=[]}function U(){return new Error("Array Methods must be provided an Array")}function U(){return new Error("Array Methods must be provided an Array")}function P(T){return new ve(this,T).promise}function K(T){var x=this;return new x(z(T)?function(M,F){for(var G=T.length,W=0;W<G;W++)x.resolve(T[W]).then(M,F)}:function(M,F){return F(new TypeError("You must pass an array to race."))})}function H(T){var x=this,M=new x(d);return S(M,T),M}function q(){throw new TypeError("You must pass a resolver function as the first argument to the promise constructor")}function N(){throw new TypeError("Failed to construct 'Promise': Please use the 'new'
|
||
|
dts: `+(ee+J)+" ms, expected: "+(ee+Math.round(S))+" ms, delta: "+Math.round(fe)+" ms, generate: "+ue+" frames");var se=s.default.getSilentFrame(this._audioMeta.originalCodec,this._audioMeta.channelCount);se==null&&(i.default.w(this.TAG,"Unable to generate silent frame for "+this._audioMeta.originalCodec+" with "+this._audioMeta.channelCount+" channels, repeat last frame"),se=ne),Y=[];for(var de=0;de<ue;de++){var he=Math.round(le);if(Y.length>0){var _e=Y[Y.length-1];_e.duration=he-_e.dts}var pe={dts:he,pts:he,cts:0,unit:se,size:se.byteLength,duration:0,originalDts:re,flags:{isLeading:0,dependsOn:1,isDependedOn:0,hasRedundancy:0}};Y.push(pe),A+=ne.byteLength,le+=S}var ve=Y[Y.length-1];ve.duration=ee+J-ve.dts,J=Math.round(S)}V.push({dts:ee,pts:ee,cts:0,unit:Q.unit,size:Q.unit.byteLength,duration:J,originalDts:re,flags:{isLeading:0,dependsOn:1,isDependedOn:0,hasRedundancy:0}}),oe&&V.push.apply(V,Y)}L?O=new Uint8Array(A):(O=new Uint8Array(A),O[0]=A>>>24&255,O[1]=A>>>16&255,O[2]=A>>>8&255,O[3]=255&A,O.set(t.default.types.mdat,4));for(var te=0;te<V.length;te++){var T=V[te].unit;O.set(T,E),E+=T.byteLength}var x=V[V.length-1];b=x.dts+x.duration,this._audioNextDts=b;var M=new d.MediaSegmentInfo;M.beginDts=y,M.endDts=b,M.beginPts=y,M.endPts=b,M.originalBeginDts=V[0].originalDts,M.originalEndDts=x.originalDts+x.duration,M.firstSample=new d.SampleInfo(V[0].dts,V[0].pts,V[0].duration,V[0].originalDts,!1),M.lastSample=new d.SampleInfo(x.dts,x.pts,x.duration,x.originalDts,!1),this._isLive||this._audioSegmentInfoList.append(M),o.samples=V,o.sequenceNumber++;var F=null;F=L?new Uint8Array:t.default.moof(o,y),o.samples=[],o.length=0;var G={type:"audio",data:this._mergeBoxes(F,O).buffer,sampleCount:V.length,info:M};L&&l&&(G.timestampOffset=y),this._onMediaSegment("audio",G)}}}},{key:"_remuxVideo",value:function(n,m){if(this._videoMeta!=null){var o=n,u=o.samples,v=void 0,y=-1,b=-1,S=-1,L=-1;if(u&&u.length!==0&&(u.length!==1||m)){var l=8,h=null,E=8+n.length,O=null;if(u.length>1&&(O=u.pop(),E-=O.length),this._videoStashedLastSample!=null){var A=this._videoStashedLastSample;this._videoStashedLastSample=null,u.unshift(A),E+=A.length}O!=null&&(this._videoStashedLastSample=O);var D=u[0].dts-this._dtsBase;if(this._videoNextDts)v=D-this._videoNextDts;else if(this._videoSegmentInfoList.isEmpty())v=0;else{var B=this._videoSegmentInfoList.getLastSampleBefore(D);if(B!=null){var U=D-(B.originalDts+B.duration);U<=3&&(U=0);var P=B.dts+B.duration+U;v=D-P}else v=0}for(var K=new d.MediaSegmentInfo,H=[],q=0;q<u.length;q++){var N=u[q],Z=N.dts-this._dtsBase,X=N.isKeyframe,z=Z-v,V=N.cts,$=z+V;y===-1&&(y=z,S=$);var Q=0;if(q!==u.length-1)Q=u[q+1].dts-this._dtsBase-v-z;else if(O!=null){var ne=O.dts-this._dtsBase-v;Q=ne-z}else Q=H.length>=1?H[H.length-1].duration:Math.floor(this._videoMeta.refSampleDuration);if(X){var re=new d.SampleInfo(z,$,Q,N.dts,!0);re.fileposition=N.fileposition,K.appendSyncPoint(re)}H.push({dts:z,pts:$,cts:V,units:N.units,size:N.length,isKeyframe:X,duration:Q,originalDts:Z,flags:{isLeading:0,dependsOn:X?2:1,isDependedOn:X?1:0,hasRedundancy:0,isNonSync:X?0:1}})}h=new Uint8Array(E),h[0]=E>>>24&255,h[1]=E>>>16&255,h[2]=E>>>8&255,h[3]=255&E,h.set(t.default.types.mdat,4);for(var ee=0;ee<H.length;ee++)for(var J=H[ee].units;J.length;){var ae=J.shift(),oe=ae.data;h.set(oe,l),l+=oe.byteLength}var Y=H[H.length-1];if(b=Y.dts+Y.duration,L=Y.pts+Y.duration,this._videoNextDts=b,K.beginDts=y,K.endDts=b,K.beginPts=S,K.endPts=L,K.originalBeginDts=H[0].originalDts,K.originalEndDts=Y.originalDts+Y.duration,K.firstSample=new d.SampleInfo(H[0].dts,H[0].pts,H[0].duration,H[0].originalDts,H[0].isKeyframe),K.lastSample=new d.SampleInfo(Y.dts,Y.pts,Y.duration,Y.originalDts,Y.isKeyframe),this._isLive||this._videoSegmentInfoList.append(K),o.samples=H,o.sequenceNumber++,this._forceFirstIDR){var fe=H[0].flags;fe.dependsOn=2,fe.isNonSync=0}var ue=t.default.moof(o,y);o.samples=[],o.length=0,this._onMediaSegment("video",{type:"video",data:this._mergeBoxes(ue,h).buffer,sampleCount:H.length,info:K})}}}},{key:"_mergeBoxes",value:function(n,m){var o=new Uint8Array(n.byteLength+m
|