2016-03-09 12:40:22 -05:00
! function ( e ) { if ( "object" == typeof exports && "undefined" != typeof module ) module . exports = e ( ) ; else if ( "function" == typeof define && define . amd ) define ( [ ] , e ) ; else { var t ; t = "undefined" != typeof window ? window : "undefined" != typeof global ? global : "undefined" != typeof self ? self : this , t . Hls = e ( ) } } ( function ( ) { return function s ( e , t , r ) { function n ( a , d ) { if ( ! t [ a ] ) { if ( ! e [ a ] ) { var l = "function" == typeof require && require ; if ( ! d && l ) return l ( a , ! 0 ) ; if ( i ) return i ( a , ! 0 ) ; var u = new Error ( "Cannot find module '" + a + "'" ) ; throw u . code = "MODULE_NOT_FOUND" , u } var o = t [ a ] = { exports : { } } ; e [ a ] [ 0 ] . call ( o . exports , function ( t ) { var r = e [ a ] [ 1 ] [ t ] ; return n ( r ? r : t ) } , o , o . exports , s , e , t , r ) } return t [ a ] . exports } for ( var i = "function" == typeof require && require , a = 0 ; a < r . length ; a ++ ) n ( r [ a ] ) ; return n } ( { 1 : [ function ( s , a , o ) { function e ( ) { this . _events = this . _events || { } , this . _maxListeners = this . _maxListeners || void 0 } function t ( e ) { return "function" == typeof e } function i ( e ) { return "number" == typeof e } function r ( e ) { return "object" == typeof e && null !== e } function n ( e ) { return void 0 === e } a . exports = e , e . EventEmitter = e , e . prototype . _events = void 0 , e . prototype . _maxListeners = void 0 , e . defaultMaxListeners = 10 , e . prototype . setMaxListeners = function ( e ) { if ( ! i ( e ) || 0 > e || isNaN ( e ) ) throw TypeError ( "n must be a positive number" ) ; return this . _maxListeners = e , this } , e . prototype . emit = function ( l ) { var s , e , u , a , i , o ; if ( this . _events || ( this . _events = { } ) , "error" === l && ( ! this . _events . error || r ( this . _events . error ) && ! this . _events . error . length ) ) { if ( s = arguments [ 1 ] , s instanceof Error ) throw s ; throw TypeError ( 'Uncaught, unspecified "error" event.' ) } if ( e = this . _events [ l ] , n ( e ) ) return ! 1 ; if ( t ( e ) ) switch ( arguments . length ) { case 1 : e . call ( this ) ; break ; case 2 : e . call ( this , arguments [ 1 ] ) ; break ; case 3 : e . call ( this , arguments [ 1 ] , arguments [ 2 ] ) ; break ; default : a = Array . prototype . slice . call ( arguments , 1 ) , e . apply ( this , a ) } else if ( r ( e ) ) for ( a = Array . prototype . slice . call ( arguments , 1 ) , o = e . slice ( ) , u = o . length , i = 0 ; u > i ; i ++ ) o [ i ] . apply ( this , a ) ; return ! 0 } , e . prototype . addListener = function ( a , i ) { var s ; if ( ! t ( i ) ) throw TypeError ( "listener must be a function" ) ; return this . _events || ( this . _events = { } ) , this . _events . newListener && this . emit ( "newListener" , a , t ( i . listener ) ? i . listener : i ) , this . _events [ a ] ? r ( this . _events [ a ] ) ? this . _events [ a ] . push ( i ) : this . _events [ a ] = [ this . _events [ a ] , i ] : this . _events [ a ] = i , r ( this . _events [ a ] ) && ! this . _events [ a ] . warned && ( s = n ( this . _maxListeners ) ? e . defaultMaxListeners : this . _maxListeners , s && s > 0 && this . _events [ a ] . length > s && ( this . _events [ a ] . warned = ! 0 , "function" == typeof console . trace ) ) , this } , e . prototype . on = e . prototype . addListener , e . prototype . once = function ( n , e ) { function r ( ) { this . removeListener ( n , r ) , a || ( a = ! 0 , e . apply ( this , arguments ) ) } if ( ! t ( e ) ) throw TypeError ( "listener must be a function" ) ; var a = ! 1 ; return r . listener = e , this . on ( n , r ) , this } , e . prototype . removeListener = function ( a , n ) { var e , s , o , i ; if ( ! t ( n ) ) throw TypeError ( "listener must be a function" ) ; if ( ! this . _events || ! this . _events [ a ] ) return this ; if ( e = this . _events [ a ] , o = e . length , s = - 1 , e === n || t ( e . listener ) && e . listener === n ) delete this . _events [ a ] , this . _events . removeListener && this . emit ( "removeListener" , a , n ) ; else if ( r ( e ) ) { for ( i = o ; i -- > 0 ; ) if ( e [ i ] === n || e [ i ] . listener && e [ i ] . listener === n ) { s = i ; break } if ( 0 > s ) return this ; 1 === e . length ? ( e . length = 0 , delete this . _events [ a ] ) : e . splice ( s , 1 ) , this . _events . removeListener && this . emit ( "removeListener" , a , n ) } return this } , e . prototype . removeAllListeners = function ( r ) { var n , e ; if ( ! this . _events ) return this ; if ( ! this . _events . removeListener ) return 0 === arguments . length ? this . _events = { } : this . _events [ r ] && delete this . _events [ r ] , this ; if ( 0 === arguments . length ) { for ( n in this . _events ) "removeListener" !== n && this . removeAllListeners ( n ) ; return this . removeAllListeners ( "removeListener" ) , this . _events = { } , this } if ( e = this . _events [ r ] , t ( e ) ) this . removeListener ( r , e ) ; else if ( e ) for ( ; e . length ; ) this . removeListener ( r , e [ e . length - 1 ] ) ; return delete this . _events [ r ] , this } , e . prototype . listeners = function ( e ) { var r ; return r = this . _events && this . _events [ e ] ? t ( this . _events [ e ] ) ? [ this . _events [ e ] ] : this . _events [ e ] . slice ( ) : [ ] } , e . prototype . listenerCount = function ( r ) { if ( this . _events ) { var e = this . _events [ r ] ; if ( t ( e ) ) return 1 ; if ( e ) return e . length } return 0 } , e . listenerCount = function ( e , t ) { return e . listenerCount ( t ) } } , { } ]
2016-03-10 12:59:32 -05:00
details : n , level : a } ) , this . startFragRequested === ! 1 ) { if ( n . live ) { var f = void 0 !== this . config . liveSyncDuration ? this . config . liveSyncDuration : this . config . liveSyncDurationCount * n . targetduration ; this . startPosition = Math . max ( 0 , i + u - f ) } this . nextLoadPosition = this . startPosition } this . state === e . WAITING _LEVEL && ( this . state = e . IDLE ) , this . tick ( ) } } , { key : "onKeyLoaded" , value : function ( ) { this . state === e . KEY _LOADING && ( this . state = e . IDLE , this . tick ( ) ) } } , { key : "onFragLoaded" , value : function ( a ) { var n = this . fragCurrent ; if ( this . state === e . FRAG _LOADING && n && a . frag . level === n . level && a . frag . sn === n . sn ) if ( this . fragBitrateTest === ! 0 ) this . state = e . IDLE , this . fragBitrateTest = ! 1 , a . stats . tparsed = a . stats . tbuffered = performance . now ( ) , this . hls . trigger ( r . default . FRAG _BUFFERED , { stats : a . stats , frag : n } ) ; else { this . state = e . PARSING , this . stats = a . stats ; var s = this . levels [ this . level ] , o = s . details , d = o . totalduration , f = n . start , l = n . level , u = n . sn , i = s . audioCodec || this . config . defaultAudioCodec ; this . audioCodecSwap && ( t . logger . log ( "swapping playlist audio codec" ) , void 0 === i && ( i = this . lastAudioCodec ) , i && ( i = - 1 !== i . indexOf ( "mp4a.40.5" ) ? "mp4a.40.2" : "mp4a.40.5" ) ) , this . pendingAppending = 0 , t . logger . log ( "Demuxing " + u + " of [" + o . startSN + " ," + o . endSN + "],level " + l ) , this . demuxer . push ( a . payload , i , s . videoCodec , f , n . cc , l , u , d , n . decryptdata ) } this . fragLoadError = 0 } } , { key : "onFragParsingInitSegment" , value : function ( l ) { if ( this . state === e . PARSING ) { var o , n , a = l . tracks ; if ( n = a . audio ) { var i = this . levels [ this . level ] . audioCodec , u = navigator . userAgent . toLowerCase ( ) ; i && this . audioCodecSwap && ( t . logger . log ( "swapping playlist audio codec" ) , i = - 1 !== i . indexOf ( "mp4a.40.5" ) ? "mp4a.40.2" : "mp4a.40.5" ) , this . audioCodecSwitch && 1 !== n . metadata . channelCount && - 1 === u . indexOf ( "firefox" ) && ( i = "mp4a.40.5" ) , - 1 !== u . indexOf ( "android" ) && ( i = "mp4a.40.2" , t . logger . log ( "Android: force audio codec to" + i ) ) , n . levelCodec = i } if ( n = a . video , n && ( n . levelCodec = this . levels [ this . level ] . videoCodec ) , l . unique ) { var s = { codec : "" , levelCodec : "" } ; for ( o in l . tracks ) n = a [ o ] , s . container = n . container , s . codec && ( s . codec += "," , s . levelCodec += "," ) , n . codec && ( s . codec += n . codec ) , n . levelCodec && ( s . levelCodec += n . levelCodec ) ; a = { audiovideo : s } } this . hls . trigger ( r . default . BUFFER _CODECS , a ) ; for ( o in a ) { n = a [ o ] , t . logger . log ( "track:" + o + ",container:" + n . container + ",codecs[level/parsed]=[" + n . levelCodec + "/" + n . codec + "]" ) ; var d = n . initSegment ; d && ( this . pendingAppending ++ , this . hls . trigger ( r . default . BUFFER _APPENDING , { type : o , data : d } ) ) } this . tick ( ) } } } , { key : "onFragParsingData" , value : function ( n ) { var o = this ; if ( this . state === e . PARSING ) { this . tparse2 = Date . now ( ) ; var a = this . levels [ this . level ] , i = this . fragCurrent ; t . logger . log ( "parsed " + n . type + ",PTS:[" + n . startPTS . toFixed ( 3 ) + "," + n . endPTS . toFixed ( 3 ) + "],DTS:[" + n . startDTS . toFixed ( 3 ) + "/" + n . endDTS . toFixed ( 3 ) + "],nb:" + n . nb ) ; var u = l . default . updateFragPTS ( a . details , i . sn , n . startPTS , n . endPTS ) , s = this . hls ; s . trigger ( r . default . LEVEL _PTS _UPDATED , { details : a . details , level : this . level , drift : u } ) , [ n . data1 , n . data2 ] . forEach ( function ( e ) { e && ( o . pendingAppending ++ , s . trigger ( r . default . BUFFER _APPENDING , { type : n . type , data : e } ) ) } ) , this . nextLoadPosition = n . endPTS , this . bufferRange . push ( { type : n . type , start : n . startPTS , end : n . endPTS , frag : i } ) , this . tick ( ) } else t . logger . warn ( "not in PARSING state but " + this . state + ", ignoring FRAG_PARSING_DATA event" ) } } , { key : "onFragParsed" , value : function ( ) { this . state === e . PARSING && ( this . stats . tparsed = performance . now ( ) , this . state = e . PARSED , this . _checkAppendedParsed ( ) ) } } , { key : "onBufferAppended" , value : function ( ) { switch ( this . state ) { case e . PARSING : case e . PARSED : this . pendingAppending -- , this . _checkAppendedParsed ( ) } } } , { key : "_checkAppendedParsed" , value : function ( ) { if ( this . state === e . PARSED && 0 === this . pendingAppending ) { var a = this . fragCurrent , n = this . stats ; a && ( this . fragPrevious = a , n . tbuffered = performance . now ( ) , this . fragLastKbps = Math . round ( 8 * n . length / ( n . tbuffered - n . tfirst ) ) , this . hls . trigger ( r . default . FRAG _BUFFERED , { stats : n , frag : a } ) , t . logger . log ( "media buffered : " + this . timeRangesToString ( this . media . buffered ) ) , this . state = e . IDLE ) , this . tick ( ) } } } , { key : "onError" , value : function ( a ) { switch ( a . details ) { case n . ErrorDetails . FRAG _LOAD _ERROR : case n . ErrorDetails . FRAG _LOAD _TIMEOUT : if ( ! a . fatal ) { var i = this . fragLoadError ; if ( i ? i ++ : i = 1 , i <= this . config .
this . lastSN = E , this . contiguous || ( this . aacOverFlow = null ) ; var v = this . pmtParsed , h = this . _avcTrack . id , f = this . _aacTrack . id , g = this . _id3Track . id ; for ( c -= c % 188 , t = 0 ; c > t ; t += 188 ) if ( 71 === n [ t ] ) { if ( d = ! ! ( 64 & n [ t + 1 ] ) , u = ( ( 31 & n [ t + 1 ] ) << 8 ) + n [ t + 2 ] , y = ( 48 & n [ t + 3 ] ) >> 4 , y > 1 ) { if ( a = t + 5 + n [ t + 4 ] , a === t + 188 ) continue } else a = t + 4 ; if ( v ) if ( u === h ) { if ( d ) { if ( s && ( this . _parseAVCPES ( this . _parsePES ( s ) ) , b && this . _avcTrack . codec && ( - 1 === f || this . _aacTrack . codec ) ) ) return void this . remux ( n ) ; s = { data : [ ] , size : 0 } } s && ( s . data . push ( n . subarray ( a , t + 188 ) ) , s . size += t + 188 - a ) } else if ( u === f ) { if ( d ) { if ( o && ( this . _parseAACPES ( this . _parsePES ( o ) ) , b && this . _aacTrack . codec && ( - 1 === h || this . _avcTrack . codec ) ) ) return void this . remux ( n ) ; o = { data : [ ] , size : 0 } } o && ( o . data . push ( n . subarray ( a , t + 188 ) ) , o . size += t + 188 - a ) } else u === g && ( d && ( l && this . _parseID3PES ( this . _parsePES ( l ) ) , l = { data : [ ] , size : 0 } ) , l && ( l . data . push ( n . subarray ( a , t + 188 ) ) , l . size += t + 188 - a ) ) ; else d && ( a += n [ a ] + 1 ) , 0 === u ? this . _parsePAT ( n , a ) : u === this . _pmtId && ( this . _parsePMT ( n , a ) , v = this . pmtParsed = ! 0 , h = this . _avcTrack . id , f = this . _aacTrack . id , g = this . _id3Track . id ) } else this . observer . trigger ( i . default . ERROR , { type : r . ErrorTypes . MEDIA _ERROR , details : r . ErrorDetails . FRAG _PARSING _ERROR , fatal : ! 1 , reason : "TS packet did not start with 0x47" } ) ; s && this . _parseAVCPES ( this . _parsePES ( s ) ) , o && this . _parseAACPES ( this . _parsePES ( o ) ) , l && this . _parseID3PES ( this . _parsePES ( l ) ) , this . remux ( null ) } } , { key : "remux" , value : function ( e ) { this . remuxer . remux ( this . _aacTrack , this . _avcTrack , this . _id3Track , this . _txtTrack , this . timeOffset , this . contiguous , e ) } } , { key : "destroy" , value : function ( ) { this . switchLevel ( ) , this . _initPTS = this . _initDTS = void 0 , this . _duration = 0 } } , { key : "_parsePAT" , value : function ( e , t ) { this . _pmtId = ( 31 & e [ t + 10 ] ) << 8 | e [ t + 11 ] } } , { key : "_parsePMT" , value : function ( r , t ) { var a , i , s , n ; for ( a = ( 15 & r [ t + 1 ] ) << 8 | r [ t + 2 ] , i = t + 3 + a - 4 , s = ( 15 & r [ t + 10 ] ) << 8 | r [ t + 11 ] , t += 12 + s ; i > t ; ) { switch ( n = ( 31 & r [ t + 1 ] ) << 8 | r [ t + 2 ] , r [ t ] ) { case 15 : this . _aacTrack . id = n ; break ; case 21 : this . _id3Track . id = n ; break ; case 27 : this . _avcTrack . id = n ; break ; default : e . logger . log ( "unkown stream type:" + r [ t ] ) } t += ( ( 15 & r [ t + 3 ] ) << 8 | r [ t + 4 ] ) + 5 } } } , { key : "_parsePES" , value : function ( o ) { var e , i , h , d , u , l , n , r , t , f = 0 , s = o . data ; if ( e = s [ 0 ] , h = ( e [ 0 ] << 16 ) + ( e [ 1 ] << 8 ) + e [ 2 ] , 1 === h ) { for ( d = ( e [ 4 ] << 8 ) + e [ 5 ] , i = e [ 7 ] , 192 & i && ( n = 536870912 * ( 14 & e [ 9 ] ) + 4194304 * ( 255 & e [ 10 ] ) + 16384 * ( 254 & e [ 11 ] ) + 128 * ( 255 & e [ 12 ] ) + ( 254 & e [ 13 ] ) / 2 , n > 4294967295 && ( n -= 8589934592 ) , 64 & i ? ( r = 536870912 * ( 14 & e [ 14 ] ) + 4194304 * ( 255 & e [ 15 ] ) + 16384 * ( 254 & e [ 16 ] ) + 128 * ( 255 & e [ 17 ] ) + ( 254 & e [ 18 ] ) / 2 , r > 4294967295 && ( r -= 8589934592 ) ) : r = n ) , u = e [ 8 ] , t = u + 9 , o . size -= t , l = new Uint8Array ( o . size ) ; s . length ; ) { e = s . shift ( ) ; var a = e . byteLength ; if ( t ) { if ( t > a ) { t -= a ; continue } e = e . subarray ( t ) , a -= t , t = 0 } l . set ( e , f ) , f += a } return { data : l , pts : n , dts : r , len : d } } return null } } , { key : "_parseAVCPES" , value : function ( n ) { var t , y , i , l , f = this , r = this . _avcTrack , u = r . samples , m = this . _parseAVCNALu ( n . data ) , d = [ ] , o = ! 1 , c = ! 1 , g = 0 ; if ( 0 === m . length && u . length > 0 ) { var v = u [ u . length - 1 ] , h = v . units . units [ v . units . units . length - 1 ] , p = new Uint8Array ( h . data . byteLength + n . data . byteLength ) ; p . set ( h . data , 0 ) , p . set ( n . data , h . data . byteLength ) , h . data = p , v . units . length += n . data . byteLength , r . len += n . data . byteLength } n . data = null ; var a = "" ; m . forEach ( function ( e ) { switch ( e . type ) { case 1 : i = ! 0 , o && ( a += "NDR " ) ; break ; case 5 : i = ! 0 , o && ( a += "IDR " ) , c = ! 0 ; break ; case 6 : i = ! 0 , o && ( a += "SEI " ) , t = new s . default ( e . data ) , t . readUByte ( ) ; var E = t . readUByte ( ) ; if ( 4 === E ) { var p = 0 ; do p = t . readUByte ( ) ; while ( 255 === p ) ; var R = t . readUByte ( ) ; if ( 181 === R ) { var _ = t . readUShort ( ) ; if ( 49 === _ ) { var A = t . readUInt ( ) ; if ( 1195456820 === A ) { var L = t . readUByte ( ) ; if ( 3 === L ) { var v = t . readUByte ( ) , b = t . readUByte ( ) , S = 31 & v , h = [ v , b ] ; for ( l = 0 ; S > l ; l ++ ) h . push ( t . readUByte ( ) ) , h . push ( t . readUByte ( ) ) , h . push ( t . readUByte ( ) ) ; f . _txtTrack . samples . push ( { type : 3 , pts : n . pts , bytes : h } ) } } } } } break ; case 7 : if ( i = ! 0 , o && ( a += "SPS " ) , ! r . sps ) { t = new s . default ( e . data ) ; var y = t . readSPS ( ) ; r . width = y . width , r . height = y . height , r . sps = [ e . data ] , r . timescale = f . remuxer . timescale , r . duration = f . remuxer . timescale * f . _duration ; var k = e . data . subarray ( 1 , 4 ) , m = "avc1." ; for ( l = 0 ; 3 > l ; l ++ ) { var u = k [ l ] . toString ( 16 ) ; u . length < 2 && ( u = "0" + u ) , m += u } r . codec = m } break ; case 8 : i = ! 0 , o && ( a += "PPS " ) , r . pps || ( r . pps = [ e . data ] ) ; break ; case 9 : i = ! 1 , o && ( a += "AUD " ) ; break ; default : i = ! 1 , a += "unknown NAL " + e . type + " " } i && ( d . push ( e ) , g += e . data . byte
var r = new Uint8Array ( [ 105 , 115 , 111 , 109 ] ) , o = new Uint8Array ( [ 97 , 118 , 99 , 49 ] ) , l = new Uint8Array ( [ 0 , 0 , 0 , 1 ] ) ; e . FTYP = e . box ( e . types . ftyp , r , l , r , o ) , e . DINF = e . box ( e . types . dinf , e . box ( e . types . dref , i ) ) } } , { key : "box" , value : function ( a ) { for ( var t , n = Array . prototype . slice . call ( arguments , 1 ) , e = 8 , r = n . length , i = r ; r -- ; ) e += n [ r ] . byteLength ; for ( t = new Uint8Array ( e ) , t [ 0 ] = e >> 24 & 255 , t [ 1 ] = e >> 16 & 255 , t [ 2 ] = e >> 8 & 255 , t [ 3 ] = 255 & e , t . set ( a , 4 ) , r = 0 , e = 8 ; i > r ; r ++ ) t . set ( n [ r ] , e ) , e += n [ r ] . byteLength ; return t } } , { key : "hdlr" , value : function ( t ) { return e . box ( e . types . hdlr , e . HDLR _TYPES [ t ] ) } } , { key : "mdat" , value : function ( t ) { return e . box ( e . types . mdat , t ) } } , { key : "mdhd" , value : function ( t , r ) { return e . box ( e . types . mdhd , new Uint8Array ( [ 0 , 0 , 0 , 0 , 0 , 0 , 0 , 2 , 0 , 0 , 0 , 3 , t >> 24 & 255 , t >> 16 & 255 , t >> 8 & 255 , 255 & t , r >> 24 , r >> 16 & 255 , r >> 8 & 255 , 255 & r , 85 , 196 , 0 , 0 ] ) ) } } , { key : "mdia" , value : function ( t ) { return e . box ( e . types . mdia , e . mdhd ( t . timescale , t . duration ) , e . hdlr ( t . type ) , e . minf ( t ) ) } } , { key : "mfhd" , value : function ( t ) { return e . box ( e . types . mfhd , new Uint8Array ( [ 0 , 0 , 0 , 0 , t >> 24 , t >> 16 & 255 , t >> 8 & 255 , 255 & t ] ) ) } } , { key : "minf" , value : function ( t ) { return "audio" === t . type ? e . box ( e . types . minf , e . box ( e . types . smhd , e . SMHD ) , e . DINF , e . stbl ( t ) ) : e . box ( e . types . minf , e . box ( e . types . vmhd , e . VMHD ) , e . DINF , e . stbl ( t ) ) } } , { key : "moof" , value : function ( t , r , n ) { return e . box ( e . types . moof , e . mfhd ( t ) , e . traf ( n , r ) ) } } , { key : "moov" , value : function ( t ) { for ( var r = t . length , n = [ ] ; r -- ; ) n [ r ] = e . trak ( t [ r ] ) ; return e . box . apply ( null , [ e . types . moov , e . mvhd ( t [ 0 ] . timescale , t [ 0 ] . duration ) ] . concat ( n ) . concat ( e . mvex ( t ) ) ) } } , { key : "mvex" , value : function ( r ) { for ( var t = r . length , n = [ ] ; t -- ; ) n [ t ] = e . trex ( r [ t ] ) ; return e . box . apply ( null , [ e . types . mvex ] . concat ( n ) ) } } , { key : "mvhd" , value : function ( t , r ) { var n = new Uint8Array ( [ 0 , 0 , 0 , 0 , 0 , 0 , 0 , 1 , 0 , 0 , 0 , 2 , t >> 24 & 255 , t >> 16 & 255 , t >> 8 & 255 , 255 & t , r >> 24 & 255 , r >> 16 & 255 , r >> 8 & 255 , 255 & r , 0 , 1 , 0 , 0 , 1 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 1 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 1 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 64 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 255 , 255 , 255 , 255 ] ) ; return e . box ( e . types . mvhd , n ) } } , { key : "sdtp" , value : function ( i ) { var r , t , n = i . samples || [ ] , a = new Uint8Array ( 4 + n . length ) ; for ( t = 0 ; t < n . length ; t ++ ) r = n [ t ] . flags , a [ t + 4 ] = r . dependsOn << 4 | r . isDependedOn << 2 | r . hasRedundancy ; return e . box ( e . types . sdtp , a ) } } , { key : "stbl" , value : function ( t ) { return e . box ( e . types . stbl , e . stsd ( t ) , e . box ( e . types . stts , e . STTS ) , e . box ( e . types . stsc , e . STSC ) , e . box ( e . types . stsz , e . STSZ ) , e . box ( e . types . stco , e . STCO ) ) } } , { key : "avc1" , value : function ( t ) { var r , a , i , n = [ ] , s = [ ] ; for ( r = 0 ; r < t . sps . length ; r ++ ) a = t . sps [ r ] , i = a . byteLength , n . push ( i >>> 8 & 255 ) , n . push ( 255 & i ) , n = n . concat ( Array . prototype . slice . call ( a ) ) ; for ( r = 0 ; r < t . pps . length ; r ++ ) a = t . pps [ r ] , i = a . byteLength , s . push ( i >>> 8 & 255 ) , s . push ( 255 & i ) , s = s . concat ( Array . prototype . slice . call ( a ) ) ; var u = e . box ( e . types . avcC , new Uint8Array ( [ 1 , n [ 3 ] , n [ 4 ] , n [ 5 ] , 255 , 224 | t . sps . length ] . concat ( n ) . concat ( [ t . pps . length ] ) . concat ( s ) ) ) , o = t . width , l = t . height ; return e . box ( e . types . avc1 , new Uint8Array ( [ 0 , 0 , 0 , 0 , 0 , 0 , 0 , 1 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , o >> 8 & 255 , 255 & o , l >> 8 & 255 , 255 & l , 0 , 72 , 0 , 0 , 0 , 72 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 1 , 18 , 100 , 97 , 105 , 108 , 121 , 109 , 111 , 116 , 105 , 111 , 110 , 47 , 104 , 108 , 115 , 46 , 106 , 115 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 24 , 17 , 17 ] ) , u , e . box ( e . types . btrt , new Uint8Array ( [ 0 , 28 , 156 , 128 , 0 , 45 , 198 , 192 , 0 , 45 , 198 , 192 ] ) ) ) } } , { key : "esds" , value : function ( t ) { var e = t . config . length ; return new Uint8Array ( [ 0 , 0 , 0 , 0 , 3 , 23 + e , 0 , 1 , 0 , 4 , 15 + e , 64 , 21 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 5 ] . concat ( [ e ] ) . concat ( t . config ) . concat ( [ 6 , 1 , 2 ] ) ) } } , { key : "mp4a" , value : function ( t ) { var r = t . audiosamplerate ; return e . box ( e . types . mp4a , new Uint8Array ( [ 0 , 0 , 0 , 0 , 0 , 0 , 0 , 1 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , t . channelCount , 0 , 16 , 0 , 0 , 0 , 0 , r >> 8 & 255 , 255 & r , 0 , 0 ] ) , e . box ( e . types . esds , e . esds ( t ) ) ) } } , { key : "stsd" , value : function ( t ) { return "audio" === t . type ? e . box ( e . types . stsd , e . STSD , e . mp4a ( t ) ) : e . box ( e . types . stsd , e . STSD , e . avc1 ( t ) ) } } , { key : "tkhd" , value : function ( t ) { var r = t . id , n = t . duration , a = t . width , i = t . height ; return e . box ( e . types . tkhd , new Uint8Array ( [ 0 , 0 , 0 , 7 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , r >> 24 & 255 , r >> 16 & 255 , r >> 8 & 255 , 255 & r , 0 , 0 , 0 , 0 , n >> 24 , n >> 16 & 255 , n >> 8 & 255 , 255 & n , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 1 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 1 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 64 , 0 , 0 , 0 , a >> 8 & 255 , 255 & a , 0 , 0 , i >> 8 & 255 , 255 & i , 0 , 0 ] ) ) } } , { key : "traf" , value : function ( n , t ) { var a = e . sdtp ( n ) , r = n . id ; return e . box ( e . types . traf , e . box ( e . types