2024-03-15 16:58:55 +08:00
import {
_ _commonJS
2024-08-02 18:19:39 +08:00
} from "./chunk-A5ICIBVI.js" ;
2024-03-15 16:58:55 +08:00
// node_modules/flv.js/dist/flv.js
var require _flv = _ _commonJS ( {
"node_modules/flv.js/dist/flv.js" ( exports , module ) {
( function webpackUniversalModuleDefinition ( root , factory ) {
if ( typeof exports === "object" && typeof module === "object" )
module . exports = factory ( ) ;
else if ( typeof define === "function" && define . amd )
define ( [ ] , factory ) ;
else if ( typeof exports === "object" )
exports [ "flvjs" ] = factory ( ) ;
else
root [ "flvjs" ] = factory ( ) ;
} ) ( self , function ( ) {
return function ( ) {
var _ _webpack _modules _ _ = {
"./node_modules/es6-promise/dist/es6-promise.js" : function ( module2 , _ _unused _webpack _exports , _ _webpack _require _ _2 ) {
( function ( global , factory ) {
true ? module2 . exports = factory ( ) : 0 ;
} ) ( this , function ( ) {
"use strict" ;
function objectOrFunction ( x ) {
var type = typeof x ;
return x !== null && ( type === "object" || type === "function" ) ;
}
function isFunction ( x ) {
return typeof x === "function" ;
}
var _isArray = void 0 ;
if ( Array . isArray ) {
_isArray = Array . isArray ;
} else {
_isArray = function ( x ) {
return Object . prototype . toString . call ( x ) === "[object Array]" ;
} ;
}
var isArray = _isArray ;
var len = 0 ;
var vertxNext = void 0 ;
var customSchedulerFn = void 0 ;
var asap = function asap2 ( callback , arg ) {
queue [ len ] = callback ;
queue [ len + 1 ] = arg ;
len += 2 ;
if ( len === 2 ) {
if ( customSchedulerFn ) {
customSchedulerFn ( flush ) ;
} else {
scheduleFlush ( ) ;
}
}
} ;
function setScheduler ( scheduleFn ) {
customSchedulerFn = scheduleFn ;
}
function setAsap ( asapFn ) {
asap = asapFn ;
}
var browserWindow = typeof window !== "undefined" ? window : void 0 ;
var browserGlobal = browserWindow || { } ;
var BrowserMutationObserver = browserGlobal . MutationObserver || browserGlobal . WebKitMutationObserver ;
var isNode = typeof self === "undefined" && typeof process !== "undefined" && { } . toString . call ( process ) === "[object process]" ;
var isWorker = typeof Uint8ClampedArray !== "undefined" && typeof importScripts !== "undefined" && typeof MessageChannel !== "undefined" ;
function useNextTick ( ) {
return function ( ) {
return process . nextTick ( flush ) ;
} ;
}
function useVertxTimer ( ) {
if ( typeof vertxNext !== "undefined" ) {
return function ( ) {
vertxNext ( flush ) ;
} ;
}
return useSetTimeout ( ) ;
}
function useMutationObserver ( ) {
var iterations = 0 ;
var observer = new BrowserMutationObserver ( flush ) ;
var node = document . createTextNode ( "" ) ;
observer . observe ( node , { characterData : true } ) ;
return function ( ) {
node . data = iterations = ++ iterations % 2 ;
} ;
}
function useMessageChannel ( ) {
var channel = new MessageChannel ( ) ;
channel . port1 . onmessage = flush ;
return function ( ) {
return channel . port2 . postMessage ( 0 ) ;
} ;
}
function useSetTimeout ( ) {
var globalSetTimeout = setTimeout ;
return function ( ) {
return globalSetTimeout ( flush , 1 ) ;
} ;
}
var queue = new Array ( 1e3 ) ;
function flush ( ) {
for ( var i = 0 ; i < len ; i += 2 ) {
var callback = queue [ i ] ;
var arg = queue [ i + 1 ] ;
callback ( arg ) ;
queue [ i ] = void 0 ;
queue [ i + 1 ] = void 0 ;
}
len = 0 ;
}
function attemptVertx ( ) {
try {
var vertx = Function ( "return this" ) ( ) . require ( "vertx" ) ;
vertxNext = vertx . runOnLoop || vertx . runOnContext ;
return useVertxTimer ( ) ;
} catch ( e ) {
return useSetTimeout ( ) ;
}
}
var scheduleFlush = void 0 ;
if ( isNode ) {
scheduleFlush = useNextTick ( ) ;
} else if ( BrowserMutationObserver ) {
scheduleFlush = useMutationObserver ( ) ;
} else if ( isWorker ) {
scheduleFlush = useMessageChannel ( ) ;
} else if ( browserWindow === void 0 && true ) {
scheduleFlush = attemptVertx ( ) ;
} else {
scheduleFlush = useSetTimeout ( ) ;
}
function then ( onFulfillment , onRejection ) {
var parent = this ;
var child = new this . constructor ( noop ) ;
if ( child [ PROMISE _ID ] === void 0 ) {
makePromise ( child ) ;
}
var _state = parent . _state ;
if ( _state ) {
var callback = arguments [ _state - 1 ] ;
asap ( function ( ) {
return invokeCallback ( _state , child , callback , parent . _result ) ;
} ) ;
} else {
subscribe ( parent , child , onFulfillment , onRejection ) ;
}
return child ;
}
function resolve$1 ( object ) {
var Constructor = this ;
if ( object && typeof object === "object" && object . constructor === Constructor ) {
return object ;
}
var promise = new Constructor ( noop ) ;
resolve ( promise , object ) ;
return promise ;
}
var PROMISE _ID = Math . random ( ) . toString ( 36 ) . substring ( 2 ) ;
function noop ( ) {
}
var PENDING = void 0 ;
var FULFILLED = 1 ;
var REJECTED = 2 ;
function selfFulfillment ( ) {
return new TypeError ( "You cannot resolve a promise with itself" ) ;
}
function cannotReturnOwn ( ) {
return new TypeError ( "A promises callback cannot return that same promise." ) ;
}
function tryThen ( then$$1 , value , fulfillmentHandler , rejectionHandler ) {
try {
then$$1 . call ( value , fulfillmentHandler , rejectionHandler ) ;
} catch ( e ) {
return e ;
}
}
function handleForeignThenable ( promise , thenable , then$$1 ) {
asap ( function ( promise2 ) {
var sealed = false ;
var error = tryThen ( then$$1 , thenable , function ( value ) {
if ( sealed ) {
return ;
}
sealed = true ;
if ( thenable !== value ) {
resolve ( promise2 , value ) ;
} else {
fulfill ( promise2 , value ) ;
}
} , function ( reason ) {
if ( sealed ) {
return ;
}
sealed = true ;
reject ( promise2 , reason ) ;
} , "Settle: " + ( promise2 . _label || " unknown promise" ) ) ;
if ( ! sealed && error ) {
sealed = true ;
reject ( promise2 , error ) ;
}
} , promise ) ;
}
function handleOwnThenable ( promise , thenable ) {
if ( thenable . _state === FULFILLED ) {
fulfill ( promise , thenable . _result ) ;
} else if ( thenable . _state === REJECTED ) {
reject ( promise , thenable . _result ) ;
} else {
subscribe ( thenable , void 0 , function ( value ) {
return resolve ( promise , value ) ;
} , function ( reason ) {
return reject ( promise , reason ) ;
} ) ;
}
}
function handleMaybeThenable ( promise , maybeThenable , then$$1 ) {
if ( maybeThenable . constructor === promise . constructor && then$$1 === then && maybeThenable . constructor . resolve === resolve$1 ) {
handleOwnThenable ( promise , maybeThenable ) ;
} else {
if ( then$$1 === void 0 ) {
fulfill ( promise , maybeThenable ) ;
} else if ( isFunction ( then$$1 ) ) {
handleForeignThenable ( promise , maybeThenable , then$$1 ) ;
} else {
fulfill ( promise , maybeThenable ) ;
}
}
}
function resolve ( promise , value ) {
if ( promise === value ) {
reject ( promise , selfFulfillment ( ) ) ;
} else if ( objectOrFunction ( value ) ) {
var then$$1 = void 0 ;
try {
then$$1 = value . then ;
} catch ( error ) {
reject ( promise , error ) ;
return ;
}
handleMaybeThenable ( promise , value , then$$1 ) ;
} else {
fulfill ( promise , value ) ;
}
}
function publishRejection ( promise ) {
if ( promise . _onerror ) {
promise . _onerror ( promise . _result ) ;
}
publish ( promise ) ;
}
function fulfill ( promise , value ) {
if ( promise . _state !== PENDING ) {
return ;
}
promise . _result = value ;
promise . _state = FULFILLED ;
if ( promise . _subscribers . length !== 0 ) {
asap ( publish , promise ) ;
}
}
function reject ( promise , reason ) {
if ( promise . _state !== PENDING ) {
return ;
}
promise . _state = REJECTED ;
promise . _result = reason ;
asap ( publishRejection , promise ) ;
}
function subscribe ( parent , child , onFulfillment , onRejection ) {
var _subscribers = parent . _subscribers ;
var length = _subscribers . length ;
parent . _onerror = null ;
_subscribers [ length ] = child ;
_subscribers [ length + FULFILLED ] = onFulfillment ;
_subscribers [ length + REJECTED ] = onRejection ;
if ( length === 0 && parent . _state ) {
asap ( publish , parent ) ;
}
}
function publish ( promise ) {
var subscribers = promise . _subscribers ;
var settled = promise . _state ;
if ( subscribers . length === 0 ) {
return ;
}
var child = void 0 , callback = void 0 , detail = promise . _result ;
for ( var i = 0 ; i < subscribers . length ; i += 3 ) {
child = subscribers [ i ] ;
callback = subscribers [ i + settled ] ;
if ( child ) {
invokeCallback ( settled , child , callback , detail ) ;
} else {
callback ( detail ) ;
}
}
promise . _subscribers . length = 0 ;
}
function invokeCallback ( settled , promise , callback , detail ) {
var hasCallback = isFunction ( callback ) , value = void 0 , error = void 0 , succeeded = true ;
if ( hasCallback ) {
try {
value = callback ( detail ) ;
} catch ( e ) {
succeeded = false ;
error = e ;
}
if ( promise === value ) {
reject ( promise , cannotReturnOwn ( ) ) ;
return ;
}
} else {
value = detail ;
}
if ( promise . _state !== PENDING ) {
} else if ( hasCallback && succeeded ) {
resolve ( promise , value ) ;
} else if ( succeeded === false ) {
reject ( promise , error ) ;
} else if ( settled === FULFILLED ) {
fulfill ( promise , value ) ;
} else if ( settled === REJECTED ) {
reject ( promise , value ) ;
}
}
function initializePromise ( promise , resolver ) {
try {
resolver ( function resolvePromise ( value ) {
resolve ( promise , value ) ;
} , function rejectPromise ( reason ) {
reject ( promise , reason ) ;
} ) ;
} catch ( e ) {
reject ( promise , e ) ;
}
}
var id = 0 ;
function nextId ( ) {
return id ++ ;
}
function makePromise ( promise ) {
promise [ PROMISE _ID ] = id ++ ;
promise . _state = void 0 ;
promise . _result = void 0 ;
promise . _subscribers = [ ] ;
}
function validationError ( ) {
return new Error ( "Array Methods must be provided an Array" ) ;
}
var Enumerator = function ( ) {
function Enumerator2 ( Constructor , input ) {
this . _instanceConstructor = Constructor ;
this . promise = new Constructor ( noop ) ;
if ( ! this . promise [ PROMISE _ID ] ) {
makePromise ( this . promise ) ;
}
if ( isArray ( input ) ) {
this . length = input . length ;
this . _remaining = input . length ;
this . _result = new Array ( this . length ) ;
if ( this . length === 0 ) {
fulfill ( this . promise , this . _result ) ;
} else {
this . length = this . length || 0 ;
this . _enumerate ( input ) ;
if ( this . _remaining === 0 ) {
fulfill ( this . promise , this . _result ) ;
}
}
} else {
reject ( this . promise , validationError ( ) ) ;
}
}
Enumerator2 . prototype . _enumerate = function _enumerate ( input ) {
for ( var i = 0 ; this . _state === PENDING && i < input . length ; i ++ ) {
this . _eachEntry ( input [ i ] , i ) ;
}
} ;
Enumerator2 . prototype . _eachEntry = function _eachEntry ( entry , i ) {
var c = this . _instanceConstructor ;
var resolve$$1 = c . resolve ;
if ( resolve$$1 === resolve$1 ) {
var _then = void 0 ;
var error = void 0 ;
var didError = false ;
try {
_then = entry . then ;
} catch ( e ) {
didError = true ;
error = e ;
}
if ( _then === then && entry . _state !== PENDING ) {
this . _settledAt ( entry . _state , i , entry . _result ) ;
} else if ( typeof _then !== "function" ) {
this . _remaining -- ;
this . _result [ i ] = entry ;
} else if ( c === Promise $1 ) {
var promise = new c ( noop ) ;
if ( didError ) {
reject ( promise , error ) ;
} else {
handleMaybeThenable ( promise , entry , _then ) ;
}
this . _willSettleAt ( promise , i ) ;
} else {
this . _willSettleAt ( new c ( function ( resolve$$12 ) {
return resolve$$12 ( entry ) ;
} ) , i ) ;
}
} else {
this . _willSettleAt ( resolve$$1 ( entry ) , i ) ;
}
} ;
Enumerator2 . prototype . _settledAt = function _settledAt ( state , i , value ) {
var promise = this . promise ;
if ( promise . _state === PENDING ) {
this . _remaining -- ;
if ( state === REJECTED ) {
reject ( promise , value ) ;
} else {
this . _result [ i ] = value ;
}
}
if ( this . _remaining === 0 ) {
fulfill ( promise , this . _result ) ;
}
} ;
Enumerator2 . prototype . _willSettleAt = function _willSettleAt ( promise , i ) {
var enumerator = this ;
subscribe ( promise , void 0 , function ( value ) {
return enumerator . _settledAt ( FULFILLED , i , value ) ;
} , function ( reason ) {
return enumerator . _settledAt ( REJECTED , i , reason ) ;
} ) ;
} ;
return Enumerator2 ;
} ( ) ;
function all ( entries ) {
return new Enumerator ( this , entries ) . promise ;
}
function race ( entries ) {
var Constructor = this ;
if ( ! isArray ( entries ) ) {
return new Constructor ( function ( _ , reject2 ) {
return reject2 ( new TypeError ( "You must pass an array to race." ) ) ;
} ) ;
} else {
return new Constructor ( function ( resolve2 , reject2 ) {
var length = entries . length ;
for ( var i = 0 ; i < length ; i ++ ) {
Constructor . resolve ( entries [ i ] ) . then ( resolve2 , reject2 ) ;
}
} ) ;
}
}
function reject$1 ( reason ) {
var Constructor = this ;
var promise = new Constructor ( noop ) ;
reject ( promise , reason ) ;
return promise ;
}
function needsResolver ( ) {
throw new TypeError ( "You must pass a resolver function as the first argument to the promise constructor" ) ;
}
function needsNew ( ) {
throw new TypeError ( "Failed to construct 'Promise': Please use the 'new' operator, this object constructor cannot be called as a function." ) ;
}
var Promise $1 = function ( ) {
function Promise2 ( resolver ) {
this [ PROMISE _ID ] = nextId ( ) ;
this . _result = this . _state = void 0 ;
this . _subscribers = [ ] ;
if ( noop !== resolver ) {
typeof resolver !== "function" && needsResolver ( ) ;
this instanceof Promise2 ? initializePromise ( this , resolver ) : needsNew ( ) ;
}
}
Promise2 . prototype . catch = function _catch ( onRejection ) {
return this . then ( null , onRejection ) ;
} ;
Promise2 . prototype . finally = function _finally ( callback ) {
var promise = this ;
var constructor = promise . constructor ;
if ( isFunction ( callback ) ) {
return promise . then ( function ( value ) {
return constructor . resolve ( callback ( ) ) . then ( function ( ) {
return value ;
} ) ;
} , function ( reason ) {
return constructor . resolve ( callback ( ) ) . then ( function ( ) {
throw reason ;
} ) ;
} ) ;
}
return promise . then ( callback , callback ) ;
} ;
return Promise2 ;
} ( ) ;
Promise $1 . prototype . then = then ;
Promise $1 . all = all ;
Promise $1 . race = race ;
Promise $1 . resolve = resolve$1 ;
Promise $1 . reject = reject$1 ;
Promise $1 . _setScheduler = setScheduler ;
Promise $1 . _setAsap = setAsap ;
Promise $1 . _asap = asap ;
function polyfill ( ) {
var local = void 0 ;
if ( typeof _ _webpack _require _ _2 . g !== "undefined" ) {
local = _ _webpack _require _ _2 . g ;
} else if ( typeof self !== "undefined" ) {
local = self ;
} else {
try {
local = Function ( "return this" ) ( ) ;
} catch ( e ) {
throw new Error ( "polyfill failed because global object is unavailable in this environment" ) ;
}
}
var P = local . Promise ;
if ( P ) {
var promiseToString = null ;
try {
promiseToString = Object . prototype . toString . call ( P . resolve ( ) ) ;
} catch ( e ) {
}
if ( promiseToString === "[object Promise]" && ! P . cast ) {
return ;
}
}
local . Promise = Promise $1 ;
}
Promise $1 . polyfill = polyfill ;
Promise $1 . Promise = Promise $1 ;
return Promise $1 ;
} ) ;
} ,
"./node_modules/events/events.js" : function ( module2 ) {
"use strict" ;
var R = typeof Reflect === "object" ? Reflect : null ;
var ReflectApply = R && typeof R . apply === "function" ? R . apply : function ReflectApply2 ( target , receiver , args ) {
return Function . prototype . apply . call ( target , receiver , args ) ;
} ;
var ReflectOwnKeys ;
if ( R && typeof R . ownKeys === "function" ) {
ReflectOwnKeys = R . ownKeys ;
} else if ( Object . getOwnPropertySymbols ) {
ReflectOwnKeys = function ReflectOwnKeys2 ( target ) {
return Object . getOwnPropertyNames ( target ) . concat ( Object . getOwnPropertySymbols ( target ) ) ;
} ;
} else {
ReflectOwnKeys = function ReflectOwnKeys2 ( target ) {
return Object . getOwnPropertyNames ( target ) ;
} ;
}
function ProcessEmitWarning ( warning ) {
if ( console && console . warn )
console . warn ( warning ) ;
}
var NumberIsNaN = Number . isNaN || function NumberIsNaN2 ( value ) {
return value !== value ;
} ;
function EventEmitter ( ) {
EventEmitter . init . call ( this ) ;
}
module2 . exports = EventEmitter ;
module2 . exports . once = once ;
EventEmitter . EventEmitter = EventEmitter ;
EventEmitter . prototype . _events = void 0 ;
EventEmitter . prototype . _eventsCount = 0 ;
EventEmitter . prototype . _maxListeners = void 0 ;
var defaultMaxListeners = 10 ;
function checkListener ( listener ) {
if ( typeof listener !== "function" ) {
throw new TypeError ( 'The "listener" argument must be of type Function. Received type ' + typeof listener ) ;
}
}
Object . defineProperty ( EventEmitter , "defaultMaxListeners" , {
enumerable : true ,
get : function ( ) {
return defaultMaxListeners ;
} ,
set : function ( arg ) {
if ( typeof arg !== "number" || arg < 0 || NumberIsNaN ( arg ) ) {
throw new RangeError ( 'The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received ' + arg + "." ) ;
}
defaultMaxListeners = arg ;
}
} ) ;
EventEmitter . init = function ( ) {
if ( this . _events === void 0 || this . _events === Object . getPrototypeOf ( this ) . _events ) {
this . _events = Object . create ( null ) ;
this . _eventsCount = 0 ;
}
this . _maxListeners = this . _maxListeners || void 0 ;
} ;
EventEmitter . prototype . setMaxListeners = function setMaxListeners ( n ) {
if ( typeof n !== "number" || n < 0 || NumberIsNaN ( n ) ) {
throw new RangeError ( 'The value of "n" is out of range. It must be a non-negative number. Received ' + n + "." ) ;
}
this . _maxListeners = n ;
return this ;
} ;
function _getMaxListeners ( that ) {
if ( that . _maxListeners === void 0 )
return EventEmitter . defaultMaxListeners ;
return that . _maxListeners ;
}
EventEmitter . prototype . getMaxListeners = function getMaxListeners ( ) {
return _getMaxListeners ( this ) ;
} ;
EventEmitter . prototype . emit = function emit ( type ) {
var args = [ ] ;
for ( var i = 1 ; i < arguments . length ; i ++ )
args . push ( arguments [ i ] ) ;
var doError = type === "error" ;
var events = this . _events ;
if ( events !== void 0 )
doError = doError && events . error === void 0 ;
else if ( ! doError )
return false ;
if ( doError ) {
var er ;
if ( args . length > 0 )
er = args [ 0 ] ;
if ( er instanceof Error ) {
throw er ;
}
var err = new Error ( "Unhandled error." + ( er ? " (" + er . message + ")" : "" ) ) ;
err . context = er ;
throw err ;
}
var handler = events [ type ] ;
if ( handler === void 0 )
return false ;
if ( typeof handler === "function" ) {
ReflectApply ( handler , this , args ) ;
} else {
var len = handler . length ;
var listeners = arrayClone ( handler , len ) ;
for ( var i = 0 ; i < len ; ++ i )
ReflectApply ( listeners [ i ] , this , args ) ;
}
return true ;
} ;
function _addListener ( target , type , listener , prepend ) {
var m ;
var events ;
var existing ;
checkListener ( listener ) ;
events = target . _events ;
if ( events === void 0 ) {
events = target . _events = Object . create ( null ) ;
target . _eventsCount = 0 ;
} else {
if ( events . newListener !== void 0 ) {
target . emit ( "newListener" , type , listener . listener ? listener . listener : listener ) ;
events = target . _events ;
}
existing = events [ type ] ;
}
if ( existing === void 0 ) {
existing = events [ type ] = listener ;
++ target . _eventsCount ;
} else {
if ( typeof existing === "function" ) {
existing = events [ type ] = prepend ? [ listener , existing ] : [ existing , listener ] ;
} else if ( prepend ) {
existing . unshift ( listener ) ;
} else {
existing . push ( listener ) ;
}
m = _getMaxListeners ( target ) ;
if ( m > 0 && existing . length > m && ! existing . warned ) {
existing . warned = true ;
var w = new Error ( "Possible EventEmitter memory leak detected. " + existing . length + " " + String ( type ) + " listeners added. Use emitter.setMaxListeners() to increase limit" ) ;
w . name = "MaxListenersExceededWarning" ;
w . emitter = target ;
w . type = type ;
w . count = existing . length ;
ProcessEmitWarning ( w ) ;
}
}
return target ;
}
EventEmitter . prototype . addListener = function addListener ( type , listener ) {
return _addListener ( this , type , listener , false ) ;
} ;
EventEmitter . prototype . on = EventEmitter . prototype . addListener ;
EventEmitter . prototype . prependListener = function prependListener ( type , listener ) {
return _addListener ( this , type , listener , true ) ;
} ;
function onceWrapper ( ) {
if ( ! this . fired ) {
this . target . removeListener ( this . type , this . wrapFn ) ;
this . fired = true ;
if ( arguments . length === 0 )
return this . listener . call ( this . target ) ;
return this . listener . apply ( this . target , arguments ) ;
}
}
function _onceWrap ( target , type , listener ) {
var state = { fired : false , wrapFn : void 0 , target , type , listener } ;
var wrapped = onceWrapper . bind ( state ) ;
wrapped . listener = listener ;
state . wrapFn = wrapped ;
return wrapped ;
}
EventEmitter . prototype . once = function once2 ( type , listener ) {
checkListener ( listener ) ;
this . on ( type , _onceWrap ( this , type , listener ) ) ;
return this ;
} ;
EventEmitter . prototype . prependOnceListener = function prependOnceListener ( type , listener ) {
checkListener ( listener ) ;
this . prependListener ( type , _onceWrap ( this , type , listener ) ) ;
return this ;
} ;
EventEmitter . prototype . removeListener = function removeListener ( type , listener ) {
var list , events , position , i , originalListener ;
checkListener ( listener ) ;
events = this . _events ;
if ( events === void 0 )
return this ;
list = events [ type ] ;
if ( list === void 0 )
return this ;
if ( list === listener || list . listener === listener ) {
if ( -- this . _eventsCount === 0 )
this . _events = Object . create ( null ) ;
else {
delete events [ type ] ;
if ( events . removeListener )
this . emit ( "removeListener" , type , list . listener || listener ) ;
}
} else if ( typeof list !== "function" ) {
position = - 1 ;
for ( i = list . length - 1 ; i >= 0 ; i -- ) {
if ( list [ i ] === listener || list [ i ] . listener === listener ) {
originalListener = list [ i ] . listener ;
position = i ;
break ;
}
}
if ( position < 0 )
return this ;
if ( position === 0 )
list . shift ( ) ;
else {
spliceOne ( list , position ) ;
}
if ( list . length === 1 )
events [ type ] = list [ 0 ] ;
if ( events . removeListener !== void 0 )
this . emit ( "removeListener" , type , originalListener || listener ) ;
}
return this ;
} ;
EventEmitter . prototype . off = EventEmitter . prototype . removeListener ;
EventEmitter . prototype . removeAllListeners = function removeAllListeners ( type ) {
var listeners , events , i ;
events = this . _events ;
if ( events === void 0 )
return this ;
if ( events . removeListener === void 0 ) {
if ( arguments . length === 0 ) {
this . _events = Object . create ( null ) ;
this . _eventsCount = 0 ;
} else if ( events [ type ] !== void 0 ) {
if ( -- this . _eventsCount === 0 )
this . _events = Object . create ( null ) ;
else
delete events [ type ] ;
}
return this ;
}
if ( arguments . length === 0 ) {
var keys = Object . keys ( events ) ;
var key ;
for ( i = 0 ; i < keys . length ; ++ i ) {
key = keys [ i ] ;
if ( key === "removeListener" )
continue ;
this . removeAllListeners ( key ) ;
}
this . removeAllListeners ( "removeListener" ) ;
this . _events = Object . create ( null ) ;
this . _eventsCount = 0 ;
return this ;
}
listeners = events [ type ] ;
if ( typeof listeners === "function" ) {
this . removeListener ( type , listeners ) ;
} else if ( listeners !== void 0 ) {
for ( i = listeners . length - 1 ; i >= 0 ; i -- ) {
this . removeListener ( type , listeners [ i ] ) ;
}
}
return this ;
} ;
function _listeners ( target , type , unwrap ) {
var events = target . _events ;
if ( events === void 0 )
return [ ] ;
var evlistener = events [ type ] ;
if ( evlistener === void 0 )
return [ ] ;
if ( typeof evlistener === "function" )
return unwrap ? [ evlistener . listener || evlistener ] : [ evlistener ] ;
return unwrap ? unwrapListeners ( evlistener ) : arrayClone ( evlistener , evlistener . length ) ;
}
EventEmitter . prototype . listeners = function listeners ( type ) {
return _listeners ( this , type , true ) ;
} ;
EventEmitter . prototype . rawListeners = function rawListeners ( type ) {
return _listeners ( this , type , false ) ;
} ;
EventEmitter . listenerCount = function ( emitter , type ) {
if ( typeof emitter . listenerCount === "function" ) {
return emitter . listenerCount ( type ) ;
} else {
return listenerCount . call ( emitter , type ) ;
}
} ;
EventEmitter . prototype . listenerCount = listenerCount ;
function listenerCount ( type ) {
var events = this . _events ;
if ( events !== void 0 ) {
var evlistener = events [ type ] ;
if ( typeof evlistener === "function" ) {
return 1 ;
} else if ( evlistener !== void 0 ) {
return evlistener . length ;
}
}
return 0 ;
}
EventEmitter . prototype . eventNames = function eventNames ( ) {
return this . _eventsCount > 0 ? ReflectOwnKeys ( this . _events ) : [ ] ;
} ;
function arrayClone ( arr , n ) {
var copy = new Array ( n ) ;
for ( var i = 0 ; i < n ; ++ i )
copy [ i ] = arr [ i ] ;
return copy ;
}
function spliceOne ( list , index ) {
for ( ; index + 1 < list . length ; index ++ )
list [ index ] = list [ index + 1 ] ;
list . pop ( ) ;
}
function unwrapListeners ( arr ) {
var ret = new Array ( arr . length ) ;
for ( var i = 0 ; i < ret . length ; ++ i ) {
ret [ i ] = arr [ i ] . listener || arr [ i ] ;
}
return ret ;
}
function once ( emitter , name ) {
return new Promise ( function ( resolve , reject ) {
function errorListener ( err ) {
emitter . removeListener ( name , resolver ) ;
reject ( err ) ;
}
function resolver ( ) {
if ( typeof emitter . removeListener === "function" ) {
emitter . removeListener ( "error" , errorListener ) ;
}
resolve ( [ ] . slice . call ( arguments ) ) ;
}
;
eventTargetAgnosticAddListener ( emitter , name , resolver , { once : true } ) ;
if ( name !== "error" ) {
addErrorHandlerIfEventEmitter ( emitter , errorListener , { once : true } ) ;
}
} ) ;
}
function addErrorHandlerIfEventEmitter ( emitter , handler , flags ) {
if ( typeof emitter . on === "function" ) {
eventTargetAgnosticAddListener ( emitter , "error" , handler , flags ) ;
}
}
function eventTargetAgnosticAddListener ( emitter , name , listener , flags ) {
if ( typeof emitter . on === "function" ) {
if ( flags . once ) {
emitter . once ( name , listener ) ;
} else {
emitter . on ( name , listener ) ;
}
} else if ( typeof emitter . addEventListener === "function" ) {
emitter . addEventListener ( name , function wrapListener ( arg ) {
if ( flags . once ) {
emitter . removeEventListener ( name , wrapListener ) ;
}
listener ( arg ) ;
} ) ;
} else {
throw new TypeError ( 'The "emitter" argument must be of type EventEmitter. Received type ' + typeof emitter ) ;
}
}
} ,
"./node_modules/webworkify-webpack/index.js" : function ( module2 , _ _unused _webpack _exports , _ _webpack _require _ _2 ) {
function webpackBootstrapFunc ( modules ) {
var installedModules = { } ;
function _ _nested _webpack _require _164 _ _ ( moduleId ) {
if ( installedModules [ moduleId ] )
return installedModules [ moduleId ] . exports ;
var module3 = installedModules [ moduleId ] = {
i : moduleId ,
l : false ,
exports : { }
} ;
modules [ moduleId ] . call ( module3 . exports , module3 , module3 . exports , _ _nested _webpack _require _164 _ _ ) ;
module3 . l = true ;
return module3 . exports ;
}
_ _nested _webpack _require _164 _ _ . m = modules ;
_ _nested _webpack _require _164 _ _ . c = installedModules ;
_ _nested _webpack _require _164 _ _ . i = function ( value ) {
return value ;
} ;
_ _nested _webpack _require _164 _ _ . d = function ( exports2 , name , getter ) {
if ( ! _ _nested _webpack _require _164 _ _ . o ( exports2 , name ) ) {
Object . defineProperty ( exports2 , name , {
configurable : false ,
enumerable : true ,
get : getter
} ) ;
}
} ;
_ _nested _webpack _require _164 _ _ . r = function ( exports2 ) {
Object . defineProperty ( exports2 , "__esModule" , { value : true } ) ;
} ;
_ _nested _webpack _require _164 _ _ . n = function ( module3 ) {
var getter = module3 && module3 . _ _esModule ? function getDefault ( ) {
return module3 [ "default" ] ;
} : function getModuleExports ( ) {
return module3 ;
} ;
_ _nested _webpack _require _164 _ _ . d ( getter , "a" , getter ) ;
return getter ;
} ;
_ _nested _webpack _require _164 _ _ . o = function ( object , property ) {
return Object . prototype . hasOwnProperty . call ( object , property ) ;
} ;
_ _nested _webpack _require _164 _ _ . p = "/" ;
_ _nested _webpack _require _164 _ _ . oe = function ( err ) {
console . error ( err ) ;
throw err ;
} ;
var f = _ _nested _webpack _require _164 _ _ ( _ _nested _webpack _require _164 _ _ . s = ENTRY _MODULE ) ;
return f . default || f ;
}
var moduleNameReqExp = "[\\.|\\-|\\+|\\w|/|@]+" ;
var dependencyRegExp = "\\(\\s*(/\\*.*?\\*/)?\\s*.*?(" + moduleNameReqExp + ").*?\\)" ;
function quoteRegExp ( str ) {
return ( str + "" ) . replace ( /[.?*+^$[\]\\(){}|-]/g , "\\$&" ) ;
}
function isNumeric ( n ) {
return ! isNaN ( 1 * n ) ;
}
function getModuleDependencies ( sources , module3 , queueName ) {
var retval = { } ;
retval [ queueName ] = [ ] ;
var fnString = module3 . toString ( ) ;
var wrapperSignature = fnString . match ( /^function\s?\w*\(\w+,\s*\w+,\s*(\w+)\)/ ) ;
if ( ! wrapperSignature )
return retval ;
var webpackRequireName = wrapperSignature [ 1 ] ;
var re = new RegExp ( "(\\\\n|\\W)" + quoteRegExp ( webpackRequireName ) + dependencyRegExp , "g" ) ;
var match ;
while ( match = re . exec ( fnString ) ) {
if ( match [ 3 ] === "dll-reference" )
continue ;
retval [ queueName ] . push ( match [ 3 ] ) ;
}
re = new RegExp ( "\\(" + quoteRegExp ( webpackRequireName ) + '\\("(dll-reference\\s(' + moduleNameReqExp + '))"\\)\\)' + dependencyRegExp , "g" ) ;
while ( match = re . exec ( fnString ) ) {
if ( ! sources [ match [ 2 ] ] ) {
retval [ queueName ] . push ( match [ 1 ] ) ;
sources [ match [ 2 ] ] = _ _webpack _require _ _2 ( match [ 1 ] ) . m ;
}
retval [ match [ 2 ] ] = retval [ match [ 2 ] ] || [ ] ;
retval [ match [ 2 ] ] . push ( match [ 4 ] ) ;
}
var keys = Object . keys ( retval ) ;
for ( var i = 0 ; i < keys . length ; i ++ ) {
for ( var j = 0 ; j < retval [ keys [ i ] ] . length ; j ++ ) {
if ( isNumeric ( retval [ keys [ i ] ] [ j ] ) ) {
retval [ keys [ i ] ] [ j ] = 1 * retval [ keys [ i ] ] [ j ] ;
}
}
}
return retval ;
}
function hasValuesInQueues ( queues ) {
var keys = Object . keys ( queues ) ;
return keys . reduce ( function ( hasValues , key ) {
return hasValues || queues [ key ] . length > 0 ;
} , false ) ;
}
function getRequiredModules ( sources , moduleId ) {
var modulesQueue = {
main : [ moduleId ]
} ;
var requiredModules = {
main : [ ]
} ;
var seenModules = {
main : { }
} ;
while ( hasValuesInQueues ( modulesQueue ) ) {
var queues = Object . keys ( modulesQueue ) ;
for ( var i = 0 ; i < queues . length ; i ++ ) {
var queueName = queues [ i ] ;
var queue = modulesQueue [ queueName ] ;
var moduleToCheck = queue . pop ( ) ;
seenModules [ queueName ] = seenModules [ queueName ] || { } ;
if ( seenModules [ queueName ] [ moduleToCheck ] || ! sources [ queueName ] [ moduleToCheck ] )
continue ;
seenModules [ queueName ] [ moduleToCheck ] = true ;
requiredModules [ queueName ] = requiredModules [ queueName ] || [ ] ;
requiredModules [ queueName ] . push ( moduleToCheck ) ;
var newModules = getModuleDependencies ( sources , sources [ queueName ] [ moduleToCheck ] , queueName ) ;
var newModulesKeys = Object . keys ( newModules ) ;
for ( var j = 0 ; j < newModulesKeys . length ; j ++ ) {
modulesQueue [ newModulesKeys [ j ] ] = modulesQueue [ newModulesKeys [ j ] ] || [ ] ;
modulesQueue [ newModulesKeys [ j ] ] = modulesQueue [ newModulesKeys [ j ] ] . concat ( newModules [ newModulesKeys [ j ] ] ) ;
}
}
}
return requiredModules ;
}
module2 . exports = function ( moduleId , options ) {
options = options || { } ;
var sources = {
main : _ _webpack _require _ _2 . m
} ;
var requiredModules = options . all ? { main : Object . keys ( sources . main ) } : getRequiredModules ( sources , moduleId ) ;
var src = "" ;
Object . keys ( requiredModules ) . filter ( function ( m ) {
return m !== "main" ;
} ) . forEach ( function ( module3 ) {
var entryModule = 0 ;
while ( requiredModules [ module3 ] [ entryModule ] ) {
entryModule ++ ;
}
requiredModules [ module3 ] . push ( entryModule ) ;
sources [ module3 ] [ entryModule ] = "(function(module, exports, __webpack_require__) { module.exports = __webpack_require__; })" ;
src = src + "var " + module3 + " = (" + webpackBootstrapFunc . toString ( ) . replace ( "ENTRY_MODULE" , JSON . stringify ( entryModule ) ) + ")({" + requiredModules [ module3 ] . map ( function ( id ) {
return "" + JSON . stringify ( id ) + ": " + sources [ module3 ] [ id ] . toString ( ) ;
} ) . join ( "," ) + "});\n" ;
} ) ;
src = src + "new ((" + webpackBootstrapFunc . toString ( ) . replace ( "ENTRY_MODULE" , JSON . stringify ( moduleId ) ) + ")({" + requiredModules . main . map ( function ( id ) {
return "" + JSON . stringify ( id ) + ": " + sources . main [ id ] . toString ( ) ;
} ) . join ( "," ) + "}))(self);" ;
var blob = new window . Blob ( [ src ] , { type : "text/javascript" } ) ;
if ( options . bare ) {
return blob ;
}
var URL = window . URL || window . webkitURL || window . mozURL || window . msURL ;
var workerUrl = URL . createObjectURL ( blob ) ;
var worker = new window . Worker ( workerUrl ) ;
worker . objectURL = workerUrl ;
return worker ;
} ;
} ,
"./src/config.js" : function ( _ _unused _webpack _module , _ _webpack _exports _ _2 , _ _webpack _require _ _2 ) {
"use strict" ;
_ _webpack _require _ _2 . r ( _ _webpack _exports _ _2 ) ;
_ _webpack _require _ _2 . d ( _ _webpack _exports _ _2 , {
"defaultConfig" : function ( ) {
return defaultConfig ;
} ,
"createDefaultConfig" : function ( ) {
return createDefaultConfig ;
}
} ) ;
var defaultConfig = {
enableWorker : false ,
enableStashBuffer : true ,
stashInitialSize : void 0 ,
isLive : false ,
lazyLoad : true ,
lazyLoadMaxDuration : 3 * 60 ,
lazyLoadRecoverDuration : 30 ,
deferLoadAfterSourceOpen : true ,
autoCleanupMaxBackwardDuration : 3 * 60 ,
autoCleanupMinBackwardDuration : 2 * 60 ,
statisticsInfoReportInterval : 600 ,
fixAudioTimestampGap : true ,
accurateSeek : false ,
seekType : "range" ,
seekParamStart : "bstart" ,
seekParamEnd : "bend" ,
rangeLoadZeroStart : false ,
customSeekHandler : void 0 ,
reuseRedirectedURL : false ,
headers : void 0 ,
customLoader : void 0
} ;
function createDefaultConfig ( ) {
return Object . assign ( { } , defaultConfig ) ;
}
} ,
"./src/core/features.js" : function ( _ _unused _webpack _module , _ _webpack _exports _ _2 , _ _webpack _require _ _2 ) {
"use strict" ;
_ _webpack _require _ _2 . r ( _ _webpack _exports _ _2 ) ;
var _io _io _controller _js _ _WEBPACK _IMPORTED _MODULE _0 _ _ = _ _webpack _require _ _2 ( "./src/io/io-controller.js" ) ;
var _config _js _ _WEBPACK _IMPORTED _MODULE _1 _ _ = _ _webpack _require _ _2 ( "./src/config.js" ) ;
var Features = function ( ) {
function Features2 ( ) {
}
Features2 . supportMSEH264Playback = function ( ) {
return window . MediaSource && window . MediaSource . isTypeSupported ( 'video/mp4; codecs="avc1.42E01E,mp4a.40.2"' ) ;
} ;
Features2 . supportNetworkStreamIO = function ( ) {
var ioctl = new _io _io _controller _js _ _WEBPACK _IMPORTED _MODULE _0 _ _ . default ( { } , ( 0 , _config _js _ _WEBPACK _IMPORTED _MODULE _1 _ _ . createDefaultConfig ) ( ) ) ;
var loaderType = ioctl . loaderType ;
ioctl . destroy ( ) ;
return loaderType == "fetch-stream-loader" || loaderType == "xhr-moz-chunked-loader" ;
} ;
Features2 . getNetworkLoaderTypeName = function ( ) {
var ioctl = new _io _io _controller _js _ _WEBPACK _IMPORTED _MODULE _0 _ _ . default ( { } , ( 0 , _config _js _ _WEBPACK _IMPORTED _MODULE _1 _ _ . createDefaultConfig ) ( ) ) ;
var loaderType = ioctl . loaderType ;
ioctl . destroy ( ) ;
return loaderType ;
} ;
Features2 . supportNativeMediaPlayback = function ( mimeType ) {
if ( Features2 . videoElement == void 0 ) {
Features2 . videoElement = window . document . createElement ( "video" ) ;
}
var canPlay = Features2 . videoElement . canPlayType ( mimeType ) ;
return canPlay === "probably" || canPlay == "maybe" ;
} ;
Features2 . getFeatureList = function ( ) {
var features = {
mseFlvPlayback : false ,
mseLiveFlvPlayback : false ,
networkStreamIO : false ,
networkLoaderName : "" ,
nativeMP4H264Playback : false ,
nativeWebmVP8Playback : false ,
nativeWebmVP9Playback : false
} ;
features . mseFlvPlayback = Features2 . supportMSEH264Playback ( ) ;
features . networkStreamIO = Features2 . supportNetworkStreamIO ( ) ;
features . networkLoaderName = Features2 . getNetworkLoaderTypeName ( ) ;
features . mseLiveFlvPlayback = features . mseFlvPlayback && features . networkStreamIO ;
features . nativeMP4H264Playback = Features2 . supportNativeMediaPlayback ( 'video/mp4; codecs="avc1.42001E, mp4a.40.2"' ) ;
features . nativeWebmVP8Playback = Features2 . supportNativeMediaPlayback ( 'video/webm; codecs="vp8.0, vorbis"' ) ;
features . nativeWebmVP9Playback = Features2 . supportNativeMediaPlayback ( 'video/webm; codecs="vp9"' ) ;
return features ;
} ;
return Features2 ;
} ( ) ;
_ _webpack _exports _ _2 [ "default" ] = Features ;
} ,
"./src/core/media-info.js" : function ( _ _unused _webpack _module , _ _webpack _exports _ _2 , _ _webpack _require _ _2 ) {
"use strict" ;
_ _webpack _require _ _2 . r ( _ _webpack _exports _ _2 ) ;
var MediaInfo = function ( ) {
function MediaInfo2 ( ) {
this . mimeType = null ;
this . duration = null ;
this . hasAudio = null ;
this . hasVideo = null ;
this . audioCodec = null ;
this . videoCodec = null ;
this . audioDataRate = null ;
this . videoDataRate = null ;
this . audioSampleRate = null ;
this . audioChannelCount = null ;
this . width = null ;
this . height = null ;
this . fps = null ;
this . profile = null ;
this . level = null ;
this . refFrames = null ;
this . chromaFormat = null ;
this . sarNum = null ;
this . sarDen = null ;
this . metadata = null ;
this . segments = null ;
this . segmentCount = null ;
this . hasKeyframesIndex = null ;
this . keyframesIndex = null ;
}
MediaInfo2 . prototype . isComplete = function ( ) {
var audioInfoComplete = this . hasAudio === false || this . hasAudio === true && this . audioCodec != null && this . audioSampleRate != null && this . audioChannelCount != null ;
var videoInfoComplete = this . hasVideo === false || this . hasVideo === true && this . videoCodec != null && this . width != null && this . height != null && this . fps != null && this . profile != null && this . level != null && this . refFrames != null && this . chromaFormat != null && this . sarNum != null && this . sarDen != null ;
return this . mimeType != null && this . duration != null && this . metadata != null && this . hasKeyframesIndex != null && audioInfoComplete && videoInfoComplete ;
} ;
MediaInfo2 . prototype . isSeekable = function ( ) {
return this . hasKeyframesIndex === true ;
} ;
MediaInfo2 . prototype . getNearestKeyframe = function ( milliseconds ) {
if ( this . keyframesIndex == null ) {
return null ;
}
var table = this . keyframesIndex ;
var keyframeIdx = this . _search ( table . times , milliseconds ) ;
return {
index : keyframeIdx ,
milliseconds : table . times [ keyframeIdx ] ,
fileposition : table . filepositions [ keyframeIdx ]
} ;
} ;
MediaInfo2 . prototype . _search = function ( list , value ) {
var idx = 0 ;
var last = list . length - 1 ;
var mid = 0 ;
var lbound = 0 ;
var ubound = last ;
if ( value < list [ 0 ] ) {
idx = 0 ;
lbound = ubound + 1 ;
}
while ( lbound <= ubound ) {
mid = lbound + Math . floor ( ( ubound - lbound ) / 2 ) ;
if ( mid === last || value >= list [ mid ] && value < list [ mid + 1 ] ) {
idx = mid ;
break ;
} else if ( list [ mid ] < value ) {
lbound = mid + 1 ;
} else {
ubound = mid - 1 ;
}
}
return idx ;
} ;
return MediaInfo2 ;
} ( ) ;
_ _webpack _exports _ _2 [ "default" ] = MediaInfo ;
} ,
"./src/core/media-segment-info.js" : function ( _ _unused _webpack _module , _ _webpack _exports _ _2 , _ _webpack _require _ _2 ) {
"use strict" ;
_ _webpack _require _ _2 . r ( _ _webpack _exports _ _2 ) ;
_ _webpack _require _ _2 . d ( _ _webpack _exports _ _2 , {
"SampleInfo" : function ( ) {
return SampleInfo ;
} ,
"MediaSegmentInfo" : function ( ) {
return MediaSegmentInfo ;
} ,
"IDRSampleList" : function ( ) {
return IDRSampleList ;
} ,
"MediaSegmentInfoList" : function ( ) {
return MediaSegmentInfoList ;
}
} ) ;
var SampleInfo = function ( ) {
function SampleInfo2 ( dts , pts , duration , originalDts , isSync ) {
this . dts = dts ;
this . pts = pts ;
this . duration = duration ;
this . originalDts = originalDts ;
this . isSyncPoint = isSync ;
this . fileposition = null ;
}
return SampleInfo2 ;
} ( ) ;
var MediaSegmentInfo = function ( ) {
function MediaSegmentInfo2 ( ) {
this . beginDts = 0 ;
this . endDts = 0 ;
this . beginPts = 0 ;
this . endPts = 0 ;
this . originalBeginDts = 0 ;
this . originalEndDts = 0 ;
this . syncPoints = [ ] ;
this . firstSample = null ;
this . lastSample = null ;
}
MediaSegmentInfo2 . prototype . appendSyncPoint = function ( sampleInfo ) {
sampleInfo . isSyncPoint = true ;
this . syncPoints . push ( sampleInfo ) ;
} ;
return MediaSegmentInfo2 ;
} ( ) ;
var IDRSampleList = function ( ) {
function IDRSampleList2 ( ) {
this . _list = [ ] ;
}
IDRSampleList2 . prototype . clear = function ( ) {
this . _list = [ ] ;
} ;
IDRSampleList2 . prototype . appendArray = function ( syncPoints ) {
var list = this . _list ;
if ( syncPoints . length === 0 ) {
return ;
}
if ( list . length > 0 && syncPoints [ 0 ] . originalDts < list [ list . length - 1 ] . originalDts ) {
this . clear ( ) ;
}
Array . prototype . push . apply ( list , syncPoints ) ;
} ;
IDRSampleList2 . prototype . getLastSyncPointBeforeDts = function ( dts ) {
if ( this . _list . length == 0 ) {
return null ;
}
var list = this . _list ;
var idx = 0 ;
var last = list . length - 1 ;
var mid = 0 ;
var lbound = 0 ;
var ubound = last ;
if ( dts < list [ 0 ] . dts ) {
idx = 0 ;
lbound = ubound + 1 ;
}
while ( lbound <= ubound ) {
mid = lbound + Math . floor ( ( ubound - lbound ) / 2 ) ;
if ( mid === last || dts >= list [ mid ] . dts && dts < list [ mid + 1 ] . dts ) {
idx = mid ;
break ;
} else if ( list [ mid ] . dts < dts ) {
lbound = mid + 1 ;
} else {
ubound = mid - 1 ;
}
}
return this . _list [ idx ] ;
} ;
return IDRSampleList2 ;
} ( ) ;
var MediaSegmentInfoList = function ( ) {
function MediaSegmentInfoList2 ( type ) {
this . _type = type ;
this . _list = [ ] ;
this . _lastAppendLocation = - 1 ;
}
Object . defineProperty ( MediaSegmentInfoList2 . prototype , "type" , {
get : function ( ) {
return this . _type ;
} ,
enumerable : false ,
configurable : true
} ) ;
Object . defineProperty ( MediaSegmentInfoList2 . prototype , "length" , {
get : function ( ) {
return this . _list . length ;
} ,
enumerable : false ,
configurable : true
} ) ;
MediaSegmentInfoList2 . prototype . isEmpty = function ( ) {
return this . _list . length === 0 ;
} ;
MediaSegmentInfoList2 . prototype . clear = function ( ) {
this . _list = [ ] ;
this . _lastAppendLocation = - 1 ;
} ;
MediaSegmentInfoList2 . prototype . _searchNearestSegmentBefore = function ( originalBeginDts ) {
var list = this . _list ;
if ( list . length === 0 ) {
return - 2 ;
}
var last = list . length - 1 ;
var mid = 0 ;
var lbound = 0 ;
var ubound = last ;
var idx = 0 ;
if ( originalBeginDts < list [ 0 ] . originalBeginDts ) {
idx = - 1 ;
return idx ;
}
while ( lbound <= ubound ) {
mid = lbound + Math . floor ( ( ubound - lbound ) / 2 ) ;
if ( mid === last || originalBeginDts > list [ mid ] . lastSample . originalDts && originalBeginDts < list [ mid + 1 ] . originalBeginDts ) {
idx = mid ;
break ;
} else if ( list [ mid ] . originalBeginDts < originalBeginDts ) {
lbound = mid + 1 ;
} else {
ubound = mid - 1 ;
}
}
return idx ;
} ;
MediaSegmentInfoList2 . prototype . _searchNearestSegmentAfter = function ( originalBeginDts ) {
return this . _searchNearestSegmentBefore ( originalBeginDts ) + 1 ;
} ;
MediaSegmentInfoList2 . prototype . append = function ( mediaSegmentInfo ) {
var list = this . _list ;
var msi = mediaSegmentInfo ;
var lastAppendIdx = this . _lastAppendLocation ;
var insertIdx = 0 ;
if ( lastAppendIdx !== - 1 && lastAppendIdx < list . length && msi . originalBeginDts >= list [ lastAppendIdx ] . lastSample . originalDts && ( lastAppendIdx === list . length - 1 || lastAppendIdx < list . length - 1 && msi . originalBeginDts < list [ lastAppendIdx + 1 ] . originalBeginDts ) ) {
insertIdx = lastAppendIdx + 1 ;
} else {
if ( list . length > 0 ) {
insertIdx = this . _searchNearestSegmentBefore ( msi . originalBeginDts ) + 1 ;
}
}
this . _lastAppendLocation = insertIdx ;
this . _list . splice ( insertIdx , 0 , msi ) ;
} ;
MediaSegmentInfoList2 . prototype . getLastSegmentBefore = function ( originalBeginDts ) {
var idx = this . _searchNearestSegmentBefore ( originalBeginDts ) ;
if ( idx >= 0 ) {
return this . _list [ idx ] ;
} else {
return null ;
}
} ;
MediaSegmentInfoList2 . prototype . getLastSampleBefore = function ( originalBeginDts ) {
var segment = this . getLastSegmentBefore ( originalBeginDts ) ;
if ( segment != null ) {
return segment . lastSample ;
} else {
return null ;
}
} ;
MediaSegmentInfoList2 . prototype . getLastSyncPointBefore = function ( originalBeginDts ) {
var segmentIdx = this . _searchNearestSegmentBefore ( originalBeginDts ) ;
var syncPoints = this . _list [ segmentIdx ] . syncPoints ;
while ( syncPoints . length === 0 && segmentIdx > 0 ) {
segmentIdx -- ;
syncPoints = this . _list [ segmentIdx ] . syncPoints ;
}
if ( syncPoints . length > 0 ) {
return syncPoints [ syncPoints . length - 1 ] ;
} else {
return null ;
}
} ;
return MediaSegmentInfoList2 ;
} ( ) ;
} ,
"./src/core/mse-controller.js" : function ( _ _unused _webpack _module , _ _webpack _exports _ _2 , _ _webpack _require _ _2 ) {
"use strict" ;
_ _webpack _require _ _2 . r ( _ _webpack _exports _ _2 ) ;
var events _ _WEBPACK _IMPORTED _MODULE _0 _ _ = _ _webpack _require _ _2 ( "./node_modules/events/events.js" ) ;
var events _ _WEBPACK _IMPORTED _MODULE _0 _ _ _default = _ _webpack _require _ _2 . n ( events _ _WEBPACK _IMPORTED _MODULE _0 _ _ ) ;
var _utils _logger _js _ _WEBPACK _IMPORTED _MODULE _1 _ _ = _ _webpack _require _ _2 ( "./src/utils/logger.js" ) ;
var _utils _browser _js _ _WEBPACK _IMPORTED _MODULE _2 _ _ = _ _webpack _require _ _2 ( "./src/utils/browser.js" ) ;
var _mse _events _js _ _WEBPACK _IMPORTED _MODULE _3 _ _ = _ _webpack _require _ _2 ( "./src/core/mse-events.js" ) ;
var _media _segment _info _js _ _WEBPACK _IMPORTED _MODULE _4 _ _ = _ _webpack _require _ _2 ( "./src/core/media-segment-info.js" ) ;
var _utils _exception _js _ _WEBPACK _IMPORTED _MODULE _5 _ _ = _ _webpack _require _ _2 ( "./src/utils/exception.js" ) ;
var MSEController = function ( ) {
function MSEController2 ( config ) {
this . TAG = "MSEController" ;
this . _config = config ;
this . _emitter = new ( events _ _WEBPACK _IMPORTED _MODULE _0 _ _ _default ( ) ) ( ) ;
if ( this . _config . isLive && this . _config . autoCleanupSourceBuffer == void 0 ) {
this . _config . autoCleanupSourceBuffer = true ;
}
this . e = {
onSourceOpen : this . _onSourceOpen . bind ( this ) ,
onSourceEnded : this . _onSourceEnded . bind ( this ) ,
onSourceClose : this . _onSourceClose . bind ( this ) ,
onSourceBufferError : this . _onSourceBufferError . bind ( this ) ,
onSourceBufferUpdateEnd : this . _onSourceBufferUpdateEnd . bind ( this )
} ;
this . _mediaSource = null ;
this . _mediaSourceObjectURL = null ;
this . _mediaElement = null ;
this . _isBufferFull = false ;
this . _hasPendingEos = false ;
this . _requireSetMediaDuration = false ;
this . _pendingMediaDuration = 0 ;
this . _pendingSourceBufferInit = [ ] ;
this . _mimeTypes = {
video : null ,
audio : null
} ;
this . _sourceBuffers = {
video : null ,
audio : null
} ;
this . _lastInitSegments = {
video : null ,
audio : null
} ;
this . _pendingSegments = {
video : [ ] ,
audio : [ ]
} ;
this . _pendingRemoveRanges = {
video : [ ] ,
audio : [ ]
} ;
this . _idrList = new _media _segment _info _js _ _WEBPACK _IMPORTED _MODULE _4 _ _ . IDRSampleList ( ) ;
}
MSEController2 . prototype . destroy = function ( ) {
if ( this . _mediaElement || this . _mediaSource ) {
this . detachMediaElement ( ) ;
}
this . e = null ;
this . _emitter . removeAllListeners ( ) ;
this . _emitter = null ;
} ;
MSEController2 . prototype . on = function ( event , listener ) {
this . _emitter . addListener ( event , listener ) ;
} ;
MSEController2 . prototype . off = function ( event , listener ) {
this . _emitter . removeListener ( event , listener ) ;
} ;
MSEController2 . prototype . attachMediaElement = function ( mediaElement ) {
if ( this . _mediaSource ) {
throw new _utils _exception _js _ _WEBPACK _IMPORTED _MODULE _5 _ _ . IllegalStateException ( "MediaSource has been attached to an HTMLMediaElement!" ) ;
}
var ms = this . _mediaSource = new window . MediaSource ( ) ;
ms . addEventListener ( "sourceopen" , this . e . onSourceOpen ) ;
ms . addEventListener ( "sourceended" , this . e . onSourceEnded ) ;
ms . addEventListener ( "sourceclose" , this . e . onSourceClose ) ;
this . _mediaElement = mediaElement ;
this . _mediaSourceObjectURL = window . URL . createObjectURL ( this . _mediaSource ) ;
mediaElement . src = this . _mediaSourceObjectURL ;
} ;
MSEController2 . prototype . detachMediaElement = function ( ) {
if ( this . _mediaSource ) {
var ms = this . _mediaSource ;
for ( var type in this . _sourceBuffers ) {
var ps = this . _pendingSegments [ type ] ;
ps . splice ( 0 , ps . length ) ;
this . _pendingSegments [ type ] = null ;
this . _pendingRemoveRanges [ type ] = null ;
this . _lastInitSegments [ type ] = null ;
var sb = this . _sourceBuffers [ type ] ;
if ( sb ) {
if ( ms . readyState !== "closed" ) {
try {
ms . removeSourceBuffer ( sb ) ;
} catch ( error ) {
_utils _logger _js _ _WEBPACK _IMPORTED _MODULE _1 _ _ . default . e ( this . TAG , error . message ) ;
}
sb . removeEventListener ( "error" , this . e . onSourceBufferError ) ;
sb . removeEventListener ( "updateend" , this . e . onSourceBufferUpdateEnd ) ;
}
this . _mimeTypes [ type ] = null ;
this . _sourceBuffers [ type ] = null ;
}
}
if ( ms . readyState === "open" ) {
try {
ms . endOfStream ( ) ;
} catch ( error ) {
_utils _logger _js _ _WEBPACK _IMPORTED _MODULE _1 _ _ . default . e ( this . TAG , error . message ) ;
}
}
ms . removeEventListener ( "sourceopen" , this . e . onSourceOpen ) ;
ms . removeEventListener ( "sourceended" , this . e . onSourceEnded ) ;
ms . removeEventListener ( "sourceclose" , this . e . onSourceClose ) ;
this . _pendingSourceBufferInit = [ ] ;
this . _isBufferFull = false ;
this . _idrList . clear ( ) ;
this . _mediaSource = null ;
}
if ( this . _mediaElement ) {
this . _mediaElement . src = "" ;
this . _mediaElement . removeAttribute ( "src" ) ;
this . _mediaElement = null ;
}
if ( this . _mediaSourceObjectURL ) {
window . URL . revokeObjectURL ( this . _mediaSourceObjectURL ) ;
this . _mediaSourceObjectURL = null ;
}
} ;
MSEController2 . prototype . appendInitSegment = function ( initSegment , deferred ) {
if ( ! this . _mediaSource || this . _mediaSource . readyState !== "open" ) {
this . _pendingSourceBufferInit . push ( initSegment ) ;
this . _pendingSegments [ initSegment . type ] . push ( initSegment ) ;
return ;
}
var is = initSegment ;
var mimeType = "" + is . container ;
if ( is . codec && is . codec . length > 0 ) {
mimeType += ";codecs=" + is . codec ;
}
var firstInitSegment = false ;
_utils _logger _js _ _WEBPACK _IMPORTED _MODULE _1 _ _ . default . v ( this . TAG , "Received Initialization Segment, mimeType: " + mimeType ) ;
this . _lastInitSegments [ is . type ] = is ;
if ( mimeType !== this . _mimeTypes [ is . type ] ) {
if ( ! this . _mimeTypes [ is . type ] ) {
firstInitSegment = true ;
try {
var sb = this . _sourceBuffers [ is . type ] = this . _mediaSource . addSourceBuffer ( mimeType ) ;
sb . addEventListener ( "error" , this . e . onSourceBufferError ) ;
sb . addEventListener ( "updateend" , this . e . onSourceBufferUpdateEnd ) ;
} catch ( error ) {
_utils _logger _js _ _WEBPACK _IMPORTED _MODULE _1 _ _ . default . e ( this . TAG , error . message ) ;
this . _emitter . emit ( _mse _events _js _ _WEBPACK _IMPORTED _MODULE _3 _ _ . default . ERROR , { code : error . code , msg : error . message } ) ;
return ;
}
} else {
_utils _logger _js _ _WEBPACK _IMPORTED _MODULE _1 _ _ . default . v ( this . TAG , "Notice: " + is . type + " mimeType changed, origin: " + this . _mimeTypes [ is . type ] + ", target: " + mimeType ) ;
}
this . _mimeTypes [ is . type ] = mimeType ;
}
if ( ! deferred ) {
this . _pendingSegments [ is . type ] . push ( is ) ;
}
if ( ! firstInitSegment ) {
if ( this . _sourceBuffers [ is . type ] && ! this . _sourceBuffers [ is . type ] . updating ) {
this . _doAppendSegments ( ) ;
}
}
if ( _utils _browser _js _ _WEBPACK _IMPORTED _MODULE _2 _ _ . default . safari && is . container === "audio/mpeg" && is . mediaDuration > 0 ) {
this . _requireSetMediaDuration = true ;
this . _pendingMediaDuration = is . mediaDuration / 1e3 ;
this . _updateMediaSourceDuration ( ) ;
}
} ;
MSEController2 . prototype . appendMediaSegment = function ( mediaSegment ) {
var ms = mediaSegment ;
this . _pendingSegments [ ms . type ] . push ( ms ) ;
if ( this . _config . autoCleanupSourceBuffer && this . _needCleanupSourceBuffer ( ) ) {
this . _doCleanupSourceBuffer ( ) ;
}
var sb = this . _sourceBuffers [ ms . type ] ;
if ( sb && ! sb . updating && ! this . _hasPendingRemoveRanges ( ) ) {
this . _doAppendSegments ( ) ;
}
} ;
MSEController2 . prototype . seek = function ( seconds ) {
for ( var type in this . _sourceBuffers ) {
if ( ! this . _sourceBuffers [ type ] ) {
continue ;
}
var sb = this . _sourceBuffers [ type ] ;
if ( this . _mediaSource . readyState === "open" ) {
try {
sb . abort ( ) ;
} catch ( error ) {
_utils _logger _js _ _WEBPACK _IMPORTED _MODULE _1 _ _ . default . e ( this . TAG , error . message ) ;
}
}
this . _idrList . clear ( ) ;
var ps = this . _pendingSegments [ type ] ;
ps . splice ( 0 , ps . length ) ;
if ( this . _mediaSource . readyState === "closed" ) {
continue ;
}
for ( var i = 0 ; i < sb . buffered . length ; i ++ ) {
var start = sb . buffered . start ( i ) ;
var end = sb . buffered . end ( i ) ;
this . _pendingRemoveRanges [ type ] . push ( { start , end } ) ;
}
if ( ! sb . updating ) {
this . _doRemoveRanges ( ) ;
}
if ( _utils _browser _js _ _WEBPACK _IMPORTED _MODULE _2 _ _ . default . safari ) {
var lastInitSegment = this . _lastInitSegments [ type ] ;
if ( lastInitSegment ) {
this . _pendingSegments [ type ] . push ( lastInitSegment ) ;
if ( ! sb . updating ) {
this . _doAppendSegments ( ) ;
}
}
}
}
} ;
MSEController2 . prototype . endOfStream = function ( ) {
var ms = this . _mediaSource ;
var sb = this . _sourceBuffers ;
if ( ! ms || ms . readyState !== "open" ) {
if ( ms && ms . readyState === "closed" && this . _hasPendingSegments ( ) ) {
this . _hasPendingEos = true ;
}
return ;
}
if ( sb . video && sb . video . updating || sb . audio && sb . audio . updating ) {
this . _hasPendingEos = true ;
} else {
this . _hasPendingEos = false ;
ms . endOfStream ( ) ;
}
} ;
MSEController2 . prototype . getNearestKeyframe = function ( dts ) {
return this . _idrList . getLastSyncPointBeforeDts ( dts ) ;
} ;
MSEController2 . prototype . _needCleanupSourceBuffer = function ( ) {
if ( ! this . _config . autoCleanupSourceBuffer ) {
return false ;
}
var currentTime = this . _mediaElement . currentTime ;
for ( var type in this . _sourceBuffers ) {
var sb = this . _sourceBuffers [ type ] ;
if ( sb ) {
var buffered = sb . buffered ;
if ( buffered . length >= 1 ) {
if ( currentTime - buffered . start ( 0 ) >= this . _config . autoCleanupMaxBackwardDuration ) {
return true ;
}
}
}
}
return false ;
} ;
MSEController2 . prototype . _doCleanupSourceBuffer = function ( ) {
var currentTime = this . _mediaElement . currentTime ;
for ( var type in this . _sourceBuffers ) {
var sb = this . _sourceBuffers [ type ] ;
if ( sb ) {
var buffered = sb . buffered ;
var doRemove = false ;
for ( var i = 0 ; i < buffered . length ; i ++ ) {
var start = buffered . start ( i ) ;
var end = buffered . end ( i ) ;
if ( start <= currentTime && currentTime < end + 3 ) {
if ( currentTime - start >= this . _config . autoCleanupMaxBackwardDuration ) {
doRemove = true ;
var removeEnd = currentTime - this . _config . autoCleanupMinBackwardDuration ;
this . _pendingRemoveRanges [ type ] . push ( { start , end : removeEnd } ) ;
}
} else if ( end < currentTime ) {
doRemove = true ;
this . _pendingRemoveRanges [ type ] . push ( { start , end } ) ;
}
}
if ( doRemove && ! sb . updating ) {
this . _doRemoveRanges ( ) ;
}
}
}
} ;
MSEController2 . prototype . _updateMediaSourceDuration = function ( ) {
var sb = this . _sourceBuffers ;
if ( this . _mediaElement . readyState === 0 || this . _mediaSource . readyState !== "open" ) {
return ;
}
if ( sb . video && sb . video . updating || sb . audio && sb . audio . updating ) {
return ;
}
var current = this . _mediaSource . duration ;
var target = this . _pendingMediaDuration ;
if ( target > 0 && ( isNaN ( current ) || target > current ) ) {
_utils _logger _js _ _WEBPACK _IMPORTED _MODULE _1 _ _ . default . v ( this . TAG , "Update MediaSource duration from " + current + " to " + target ) ;
this . _mediaSource . duration = target ;
}
this . _requireSetMediaDuration = false ;
this . _pendingMediaDuration = 0 ;
} ;
MSEController2 . prototype . _doRemoveRanges = function ( ) {
for ( var type in this . _pendingRemoveRanges ) {
if ( ! this . _sourceBuffers [ type ] || this . _sourceBuffers [ type ] . updating ) {
continue ;
}
var sb = this . _sourceBuffers [ type ] ;
var ranges = this . _pendingRemoveRanges [ type ] ;
while ( ranges . length && ! sb . updating ) {
var range = ranges . shift ( ) ;
sb . remove ( range . start , range . end ) ;
}
}
} ;
MSEController2 . prototype . _doAppendSegments = function ( ) {
var pendingSegments = this . _pendingSegments ;
for ( var type in pendingSegments ) {
if ( ! this . _sourceBuffers [ type ] || this . _sourceBuffers [ type ] . updating ) {
continue ;
}
if ( pendingSegments [ type ] . length > 0 ) {
var segment = pendingSegments [ type ] . shift ( ) ;
if ( segment . timestampOffset ) {
var currentOffset = this . _sourceBuffers [ type ] . timestampOffset ;
var targetOffset = segment . timestampOffset / 1e3 ;
var delta = Math . abs ( currentOffset - targetOffset ) ;
if ( delta > 0.1 ) {
_utils _logger _js _ _WEBPACK _IMPORTED _MODULE _1 _ _ . default . v ( this . TAG , "Update MPEG audio timestampOffset from " + currentOffset + " to " + targetOffset ) ;
this . _sourceBuffers [ type ] . timestampOffset = targetOffset ;
}
delete segment . timestampOffset ;
}
if ( ! segment . data || segment . data . byteLength === 0 ) {
continue ;
}
try {
this . _sourceBuffers [ type ] . appendBuffer ( segment . data ) ;
this . _isBufferFull = false ;
if ( type === "video" && segment . hasOwnProperty ( "info" ) ) {
this . _idrList . appendArray ( segment . info . syncPoints ) ;
}
} catch ( error ) {
this . _pendingSegments [ type ] . unshift ( segment ) ;
if ( error . code === 22 ) {
if ( ! this . _isBufferFull ) {
this . _emitter . emit ( _mse _events _js _ _WEBPACK _IMPORTED _MODULE _3 _ _ . default . BUFFER _FULL ) ;
}
this . _isBufferFull = true ;
} else {
_utils _logger _js _ _WEBPACK _IMPORTED _MODULE _1 _ _ . default . e ( this . TAG , error . message ) ;
this . _emitter . emit ( _mse _events _js _ _WEBPACK _IMPORTED _MODULE _3 _ _ . default . ERROR , { code : error . code , msg : error . message } ) ;
}
}
}
}
} ;
MSEController2 . prototype . _onSourceOpen = function ( ) {
_utils _logger _js _ _WEBPACK _IMPORTED _MODULE _1 _ _ . default . v ( this . TAG , "MediaSource onSourceOpen" ) ;
this . _mediaSource . removeEventListener ( "sourceopen" , this . e . onSourceOpen ) ;
if ( this . _pendingSourceBufferInit . length > 0 ) {
var pendings = this . _pendingSourceBufferInit ;
while ( pendings . length ) {
var segment = pendings . shift ( ) ;
this . appendInitSegment ( segment , true ) ;
}
}
if ( this . _hasPendingSegments ( ) ) {
this . _doAppendSegments ( ) ;
}
this . _emitter . emit ( _mse _events _js _ _WEBPACK _IMPORTED _MODULE _3 _ _ . default . SOURCE _OPEN ) ;
} ;
MSEController2 . prototype . _onSourceEnded = function ( ) {
_utils _logger _js _ _WEBPACK _IMPORTED _MODULE _1 _ _ . default . v ( this . TAG , "MediaSource onSourceEnded" ) ;
} ;
MSEController2 . prototype . _onSourceClose = function ( ) {
_utils _logger _js _ _WEBPACK _IMPORTED _MODULE _1 _ _ . default . v ( this . TAG , "MediaSource onSourceClose" ) ;
if ( this . _mediaSource && this . e != null ) {
this . _mediaSource . removeEventListener ( "sourceopen" , this . e . onSourceOpen ) ;
this . _mediaSource . removeEventListener ( "sourceended" , this . e . onSourceEnded ) ;
this . _mediaSource . removeEventListener ( "sourceclose" , this . e . onSourceClose ) ;
}
} ;
MSEController2 . prototype . _hasPendingSegments = function ( ) {
var ps = this . _pendingSegments ;
return ps . video . length > 0 || ps . audio . length > 0 ;
} ;
MSEController2 . prototype . _hasPendingRemoveRanges = function ( ) {
var prr = this . _pendingRemoveRanges ;
return prr . video . length > 0 || prr . audio . length > 0 ;
} ;
MSEController2 . prototype . _onSourceBufferUpdateEnd = function ( ) {
if ( this . _requireSetMediaDuration ) {
this . _updateMediaSourceDuration ( ) ;
} else if ( this . _hasPendingRemoveRanges ( ) ) {
this . _doRemoveRanges ( ) ;
} else if ( this . _hasPendingSegments ( ) ) {
this . _doAppendSegments ( ) ;
} else if ( this . _hasPendingEos ) {
this . endOfStream ( ) ;
}
this . _emitter . emit ( _mse _events _js _ _WEBPACK _IMPORTED _MODULE _3 _ _ . default . UPDATE _END ) ;
} ;
MSEController2 . prototype . _onSourceBufferError = function ( e ) {
_utils _logger _js _ _WEBPACK _IMPORTED _MODULE _1 _ _ . default . e ( this . TAG , "SourceBuffer Error: " + e ) ;
} ;
return MSEController2 ;
} ( ) ;
_ _webpack _exports _ _2 [ "default" ] = MSEController ;
} ,
"./src/core/mse-events.js" : function ( _ _unused _webpack _module , _ _webpack _exports _ _2 , _ _webpack _require _ _2 ) {
"use strict" ;
_ _webpack _require _ _2 . r ( _ _webpack _exports _ _2 ) ;
var MSEEvents = {
ERROR : "error" ,
SOURCE _OPEN : "source_open" ,
UPDATE _END : "update_end" ,
BUFFER _FULL : "buffer_full"
} ;
_ _webpack _exports _ _2 [ "default" ] = MSEEvents ;
} ,
"./src/core/transmuxer.js" : function ( _ _unused _webpack _module , _ _webpack _exports _ _2 , _ _webpack _require _ _2 ) {
"use strict" ;
_ _webpack _require _ _2 . r ( _ _webpack _exports _ _2 ) ;
var events _ _WEBPACK _IMPORTED _MODULE _0 _ _ = _ _webpack _require _ _2 ( "./node_modules/events/events.js" ) ;
var events _ _WEBPACK _IMPORTED _MODULE _0 _ _ _default = _ _webpack _require _ _2 . n ( events _ _WEBPACK _IMPORTED _MODULE _0 _ _ ) ;
var webworkify _webpack _ _WEBPACK _IMPORTED _MODULE _1 _ _ = _ _webpack _require _ _2 ( "./node_modules/webworkify-webpack/index.js" ) ;
var webworkify _webpack _ _WEBPACK _IMPORTED _MODULE _1 _ _ _default = _ _webpack _require _ _2 . n ( webworkify _webpack _ _WEBPACK _IMPORTED _MODULE _1 _ _ ) ;
var _utils _logger _js _ _WEBPACK _IMPORTED _MODULE _2 _ _ = _ _webpack _require _ _2 ( "./src/utils/logger.js" ) ;
var _utils _logging _control _js _ _WEBPACK _IMPORTED _MODULE _3 _ _ = _ _webpack _require _ _2 ( "./src/utils/logging-control.js" ) ;
var _transmuxing _controller _js _ _WEBPACK _IMPORTED _MODULE _4 _ _ = _ _webpack _require _ _2 ( "./src/core/transmuxing-controller.js" ) ;
var _transmuxing _events _js _ _WEBPACK _IMPORTED _MODULE _5 _ _ = _ _webpack _require _ _2 ( "./src/core/transmuxing-events.js" ) ;
var _media _info _js _ _WEBPACK _IMPORTED _MODULE _6 _ _ = _ _webpack _require _ _2 ( "./src/core/media-info.js" ) ;
var Transmuxer = function ( ) {
function Transmuxer2 ( mediaDataSource , config ) {
this . TAG = "Transmuxer" ;
this . _emitter = new ( events _ _WEBPACK _IMPORTED _MODULE _0 _ _ _default ( ) ) ( ) ;
if ( config . enableWorker && typeof Worker !== "undefined" ) {
try {
this . _worker = webworkify _webpack _ _WEBPACK _IMPORTED _MODULE _1 _ _ _default ( ) ( "./src/core/transmuxing-worker.js" ) ;
this . _workerDestroying = false ;
this . _worker . addEventListener ( "message" , this . _onWorkerMessage . bind ( this ) ) ;
this . _worker . postMessage ( { cmd : "init" , param : [ mediaDataSource , config ] } ) ;
this . e = {
onLoggingConfigChanged : this . _onLoggingConfigChanged . bind ( this )
} ;
_utils _logging _control _js _ _WEBPACK _IMPORTED _MODULE _3 _ _ . default . registerListener ( this . e . onLoggingConfigChanged ) ;
this . _worker . postMessage ( { cmd : "logging_config" , param : _utils _logging _control _js _ _WEBPACK _IMPORTED _MODULE _3 _ _ . default . getConfig ( ) } ) ;
} catch ( error ) {
_utils _logger _js _ _WEBPACK _IMPORTED _MODULE _2 _ _ . default . e ( this . TAG , "Error while initialize transmuxing worker, fallback to inline transmuxing" ) ;
this . _worker = null ;
this . _controller = new _transmuxing _controller _js _ _WEBPACK _IMPORTED _MODULE _4 _ _ . default ( mediaDataSource , config ) ;
}
} else {
this . _controller = new _transmuxing _controller _js _ _WEBPACK _IMPORTED _MODULE _4 _ _ . default ( mediaDataSource , config ) ;
}
if ( this . _controller ) {
var ctl = this . _controller ;
ctl . on ( _transmuxing _events _js _ _WEBPACK _IMPORTED _MODULE _5 _ _ . default . IO _ERROR , this . _onIOError . bind ( this ) ) ;
ctl . on ( _transmuxing _events _js _ _WEBPACK _IMPORTED _MODULE _5 _ _ . default . DEMUX _ERROR , this . _onDemuxError . bind ( this ) ) ;
ctl . on ( _transmuxing _events _js _ _WEBPACK _IMPORTED _MODULE _5 _ _ . default . INIT _SEGMENT , this . _onInitSegment . bind ( this ) ) ;
ctl . on ( _transmuxing _events _js _ _WEBPACK _IMPORTED _MODULE _5 _ _ . default . MEDIA _SEGMENT , this . _onMediaSegment . bind ( this ) ) ;
ctl . on ( _transmuxing _events _js _ _WEBPACK _IMPORTED _MODULE _5 _ _ . default . LOADING _COMPLETE , this . _onLoadingComplete . bind ( this ) ) ;
ctl . on ( _transmuxing _events _js _ _WEBPACK _IMPORTED _MODULE _5 _ _ . default . RECOVERED _EARLY _EOF , this . _onRecoveredEarlyEof . bind ( this ) ) ;
ctl . on ( _transmuxing _events _js _ _WEBPACK _IMPORTED _MODULE _5 _ _ . default . MEDIA _INFO , this . _onMediaInfo . bind ( this ) ) ;
ctl . on ( _transmuxing _events _js _ _WEBPACK _IMPORTED _MODULE _5 _ _ . default . METADATA _ARRIVED , this . _onMetaDataArrived . bind ( this ) ) ;
ctl . on ( _transmuxing _events _js _ _WEBPACK _IMPORTED _MODULE _5 _ _ . default . SCRIPTDATA _ARRIVED , this . _onScriptDataArrived . bind ( this ) ) ;
ctl . on ( _transmuxing _events _js _ _WEBPACK _IMPORTED _MODULE _5 _ _ . default . STATISTICS _INFO , this . _onStatisticsInfo . bind ( this ) ) ;
ctl . on ( _transmuxing _events _js _ _WEBPACK _IMPORTED _MODULE _5 _ _ . default . RECOMMEND _SEEKPOINT , this . _onRecommendSeekpoint . bind ( this ) ) ;
}
}
Transmuxer2 . prototype . destroy = function ( ) {
if ( this . _worker ) {
if ( ! this . _workerDestroying ) {
this . _workerDestroying = true ;
this . _worker . postMessage ( { cmd : "destroy" } ) ;
_utils _logging _control _js _ _WEBPACK _IMPORTED _MODULE _3 _ _ . default . removeListener ( this . e . onLoggingConfigChanged ) ;
this . e = null ;
}
} else {
this . _controller . destroy ( ) ;
this . _controller = null ;
}
this . _emitter . removeAllListeners ( ) ;
this . _emitter = null ;
} ;
Transmuxer2 . prototype . on = function ( event , listener ) {
this . _emitter . addListener ( event , listener ) ;
} ;
Transmuxer2 . prototype . off = function ( event , listener ) {
this . _emitter . removeListener ( event , listener ) ;
} ;
Transmuxer2 . prototype . hasWorker = function ( ) {
return this . _worker != null ;
} ;
Transmuxer2 . prototype . open = function ( ) {
if ( this . _worker ) {
this . _worker . postMessage ( { cmd : "start" } ) ;
} else {
this . _controller . start ( ) ;
}
} ;
Transmuxer2 . prototype . close = function ( ) {
if ( this . _worker ) {
this . _worker . postMessage ( { cmd : "stop" } ) ;
} else {
this . _controller . stop ( ) ;
}
} ;
Transmuxer2 . prototype . seek = function ( milliseconds ) {
if ( this . _worker ) {
this . _worker . postMessage ( { cmd : "seek" , param : milliseconds } ) ;
} else {
this . _controller . seek ( milliseconds ) ;
}
} ;
Transmuxer2 . prototype . pause = function ( ) {
if ( this . _worker ) {
this . _worker . postMessage ( { cmd : "pause" } ) ;
} else {
this . _controller . pause ( ) ;
}
} ;
Transmuxer2 . prototype . resume = function ( ) {
if ( this . _worker ) {
this . _worker . postMessage ( { cmd : "resume" } ) ;
} else {
this . _controller . resume ( ) ;
}
} ;
Transmuxer2 . prototype . _onInitSegment = function ( type , initSegment ) {
var _this = this ;
Promise . resolve ( ) . then ( function ( ) {
_this . _emitter . emit ( _transmuxing _events _js _ _WEBPACK _IMPORTED _MODULE _5 _ _ . default . INIT _SEGMENT , type , initSegment ) ;
} ) ;
} ;
Transmuxer2 . prototype . _onMediaSegment = function ( type , mediaSegment ) {
var _this = this ;
Promise . resolve ( ) . then ( function ( ) {
_this . _emitter . emit ( _transmuxing _events _js _ _WEBPACK _IMPORTED _MODULE _5 _ _ . default . MEDIA _SEGMENT , type , mediaSegment ) ;
} ) ;
} ;
Transmuxer2 . prototype . _onLoadingComplete = function ( ) {
var _this = this ;
Promise . resolve ( ) . then ( function ( ) {
_this . _emitter . emit ( _transmuxing _events _js _ _WEBPACK _IMPORTED _MODULE _5 _ _ . default . LOADING _COMPLETE ) ;
} ) ;
} ;
Transmuxer2 . prototype . _onRecoveredEarlyEof = function ( ) {
var _this = this ;
Promise . resolve ( ) . then ( function ( ) {
_this . _emitter . emit ( _transmuxing _events _js _ _WEBPACK _IMPORTED _MODULE _5 _ _ . default . RECOVERED _EARLY _EOF ) ;
} ) ;
} ;
Transmuxer2 . prototype . _onMediaInfo = function ( mediaInfo ) {
var _this = this ;
Promise . resolve ( ) . then ( function ( ) {
_this . _emitter . emit ( _transmuxing _events _js _ _WEBPACK _IMPORTED _MODULE _5 _ _ . default . MEDIA _INFO , mediaInfo ) ;
} ) ;
} ;
Transmuxer2 . prototype . _onMetaDataArrived = function ( metadata ) {
var _this = this ;
Promise . resolve ( ) . then ( function ( ) {
_this . _emitter . emit ( _transmuxing _events _js _ _WEBPACK _IMPORTED _MODULE _5 _ _ . default . METADATA _ARRIVED , metadata ) ;
} ) ;
} ;
Transmuxer2 . prototype . _onScriptDataArrived = function ( data ) {
var _this = this ;
Promise . resolve ( ) . then ( function ( ) {
_this . _emitter . emit ( _transmuxing _events _js _ _WEBPACK _IMPORTED _MODULE _5 _ _ . default . SCRIPTDATA _ARRIVED , data ) ;
} ) ;
} ;
Transmuxer2 . prototype . _onStatisticsInfo = function ( statisticsInfo ) {
var _this = this ;
Promise . resolve ( ) . then ( function ( ) {
_this . _emitter . emit ( _transmuxing _events _js _ _WEBPACK _IMPORTED _MODULE _5 _ _ . default . STATISTICS _INFO , statisticsInfo ) ;
} ) ;
} ;
Transmuxer2 . prototype . _onIOError = function ( type , info ) {
var _this = this ;
Promise . resolve ( ) . then ( function ( ) {
_this . _emitter . emit ( _transmuxing _events _js _ _WEBPACK _IMPORTED _MODULE _5 _ _ . default . IO _ERROR , type , info ) ;
} ) ;
} ;
Transmuxer2 . prototype . _onDemuxError = function ( type , info ) {
var _this = this ;
Promise . resolve ( ) . then ( function ( ) {
_this . _emitter . emit ( _transmuxing _events _js _ _WEBPACK _IMPORTED _MODULE _5 _ _ . default . DEMUX _ERROR , type , info ) ;
} ) ;
} ;
Transmuxer2 . prototype . _onRecommendSeekpoint = function ( milliseconds ) {
var _this = this ;
Promise . resolve ( ) . then ( function ( ) {
_this . _emitter . emit ( _transmuxing _events _js _ _WEBPACK _IMPORTED _MODULE _5 _ _ . default . RECOMMEND _SEEKPOINT , milliseconds ) ;
} ) ;
} ;
Transmuxer2 . prototype . _onLoggingConfigChanged = function ( config ) {
if ( this . _worker ) {
this . _worker . postMessage ( { cmd : "logging_config" , param : config } ) ;
}
} ;
Transmuxer2 . prototype . _onWorkerMessage = function ( e ) {
var message = e . data ;
var data = message . data ;
if ( message . msg === "destroyed" || this . _workerDestroying ) {
this . _workerDestroying = false ;
this . _worker . terminate ( ) ;
this . _worker = null ;
return ;
}
switch ( message . msg ) {
case _transmuxing _events _js _ _WEBPACK _IMPORTED _MODULE _5 _ _ . default . INIT _SEGMENT :
case _transmuxing _events _js _ _WEBPACK _IMPORTED _MODULE _5 _ _ . default . MEDIA _SEGMENT :
this . _emitter . emit ( message . msg , data . type , data . data ) ;
break ;
case _transmuxing _events _js _ _WEBPACK _IMPORTED _MODULE _5 _ _ . default . LOADING _COMPLETE :
case _transmuxing _events _js _ _WEBPACK _IMPORTED _MODULE _5 _ _ . default . RECOVERED _EARLY _EOF :
this . _emitter . emit ( message . msg ) ;
break ;
case _transmuxing _events _js _ _WEBPACK _IMPORTED _MODULE _5 _ _ . default . MEDIA _INFO :
Object . setPrototypeOf ( data , _media _info _js _ _WEBPACK _IMPORTED _MODULE _6 _ _ . default . prototype ) ;
this . _emitter . emit ( message . msg , data ) ;
break ;
case _transmuxing _events _js _ _WEBPACK _IMPORTED _MODULE _5 _ _ . default . METADATA _ARRIVED :
case _transmuxing _events _js _ _WEBPACK _IMPORTED _MODULE _5 _ _ . default . SCRIPTDATA _ARRIVED :
case _transmuxing _events _js _ _WEBPACK _IMPORTED _MODULE _5 _ _ . default . STATISTICS _INFO :
this . _emitter . emit ( message . msg , data ) ;
break ;
case _transmuxing _events _js _ _WEBPACK _IMPORTED _MODULE _5 _ _ . default . IO _ERROR :
case _transmuxing _events _js _ _WEBPACK _IMPORTED _MODULE _5 _ _ . default . DEMUX _ERROR :
this . _emitter . emit ( message . msg , data . type , data . info ) ;
break ;
case _transmuxing _events _js _ _WEBPACK _IMPORTED _MODULE _5 _ _ . default . RECOMMEND _SEEKPOINT :
this . _emitter . emit ( message . msg , data ) ;
break ;
case "logcat_callback" :
_utils _logger _js _ _WEBPACK _IMPORTED _MODULE _2 _ _ . default . emitter . emit ( "log" , data . type , data . logcat ) ;
break ;
default :
break ;
}
} ;
return Transmuxer2 ;
} ( ) ;
_ _webpack _exports _ _2 [ "default" ] = Transmuxer ;
} ,
"./src/core/transmuxing-controller.js" : function ( _ _unused _webpack _module , _ _webpack _exports _ _2 , _ _webpack _require _ _2 ) {
"use strict" ;
_ _webpack _require _ _2 . r ( _ _webpack _exports _ _2 ) ;
var events _ _WEBPACK _IMPORTED _MODULE _0 _ _ = _ _webpack _require _ _2 ( "./node_modules/events/events.js" ) ;
var events _ _WEBPACK _IMPORTED _MODULE _0 _ _ _default = _ _webpack _require _ _2 . n ( events _ _WEBPACK _IMPORTED _MODULE _0 _ _ ) ;
var _utils _logger _js _ _WEBPACK _IMPORTED _MODULE _1 _ _ = _ _webpack _require _ _2 ( "./src/utils/logger.js" ) ;
var _utils _browser _js _ _WEBPACK _IMPORTED _MODULE _2 _ _ = _ _webpack _require _ _2 ( "./src/utils/browser.js" ) ;
var _media _info _js _ _WEBPACK _IMPORTED _MODULE _3 _ _ = _ _webpack _require _ _2 ( "./src/core/media-info.js" ) ;
var _demux _flv _demuxer _js _ _WEBPACK _IMPORTED _MODULE _4 _ _ = _ _webpack _require _ _2 ( "./src/demux/flv-demuxer.js" ) ;
var _remux _mp4 _remuxer _js _ _WEBPACK _IMPORTED _MODULE _5 _ _ = _ _webpack _require _ _2 ( "./src/remux/mp4-remuxer.js" ) ;
var _demux _demux _errors _js _ _WEBPACK _IMPORTED _MODULE _6 _ _ = _ _webpack _require _ _2 ( "./src/demux/demux-errors.js" ) ;
var _io _io _controller _js _ _WEBPACK _IMPORTED _MODULE _7 _ _ = _ _webpack _require _ _2 ( "./src/io/io-controller.js" ) ;
var _transmuxing _events _js _ _WEBPACK _IMPORTED _MODULE _8 _ _ = _ _webpack _require _ _2 ( "./src/core/transmuxing-events.js" ) ;
var TransmuxingController = function ( ) {
function TransmuxingController2 ( mediaDataSource , config ) {
this . TAG = "TransmuxingController" ;
this . _emitter = new ( events _ _WEBPACK _IMPORTED _MODULE _0 _ _ _default ( ) ) ( ) ;
this . _config = config ;
if ( ! mediaDataSource . segments ) {
mediaDataSource . segments = [ {
duration : mediaDataSource . duration ,
filesize : mediaDataSource . filesize ,
url : mediaDataSource . url
} ] ;
}
if ( typeof mediaDataSource . cors !== "boolean" ) {
mediaDataSource . cors = true ;
}
if ( typeof mediaDataSource . withCredentials !== "boolean" ) {
mediaDataSource . withCredentials = false ;
}
this . _mediaDataSource = mediaDataSource ;
this . _currentSegmentIndex = 0 ;
var totalDuration = 0 ;
this . _mediaDataSource . segments . forEach ( function ( segment ) {
segment . timestampBase = totalDuration ;
totalDuration += segment . duration ;
segment . cors = mediaDataSource . cors ;
segment . withCredentials = mediaDataSource . withCredentials ;
if ( config . referrerPolicy ) {
segment . referrerPolicy = config . referrerPolicy ;
}
} ) ;
if ( ! isNaN ( totalDuration ) && this . _mediaDataSource . duration !== totalDuration ) {
this . _mediaDataSource . duration = totalDuration ;
}
this . _mediaInfo = null ;
this . _demuxer = null ;
this . _remuxer = null ;
this . _ioctl = null ;
this . _pendingSeekTime = null ;
this . _pendingResolveSeekPoint = null ;
this . _statisticsReporter = null ;
}
TransmuxingController2 . prototype . destroy = function ( ) {
this . _mediaInfo = null ;
this . _mediaDataSource = null ;
if ( this . _statisticsReporter ) {
this . _disableStatisticsReporter ( ) ;
}
if ( this . _ioctl ) {
this . _ioctl . destroy ( ) ;
this . _ioctl = null ;
}
if ( this . _demuxer ) {
this . _demuxer . destroy ( ) ;
this . _demuxer = null ;
}
if ( this . _remuxer ) {
this . _remuxer . destroy ( ) ;
this . _remuxer = null ;
}
this . _emitter . removeAllListeners ( ) ;
this . _emitter = null ;
} ;
TransmuxingController2 . prototype . on = function ( event , listener ) {
this . _emitter . addListener ( event , listener ) ;
} ;
TransmuxingController2 . prototype . off = function ( event , listener ) {
this . _emitter . removeListener ( event , listener ) ;
} ;
TransmuxingController2 . prototype . start = function ( ) {
this . _loadSegment ( 0 ) ;
this . _enableStatisticsReporter ( ) ;
} ;
TransmuxingController2 . prototype . _loadSegment = function ( segmentIndex , optionalFrom ) {
this . _currentSegmentIndex = segmentIndex ;
var dataSource = this . _mediaDataSource . segments [ segmentIndex ] ;
var ioctl = this . _ioctl = new _io _io _controller _js _ _WEBPACK _IMPORTED _MODULE _7 _ _ . default ( dataSource , this . _config , segmentIndex ) ;
ioctl . onError = this . _onIOException . bind ( this ) ;
ioctl . onSeeked = this . _onIOSeeked . bind ( this ) ;
ioctl . onComplete = this . _onIOComplete . bind ( this ) ;
ioctl . onRedirect = this . _onIORedirect . bind ( this ) ;
ioctl . onRecoveredEarlyEof = this . _onIORecoveredEarlyEof . bind ( this ) ;
if ( optionalFrom ) {
this . _demuxer . bindDataSource ( this . _ioctl ) ;
} else {
ioctl . onDataArrival = this . _onInitChunkArrival . bind ( this ) ;
}
ioctl . open ( optionalFrom ) ;
} ;
TransmuxingController2 . prototype . stop = function ( ) {
this . _internalAbort ( ) ;
this . _disableStatisticsReporter ( ) ;
} ;
TransmuxingController2 . prototype . _internalAbort = function ( ) {
if ( this . _ioctl ) {
this . _ioctl . destroy ( ) ;
this . _ioctl = null ;
}
} ;
TransmuxingController2 . prototype . pause = function ( ) {
if ( this . _ioctl && this . _ioctl . isWorking ( ) ) {
this . _ioctl . pause ( ) ;
this . _disableStatisticsReporter ( ) ;
}
} ;
TransmuxingController2 . prototype . resume = function ( ) {
if ( this . _ioctl && this . _ioctl . isPaused ( ) ) {
this . _ioctl . resume ( ) ;
this . _enableStatisticsReporter ( ) ;
}
} ;
TransmuxingController2 . prototype . seek = function ( milliseconds ) {
if ( this . _mediaInfo == null || ! this . _mediaInfo . isSeekable ( ) ) {
return ;
}
var targetSegmentIndex = this . _searchSegmentIndexContains ( milliseconds ) ;
if ( targetSegmentIndex === this . _currentSegmentIndex ) {
var segmentInfo = this . _mediaInfo . segments [ targetSegmentIndex ] ;
if ( segmentInfo == void 0 ) {
this . _pendingSeekTime = milliseconds ;
} else {
var keyframe = segmentInfo . getNearestKeyframe ( milliseconds ) ;
this . _remuxer . seek ( keyframe . milliseconds ) ;
this . _ioctl . seek ( keyframe . fileposition ) ;
this . _pendingResolveSeekPoint = keyframe . milliseconds ;
}
} else {
var targetSegmentInfo = this . _mediaInfo . segments [ targetSegmentIndex ] ;
if ( targetSegmentInfo == void 0 ) {
this . _pendingSeekTime = milliseconds ;
this . _internalAbort ( ) ;
this . _remuxer . seek ( ) ;
this . _remuxer . insertDiscontinuity ( ) ;
this . _loadSegment ( targetSegmentIndex ) ;
} else {
var keyframe = targetSegmentInfo . getNearestKeyframe ( milliseconds ) ;
this . _internalAbort ( ) ;
this . _remuxer . seek ( milliseconds ) ;
this . _remuxer . insertDiscontinuity ( ) ;
this . _demuxer . resetMediaInfo ( ) ;
this . _demuxer . timestampBase = this . _mediaDataSource . segments [ targetSegmentIndex ] . timestampBase ;
this . _loadSegment ( targetSegmentIndex , keyframe . fileposition ) ;
this . _pendingResolveSeekPoint = keyframe . milliseconds ;
this . _reportSegmentMediaInfo ( targetSegmentIndex ) ;
}
}
this . _enableStatisticsReporter ( ) ;
} ;
TransmuxingController2 . prototype . _searchSegmentIndexContains = function ( milliseconds ) {
var segments = this . _mediaDataSource . segments ;
var idx = segments . length - 1 ;
for ( var i = 0 ; i < segments . length ; i ++ ) {
if ( milliseconds < segments [ i ] . timestampBase ) {
idx = i - 1 ;
break ;
}
}
return idx ;
} ;
TransmuxingController2 . prototype . _onInitChunkArrival = function ( data , byteStart ) {
var _this = this ;
var probeData = null ;
var consumed = 0 ;
if ( byteStart > 0 ) {
this . _demuxer . bindDataSource ( this . _ioctl ) ;
this . _demuxer . timestampBase = this . _mediaDataSource . segments [ this . _currentSegmentIndex ] . timestampBase ;
consumed = this . _demuxer . parseChunks ( data , byteStart ) ;
} else if ( ( probeData = _demux _flv _demuxer _js _ _WEBPACK _IMPORTED _MODULE _4 _ _ . default . probe ( data ) ) . match ) {
this . _demuxer = new _demux _flv _demuxer _js _ _WEBPACK _IMPORTED _MODULE _4 _ _ . default ( probeData , this . _config ) ;
if ( ! this . _remuxer ) {
this . _remuxer = new _remux _mp4 _remuxer _js _ _WEBPACK _IMPORTED _MODULE _5 _ _ . default ( this . _config ) ;
}
var mds = this . _mediaDataSource ;
if ( mds . duration != void 0 && ! isNaN ( mds . duration ) ) {
this . _demuxer . overridedDuration = mds . duration ;
}
if ( typeof mds . hasAudio === "boolean" ) {
this . _demuxer . overridedHasAudio = mds . hasAudio ;
}
if ( typeof mds . hasVideo === "boolean" ) {
this . _demuxer . overridedHasVideo = mds . hasVideo ;
}
this . _demuxer . timestampBase = mds . segments [ this . _currentSegmentIndex ] . timestampBase ;
this . _demuxer . onError = this . _onDemuxException . bind ( this ) ;
this . _demuxer . onMediaInfo = this . _onMediaInfo . bind ( this ) ;
this . _demuxer . onMetaDataArrived = this . _onMetaDataArrived . bind ( this ) ;
this . _demuxer . onScriptDataArrived = this . _onScriptDataArrived . bind ( this ) ;
this . _remuxer . bindDataSource ( this . _demuxer . bindDataSource ( this . _ioctl ) ) ;
this . _remuxer . onInitSegment = this . _onRemuxerInitSegmentArrival . bind ( this ) ;
this . _remuxer . onMediaSegment = this . _onRemuxerMediaSegmentArrival . bind ( this ) ;
consumed = this . _demuxer . parseChunks ( data , byteStart ) ;
} else {
probeData = null ;
_utils _logger _js _ _WEBPACK _IMPORTED _MODULE _1 _ _ . default . e ( this . TAG , "Non-FLV, Unsupported media type!" ) ;
Promise . resolve ( ) . then ( function ( ) {
_this . _internalAbort ( ) ;
} ) ;
this . _emitter . emit ( _transmuxing _events _js _ _WEBPACK _IMPORTED _MODULE _8 _ _ . default . DEMUX _ERROR , _demux _demux _errors _js _ _WEBPACK _IMPORTED _MODULE _6 _ _ . default . FORMAT _UNSUPPORTED , "Non-FLV, Unsupported media type" ) ;
consumed = 0 ;
}
return consumed ;
} ;
TransmuxingController2 . prototype . _onMediaInfo = function ( mediaInfo ) {
var _this = this ;
if ( this . _mediaInfo == null ) {
this . _mediaInfo = Object . assign ( { } , mediaInfo ) ;
this . _mediaInfo . keyframesIndex = null ;
this . _mediaInfo . segments = [ ] ;
this . _mediaInfo . segmentCount = this . _mediaDataSource . segments . length ;
Object . setPrototypeOf ( this . _mediaInfo , _media _info _js _ _WEBPACK _IMPORTED _MODULE _3 _ _ . default . prototype ) ;
}
var segmentInfo = Object . assign ( { } , mediaInfo ) ;
Object . setPrototypeOf ( segmentInfo , _media _info _js _ _WEBPACK _IMPORTED _MODULE _3 _ _ . default . prototype ) ;
this . _mediaInfo . segments [ this . _currentSegmentIndex ] = segmentInfo ;
this . _reportSegmentMediaInfo ( this . _currentSegmentIndex ) ;
if ( this . _pendingSeekTime != null ) {
Promise . resolve ( ) . then ( function ( ) {
var target = _this . _pendingSeekTime ;
_this . _pendingSeekTime = null ;
_this . seek ( target ) ;
} ) ;
}
} ;
TransmuxingController2 . prototype . _onMetaDataArrived = function ( metadata ) {
this . _emitter . emit ( _transmuxing _events _js _ _WEBPACK _IMPORTED _MODULE _8 _ _ . default . METADATA _ARRIVED , metadata ) ;
} ;
TransmuxingController2 . prototype . _onScriptDataArrived = function ( data ) {
this . _emitter . emit ( _transmuxing _events _js _ _WEBPACK _IMPORTED _MODULE _8 _ _ . default . SCRIPTDATA _ARRIVED , data ) ;
} ;
TransmuxingController2 . prototype . _onIOSeeked = function ( ) {
this . _remuxer . insertDiscontinuity ( ) ;
} ;
TransmuxingController2 . prototype . _onIOComplete = function ( extraData ) {
var segmentIndex = extraData ;
var nextSegmentIndex = segmentIndex + 1 ;
if ( nextSegmentIndex < this . _mediaDataSource . segments . length ) {
this . _internalAbort ( ) ;
this . _remuxer . flushStashedSamples ( ) ;
this . _loadSegment ( nextSegmentIndex ) ;
} else {
this . _remuxer . flushStashedSamples ( ) ;
this . _emitter . emit ( _transmuxing _events _js _ _WEBPACK _IMPORTED _MODULE _8 _ _ . default . LOADING _COMPLETE ) ;
this . _disableStatisticsReporter ( ) ;
}
} ;
TransmuxingController2 . prototype . _onIORedirect = function ( redirectedURL ) {
var segmentIndex = this . _ioctl . extraData ;
this . _mediaDataSource . segments [ segmentIndex ] . redirectedURL = redirectedURL ;
} ;
TransmuxingController2 . prototype . _onIORecoveredEarlyEof = function ( ) {
this . _emitter . emit ( _transmuxing _events _js _ _WEBPACK _IMPORTED _MODULE _8 _ _ . default . RECOVERED _EARLY _EOF ) ;
} ;
TransmuxingController2 . prototype . _onIOException = function ( type , info ) {
_utils _logger _js _ _WEBPACK _IMPORTED _MODULE _1 _ _ . default . e ( this . TAG , "IOException: type = " + type + ", code = " + info . code + ", msg = " + info . msg ) ;
this . _emitter . emit ( _transmuxing _events _js _ _WEBPACK _IMPORTED _MODULE _8 _ _ . default . IO _ERROR , type , info ) ;
this . _disableStatisticsReporter ( ) ;
} ;
TransmuxingController2 . prototype . _onDemuxException = function ( type , info ) {
_utils _logger _js _ _WEBPACK _IMPORTED _MODULE _1 _ _ . default . e ( this . TAG , "DemuxException: type = " + type + ", info = " + info ) ;
this . _emitter . emit ( _transmuxing _events _js _ _WEBPACK _IMPORTED _MODULE _8 _ _ . default . DEMUX _ERROR , type , info ) ;
} ;
TransmuxingController2 . prototype . _onRemuxerInitSegmentArrival = function ( type , initSegment ) {
this . _emitter . emit ( _transmuxing _events _js _ _WEBPACK _IMPORTED _MODULE _8 _ _ . default . INIT _SEGMENT , type , initSegment ) ;
} ;
TransmuxingController2 . prototype . _onRemuxerMediaSegmentArrival = function ( type , mediaSegment ) {
if ( this . _pendingSeekTime != null ) {
return ;
}
this . _emitter . emit ( _transmuxing _events _js _ _WEBPACK _IMPORTED _MODULE _8 _ _ . default . MEDIA _SEGMENT , type , mediaSegment ) ;
if ( this . _pendingResolveSeekPoint != null && type === "video" ) {
var syncPoints = mediaSegment . info . syncPoints ;
var seekpoint = this . _pendingResolveSeekPoint ;
this . _pendingResolveSeekPoint = null ;
if ( _utils _browser _js _ _WEBPACK _IMPORTED _MODULE _2 _ _ . default . safari && syncPoints . length > 0 && syncPoints [ 0 ] . originalDts === seekpoint ) {
seekpoint = syncPoints [ 0 ] . pts ;
}
this . _emitter . emit ( _transmuxing _events _js _ _WEBPACK _IMPORTED _MODULE _8 _ _ . default . RECOMMEND _SEEKPOINT , seekpoint ) ;
}
} ;
TransmuxingController2 . prototype . _enableStatisticsReporter = function ( ) {
if ( this . _statisticsReporter == null ) {
this . _statisticsReporter = self . setInterval ( this . _reportStatisticsInfo . bind ( this ) , this . _config . statisticsInfoReportInterval ) ;
}
} ;
TransmuxingController2 . prototype . _disableStatisticsReporter = function ( ) {
if ( this . _statisticsReporter ) {
self . clearInterval ( this . _statisticsReporter ) ;
this . _statisticsReporter = null ;
}
} ;
TransmuxingController2 . prototype . _reportSegmentMediaInfo = function ( segmentIndex ) {
var segmentInfo = this . _mediaInfo . segments [ segmentIndex ] ;
var exportInfo = Object . assign ( { } , segmentInfo ) ;
exportInfo . duration = this . _mediaInfo . duration ;
exportInfo . segmentCount = this . _mediaInfo . segmentCount ;
delete exportInfo . segments ;
delete exportInfo . keyframesIndex ;
this . _emitter . emit ( _transmuxing _events _js _ _WEBPACK _IMPORTED _MODULE _8 _ _ . default . MEDIA _INFO , exportInfo ) ;
} ;
TransmuxingController2 . prototype . _reportStatisticsInfo = function ( ) {
var info = { } ;
info . url = this . _ioctl . currentURL ;
info . hasRedirect = this . _ioctl . hasRedirect ;
if ( info . hasRedirect ) {
info . redirectedURL = this . _ioctl . currentRedirectedURL ;
}
info . speed = this . _ioctl . currentSpeed ;
info . loaderType = this . _ioctl . loaderType ;
info . currentSegmentIndex = this . _currentSegmentIndex ;
info . totalSegmentCount = this . _mediaDataSource . segments . length ;
this . _emitter . emit ( _transmuxing _events _js _ _WEBPACK _IMPORTED _MODULE _8 _ _ . default . STATISTICS _INFO , info ) ;
} ;
return TransmuxingController2 ;
} ( ) ;
_ _webpack _exports _ _2 [ "default" ] = TransmuxingController ;
} ,
"./src/core/transmuxing-events.js" : function ( _ _unused _webpack _module , _ _webpack _exports _ _2 , _ _webpack _require _ _2 ) {
"use strict" ;
_ _webpack _require _ _2 . r ( _ _webpack _exports _ _2 ) ;
var TransmuxingEvents = {
IO _ERROR : "io_error" ,
DEMUX _ERROR : "demux_error" ,
INIT _SEGMENT : "init_segment" ,
MEDIA _SEGMENT : "media_segment" ,
LOADING _COMPLETE : "loading_complete" ,
RECOVERED _EARLY _EOF : "recovered_early_eof" ,
MEDIA _INFO : "media_info" ,
METADATA _ARRIVED : "metadata_arrived" ,
SCRIPTDATA _ARRIVED : "scriptdata_arrived" ,
STATISTICS _INFO : "statistics_info" ,
RECOMMEND _SEEKPOINT : "recommend_seekpoint"
} ;
_ _webpack _exports _ _2 [ "default" ] = TransmuxingEvents ;
} ,
"./src/core/transmuxing-worker.js" : function ( _ _unused _webpack _module , _ _webpack _exports _ _2 , _ _webpack _require _ _2 ) {
"use strict" ;
_ _webpack _require _ _2 . r ( _ _webpack _exports _ _2 ) ;
var _utils _logging _control _js _ _WEBPACK _IMPORTED _MODULE _0 _ _ = _ _webpack _require _ _2 ( "./src/utils/logging-control.js" ) ;
var _utils _polyfill _js _ _WEBPACK _IMPORTED _MODULE _1 _ _ = _ _webpack _require _ _2 ( "./src/utils/polyfill.js" ) ;
var _transmuxing _controller _js _ _WEBPACK _IMPORTED _MODULE _2 _ _ = _ _webpack _require _ _2 ( "./src/core/transmuxing-controller.js" ) ;
var _transmuxing _events _js _ _WEBPACK _IMPORTED _MODULE _3 _ _ = _ _webpack _require _ _2 ( "./src/core/transmuxing-events.js" ) ;
var TransmuxingWorker = function ( self2 ) {
var TAG = "TransmuxingWorker" ;
var controller = null ;
var logcatListener = onLogcatCallback . bind ( this ) ;
_utils _polyfill _js _ _WEBPACK _IMPORTED _MODULE _1 _ _ . default . install ( ) ;
self2 . addEventListener ( "message" , function ( e ) {
switch ( e . data . cmd ) {
case "init" :
controller = new _transmuxing _controller _js _ _WEBPACK _IMPORTED _MODULE _2 _ _ . default ( e . data . param [ 0 ] , e . data . param [ 1 ] ) ;
controller . on ( _transmuxing _events _js _ _WEBPACK _IMPORTED _MODULE _3 _ _ . default . IO _ERROR , onIOError . bind ( this ) ) ;
controller . on ( _transmuxing _events _js _ _WEBPACK _IMPORTED _MODULE _3 _ _ . default . DEMUX _ERROR , onDemuxError . bind ( this ) ) ;
controller . on ( _transmuxing _events _js _ _WEBPACK _IMPORTED _MODULE _3 _ _ . default . INIT _SEGMENT , onInitSegment . bind ( this ) ) ;
controller . on ( _transmuxing _events _js _ _WEBPACK _IMPORTED _MODULE _3 _ _ . default . MEDIA _SEGMENT , onMediaSegment . bind ( this ) ) ;
controller . on ( _transmuxing _events _js _ _WEBPACK _IMPORTED _MODULE _3 _ _ . default . LOADING _COMPLETE , onLoadingComplete . bind ( this ) ) ;
controller . on ( _transmuxing _events _js _ _WEBPACK _IMPORTED _MODULE _3 _ _ . default . RECOVERED _EARLY _EOF , onRecoveredEarlyEof . bind ( this ) ) ;
controller . on ( _transmuxing _events _js _ _WEBPACK _IMPORTED _MODULE _3 _ _ . default . MEDIA _INFO , onMediaInfo . bind ( this ) ) ;
controller . on ( _transmuxing _events _js _ _WEBPACK _IMPORTED _MODULE _3 _ _ . default . METADATA _ARRIVED , onMetaDataArrived . bind ( this ) ) ;
controller . on ( _transmuxing _events _js _ _WEBPACK _IMPORTED _MODULE _3 _ _ . default . SCRIPTDATA _ARRIVED , onScriptDataArrived . bind ( this ) ) ;
controller . on ( _transmuxing _events _js _ _WEBPACK _IMPORTED _MODULE _3 _ _ . default . STATISTICS _INFO , onStatisticsInfo . bind ( this ) ) ;
controller . on ( _transmuxing _events _js _ _WEBPACK _IMPORTED _MODULE _3 _ _ . default . RECOMMEND _SEEKPOINT , onRecommendSeekpoint . bind ( this ) ) ;
break ;
case "destroy" :
if ( controller ) {
controller . destroy ( ) ;
controller = null ;
}
self2 . postMessage ( { msg : "destroyed" } ) ;
break ;
case "start" :
controller . start ( ) ;
break ;
case "stop" :
controller . stop ( ) ;
break ;
case "seek" :
controller . seek ( e . data . param ) ;
break ;
case "pause" :
controller . pause ( ) ;
break ;
case "resume" :
controller . resume ( ) ;
break ;
case "logging_config" : {
var config = e . data . param ;
_utils _logging _control _js _ _WEBPACK _IMPORTED _MODULE _0 _ _ . default . applyConfig ( config ) ;
if ( config . enableCallback === true ) {
_utils _logging _control _js _ _WEBPACK _IMPORTED _MODULE _0 _ _ . default . addLogListener ( logcatListener ) ;
} else {
_utils _logging _control _js _ _WEBPACK _IMPORTED _MODULE _0 _ _ . default . removeLogListener ( logcatListener ) ;
}
break ;
}
}
} ) ;
function onInitSegment ( type , initSegment ) {
var obj = {
msg : _transmuxing _events _js _ _WEBPACK _IMPORTED _MODULE _3 _ _ . default . INIT _SEGMENT ,
data : {
type ,
data : initSegment
}
} ;
self2 . postMessage ( obj , [ initSegment . data ] ) ;
}
function onMediaSegment ( type , mediaSegment ) {
var obj = {
msg : _transmuxing _events _js _ _WEBPACK _IMPORTED _MODULE _3 _ _ . default . MEDIA _SEGMENT ,
data : {
type ,
data : mediaSegment
}
} ;
self2 . postMessage ( obj , [ mediaSegment . data ] ) ;
}
function onLoadingComplete ( ) {
var obj = {
msg : _transmuxing _events _js _ _WEBPACK _IMPORTED _MODULE _3 _ _ . default . LOADING _COMPLETE
} ;
self2 . postMessage ( obj ) ;
}
function onRecoveredEarlyEof ( ) {
var obj = {
msg : _transmuxing _events _js _ _WEBPACK _IMPORTED _MODULE _3 _ _ . default . RECOVERED _EARLY _EOF
} ;
self2 . postMessage ( obj ) ;
}
function onMediaInfo ( mediaInfo ) {
var obj = {
msg : _transmuxing _events _js _ _WEBPACK _IMPORTED _MODULE _3 _ _ . default . MEDIA _INFO ,
data : mediaInfo
} ;
self2 . postMessage ( obj ) ;
}
function onMetaDataArrived ( metadata ) {
var obj = {
msg : _transmuxing _events _js _ _WEBPACK _IMPORTED _MODULE _3 _ _ . default . METADATA _ARRIVED ,
data : metadata
} ;
self2 . postMessage ( obj ) ;
}
function onScriptDataArrived ( data ) {
var obj = {
msg : _transmuxing _events _js _ _WEBPACK _IMPORTED _MODULE _3 _ _ . default . SCRIPTDATA _ARRIVED ,
data
} ;
self2 . postMessage ( obj ) ;
}
function onStatisticsInfo ( statInfo ) {
var obj = {
msg : _transmuxing _events _js _ _WEBPACK _IMPORTED _MODULE _3 _ _ . default . STATISTICS _INFO ,
data : statInfo
} ;
self2 . postMessage ( obj ) ;
}
function onIOError ( type , info ) {
self2 . postMessage ( {
msg : _transmuxing _events _js _ _WEBPACK _IMPORTED _MODULE _3 _ _ . default . IO _ERROR ,
data : {
type ,
info
}
} ) ;
}
function onDemuxError ( type , info ) {
self2 . postMessage ( {
msg : _transmuxing _events _js _ _WEBPACK _IMPORTED _MODULE _3 _ _ . default . DEMUX _ERROR ,
data : {
type ,
info
}
} ) ;
}
function onRecommendSeekpoint ( milliseconds ) {
self2 . postMessage ( {
msg : _transmuxing _events _js _ _WEBPACK _IMPORTED _MODULE _3 _ _ . default . RECOMMEND _SEEKPOINT ,
data : milliseconds
} ) ;
}
function onLogcatCallback ( type , str ) {
self2 . postMessage ( {
msg : "logcat_callback" ,
data : {
type ,
logcat : str
}
} ) ;
}
} ;
_ _webpack _exports _ _2 [ "default" ] = TransmuxingWorker ;
} ,
"./src/demux/amf-parser.js" : function ( _ _unused _webpack _module , _ _webpack _exports _ _2 , _ _webpack _require _ _2 ) {
"use strict" ;
_ _webpack _require _ _2 . r ( _ _webpack _exports _ _2 ) ;
var _utils _logger _js _ _WEBPACK _IMPORTED _MODULE _0 _ _ = _ _webpack _require _ _2 ( "./src/utils/logger.js" ) ;
var _utils _utf8 _conv _js _ _WEBPACK _IMPORTED _MODULE _1 _ _ = _ _webpack _require _ _2 ( "./src/utils/utf8-conv.js" ) ;
var _utils _exception _js _ _WEBPACK _IMPORTED _MODULE _2 _ _ = _ _webpack _require _ _2 ( "./src/utils/exception.js" ) ;
var le = function ( ) {
var buf = new ArrayBuffer ( 2 ) ;
new DataView ( buf ) . setInt16 ( 0 , 256 , true ) ;
return new Int16Array ( buf ) [ 0 ] === 256 ;
} ( ) ;
var AMF = function ( ) {
function AMF2 ( ) {
}
AMF2 . parseScriptData = function ( arrayBuffer , dataOffset , dataSize ) {
var data = { } ;
try {
var name _1 = AMF2 . parseValue ( arrayBuffer , dataOffset , dataSize ) ;
var value = AMF2 . parseValue ( arrayBuffer , dataOffset + name _1 . size , dataSize - name _1 . size ) ;
data [ name _1 . data ] = value . data ;
} catch ( e ) {
_utils _logger _js _ _WEBPACK _IMPORTED _MODULE _0 _ _ . default . e ( "AMF" , e . toString ( ) ) ;
}
return data ;
} ;
AMF2 . parseObject = function ( arrayBuffer , dataOffset , dataSize ) {
if ( dataSize < 3 ) {
throw new _utils _exception _js _ _WEBPACK _IMPORTED _MODULE _2 _ _ . IllegalStateException ( "Data not enough when parse ScriptDataObject" ) ;
}
var name = AMF2 . parseString ( arrayBuffer , dataOffset , dataSize ) ;
var value = AMF2 . parseValue ( arrayBuffer , dataOffset + name . size , dataSize - name . size ) ;
var isObjectEnd = value . objectEnd ;
return {
data : {
name : name . data ,
value : value . data
} ,
size : name . size + value . size ,
objectEnd : isObjectEnd
} ;
} ;
AMF2 . parseVariable = function ( arrayBuffer , dataOffset , dataSize ) {
return AMF2 . parseObject ( arrayBuffer , dataOffset , dataSize ) ;
} ;
AMF2 . parseString = function ( arrayBuffer , dataOffset , dataSize ) {
if ( dataSize < 2 ) {
throw new _utils _exception _js _ _WEBPACK _IMPORTED _MODULE _2 _ _ . IllegalStateException ( "Data not enough when parse String" ) ;
}
var v = new DataView ( arrayBuffer , dataOffset , dataSize ) ;
var length = v . getUint16 ( 0 , ! le ) ;
var str ;
if ( length > 0 ) {
str = ( 0 , _utils _utf8 _conv _js _ _WEBPACK _IMPORTED _MODULE _1 _ _ . default ) ( new Uint8Array ( arrayBuffer , dataOffset + 2 , length ) ) ;
} else {
str = "" ;
}
return {
data : str ,
size : 2 + length
} ;
} ;
AMF2 . parseLongString = function ( arrayBuffer , dataOffset , dataSize ) {
if ( dataSize < 4 ) {
throw new _utils _exception _js _ _WEBPACK _IMPORTED _MODULE _2 _ _ . IllegalStateException ( "Data not enough when parse LongString" ) ;
}
var v = new DataView ( arrayBuffer , dataOffset , dataSize ) ;
var length = v . getUint32 ( 0 , ! le ) ;
var str ;
if ( length > 0 ) {
str = ( 0 , _utils _utf8 _conv _js _ _WEBPACK _IMPORTED _MODULE _1 _ _ . default ) ( new Uint8Array ( arrayBuffer , dataOffset + 4 , length ) ) ;
} else {
str = "" ;
}
return {
data : str ,
size : 4 + length
} ;
} ;
AMF2 . parseDate = function ( arrayBuffer , dataOffset , dataSize ) {
if ( dataSize < 10 ) {
throw new _utils _exception _js _ _WEBPACK _IMPORTED _MODULE _2 _ _ . IllegalStateException ( "Data size invalid when parse Date" ) ;
}
var v = new DataView ( arrayBuffer , dataOffset , dataSize ) ;
var timestamp = v . getFloat64 ( 0 , ! le ) ;
var localTimeOffset = v . getInt16 ( 8 , ! le ) ;
timestamp += localTimeOffset * 60 * 1e3 ;
return {
data : new Date ( timestamp ) ,
size : 8 + 2
} ;
} ;
AMF2 . parseValue = function ( arrayBuffer , dataOffset , dataSize ) {
if ( dataSize < 1 ) {
throw new _utils _exception _js _ _WEBPACK _IMPORTED _MODULE _2 _ _ . IllegalStateException ( "Data not enough when parse Value" ) ;
}
var v = new DataView ( arrayBuffer , dataOffset , dataSize ) ;
var offset = 1 ;
var type = v . getUint8 ( 0 ) ;
var value ;
var objectEnd = false ;
try {
switch ( type ) {
case 0 :
value = v . getFloat64 ( 1 , ! le ) ;
offset += 8 ;
break ;
case 1 : {
var b = v . getUint8 ( 1 ) ;
value = b ? true : false ;
offset += 1 ;
break ;
}
case 2 : {
var amfstr = AMF2 . parseString ( arrayBuffer , dataOffset + 1 , dataSize - 1 ) ;
value = amfstr . data ;
offset += amfstr . size ;
break ;
}
case 3 : {
value = { } ;
var terminal = 0 ;
if ( ( v . getUint32 ( dataSize - 4 , ! le ) & 16777215 ) === 9 ) {
terminal = 3 ;
}
while ( offset < dataSize - 4 ) {
var amfobj = AMF2 . parseObject ( arrayBuffer , dataOffset + offset , dataSize - offset - terminal ) ;
if ( amfobj . objectEnd )
break ;
value [ amfobj . data . name ] = amfobj . data . value ;
offset += amfobj . size ;
}
if ( offset <= dataSize - 3 ) {
var marker = v . getUint32 ( offset - 1 , ! le ) & 16777215 ;
if ( marker === 9 ) {
offset += 3 ;
}
}
break ;
}
case 8 : {
value = { } ;
offset += 4 ;
var terminal = 0 ;
if ( ( v . getUint32 ( dataSize - 4 , ! le ) & 16777215 ) === 9 ) {
terminal = 3 ;
}
while ( offset < dataSize - 8 ) {
var amfvar = AMF2 . parseVariable ( arrayBuffer , dataOffset + offset , dataSize - offset - terminal ) ;
if ( amfvar . objectEnd )
break ;
value [ amfvar . data . name ] = amfvar . data . value ;
offset += amfvar . size ;
}
if ( offset <= dataSize - 3 ) {
var marker = v . getUint32 ( offset - 1 , ! le ) & 16777215 ;
if ( marker === 9 ) {
offset += 3 ;
}
}
break ;
}
case 9 :
value = void 0 ;
offset = 1 ;
objectEnd = true ;
break ;
case 10 : {
value = [ ] ;
var strictArrayLength = v . getUint32 ( 1 , ! le ) ;
offset += 4 ;
for ( var i = 0 ; i < strictArrayLength ; i ++ ) {
var val = AMF2 . parseValue ( arrayBuffer , dataOffset + offset , dataSize - offset ) ;
value . push ( val . data ) ;
offset += val . size ;
}
break ;
}
case 11 : {
var date = AMF2 . parseDate ( arrayBuffer , dataOffset + 1 , dataSize - 1 ) ;
value = date . data ;
offset += date . size ;
break ;
}
case 12 : {
var amfLongStr = AMF2 . parseString ( arrayBuffer , dataOffset + 1 , dataSize - 1 ) ;
value = amfLongStr . data ;
offset += amfLongStr . size ;
break ;
}
default :
offset = dataSize ;
_utils _logger _js _ _WEBPACK _IMPORTED _MODULE _0 _ _ . default . w ( "AMF" , "Unsupported AMF value type " + type ) ;
}
} catch ( e ) {
_utils _logger _js _ _WEBPACK _IMPORTED _MODULE _0 _ _ . default . e ( "AMF" , e . toString ( ) ) ;
}
return {
data : value ,
size : offset ,
objectEnd
} ;
} ;
return AMF2 ;
} ( ) ;
_ _webpack _exports _ _2 [ "default" ] = AMF ;
} ,
"./src/demux/demux-errors.js" : function ( _ _unused _webpack _module , _ _webpack _exports _ _2 , _ _webpack _require _ _2 ) {
"use strict" ;
_ _webpack _require _ _2 . r ( _ _webpack _exports _ _2 ) ;
var DemuxErrors = {
OK : "OK" ,
FORMAT _ERROR : "FormatError" ,
FORMAT _UNSUPPORTED : "FormatUnsupported" ,
CODEC _UNSUPPORTED : "CodecUnsupported"
} ;
_ _webpack _exports _ _2 [ "default" ] = DemuxErrors ;
} ,
"./src/demux/exp-golomb.js" : function ( _ _unused _webpack _module , _ _webpack _exports _ _2 , _ _webpack _require _ _2 ) {
"use strict" ;
_ _webpack _require _ _2 . r ( _ _webpack _exports _ _2 ) ;
var _utils _exception _js _ _WEBPACK _IMPORTED _MODULE _0 _ _ = _ _webpack _require _ _2 ( "./src/utils/exception.js" ) ;
var ExpGolomb = function ( ) {
function ExpGolomb2 ( uint8array ) {
this . TAG = "ExpGolomb" ;
this . _buffer = uint8array ;
this . _buffer _index = 0 ;
this . _total _bytes = uint8array . byteLength ;
this . _total _bits = uint8array . byteLength * 8 ;
this . _current _word = 0 ;
this . _current _word _bits _left = 0 ;
}
ExpGolomb2 . prototype . destroy = function ( ) {
this . _buffer = null ;
} ;
ExpGolomb2 . prototype . _fillCurrentWord = function ( ) {
var buffer _bytes _left = this . _total _bytes - this . _buffer _index ;
if ( buffer _bytes _left <= 0 )
throw new _utils _exception _js _ _WEBPACK _IMPORTED _MODULE _0 _ _ . IllegalStateException ( "ExpGolomb: _fillCurrentWord() but no bytes available" ) ;
var bytes _read = Math . min ( 4 , buffer _bytes _left ) ;
var word = new Uint8Array ( 4 ) ;
word . set ( this . _buffer . subarray ( this . _buffer _index , this . _buffer _index + bytes _read ) ) ;
this . _current _word = new DataView ( word . buffer ) . getUint32 ( 0 , false ) ;
this . _buffer _index += bytes _read ;
this . _current _word _bits _left = bytes _read * 8 ;
} ;
ExpGolomb2 . prototype . readBits = function ( bits ) {
if ( bits > 32 )
throw new _utils _exception _js _ _WEBPACK _IMPORTED _MODULE _0 _ _ . InvalidArgumentException ( "ExpGolomb: readBits() bits exceeded max 32bits!" ) ;
if ( bits <= this . _current _word _bits _left ) {
var result _1 = this . _current _word >>> 32 - bits ;
this . _current _word <<= bits ;
this . _current _word _bits _left -= bits ;
return result _1 ;
}
var result = this . _current _word _bits _left ? this . _current _word : 0 ;
result = result >>> 32 - this . _current _word _bits _left ;
var bits _need _left = bits - this . _current _word _bits _left ;
this . _fillCurrentWord ( ) ;
var bits _read _next = Math . min ( bits _need _left , this . _current _word _bits _left ) ;
var result2 = this . _current _word >>> 32 - bits _read _next ;
this . _current _word <<= bits _read _next ;
this . _current _word _bits _left -= bits _read _next ;
result = result << bits _read _next | result2 ;
return result ;
} ;
ExpGolomb2 . prototype . readBool = function ( ) {
return this . readBits ( 1 ) === 1 ;
} ;
ExpGolomb2 . prototype . readByte = function ( ) {
return this . readBits ( 8 ) ;
} ;
ExpGolomb2 . prototype . _skipLeadingZero = function ( ) {
var zero _count ;
for ( zero _count = 0 ; zero _count < this . _current _word _bits _left ; zero _count ++ ) {
if ( ( this . _current _word & 2147483648 >>> zero _count ) !== 0 ) {
this . _current _word <<= zero _count ;
this . _current _word _bits _left -= zero _count ;
return zero _count ;
}
}
this . _fillCurrentWord ( ) ;
return zero _count + this . _skipLeadingZero ( ) ;
} ;
ExpGolomb2 . prototype . readUEG = function ( ) {
var leading _zeros = this . _skipLeadingZero ( ) ;
return this . readBits ( leading _zeros + 1 ) - 1 ;
} ;
ExpGolomb2 . prototype . readSEG = function ( ) {
var value = this . readUEG ( ) ;
if ( value & 1 ) {
return value + 1 >>> 1 ;
} else {
return - 1 * ( value >>> 1 ) ;
}
} ;
return ExpGolomb2 ;
} ( ) ;
_ _webpack _exports _ _2 [ "default" ] = ExpGolomb ;
} ,
"./src/demux/flv-demuxer.js" : function ( _ _unused _webpack _module , _ _webpack _exports _ _2 , _ _webpack _require _ _2 ) {
"use strict" ;
_ _webpack _require _ _2 . r ( _ _webpack _exports _ _2 ) ;
var _utils _logger _js _ _WEBPACK _IMPORTED _MODULE _0 _ _ = _ _webpack _require _ _2 ( "./src/utils/logger.js" ) ;
var _amf _parser _js _ _WEBPACK _IMPORTED _MODULE _1 _ _ = _ _webpack _require _ _2 ( "./src/demux/amf-parser.js" ) ;
var _sps _parser _js _ _WEBPACK _IMPORTED _MODULE _2 _ _ = _ _webpack _require _ _2 ( "./src/demux/sps-parser.js" ) ;
var _demux _errors _js _ _WEBPACK _IMPORTED _MODULE _3 _ _ = _ _webpack _require _ _2 ( "./src/demux/demux-errors.js" ) ;
var _core _media _info _js _ _WEBPACK _IMPORTED _MODULE _4 _ _ = _ _webpack _require _ _2 ( "./src/core/media-info.js" ) ;
var _utils _exception _js _ _WEBPACK _IMPORTED _MODULE _5 _ _ = _ _webpack _require _ _2 ( "./src/utils/exception.js" ) ;
function Swap16 ( src ) {
return src >>> 8 & 255 | ( src & 255 ) << 8 ;
}
function Swap32 ( src ) {
return ( src & 4278190080 ) >>> 24 | ( src & 16711680 ) >>> 8 | ( src & 65280 ) << 8 | ( src & 255 ) << 24 ;
}
function ReadBig32 ( array , index ) {
return array [ index ] << 24 | array [ index + 1 ] << 16 | array [ index + 2 ] << 8 | array [ index + 3 ] ;
}
var FLVDemuxer = function ( ) {
function FLVDemuxer2 ( probeData , config ) {
this . TAG = "FLVDemuxer" ;
this . _config = config ;
this . _onError = null ;
this . _onMediaInfo = null ;
this . _onMetaDataArrived = null ;
this . _onScriptDataArrived = null ;
this . _onTrackMetadata = null ;
this . _onDataAvailable = null ;
this . _dataOffset = probeData . dataOffset ;
this . _firstParse = true ;
this . _dispatch = false ;
this . _hasAudio = probeData . hasAudioTrack ;
this . _hasVideo = probeData . hasVideoTrack ;
this . _hasAudioFlagOverrided = false ;
this . _hasVideoFlagOverrided = false ;
this . _audioInitialMetadataDispatched = false ;
this . _videoInitialMetadataDispatched = false ;
this . _mediaInfo = new _core _media _info _js _ _WEBPACK _IMPORTED _MODULE _4 _ _ . default ( ) ;
this . _mediaInfo . hasAudio = this . _hasAudio ;
this . _mediaInfo . hasVideo = this . _hasVideo ;
this . _metadata = null ;
this . _audioMetadata = null ;
this . _videoMetadata = null ;
this . _naluLengthSize = 4 ;
this . _timestampBase = 0 ;
this . _timescale = 1e3 ;
this . _duration = 0 ;
this . _durationOverrided = false ;
this . _referenceFrameRate = {
fixed : true ,
fps : 23.976 ,
fps _num : 23976 ,
fps _den : 1e3
} ;
this . _flvSoundRateTable = [ 5500 , 11025 , 22050 , 44100 , 48e3 ] ;
this . _mpegSamplingRates = [
96e3 ,
88200 ,
64e3 ,
48e3 ,
44100 ,
32e3 ,
24e3 ,
22050 ,
16e3 ,
12e3 ,
11025 ,
8e3 ,
7350
] ;
this . _mpegAudioV10SampleRateTable = [ 44100 , 48e3 , 32e3 , 0 ] ;
this . _mpegAudioV20SampleRateTable = [ 22050 , 24e3 , 16e3 , 0 ] ;
this . _mpegAudioV25SampleRateTable = [ 11025 , 12e3 , 8e3 , 0 ] ;
this . _mpegAudioL1BitRateTable = [ 0 , 32 , 64 , 96 , 128 , 160 , 192 , 224 , 256 , 288 , 320 , 352 , 384 , 416 , 448 , - 1 ] ;
this . _mpegAudioL2BitRateTable = [ 0 , 32 , 48 , 56 , 64 , 80 , 96 , 112 , 128 , 160 , 192 , 224 , 256 , 320 , 384 , - 1 ] ;
this . _mpegAudioL3BitRateTable = [ 0 , 32 , 40 , 48 , 56 , 64 , 80 , 96 , 112 , 128 , 160 , 192 , 224 , 256 , 320 , - 1 ] ;
this . _videoTrack = { type : "video" , id : 1 , sequenceNumber : 0 , samples : [ ] , length : 0 } ;
this . _audioTrack = { type : "audio" , id : 2 , sequenceNumber : 0 , samples : [ ] , length : 0 } ;
this . _littleEndian = function ( ) {
var buf = new ArrayBuffer ( 2 ) ;
new DataView ( buf ) . setInt16 ( 0 , 256 , true ) ;
return new Int16Array ( buf ) [ 0 ] === 256 ;
} ( ) ;
}
FLVDemuxer2 . prototype . destroy = function ( ) {
this . _mediaInfo = null ;
this . _metadata = null ;
this . _audioMetadata = null ;
this . _videoMetadata = null ;
this . _videoTrack = null ;
this . _audioTrack = null ;
this . _onError = null ;
this . _onMediaInfo = null ;
this . _onMetaDataArrived = null ;
this . _onScriptDataArrived = null ;
this . _onTrackMetadata = null ;
this . _onDataAvailable = null ;
} ;
FLVDemuxer2 . probe = function ( buffer ) {
var data = new Uint8Array ( buffer ) ;
var mismatch = { match : false } ;
if ( data [ 0 ] !== 70 || data [ 1 ] !== 76 || data [ 2 ] !== 86 || data [ 3 ] !== 1 ) {
return mismatch ;
}
var hasAudio = ( data [ 4 ] & 4 ) >>> 2 !== 0 ;
var hasVideo = ( data [ 4 ] & 1 ) !== 0 ;
var offset = ReadBig32 ( data , 5 ) ;
if ( offset < 9 ) {
return mismatch ;
}
return {
match : true ,
consumed : offset ,
dataOffset : offset ,
hasAudioTrack : hasAudio ,
hasVideoTrack : hasVideo
} ;
} ;
FLVDemuxer2 . prototype . bindDataSource = function ( loader ) {
loader . onDataArrival = this . parseChunks . bind ( this ) ;
return this ;
} ;
Object . defineProperty ( FLVDemuxer2 . prototype , "onTrackMetadata" , {
get : function ( ) {
return this . _onTrackMetadata ;
} ,
set : function ( callback ) {
this . _onTrackMetadata = callback ;
} ,
enumerable : false ,
configurable : true
} ) ;
Object . defineProperty ( FLVDemuxer2 . prototype , "onMediaInfo" , {
get : function ( ) {
return this . _onMediaInfo ;
} ,
set : function ( callback ) {
this . _onMediaInfo = callback ;
} ,
enumerable : false ,
configurable : true
} ) ;
Object . defineProperty ( FLVDemuxer2 . prototype , "onMetaDataArrived" , {
get : function ( ) {
return this . _onMetaDataArrived ;
} ,
set : function ( callback ) {
this . _onMetaDataArrived = callback ;
} ,
enumerable : false ,
configurable : true
} ) ;
Object . defineProperty ( FLVDemuxer2 . prototype , "onScriptDataArrived" , {
get : function ( ) {
return this . _onScriptDataArrived ;
} ,
set : function ( callback ) {
this . _onScriptDataArrived = callback ;
} ,
enumerable : false ,
configurable : true
} ) ;
Object . defineProperty ( FLVDemuxer2 . prototype , "onError" , {
get : function ( ) {
return this . _onError ;
} ,
set : function ( callback ) {
this . _onError = callback ;
} ,
enumerable : false ,
configurable : true
} ) ;
Object . defineProperty ( FLVDemuxer2 . prototype , "onDataAvailable" , {
get : function ( ) {
return this . _onDataAvailable ;
} ,
set : function ( callback ) {
this . _onDataAvailable = callback ;
} ,
enumerable : false ,
configurable : true
} ) ;
Object . defineProperty ( FLVDemuxer2 . prototype , "timestampBase" , {
get : function ( ) {
return this . _timestampBase ;
} ,
set : function ( base ) {
this . _timestampBase = base ;
} ,
enumerable : false ,
configurable : true
} ) ;
Object . defineProperty ( FLVDemuxer2 . prototype , "overridedDuration" , {
get : function ( ) {
return this . _duration ;
} ,
set : function ( duration ) {
this . _durationOverrided = true ;
this . _duration = duration ;
this . _mediaInfo . duration = duration ;
} ,
enumerable : false ,
configurable : true
} ) ;
Object . defineProperty ( FLVDemuxer2 . prototype , "overridedHasAudio" , {
set : function ( hasAudio ) {
this . _hasAudioFlagOverrided = true ;
this . _hasAudio = hasAudio ;
this . _mediaInfo . hasAudio = hasAudio ;
} ,
enumerable : false ,
configurable : true
} ) ;
Object . defineProperty ( FLVDemuxer2 . prototype , "overridedHasVideo" , {
set : function ( hasVideo ) {
this . _hasVideoFlagOverrided = true ;
this . _hasVideo = hasVideo ;
this . _mediaInfo . hasVideo = hasVideo ;
} ,
enumerable : false ,
configurable : true
} ) ;
FLVDemuxer2 . prototype . resetMediaInfo = function ( ) {
this . _mediaInfo = new _core _media _info _js _ _WEBPACK _IMPORTED _MODULE _4 _ _ . default ( ) ;
} ;
FLVDemuxer2 . prototype . _isInitialMetadataDispatched = function ( ) {
if ( this . _hasAudio && this . _hasVideo ) {
return this . _audioInitialMetadataDispatched && this . _videoInitialMetadataDispatched ;
}
if ( this . _hasAudio && ! this . _hasVideo ) {
return this . _audioInitialMetadataDispatched ;
}
if ( ! this . _hasAudio && this . _hasVideo ) {
return this . _videoInitialMetadataDispatched ;
}
return false ;
} ;
FLVDemuxer2 . prototype . parseChunks = function ( chunk , byteStart ) {
if ( ! this . _onError || ! this . _onMediaInfo || ! this . _onTrackMetadata || ! this . _onDataAvailable ) {
throw new _utils _exception _js _ _WEBPACK _IMPORTED _MODULE _5 _ _ . IllegalStateException ( "Flv: onError & onMediaInfo & onTrackMetadata & onDataAvailable callback must be specified" ) ;
}
var offset = 0 ;
var le = this . _littleEndian ;
if ( byteStart === 0 ) {
if ( chunk . byteLength > 13 ) {
var probeData = FLVDemuxer2 . probe ( chunk ) ;
offset = probeData . dataOffset ;
} else {
return 0 ;
}
}
if ( this . _firstParse ) {
this . _firstParse = false ;
if ( byteStart + offset !== this . _dataOffset ) {
_utils _logger _js _ _WEBPACK _IMPORTED _MODULE _0 _ _ . default . w ( this . TAG , "First time parsing but chunk byteStart invalid!" ) ;
}
var v = new DataView ( chunk , offset ) ;
var prevTagSize0 = v . getUint32 ( 0 , ! le ) ;
if ( prevTagSize0 !== 0 ) {
_utils _logger _js _ _WEBPACK _IMPORTED _MODULE _0 _ _ . default . w ( this . TAG , "PrevTagSize0 !== 0 !!!" ) ;
}
offset += 4 ;
}
while ( offset < chunk . byteLength ) {
this . _dispatch = true ;
var v = new DataView ( chunk , offset ) ;
if ( offset + 11 + 4 > chunk . byteLength ) {
break ;
}
var tagType = v . getUint8 ( 0 ) ;
var dataSize = v . getUint32 ( 0 , ! le ) & 16777215 ;
if ( offset + 11 + dataSize + 4 > chunk . byteLength ) {
break ;
}
if ( tagType !== 8 && tagType !== 9 && tagType !== 18 ) {
_utils _logger _js _ _WEBPACK _IMPORTED _MODULE _0 _ _ . default . w ( this . TAG , "Unsupported tag type " + tagType + ", skipped" ) ;
offset += 11 + dataSize + 4 ;
continue ;
}
var ts2 = v . getUint8 ( 4 ) ;
var ts1 = v . getUint8 ( 5 ) ;
var ts0 = v . getUint8 ( 6 ) ;
var ts3 = v . getUint8 ( 7 ) ;
var timestamp = ts0 | ts1 << 8 | ts2 << 16 | ts3 << 24 ;
var streamId = v . getUint32 ( 7 , ! le ) & 16777215 ;
if ( streamId !== 0 ) {
_utils _logger _js _ _WEBPACK _IMPORTED _MODULE _0 _ _ . default . w ( this . TAG , "Meet tag which has StreamID != 0!" ) ;
}
var dataOffset = offset + 11 ;
switch ( tagType ) {
case 8 :
this . _parseAudioData ( chunk , dataOffset , dataSize , timestamp ) ;
break ;
case 9 :
this . _parseVideoData ( chunk , dataOffset , dataSize , timestamp , byteStart + offset ) ;
break ;
case 18 :
this . _parseScriptData ( chunk , dataOffset , dataSize ) ;
break ;
}
var prevTagSize = v . getUint32 ( 11 + dataSize , ! le ) ;
if ( prevTagSize !== 11 + dataSize ) {
_utils _logger _js _ _WEBPACK _IMPORTED _MODULE _0 _ _ . default . w ( this . TAG , "Invalid PrevTagSize " + prevTagSize ) ;
}
offset += 11 + dataSize + 4 ;
}
if ( this . _isInitialMetadataDispatched ( ) ) {
if ( this . _dispatch && ( this . _audioTrack . length || this . _videoTrack . length ) ) {
this . _onDataAvailable ( this . _audioTrack , this . _videoTrack ) ;
}
}
return offset ;
} ;
FLVDemuxer2 . prototype . _parseScriptData = function ( arrayBuffer , dataOffset , dataSize ) {
var scriptData = _amf _parser _js _ _WEBPACK _IMPORTED _MODULE _1 _ _ . default . parseScriptData ( arrayBuffer , dataOffset , dataSize ) ;
if ( scriptData . hasOwnProperty ( "onMetaData" ) ) {
if ( scriptData . onMetaData == null || typeof scriptData . onMetaData !== "object" ) {
_utils _logger _js _ _WEBPACK _IMPORTED _MODULE _0 _ _ . default . w ( this . TAG , "Invalid onMetaData structure!" ) ;
return ;
}
if ( this . _metadata ) {
_utils _logger _js _ _WEBPACK _IMPORTED _MODULE _0 _ _ . default . w ( this . TAG , "Found another onMetaData tag!" ) ;
}
this . _metadata = scriptData ;
var onMetaData = this . _metadata . onMetaData ;
if ( this . _onMetaDataArrived ) {
this . _onMetaDataArrived ( Object . assign ( { } , onMetaData ) ) ;
}
if ( typeof onMetaData . hasAudio === "boolean" ) {
if ( this . _hasAudioFlagOverrided === false ) {
this . _hasAudio = onMetaData . hasAudio ;
this . _mediaInfo . hasAudio = this . _hasAudio ;
}
}
if ( typeof onMetaData . hasVideo === "boolean" ) {
if ( this . _hasVideoFlagOverrided === false ) {
this . _hasVideo = onMetaData . hasVideo ;
this . _mediaInfo . hasVideo = this . _hasVideo ;
}
}
if ( typeof onMetaData . audiodatarate === "number" ) {
this . _mediaInfo . audioDataRate = onMetaData . audiodatarate ;
}
if ( typeof onMetaData . videodatarate === "number" ) {
this . _mediaInfo . videoDataRate = onMetaData . videodatarate ;
}
if ( typeof onMetaData . width === "number" ) {
this . _mediaInfo . width = onMetaData . width ;
}
if ( typeof onMetaData . height === "number" ) {
this . _mediaInfo . height = onMetaData . height ;
}
if ( typeof onMetaData . duration === "number" ) {
if ( ! this . _durationOverrided ) {
var duration = Math . floor ( onMetaData . duration * this . _timescale ) ;
this . _duration = duration ;
this . _mediaInfo . duration = duration ;
}
} else {
this . _mediaInfo . duration = 0 ;
}
if ( typeof onMetaData . framerate === "number" ) {
var fps _num = Math . floor ( onMetaData . framerate * 1e3 ) ;
if ( fps _num > 0 ) {
var fps = fps _num / 1e3 ;
this . _referenceFrameRate . fixed = true ;
this . _referenceFrameRate . fps = fps ;
this . _referenceFrameRate . fps _num = fps _num ;
this . _referenceFrameRate . fps _den = 1e3 ;
this . _mediaInfo . fps = fps ;
}
}
if ( typeof onMetaData . keyframes === "object" ) {
this . _mediaInfo . hasKeyframesIndex = true ;
var keyframes = onMetaData . keyframes ;
this . _mediaInfo . keyframesIndex = this . _parseKeyframesIndex ( keyframes ) ;
onMetaData . keyframes = null ;
} else {
this . _mediaInfo . hasKeyframesIndex = false ;
}
this . _dispatch = false ;
this . _mediaInfo . metadata = onMetaData ;
_utils _logger _js _ _WEBPACK _IMPORTED _MODULE _0 _ _ . default . v ( this . TAG , "Parsed onMetaData" ) ;
if ( this . _mediaInfo . isComplete ( ) ) {
this . _onMediaInfo ( this . _mediaInfo ) ;
}
}
if ( Object . keys ( scriptData ) . length > 0 ) {
if ( this . _onScriptDataArrived ) {
this . _onScriptDataArrived ( Object . assign ( { } , scriptData ) ) ;
}
}
} ;
FLVDemuxer2 . prototype . _parseKeyframesIndex = function ( keyframes ) {
var times = [ ] ;
var filepositions = [ ] ;
for ( var i = 1 ; i < keyframes . times . length ; i ++ ) {
var time = this . _timestampBase + Math . floor ( keyframes . times [ i ] * 1e3 ) ;
times . push ( time ) ;
filepositions . push ( keyframes . filepositions [ i ] ) ;
}
return {
times ,
filepositions
} ;
} ;
FLVDemuxer2 . prototype . _parseAudioData = function ( arrayBuffer , dataOffset , dataSize , tagTimestamp ) {
if ( dataSize <= 1 ) {
_utils _logger _js _ _WEBPACK _IMPORTED _MODULE _0 _ _ . default . w ( this . TAG , "Flv: Invalid audio packet, missing SoundData payload!" ) ;
return ;
}
if ( this . _hasAudioFlagOverrided === true && this . _hasAudio === false ) {
return ;
}
var le = this . _littleEndian ;
var v = new DataView ( arrayBuffer , dataOffset , dataSize ) ;
var soundSpec = v . getUint8 ( 0 ) ;
var soundFormat = soundSpec >>> 4 ;
if ( soundFormat !== 2 && soundFormat !== 10 ) {
this . _onError ( _demux _errors _js _ _WEBPACK _IMPORTED _MODULE _3 _ _ . default . CODEC _UNSUPPORTED , "Flv: Unsupported audio codec idx: " + soundFormat ) ;
return ;
}
var soundRate = 0 ;
var soundRateIndex = ( soundSpec & 12 ) >>> 2 ;
if ( soundRateIndex >= 0 && soundRateIndex <= 4 ) {
soundRate = this . _flvSoundRateTable [ soundRateIndex ] ;
} else {
this . _onError ( _demux _errors _js _ _WEBPACK _IMPORTED _MODULE _3 _ _ . default . FORMAT _ERROR , "Flv: Invalid audio sample rate idx: " + soundRateIndex ) ;
return ;
}
var soundSize = ( soundSpec & 2 ) >>> 1 ;
var soundType = soundSpec & 1 ;
var meta = this . _audioMetadata ;
var track = this . _audioTrack ;
if ( ! meta ) {
if ( this . _hasAudio === false && this . _hasAudioFlagOverrided === false ) {
this . _hasAudio = true ;
this . _mediaInfo . hasAudio = true ;
}
meta = this . _audioMetadata = { } ;
meta . type = "audio" ;
meta . id = track . id ;
meta . timescale = this . _timescale ;
meta . duration = this . _duration ;
meta . audioSampleRate = soundRate ;
meta . channelCount = soundType === 0 ? 1 : 2 ;
}
if ( soundFormat === 10 ) {
var aacData = this . _parseAACAudioData ( arrayBuffer , dataOffset + 1 , dataSize - 1 ) ;
if ( aacData == void 0 ) {
return ;
}
if ( aacData . packetType === 0 ) {
if ( meta . config ) {
_utils _logger _js _ _WEBPACK _IMPORTED _MODULE _0 _ _ . default . w ( this . TAG , "Found another AudioSpecificConfig!" ) ;
}
var misc = aacData . data ;
meta . audioSampleRate = misc . samplingRate ;
meta . channelCount = misc . channelCount ;
meta . codec = misc . codec ;
meta . originalCodec = misc . originalCodec ;
meta . config = misc . config ;
meta . refSampleDuration = 1024 / meta . audioSampleRate * meta . timescale ;
_utils _logger _js _ _WEBPACK _IMPORTED _MODULE _0 _ _ . default . v ( this . TAG , "Parsed AudioSpecificConfig" ) ;
if ( this . _isInitialMetadataDispatched ( ) ) {
if ( this . _dispatch && ( this . _audioTrack . length || this . _videoTrack . length ) ) {
this . _onDataAvailable ( this . _audioTrack , this . _videoTrack ) ;
}
} else {
this . _audioInitialMetadataDispatched = true ;
}
this . _dispatch = false ;
this . _onTrackMetadata ( "audio" , meta ) ;
var mi = this . _mediaInfo ;
mi . audioCodec = meta . originalCodec ;
mi . audioSampleRate = meta . audioSampleRate ;
mi . audioChannelCount = meta . channelCount ;
if ( mi . hasVideo ) {
if ( mi . videoCodec != null ) {
mi . mimeType = 'video/x-flv; codecs="' + mi . videoCodec + "," + mi . audioCodec + '"' ;
}
} else {
mi . mimeType = 'video/x-flv; codecs="' + mi . audioCodec + '"' ;
}
if ( mi . isComplete ( ) ) {
this . _onMediaInfo ( mi ) ;
}
} else if ( aacData . packetType === 1 ) {
var dts = this . _timestampBase + tagTimestamp ;
var aacSample = { unit : aacData . data , length : aacData . data . byteLength , dts , pts : dts } ;
track . samples . push ( aacSample ) ;
track . length += aacData . data . length ;
} else {
_utils _logger _js _ _WEBPACK _IMPORTED _MODULE _0 _ _ . default . e ( this . TAG , "Flv: Unsupported AAC data type " + aacData . packetType ) ;
}
} else if ( soundFormat === 2 ) {
if ( ! meta . codec ) {
var misc = this . _parseMP3AudioData ( arrayBuffer , dataOffset + 1 , dataSize - 1 , true ) ;
if ( misc == void 0 ) {
return ;
}
meta . audioSampleRate = misc . samplingRate ;
meta . channelCount = misc . channelCount ;
meta . codec = misc . codec ;
meta . originalCodec = misc . originalCodec ;
meta . refSampleDuration = 1152 / meta . audioSampleRate * meta . timescale ;
_utils _logger _js _ _WEBPACK _IMPORTED _MODULE _0 _ _ . default . v ( this . TAG , "Parsed MPEG Audio Frame Header" ) ;
this . _audioInitialMetadataDispatched = true ;
this . _onTrackMetadata ( "audio" , meta ) ;
var mi = this . _mediaInfo ;
mi . audioCodec = meta . codec ;
mi . audioSampleRate = meta . audioSampleRate ;
mi . audioChannelCount = meta . channelCount ;
mi . audioDataRate = misc . bitRate ;
if ( mi . hasVideo ) {
if ( mi . videoCodec != null ) {
mi . mimeType = 'video/x-flv; codecs="' + mi . videoCodec + "," + mi . audioCodec + '"' ;
}
} else {
mi . mimeType = 'video/x-flv; codecs="' + mi . audioCodec + '"' ;
}
if ( mi . isComplete ( ) ) {
this . _onMediaInfo ( mi ) ;
}
}
var data = this . _parseMP3AudioData ( arrayBuffer , dataOffset + 1 , dataSize - 1 , false ) ;
if ( data == void 0 ) {
return ;
}
var dts = this . _timestampBase + tagTimestamp ;
var mp3Sample = { unit : data , length : data . byteLength , dts , pts : dts } ;
track . samples . push ( mp3Sample ) ;
track . length += data . length ;
}
} ;
FLVDemuxer2 . prototype . _parseAACAudioData = function ( arrayBuffer , dataOffset , dataSize ) {
if ( dataSize <= 1 ) {
_utils _logger _js _ _WEBPACK _IMPORTED _MODULE _0 _ _ . default . w ( this . TAG , "Flv: Invalid AAC packet, missing AACPacketType or/and Data!" ) ;
return ;
}
var result = { } ;
var array = new Uint8Array ( arrayBuffer , dataOffset , dataSize ) ;
result . packetType = array [ 0 ] ;
if ( array [ 0 ] === 0 ) {
result . data = this . _parseAACAudioSpecificConfig ( arrayBuffer , dataOffset + 1 , dataSize - 1 ) ;
} else {
result . data = array . subarray ( 1 ) ;
}
return result ;
} ;
FLVDemuxer2 . prototype . _parseAACAudioSpecificConfig = function ( arrayBuffer , dataOffset , dataSize ) {
var array = new Uint8Array ( arrayBuffer , dataOffset , dataSize ) ;
var config = null ;
var audioObjectType = 0 ;
var originalAudioObjectType = 0 ;
var audioExtensionObjectType = null ;
var samplingIndex = 0 ;
var extensionSamplingIndex = null ;
audioObjectType = originalAudioObjectType = array [ 0 ] >>> 3 ;
samplingIndex = ( array [ 0 ] & 7 ) << 1 | array [ 1 ] >>> 7 ;
if ( samplingIndex < 0 || samplingIndex >= this . _mpegSamplingRates . length ) {
this . _onError ( _demux _errors _js _ _WEBPACK _IMPORTED _MODULE _3 _ _ . default . FORMAT _ERROR , "Flv: AAC invalid sampling frequency index!" ) ;
return ;
}
var samplingFrequence = this . _mpegSamplingRates [ samplingIndex ] ;
var channelConfig = ( array [ 1 ] & 120 ) >>> 3 ;
if ( channelConfig < 0 || channelConfig >= 8 ) {
this . _onError ( _demux _errors _js _ _WEBPACK _IMPORTED _MODULE _3 _ _ . default . FORMAT _ERROR , "Flv: AAC invalid channel configuration" ) ;
return ;
}
if ( audioObjectType === 5 ) {
extensionSamplingIndex = ( array [ 1 ] & 7 ) << 1 | array [ 2 ] >>> 7 ;
audioExtensionObjectType = ( array [ 2 ] & 124 ) >>> 2 ;
}
var userAgent = self . navigator . userAgent . toLowerCase ( ) ;
if ( userAgent . indexOf ( "firefox" ) !== - 1 ) {
if ( samplingIndex >= 6 ) {
audioObjectType = 5 ;
config = new Array ( 4 ) ;
extensionSamplingIndex = samplingIndex - 3 ;
} else {
audioObjectType = 2 ;
config = new Array ( 2 ) ;
extensionSamplingIndex = samplingIndex ;
}
} else if ( userAgent . indexOf ( "android" ) !== - 1 ) {
audioObjectType = 2 ;
config = new Array ( 2 ) ;
extensionSamplingIndex = samplingIndex ;
} else {
audioObjectType = 5 ;
extensionSamplingIndex = samplingIndex ;
config = new Array ( 4 ) ;
if ( samplingIndex >= 6 ) {
extensionSamplingIndex = samplingIndex - 3 ;
} else if ( channelConfig === 1 ) {
audioObjectType = 2 ;
config = new Array ( 2 ) ;
extensionSamplingIndex = samplingIndex ;
}
}
config [ 0 ] = audioObjectType << 3 ;
config [ 0 ] |= ( samplingIndex & 15 ) >>> 1 ;
config [ 1 ] = ( samplingIndex & 15 ) << 7 ;
config [ 1 ] |= ( channelConfig & 15 ) << 3 ;
if ( audioObjectType === 5 ) {
config [ 1 ] |= ( extensionSamplingIndex & 15 ) >>> 1 ;
config [ 2 ] = ( extensionSamplingIndex & 1 ) << 7 ;
config [ 2 ] |= 2 << 2 ;
config [ 3 ] = 0 ;
}
return {
config ,
samplingRate : samplingFrequence ,
channelCount : channelConfig ,
codec : "mp4a.40." + audioObjectType ,
originalCodec : "mp4a.40." + originalAudioObjectType
} ;
} ;
FLVDemuxer2 . prototype . _parseMP3AudioData = function ( arrayBuffer , dataOffset , dataSize , requestHeader ) {
if ( dataSize < 4 ) {
_utils _logger _js _ _WEBPACK _IMPORTED _MODULE _0 _ _ . default . w ( this . TAG , "Flv: Invalid MP3 packet, header missing!" ) ;
return ;
}
var le = this . _littleEndian ;
var array = new Uint8Array ( arrayBuffer , dataOffset , dataSize ) ;
var result = null ;
if ( requestHeader ) {
if ( array [ 0 ] !== 255 ) {
return ;
}
var ver = array [ 1 ] >>> 3 & 3 ;
var layer = ( array [ 1 ] & 6 ) >> 1 ;
var bitrate _index = ( array [ 2 ] & 240 ) >>> 4 ;
var sampling _freq _index = ( array [ 2 ] & 12 ) >>> 2 ;
var channel _mode = array [ 3 ] >>> 6 & 3 ;
var channel _count = channel _mode !== 3 ? 2 : 1 ;
var sample _rate = 0 ;
var bit _rate = 0 ;
var object _type = 34 ;
var codec = "mp3" ;
switch ( ver ) {
case 0 :
sample _rate = this . _mpegAudioV25SampleRateTable [ sampling _freq _index ] ;
break ;
case 2 :
sample _rate = this . _mpegAudioV20SampleRateTable [ sampling _freq _index ] ;
break ;
case 3 :
sample _rate = this . _mpegAudioV10SampleRateTable [ sampling _freq _index ] ;
break ;
}
switch ( layer ) {
case 1 :
object _type = 34 ;
if ( bitrate _index < this . _mpegAudioL3BitRateTable . length ) {
bit _rate = this . _mpegAudioL3BitRateTable [ bitrate _index ] ;
}
break ;
case 2 :
object _type = 33 ;
if ( bitrate _index < this . _mpegAudioL2BitRateTable . length ) {
bit _rate = this . _mpegAudioL2BitRateTable [ bitrate _index ] ;
}
break ;
case 3 :
object _type = 32 ;
if ( bitrate _index < this . _mpegAudioL1BitRateTable . length ) {
bit _rate = this . _mpegAudioL1BitRateTable [ bitrate _index ] ;
}
break ;
}
result = {
bitRate : bit _rate ,
samplingRate : sample _rate ,
channelCount : channel _count ,
codec ,
originalCodec : codec
} ;
} else {
result = array ;
}
return result ;
} ;
FLVDemuxer2 . prototype . _parseVideoData = function ( arrayBuffer , dataOffset , dataSize , tagTimestamp , tagPosition ) {
if ( dataSize <= 1 ) {
_utils _logger _js _ _WEBPACK _IMPORTED _MODULE _0 _ _ . default . w ( this . TAG , "Flv: Invalid video packet, missing VideoData payload!" ) ;
return ;
}
if ( this . _hasVideoFlagOverrided === true && this . _hasVideo === false ) {
return ;
}
var spec = new Uint8Array ( arrayBuffer , dataOffset , dataSize ) [ 0 ] ;
var frameType = ( spec & 240 ) >>> 4 ;
var codecId = spec & 15 ;
if ( codecId !== 7 ) {
this . _onError ( _demux _errors _js _ _WEBPACK _IMPORTED _MODULE _3 _ _ . default . CODEC _UNSUPPORTED , "Flv: Unsupported codec in video frame: " + codecId ) ;
return ;
}
this . _parseAVCVideoPacket ( arrayBuffer , dataOffset + 1 , dataSize - 1 , tagTimestamp , tagPosition , frameType ) ;
} ;
FLVDemuxer2 . prototype . _parseAVCVideoPacket = function ( arrayBuffer , dataOffset , dataSize , tagTimestamp , tagPosition , frameType ) {
if ( dataSize < 4 ) {
_utils _logger _js _ _WEBPACK _IMPORTED _MODULE _0 _ _ . default . w ( this . TAG , "Flv: Invalid AVC packet, missing AVCPacketType or/and CompositionTime" ) ;
return ;
}
var le = this . _littleEndian ;
var v = new DataView ( arrayBuffer , dataOffset , dataSize ) ;
var packetType = v . getUint8 ( 0 ) ;
var cts _unsigned = v . getUint32 ( 0 , ! le ) & 16777215 ;
var cts = cts _unsigned << 8 >> 8 ;
if ( packetType === 0 ) {
this . _parseAVCDecoderConfigurationRecord ( arrayBuffer , dataOffset + 4 , dataSize - 4 ) ;
} else if ( packetType === 1 ) {
this . _parseAVCVideoData ( arrayBuffer , dataOffset + 4 , dataSize - 4 , tagTimestamp , tagPosition , frameType , cts ) ;
} else if ( packetType === 2 ) {
} else {
this . _onError ( _demux _errors _js _ _WEBPACK _IMPORTED _MODULE _3 _ _ . default . FORMAT _ERROR , "Flv: Invalid video packet type " + packetType ) ;
return ;
}
} ;
FLVDemuxer2 . prototype . _parseAVCDecoderConfigurationRecord = function ( arrayBuffer , dataOffset , dataSize ) {
if ( dataSize < 7 ) {
_utils _logger _js _ _WEBPACK _IMPORTED _MODULE _0 _ _ . default . w ( this . TAG , "Flv: Invalid AVCDecoderConfigurationRecord, lack of data!" ) ;
return ;
}
var meta = this . _videoMetadata ;
var track = this . _videoTrack ;
var le = this . _littleEndian ;
var v = new DataView ( arrayBuffer , dataOffset , dataSize ) ;
if ( ! meta ) {
if ( this . _hasVideo === false && this . _hasVideoFlagOverrided === false ) {
this . _hasVideo = true ;
this . _mediaInfo . hasVideo = true ;
}
meta = this . _videoMetadata = { } ;
meta . type = "video" ;
meta . id = track . id ;
meta . timescale = this . _timescale ;
meta . duration = this . _duration ;
} else {
if ( typeof meta . avcc !== "undefined" ) {
_utils _logger _js _ _WEBPACK _IMPORTED _MODULE _0 _ _ . default . w ( this . TAG , "Found another AVCDecoderConfigurationRecord!" ) ;
}
}
var version = v . getUint8 ( 0 ) ;
var avcProfile = v . getUint8 ( 1 ) ;
var profileCompatibility = v . getUint8 ( 2 ) ;
var avcLevel = v . getUint8 ( 3 ) ;
if ( version !== 1 || avcProfile === 0 ) {
this . _onError ( _demux _errors _js _ _WEBPACK _IMPORTED _MODULE _3 _ _ . default . FORMAT _ERROR , "Flv: Invalid AVCDecoderConfigurationRecord" ) ;
return ;
}
this . _naluLengthSize = ( v . getUint8 ( 4 ) & 3 ) + 1 ;
if ( this . _naluLengthSize !== 3 && this . _naluLengthSize !== 4 ) {
this . _onError ( _demux _errors _js _ _WEBPACK _IMPORTED _MODULE _3 _ _ . default . FORMAT _ERROR , "Flv: Strange NaluLengthSizeMinusOne: " + ( this . _naluLengthSize - 1 ) ) ;
return ;
}
var spsCount = v . getUint8 ( 5 ) & 31 ;
if ( spsCount === 0 ) {
this . _onError ( _demux _errors _js _ _WEBPACK _IMPORTED _MODULE _3 _ _ . default . FORMAT _ERROR , "Flv: Invalid AVCDecoderConfigurationRecord: No SPS" ) ;
return ;
} else if ( spsCount > 1 ) {
_utils _logger _js _ _WEBPACK _IMPORTED _MODULE _0 _ _ . default . w ( this . TAG , "Flv: Strange AVCDecoderConfigurationRecord: SPS Count = " + spsCount ) ;
}
var offset = 6 ;
for ( var i = 0 ; i < spsCount ; i ++ ) {
var len = v . getUint16 ( offset , ! le ) ;
offset += 2 ;
if ( len === 0 ) {
continue ;
}
var sps = new Uint8Array ( arrayBuffer , dataOffset + offset , len ) ;
offset += len ;
var config = _sps _parser _js _ _WEBPACK _IMPORTED _MODULE _2 _ _ . default . parseSPS ( sps ) ;
if ( i !== 0 ) {
continue ;
}
meta . codecWidth = config . codec _size . width ;
meta . codecHeight = config . codec _size . height ;
meta . presentWidth = config . present _size . width ;
meta . presentHeight = config . present _size . height ;
meta . profile = config . profile _string ;
meta . level = config . level _string ;
meta . bitDepth = config . bit _depth ;
meta . chromaFormat = config . chroma _format ;
meta . sarRatio = config . sar _ratio ;
meta . frameRate = config . frame _rate ;
if ( config . frame _rate . fixed === false || config . frame _rate . fps _num === 0 || config . frame _rate . fps _den === 0 ) {
meta . frameRate = this . _referenceFrameRate ;
}
var fps _den = meta . frameRate . fps _den ;
var fps _num = meta . frameRate . fps _num ;
meta . refSampleDuration = meta . timescale * ( fps _den / fps _num ) ;
var codecArray = sps . subarray ( 1 , 4 ) ;
var codecString = "avc1." ;
for ( var j = 0 ; j < 3 ; j ++ ) {
var h = codecArray [ j ] . toString ( 16 ) ;
if ( h . length < 2 ) {
h = "0" + h ;
}
codecString += h ;
}
meta . codec = codecString ;
var mi = this . _mediaInfo ;
mi . width = meta . codecWidth ;
mi . height = meta . codecHeight ;
mi . fps = meta . frameRate . fps ;
mi . profile = meta . profile ;
mi . level = meta . level ;
mi . refFrames = config . ref _frames ;
mi . chromaFormat = config . chroma _format _string ;
mi . sarNum = meta . sarRatio . width ;
mi . sarDen = meta . sarRatio . height ;
mi . videoCodec = codecString ;
if ( mi . hasAudio ) {
if ( mi . audioCodec != null ) {
mi . mimeType = 'video/x-flv; codecs="' + mi . videoCodec + "," + mi . audioCodec + '"' ;
}
} else {
mi . mimeType = 'video/x-flv; codecs="' + mi . videoCodec + '"' ;
}
if ( mi . isComplete ( ) ) {
this . _onMediaInfo ( mi ) ;
}
}
var ppsCount = v . getUint8 ( offset ) ;
if ( ppsCount === 0 ) {
this . _onError ( _demux _errors _js _ _WEBPACK _IMPORTED _MODULE _3 _ _ . default . FORMAT _ERROR , "Flv: Invalid AVCDecoderConfigurationRecord: No PPS" ) ;
return ;
} else if ( ppsCount > 1 ) {
_utils _logger _js _ _WEBPACK _IMPORTED _MODULE _0 _ _ . default . w ( this . TAG , "Flv: Strange AVCDecoderConfigurationRecord: PPS Count = " + ppsCount ) ;
}
offset ++ ;
for ( var i = 0 ; i < ppsCount ; i ++ ) {
var len = v . getUint16 ( offset , ! le ) ;
offset += 2 ;
if ( len === 0 ) {
continue ;
}
offset += len ;
}
meta . avcc = new Uint8Array ( dataSize ) ;
meta . avcc . set ( new Uint8Array ( arrayBuffer , dataOffset , dataSize ) , 0 ) ;
_utils _logger _js _ _WEBPACK _IMPORTED _MODULE _0 _ _ . default . v ( this . TAG , "Parsed AVCDecoderConfigurationRecord" ) ;
if ( this . _isInitialMetadataDispatched ( ) ) {
if ( this . _dispatch && ( this . _audioTrack . length || this . _videoTrack . length ) ) {
this . _onDataAvailable ( this . _audioTrack , this . _videoTrack ) ;
}
} else {
this . _videoInitialMetadataDispatched = true ;
}
this . _dispatch = false ;
this . _onTrackMetadata ( "video" , meta ) ;
} ;
FLVDemuxer2 . prototype . _parseAVCVideoData = function ( arrayBuffer , dataOffset , dataSize , tagTimestamp , tagPosition , frameType , cts ) {
var le = this . _littleEndian ;
var v = new DataView ( arrayBuffer , dataOffset , dataSize ) ;
var units = [ ] , length = 0 ;
var offset = 0 ;
var lengthSize = this . _naluLengthSize ;
var dts = this . _timestampBase + tagTimestamp ;
var keyframe = frameType === 1 ;
while ( offset < dataSize ) {
if ( offset + 4 >= dataSize ) {
_utils _logger _js _ _WEBPACK _IMPORTED _MODULE _0 _ _ . default . w ( this . TAG , "Malformed Nalu near timestamp " + dts + ", offset = " + offset + ", dataSize = " + dataSize ) ;
break ;
}
var naluSize = v . getUint32 ( offset , ! le ) ;
if ( lengthSize === 3 ) {
naluSize >>>= 8 ;
}
if ( naluSize > dataSize - lengthSize ) {
_utils _logger _js _ _WEBPACK _IMPORTED _MODULE _0 _ _ . default . w ( this . TAG , "Malformed Nalus near timestamp " + dts + ", NaluSize > DataSize!" ) ;
return ;
}
var unitType = v . getUint8 ( offset + lengthSize ) & 31 ;
if ( unitType === 5 ) {
keyframe = true ;
}
var data = new Uint8Array ( arrayBuffer , dataOffset + offset , lengthSize + naluSize ) ;
var unit = { type : unitType , data } ;
units . push ( unit ) ;
length += data . byteLength ;
offset += lengthSize + naluSize ;
}
if ( units . length ) {
var track = this . _videoTrack ;
var avcSample = {
units ,
length ,
isKeyframe : keyframe ,
dts ,
cts ,
pts : dts + cts
} ;
if ( keyframe ) {
avcSample . fileposition = tagPosition ;
}
track . samples . push ( avcSample ) ;
track . length += length ;
}
} ;
return FLVDemuxer2 ;
} ( ) ;
_ _webpack _exports _ _2 [ "default" ] = FLVDemuxer ;
} ,
"./src/demux/sps-parser.js" : function ( _ _unused _webpack _module , _ _webpack _exports _ _2 , _ _webpack _require _ _2 ) {
"use strict" ;
_ _webpack _require _ _2 . r ( _ _webpack _exports _ _2 ) ;
var _exp _golomb _js _ _WEBPACK _IMPORTED _MODULE _0 _ _ = _ _webpack _require _ _2 ( "./src/demux/exp-golomb.js" ) ;
var SPSParser = function ( ) {
function SPSParser2 ( ) {
}
SPSParser2 . _ebsp2rbsp = function ( uint8array ) {
var src = uint8array ;
var src _length = src . byteLength ;
var dst = new Uint8Array ( src _length ) ;
var dst _idx = 0 ;
for ( var i = 0 ; i < src _length ; i ++ ) {
if ( i >= 2 ) {
if ( src [ i ] === 3 && src [ i - 1 ] === 0 && src [ i - 2 ] === 0 ) {
continue ;
}
}
dst [ dst _idx ] = src [ i ] ;
dst _idx ++ ;
}
return new Uint8Array ( dst . buffer , 0 , dst _idx ) ;
} ;
SPSParser2 . parseSPS = function ( uint8array ) {
var rbsp = SPSParser2 . _ebsp2rbsp ( uint8array ) ;
var gb = new _exp _golomb _js _ _WEBPACK _IMPORTED _MODULE _0 _ _ . default ( rbsp ) ;
gb . readByte ( ) ;
var profile _idc = gb . readByte ( ) ;
gb . readByte ( ) ;
var level _idc = gb . readByte ( ) ;
gb . readUEG ( ) ;
var profile _string = SPSParser2 . getProfileString ( profile _idc ) ;
var level _string = SPSParser2 . getLevelString ( level _idc ) ;
var chroma _format _idc = 1 ;
var chroma _format = 420 ;
var chroma _format _table = [ 0 , 420 , 422 , 444 ] ;
var bit _depth = 8 ;
if ( profile _idc === 100 || profile _idc === 110 || profile _idc === 122 || profile _idc === 244 || profile _idc === 44 || profile _idc === 83 || profile _idc === 86 || profile _idc === 118 || profile _idc === 128 || profile _idc === 138 || profile _idc === 144 ) {
chroma _format _idc = gb . readUEG ( ) ;
if ( chroma _format _idc === 3 ) {
gb . readBits ( 1 ) ;
}
if ( chroma _format _idc <= 3 ) {
chroma _format = chroma _format _table [ chroma _format _idc ] ;
}
bit _depth = gb . readUEG ( ) + 8 ;
gb . readUEG ( ) ;
gb . readBits ( 1 ) ;
if ( gb . readBool ( ) ) {
var scaling _list _count = chroma _format _idc !== 3 ? 8 : 12 ;
for ( var i = 0 ; i < scaling _list _count ; i ++ ) {
if ( gb . readBool ( ) ) {
if ( i < 6 ) {
SPSParser2 . _skipScalingList ( gb , 16 ) ;
} else {
SPSParser2 . _skipScalingList ( gb , 64 ) ;
}
}
}
}
}
gb . readUEG ( ) ;
var pic _order _cnt _type = gb . readUEG ( ) ;
if ( pic _order _cnt _type === 0 ) {
gb . readUEG ( ) ;
} else if ( pic _order _cnt _type === 1 ) {
gb . readBits ( 1 ) ;
gb . readSEG ( ) ;
gb . readSEG ( ) ;
var num _ref _frames _in _pic _order _cnt _cycle = gb . readUEG ( ) ;
for ( var i = 0 ; i < num _ref _frames _in _pic _order _cnt _cycle ; i ++ ) {
gb . readSEG ( ) ;
}
}
var ref _frames = gb . readUEG ( ) ;
gb . readBits ( 1 ) ;
var pic _width _in _mbs _minus1 = gb . readUEG ( ) ;
var pic _height _in _map _units _minus1 = gb . readUEG ( ) ;
var frame _mbs _only _flag = gb . readBits ( 1 ) ;
if ( frame _mbs _only _flag === 0 ) {
gb . readBits ( 1 ) ;
}
gb . readBits ( 1 ) ;
var frame _crop _left _offset = 0 ;
var frame _crop _right _offset = 0 ;
var frame _crop _top _offset = 0 ;
var frame _crop _bottom _offset = 0 ;
var frame _cropping _flag = gb . readBool ( ) ;
if ( frame _cropping _flag ) {
frame _crop _left _offset = gb . readUEG ( ) ;
frame _crop _right _offset = gb . readUEG ( ) ;
frame _crop _top _offset = gb . readUEG ( ) ;
frame _crop _bottom _offset = gb . readUEG ( ) ;
}
var sar _width = 1 , sar _height = 1 ;
var fps = 0 , fps _fixed = true , fps _num = 0 , fps _den = 0 ;
var vui _parameters _present _flag = gb . readBool ( ) ;
if ( vui _parameters _present _flag ) {
if ( gb . readBool ( ) ) {
var aspect _ratio _idc = gb . readByte ( ) ;
var sar _w _table = [ 1 , 12 , 10 , 16 , 40 , 24 , 20 , 32 , 80 , 18 , 15 , 64 , 160 , 4 , 3 , 2 ] ;
var sar _h _table = [ 1 , 11 , 11 , 11 , 33 , 11 , 11 , 11 , 33 , 11 , 11 , 33 , 99 , 3 , 2 , 1 ] ;
if ( aspect _ratio _idc > 0 && aspect _ratio _idc < 16 ) {
sar _width = sar _w _table [ aspect _ratio _idc - 1 ] ;
sar _height = sar _h _table [ aspect _ratio _idc - 1 ] ;
} else if ( aspect _ratio _idc === 255 ) {
sar _width = gb . readByte ( ) << 8 | gb . readByte ( ) ;
sar _height = gb . readByte ( ) << 8 | gb . readByte ( ) ;
}
}
if ( gb . readBool ( ) ) {
gb . readBool ( ) ;
}
if ( gb . readBool ( ) ) {
gb . readBits ( 4 ) ;
if ( gb . readBool ( ) ) {
gb . readBits ( 24 ) ;
}
}
if ( gb . readBool ( ) ) {
gb . readUEG ( ) ;
gb . readUEG ( ) ;
}
if ( gb . readBool ( ) ) {
var num _units _in _tick = gb . readBits ( 32 ) ;
var time _scale = gb . readBits ( 32 ) ;
fps _fixed = gb . readBool ( ) ;
fps _num = time _scale ;
fps _den = num _units _in _tick * 2 ;
fps = fps _num / fps _den ;
}
}
var sarScale = 1 ;
if ( sar _width !== 1 || sar _height !== 1 ) {
sarScale = sar _width / sar _height ;
}
var crop _unit _x = 0 , crop _unit _y = 0 ;
if ( chroma _format _idc === 0 ) {
crop _unit _x = 1 ;
crop _unit _y = 2 - frame _mbs _only _flag ;
} else {
var sub _wc = chroma _format _idc === 3 ? 1 : 2 ;
var sub _hc = chroma _format _idc === 1 ? 2 : 1 ;
crop _unit _x = sub _wc ;
crop _unit _y = sub _hc * ( 2 - frame _mbs _only _flag ) ;
}
var codec _width = ( pic _width _in _mbs _minus1 + 1 ) * 16 ;
var codec _height = ( 2 - frame _mbs _only _flag ) * ( ( pic _height _in _map _units _minus1 + 1 ) * 16 ) ;
codec _width -= ( frame _crop _left _offset + frame _crop _right _offset ) * crop _unit _x ;
codec _height -= ( frame _crop _top _offset + frame _crop _bottom _offset ) * crop _unit _y ;
var present _width = Math . ceil ( codec _width * sarScale ) ;
gb . destroy ( ) ;
gb = null ;
return {
profile _string ,
level _string ,
bit _depth ,
ref _frames ,
chroma _format ,
chroma _format _string : SPSParser2 . getChromaFormatString ( chroma _format ) ,
frame _rate : {
fixed : fps _fixed ,
fps ,
fps _den ,
fps _num
} ,
sar _ratio : {
width : sar _width ,
height : sar _height
} ,
codec _size : {
width : codec _width ,
height : codec _height
} ,
present _size : {
width : present _width ,
height : codec _height
}
} ;
} ;
SPSParser2 . _skipScalingList = function ( gb , count ) {
var last _scale = 8 , next _scale = 8 ;
var delta _scale = 0 ;
for ( var i = 0 ; i < count ; i ++ ) {
if ( next _scale !== 0 ) {
delta _scale = gb . readSEG ( ) ;
next _scale = ( last _scale + delta _scale + 256 ) % 256 ;
}
last _scale = next _scale === 0 ? last _scale : next _scale ;
}
} ;
SPSParser2 . getProfileString = function ( profile _idc ) {
switch ( profile _idc ) {
case 66 :
return "Baseline" ;
case 77 :
return "Main" ;
case 88 :
return "Extended" ;
case 100 :
return "High" ;
case 110 :
return "High10" ;
case 122 :
return "High422" ;
case 244 :
return "High444" ;
default :
return "Unknown" ;
}
} ;
SPSParser2 . getLevelString = function ( level _idc ) {
return ( level _idc / 10 ) . toFixed ( 1 ) ;
} ;
SPSParser2 . getChromaFormatString = function ( chroma ) {
switch ( chroma ) {
case 420 :
return "4:2:0" ;
case 422 :
return "4:2:2" ;
case 444 :
return "4:4:4" ;
default :
return "Unknown" ;
}
} ;
return SPSParser2 ;
} ( ) ;
_ _webpack _exports _ _2 [ "default" ] = SPSParser ;
} ,
"./src/flv.js" : function ( _ _unused _webpack _module , _ _webpack _exports _ _2 , _ _webpack _require _ _2 ) {
"use strict" ;
_ _webpack _require _ _2 . r ( _ _webpack _exports _ _2 ) ;
var _utils _polyfill _js _ _WEBPACK _IMPORTED _MODULE _0 _ _ = _ _webpack _require _ _2 ( "./src/utils/polyfill.js" ) ;
var _core _features _js _ _WEBPACK _IMPORTED _MODULE _1 _ _ = _ _webpack _require _ _2 ( "./src/core/features.js" ) ;
var _io _loader _js _ _WEBPACK _IMPORTED _MODULE _2 _ _ = _ _webpack _require _ _2 ( "./src/io/loader.js" ) ;
var _player _flv _player _js _ _WEBPACK _IMPORTED _MODULE _3 _ _ = _ _webpack _require _ _2 ( "./src/player/flv-player.js" ) ;
var _player _native _player _js _ _WEBPACK _IMPORTED _MODULE _4 _ _ = _ _webpack _require _ _2 ( "./src/player/native-player.js" ) ;
var _player _player _events _js _ _WEBPACK _IMPORTED _MODULE _5 _ _ = _ _webpack _require _ _2 ( "./src/player/player-events.js" ) ;
var _player _player _errors _js _ _WEBPACK _IMPORTED _MODULE _6 _ _ = _ _webpack _require _ _2 ( "./src/player/player-errors.js" ) ;
var _utils _logging _control _js _ _WEBPACK _IMPORTED _MODULE _7 _ _ = _ _webpack _require _ _2 ( "./src/utils/logging-control.js" ) ;
var _utils _exception _js _ _WEBPACK _IMPORTED _MODULE _8 _ _ = _ _webpack _require _ _2 ( "./src/utils/exception.js" ) ;
_utils _polyfill _js _ _WEBPACK _IMPORTED _MODULE _0 _ _ . default . install ( ) ;
function createPlayer ( mediaDataSource , optionalConfig ) {
var mds = mediaDataSource ;
if ( mds == null || typeof mds !== "object" ) {
throw new _utils _exception _js _ _WEBPACK _IMPORTED _MODULE _8 _ _ . InvalidArgumentException ( "MediaDataSource must be an javascript object!" ) ;
}
if ( ! mds . hasOwnProperty ( "type" ) ) {
throw new _utils _exception _js _ _WEBPACK _IMPORTED _MODULE _8 _ _ . InvalidArgumentException ( "MediaDataSource must has type field to indicate video file type!" ) ;
}
switch ( mds . type ) {
case "flv" :
return new _player _flv _player _js _ _WEBPACK _IMPORTED _MODULE _3 _ _ . default ( mds , optionalConfig ) ;
default :
return new _player _native _player _js _ _WEBPACK _IMPORTED _MODULE _4 _ _ . default ( mds , optionalConfig ) ;
}
}
function isSupported ( ) {
return _core _features _js _ _WEBPACK _IMPORTED _MODULE _1 _ _ . default . supportMSEH264Playback ( ) ;
}
function getFeatureList ( ) {
return _core _features _js _ _WEBPACK _IMPORTED _MODULE _1 _ _ . default . getFeatureList ( ) ;
}
var flvjs = { } ;
flvjs . createPlayer = createPlayer ;
flvjs . isSupported = isSupported ;
flvjs . getFeatureList = getFeatureList ;
flvjs . BaseLoader = _io _loader _js _ _WEBPACK _IMPORTED _MODULE _2 _ _ . BaseLoader ;
flvjs . LoaderStatus = _io _loader _js _ _WEBPACK _IMPORTED _MODULE _2 _ _ . LoaderStatus ;
flvjs . LoaderErrors = _io _loader _js _ _WEBPACK _IMPORTED _MODULE _2 _ _ . LoaderErrors ;
flvjs . Events = _player _player _events _js _ _WEBPACK _IMPORTED _MODULE _5 _ _ . default ;
flvjs . ErrorTypes = _player _player _errors _js _ _WEBPACK _IMPORTED _MODULE _6 _ _ . ErrorTypes ;
flvjs . ErrorDetails = _player _player _errors _js _ _WEBPACK _IMPORTED _MODULE _6 _ _ . ErrorDetails ;
flvjs . FlvPlayer = _player _flv _player _js _ _WEBPACK _IMPORTED _MODULE _3 _ _ . default ;
flvjs . NativePlayer = _player _native _player _js _ _WEBPACK _IMPORTED _MODULE _4 _ _ . default ;
flvjs . LoggingControl = _utils _logging _control _js _ _WEBPACK _IMPORTED _MODULE _7 _ _ . default ;
Object . defineProperty ( flvjs , "version" , {
enumerable : true ,
get : function ( ) {
return "1.6.2" ;
}
} ) ;
_ _webpack _exports _ _2 [ "default" ] = flvjs ;
} ,
"./src/index.js" : function ( module2 , _ _unused _webpack _exports , _ _webpack _require _ _2 ) {
module2 . exports = _ _webpack _require _ _2 ( "./src/flv.js" ) . default ;
} ,
"./src/io/fetch-stream-loader.js" : function ( _ _unused _webpack _module , _ _webpack _exports _ _2 , _ _webpack _require _ _2 ) {
"use strict" ;
_ _webpack _require _ _2 . r ( _ _webpack _exports _ _2 ) ;
var _utils _browser _js _ _WEBPACK _IMPORTED _MODULE _0 _ _ = _ _webpack _require _ _2 ( "./src/utils/browser.js" ) ;
var _loader _js _ _WEBPACK _IMPORTED _MODULE _1 _ _ = _ _webpack _require _ _2 ( "./src/io/loader.js" ) ;
var _utils _exception _js _ _WEBPACK _IMPORTED _MODULE _2 _ _ = _ _webpack _require _ _2 ( "./src/utils/exception.js" ) ;
var _ _extends = function ( ) {
var extendStatics = function ( d , b ) {
extendStatics = Object . setPrototypeOf || { _ _proto _ _ : [ ] } instanceof Array && function ( d2 , b2 ) {
d2 . _ _proto _ _ = b2 ;
} || function ( d2 , b2 ) {
for ( var p in b2 )
if ( Object . prototype . hasOwnProperty . call ( b2 , p ) )
d2 [ p ] = b2 [ p ] ;
} ;
return extendStatics ( d , b ) ;
} ;
return function ( d , b ) {
if ( typeof b !== "function" && b !== null )
throw new TypeError ( "Class extends value " + String ( b ) + " is not a constructor or null" ) ;
extendStatics ( d , b ) ;
function _ _ ( ) {
this . constructor = d ;
}
d . prototype = b === null ? Object . create ( b ) : ( _ _ . prototype = b . prototype , new _ _ ( ) ) ;
} ;
} ( ) ;
var FetchStreamLoader = function ( _super ) {
_ _extends ( FetchStreamLoader2 , _super ) ;
function FetchStreamLoader2 ( seekHandler , config ) {
var _this = _super . call ( this , "fetch-stream-loader" ) || this ;
_this . TAG = "FetchStreamLoader" ;
_this . _seekHandler = seekHandler ;
_this . _config = config ;
_this . _needStash = true ;
_this . _requestAbort = false ;
_this . _contentLength = null ;
_this . _receivedLength = 0 ;
return _this ;
}
FetchStreamLoader2 . isSupported = function ( ) {
try {
var isWorkWellEdge = _utils _browser _js _ _WEBPACK _IMPORTED _MODULE _0 _ _ . default . msedge && _utils _browser _js _ _WEBPACK _IMPORTED _MODULE _0 _ _ . default . version . minor >= 15048 ;
var browserNotBlacklisted = _utils _browser _js _ _WEBPACK _IMPORTED _MODULE _0 _ _ . default . msedge ? isWorkWellEdge : true ;
return self . fetch && self . ReadableStream && browserNotBlacklisted ;
} catch ( e ) {
return false ;
}
} ;
FetchStreamLoader2 . prototype . destroy = function ( ) {
if ( this . isWorking ( ) ) {
this . abort ( ) ;
}
_super . prototype . destroy . call ( this ) ;
} ;
FetchStreamLoader2 . prototype . open = function ( dataSource , range ) {
var _this = this ;
this . _dataSource = dataSource ;
this . _range = range ;
var sourceURL = dataSource . url ;
if ( this . _config . reuseRedirectedURL && dataSource . redirectedURL != void 0 ) {
sourceURL = dataSource . redirectedURL ;
}
var seekConfig = this . _seekHandler . getConfig ( sourceURL , range ) ;
var headers = new self . Headers ( ) ;
if ( typeof seekConfig . headers === "object" ) {
var configHeaders = seekConfig . headers ;
for ( var key in configHeaders ) {
if ( configHeaders . hasOwnProperty ( key ) ) {
headers . append ( key , configHeaders [ key ] ) ;
}
}
}
var params = {
method : "GET" ,
headers ,
mode : "cors" ,
cache : "default" ,
referrerPolicy : "no-referrer-when-downgrade"
} ;
if ( typeof this . _config . headers === "object" ) {
for ( var key in this . _config . headers ) {
headers . append ( key , this . _config . headers [ key ] ) ;
}
}
if ( dataSource . cors === false ) {
params . mode = "same-origin" ;
}
if ( dataSource . withCredentials ) {
params . credentials = "include" ;
}
if ( dataSource . referrerPolicy ) {
params . referrerPolicy = dataSource . referrerPolicy ;
}
if ( self . AbortController ) {
this . _abortController = new self . AbortController ( ) ;
params . signal = this . _abortController . signal ;
}
this . _status = _loader _js _ _WEBPACK _IMPORTED _MODULE _1 _ _ . LoaderStatus . kConnecting ;
self . fetch ( seekConfig . url , params ) . then ( function ( res ) {
if ( _this . _requestAbort ) {
_this . _status = _loader _js _ _WEBPACK _IMPORTED _MODULE _1 _ _ . LoaderStatus . kIdle ;
res . body . cancel ( ) ;
return ;
}
if ( res . ok && ( res . status >= 200 && res . status <= 299 ) ) {
if ( res . url !== seekConfig . url ) {
if ( _this . _onURLRedirect ) {
var redirectedURL = _this . _seekHandler . removeURLParameters ( res . url ) ;
_this . _onURLRedirect ( redirectedURL ) ;
}
}
var lengthHeader = res . headers . get ( "Content-Length" ) ;
if ( lengthHeader != null ) {
_this . _contentLength = parseInt ( lengthHeader ) ;
if ( _this . _contentLength !== 0 ) {
if ( _this . _onContentLengthKnown ) {
_this . _onContentLengthKnown ( _this . _contentLength ) ;
}
}
}
return _this . _pump . call ( _this , res . body . getReader ( ) ) ;
} else {
_this . _status = _loader _js _ _WEBPACK _IMPORTED _MODULE _1 _ _ . LoaderStatus . kError ;
if ( _this . _onError ) {
_this . _onError ( _loader _js _ _WEBPACK _IMPORTED _MODULE _1 _ _ . LoaderErrors . HTTP _STATUS _CODE _INVALID , { code : res . status , msg : res . statusText } ) ;
} else {
throw new _utils _exception _js _ _WEBPACK _IMPORTED _MODULE _2 _ _ . RuntimeException ( "FetchStreamLoader: Http code invalid, " + res . status + " " + res . statusText ) ;
}
}
} ) . catch ( function ( e ) {
if ( _this . _abortController && _this . _abortController . signal . aborted ) {
return ;
}
_this . _status = _loader _js _ _WEBPACK _IMPORTED _MODULE _1 _ _ . LoaderStatus . kError ;
if ( _this . _onError ) {
_this . _onError ( _loader _js _ _WEBPACK _IMPORTED _MODULE _1 _ _ . LoaderErrors . EXCEPTION , { code : - 1 , msg : e . message } ) ;
} else {
throw e ;
}
} ) ;
} ;
FetchStreamLoader2 . prototype . abort = function ( ) {
this . _requestAbort = true ;
if ( this . _status !== _loader _js _ _WEBPACK _IMPORTED _MODULE _1 _ _ . LoaderStatus . kBuffering || ! _utils _browser _js _ _WEBPACK _IMPORTED _MODULE _0 _ _ . default . chrome ) {
if ( this . _abortController ) {
try {
this . _abortController . abort ( ) ;
} catch ( e ) {
}
}
}
} ;
FetchStreamLoader2 . prototype . _pump = function ( reader ) {
var _this = this ;
return reader . read ( ) . then ( function ( result ) {
if ( result . done ) {
if ( _this . _contentLength !== null && _this . _receivedLength < _this . _contentLength ) {
_this . _status = _loader _js _ _WEBPACK _IMPORTED _MODULE _1 _ _ . LoaderStatus . kError ;
var type = _loader _js _ _WEBPACK _IMPORTED _MODULE _1 _ _ . LoaderErrors . EARLY _EOF ;
var info = { code : - 1 , msg : "Fetch stream meet Early-EOF" } ;
if ( _this . _onError ) {
_this . _onError ( type , info ) ;
} else {
throw new _utils _exception _js _ _WEBPACK _IMPORTED _MODULE _2 _ _ . RuntimeException ( info . msg ) ;
}
} else {
_this . _status = _loader _js _ _WEBPACK _IMPORTED _MODULE _1 _ _ . LoaderStatus . kComplete ;
if ( _this . _onComplete ) {
_this . _onComplete ( _this . _range . from , _this . _range . from + _this . _receivedLength - 1 ) ;
}
}
} else {
if ( _this . _abortController && _this . _abortController . signal . aborted ) {
_this . _status = _loader _js _ _WEBPACK _IMPORTED _MODULE _1 _ _ . LoaderStatus . kComplete ;
return ;
} else if ( _this . _requestAbort === true ) {
_this . _status = _loader _js _ _WEBPACK _IMPORTED _MODULE _1 _ _ . LoaderStatus . kComplete ;
return reader . cancel ( ) ;
}
_this . _status = _loader _js _ _WEBPACK _IMPORTED _MODULE _1 _ _ . LoaderStatus . kBuffering ;
var chunk = result . value . buffer ;
var byteStart = _this . _range . from + _this . _receivedLength ;
_this . _receivedLength += chunk . byteLength ;
if ( _this . _onDataArrival ) {
_this . _onDataArrival ( chunk , byteStart , _this . _receivedLength ) ;
}
_this . _pump ( reader ) ;
}
} ) . catch ( function ( e ) {
if ( _this . _abortController && _this . _abortController . signal . aborted ) {
_this . _status = _loader _js _ _WEBPACK _IMPORTED _MODULE _1 _ _ . LoaderStatus . kComplete ;
return ;
}
if ( e . code === 11 && _utils _browser _js _ _WEBPACK _IMPORTED _MODULE _0 _ _ . default . msedge ) {
return ;
}
_this . _status = _loader _js _ _WEBPACK _IMPORTED _MODULE _1 _ _ . LoaderStatus . kError ;
var type = 0 ;
var info = null ;
if ( ( e . code === 19 || e . message === "network error" ) && ( _this . _contentLength === null || _this . _contentLength !== null && _this . _receivedLength < _this . _contentLength ) ) {
type = _loader _js _ _WEBPACK _IMPORTED _MODULE _1 _ _ . LoaderErrors . EARLY _EOF ;
info = { code : e . code , msg : "Fetch stream meet Early-EOF" } ;
} else {
type = _loader _js _ _WEBPACK _IMPORTED _MODULE _1 _ _ . LoaderErrors . EXCEPTION ;
info = { code : e . code , msg : e . message } ;
}
if ( _this . _onError ) {
_this . _onError ( type , info ) ;
} else {
throw new _utils _exception _js _ _WEBPACK _IMPORTED _MODULE _2 _ _ . RuntimeException ( info . msg ) ;
}
} ) ;
} ;
return FetchStreamLoader2 ;
} ( _loader _js _ _WEBPACK _IMPORTED _MODULE _1 _ _ . BaseLoader ) ;
_ _webpack _exports _ _2 [ "default" ] = FetchStreamLoader ;
} ,
"./src/io/io-controller.js" : function ( _ _unused _webpack _module , _ _webpack _exports _ _2 , _ _webpack _require _ _2 ) {
"use strict" ;
_ _webpack _require _ _2 . r ( _ _webpack _exports _ _2 ) ;
var _utils _logger _js _ _WEBPACK _IMPORTED _MODULE _0 _ _ = _ _webpack _require _ _2 ( "./src/utils/logger.js" ) ;
var _speed _sampler _js _ _WEBPACK _IMPORTED _MODULE _1 _ _ = _ _webpack _require _ _2 ( "./src/io/speed-sampler.js" ) ;
var _loader _js _ _WEBPACK _IMPORTED _MODULE _2 _ _ = _ _webpack _require _ _2 ( "./src/io/loader.js" ) ;
var _fetch _stream _loader _js _ _WEBPACK _IMPORTED _MODULE _3 _ _ = _ _webpack _require _ _2 ( "./src/io/fetch-stream-loader.js" ) ;
var _xhr _moz _chunked _loader _js _ _WEBPACK _IMPORTED _MODULE _4 _ _ = _ _webpack _require _ _2 ( "./src/io/xhr-moz-chunked-loader.js" ) ;
var _xhr _range _loader _js _ _WEBPACK _IMPORTED _MODULE _5 _ _ = _ _webpack _require _ _2 ( "./src/io/xhr-range-loader.js" ) ;
var _websocket _loader _js _ _WEBPACK _IMPORTED _MODULE _6 _ _ = _ _webpack _require _ _2 ( "./src/io/websocket-loader.js" ) ;
var _range _seek _handler _js _ _WEBPACK _IMPORTED _MODULE _7 _ _ = _ _webpack _require _ _2 ( "./src/io/range-seek-handler.js" ) ;
var _param _seek _handler _js _ _WEBPACK _IMPORTED _MODULE _8 _ _ = _ _webpack _require _ _2 ( "./src/io/param-seek-handler.js" ) ;
var _utils _exception _js _ _WEBPACK _IMPORTED _MODULE _9 _ _ = _ _webpack _require _ _2 ( "./src/utils/exception.js" ) ;
var IOController = function ( ) {
function IOController2 ( dataSource , config , extraData ) {
this . TAG = "IOController" ;
this . _config = config ;
this . _extraData = extraData ;
this . _stashInitialSize = 1024 * 384 ;
if ( config . stashInitialSize != void 0 && config . stashInitialSize > 0 ) {
this . _stashInitialSize = config . stashInitialSize ;
}
this . _stashUsed = 0 ;
this . _stashSize = this . _stashInitialSize ;
this . _bufferSize = 1024 * 1024 * 3 ;
this . _stashBuffer = new ArrayBuffer ( this . _bufferSize ) ;
this . _stashByteStart = 0 ;
this . _enableStash = true ;
if ( config . enableStashBuffer === false ) {
this . _enableStash = false ;
}
this . _loader = null ;
this . _loaderClass = null ;
this . _seekHandler = null ;
this . _dataSource = dataSource ;
this . _isWebSocketURL = /wss?:\/\/(.+?)/ . test ( dataSource . url ) ;
this . _refTotalLength = dataSource . filesize ? dataSource . filesize : null ;
this . _totalLength = this . _refTotalLength ;
this . _fullRequestFlag = false ;
this . _currentRange = null ;
this . _redirectedURL = null ;
this . _speedNormalized = 0 ;
this . _speedSampler = new _speed _sampler _js _ _WEBPACK _IMPORTED _MODULE _1 _ _ . default ( ) ;
this . _speedNormalizeList = [ 64 , 128 , 256 , 384 , 512 , 768 , 1024 , 1536 , 2048 , 3072 , 4096 ] ;
this . _isEarlyEofReconnecting = false ;
this . _paused = false ;
this . _resumeFrom = 0 ;
this . _onDataArrival = null ;
this . _onSeeked = null ;
this . _onError = null ;
this . _onComplete = null ;
this . _onRedirect = null ;
this . _onRecoveredEarlyEof = null ;
this . _selectSeekHandler ( ) ;
this . _selectLoader ( ) ;
this . _createLoader ( ) ;
}
IOController2 . prototype . destroy = function ( ) {
if ( this . _loader . isWorking ( ) ) {
this . _loader . abort ( ) ;
}
this . _loader . destroy ( ) ;
this . _loader = null ;
this . _loaderClass = null ;
this . _dataSource = null ;
this . _stashBuffer = null ;
this . _stashUsed = this . _stashSize = this . _bufferSize = this . _stashByteStart = 0 ;
this . _currentRange = null ;
this . _speedSampler = null ;
this . _isEarlyEofReconnecting = false ;
this . _onDataArrival = null ;
this . _onSeeked = null ;
this . _onError = null ;
this . _onComplete = null ;
this . _onRedirect = null ;
this . _onRecoveredEarlyEof = null ;
this . _extraData = null ;
} ;
IOController2 . prototype . isWorking = function ( ) {
return this . _loader && this . _loader . isWorking ( ) && ! this . _paused ;
} ;
IOController2 . prototype . isPaused = function ( ) {
return this . _paused ;
} ;
Object . defineProperty ( IOController2 . prototype , "status" , {
get : function ( ) {
return this . _loader . status ;
} ,
enumerable : false ,
configurable : true
} ) ;
Object . defineProperty ( IOController2 . prototype , "extraData" , {
get : function ( ) {
return this . _extraData ;
} ,
set : function ( data ) {
this . _extraData = data ;
} ,
enumerable : false ,
configurable : true
} ) ;
Object . defineProperty ( IOController2 . prototype , "onDataArrival" , {
get : function ( ) {
return this . _onDataArrival ;
} ,
set : function ( callback ) {
this . _onDataArrival = callback ;
} ,
enumerable : false ,
configurable : true
} ) ;
Object . defineProperty ( IOController2 . prototype , "onSeeked" , {
get : function ( ) {
return this . _onSeeked ;
} ,
set : function ( callback ) {
this . _onSeeked = callback ;
} ,
enumerable : false ,
configurable : true
} ) ;
Object . defineProperty ( IOController2 . prototype , "onError" , {
get : function ( ) {
return this . _onError ;
} ,
set : function ( callback ) {
this . _onError = callback ;
} ,
enumerable : false ,
configurable : true
} ) ;
Object . defineProperty ( IOController2 . prototype , "onComplete" , {
get : function ( ) {
return this . _onComplete ;
} ,
set : function ( callback ) {
this . _onComplete = callback ;
} ,
enumerable : false ,
configurable : true
} ) ;
Object . defineProperty ( IOController2 . prototype , "onRedirect" , {
get : function ( ) {
return this . _onRedirect ;
} ,
set : function ( callback ) {
this . _onRedirect = callback ;
} ,
enumerable : false ,
configurable : true
} ) ;
Object . defineProperty ( IOController2 . prototype , "onRecoveredEarlyEof" , {
get : function ( ) {
return this . _onRecoveredEarlyEof ;
} ,
set : function ( callback ) {
this . _onRecoveredEarlyEof = callback ;
} ,
enumerable : false ,
configurable : true
} ) ;
Object . defineProperty ( IOController2 . prototype , "currentURL" , {
get : function ( ) {
return this . _dataSource . url ;
} ,
enumerable : false ,
configurable : true
} ) ;
Object . defineProperty ( IOController2 . prototype , "hasRedirect" , {
get : function ( ) {
return this . _redirectedURL != null || this . _dataSource . redirectedURL != void 0 ;
} ,
enumerable : false ,
configurable : true
} ) ;
Object . defineProperty ( IOController2 . prototype , "currentRedirectedURL" , {
get : function ( ) {
return this . _redirectedURL || this . _dataSource . redirectedURL ;
} ,
enumerable : false ,
configurable : true
} ) ;
Object . defineProperty ( IOController2 . prototype , "currentSpeed" , {
get : function ( ) {
if ( this . _loaderClass === _xhr _range _loader _js _ _WEBPACK _IMPORTED _MODULE _5 _ _ . default ) {
return this . _loader . currentSpeed ;
}
return this . _speedSampler . lastSecondKBps ;
} ,
enumerable : false ,
configurable : true
} ) ;
Object . defineProperty ( IOController2 . prototype , "loaderType" , {
get : function ( ) {
return this . _loader . type ;
} ,
enumerable : false ,
configurable : true
} ) ;
IOController2 . prototype . _selectSeekHandler = function ( ) {
var config = this . _config ;
if ( config . seekType === "range" ) {
this . _seekHandler = new _range _seek _handler _js _ _WEBPACK _IMPORTED _MODULE _7 _ _ . default ( this . _config . rangeLoadZeroStart ) ;
} else if ( config . seekType === "param" ) {
var paramStart = config . seekParamStart || "bstart" ;
var paramEnd = config . seekParamEnd || "bend" ;
this . _seekHandler = new _param _seek _handler _js _ _WEBPACK _IMPORTED _MODULE _8 _ _ . default ( paramStart , paramEnd ) ;
} else if ( config . seekType === "custom" ) {
if ( typeof config . customSeekHandler !== "function" ) {
throw new _utils _exception _js _ _WEBPACK _IMPORTED _MODULE _9 _ _ . InvalidArgumentException ( "Custom seekType specified in config but invalid customSeekHandler!" ) ;
}
this . _seekHandler = new config . customSeekHandler ( ) ;
} else {
throw new _utils _exception _js _ _WEBPACK _IMPORTED _MODULE _9 _ _ . InvalidArgumentException ( "Invalid seekType in config: " + config . seekType ) ;
}
} ;
IOController2 . prototype . _selectLoader = function ( ) {
if ( this . _config . customLoader != null ) {
this . _loaderClass = this . _config . customLoader ;
} else if ( this . _isWebSocketURL ) {
this . _loaderClass = _websocket _loader _js _ _WEBPACK _IMPORTED _MODULE _6 _ _ . default ;
} else if ( _fetch _stream _loader _js _ _WEBPACK _IMPORTED _MODULE _3 _ _ . default . isSupported ( ) ) {
this . _loaderClass = _fetch _stream _loader _js _ _WEBPACK _IMPORTED _MODULE _3 _ _ . default ;
} else if ( _xhr _moz _chunked _loader _js _ _WEBPACK _IMPORTED _MODULE _4 _ _ . default . isSupported ( ) ) {
this . _loaderClass = _xhr _moz _chunked _loader _js _ _WEBPACK _IMPORTED _MODULE _4 _ _ . default ;
} else if ( _xhr _range _loader _js _ _WEBPACK _IMPORTED _MODULE _5 _ _ . default . isSupported ( ) ) {
this . _loaderClass = _xhr _range _loader _js _ _WEBPACK _IMPORTED _MODULE _5 _ _ . default ;
} else {
throw new _utils _exception _js _ _WEBPACK _IMPORTED _MODULE _9 _ _ . RuntimeException ( "Your browser doesn't support xhr with arraybuffer responseType!" ) ;
}
} ;
IOController2 . prototype . _createLoader = function ( ) {
this . _loader = new this . _loaderClass ( this . _seekHandler , this . _config ) ;
if ( this . _loader . needStashBuffer === false ) {
this . _enableStash = false ;
}
this . _loader . onContentLengthKnown = this . _onContentLengthKnown . bind ( this ) ;
this . _loader . onURLRedirect = this . _onURLRedirect . bind ( this ) ;
this . _loader . onDataArrival = this . _onLoaderChunkArrival . bind ( this ) ;
this . _loader . onComplete = this . _onLoaderComplete . bind ( this ) ;
this . _loader . onError = this . _onLoaderError . bind ( this ) ;
} ;
IOController2 . prototype . open = function ( optionalFrom ) {
this . _currentRange = { from : 0 , to : - 1 } ;
if ( optionalFrom ) {
this . _currentRange . from = optionalFrom ;
}
this . _speedSampler . reset ( ) ;
if ( ! optionalFrom ) {
this . _fullRequestFlag = true ;
}
this . _loader . open ( this . _dataSource , Object . assign ( { } , this . _currentRange ) ) ;
} ;
IOController2 . prototype . abort = function ( ) {
this . _loader . abort ( ) ;
if ( this . _paused ) {
this . _paused = false ;
this . _resumeFrom = 0 ;
}
} ;
IOController2 . prototype . pause = function ( ) {
if ( this . isWorking ( ) ) {
this . _loader . abort ( ) ;
if ( this . _stashUsed !== 0 ) {
this . _resumeFrom = this . _stashByteStart ;
this . _currentRange . to = this . _stashByteStart - 1 ;
} else {
this . _resumeFrom = this . _currentRange . to + 1 ;
}
this . _stashUsed = 0 ;
this . _stashByteStart = 0 ;
this . _paused = true ;
}
} ;
IOController2 . prototype . resume = function ( ) {
if ( this . _paused ) {
this . _paused = false ;
var bytes = this . _resumeFrom ;
this . _resumeFrom = 0 ;
this . _internalSeek ( bytes , true ) ;
}
} ;
IOController2 . prototype . seek = function ( bytes ) {
this . _paused = false ;
this . _stashUsed = 0 ;
this . _stashByteStart = 0 ;
this . _internalSeek ( bytes , true ) ;
} ;
IOController2 . prototype . _internalSeek = function ( bytes , dropUnconsumed ) {
if ( this . _loader . isWorking ( ) ) {
this . _loader . abort ( ) ;
}
this . _flushStashBuffer ( dropUnconsumed ) ;
this . _loader . destroy ( ) ;
this . _loader = null ;
var requestRange = { from : bytes , to : - 1 } ;
this . _currentRange = { from : requestRange . from , to : - 1 } ;
this . _speedSampler . reset ( ) ;
this . _stashSize = this . _stashInitialSize ;
this . _createLoader ( ) ;
this . _loader . open ( this . _dataSource , requestRange ) ;
if ( this . _onSeeked ) {
this . _onSeeked ( ) ;
}
} ;
IOController2 . prototype . updateUrl = function ( url ) {
if ( ! url || typeof url !== "string" || url . length === 0 ) {
throw new _utils _exception _js _ _WEBPACK _IMPORTED _MODULE _9 _ _ . InvalidArgumentException ( "Url must be a non-empty string!" ) ;
}
this . _dataSource . url = url ;
} ;
IOController2 . prototype . _expandBuffer = function ( expectedBytes ) {
var bufferNewSize = this . _stashSize ;
while ( bufferNewSize + 1024 * 1024 * 1 < expectedBytes ) {
bufferNewSize *= 2 ;
}
bufferNewSize += 1024 * 1024 * 1 ;
if ( bufferNewSize === this . _bufferSize ) {
return ;
}
var newBuffer = new ArrayBuffer ( bufferNewSize ) ;
if ( this . _stashUsed > 0 ) {
var stashOldArray = new Uint8Array ( this . _stashBuffer , 0 , this . _stashUsed ) ;
var stashNewArray = new Uint8Array ( newBuffer , 0 , bufferNewSize ) ;
stashNewArray . set ( stashOldArray , 0 ) ;
}
this . _stashBuffer = newBuffer ;
this . _bufferSize = bufferNewSize ;
} ;
IOController2 . prototype . _normalizeSpeed = function ( input ) {
var list = this . _speedNormalizeList ;
var last = list . length - 1 ;
var mid = 0 ;
var lbound = 0 ;
var ubound = last ;
if ( input < list [ 0 ] ) {
return list [ 0 ] ;
}
while ( lbound <= ubound ) {
mid = lbound + Math . floor ( ( ubound - lbound ) / 2 ) ;
if ( mid === last || input >= list [ mid ] && input < list [ mid + 1 ] ) {
return list [ mid ] ;
} else if ( list [ mid ] < input ) {
lbound = mid + 1 ;
} else {
ubound = mid - 1 ;
}
}
} ;
IOController2 . prototype . _adjustStashSize = function ( normalized ) {
var stashSizeKB = 0 ;
if ( this . _config . isLive ) {
stashSizeKB = normalized ;
} else {
if ( normalized < 512 ) {
stashSizeKB = normalized ;
} else if ( normalized >= 512 && normalized <= 1024 ) {
stashSizeKB = Math . floor ( normalized * 1.5 ) ;
} else {
stashSizeKB = normalized * 2 ;
}
}
if ( stashSizeKB > 8192 ) {
stashSizeKB = 8192 ;
}
var bufferSize = stashSizeKB * 1024 + 1024 * 1024 * 1 ;
if ( this . _bufferSize < bufferSize ) {
this . _expandBuffer ( bufferSize ) ;
}
this . _stashSize = stashSizeKB * 1024 ;
} ;
IOController2 . prototype . _dispatchChunks = function ( chunks , byteStart ) {
this . _currentRange . to = byteStart + chunks . byteLength - 1 ;
return this . _onDataArrival ( chunks , byteStart ) ;
} ;
IOController2 . prototype . _onURLRedirect = function ( redirectedURL ) {
this . _redirectedURL = redirectedURL ;
if ( this . _onRedirect ) {
this . _onRedirect ( redirectedURL ) ;
}
} ;
IOController2 . prototype . _onContentLengthKnown = function ( contentLength ) {
if ( contentLength && this . _fullRequestFlag ) {
this . _totalLength = contentLength ;
this . _fullRequestFlag = false ;
}
} ;
IOController2 . prototype . _onLoaderChunkArrival = function ( chunk , byteStart , receivedLength ) {
if ( ! this . _onDataArrival ) {
throw new _utils _exception _js _ _WEBPACK _IMPORTED _MODULE _9 _ _ . IllegalStateException ( "IOController: No existing consumer (onDataArrival) callback!" ) ;
}
if ( this . _paused ) {
return ;
}
if ( this . _isEarlyEofReconnecting ) {
this . _isEarlyEofReconnecting = false ;
if ( this . _onRecoveredEarlyEof ) {
this . _onRecoveredEarlyEof ( ) ;
}
}
this . _speedSampler . addBytes ( chunk . byteLength ) ;
var KBps = this . _speedSampler . lastSecondKBps ;
if ( KBps !== 0 ) {
var normalized = this . _normalizeSpeed ( KBps ) ;
if ( this . _speedNormalized !== normalized ) {
this . _speedNormalized = normalized ;
this . _adjustStashSize ( normalized ) ;
}
}
if ( ! this . _enableStash ) {
if ( this . _stashUsed === 0 ) {
var consumed = this . _dispatchChunks ( chunk , byteStart ) ;
if ( consumed < chunk . byteLength ) {
var remain = chunk . byteLength - consumed ;
if ( remain > this . _bufferSize ) {
this . _expandBuffer ( remain ) ;
}
var stashArray = new Uint8Array ( this . _stashBuffer , 0 , this . _bufferSize ) ;
stashArray . set ( new Uint8Array ( chunk , consumed ) , 0 ) ;
this . _stashUsed += remain ;
this . _stashByteStart = byteStart + consumed ;
}
} else {
if ( this . _stashUsed + chunk . byteLength > this . _bufferSize ) {
this . _expandBuffer ( this . _stashUsed + chunk . byteLength ) ;
}
var stashArray = new Uint8Array ( this . _stashBuffer , 0 , this . _bufferSize ) ;
stashArray . set ( new Uint8Array ( chunk ) , this . _stashUsed ) ;
this . _stashUsed += chunk . byteLength ;
var consumed = this . _dispatchChunks ( this . _stashBuffer . slice ( 0 , this . _stashUsed ) , this . _stashByteStart ) ;
if ( consumed < this . _stashUsed && consumed > 0 ) {
var remainArray = new Uint8Array ( this . _stashBuffer , consumed ) ;
stashArray . set ( remainArray , 0 ) ;
}
this . _stashUsed -= consumed ;
this . _stashByteStart += consumed ;
}
} else {
if ( this . _stashUsed === 0 && this . _stashByteStart === 0 ) {
this . _stashByteStart = byteStart ;
}
if ( this . _stashUsed + chunk . byteLength <= this . _stashSize ) {
var stashArray = new Uint8Array ( this . _stashBuffer , 0 , this . _stashSize ) ;
stashArray . set ( new Uint8Array ( chunk ) , this . _stashUsed ) ;
this . _stashUsed += chunk . byteLength ;
} else {
var stashArray = new Uint8Array ( this . _stashBuffer , 0 , this . _bufferSize ) ;
if ( this . _stashUsed > 0 ) {
var buffer = this . _stashBuffer . slice ( 0 , this . _stashUsed ) ;
var consumed = this . _dispatchChunks ( buffer , this . _stashByteStart ) ;
if ( consumed < buffer . byteLength ) {
if ( consumed > 0 ) {
var remainArray = new Uint8Array ( buffer , consumed ) ;
stashArray . set ( remainArray , 0 ) ;
this . _stashUsed = remainArray . byteLength ;
this . _stashByteStart += consumed ;
}
} else {
this . _stashUsed = 0 ;
this . _stashByteStart += consumed ;
}
if ( this . _stashUsed + chunk . byteLength > this . _bufferSize ) {
this . _expandBuffer ( this . _stashUsed + chunk . byteLength ) ;
stashArray = new Uint8Array ( this . _stashBuffer , 0 , this . _bufferSize ) ;
}
stashArray . set ( new Uint8Array ( chunk ) , this . _stashUsed ) ;
this . _stashUsed += chunk . byteLength ;
} else {
var consumed = this . _dispatchChunks ( chunk , byteStart ) ;
if ( consumed < chunk . byteLength ) {
var remain = chunk . byteLength - consumed ;
if ( remain > this . _bufferSize ) {
this . _expandBuffer ( remain ) ;
stashArray = new Uint8Array ( this . _stashBuffer , 0 , this . _bufferSize ) ;
}
stashArray . set ( new Uint8Array ( chunk , consumed ) , 0 ) ;
this . _stashUsed += remain ;
this . _stashByteStart = byteStart + consumed ;
}
}
}
}
} ;
IOController2 . prototype . _flushStashBuffer = function ( dropUnconsumed ) {
if ( this . _stashUsed > 0 ) {
var buffer = this . _stashBuffer . slice ( 0 , this . _stashUsed ) ;
var consumed = this . _dispatchChunks ( buffer , this . _stashByteStart ) ;
var remain = buffer . byteLength - consumed ;
if ( consumed < buffer . byteLength ) {
if ( dropUnconsumed ) {
_utils _logger _js _ _WEBPACK _IMPORTED _MODULE _0 _ _ . default . w ( this . TAG , remain + " bytes unconsumed data remain when flush buffer, dropped" ) ;
} else {
if ( consumed > 0 ) {
var stashArray = new Uint8Array ( this . _stashBuffer , 0 , this . _bufferSize ) ;
var remainArray = new Uint8Array ( buffer , consumed ) ;
stashArray . set ( remainArray , 0 ) ;
this . _stashUsed = remainArray . byteLength ;
this . _stashByteStart += consumed ;
}
return 0 ;
}
}
this . _stashUsed = 0 ;
this . _stashByteStart = 0 ;
return remain ;
}
return 0 ;
} ;
IOController2 . prototype . _onLoaderComplete = function ( from , to ) {
this . _flushStashBuffer ( true ) ;
if ( this . _onComplete ) {
this . _onComplete ( this . _extraData ) ;
}
} ;
IOController2 . prototype . _onLoaderError = function ( type , data ) {
_utils _logger _js _ _WEBPACK _IMPORTED _MODULE _0 _ _ . default . e ( this . TAG , "Loader error, code = " + data . code + ", msg = " + data . msg ) ;
this . _flushStashBuffer ( false ) ;
if ( this . _isEarlyEofReconnecting ) {
this . _isEarlyEofReconnecting = false ;
type = _loader _js _ _WEBPACK _IMPORTED _MODULE _2 _ _ . LoaderErrors . UNRECOVERABLE _EARLY _EOF ;
}
switch ( type ) {
case _loader _js _ _WEBPACK _IMPORTED _MODULE _2 _ _ . LoaderErrors . EARLY _EOF : {
if ( ! this . _config . isLive ) {
if ( this . _totalLength ) {
var nextFrom = this . _currentRange . to + 1 ;
if ( nextFrom < this . _totalLength ) {
_utils _logger _js _ _WEBPACK _IMPORTED _MODULE _0 _ _ . default . w ( this . TAG , "Connection lost, trying reconnect..." ) ;
this . _isEarlyEofReconnecting = true ;
this . _internalSeek ( nextFrom , false ) ;
}
return ;
}
}
type = _loader _js _ _WEBPACK _IMPORTED _MODULE _2 _ _ . LoaderErrors . UNRECOVERABLE _EARLY _EOF ;
break ;
}
case _loader _js _ _WEBPACK _IMPORTED _MODULE _2 _ _ . LoaderErrors . UNRECOVERABLE _EARLY _EOF :
case _loader _js _ _WEBPACK _IMPORTED _MODULE _2 _ _ . LoaderErrors . CONNECTING _TIMEOUT :
case _loader _js _ _WEBPACK _IMPORTED _MODULE _2 _ _ . LoaderErrors . HTTP _STATUS _CODE _INVALID :
case _loader _js _ _WEBPACK _IMPORTED _MODULE _2 _ _ . LoaderErrors . EXCEPTION :
break ;
}
if ( this . _onError ) {
this . _onError ( type , data ) ;
} else {
throw new _utils _exception _js _ _WEBPACK _IMPORTED _MODULE _9 _ _ . RuntimeException ( "IOException: " + data . msg ) ;
}
} ;
return IOController2 ;
} ( ) ;
_ _webpack _exports _ _2 [ "default" ] = IOController ;
} ,
"./src/io/loader.js" : function ( _ _unused _webpack _module , _ _webpack _exports _ _2 , _ _webpack _require _ _2 ) {
"use strict" ;
_ _webpack _require _ _2 . r ( _ _webpack _exports _ _2 ) ;
_ _webpack _require _ _2 . d ( _ _webpack _exports _ _2 , {
"LoaderStatus" : function ( ) {
return LoaderStatus ;
} ,
"LoaderErrors" : function ( ) {
return LoaderErrors ;
} ,
"BaseLoader" : function ( ) {
return BaseLoader ;
}
} ) ;
var _utils _exception _js _ _WEBPACK _IMPORTED _MODULE _0 _ _ = _ _webpack _require _ _2 ( "./src/utils/exception.js" ) ;
var LoaderStatus = {
kIdle : 0 ,
kConnecting : 1 ,
kBuffering : 2 ,
kError : 3 ,
kComplete : 4
} ;
var LoaderErrors = {
OK : "OK" ,
EXCEPTION : "Exception" ,
HTTP _STATUS _CODE _INVALID : "HttpStatusCodeInvalid" ,
CONNECTING _TIMEOUT : "ConnectingTimeout" ,
EARLY _EOF : "EarlyEof" ,
UNRECOVERABLE _EARLY _EOF : "UnrecoverableEarlyEof"
} ;
var BaseLoader = function ( ) {
function BaseLoader2 ( typeName ) {
this . _type = typeName || "undefined" ;
this . _status = LoaderStatus . kIdle ;
this . _needStash = false ;
this . _onContentLengthKnown = null ;
this . _onURLRedirect = null ;
this . _onDataArrival = null ;
this . _onError = null ;
this . _onComplete = null ;
}
BaseLoader2 . prototype . destroy = function ( ) {
this . _status = LoaderStatus . kIdle ;
this . _onContentLengthKnown = null ;
this . _onURLRedirect = null ;
this . _onDataArrival = null ;
this . _onError = null ;
this . _onComplete = null ;
} ;
BaseLoader2 . prototype . isWorking = function ( ) {
return this . _status === LoaderStatus . kConnecting || this . _status === LoaderStatus . kBuffering ;
} ;
Object . defineProperty ( BaseLoader2 . prototype , "type" , {
get : function ( ) {
return this . _type ;
} ,
enumerable : false ,
configurable : true
} ) ;
Object . defineProperty ( BaseLoader2 . prototype , "status" , {
get : function ( ) {
return this . _status ;
} ,
enumerable : false ,
configurable : true
} ) ;
Object . defineProperty ( BaseLoader2 . prototype , "needStashBuffer" , {
get : function ( ) {
return this . _needStash ;
} ,
enumerable : false ,
configurable : true
} ) ;
Object . defineProperty ( BaseLoader2 . prototype , "onContentLengthKnown" , {
get : function ( ) {
return this . _onContentLengthKnown ;
} ,
set : function ( callback ) {
this . _onContentLengthKnown = callback ;
} ,
enumerable : false ,
configurable : true
} ) ;
Object . defineProperty ( BaseLoader2 . prototype , "onURLRedirect" , {
get : function ( ) {
return this . _onURLRedirect ;
} ,
set : function ( callback ) {
this . _onURLRedirect = callback ;
} ,
enumerable : false ,
configurable : true
} ) ;
Object . defineProperty ( BaseLoader2 . prototype , "onDataArrival" , {
get : function ( ) {
return this . _onDataArrival ;
} ,
set : function ( callback ) {
this . _onDataArrival = callback ;
} ,
enumerable : false ,
configurable : true
} ) ;
Object . defineProperty ( BaseLoader2 . prototype , "onError" , {
get : function ( ) {
return this . _onError ;
} ,
set : function ( callback ) {
this . _onError = callback ;
} ,
enumerable : false ,
configurable : true
} ) ;
Object . defineProperty ( BaseLoader2 . prototype , "onComplete" , {
get : function ( ) {
return this . _onComplete ;
} ,
set : function ( callback ) {
this . _onComplete = callback ;
} ,
enumerable : false ,
configurable : true
} ) ;
BaseLoader2 . prototype . open = function ( dataSource , range ) {
throw new _utils _exception _js _ _WEBPACK _IMPORTED _MODULE _0 _ _ . NotImplementedException ( "Unimplemented abstract function!" ) ;
} ;
BaseLoader2 . prototype . abort = function ( ) {
throw new _utils _exception _js _ _WEBPACK _IMPORTED _MODULE _0 _ _ . NotImplementedException ( "Unimplemented abstract function!" ) ;
} ;
return BaseLoader2 ;
} ( ) ;
} ,
"./src/io/param-seek-handler.js" : function ( _ _unused _webpack _module , _ _webpack _exports _ _2 , _ _webpack _require _ _2 ) {
"use strict" ;
_ _webpack _require _ _2 . r ( _ _webpack _exports _ _2 ) ;
var ParamSeekHandler = function ( ) {
function ParamSeekHandler2 ( paramStart , paramEnd ) {
this . _startName = paramStart ;
this . _endName = paramEnd ;
}
ParamSeekHandler2 . prototype . getConfig = function ( baseUrl , range ) {
var url = baseUrl ;
if ( range . from !== 0 || range . to !== - 1 ) {
var needAnd = true ;
if ( url . indexOf ( "?" ) === - 1 ) {
url += "?" ;
needAnd = false ;
}
if ( needAnd ) {
url += "&" ;
}
url += this . _startName + "=" + range . from . toString ( ) ;
if ( range . to !== - 1 ) {
url += "&" + this . _endName + "=" + range . to . toString ( ) ;
}
}
return {
url ,
headers : { }
} ;
} ;
ParamSeekHandler2 . prototype . removeURLParameters = function ( seekedURL ) {
var baseURL = seekedURL . split ( "?" ) [ 0 ] ;
var params = void 0 ;
var queryIndex = seekedURL . indexOf ( "?" ) ;
if ( queryIndex !== - 1 ) {
params = seekedURL . substring ( queryIndex + 1 ) ;
}
var resultParams = "" ;
if ( params != void 0 && params . length > 0 ) {
var pairs = params . split ( "&" ) ;
for ( var i = 0 ; i < pairs . length ; i ++ ) {
var pair = pairs [ i ] . split ( "=" ) ;
var requireAnd = i > 0 ;
if ( pair [ 0 ] !== this . _startName && pair [ 0 ] !== this . _endName ) {
if ( requireAnd ) {
resultParams += "&" ;
}
resultParams += pairs [ i ] ;
}
}
}
return resultParams . length === 0 ? baseURL : baseURL + "?" + resultParams ;
} ;
return ParamSeekHandler2 ;
} ( ) ;
_ _webpack _exports _ _2 [ "default" ] = ParamSeekHandler ;
} ,
"./src/io/range-seek-handler.js" : function ( _ _unused _webpack _module , _ _webpack _exports _ _2 , _ _webpack _require _ _2 ) {
"use strict" ;
_ _webpack _require _ _2 . r ( _ _webpack _exports _ _2 ) ;
var RangeSeekHandler = function ( ) {
function RangeSeekHandler2 ( zeroStart ) {
this . _zeroStart = zeroStart || false ;
}
RangeSeekHandler2 . prototype . getConfig = function ( url , range ) {
var headers = { } ;
if ( range . from !== 0 || range . to !== - 1 ) {
var param = void 0 ;
if ( range . to !== - 1 ) {
param = "bytes=" + range . from . toString ( ) + "-" + range . to . toString ( ) ;
} else {
param = "bytes=" + range . from . toString ( ) + "-" ;
}
headers [ "Range" ] = param ;
} else if ( this . _zeroStart ) {
headers [ "Range" ] = "bytes=0-" ;
}
return {
url ,
headers
} ;
} ;
RangeSeekHandler2 . prototype . removeURLParameters = function ( seekedURL ) {
return seekedURL ;
} ;
return RangeSeekHandler2 ;
} ( ) ;
_ _webpack _exports _ _2 [ "default" ] = RangeSeekHandler ;
} ,
"./src/io/speed-sampler.js" : function ( _ _unused _webpack _module , _ _webpack _exports _ _2 , _ _webpack _require _ _2 ) {
"use strict" ;
_ _webpack _require _ _2 . r ( _ _webpack _exports _ _2 ) ;
var SpeedSampler = function ( ) {
function SpeedSampler2 ( ) {
this . _firstCheckpoint = 0 ;
this . _lastCheckpoint = 0 ;
this . _intervalBytes = 0 ;
this . _totalBytes = 0 ;
this . _lastSecondBytes = 0 ;
if ( self . performance && self . performance . now ) {
this . _now = self . performance . now . bind ( self . performance ) ;
} else {
this . _now = Date . now ;
}
}
SpeedSampler2 . prototype . reset = function ( ) {
this . _firstCheckpoint = this . _lastCheckpoint = 0 ;
this . _totalBytes = this . _intervalBytes = 0 ;
this . _lastSecondBytes = 0 ;
} ;
SpeedSampler2 . prototype . addBytes = function ( bytes ) {
if ( this . _firstCheckpoint === 0 ) {
this . _firstCheckpoint = this . _now ( ) ;
this . _lastCheckpoint = this . _firstCheckpoint ;
this . _intervalBytes += bytes ;
this . _totalBytes += bytes ;
} else if ( this . _now ( ) - this . _lastCheckpoint < 1e3 ) {
this . _intervalBytes += bytes ;
this . _totalBytes += bytes ;
} else {
this . _lastSecondBytes = this . _intervalBytes ;
this . _intervalBytes = bytes ;
this . _totalBytes += bytes ;
this . _lastCheckpoint = this . _now ( ) ;
}
} ;
Object . defineProperty ( SpeedSampler2 . prototype , "currentKBps" , {
get : function ( ) {
this . addBytes ( 0 ) ;
var durationSeconds = ( this . _now ( ) - this . _lastCheckpoint ) / 1e3 ;
if ( durationSeconds == 0 )
durationSeconds = 1 ;
return this . _intervalBytes / durationSeconds / 1024 ;
} ,
enumerable : false ,
configurable : true
} ) ;
Object . defineProperty ( SpeedSampler2 . prototype , "lastSecondKBps" , {
get : function ( ) {
this . addBytes ( 0 ) ;
if ( this . _lastSecondBytes !== 0 ) {
return this . _lastSecondBytes / 1024 ;
} else {
if ( this . _now ( ) - this . _lastCheckpoint >= 500 ) {
return this . currentKBps ;
} else {
return 0 ;
}
}
} ,
enumerable : false ,
configurable : true
} ) ;
Object . defineProperty ( SpeedSampler2 . prototype , "averageKBps" , {
get : function ( ) {
var durationSeconds = ( this . _now ( ) - this . _firstCheckpoint ) / 1e3 ;
return this . _totalBytes / durationSeconds / 1024 ;
} ,
enumerable : false ,
configurable : true
} ) ;
return SpeedSampler2 ;
} ( ) ;
_ _webpack _exports _ _2 [ "default" ] = SpeedSampler ;
} ,
"./src/io/websocket-loader.js" : function ( _ _unused _webpack _module , _ _webpack _exports _ _2 , _ _webpack _require _ _2 ) {
"use strict" ;
_ _webpack _require _ _2 . r ( _ _webpack _exports _ _2 ) ;
var _loader _js _ _WEBPACK _IMPORTED _MODULE _0 _ _ = _ _webpack _require _ _2 ( "./src/io/loader.js" ) ;
var _utils _exception _js _ _WEBPACK _IMPORTED _MODULE _1 _ _ = _ _webpack _require _ _2 ( "./src/utils/exception.js" ) ;
var _ _extends = function ( ) {
var extendStatics = function ( d , b ) {
extendStatics = Object . setPrototypeOf || { _ _proto _ _ : [ ] } instanceof Array && function ( d2 , b2 ) {
d2 . _ _proto _ _ = b2 ;
} || function ( d2 , b2 ) {
for ( var p in b2 )
if ( Object . prototype . hasOwnProperty . call ( b2 , p ) )
d2 [ p ] = b2 [ p ] ;
} ;
return extendStatics ( d , b ) ;
} ;
return function ( d , b ) {
if ( typeof b !== "function" && b !== null )
throw new TypeError ( "Class extends value " + String ( b ) + " is not a constructor or null" ) ;
extendStatics ( d , b ) ;
function _ _ ( ) {
this . constructor = d ;
}
d . prototype = b === null ? Object . create ( b ) : ( _ _ . prototype = b . prototype , new _ _ ( ) ) ;
} ;
} ( ) ;
var WebSocketLoader = function ( _super ) {
_ _extends ( WebSocketLoader2 , _super ) ;
function WebSocketLoader2 ( ) {
var _this = _super . call ( this , "websocket-loader" ) || this ;
_this . TAG = "WebSocketLoader" ;
_this . _needStash = true ;
_this . _ws = null ;
_this . _requestAbort = false ;
_this . _receivedLength = 0 ;
return _this ;
}
WebSocketLoader2 . isSupported = function ( ) {
try {
return typeof self . WebSocket !== "undefined" ;
} catch ( e ) {
return false ;
}
} ;
WebSocketLoader2 . prototype . destroy = function ( ) {
if ( this . _ws ) {
this . abort ( ) ;
}
_super . prototype . destroy . call ( this ) ;
} ;
WebSocketLoader2 . prototype . open = function ( dataSource ) {
try {
var ws = this . _ws = new self . WebSocket ( dataSource . url ) ;
ws . binaryType = "arraybuffer" ;
ws . onopen = this . _onWebSocketOpen . bind ( this ) ;
ws . onclose = this . _onWebSocketClose . bind ( this ) ;
ws . onmessage = this . _onWebSocketMessage . bind ( this ) ;
ws . onerror = this . _onWebSocketError . bind ( this ) ;
this . _status = _loader _js _ _WEBPACK _IMPORTED _MODULE _0 _ _ . LoaderStatus . kConnecting ;
} catch ( e ) {
this . _status = _loader _js _ _WEBPACK _IMPORTED _MODULE _0 _ _ . LoaderStatus . kError ;
var info = { code : e . code , msg : e . message } ;
if ( this . _onError ) {
this . _onError ( _loader _js _ _WEBPACK _IMPORTED _MODULE _0 _ _ . LoaderErrors . EXCEPTION , info ) ;
} else {
throw new _utils _exception _js _ _WEBPACK _IMPORTED _MODULE _1 _ _ . RuntimeException ( info . msg ) ;
}
}
} ;
WebSocketLoader2 . prototype . abort = function ( ) {
var ws = this . _ws ;
if ( ws && ( ws . readyState === 0 || ws . readyState === 1 ) ) {
this . _requestAbort = true ;
ws . close ( ) ;
}
this . _ws = null ;
this . _status = _loader _js _ _WEBPACK _IMPORTED _MODULE _0 _ _ . LoaderStatus . kComplete ;
} ;
WebSocketLoader2 . prototype . _onWebSocketOpen = function ( e ) {
this . _status = _loader _js _ _WEBPACK _IMPORTED _MODULE _0 _ _ . LoaderStatus . kBuffering ;
} ;
WebSocketLoader2 . prototype . _onWebSocketClose = function ( e ) {
if ( this . _requestAbort === true ) {
this . _requestAbort = false ;
return ;
}
this . _status = _loader _js _ _WEBPACK _IMPORTED _MODULE _0 _ _ . LoaderStatus . kComplete ;
if ( this . _onComplete ) {
this . _onComplete ( 0 , this . _receivedLength - 1 ) ;
}
} ;
WebSocketLoader2 . prototype . _onWebSocketMessage = function ( e ) {
var _this = this ;
if ( e . data instanceof ArrayBuffer ) {
this . _dispatchArrayBuffer ( e . data ) ;
} else if ( e . data instanceof Blob ) {
var reader _1 = new FileReader ( ) ;
reader _1 . onload = function ( ) {
_this . _dispatchArrayBuffer ( reader _1 . result ) ;
} ;
reader _1 . readAsArrayBuffer ( e . data ) ;
} else {
this . _status = _loader _js _ _WEBPACK _IMPORTED _MODULE _0 _ _ . LoaderStatus . kError ;
var info = { code : - 1 , msg : "Unsupported WebSocket message type: " + e . data . constructor . name } ;
if ( this . _onError ) {
this . _onError ( _loader _js _ _WEBPACK _IMPORTED _MODULE _0 _ _ . LoaderErrors . EXCEPTION , info ) ;
} else {
throw new _utils _exception _js _ _WEBPACK _IMPORTED _MODULE _1 _ _ . RuntimeException ( info . msg ) ;
}
}
} ;
WebSocketLoader2 . prototype . _dispatchArrayBuffer = function ( arraybuffer ) {
var chunk = arraybuffer ;
var byteStart = this . _receivedLength ;
this . _receivedLength += chunk . byteLength ;
if ( this . _onDataArrival ) {
this . _onDataArrival ( chunk , byteStart , this . _receivedLength ) ;
}
} ;
WebSocketLoader2 . prototype . _onWebSocketError = function ( e ) {
this . _status = _loader _js _ _WEBPACK _IMPORTED _MODULE _0 _ _ . LoaderStatus . kError ;
var info = {
code : e . code ,
msg : e . message
} ;
if ( this . _onError ) {
this . _onError ( _loader _js _ _WEBPACK _IMPORTED _MODULE _0 _ _ . LoaderErrors . EXCEPTION , info ) ;
} else {
throw new _utils _exception _js _ _WEBPACK _IMPORTED _MODULE _1 _ _ . RuntimeException ( info . msg ) ;
}
} ;
return WebSocketLoader2 ;
} ( _loader _js _ _WEBPACK _IMPORTED _MODULE _0 _ _ . BaseLoader ) ;
_ _webpack _exports _ _2 [ "default" ] = WebSocketLoader ;
} ,
"./src/io/xhr-moz-chunked-loader.js" : function ( _ _unused _webpack _module , _ _webpack _exports _ _2 , _ _webpack _require _ _2 ) {
"use strict" ;
_ _webpack _require _ _2 . r ( _ _webpack _exports _ _2 ) ;
var _utils _logger _js _ _WEBPACK _IMPORTED _MODULE _0 _ _ = _ _webpack _require _ _2 ( "./src/utils/logger.js" ) ;
var _loader _js _ _WEBPACK _IMPORTED _MODULE _1 _ _ = _ _webpack _require _ _2 ( "./src/io/loader.js" ) ;
var _utils _exception _js _ _WEBPACK _IMPORTED _MODULE _2 _ _ = _ _webpack _require _ _2 ( "./src/utils/exception.js" ) ;
var _ _extends = function ( ) {
var extendStatics = function ( d , b ) {
extendStatics = Object . setPrototypeOf || { _ _proto _ _ : [ ] } instanceof Array && function ( d2 , b2 ) {
d2 . _ _proto _ _ = b2 ;
} || function ( d2 , b2 ) {
for ( var p in b2 )
if ( Object . prototype . hasOwnProperty . call ( b2 , p ) )
d2 [ p ] = b2 [ p ] ;
} ;
return extendStatics ( d , b ) ;
} ;
return function ( d , b ) {
if ( typeof b !== "function" && b !== null )
throw new TypeError ( "Class extends value " + String ( b ) + " is not a constructor or null" ) ;
extendStatics ( d , b ) ;
function _ _ ( ) {
this . constructor = d ;
}
d . prototype = b === null ? Object . create ( b ) : ( _ _ . prototype = b . prototype , new _ _ ( ) ) ;
} ;
} ( ) ;
var MozChunkedLoader = function ( _super ) {
_ _extends ( MozChunkedLoader2 , _super ) ;
function MozChunkedLoader2 ( seekHandler , config ) {
var _this = _super . call ( this , "xhr-moz-chunked-loader" ) || this ;
_this . TAG = "MozChunkedLoader" ;
_this . _seekHandler = seekHandler ;
_this . _config = config ;
_this . _needStash = true ;
_this . _xhr = null ;
_this . _requestAbort = false ;
_this . _contentLength = null ;
_this . _receivedLength = 0 ;
return _this ;
}
MozChunkedLoader2 . isSupported = function ( ) {
try {
var xhr = new XMLHttpRequest ( ) ;
xhr . open ( "GET" , "https://example.com" , true ) ;
xhr . responseType = "moz-chunked-arraybuffer" ;
return xhr . responseType === "moz-chunked-arraybuffer" ;
} catch ( e ) {
_utils _logger _js _ _WEBPACK _IMPORTED _MODULE _0 _ _ . default . w ( "MozChunkedLoader" , e . message ) ;
return false ;
}
} ;
MozChunkedLoader2 . prototype . destroy = function ( ) {
if ( this . isWorking ( ) ) {
this . abort ( ) ;
}
if ( this . _xhr ) {
this . _xhr . onreadystatechange = null ;
this . _xhr . onprogress = null ;
this . _xhr . onloadend = null ;
this . _xhr . onerror = null ;
this . _xhr = null ;
}
_super . prototype . destroy . call ( this ) ;
} ;
MozChunkedLoader2 . prototype . open = function ( dataSource , range ) {
this . _dataSource = dataSource ;
this . _range = range ;
var sourceURL = dataSource . url ;
if ( this . _config . reuseRedirectedURL && dataSource . redirectedURL != void 0 ) {
sourceURL = dataSource . redirectedURL ;
}
var seekConfig = this . _seekHandler . getConfig ( sourceURL , range ) ;
this . _requestURL = seekConfig . url ;
var xhr = this . _xhr = new XMLHttpRequest ( ) ;
xhr . open ( "GET" , seekConfig . url , true ) ;
xhr . responseType = "moz-chunked-arraybuffer" ;
xhr . onreadystatechange = this . _onReadyStateChange . bind ( this ) ;
xhr . onprogress = this . _onProgress . bind ( this ) ;
xhr . onloadend = this . _onLoadEnd . bind ( this ) ;
xhr . onerror = this . _onXhrError . bind ( this ) ;
if ( dataSource . withCredentials ) {
xhr . withCredentials = true ;
}
if ( typeof seekConfig . headers === "object" ) {
var headers = seekConfig . headers ;
for ( var key in headers ) {
if ( headers . hasOwnProperty ( key ) ) {
xhr . setRequestHeader ( key , headers [ key ] ) ;
}
}
}
if ( typeof this . _config . headers === "object" ) {
var headers = this . _config . headers ;
for ( var key in headers ) {
if ( headers . hasOwnProperty ( key ) ) {
xhr . setRequestHeader ( key , headers [ key ] ) ;
}
}
}
this . _status = _loader _js _ _WEBPACK _IMPORTED _MODULE _1 _ _ . LoaderStatus . kConnecting ;
xhr . send ( ) ;
} ;
MozChunkedLoader2 . prototype . abort = function ( ) {
this . _requestAbort = true ;
if ( this . _xhr ) {
this . _xhr . abort ( ) ;
}
this . _status = _loader _js _ _WEBPACK _IMPORTED _MODULE _1 _ _ . LoaderStatus . kComplete ;
} ;
MozChunkedLoader2 . prototype . _onReadyStateChange = function ( e ) {
var xhr = e . target ;
if ( xhr . readyState === 2 ) {
if ( xhr . responseURL != void 0 && xhr . responseURL !== this . _requestURL ) {
if ( this . _onURLRedirect ) {
var redirectedURL = this . _seekHandler . removeURLParameters ( xhr . responseURL ) ;
this . _onURLRedirect ( redirectedURL ) ;
}
}
if ( xhr . status !== 0 && ( xhr . status < 200 || xhr . status > 299 ) ) {
this . _status = _loader _js _ _WEBPACK _IMPORTED _MODULE _1 _ _ . LoaderStatus . kError ;
if ( this . _onError ) {
this . _onError ( _loader _js _ _WEBPACK _IMPORTED _MODULE _1 _ _ . LoaderErrors . HTTP _STATUS _CODE _INVALID , { code : xhr . status , msg : xhr . statusText } ) ;
} else {
throw new _utils _exception _js _ _WEBPACK _IMPORTED _MODULE _2 _ _ . RuntimeException ( "MozChunkedLoader: Http code invalid, " + xhr . status + " " + xhr . statusText ) ;
}
} else {
this . _status = _loader _js _ _WEBPACK _IMPORTED _MODULE _1 _ _ . LoaderStatus . kBuffering ;
}
}
} ;
MozChunkedLoader2 . prototype . _onProgress = function ( e ) {
if ( this . _status === _loader _js _ _WEBPACK _IMPORTED _MODULE _1 _ _ . LoaderStatus . kError ) {
return ;
}
if ( this . _contentLength === null ) {
if ( e . total !== null && e . total !== 0 ) {
this . _contentLength = e . total ;
if ( this . _onContentLengthKnown ) {
this . _onContentLengthKnown ( this . _contentLength ) ;
}
}
}
var chunk = e . target . response ;
var byteStart = this . _range . from + this . _receivedLength ;
this . _receivedLength += chunk . byteLength ;
if ( this . _onDataArrival ) {
this . _onDataArrival ( chunk , byteStart , this . _receivedLength ) ;
}
} ;
MozChunkedLoader2 . prototype . _onLoadEnd = function ( e ) {
if ( this . _requestAbort === true ) {
this . _requestAbort = false ;
return ;
} else if ( this . _status === _loader _js _ _WEBPACK _IMPORTED _MODULE _1 _ _ . LoaderStatus . kError ) {
return ;
}
this . _status = _loader _js _ _WEBPACK _IMPORTED _MODULE _1 _ _ . LoaderStatus . kComplete ;
if ( this . _onComplete ) {
this . _onComplete ( this . _range . from , this . _range . from + this . _receivedLength - 1 ) ;
}
} ;
MozChunkedLoader2 . prototype . _onXhrError = function ( e ) {
this . _status = _loader _js _ _WEBPACK _IMPORTED _MODULE _1 _ _ . LoaderStatus . kError ;
var type = 0 ;
var info = null ;
if ( this . _contentLength && e . loaded < this . _contentLength ) {
type = _loader _js _ _WEBPACK _IMPORTED _MODULE _1 _ _ . LoaderErrors . EARLY _EOF ;
info = { code : - 1 , msg : "Moz-Chunked stream meet Early-Eof" } ;
} else {
type = _loader _js _ _WEBPACK _IMPORTED _MODULE _1 _ _ . LoaderErrors . EXCEPTION ;
info = { code : - 1 , msg : e . constructor . name + " " + e . type } ;
}
if ( this . _onError ) {
this . _onError ( type , info ) ;
} else {
throw new _utils _exception _js _ _WEBPACK _IMPORTED _MODULE _2 _ _ . RuntimeException ( info . msg ) ;
}
} ;
return MozChunkedLoader2 ;
} ( _loader _js _ _WEBPACK _IMPORTED _MODULE _1 _ _ . BaseLoader ) ;
_ _webpack _exports _ _2 [ "default" ] = MozChunkedLoader ;
} ,
"./src/io/xhr-range-loader.js" : function ( _ _unused _webpack _module , _ _webpack _exports _ _2 , _ _webpack _require _ _2 ) {
"use strict" ;
_ _webpack _require _ _2 . r ( _ _webpack _exports _ _2 ) ;
var _utils _logger _js _ _WEBPACK _IMPORTED _MODULE _0 _ _ = _ _webpack _require _ _2 ( "./src/utils/logger.js" ) ;
var _speed _sampler _js _ _WEBPACK _IMPORTED _MODULE _1 _ _ = _ _webpack _require _ _2 ( "./src/io/speed-sampler.js" ) ;
var _loader _js _ _WEBPACK _IMPORTED _MODULE _2 _ _ = _ _webpack _require _ _2 ( "./src/io/loader.js" ) ;
var _utils _exception _js _ _WEBPACK _IMPORTED _MODULE _3 _ _ = _ _webpack _require _ _2 ( "./src/utils/exception.js" ) ;
var _ _extends = function ( ) {
var extendStatics = function ( d , b ) {
extendStatics = Object . setPrototypeOf || { _ _proto _ _ : [ ] } instanceof Array && function ( d2 , b2 ) {
d2 . _ _proto _ _ = b2 ;
} || function ( d2 , b2 ) {
for ( var p in b2 )
if ( Object . prototype . hasOwnProperty . call ( b2 , p ) )
d2 [ p ] = b2 [ p ] ;
} ;
return extendStatics ( d , b ) ;
} ;
return function ( d , b ) {
if ( typeof b !== "function" && b !== null )
throw new TypeError ( "Class extends value " + String ( b ) + " is not a constructor or null" ) ;
extendStatics ( d , b ) ;
function _ _ ( ) {
this . constructor = d ;
}
d . prototype = b === null ? Object . create ( b ) : ( _ _ . prototype = b . prototype , new _ _ ( ) ) ;
} ;
} ( ) ;
var RangeLoader = function ( _super ) {
_ _extends ( RangeLoader2 , _super ) ;
function RangeLoader2 ( seekHandler , config ) {
var _this = _super . call ( this , "xhr-range-loader" ) || this ;
_this . TAG = "RangeLoader" ;
_this . _seekHandler = seekHandler ;
_this . _config = config ;
_this . _needStash = false ;
_this . _chunkSizeKBList = [
128 ,
256 ,
384 ,
512 ,
768 ,
1024 ,
1536 ,
2048 ,
3072 ,
4096 ,
5120 ,
6144 ,
7168 ,
8192
] ;
_this . _currentChunkSizeKB = 384 ;
_this . _currentSpeedNormalized = 0 ;
_this . _zeroSpeedChunkCount = 0 ;
_this . _xhr = null ;
_this . _speedSampler = new _speed _sampler _js _ _WEBPACK _IMPORTED _MODULE _1 _ _ . default ( ) ;
_this . _requestAbort = false ;
_this . _waitForTotalLength = false ;
_this . _totalLengthReceived = false ;
_this . _currentRequestURL = null ;
_this . _currentRedirectedURL = null ;
_this . _currentRequestRange = null ;
_this . _totalLength = null ;
_this . _contentLength = null ;
_this . _receivedLength = 0 ;
_this . _lastTimeLoaded = 0 ;
return _this ;
}
RangeLoader2 . isSupported = function ( ) {
try {
var xhr = new XMLHttpRequest ( ) ;
xhr . open ( "GET" , "https://example.com" , true ) ;
xhr . responseType = "arraybuffer" ;
return xhr . responseType === "arraybuffer" ;
} catch ( e ) {
_utils _logger _js _ _WEBPACK _IMPORTED _MODULE _0 _ _ . default . w ( "RangeLoader" , e . message ) ;
return false ;
}
} ;
RangeLoader2 . prototype . destroy = function ( ) {
if ( this . isWorking ( ) ) {
this . abort ( ) ;
}
if ( this . _xhr ) {
this . _xhr . onreadystatechange = null ;
this . _xhr . onprogress = null ;
this . _xhr . onload = null ;
this . _xhr . onerror = null ;
this . _xhr = null ;
}
_super . prototype . destroy . call ( this ) ;
} ;
Object . defineProperty ( RangeLoader2 . prototype , "currentSpeed" , {
get : function ( ) {
return this . _speedSampler . lastSecondKBps ;
} ,
enumerable : false ,
configurable : true
} ) ;
RangeLoader2 . prototype . open = function ( dataSource , range ) {
this . _dataSource = dataSource ;
this . _range = range ;
this . _status = _loader _js _ _WEBPACK _IMPORTED _MODULE _2 _ _ . LoaderStatus . kConnecting ;
var useRefTotalLength = false ;
if ( this . _dataSource . filesize != void 0 && this . _dataSource . filesize !== 0 ) {
useRefTotalLength = true ;
this . _totalLength = this . _dataSource . filesize ;
}
if ( ! this . _totalLengthReceived && ! useRefTotalLength ) {
this . _waitForTotalLength = true ;
this . _internalOpen ( this . _dataSource , { from : 0 , to : - 1 } ) ;
} else {
this . _openSubRange ( ) ;
}
} ;
RangeLoader2 . prototype . _openSubRange = function ( ) {
var chunkSize = this . _currentChunkSizeKB * 1024 ;
var from = this . _range . from + this . _receivedLength ;
var to = from + chunkSize ;
if ( this . _contentLength != null ) {
if ( to - this . _range . from >= this . _contentLength ) {
to = this . _range . from + this . _contentLength - 1 ;
}
}
this . _currentRequestRange = { from , to } ;
this . _internalOpen ( this . _dataSource , this . _currentRequestRange ) ;
} ;
RangeLoader2 . prototype . _internalOpen = function ( dataSource , range ) {
this . _lastTimeLoaded = 0 ;
var sourceURL = dataSource . url ;
if ( this . _config . reuseRedirectedURL ) {
if ( this . _currentRedirectedURL != void 0 ) {
sourceURL = this . _currentRedirectedURL ;
} else if ( dataSource . redirectedURL != void 0 ) {
sourceURL = dataSource . redirectedURL ;
}
}
var seekConfig = this . _seekHandler . getConfig ( sourceURL , range ) ;
this . _currentRequestURL = seekConfig . url ;
var xhr = this . _xhr = new XMLHttpRequest ( ) ;
xhr . open ( "GET" , seekConfig . url , true ) ;
xhr . responseType = "arraybuffer" ;
xhr . onreadystatechange = this . _onReadyStateChange . bind ( this ) ;
xhr . onprogress = this . _onProgress . bind ( this ) ;
xhr . onload = this . _onLoad . bind ( this ) ;
xhr . onerror = this . _onXhrError . bind ( this ) ;
if ( dataSource . withCredentials ) {
xhr . withCredentials = true ;
}
if ( typeof seekConfig . headers === "object" ) {
var headers = seekConfig . headers ;
for ( var key in headers ) {
if ( headers . hasOwnProperty ( key ) ) {
xhr . setRequestHeader ( key , headers [ key ] ) ;
}
}
}
if ( typeof this . _config . headers === "object" ) {
var headers = this . _config . headers ;
for ( var key in headers ) {
if ( headers . hasOwnProperty ( key ) ) {
xhr . setRequestHeader ( key , headers [ key ] ) ;
}
}
}
xhr . send ( ) ;
} ;
RangeLoader2 . prototype . abort = function ( ) {
this . _requestAbort = true ;
this . _internalAbort ( ) ;
this . _status = _loader _js _ _WEBPACK _IMPORTED _MODULE _2 _ _ . LoaderStatus . kComplete ;
} ;
RangeLoader2 . prototype . _internalAbort = function ( ) {
if ( this . _xhr ) {
this . _xhr . onreadystatechange = null ;
this . _xhr . onprogress = null ;
this . _xhr . onload = null ;
this . _xhr . onerror = null ;
this . _xhr . abort ( ) ;
this . _xhr = null ;
}
} ;
RangeLoader2 . prototype . _onReadyStateChange = function ( e ) {
var xhr = e . target ;
if ( xhr . readyState === 2 ) {
if ( xhr . responseURL != void 0 ) {
var redirectedURL = this . _seekHandler . removeURLParameters ( xhr . responseURL ) ;
if ( xhr . responseURL !== this . _currentRequestURL && redirectedURL !== this . _currentRedirectedURL ) {
this . _currentRedirectedURL = redirectedURL ;
if ( this . _onURLRedirect ) {
this . _onURLRedirect ( redirectedURL ) ;
}
}
}
if ( xhr . status >= 200 && xhr . status <= 299 ) {
if ( this . _waitForTotalLength ) {
return ;
}
this . _status = _loader _js _ _WEBPACK _IMPORTED _MODULE _2 _ _ . LoaderStatus . kBuffering ;
} else {
this . _status = _loader _js _ _WEBPACK _IMPORTED _MODULE _2 _ _ . LoaderStatus . kError ;
if ( this . _onError ) {
this . _onError ( _loader _js _ _WEBPACK _IMPORTED _MODULE _2 _ _ . LoaderErrors . HTTP _STATUS _CODE _INVALID , { code : xhr . status , msg : xhr . statusText } ) ;
} else {
throw new _utils _exception _js _ _WEBPACK _IMPORTED _MODULE _3 _ _ . RuntimeException ( "RangeLoader: Http code invalid, " + xhr . status + " " + xhr . statusText ) ;
}
}
}
} ;
RangeLoader2 . prototype . _onProgress = function ( e ) {
if ( this . _status === _loader _js _ _WEBPACK _IMPORTED _MODULE _2 _ _ . LoaderStatus . kError ) {
return ;
}
if ( this . _contentLength === null ) {
var openNextRange = false ;
if ( this . _waitForTotalLength ) {
this . _waitForTotalLength = false ;
this . _totalLengthReceived = true ;
openNextRange = true ;
var total = e . total ;
this . _internalAbort ( ) ;
if ( total != null & total !== 0 ) {
this . _totalLength = total ;
}
}
if ( this . _range . to === - 1 ) {
this . _contentLength = this . _totalLength - this . _range . from ;
} else {
this . _contentLength = this . _range . to - this . _range . from + 1 ;
}
if ( openNextRange ) {
this . _openSubRange ( ) ;
return ;
}
if ( this . _onContentLengthKnown ) {
this . _onContentLengthKnown ( this . _contentLength ) ;
}
}
var delta = e . loaded - this . _lastTimeLoaded ;
this . _lastTimeLoaded = e . loaded ;
this . _speedSampler . addBytes ( delta ) ;
} ;
RangeLoader2 . prototype . _normalizeSpeed = function ( input ) {
var list = this . _chunkSizeKBList ;
var last = list . length - 1 ;
var mid = 0 ;
var lbound = 0 ;
var ubound = last ;
if ( input < list [ 0 ] ) {
return list [ 0 ] ;
}
while ( lbound <= ubound ) {
mid = lbound + Math . floor ( ( ubound - lbound ) / 2 ) ;
if ( mid === last || input >= list [ mid ] && input < list [ mid + 1 ] ) {
return list [ mid ] ;
} else if ( list [ mid ] < input ) {
lbound = mid + 1 ;
} else {
ubound = mid - 1 ;
}
}
} ;
RangeLoader2 . prototype . _onLoad = function ( e ) {
if ( this . _status === _loader _js _ _WEBPACK _IMPORTED _MODULE _2 _ _ . LoaderStatus . kError ) {
return ;
}
if ( this . _waitForTotalLength ) {
this . _waitForTotalLength = false ;
return ;
}
this . _lastTimeLoaded = 0 ;
var KBps = this . _speedSampler . lastSecondKBps ;
if ( KBps === 0 ) {
this . _zeroSpeedChunkCount ++ ;
if ( this . _zeroSpeedChunkCount >= 3 ) {
KBps = this . _speedSampler . currentKBps ;
}
}
if ( KBps !== 0 ) {
var normalized = this . _normalizeSpeed ( KBps ) ;
if ( this . _currentSpeedNormalized !== normalized ) {
this . _currentSpeedNormalized = normalized ;
this . _currentChunkSizeKB = normalized ;
}
}
var chunk = e . target . response ;
var byteStart = this . _range . from + this . _receivedLength ;
this . _receivedLength += chunk . byteLength ;
var reportComplete = false ;
if ( this . _contentLength != null && this . _receivedLength < this . _contentLength ) {
this . _openSubRange ( ) ;
} else {
reportComplete = true ;
}
if ( this . _onDataArrival ) {
this . _onDataArrival ( chunk , byteStart , this . _receivedLength ) ;
}
if ( reportComplete ) {
this . _status = _loader _js _ _WEBPACK _IMPORTED _MODULE _2 _ _ . LoaderStatus . kComplete ;
if ( this . _onComplete ) {
this . _onComplete ( this . _range . from , this . _range . from + this . _receivedLength - 1 ) ;
}
}
} ;
RangeLoader2 . prototype . _onXhrError = function ( e ) {
this . _status = _loader _js _ _WEBPACK _IMPORTED _MODULE _2 _ _ . LoaderStatus . kError ;
var type = 0 ;
var info = null ;
if ( this . _contentLength && this . _receivedLength > 0 && this . _receivedLength < this . _contentLength ) {
type = _loader _js _ _WEBPACK _IMPORTED _MODULE _2 _ _ . LoaderErrors . EARLY _EOF ;
info = { code : - 1 , msg : "RangeLoader meet Early-Eof" } ;
} else {
type = _loader _js _ _WEBPACK _IMPORTED _MODULE _2 _ _ . LoaderErrors . EXCEPTION ;
info = { code : - 1 , msg : e . constructor . name + " " + e . type } ;
}
if ( this . _onError ) {
this . _onError ( type , info ) ;
} else {
throw new _utils _exception _js _ _WEBPACK _IMPORTED _MODULE _3 _ _ . RuntimeException ( info . msg ) ;
}
} ;
return RangeLoader2 ;
} ( _loader _js _ _WEBPACK _IMPORTED _MODULE _2 _ _ . BaseLoader ) ;
_ _webpack _exports _ _2 [ "default" ] = RangeLoader ;
} ,
"./src/player/flv-player.js" : function ( _ _unused _webpack _module , _ _webpack _exports _ _2 , _ _webpack _require _ _2 ) {
"use strict" ;
_ _webpack _require _ _2 . r ( _ _webpack _exports _ _2 ) ;
var events _ _WEBPACK _IMPORTED _MODULE _0 _ _ = _ _webpack _require _ _2 ( "./node_modules/events/events.js" ) ;
var events _ _WEBPACK _IMPORTED _MODULE _0 _ _ _default = _ _webpack _require _ _2 . n ( events _ _WEBPACK _IMPORTED _MODULE _0 _ _ ) ;
var _utils _logger _js _ _WEBPACK _IMPORTED _MODULE _1 _ _ = _ _webpack _require _ _2 ( "./src/utils/logger.js" ) ;
var _utils _browser _js _ _WEBPACK _IMPORTED _MODULE _2 _ _ = _ _webpack _require _ _2 ( "./src/utils/browser.js" ) ;
var _player _events _js _ _WEBPACK _IMPORTED _MODULE _3 _ _ = _ _webpack _require _ _2 ( "./src/player/player-events.js" ) ;
var _core _transmuxer _js _ _WEBPACK _IMPORTED _MODULE _4 _ _ = _ _webpack _require _ _2 ( "./src/core/transmuxer.js" ) ;
var _core _transmuxing _events _js _ _WEBPACK _IMPORTED _MODULE _5 _ _ = _ _webpack _require _ _2 ( "./src/core/transmuxing-events.js" ) ;
var _core _mse _controller _js _ _WEBPACK _IMPORTED _MODULE _6 _ _ = _ _webpack _require _ _2 ( "./src/core/mse-controller.js" ) ;
var _core _mse _events _js _ _WEBPACK _IMPORTED _MODULE _7 _ _ = _ _webpack _require _ _2 ( "./src/core/mse-events.js" ) ;
var _player _errors _js _ _WEBPACK _IMPORTED _MODULE _8 _ _ = _ _webpack _require _ _2 ( "./src/player/player-errors.js" ) ;
var _config _js _ _WEBPACK _IMPORTED _MODULE _9 _ _ = _ _webpack _require _ _2 ( "./src/config.js" ) ;
var _utils _exception _js _ _WEBPACK _IMPORTED _MODULE _10 _ _ = _ _webpack _require _ _2 ( "./src/utils/exception.js" ) ;
var FlvPlayer = function ( ) {
function FlvPlayer2 ( mediaDataSource , config ) {
this . TAG = "FlvPlayer" ;
this . _type = "FlvPlayer" ;
this . _emitter = new ( events _ _WEBPACK _IMPORTED _MODULE _0 _ _ _default ( ) ) ( ) ;
this . _config = ( 0 , _config _js _ _WEBPACK _IMPORTED _MODULE _9 _ _ . createDefaultConfig ) ( ) ;
if ( typeof config === "object" ) {
Object . assign ( this . _config , config ) ;
}
if ( mediaDataSource . type . toLowerCase ( ) !== "flv" ) {
throw new _utils _exception _js _ _WEBPACK _IMPORTED _MODULE _10 _ _ . InvalidArgumentException ( "FlvPlayer requires an flv MediaDataSource input!" ) ;
}
if ( mediaDataSource . isLive === true ) {
this . _config . isLive = true ;
}
this . e = {
onvLoadedMetadata : this . _onvLoadedMetadata . bind ( this ) ,
onvSeeking : this . _onvSeeking . bind ( this ) ,
onvCanPlay : this . _onvCanPlay . bind ( this ) ,
onvStalled : this . _onvStalled . bind ( this ) ,
onvProgress : this . _onvProgress . bind ( this )
} ;
if ( self . performance && self . performance . now ) {
this . _now = self . performance . now . bind ( self . performance ) ;
} else {
this . _now = Date . now ;
}
this . _pendingSeekTime = null ;
this . _requestSetTime = false ;
this . _seekpointRecord = null ;
this . _progressChecker = null ;
this . _mediaDataSource = mediaDataSource ;
this . _mediaElement = null ;
this . _msectl = null ;
this . _transmuxer = null ;
this . _mseSourceOpened = false ;
this . _hasPendingLoad = false ;
this . _receivedCanPlay = false ;
this . _mediaInfo = null ;
this . _statisticsInfo = null ;
var chromeNeedIDRFix = _utils _browser _js _ _WEBPACK _IMPORTED _MODULE _2 _ _ . default . chrome && ( _utils _browser _js _ _WEBPACK _IMPORTED _MODULE _2 _ _ . default . version . major < 50 || _utils _browser _js _ _WEBPACK _IMPORTED _MODULE _2 _ _ . default . version . major === 50 && _utils _browser _js _ _WEBPACK _IMPORTED _MODULE _2 _ _ . default . version . build < 2661 ) ;
this . _alwaysSeekKeyframe = chromeNeedIDRFix || _utils _browser _js _ _WEBPACK _IMPORTED _MODULE _2 _ _ . default . msedge || _utils _browser _js _ _WEBPACK _IMPORTED _MODULE _2 _ _ . default . msie ? true : false ;
if ( this . _alwaysSeekKeyframe ) {
this . _config . accurateSeek = false ;
}
}
FlvPlayer2 . prototype . destroy = function ( ) {
if ( this . _progressChecker != null ) {
window . clearInterval ( this . _progressChecker ) ;
this . _progressChecker = null ;
}
if ( this . _transmuxer ) {
this . unload ( ) ;
}
if ( this . _mediaElement ) {
this . detachMediaElement ( ) ;
}
this . e = null ;
this . _mediaDataSource = null ;
this . _emitter . removeAllListeners ( ) ;
this . _emitter = null ;
} ;
FlvPlayer2 . prototype . on = function ( event , listener ) {
var _this = this ;
if ( event === _player _events _js _ _WEBPACK _IMPORTED _MODULE _3 _ _ . default . MEDIA _INFO ) {
if ( this . _mediaInfo != null ) {
Promise . resolve ( ) . then ( function ( ) {
_this . _emitter . emit ( _player _events _js _ _WEBPACK _IMPORTED _MODULE _3 _ _ . default . MEDIA _INFO , _this . mediaInfo ) ;
} ) ;
}
} else if ( event === _player _events _js _ _WEBPACK _IMPORTED _MODULE _3 _ _ . default . STATISTICS _INFO ) {
if ( this . _statisticsInfo != null ) {
Promise . resolve ( ) . then ( function ( ) {
_this . _emitter . emit ( _player _events _js _ _WEBPACK _IMPORTED _MODULE _3 _ _ . default . STATISTICS _INFO , _this . statisticsInfo ) ;
} ) ;
}
}
this . _emitter . addListener ( event , listener ) ;
} ;
FlvPlayer2 . prototype . off = function ( event , listener ) {
this . _emitter . removeListener ( event , listener ) ;
} ;
FlvPlayer2 . prototype . attachMediaElement = function ( mediaElement ) {
var _this = this ;
this . _mediaElement = mediaElement ;
mediaElement . addEventListener ( "loadedmetadata" , this . e . onvLoadedMetadata ) ;
mediaElement . addEventListener ( "seeking" , this . e . onvSeeking ) ;
mediaElement . addEventListener ( "canplay" , this . e . onvCanPlay ) ;
mediaElement . addEventListener ( "stalled" , this . e . onvStalled ) ;
mediaElement . addEventListener ( "progress" , this . e . onvProgress ) ;
this . _msectl = new _core _mse _controller _js _ _WEBPACK _IMPORTED _MODULE _6 _ _ . default ( this . _config ) ;
this . _msectl . on ( _core _mse _events _js _ _WEBPACK _IMPORTED _MODULE _7 _ _ . default . UPDATE _END , this . _onmseUpdateEnd . bind ( this ) ) ;
this . _msectl . on ( _core _mse _events _js _ _WEBPACK _IMPORTED _MODULE _7 _ _ . default . BUFFER _FULL , this . _onmseBufferFull . bind ( this ) ) ;
this . _msectl . on ( _core _mse _events _js _ _WEBPACK _IMPORTED _MODULE _7 _ _ . default . SOURCE _OPEN , function ( ) {
_this . _mseSourceOpened = true ;
if ( _this . _hasPendingLoad ) {
_this . _hasPendingLoad = false ;
_this . load ( ) ;
}
} ) ;
this . _msectl . on ( _core _mse _events _js _ _WEBPACK _IMPORTED _MODULE _7 _ _ . default . ERROR , function ( info ) {
_this . _emitter . emit ( _player _events _js _ _WEBPACK _IMPORTED _MODULE _3 _ _ . default . ERROR , _player _errors _js _ _WEBPACK _IMPORTED _MODULE _8 _ _ . ErrorTypes . MEDIA _ERROR , _player _errors _js _ _WEBPACK _IMPORTED _MODULE _8 _ _ . ErrorDetails . MEDIA _MSE _ERROR , info ) ;
} ) ;
this . _msectl . attachMediaElement ( mediaElement ) ;
if ( this . _pendingSeekTime != null ) {
try {
mediaElement . currentTime = this . _pendingSeekTime ;
this . _pendingSeekTime = null ;
} catch ( e ) {
}
}
} ;
FlvPlayer2 . prototype . detachMediaElement = function ( ) {
if ( this . _mediaElement ) {
this . _msectl . detachMediaElement ( ) ;
this . _mediaElement . removeEventListener ( "loadedmetadata" , this . e . onvLoadedMetadata ) ;
this . _mediaElement . removeEventListener ( "seeking" , this . e . onvSeeking ) ;
this . _mediaElement . removeEventListener ( "canplay" , this . e . onvCanPlay ) ;
this . _mediaElement . removeEventListener ( "stalled" , this . e . onvStalled ) ;
this . _mediaElement . removeEventListener ( "progress" , this . e . onvProgress ) ;
this . _mediaElement = null ;
}
if ( this . _msectl ) {
this . _msectl . destroy ( ) ;
this . _msectl = null ;
}
} ;
FlvPlayer2 . prototype . load = function ( ) {
var _this = this ;
if ( ! this . _mediaElement ) {
throw new _utils _exception _js _ _WEBPACK _IMPORTED _MODULE _10 _ _ . IllegalStateException ( "HTMLMediaElement must be attached before load()!" ) ;
}
if ( this . _transmuxer ) {
throw new _utils _exception _js _ _WEBPACK _IMPORTED _MODULE _10 _ _ . IllegalStateException ( "FlvPlayer.load() has been called, please call unload() first!" ) ;
}
if ( this . _hasPendingLoad ) {
return ;
}
if ( this . _config . deferLoadAfterSourceOpen && this . _mseSourceOpened === false ) {
this . _hasPendingLoad = true ;
return ;
}
if ( this . _mediaElement . readyState > 0 ) {
this . _requestSetTime = true ;
this . _mediaElement . currentTime = 0 ;
}
this . _transmuxer = new _core _transmuxer _js _ _WEBPACK _IMPORTED _MODULE _4 _ _ . default ( this . _mediaDataSource , this . _config ) ;
this . _transmuxer . on ( _core _transmuxing _events _js _ _WEBPACK _IMPORTED _MODULE _5 _ _ . default . INIT _SEGMENT , function ( type , is ) {
_this . _msectl . appendInitSegment ( is ) ;
} ) ;
this . _transmuxer . on ( _core _transmuxing _events _js _ _WEBPACK _IMPORTED _MODULE _5 _ _ . default . MEDIA _SEGMENT , function ( type , ms ) {
_this . _msectl . appendMediaSegment ( ms ) ;
if ( _this . _config . lazyLoad && ! _this . _config . isLive ) {
var currentTime = _this . _mediaElement . currentTime ;
if ( ms . info . endDts >= ( currentTime + _this . _config . lazyLoadMaxDuration ) * 1e3 ) {
if ( _this . _progressChecker == null ) {
_utils _logger _js _ _WEBPACK _IMPORTED _MODULE _1 _ _ . default . v ( _this . TAG , "Maximum buffering duration exceeded, suspend transmuxing task" ) ;
_this . _suspendTransmuxer ( ) ;
}
}
}
} ) ;
this . _transmuxer . on ( _core _transmuxing _events _js _ _WEBPACK _IMPORTED _MODULE _5 _ _ . default . LOADING _COMPLETE , function ( ) {
_this . _msectl . endOfStream ( ) ;
_this . _emitter . emit ( _player _events _js _ _WEBPACK _IMPORTED _MODULE _3 _ _ . default . LOADING _COMPLETE ) ;
} ) ;
this . _transmuxer . on ( _core _transmuxing _events _js _ _WEBPACK _IMPORTED _MODULE _5 _ _ . default . RECOVERED _EARLY _EOF , function ( ) {
_this . _emitter . emit ( _player _events _js _ _WEBPACK _IMPORTED _MODULE _3 _ _ . default . RECOVERED _EARLY _EOF ) ;
} ) ;
this . _transmuxer . on ( _core _transmuxing _events _js _ _WEBPACK _IMPORTED _MODULE _5 _ _ . default . IO _ERROR , function ( detail , info ) {
_this . _emitter . emit ( _player _events _js _ _WEBPACK _IMPORTED _MODULE _3 _ _ . default . ERROR , _player _errors _js _ _WEBPACK _IMPORTED _MODULE _8 _ _ . ErrorTypes . NETWORK _ERROR , detail , info ) ;
} ) ;
this . _transmuxer . on ( _core _transmuxing _events _js _ _WEBPACK _IMPORTED _MODULE _5 _ _ . default . DEMUX _ERROR , function ( detail , info ) {
_this . _emitter . emit ( _player _events _js _ _WEBPACK _IMPORTED _MODULE _3 _ _ . default . ERROR , _player _errors _js _ _WEBPACK _IMPORTED _MODULE _8 _ _ . ErrorTypes . MEDIA _ERROR , detail , { code : - 1 , msg : info } ) ;
} ) ;
this . _transmuxer . on ( _core _transmuxing _events _js _ _WEBPACK _IMPORTED _MODULE _5 _ _ . default . MEDIA _INFO , function ( mediaInfo ) {
_this . _mediaInfo = mediaInfo ;
_this . _emitter . emit ( _player _events _js _ _WEBPACK _IMPORTED _MODULE _3 _ _ . default . MEDIA _INFO , Object . assign ( { } , mediaInfo ) ) ;
} ) ;
this . _transmuxer . on ( _core _transmuxing _events _js _ _WEBPACK _IMPORTED _MODULE _5 _ _ . default . METADATA _ARRIVED , function ( metadata ) {
_this . _emitter . emit ( _player _events _js _ _WEBPACK _IMPORTED _MODULE _3 _ _ . default . METADATA _ARRIVED , metadata ) ;
} ) ;
this . _transmuxer . on ( _core _transmuxing _events _js _ _WEBPACK _IMPORTED _MODULE _5 _ _ . default . SCRIPTDATA _ARRIVED , function ( data ) {
_this . _emitter . emit ( _player _events _js _ _WEBPACK _IMPORTED _MODULE _3 _ _ . default . SCRIPTDATA _ARRIVED , data ) ;
} ) ;
this . _transmuxer . on ( _core _transmuxing _events _js _ _WEBPACK _IMPORTED _MODULE _5 _ _ . default . STATISTICS _INFO , function ( statInfo ) {
_this . _statisticsInfo = _this . _fillStatisticsInfo ( statInfo ) ;
_this . _emitter . emit ( _player _events _js _ _WEBPACK _IMPORTED _MODULE _3 _ _ . default . STATISTICS _INFO , Object . assign ( { } , _this . _statisticsInfo ) ) ;
} ) ;
this . _transmuxer . on ( _core _transmuxing _events _js _ _WEBPACK _IMPORTED _MODULE _5 _ _ . default . RECOMMEND _SEEKPOINT , function ( milliseconds ) {
if ( _this . _mediaElement && ! _this . _config . accurateSeek ) {
_this . _requestSetTime = true ;
_this . _mediaElement . currentTime = milliseconds / 1e3 ;
}
} ) ;
this . _transmuxer . open ( ) ;
} ;
FlvPlayer2 . prototype . unload = function ( ) {
if ( this . _mediaElement ) {
this . _mediaElement . pause ( ) ;
}
if ( this . _msectl ) {
this . _msectl . seek ( 0 ) ;
}
if ( this . _transmuxer ) {
this . _transmuxer . close ( ) ;
this . _transmuxer . destroy ( ) ;
this . _transmuxer = null ;
}
} ;
FlvPlayer2 . prototype . play = function ( ) {
return this . _mediaElement . play ( ) ;
} ;
FlvPlayer2 . prototype . pause = function ( ) {
this . _mediaElement . pause ( ) ;
} ;
Object . defineProperty ( FlvPlayer2 . prototype , "type" , {
get : function ( ) {
return this . _type ;
} ,
enumerable : false ,
configurable : true
} ) ;
Object . defineProperty ( FlvPlayer2 . prototype , "buffered" , {
get : function ( ) {
return this . _mediaElement . buffered ;
} ,
enumerable : false ,
configurable : true
} ) ;
Object . defineProperty ( FlvPlayer2 . prototype , "duration" , {
get : function ( ) {
return this . _mediaElement . duration ;
} ,
enumerable : false ,
configurable : true
} ) ;
Object . defineProperty ( FlvPlayer2 . prototype , "volume" , {
get : function ( ) {
return this . _mediaElement . volume ;
} ,
set : function ( value ) {
this . _mediaElement . volume = value ;
} ,
enumerable : false ,
configurable : true
} ) ;
Object . defineProperty ( FlvPlayer2 . prototype , "muted" , {
get : function ( ) {
return this . _mediaElement . muted ;
} ,
set : function ( muted ) {
this . _mediaElement . muted = muted ;
} ,
enumerable : false ,
configurable : true
} ) ;
Object . defineProperty ( FlvPlayer2 . prototype , "currentTime" , {
get : function ( ) {
if ( this . _mediaElement ) {
return this . _mediaElement . currentTime ;
}
return 0 ;
} ,
set : function ( seconds ) {
if ( this . _mediaElement ) {
this . _internalSeek ( seconds ) ;
} else {
this . _pendingSeekTime = seconds ;
}
} ,
enumerable : false ,
configurable : true
} ) ;
Object . defineProperty ( FlvPlayer2 . prototype , "mediaInfo" , {
get : function ( ) {
return Object . assign ( { } , this . _mediaInfo ) ;
} ,
enumerable : false ,
configurable : true
} ) ;
Object . defineProperty ( FlvPlayer2 . prototype , "statisticsInfo" , {
get : function ( ) {
if ( this . _statisticsInfo == null ) {
this . _statisticsInfo = { } ;
}
this . _statisticsInfo = this . _fillStatisticsInfo ( this . _statisticsInfo ) ;
return Object . assign ( { } , this . _statisticsInfo ) ;
} ,
enumerable : false ,
configurable : true
} ) ;
FlvPlayer2 . prototype . _fillStatisticsInfo = function ( statInfo ) {
statInfo . playerType = this . _type ;
if ( ! ( this . _mediaElement instanceof HTMLVideoElement ) ) {
return statInfo ;
}
var hasQualityInfo = true ;
var decoded = 0 ;
var dropped = 0 ;
if ( this . _mediaElement . getVideoPlaybackQuality ) {
var quality = this . _mediaElement . getVideoPlaybackQuality ( ) ;
decoded = quality . totalVideoFrames ;
dropped = quality . droppedVideoFrames ;
} else if ( this . _mediaElement . webkitDecodedFrameCount != void 0 ) {
decoded = this . _mediaElement . webkitDecodedFrameCount ;
dropped = this . _mediaElement . webkitDroppedFrameCount ;
} else {
hasQualityInfo = false ;
}
if ( hasQualityInfo ) {
statInfo . decodedFrames = decoded ;
statInfo . droppedFrames = dropped ;
}
return statInfo ;
} ;
FlvPlayer2 . prototype . _onmseUpdateEnd = function ( ) {
if ( ! this . _config . lazyLoad || this . _config . isLive ) {
return ;
}
var buffered = this . _mediaElement . buffered ;
var currentTime = this . _mediaElement . currentTime ;
var currentRangeStart = 0 ;
var currentRangeEnd = 0 ;
for ( var i = 0 ; i < buffered . length ; i ++ ) {
var start = buffered . start ( i ) ;
var end = buffered . end ( i ) ;
if ( start <= currentTime && currentTime < end ) {
currentRangeStart = start ;
currentRangeEnd = end ;
break ;
}
}
if ( currentRangeEnd >= currentTime + this . _config . lazyLoadMaxDuration && this . _progressChecker == null ) {
_utils _logger _js _ _WEBPACK _IMPORTED _MODULE _1 _ _ . default . v ( this . TAG , "Maximum buffering duration exceeded, suspend transmuxing task" ) ;
this . _suspendTransmuxer ( ) ;
}
} ;
FlvPlayer2 . prototype . _onmseBufferFull = function ( ) {
_utils _logger _js _ _WEBPACK _IMPORTED _MODULE _1 _ _ . default . v ( this . TAG , "MSE SourceBuffer is full, suspend transmuxing task" ) ;
if ( this . _progressChecker == null ) {
this . _suspendTransmuxer ( ) ;
}
} ;
FlvPlayer2 . prototype . _suspendTransmuxer = function ( ) {
if ( this . _transmuxer ) {
this . _transmuxer . pause ( ) ;
if ( this . _progressChecker == null ) {
this . _progressChecker = window . setInterval ( this . _checkProgressAndResume . bind ( this ) , 1e3 ) ;
}
}
} ;
FlvPlayer2 . prototype . _checkProgressAndResume = function ( ) {
var currentTime = this . _mediaElement . currentTime ;
var buffered = this . _mediaElement . buffered ;
var needResume = false ;
for ( var i = 0 ; i < buffered . length ; i ++ ) {
var from = buffered . start ( i ) ;
var to = buffered . end ( i ) ;
if ( currentTime >= from && currentTime < to ) {
if ( currentTime >= to - this . _config . lazyLoadRecoverDuration ) {
needResume = true ;
}
break ;
}
}
if ( needResume ) {
window . clearInterval ( this . _progressChecker ) ;
this . _progressChecker = null ;
if ( needResume ) {
_utils _logger _js _ _WEBPACK _IMPORTED _MODULE _1 _ _ . default . v ( this . TAG , "Continue loading from paused position" ) ;
this . _transmuxer . resume ( ) ;
}
}
} ;
FlvPlayer2 . prototype . _isTimepointBuffered = function ( seconds ) {
var buffered = this . _mediaElement . buffered ;
for ( var i = 0 ; i < buffered . length ; i ++ ) {
var from = buffered . start ( i ) ;
var to = buffered . end ( i ) ;
if ( seconds >= from && seconds < to ) {
return true ;
}
}
return false ;
} ;
FlvPlayer2 . prototype . _internalSeek = function ( seconds ) {
var directSeek = this . _isTimepointBuffered ( seconds ) ;
var directSeekBegin = false ;
var directSeekBeginTime = 0 ;
if ( seconds < 1 && this . _mediaElement . buffered . length > 0 ) {
var videoBeginTime = this . _mediaElement . buffered . start ( 0 ) ;
if ( videoBeginTime < 1 && seconds < videoBeginTime || _utils _browser _js _ _WEBPACK _IMPORTED _MODULE _2 _ _ . default . safari ) {
directSeekBegin = true ;
directSeekBeginTime = _utils _browser _js _ _WEBPACK _IMPORTED _MODULE _2 _ _ . default . safari ? 0.1 : videoBeginTime ;
}
}
if ( directSeekBegin ) {
this . _requestSetTime = true ;
this . _mediaElement . currentTime = directSeekBeginTime ;
} else if ( directSeek ) {
if ( ! this . _alwaysSeekKeyframe ) {
this . _requestSetTime = true ;
this . _mediaElement . currentTime = seconds ;
} else {
var idr = this . _msectl . getNearestKeyframe ( Math . floor ( seconds * 1e3 ) ) ;
this . _requestSetTime = true ;
if ( idr != null ) {
this . _mediaElement . currentTime = idr . dts / 1e3 ;
} else {
this . _mediaElement . currentTime = seconds ;
}
}
if ( this . _progressChecker != null ) {
this . _checkProgressAndResume ( ) ;
}
} else {
if ( this . _progressChecker != null ) {
window . clearInterval ( this . _progressChecker ) ;
this . _progressChecker = null ;
}
this . _msectl . seek ( seconds ) ;
this . _transmuxer . seek ( Math . floor ( seconds * 1e3 ) ) ;
if ( this . _config . accurateSeek ) {
this . _requestSetTime = true ;
this . _mediaElement . currentTime = seconds ;
}
}
} ;
FlvPlayer2 . prototype . _checkAndApplyUnbufferedSeekpoint = function ( ) {
if ( this . _seekpointRecord ) {
if ( this . _seekpointRecord . recordTime <= this . _now ( ) - 100 ) {
var target = this . _mediaElement . currentTime ;
this . _seekpointRecord = null ;
if ( ! this . _isTimepointBuffered ( target ) ) {
if ( this . _progressChecker != null ) {
window . clearTimeout ( this . _progressChecker ) ;
this . _progressChecker = null ;
}
this . _msectl . seek ( target ) ;
this . _transmuxer . seek ( Math . floor ( target * 1e3 ) ) ;
if ( this . _config . accurateSeek ) {
this . _requestSetTime = true ;
this . _mediaElement . currentTime = target ;
}
}
} else {
window . setTimeout ( this . _checkAndApplyUnbufferedSeekpoint . bind ( this ) , 50 ) ;
}
}
} ;
FlvPlayer2 . prototype . _checkAndResumeStuckPlayback = function ( stalled ) {
var media = this . _mediaElement ;
if ( stalled || ! this . _receivedCanPlay || media . readyState < 2 ) {
var buffered = media . buffered ;
if ( buffered . length > 0 && media . currentTime < buffered . start ( 0 ) ) {
_utils _logger _js _ _WEBPACK _IMPORTED _MODULE _1 _ _ . default . w ( this . TAG , "Playback seems stuck at " + media . currentTime + ", seek to " + buffered . start ( 0 ) ) ;
this . _requestSetTime = true ;
this . _mediaElement . currentTime = buffered . start ( 0 ) ;
this . _mediaElement . removeEventListener ( "progress" , this . e . onvProgress ) ;
}
} else {
this . _mediaElement . removeEventListener ( "progress" , this . e . onvProgress ) ;
}
} ;
FlvPlayer2 . prototype . _onvLoadedMetadata = function ( e ) {
if ( this . _pendingSeekTime != null ) {
this . _mediaElement . currentTime = this . _pendingSeekTime ;
this . _pendingSeekTime = null ;
}
} ;
FlvPlayer2 . prototype . _onvSeeking = function ( e ) {
var target = this . _mediaElement . currentTime ;
var buffered = this . _mediaElement . buffered ;
if ( this . _requestSetTime ) {
this . _requestSetTime = false ;
return ;
}
if ( target < 1 && buffered . length > 0 ) {
var videoBeginTime = buffered . start ( 0 ) ;
if ( videoBeginTime < 1 && target < videoBeginTime || _utils _browser _js _ _WEBPACK _IMPORTED _MODULE _2 _ _ . default . safari ) {
this . _requestSetTime = true ;
this . _mediaElement . currentTime = _utils _browser _js _ _WEBPACK _IMPORTED _MODULE _2 _ _ . default . safari ? 0.1 : videoBeginTime ;
return ;
}
}
if ( this . _isTimepointBuffered ( target ) ) {
if ( this . _alwaysSeekKeyframe ) {
var idr = this . _msectl . getNearestKeyframe ( Math . floor ( target * 1e3 ) ) ;
if ( idr != null ) {
this . _requestSetTime = true ;
this . _mediaElement . currentTime = idr . dts / 1e3 ;
}
}
if ( this . _progressChecker != null ) {
this . _checkProgressAndResume ( ) ;
}
return ;
}
this . _seekpointRecord = {
seekPoint : target ,
recordTime : this . _now ( )
} ;
window . setTimeout ( this . _checkAndApplyUnbufferedSeekpoint . bind ( this ) , 50 ) ;
} ;
FlvPlayer2 . prototype . _onvCanPlay = function ( e ) {
this . _receivedCanPlay = true ;
this . _mediaElement . removeEventListener ( "canplay" , this . e . onvCanPlay ) ;
} ;
FlvPlayer2 . prototype . _onvStalled = function ( e ) {
this . _checkAndResumeStuckPlayback ( true ) ;
} ;
FlvPlayer2 . prototype . _onvProgress = function ( e ) {
this . _checkAndResumeStuckPlayback ( ) ;
} ;
return FlvPlayer2 ;
} ( ) ;
_ _webpack _exports _ _2 [ "default" ] = FlvPlayer ;
} ,
"./src/player/native-player.js" : function ( _ _unused _webpack _module , _ _webpack _exports _ _2 , _ _webpack _require _ _2 ) {
"use strict" ;
_ _webpack _require _ _2 . r ( _ _webpack _exports _ _2 ) ;
var events _ _WEBPACK _IMPORTED _MODULE _0 _ _ = _ _webpack _require _ _2 ( "./node_modules/events/events.js" ) ;
var events _ _WEBPACK _IMPORTED _MODULE _0 _ _ _default = _ _webpack _require _ _2 . n ( events _ _WEBPACK _IMPORTED _MODULE _0 _ _ ) ;
var _player _events _js _ _WEBPACK _IMPORTED _MODULE _1 _ _ = _ _webpack _require _ _2 ( "./src/player/player-events.js" ) ;
var _config _js _ _WEBPACK _IMPORTED _MODULE _2 _ _ = _ _webpack _require _ _2 ( "./src/config.js" ) ;
var _utils _exception _js _ _WEBPACK _IMPORTED _MODULE _3 _ _ = _ _webpack _require _ _2 ( "./src/utils/exception.js" ) ;
var NativePlayer = function ( ) {
function NativePlayer2 ( mediaDataSource , config ) {
this . TAG = "NativePlayer" ;
this . _type = "NativePlayer" ;
this . _emitter = new ( events _ _WEBPACK _IMPORTED _MODULE _0 _ _ _default ( ) ) ( ) ;
this . _config = ( 0 , _config _js _ _WEBPACK _IMPORTED _MODULE _2 _ _ . createDefaultConfig ) ( ) ;
if ( typeof config === "object" ) {
Object . assign ( this . _config , config ) ;
}
if ( mediaDataSource . type . toLowerCase ( ) === "flv" ) {
throw new _utils _exception _js _ _WEBPACK _IMPORTED _MODULE _3 _ _ . InvalidArgumentException ( "NativePlayer does't support flv MediaDataSource input!" ) ;
}
if ( mediaDataSource . hasOwnProperty ( "segments" ) ) {
throw new _utils _exception _js _ _WEBPACK _IMPORTED _MODULE _3 _ _ . InvalidArgumentException ( "NativePlayer(" + mediaDataSource . type + ") doesn't support multipart playback!" ) ;
}
this . e = {
onvLoadedMetadata : this . _onvLoadedMetadata . bind ( this )
} ;
this . _pendingSeekTime = null ;
this . _statisticsReporter = null ;
this . _mediaDataSource = mediaDataSource ;
this . _mediaElement = null ;
}
NativePlayer2 . prototype . destroy = function ( ) {
if ( this . _mediaElement ) {
this . unload ( ) ;
this . detachMediaElement ( ) ;
}
this . e = null ;
this . _mediaDataSource = null ;
this . _emitter . removeAllListeners ( ) ;
this . _emitter = null ;
} ;
NativePlayer2 . prototype . on = function ( event , listener ) {
var _this = this ;
if ( event === _player _events _js _ _WEBPACK _IMPORTED _MODULE _1 _ _ . default . MEDIA _INFO ) {
if ( this . _mediaElement != null && this . _mediaElement . readyState !== 0 ) {
Promise . resolve ( ) . then ( function ( ) {
_this . _emitter . emit ( _player _events _js _ _WEBPACK _IMPORTED _MODULE _1 _ _ . default . MEDIA _INFO , _this . mediaInfo ) ;
} ) ;
}
} else if ( event === _player _events _js _ _WEBPACK _IMPORTED _MODULE _1 _ _ . default . STATISTICS _INFO ) {
if ( this . _mediaElement != null && this . _mediaElement . readyState !== 0 ) {
Promise . resolve ( ) . then ( function ( ) {
_this . _emitter . emit ( _player _events _js _ _WEBPACK _IMPORTED _MODULE _1 _ _ . default . STATISTICS _INFO , _this . statisticsInfo ) ;
} ) ;
}
}
this . _emitter . addListener ( event , listener ) ;
} ;
NativePlayer2 . prototype . off = function ( event , listener ) {
this . _emitter . removeListener ( event , listener ) ;
} ;
NativePlayer2 . prototype . attachMediaElement = function ( mediaElement ) {
this . _mediaElement = mediaElement ;
mediaElement . addEventListener ( "loadedmetadata" , this . e . onvLoadedMetadata ) ;
if ( this . _pendingSeekTime != null ) {
try {
mediaElement . currentTime = this . _pendingSeekTime ;
this . _pendingSeekTime = null ;
} catch ( e ) {
}
}
} ;
NativePlayer2 . prototype . detachMediaElement = function ( ) {
if ( this . _mediaElement ) {
this . _mediaElement . src = "" ;
this . _mediaElement . removeAttribute ( "src" ) ;
this . _mediaElement . removeEventListener ( "loadedmetadata" , this . e . onvLoadedMetadata ) ;
this . _mediaElement = null ;
}
if ( this . _statisticsReporter != null ) {
window . clearInterval ( this . _statisticsReporter ) ;
this . _statisticsReporter = null ;
}
} ;
NativePlayer2 . prototype . load = function ( ) {
if ( ! this . _mediaElement ) {
throw new _utils _exception _js _ _WEBPACK _IMPORTED _MODULE _3 _ _ . IllegalStateException ( "HTMLMediaElement must be attached before load()!" ) ;
}
this . _mediaElement . src = this . _mediaDataSource . url ;
if ( this . _mediaElement . readyState > 0 ) {
this . _mediaElement . currentTime = 0 ;
}
this . _mediaElement . preload = "auto" ;
this . _mediaElement . load ( ) ;
this . _statisticsReporter = window . setInterval ( this . _reportStatisticsInfo . bind ( this ) , this . _config . statisticsInfoReportInterval ) ;
} ;
NativePlayer2 . prototype . unload = function ( ) {
if ( this . _mediaElement ) {
this . _mediaElement . src = "" ;
this . _mediaElement . removeAttribute ( "src" ) ;
}
if ( this . _statisticsReporter != null ) {
window . clearInterval ( this . _statisticsReporter ) ;
this . _statisticsReporter = null ;
}
} ;
NativePlayer2 . prototype . play = function ( ) {
return this . _mediaElement . play ( ) ;
} ;
NativePlayer2 . prototype . pause = function ( ) {
this . _mediaElement . pause ( ) ;
} ;
Object . defineProperty ( NativePlayer2 . prototype , "type" , {
get : function ( ) {
return this . _type ;
} ,
enumerable : false ,
configurable : true
} ) ;
Object . defineProperty ( NativePlayer2 . prototype , "buffered" , {
get : function ( ) {
return this . _mediaElement . buffered ;
} ,
enumerable : false ,
configurable : true
} ) ;
Object . defineProperty ( NativePlayer2 . prototype , "duration" , {
get : function ( ) {
return this . _mediaElement . duration ;
} ,
enumerable : false ,
configurable : true
} ) ;
Object . defineProperty ( NativePlayer2 . prototype , "volume" , {
get : function ( ) {
return this . _mediaElement . volume ;
} ,
set : function ( value ) {
this . _mediaElement . volume = value ;
} ,
enumerable : false ,
configurable : true
} ) ;
Object . defineProperty ( NativePlayer2 . prototype , "muted" , {
get : function ( ) {
return this . _mediaElement . muted ;
} ,
set : function ( muted ) {
this . _mediaElement . muted = muted ;
} ,
enumerable : false ,
configurable : true
} ) ;
Object . defineProperty ( NativePlayer2 . prototype , "currentTime" , {
get : function ( ) {
if ( this . _mediaElement ) {
return this . _mediaElement . currentTime ;
}
return 0 ;
} ,
set : function ( seconds ) {
if ( this . _mediaElement ) {
this . _mediaElement . currentTime = seconds ;
} else {
this . _pendingSeekTime = seconds ;
}
} ,
enumerable : false ,
configurable : true
} ) ;
Object . defineProperty ( NativePlayer2 . prototype , "mediaInfo" , {
get : function ( ) {
var mediaPrefix = this . _mediaElement instanceof HTMLAudioElement ? "audio/" : "video/" ;
var info = {
mimeType : mediaPrefix + this . _mediaDataSource . type
} ;
if ( this . _mediaElement ) {
info . duration = Math . floor ( this . _mediaElement . duration * 1e3 ) ;
if ( this . _mediaElement instanceof HTMLVideoElement ) {
info . width = this . _mediaElement . videoWidth ;
info . height = this . _mediaElement . videoHeight ;
}
}
return info ;
} ,
enumerable : false ,
configurable : true
} ) ;
Object . defineProperty ( NativePlayer2 . prototype , "statisticsInfo" , {
get : function ( ) {
var info = {
playerType : this . _type ,
url : this . _mediaDataSource . url
} ;
if ( ! ( this . _mediaElement instanceof HTMLVideoElement ) ) {
return info ;
}
var hasQualityInfo = true ;
var decoded = 0 ;
var dropped = 0 ;
if ( this . _mediaElement . getVideoPlaybackQuality ) {
var quality = this . _mediaElement . getVideoPlaybackQuality ( ) ;
decoded = quality . totalVideoFrames ;
dropped = quality . droppedVideoFrames ;
} else if ( this . _mediaElement . webkitDecodedFrameCount != void 0 ) {
decoded = this . _mediaElement . webkitDecodedFrameCount ;
dropped = this . _mediaElement . webkitDroppedFrameCount ;
} else {
hasQualityInfo = false ;
}
if ( hasQualityInfo ) {
info . decodedFrames = decoded ;
info . droppedFrames = dropped ;
}
return info ;
} ,
enumerable : false ,
configurable : true
} ) ;
NativePlayer2 . prototype . _onvLoadedMetadata = function ( e ) {
if ( this . _pendingSeekTime != null ) {
this . _mediaElement . currentTime = this . _pendingSeekTime ;
this . _pendingSeekTime = null ;
}
this . _emitter . emit ( _player _events _js _ _WEBPACK _IMPORTED _MODULE _1 _ _ . default . MEDIA _INFO , this . mediaInfo ) ;
} ;
NativePlayer2 . prototype . _reportStatisticsInfo = function ( ) {
this . _emitter . emit ( _player _events _js _ _WEBPACK _IMPORTED _MODULE _1 _ _ . default . STATISTICS _INFO , this . statisticsInfo ) ;
} ;
return NativePlayer2 ;
} ( ) ;
_ _webpack _exports _ _2 [ "default" ] = NativePlayer ;
} ,
"./src/player/player-errors.js" : function ( _ _unused _webpack _module , _ _webpack _exports _ _2 , _ _webpack _require _ _2 ) {
"use strict" ;
_ _webpack _require _ _2 . r ( _ _webpack _exports _ _2 ) ;
_ _webpack _require _ _2 . d ( _ _webpack _exports _ _2 , {
"ErrorTypes" : function ( ) {
return ErrorTypes ;
} ,
"ErrorDetails" : function ( ) {
return ErrorDetails ;
}
} ) ;
var _io _loader _js _ _WEBPACK _IMPORTED _MODULE _0 _ _ = _ _webpack _require _ _2 ( "./src/io/loader.js" ) ;
var _demux _demux _errors _js _ _WEBPACK _IMPORTED _MODULE _1 _ _ = _ _webpack _require _ _2 ( "./src/demux/demux-errors.js" ) ;
var ErrorTypes = {
NETWORK _ERROR : "NetworkError" ,
MEDIA _ERROR : "MediaError" ,
OTHER _ERROR : "OtherError"
} ;
var ErrorDetails = {
NETWORK _EXCEPTION : _io _loader _js _ _WEBPACK _IMPORTED _MODULE _0 _ _ . LoaderErrors . EXCEPTION ,
NETWORK _STATUS _CODE _INVALID : _io _loader _js _ _WEBPACK _IMPORTED _MODULE _0 _ _ . LoaderErrors . HTTP _STATUS _CODE _INVALID ,
NETWORK _TIMEOUT : _io _loader _js _ _WEBPACK _IMPORTED _MODULE _0 _ _ . LoaderErrors . CONNECTING _TIMEOUT ,
NETWORK _UNRECOVERABLE _EARLY _EOF : _io _loader _js _ _WEBPACK _IMPORTED _MODULE _0 _ _ . LoaderErrors . UNRECOVERABLE _EARLY _EOF ,
MEDIA _MSE _ERROR : "MediaMSEError" ,
MEDIA _FORMAT _ERROR : _demux _demux _errors _js _ _WEBPACK _IMPORTED _MODULE _1 _ _ . default . FORMAT _ERROR ,
MEDIA _FORMAT _UNSUPPORTED : _demux _demux _errors _js _ _WEBPACK _IMPORTED _MODULE _1 _ _ . default . FORMAT _UNSUPPORTED ,
MEDIA _CODEC _UNSUPPORTED : _demux _demux _errors _js _ _WEBPACK _IMPORTED _MODULE _1 _ _ . default . CODEC _UNSUPPORTED
} ;
} ,
"./src/player/player-events.js" : function ( _ _unused _webpack _module , _ _webpack _exports _ _2 , _ _webpack _require _ _2 ) {
"use strict" ;
_ _webpack _require _ _2 . r ( _ _webpack _exports _ _2 ) ;
var PlayerEvents = {
ERROR : "error" ,
LOADING _COMPLETE : "loading_complete" ,
RECOVERED _EARLY _EOF : "recovered_early_eof" ,
MEDIA _INFO : "media_info" ,
METADATA _ARRIVED : "metadata_arrived" ,
SCRIPTDATA _ARRIVED : "scriptdata_arrived" ,
STATISTICS _INFO : "statistics_info"
} ;
_ _webpack _exports _ _2 [ "default" ] = PlayerEvents ;
} ,
"./src/remux/aac-silent.js" : function ( _ _unused _webpack _module , _ _webpack _exports _ _2 , _ _webpack _require _ _2 ) {
"use strict" ;
_ _webpack _require _ _2 . r ( _ _webpack _exports _ _2 ) ;
var AAC = function ( ) {
function AAC2 ( ) {
}
AAC2 . getSilentFrame = function ( codec , channelCount ) {
if ( codec === "mp4a.40.2" ) {
if ( channelCount === 1 ) {
return new Uint8Array ( [ 0 , 200 , 0 , 128 , 35 , 128 ] ) ;
} else if ( channelCount === 2 ) {
return new Uint8Array ( [ 33 , 0 , 73 , 144 , 2 , 25 , 0 , 35 , 128 ] ) ;
} else if ( channelCount === 3 ) {
return new Uint8Array ( [ 0 , 200 , 0 , 128 , 32 , 132 , 1 , 38 , 64 , 8 , 100 , 0 , 142 ] ) ;
} else if ( channelCount === 4 ) {
return new Uint8Array ( [ 0 , 200 , 0 , 128 , 32 , 132 , 1 , 38 , 64 , 8 , 100 , 0 , 128 , 44 , 128 , 8 , 2 , 56 ] ) ;
} else if ( channelCount === 5 ) {
return new Uint8Array ( [ 0 , 200 , 0 , 128 , 32 , 132 , 1 , 38 , 64 , 8 , 100 , 0 , 130 , 48 , 4 , 153 , 0 , 33 , 144 , 2 , 56 ] ) ;
} else if ( channelCount === 6 ) {
return new Uint8Array ( [ 0 , 200 , 0 , 128 , 32 , 132 , 1 , 38 , 64 , 8 , 100 , 0 , 130 , 48 , 4 , 153 , 0 , 33 , 144 , 2 , 0 , 178 , 0 , 32 , 8 , 224 ] ) ;
}
} else {
if ( channelCount === 1 ) {
return new Uint8Array ( [ 1 , 64 , 34 , 128 , 163 , 78 , 230 , 128 , 186 , 8 , 0 , 0 , 0 , 28 , 6 , 241 , 193 , 10 , 90 , 90 , 90 , 90 , 90 , 90 , 90 , 90 , 90 , 90 , 90 , 90 , 90 , 90 , 90 , 90 , 90 , 90 , 90 , 90 , 90 , 90 , 90 , 90 , 90 , 90 , 90 , 90 , 90 , 90 , 90 , 90 , 90 , 90 , 90 , 90 , 90 , 90 , 90 , 90 , 94 ] ) ;
} else if ( channelCount === 2 ) {
return new Uint8Array ( [ 1 , 64 , 34 , 128 , 163 , 94 , 230 , 128 , 186 , 8 , 0 , 0 , 0 , 0 , 149 , 0 , 6 , 241 , 161 , 10 , 90 , 90 , 90 , 90 , 90 , 90 , 90 , 90 , 90 , 90 , 90 , 90 , 90 , 90 , 90 , 90 , 90 , 90 , 90 , 90 , 90 , 90 , 90 , 90 , 90 , 90 , 90 , 90 , 90 , 90 , 90 , 90 , 90 , 90 , 90 , 90 , 90 , 90 , 94 ] ) ;
} else if ( channelCount === 3 ) {
return new Uint8Array ( [ 1 , 64 , 34 , 128 , 163 , 94 , 230 , 128 , 186 , 8 , 0 , 0 , 0 , 0 , 149 , 0 , 6 , 241 , 161 , 10 , 90 , 90 , 90 , 90 , 90 , 90 , 90 , 90 , 90 , 90 , 90 , 90 , 90 , 90 , 90 , 90 , 90 , 90 , 90 , 90 , 90 , 90 , 90 , 90 , 90 , 90 , 90 , 90 , 90 , 90 , 90 , 90 , 90 , 90 , 90 , 90 , 90 , 90 , 94 ] ) ;
}
}
return null ;
} ;
return AAC2 ;
} ( ) ;
_ _webpack _exports _ _2 [ "default" ] = AAC ;
} ,
"./src/remux/mp4-generator.js" : function ( _ _unused _webpack _module , _ _webpack _exports _ _2 , _ _webpack _require _ _2 ) {
"use strict" ;
_ _webpack _require _ _2 . r ( _ _webpack _exports _ _2 ) ;
var MP4 = function ( ) {
function MP42 ( ) {
}
MP42 . init = function ( ) {
MP42 . types = {
avc1 : [ ] ,
avcC : [ ] ,
btrt : [ ] ,
dinf : [ ] ,
dref : [ ] ,
esds : [ ] ,
ftyp : [ ] ,
hdlr : [ ] ,
mdat : [ ] ,
mdhd : [ ] ,
mdia : [ ] ,
mfhd : [ ] ,
minf : [ ] ,
moof : [ ] ,
moov : [ ] ,
mp4a : [ ] ,
mvex : [ ] ,
mvhd : [ ] ,
sdtp : [ ] ,
stbl : [ ] ,
stco : [ ] ,
stsc : [ ] ,
stsd : [ ] ,
stsz : [ ] ,
stts : [ ] ,
tfdt : [ ] ,
tfhd : [ ] ,
traf : [ ] ,
trak : [ ] ,
trun : [ ] ,
trex : [ ] ,
tkhd : [ ] ,
vmhd : [ ] ,
smhd : [ ] ,
".mp3" : [ ]
} ;
for ( var name _1 in MP42 . types ) {
if ( MP42 . types . hasOwnProperty ( name _1 ) ) {
MP42 . types [ name _1 ] = [
name _1 . charCodeAt ( 0 ) ,
name _1 . charCodeAt ( 1 ) ,
name _1 . charCodeAt ( 2 ) ,
name _1 . charCodeAt ( 3 )
] ;
}
}
var constants = MP42 . constants = { } ;
constants . FTYP = new Uint8Array ( [
105 ,
115 ,
111 ,
109 ,
0 ,
0 ,
0 ,
1 ,
105 ,
115 ,
111 ,
109 ,
97 ,
118 ,
99 ,
49
] ) ;
constants . STSD _PREFIX = new Uint8Array ( [
0 ,
0 ,
0 ,
0 ,
0 ,
0 ,
0 ,
1
] ) ;
constants . STTS = new Uint8Array ( [
0 ,
0 ,
0 ,
0 ,
0 ,
0 ,
0 ,
0
] ) ;
constants . STSC = constants . STCO = constants . STTS ;
constants . STSZ = new Uint8Array ( [
0 ,
0 ,
0 ,
0 ,
0 ,
0 ,
0 ,
0 ,
0 ,
0 ,
0 ,
0
] ) ;
constants . HDLR _VIDEO = new Uint8Array ( [
0 ,
0 ,
0 ,
0 ,
0 ,
0 ,
0 ,
0 ,
118 ,
105 ,
100 ,
101 ,
0 ,
0 ,
0 ,
0 ,
0 ,
0 ,
0 ,
0 ,
0 ,
0 ,
0 ,
0 ,
86 ,
105 ,
100 ,
101 ,
111 ,
72 ,
97 ,
110 ,
100 ,
108 ,
101 ,
114 ,
0
] ) ;
constants . HDLR _AUDIO = new Uint8Array ( [
0 ,
0 ,
0 ,
0 ,
0 ,
0 ,
0 ,
0 ,
115 ,
111 ,
117 ,
110 ,
0 ,
0 ,
0 ,
0 ,
0 ,
0 ,
0 ,
0 ,
0 ,
0 ,
0 ,
0 ,
83 ,
111 ,
117 ,
110 ,
100 ,
72 ,
97 ,
110 ,
100 ,
108 ,
101 ,
114 ,
0
] ) ;
constants . DREF = new Uint8Array ( [
0 ,
0 ,
0 ,
0 ,
0 ,
0 ,
0 ,
1 ,
0 ,
0 ,
0 ,
12 ,
117 ,
114 ,
108 ,
32 ,
0 ,
0 ,
0 ,
1
] ) ;
constants . SMHD = new Uint8Array ( [
0 ,
0 ,
0 ,
0 ,
0 ,
0 ,
0 ,
0
] ) ;
constants . VMHD = new Uint8Array ( [
0 ,
0 ,
0 ,
1 ,
0 ,
0 ,
0 ,
0 ,
0 ,
0 ,
0 ,
0
] ) ;
} ;
MP42 . box = function ( type ) {
var size = 8 ;
var result = null ;
var datas = Array . prototype . slice . call ( arguments , 1 ) ;
var arrayCount = datas . length ;
for ( var i = 0 ; i < arrayCount ; i ++ ) {
size += datas [ i ] . byteLength ;
}
result = new Uint8Array ( size ) ;
result [ 0 ] = size >>> 24 & 255 ;
result [ 1 ] = size >>> 16 & 255 ;
result [ 2 ] = size >>> 8 & 255 ;
result [ 3 ] = size & 255 ;
result . set ( type , 4 ) ;
var offset = 8 ;
for ( var i = 0 ; i < arrayCount ; i ++ ) {
result . set ( datas [ i ] , offset ) ;
offset += datas [ i ] . byteLength ;
}
return result ;
} ;
MP42 . generateInitSegment = function ( meta ) {
var ftyp = MP42 . box ( MP42 . types . ftyp , MP42 . constants . FTYP ) ;
var moov = MP42 . moov ( meta ) ;
var result = new Uint8Array ( ftyp . byteLength + moov . byteLength ) ;
result . set ( ftyp , 0 ) ;
result . set ( moov , ftyp . byteLength ) ;
return result ;
} ;
MP42 . moov = function ( meta ) {
var mvhd = MP42 . mvhd ( meta . timescale , meta . duration ) ;
var trak = MP42 . trak ( meta ) ;
var mvex = MP42 . mvex ( meta ) ;
return MP42 . box ( MP42 . types . moov , mvhd , trak , mvex ) ;
} ;
MP42 . mvhd = function ( timescale , duration ) {
return MP42 . box ( MP42 . types . mvhd , new Uint8Array ( [
0 ,
0 ,
0 ,
0 ,
0 ,
0 ,
0 ,
0 ,
0 ,
0 ,
0 ,
0 ,
timescale >>> 24 & 255 ,
timescale >>> 16 & 255 ,
timescale >>> 8 & 255 ,
timescale & 255 ,
duration >>> 24 & 255 ,
duration >>> 16 & 255 ,
duration >>> 8 & 255 ,
duration & 255 ,
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
] ) ) ;
} ;
MP42 . trak = function ( meta ) {
return MP42 . box ( MP42 . types . trak , MP42 . tkhd ( meta ) , MP42 . mdia ( meta ) ) ;
} ;
MP42 . tkhd = function ( meta ) {
var trackId = meta . id , duration = meta . duration ;
var width = meta . presentWidth , height = meta . presentHeight ;
return MP42 . box ( MP42 . types . tkhd , new Uint8Array ( [
0 ,
0 ,
0 ,
7 ,
0 ,
0 ,
0 ,
0 ,
0 ,
0 ,
0 ,
0 ,
trackId >>> 24 & 255 ,
trackId >>> 16 & 255 ,
trackId >>> 8 & 255 ,
trackId & 255 ,
0 ,
0 ,
0 ,
0 ,
duration >>> 24 & 255 ,
duration >>> 16 & 255 ,
duration >>> 8 & 255 ,
duration & 255 ,
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 ,
width >>> 8 & 255 ,
width & 255 ,
0 ,
0 ,
height >>> 8 & 255 ,
height & 255 ,
0 ,
0
] ) ) ;
} ;
MP42 . mdia = function ( meta ) {
return MP42 . box ( MP42 . types . mdia , MP42 . mdhd ( meta ) , MP42 . hdlr ( meta ) , MP42 . minf ( meta ) ) ;
} ;
MP42 . mdhd = function ( meta ) {
var timescale = meta . timescale ;
var duration = meta . duration ;
return MP42 . box ( MP42 . types . mdhd , new Uint8Array ( [
0 ,
0 ,
0 ,
0 ,
0 ,
0 ,
0 ,
0 ,
0 ,
0 ,
0 ,
0 ,
timescale >>> 24 & 255 ,
timescale >>> 16 & 255 ,
timescale >>> 8 & 255 ,
timescale & 255 ,
duration >>> 24 & 255 ,
duration >>> 16 & 255 ,
duration >>> 8 & 255 ,
duration & 255 ,
85 ,
196 ,
0 ,
0
] ) ) ;
} ;
MP42 . hdlr = function ( meta ) {
var data = null ;
if ( meta . type === "audio" ) {
data = MP42 . constants . HDLR _AUDIO ;
} else {
data = MP42 . constants . HDLR _VIDEO ;
}
return MP42 . box ( MP42 . types . hdlr , data ) ;
} ;
MP42 . minf = function ( meta ) {
var xmhd = null ;
if ( meta . type === "audio" ) {
xmhd = MP42 . box ( MP42 . types . smhd , MP42 . constants . SMHD ) ;
} else {
xmhd = MP42 . box ( MP42 . types . vmhd , MP42 . constants . VMHD ) ;
}
return MP42 . box ( MP42 . types . minf , xmhd , MP42 . dinf ( ) , MP42 . stbl ( meta ) ) ;
} ;
MP42 . dinf = function ( ) {
var result = MP42 . box ( MP42 . types . dinf , MP42 . box ( MP42 . types . dref , MP42 . constants . DREF ) ) ;
return result ;
} ;
MP42 . stbl = function ( meta ) {
var result = MP42 . box ( MP42 . types . stbl , MP42 . stsd ( meta ) , MP42 . box ( MP42 . types . stts , MP42 . constants . STTS ) , MP42 . box ( MP42 . types . stsc , MP42 . constants . STSC ) , MP42 . box ( MP42 . types . stsz , MP42 . constants . STSZ ) , MP42 . box ( MP42 . types . stco , MP42 . constants . STCO ) ) ;
return result ;
} ;
MP42 . stsd = function ( meta ) {
if ( meta . type === "audio" ) {
if ( meta . codec === "mp3" ) {
return MP42 . box ( MP42 . types . stsd , MP42 . constants . STSD _PREFIX , MP42 . mp3 ( meta ) ) ;
}
return MP42 . box ( MP42 . types . stsd , MP42 . constants . STSD _PREFIX , MP42 . mp4a ( meta ) ) ;
} else {
return MP42 . box ( MP42 . types . stsd , MP42 . constants . STSD _PREFIX , MP42 . avc1 ( meta ) ) ;
}
} ;
MP42 . mp3 = function ( meta ) {
var channelCount = meta . channelCount ;
var sampleRate = meta . audioSampleRate ;
var data = new Uint8Array ( [
0 ,
0 ,
0 ,
0 ,
0 ,
0 ,
0 ,
1 ,
0 ,
0 ,
0 ,
0 ,
0 ,
0 ,
0 ,
0 ,
0 ,
channelCount ,
0 ,
16 ,
0 ,
0 ,
0 ,
0 ,
sampleRate >>> 8 & 255 ,
sampleRate & 255 ,
0 ,
0
] ) ;
return MP42 . box ( MP42 . types [ ".mp3" ] , data ) ;
} ;
MP42 . mp4a = function ( meta ) {
var channelCount = meta . channelCount ;
var sampleRate = meta . audioSampleRate ;
var data = new Uint8Array ( [
0 ,
0 ,
0 ,
0 ,
0 ,
0 ,
0 ,
1 ,
0 ,
0 ,
0 ,
0 ,
0 ,
0 ,
0 ,
0 ,
0 ,
channelCount ,
0 ,
16 ,
0 ,
0 ,
0 ,
0 ,
sampleRate >>> 8 & 255 ,
sampleRate & 255 ,
0 ,
0
] ) ;
return MP42 . box ( MP42 . types . mp4a , data , MP42 . esds ( meta ) ) ;
} ;
MP42 . esds = function ( meta ) {
var config = meta . config || [ ] ;
var configSize = config . length ;
var data = new Uint8Array ( [
0 ,
0 ,
0 ,
0 ,
3 ,
23 + configSize ,
0 ,
1 ,
0 ,
4 ,
15 + configSize ,
64 ,
21 ,
0 ,
0 ,
0 ,
0 ,
0 ,
0 ,
0 ,
0 ,
0 ,
0 ,
0 ,
5
] . concat ( [
configSize
] ) . concat ( config ) . concat ( [
6 ,
1 ,
2
] ) ) ;
return MP42 . box ( MP42 . types . esds , data ) ;
} ;
MP42 . avc1 = function ( meta ) {
var avcc = meta . avcc ;
var width = meta . codecWidth , height = meta . codecHeight ;
var data = 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 ,
width >>> 8 & 255 ,
width & 255 ,
height >>> 8 & 255 ,
height & 255 ,
0 ,
72 ,
0 ,
0 ,
0 ,
72 ,
0 ,
0 ,
0 ,
0 ,
0 ,
0 ,
0 ,
1 ,
10 ,
120 ,
113 ,
113 ,
47 ,
102 ,
108 ,
118 ,
46 ,
106 ,
115 ,
0 ,
0 ,
0 ,
0 ,
0 ,
0 ,
0 ,
0 ,
0 ,
0 ,
0 ,
0 ,
0 ,
0 ,
0 ,
0 ,
0 ,
0 ,
0 ,
0 ,
0 ,
0 ,
24 ,
255 ,
255
] ) ;
return MP42 . box ( MP42 . types . avc1 , data , MP42 . box ( MP42 . types . avcC , avcc ) ) ;
} ;
MP42 . mvex = function ( meta ) {
return MP42 . box ( MP42 . types . mvex , MP42 . trex ( meta ) ) ;
} ;
MP42 . trex = function ( meta ) {
var trackId = meta . id ;
var data = new Uint8Array ( [
0 ,
0 ,
0 ,
0 ,
trackId >>> 24 & 255 ,
trackId >>> 16 & 255 ,
trackId >>> 8 & 255 ,
trackId & 255 ,
0 ,
0 ,
0 ,
1 ,
0 ,
0 ,
0 ,
0 ,
0 ,
0 ,
0 ,
0 ,
0 ,
1 ,
0 ,
1
] ) ;
return MP42 . box ( MP42 . types . trex , data ) ;
} ;
MP42 . moof = function ( track , baseMediaDecodeTime ) {
return MP42 . box ( MP42 . types . moof , MP42 . mfhd ( track . sequenceNumber ) , MP42 . traf ( track , baseMediaDecodeTime ) ) ;
} ;
MP42 . mfhd = function ( sequenceNumber ) {
var data = new Uint8Array ( [
0 ,
0 ,
0 ,
0 ,
sequenceNumber >>> 24 & 255 ,
sequenceNumber >>> 16 & 255 ,
sequenceNumber >>> 8 & 255 ,
sequenceNumber & 255
] ) ;
return MP42 . box ( MP42 . types . mfhd , data ) ;
} ;
MP42 . traf = function ( track , baseMediaDecodeTime ) {
var trackId = track . id ;
var tfhd = MP42 . box ( MP42 . types . tfhd , new Uint8Array ( [
0 ,
0 ,
0 ,
0 ,
trackId >>> 24 & 255 ,
trackId >>> 16 & 255 ,
trackId >>> 8 & 255 ,
trackId & 255
] ) ) ;
var tfdt = MP42 . box ( MP42 . types . tfdt , new Uint8Array ( [
0 ,
0 ,
0 ,
0 ,
baseMediaDecodeTime >>> 24 & 255 ,
baseMediaDecodeTime >>> 16 & 255 ,
baseMediaDecodeTime >>> 8 & 255 ,
baseMediaDecodeTime & 255
] ) ) ;
var sdtp = MP42 . sdtp ( track ) ;
var trun = MP42 . trun ( track , sdtp . byteLength + 16 + 16 + 8 + 16 + 8 + 8 ) ;
return MP42 . box ( MP42 . types . traf , tfhd , tfdt , trun , sdtp ) ;
} ;
MP42 . sdtp = function ( track ) {
var samples = track . samples || [ ] ;
var sampleCount = samples . length ;
var data = new Uint8Array ( 4 + sampleCount ) ;
for ( var i = 0 ; i < sampleCount ; i ++ ) {
var flags = samples [ i ] . flags ;
data [ i + 4 ] = flags . isLeading << 6 | flags . dependsOn << 4 | flags . isDependedOn << 2 | flags . hasRedundancy ;
}
return MP42 . box ( MP42 . types . sdtp , data ) ;
} ;
MP42 . trun = function ( track , offset ) {
var samples = track . samples || [ ] ;
var sampleCount = samples . length ;
var dataSize = 12 + 16 * sampleCount ;
var data = new Uint8Array ( dataSize ) ;
offset += 8 + dataSize ;
data . set ( [
0 ,
0 ,
15 ,
1 ,
sampleCount >>> 24 & 255 ,
sampleCount >>> 16 & 255 ,
sampleCount >>> 8 & 255 ,
sampleCount & 255 ,
offset >>> 24 & 255 ,
offset >>> 16 & 255 ,
offset >>> 8 & 255 ,
offset & 255
] , 0 ) ;
for ( var i = 0 ; i < sampleCount ; i ++ ) {
var duration = samples [ i ] . duration ;
var size = samples [ i ] . size ;
var flags = samples [ i ] . flags ;
var cts = samples [ i ] . cts ;
data . set ( [
duration >>> 24 & 255 ,
duration >>> 16 & 255 ,
duration >>> 8 & 255 ,
duration & 255 ,
size >>> 24 & 255 ,
size >>> 16 & 255 ,
size >>> 8 & 255 ,
size & 255 ,
flags . isLeading << 2 | flags . dependsOn ,
flags . isDependedOn << 6 | flags . hasRedundancy << 4 | flags . isNonSync ,
0 ,
0 ,
cts >>> 24 & 255 ,
cts >>> 16 & 255 ,
cts >>> 8 & 255 ,
cts & 255
] , 12 + 16 * i ) ;
}
return MP42 . box ( MP42 . types . trun , data ) ;
} ;
MP42 . mdat = function ( data ) {
return MP42 . box ( MP42 . types . mdat , data ) ;
} ;
return MP42 ;
} ( ) ;
MP4 . init ( ) ;
_ _webpack _exports _ _2 [ "default" ] = MP4 ;
} ,
"./src/remux/mp4-remuxer.js" : function ( _ _unused _webpack _module , _ _webpack _exports _ _2 , _ _webpack _require _ _2 ) {
"use strict" ;
_ _webpack _require _ _2 . r ( _ _webpack _exports _ _2 ) ;
var _utils _logger _js _ _WEBPACK _IMPORTED _MODULE _0 _ _ = _ _webpack _require _ _2 ( "./src/utils/logger.js" ) ;
var _mp4 _generator _js _ _WEBPACK _IMPORTED _MODULE _1 _ _ = _ _webpack _require _ _2 ( "./src/remux/mp4-generator.js" ) ;
var _aac _silent _js _ _WEBPACK _IMPORTED _MODULE _2 _ _ = _ _webpack _require _ _2 ( "./src/remux/aac-silent.js" ) ;
var _utils _browser _js _ _WEBPACK _IMPORTED _MODULE _3 _ _ = _ _webpack _require _ _2 ( "./src/utils/browser.js" ) ;
var _core _media _segment _info _js _ _WEBPACK _IMPORTED _MODULE _4 _ _ = _ _webpack _require _ _2 ( "./src/core/media-segment-info.js" ) ;
var _utils _exception _js _ _WEBPACK _IMPORTED _MODULE _5 _ _ = _ _webpack _require _ _2 ( "./src/utils/exception.js" ) ;
var MP4Remuxer = function ( ) {
function MP4Remuxer2 ( config ) {
this . TAG = "MP4Remuxer" ;
this . _config = config ;
this . _isLive = config . isLive === true ? true : false ;
this . _dtsBase = - 1 ;
this . _dtsBaseInited = false ;
this . _audioDtsBase = Infinity ;
this . _videoDtsBase = Infinity ;
this . _audioNextDts = void 0 ;
this . _videoNextDts = void 0 ;
this . _audioStashedLastSample = null ;
this . _videoStashedLastSample = null ;
this . _audioMeta = null ;
this . _videoMeta = null ;
this . _audioSegmentInfoList = new _core _media _segment _info _js _ _WEBPACK _IMPORTED _MODULE _4 _ _ . MediaSegmentInfoList ( "audio" ) ;
this . _videoSegmentInfoList = new _core _media _segment _info _js _ _WEBPACK _IMPORTED _MODULE _4 _ _ . MediaSegmentInfoList ( "video" ) ;
this . _onInitSegment = null ;
this . _onMediaSegment = null ;
this . _forceFirstIDR = _utils _browser _js _ _WEBPACK _IMPORTED _MODULE _3 _ _ . default . chrome && ( _utils _browser _js _ _WEBPACK _IMPORTED _MODULE _3 _ _ . default . version . major < 50 || _utils _browser _js _ _WEBPACK _IMPORTED _MODULE _3 _ _ . default . version . major === 50 && _utils _browser _js _ _WEBPACK _IMPORTED _MODULE _3 _ _ . default . version . build < 2661 ) ? true : false ;
this . _fillSilentAfterSeek = _utils _browser _js _ _WEBPACK _IMPORTED _MODULE _3 _ _ . default . msedge || _utils _browser _js _ _WEBPACK _IMPORTED _MODULE _3 _ _ . default . msie ;
this . _mp3UseMpegAudio = ! _utils _browser _js _ _WEBPACK _IMPORTED _MODULE _3 _ _ . default . firefox ;
this . _fillAudioTimestampGap = this . _config . fixAudioTimestampGap ;
}
MP4Remuxer2 . prototype . destroy = function ( ) {
this . _dtsBase = - 1 ;
this . _dtsBaseInited = false ;
this . _audioMeta = null ;
this . _videoMeta = null ;
this . _audioSegmentInfoList . clear ( ) ;
this . _audioSegmentInfoList = null ;
this . _videoSegmentInfoList . clear ( ) ;
this . _videoSegmentInfoList = null ;
this . _onInitSegment = null ;
this . _onMediaSegment = null ;
} ;
MP4Remuxer2 . prototype . bindDataSource = function ( producer ) {
producer . onDataAvailable = this . remux . bind ( this ) ;
producer . onTrackMetadata = this . _onTrackMetadataReceived . bind ( this ) ;
return this ;
} ;
Object . defineProperty ( MP4Remuxer2 . prototype , "onInitSegment" , {
get : function ( ) {
return this . _onInitSegment ;
} ,
set : function ( callback ) {
this . _onInitSegment = callback ;
} ,
enumerable : false ,
configurable : true
} ) ;
Object . defineProperty ( MP4Remuxer2 . prototype , "onMediaSegment" , {
get : function ( ) {
return this . _onMediaSegment ;
} ,
set : function ( callback ) {
this . _onMediaSegment = callback ;
} ,
enumerable : false ,
configurable : true
} ) ;
MP4Remuxer2 . prototype . insertDiscontinuity = function ( ) {
this . _audioNextDts = this . _videoNextDts = void 0 ;
} ;
MP4Remuxer2 . prototype . seek = function ( originalDts ) {
this . _audioStashedLastSample = null ;
this . _videoStashedLastSample = null ;
this . _videoSegmentInfoList . clear ( ) ;
this . _audioSegmentInfoList . clear ( ) ;
} ;
MP4Remuxer2 . prototype . remux = function ( audioTrack , videoTrack ) {
if ( ! this . _onMediaSegment ) {
throw new _utils _exception _js _ _WEBPACK _IMPORTED _MODULE _5 _ _ . IllegalStateException ( "MP4Remuxer: onMediaSegment callback must be specificed!" ) ;
}
if ( ! this . _dtsBaseInited ) {
this . _calculateDtsBase ( audioTrack , videoTrack ) ;
}
this . _remuxVideo ( videoTrack ) ;
this . _remuxAudio ( audioTrack ) ;
} ;
MP4Remuxer2 . prototype . _onTrackMetadataReceived = function ( type , metadata ) {
var metabox = null ;
var container = "mp4" ;
var codec = metadata . codec ;
if ( type === "audio" ) {
this . _audioMeta = metadata ;
if ( metadata . codec === "mp3" && this . _mp3UseMpegAudio ) {
container = "mpeg" ;
codec = "" ;
metabox = new Uint8Array ( ) ;
} else {
metabox = _mp4 _generator _js _ _WEBPACK _IMPORTED _MODULE _1 _ _ . default . generateInitSegment ( metadata ) ;
}
} else if ( type === "video" ) {
this . _videoMeta = metadata ;
metabox = _mp4 _generator _js _ _WEBPACK _IMPORTED _MODULE _1 _ _ . default . generateInitSegment ( metadata ) ;
} else {
return ;
}
if ( ! this . _onInitSegment ) {
throw new _utils _exception _js _ _WEBPACK _IMPORTED _MODULE _5 _ _ . IllegalStateException ( "MP4Remuxer: onInitSegment callback must be specified!" ) ;
}
this . _onInitSegment ( type , {
type ,
data : metabox . buffer ,
codec ,
container : type + "/" + container ,
mediaDuration : metadata . duration
} ) ;
} ;
MP4Remuxer2 . prototype . _calculateDtsBase = function ( audioTrack , videoTrack ) {
if ( this . _dtsBaseInited ) {
return ;
}
if ( audioTrack . samples && audioTrack . samples . length ) {
this . _audioDtsBase = audioTrack . samples [ 0 ] . dts ;
}
if ( videoTrack . samples && videoTrack . samples . length ) {
this . _videoDtsBase = videoTrack . samples [ 0 ] . dts ;
}
this . _dtsBase = Math . min ( this . _audioDtsBase , this . _videoDtsBase ) ;
this . _dtsBaseInited = true ;
} ;
MP4Remuxer2 . prototype . flushStashedSamples = function ( ) {
var videoSample = this . _videoStashedLastSample ;
var audioSample = this . _audioStashedLastSample ;
var videoTrack = {
type : "video" ,
id : 1 ,
sequenceNumber : 0 ,
samples : [ ] ,
length : 0
} ;
if ( videoSample != null ) {
videoTrack . samples . push ( videoSample ) ;
videoTrack . length = videoSample . length ;
}
var audioTrack = {
type : "audio" ,
id : 2 ,
sequenceNumber : 0 ,
samples : [ ] ,
length : 0
} ;
if ( audioSample != null ) {
audioTrack . samples . push ( audioSample ) ;
audioTrack . length = audioSample . length ;
}
this . _videoStashedLastSample = null ;
this . _audioStashedLastSample = null ;
this . _remuxVideo ( videoTrack , true ) ;
this . _remuxAudio ( audioTrack , true ) ;
} ;
MP4Remuxer2 . prototype . _remuxAudio = function ( audioTrack , force ) {
if ( this . _audioMeta == null ) {
return ;
}
var track = audioTrack ;
var samples = track . samples ;
var dtsCorrection = void 0 ;
var firstDts = - 1 , lastDts = - 1 , lastPts = - 1 ;
var refSampleDuration = this . _audioMeta . refSampleDuration ;
var mpegRawTrack = this . _audioMeta . codec === "mp3" && this . _mp3UseMpegAudio ;
var firstSegmentAfterSeek = this . _dtsBaseInited && this . _audioNextDts === void 0 ;
var insertPrefixSilentFrame = false ;
if ( ! samples || samples . length === 0 ) {
return ;
}
if ( samples . length === 1 && ! force ) {
return ;
}
var offset = 0 ;
var mdatbox = null ;
var mdatBytes = 0 ;
if ( mpegRawTrack ) {
offset = 0 ;
mdatBytes = track . length ;
} else {
offset = 8 ;
mdatBytes = 8 + track . length ;
}
var lastSample = null ;
if ( samples . length > 1 ) {
lastSample = samples . pop ( ) ;
mdatBytes -= lastSample . length ;
}
if ( this . _audioStashedLastSample != null ) {
var sample = this . _audioStashedLastSample ;
this . _audioStashedLastSample = null ;
samples . unshift ( sample ) ;
mdatBytes += sample . length ;
}
if ( lastSample != null ) {
this . _audioStashedLastSample = lastSample ;
}
var firstSampleOriginalDts = samples [ 0 ] . dts - this . _dtsBase ;
if ( this . _audioNextDts ) {
dtsCorrection = firstSampleOriginalDts - this . _audioNextDts ;
} else {
if ( this . _audioSegmentInfoList . isEmpty ( ) ) {
dtsCorrection = 0 ;
if ( this . _fillSilentAfterSeek && ! this . _videoSegmentInfoList . isEmpty ( ) ) {
if ( this . _audioMeta . originalCodec !== "mp3" ) {
insertPrefixSilentFrame = true ;
}
}
} else {
var lastSample _1 = this . _audioSegmentInfoList . getLastSampleBefore ( firstSampleOriginalDts ) ;
if ( lastSample _1 != null ) {
var distance = firstSampleOriginalDts - ( lastSample _1 . originalDts + lastSample _1 . duration ) ;
if ( distance <= 3 ) {
distance = 0 ;
}
var expectedDts = lastSample _1 . dts + lastSample _1 . duration + distance ;
dtsCorrection = firstSampleOriginalDts - expectedDts ;
} else {
dtsCorrection = 0 ;
}
}
}
if ( insertPrefixSilentFrame ) {
var firstSampleDts = firstSampleOriginalDts - dtsCorrection ;
var videoSegment = this . _videoSegmentInfoList . getLastSegmentBefore ( firstSampleOriginalDts ) ;
if ( videoSegment != null && videoSegment . beginDts < firstSampleDts ) {
var silentUnit = _aac _silent _js _ _WEBPACK _IMPORTED _MODULE _2 _ _ . default . getSilentFrame ( this . _audioMeta . originalCodec , this . _audioMeta . channelCount ) ;
if ( silentUnit ) {
var dts = videoSegment . beginDts ;
var silentFrameDuration = firstSampleDts - videoSegment . beginDts ;
_utils _logger _js _ _WEBPACK _IMPORTED _MODULE _0 _ _ . default . v ( this . TAG , "InsertPrefixSilentAudio: dts: " + dts + ", duration: " + silentFrameDuration ) ;
samples . unshift ( { unit : silentUnit , dts , pts : dts } ) ;
mdatBytes += silentUnit . byteLength ;
}
} else {
insertPrefixSilentFrame = false ;
}
}
var mp4Samples = [ ] ;
for ( var i = 0 ; i < samples . length ; i ++ ) {
var sample = samples [ i ] ;
var unit = sample . unit ;
var originalDts = sample . dts - this . _dtsBase ;
var dts = originalDts ;
var needFillSilentFrames = false ;
var silentFrames = null ;
var sampleDuration = 0 ;
if ( originalDts < - 1e-3 ) {
continue ;
}
if ( this . _audioMeta . codec !== "mp3" ) {
var curRefDts = originalDts ;
var maxAudioFramesDrift = 3 ;
if ( this . _audioNextDts ) {
curRefDts = this . _audioNextDts ;
}
dtsCorrection = originalDts - curRefDts ;
if ( dtsCorrection <= - maxAudioFramesDrift * refSampleDuration ) {
_utils _logger _js _ _WEBPACK _IMPORTED _MODULE _0 _ _ . default . w ( this . TAG , "Dropping 1 audio frame (originalDts: " + originalDts + " ms ,curRefDts: " + curRefDts + " ms) due to dtsCorrection: " + dtsCorrection + " ms overlap." ) ;
continue ;
} else if ( dtsCorrection >= maxAudioFramesDrift * refSampleDuration && this . _fillAudioTimestampGap && ! _utils _browser _js _ _WEBPACK _IMPORTED _MODULE _3 _ _ . default . safari ) {
needFillSilentFrames = true ;
var frameCount = Math . floor ( dtsCorrection / refSampleDuration ) ;
_utils _logger _js _ _WEBPACK _IMPORTED _MODULE _0 _ _ . default . w ( this . TAG , "Large audio timestamp gap detected, may cause AV sync to drift. Silent frames will be generated to avoid unsync.\n" + ( "originalDts: " + originalDts + " ms, curRefDts: " + curRefDts + " ms, " ) + ( "dtsCorrection: " + Math . round ( dtsCorrection ) + " ms, generate: " + frameCount + " frames" ) ) ;
dts = Math . floor ( curRefDts ) ;
sampleDuration = Math . floor ( curRefDts + refSampleDuration ) - dts ;
var silentUnit = _aac _silent _js _ _WEBPACK _IMPORTED _MODULE _2 _ _ . default . getSilentFrame ( this . _audioMeta . originalCodec , this . _audioMeta . channelCount ) ;
if ( silentUnit == null ) {
_utils _logger _js _ _WEBPACK _IMPORTED _MODULE _0 _ _ . default . w ( this . TAG , "Unable to generate silent frame for " + ( this . _audioMeta . originalCodec + " with " + this . _audioMeta . channelCount + " channels, repeat last frame" ) ) ;
silentUnit = unit ;
}
silentFrames = [ ] ;
for ( var j = 0 ; j < frameCount ; j ++ ) {
curRefDts = curRefDts + refSampleDuration ;
var intDts = Math . floor ( curRefDts ) ;
var intDuration = Math . floor ( curRefDts + refSampleDuration ) - intDts ;
var frame = {
dts : intDts ,
pts : intDts ,
cts : 0 ,
unit : silentUnit ,
size : silentUnit . byteLength ,
duration : intDuration ,
originalDts ,
flags : {
isLeading : 0 ,
dependsOn : 1 ,
isDependedOn : 0 ,
hasRedundancy : 0
}
} ;
silentFrames . push ( frame ) ;
mdatBytes += frame . size ;
;
}
this . _audioNextDts = curRefDts + refSampleDuration ;
} else {
dts = Math . floor ( curRefDts ) ;
sampleDuration = Math . floor ( curRefDts + refSampleDuration ) - dts ;
this . _audioNextDts = curRefDts + refSampleDuration ;
}
} else {
dts = originalDts - dtsCorrection ;
if ( i !== samples . length - 1 ) {
var nextDts = samples [ i + 1 ] . dts - this . _dtsBase - dtsCorrection ;
sampleDuration = nextDts - dts ;
} else {
if ( lastSample != null ) {
var nextDts = lastSample . dts - this . _dtsBase - dtsCorrection ;
sampleDuration = nextDts - dts ;
} else if ( mp4Samples . length >= 1 ) {
sampleDuration = mp4Samples [ mp4Samples . length - 1 ] . duration ;
} else {
sampleDuration = Math . floor ( refSampleDuration ) ;
}
}
this . _audioNextDts = dts + sampleDuration ;
}
if ( firstDts === - 1 ) {
firstDts = dts ;
}
mp4Samples . push ( {
dts ,
pts : dts ,
cts : 0 ,
unit : sample . unit ,
size : sample . unit . byteLength ,
duration : sampleDuration ,
originalDts ,
flags : {
isLeading : 0 ,
dependsOn : 1 ,
isDependedOn : 0 ,
hasRedundancy : 0
}
} ) ;
if ( needFillSilentFrames ) {
mp4Samples . push . apply ( mp4Samples , silentFrames ) ;
}
}
if ( mp4Samples . length === 0 ) {
track . samples = [ ] ;
track . length = 0 ;
return ;
}
if ( mpegRawTrack ) {
mdatbox = new Uint8Array ( mdatBytes ) ;
} else {
mdatbox = new Uint8Array ( mdatBytes ) ;
mdatbox [ 0 ] = mdatBytes >>> 24 & 255 ;
mdatbox [ 1 ] = mdatBytes >>> 16 & 255 ;
mdatbox [ 2 ] = mdatBytes >>> 8 & 255 ;
mdatbox [ 3 ] = mdatBytes & 255 ;
mdatbox . set ( _mp4 _generator _js _ _WEBPACK _IMPORTED _MODULE _1 _ _ . default . types . mdat , 4 ) ;
}
for ( var i = 0 ; i < mp4Samples . length ; i ++ ) {
var unit = mp4Samples [ i ] . unit ;
mdatbox . set ( unit , offset ) ;
offset += unit . byteLength ;
}
var latest = mp4Samples [ mp4Samples . length - 1 ] ;
lastDts = latest . dts + latest . duration ;
var info = new _core _media _segment _info _js _ _WEBPACK _IMPORTED _MODULE _4 _ _ . MediaSegmentInfo ( ) ;
info . beginDts = firstDts ;
info . endDts = lastDts ;
info . beginPts = firstDts ;
info . endPts = lastDts ;
info . originalBeginDts = mp4Samples [ 0 ] . originalDts ;
info . originalEndDts = latest . originalDts + latest . duration ;
info . firstSample = new _core _media _segment _info _js _ _WEBPACK _IMPORTED _MODULE _4 _ _ . SampleInfo ( mp4Samples [ 0 ] . dts , mp4Samples [ 0 ] . pts , mp4Samples [ 0 ] . duration , mp4Samples [ 0 ] . originalDts , false ) ;
info . lastSample = new _core _media _segment _info _js _ _WEBPACK _IMPORTED _MODULE _4 _ _ . SampleInfo ( latest . dts , latest . pts , latest . duration , latest . originalDts , false ) ;
if ( ! this . _isLive ) {
this . _audioSegmentInfoList . append ( info ) ;
}
track . samples = mp4Samples ;
track . sequenceNumber ++ ;
var moofbox = null ;
if ( mpegRawTrack ) {
moofbox = new Uint8Array ( ) ;
} else {
moofbox = _mp4 _generator _js _ _WEBPACK _IMPORTED _MODULE _1 _ _ . default . moof ( track , firstDts ) ;
}
track . samples = [ ] ;
track . length = 0 ;
var segment = {
type : "audio" ,
data : this . _mergeBoxes ( moofbox , mdatbox ) . buffer ,
sampleCount : mp4Samples . length ,
info
} ;
if ( mpegRawTrack && firstSegmentAfterSeek ) {
segment . timestampOffset = firstDts ;
}
this . _onMediaSegment ( "audio" , segment ) ;
} ;
MP4Remuxer2 . prototype . _remuxVideo = function ( videoTrack , force ) {
if ( this . _videoMeta == null ) {
return ;
}
var track = videoTrack ;
var samples = track . samples ;
var dtsCorrection = void 0 ;
var firstDts = - 1 , lastDts = - 1 ;
var firstPts = - 1 , lastPts = - 1 ;
if ( ! samples || samples . length === 0 ) {
return ;
}
if ( samples . length === 1 && ! force ) {
return ;
}
var offset = 8 ;
var mdatbox = null ;
var mdatBytes = 8 + videoTrack . length ;
var lastSample = null ;
if ( samples . length > 1 ) {
lastSample = samples . pop ( ) ;
mdatBytes -= lastSample . length ;
}
if ( this . _videoStashedLastSample != null ) {
var sample = this . _videoStashedLastSample ;
this . _videoStashedLastSample = null ;
samples . unshift ( sample ) ;
mdatBytes += sample . length ;
}
if ( lastSample != null ) {
this . _videoStashedLastSample = lastSample ;
}
var firstSampleOriginalDts = samples [ 0 ] . dts - this . _dtsBase ;
if ( this . _videoNextDts ) {
dtsCorrection = firstSampleOriginalDts - this . _videoNextDts ;
} else {
if ( this . _videoSegmentInfoList . isEmpty ( ) ) {
dtsCorrection = 0 ;
} else {
var lastSample _2 = this . _videoSegmentInfoList . getLastSampleBefore ( firstSampleOriginalDts ) ;
if ( lastSample _2 != null ) {
var distance = firstSampleOriginalDts - ( lastSample _2 . originalDts + lastSample _2 . duration ) ;
if ( distance <= 3 ) {
distance = 0 ;
}
var expectedDts = lastSample _2 . dts + lastSample _2 . duration + distance ;
dtsCorrection = firstSampleOriginalDts - expectedDts ;
} else {
dtsCorrection = 0 ;
}
}
}
var info = new _core _media _segment _info _js _ _WEBPACK _IMPORTED _MODULE _4 _ _ . MediaSegmentInfo ( ) ;
var mp4Samples = [ ] ;
for ( var i = 0 ; i < samples . length ; i ++ ) {
var sample = samples [ i ] ;
var originalDts = sample . dts - this . _dtsBase ;
var isKeyframe = sample . isKeyframe ;
var dts = originalDts - dtsCorrection ;
var cts = sample . cts ;
var pts = dts + cts ;
if ( firstDts === - 1 ) {
firstDts = dts ;
firstPts = pts ;
}
var sampleDuration = 0 ;
if ( i !== samples . length - 1 ) {
var nextDts = samples [ i + 1 ] . dts - this . _dtsBase - dtsCorrection ;
sampleDuration = nextDts - dts ;
} else {
if ( lastSample != null ) {
var nextDts = lastSample . dts - this . _dtsBase - dtsCorrection ;
sampleDuration = nextDts - dts ;
} else if ( mp4Samples . length >= 1 ) {
sampleDuration = mp4Samples [ mp4Samples . length - 1 ] . duration ;
} else {
sampleDuration = Math . floor ( this . _videoMeta . refSampleDuration ) ;
}
}
if ( isKeyframe ) {
var syncPoint = new _core _media _segment _info _js _ _WEBPACK _IMPORTED _MODULE _4 _ _ . SampleInfo ( dts , pts , sampleDuration , sample . dts , true ) ;
syncPoint . fileposition = sample . fileposition ;
info . appendSyncPoint ( syncPoint ) ;
}
mp4Samples . push ( {
dts ,
pts ,
cts ,
units : sample . units ,
size : sample . length ,
isKeyframe ,
duration : sampleDuration ,
originalDts ,
flags : {
isLeading : 0 ,
dependsOn : isKeyframe ? 2 : 1 ,
isDependedOn : isKeyframe ? 1 : 0 ,
hasRedundancy : 0 ,
isNonSync : isKeyframe ? 0 : 1
}
} ) ;
}
mdatbox = new Uint8Array ( mdatBytes ) ;
mdatbox [ 0 ] = mdatBytes >>> 24 & 255 ;
mdatbox [ 1 ] = mdatBytes >>> 16 & 255 ;
mdatbox [ 2 ] = mdatBytes >>> 8 & 255 ;
mdatbox [ 3 ] = mdatBytes & 255 ;
mdatbox . set ( _mp4 _generator _js _ _WEBPACK _IMPORTED _MODULE _1 _ _ . default . types . mdat , 4 ) ;
for ( var i = 0 ; i < mp4Samples . length ; i ++ ) {
var units = mp4Samples [ i ] . units ;
while ( units . length ) {
var unit = units . shift ( ) ;
var data = unit . data ;
mdatbox . set ( data , offset ) ;
offset += data . byteLength ;
}
}
var latest = mp4Samples [ mp4Samples . length - 1 ] ;
lastDts = latest . dts + latest . duration ;
lastPts = latest . pts + latest . duration ;
this . _videoNextDts = lastDts ;
info . beginDts = firstDts ;
info . endDts = lastDts ;
info . beginPts = firstPts ;
info . endPts = lastPts ;
info . originalBeginDts = mp4Samples [ 0 ] . originalDts ;
info . originalEndDts = latest . originalDts + latest . duration ;
info . firstSample = new _core _media _segment _info _js _ _WEBPACK _IMPORTED _MODULE _4 _ _ . SampleInfo ( mp4Samples [ 0 ] . dts , mp4Samples [ 0 ] . pts , mp4Samples [ 0 ] . duration , mp4Samples [ 0 ] . originalDts , mp4Samples [ 0 ] . isKeyframe ) ;
info . lastSample = new _core _media _segment _info _js _ _WEBPACK _IMPORTED _MODULE _4 _ _ . SampleInfo ( latest . dts , latest . pts , latest . duration , latest . originalDts , latest . isKeyframe ) ;
if ( ! this . _isLive ) {
this . _videoSegmentInfoList . append ( info ) ;
}
track . samples = mp4Samples ;
track . sequenceNumber ++ ;
if ( this . _forceFirstIDR ) {
var flags = mp4Samples [ 0 ] . flags ;
flags . dependsOn = 2 ;
flags . isNonSync = 0 ;
}
var moofbox = _mp4 _generator _js _ _WEBPACK _IMPORTED _MODULE _1 _ _ . default . moof ( track , firstDts ) ;
track . samples = [ ] ;
track . length = 0 ;
this . _onMediaSegment ( "video" , {
type : "video" ,
data : this . _mergeBoxes ( moofbox , mdatbox ) . buffer ,
sampleCount : mp4Samples . length ,
info
} ) ;
} ;
MP4Remuxer2 . prototype . _mergeBoxes = function ( moof , mdat ) {
var result = new Uint8Array ( moof . byteLength + mdat . byteLength ) ;
result . set ( moof , 0 ) ;
result . set ( mdat , moof . byteLength ) ;
return result ;
} ;
return MP4Remuxer2 ;
} ( ) ;
_ _webpack _exports _ _2 [ "default" ] = MP4Remuxer ;
} ,
"./src/utils/browser.js" : function ( _ _unused _webpack _module , _ _webpack _exports _ _2 , _ _webpack _require _ _2 ) {
"use strict" ;
_ _webpack _require _ _2 . r ( _ _webpack _exports _ _2 ) ;
var Browser = { } ;
function detect ( ) {
var ua = self . navigator . userAgent . toLowerCase ( ) ;
var match = /(edge)\/([\w.]+)/ . exec ( ua ) || /(opr)[\/]([\w.]+)/ . exec ( ua ) || /(chrome)[ \/]([\w.]+)/ . exec ( ua ) || /(iemobile)[\/]([\w.]+)/ . exec ( ua ) || /(version)(applewebkit)[ \/]([\w.]+).*(safari)[ \/]([\w.]+)/ . exec ( ua ) || /(webkit)[ \/]([\w.]+).*(version)[ \/]([\w.]+).*(safari)[ \/]([\w.]+)/ . exec ( ua ) || /(webkit)[ \/]([\w.]+)/ . exec ( ua ) || /(opera)(?:.*version|)[ \/]([\w.]+)/ . exec ( ua ) || /(msie) ([\w.]+)/ . exec ( ua ) || ua . indexOf ( "trident" ) >= 0 && /(rv)(?::| )([\w.]+)/ . exec ( ua ) || ua . indexOf ( "compatible" ) < 0 && /(firefox)[ \/]([\w.]+)/ . exec ( ua ) || [ ] ;
var platform _match = /(ipad)/ . exec ( ua ) || /(ipod)/ . exec ( ua ) || /(windows phone)/ . exec ( ua ) || /(iphone)/ . exec ( ua ) || /(kindle)/ . exec ( ua ) || /(android)/ . exec ( ua ) || /(windows)/ . exec ( ua ) || /(mac)/ . exec ( ua ) || /(linux)/ . exec ( ua ) || /(cros)/ . exec ( ua ) || [ ] ;
var matched = {
browser : match [ 5 ] || match [ 3 ] || match [ 1 ] || "" ,
version : match [ 2 ] || match [ 4 ] || "0" ,
majorVersion : match [ 4 ] || match [ 2 ] || "0" ,
platform : platform _match [ 0 ] || ""
} ;
var browser = { } ;
if ( matched . browser ) {
browser [ matched . browser ] = true ;
var versionArray = matched . majorVersion . split ( "." ) ;
browser . version = {
major : parseInt ( matched . majorVersion , 10 ) ,
string : matched . version
} ;
if ( versionArray . length > 1 ) {
browser . version . minor = parseInt ( versionArray [ 1 ] , 10 ) ;
}
if ( versionArray . length > 2 ) {
browser . version . build = parseInt ( versionArray [ 2 ] , 10 ) ;
}
}
if ( matched . platform ) {
browser [ matched . platform ] = true ;
}
if ( browser . chrome || browser . opr || browser . safari ) {
browser . webkit = true ;
}
if ( browser . rv || browser . iemobile ) {
if ( browser . rv ) {
delete browser . rv ;
}
var msie = "msie" ;
matched . browser = msie ;
browser [ msie ] = true ;
}
if ( browser . edge ) {
delete browser . edge ;
var msedge = "msedge" ;
matched . browser = msedge ;
browser [ msedge ] = true ;
}
if ( browser . opr ) {
var opera = "opera" ;
matched . browser = opera ;
browser [ opera ] = true ;
}
if ( browser . safari && browser . android ) {
var android = "android" ;
matched . browser = android ;
browser [ android ] = true ;
}
browser . name = matched . browser ;
browser . platform = matched . platform ;
for ( var key in Browser ) {
if ( Browser . hasOwnProperty ( key ) ) {
delete Browser [ key ] ;
}
}
Object . assign ( Browser , browser ) ;
}
detect ( ) ;
_ _webpack _exports _ _2 [ "default" ] = Browser ;
} ,
"./src/utils/exception.js" : function ( _ _unused _webpack _module , _ _webpack _exports _ _2 , _ _webpack _require _ _2 ) {
"use strict" ;
_ _webpack _require _ _2 . r ( _ _webpack _exports _ _2 ) ;
_ _webpack _require _ _2 . d ( _ _webpack _exports _ _2 , {
"RuntimeException" : function ( ) {
return RuntimeException ;
} ,
"IllegalStateException" : function ( ) {
return IllegalStateException ;
} ,
"InvalidArgumentException" : function ( ) {
return InvalidArgumentException ;
} ,
"NotImplementedException" : function ( ) {
return NotImplementedException ;
}
} ) ;
var _ _extends = function ( ) {
var extendStatics = function ( d , b ) {
extendStatics = Object . setPrototypeOf || { _ _proto _ _ : [ ] } instanceof Array && function ( d2 , b2 ) {
d2 . _ _proto _ _ = b2 ;
} || function ( d2 , b2 ) {
for ( var p in b2 )
if ( Object . prototype . hasOwnProperty . call ( b2 , p ) )
d2 [ p ] = b2 [ p ] ;
} ;
return extendStatics ( d , b ) ;
} ;
return function ( d , b ) {
if ( typeof b !== "function" && b !== null )
throw new TypeError ( "Class extends value " + String ( b ) + " is not a constructor or null" ) ;
extendStatics ( d , b ) ;
function _ _ ( ) {
this . constructor = d ;
}
d . prototype = b === null ? Object . create ( b ) : ( _ _ . prototype = b . prototype , new _ _ ( ) ) ;
} ;
} ( ) ;
var RuntimeException = function ( ) {
function RuntimeException2 ( message ) {
this . _message = message ;
}
Object . defineProperty ( RuntimeException2 . prototype , "name" , {
get : function ( ) {
return "RuntimeException" ;
} ,
enumerable : false ,
configurable : true
} ) ;
Object . defineProperty ( RuntimeException2 . prototype , "message" , {
get : function ( ) {
return this . _message ;
} ,
enumerable : false ,
configurable : true
} ) ;
RuntimeException2 . prototype . toString = function ( ) {
return this . name + ": " + this . message ;
} ;
return RuntimeException2 ;
} ( ) ;
var IllegalStateException = function ( _super ) {
_ _extends ( IllegalStateException2 , _super ) ;
function IllegalStateException2 ( message ) {
return _super . call ( this , message ) || this ;
}
Object . defineProperty ( IllegalStateException2 . prototype , "name" , {
get : function ( ) {
return "IllegalStateException" ;
} ,
enumerable : false ,
configurable : true
} ) ;
return IllegalStateException2 ;
} ( RuntimeException ) ;
var InvalidArgumentException = function ( _super ) {
_ _extends ( InvalidArgumentException2 , _super ) ;
function InvalidArgumentException2 ( message ) {
return _super . call ( this , message ) || this ;
}
Object . defineProperty ( InvalidArgumentException2 . prototype , "name" , {
get : function ( ) {
return "InvalidArgumentException" ;
} ,
enumerable : false ,
configurable : true
} ) ;
return InvalidArgumentException2 ;
} ( RuntimeException ) ;
var NotImplementedException = function ( _super ) {
_ _extends ( NotImplementedException2 , _super ) ;
function NotImplementedException2 ( message ) {
return _super . call ( this , message ) || this ;
}
Object . defineProperty ( NotImplementedException2 . prototype , "name" , {
get : function ( ) {
return "NotImplementedException" ;
} ,
enumerable : false ,
configurable : true
} ) ;
return NotImplementedException2 ;
} ( RuntimeException ) ;
} ,
"./src/utils/logger.js" : function ( _ _unused _webpack _module , _ _webpack _exports _ _2 , _ _webpack _require _ _2 ) {
"use strict" ;
_ _webpack _require _ _2 . r ( _ _webpack _exports _ _2 ) ;
var events _ _WEBPACK _IMPORTED _MODULE _0 _ _ = _ _webpack _require _ _2 ( "./node_modules/events/events.js" ) ;
var events _ _WEBPACK _IMPORTED _MODULE _0 _ _ _default = _ _webpack _require _ _2 . n ( events _ _WEBPACK _IMPORTED _MODULE _0 _ _ ) ;
var Log = function ( ) {
function Log2 ( ) {
}
Log2 . e = function ( tag , msg ) {
if ( ! tag || Log2 . FORCE _GLOBAL _TAG )
tag = Log2 . GLOBAL _TAG ;
var str = "[" + tag + "] > " + msg ;
if ( Log2 . ENABLE _CALLBACK ) {
Log2 . emitter . emit ( "log" , "error" , str ) ;
}
if ( ! Log2 . ENABLE _ERROR ) {
return ;
}
if ( console . error ) {
console . error ( str ) ;
} else if ( console . warn ) {
console . warn ( str ) ;
} else {
console . log ( str ) ;
}
} ;
Log2 . i = function ( tag , msg ) {
if ( ! tag || Log2 . FORCE _GLOBAL _TAG )
tag = Log2 . GLOBAL _TAG ;
var str = "[" + tag + "] > " + msg ;
if ( Log2 . ENABLE _CALLBACK ) {
Log2 . emitter . emit ( "log" , "info" , str ) ;
}
if ( ! Log2 . ENABLE _INFO ) {
return ;
}
if ( console . info ) {
console . info ( str ) ;
} else {
console . log ( str ) ;
}
} ;
Log2 . w = function ( tag , msg ) {
if ( ! tag || Log2 . FORCE _GLOBAL _TAG )
tag = Log2 . GLOBAL _TAG ;
var str = "[" + tag + "] > " + msg ;
if ( Log2 . ENABLE _CALLBACK ) {
Log2 . emitter . emit ( "log" , "warn" , str ) ;
}
if ( ! Log2 . ENABLE _WARN ) {
return ;
}
if ( console . warn ) {
console . warn ( str ) ;
} else {
console . log ( str ) ;
}
} ;
Log2 . d = function ( tag , msg ) {
if ( ! tag || Log2 . FORCE _GLOBAL _TAG )
tag = Log2 . GLOBAL _TAG ;
var str = "[" + tag + "] > " + msg ;
if ( Log2 . ENABLE _CALLBACK ) {
Log2 . emitter . emit ( "log" , "debug" , str ) ;
}
if ( ! Log2 . ENABLE _DEBUG ) {
return ;
}
if ( console . debug ) {
console . debug ( str ) ;
} else {
console . log ( str ) ;
}
} ;
Log2 . v = function ( tag , msg ) {
if ( ! tag || Log2 . FORCE _GLOBAL _TAG )
tag = Log2 . GLOBAL _TAG ;
var str = "[" + tag + "] > " + msg ;
if ( Log2 . ENABLE _CALLBACK ) {
Log2 . emitter . emit ( "log" , "verbose" , str ) ;
}
if ( ! Log2 . ENABLE _VERBOSE ) {
return ;
}
console . log ( str ) ;
} ;
return Log2 ;
} ( ) ;
Log . GLOBAL _TAG = "flv.js" ;
Log . FORCE _GLOBAL _TAG = false ;
Log . ENABLE _ERROR = true ;
Log . ENABLE _INFO = true ;
Log . ENABLE _WARN = true ;
Log . ENABLE _DEBUG = true ;
Log . ENABLE _VERBOSE = true ;
Log . ENABLE _CALLBACK = false ;
Log . emitter = new ( events _ _WEBPACK _IMPORTED _MODULE _0 _ _ _default ( ) ) ( ) ;
_ _webpack _exports _ _2 [ "default" ] = Log ;
} ,
"./src/utils/logging-control.js" : function ( _ _unused _webpack _module , _ _webpack _exports _ _2 , _ _webpack _require _ _2 ) {
"use strict" ;
_ _webpack _require _ _2 . r ( _ _webpack _exports _ _2 ) ;
var events _ _WEBPACK _IMPORTED _MODULE _0 _ _ = _ _webpack _require _ _2 ( "./node_modules/events/events.js" ) ;
var events _ _WEBPACK _IMPORTED _MODULE _0 _ _ _default = _ _webpack _require _ _2 . n ( events _ _WEBPACK _IMPORTED _MODULE _0 _ _ ) ;
var _logger _js _ _WEBPACK _IMPORTED _MODULE _1 _ _ = _ _webpack _require _ _2 ( "./src/utils/logger.js" ) ;
var LoggingControl = function ( ) {
function LoggingControl2 ( ) {
}
Object . defineProperty ( LoggingControl2 , "forceGlobalTag" , {
get : function ( ) {
return _logger _js _ _WEBPACK _IMPORTED _MODULE _1 _ _ . default . FORCE _GLOBAL _TAG ;
} ,
set : function ( enable ) {
_logger _js _ _WEBPACK _IMPORTED _MODULE _1 _ _ . default . FORCE _GLOBAL _TAG = enable ;
LoggingControl2 . _notifyChange ( ) ;
} ,
enumerable : false ,
configurable : true
} ) ;
Object . defineProperty ( LoggingControl2 , "globalTag" , {
get : function ( ) {
return _logger _js _ _WEBPACK _IMPORTED _MODULE _1 _ _ . default . GLOBAL _TAG ;
} ,
set : function ( tag ) {
_logger _js _ _WEBPACK _IMPORTED _MODULE _1 _ _ . default . GLOBAL _TAG = tag ;
LoggingControl2 . _notifyChange ( ) ;
} ,
enumerable : false ,
configurable : true
} ) ;
Object . defineProperty ( LoggingControl2 , "enableAll" , {
get : function ( ) {
return _logger _js _ _WEBPACK _IMPORTED _MODULE _1 _ _ . default . ENABLE _VERBOSE && _logger _js _ _WEBPACK _IMPORTED _MODULE _1 _ _ . default . ENABLE _DEBUG && _logger _js _ _WEBPACK _IMPORTED _MODULE _1 _ _ . default . ENABLE _INFO && _logger _js _ _WEBPACK _IMPORTED _MODULE _1 _ _ . default . ENABLE _WARN && _logger _js _ _WEBPACK _IMPORTED _MODULE _1 _ _ . default . ENABLE _ERROR ;
} ,
set : function ( enable ) {
_logger _js _ _WEBPACK _IMPORTED _MODULE _1 _ _ . default . ENABLE _VERBOSE = enable ;
_logger _js _ _WEBPACK _IMPORTED _MODULE _1 _ _ . default . ENABLE _DEBUG = enable ;
_logger _js _ _WEBPACK _IMPORTED _MODULE _1 _ _ . default . ENABLE _INFO = enable ;
_logger _js _ _WEBPACK _IMPORTED _MODULE _1 _ _ . default . ENABLE _WARN = enable ;
_logger _js _ _WEBPACK _IMPORTED _MODULE _1 _ _ . default . ENABLE _ERROR = enable ;
LoggingControl2 . _notifyChange ( ) ;
} ,
enumerable : false ,
configurable : true
} ) ;
Object . defineProperty ( LoggingControl2 , "enableDebug" , {
get : function ( ) {
return _logger _js _ _WEBPACK _IMPORTED _MODULE _1 _ _ . default . ENABLE _DEBUG ;
} ,
set : function ( enable ) {
_logger _js _ _WEBPACK _IMPORTED _MODULE _1 _ _ . default . ENABLE _DEBUG = enable ;
LoggingControl2 . _notifyChange ( ) ;
} ,
enumerable : false ,
configurable : true
} ) ;
Object . defineProperty ( LoggingControl2 , "enableVerbose" , {
get : function ( ) {
return _logger _js _ _WEBPACK _IMPORTED _MODULE _1 _ _ . default . ENABLE _VERBOSE ;
} ,
set : function ( enable ) {
_logger _js _ _WEBPACK _IMPORTED _MODULE _1 _ _ . default . ENABLE _VERBOSE = enable ;
LoggingControl2 . _notifyChange ( ) ;
} ,
enumerable : false ,
configurable : true
} ) ;
Object . defineProperty ( LoggingControl2 , "enableInfo" , {
get : function ( ) {
return _logger _js _ _WEBPACK _IMPORTED _MODULE _1 _ _ . default . ENABLE _INFO ;
} ,
set : function ( enable ) {
_logger _js _ _WEBPACK _IMPORTED _MODULE _1 _ _ . default . ENABLE _INFO = enable ;
LoggingControl2 . _notifyChange ( ) ;
} ,
enumerable : false ,
configurable : true
} ) ;
Object . defineProperty ( LoggingControl2 , "enableWarn" , {
get : function ( ) {
return _logger _js _ _WEBPACK _IMPORTED _MODULE _1 _ _ . default . ENABLE _WARN ;
} ,
set : function ( enable ) {
_logger _js _ _WEBPACK _IMPORTED _MODULE _1 _ _ . default . ENABLE _WARN = enable ;
LoggingControl2 . _notifyChange ( ) ;
} ,
enumerable : false ,
configurable : true
} ) ;
Object . defineProperty ( LoggingControl2 , "enableError" , {
get : function ( ) {
return _logger _js _ _WEBPACK _IMPORTED _MODULE _1 _ _ . default . ENABLE _ERROR ;
} ,
set : function ( enable ) {
_logger _js _ _WEBPACK _IMPORTED _MODULE _1 _ _ . default . ENABLE _ERROR = enable ;
LoggingControl2 . _notifyChange ( ) ;
} ,
enumerable : false ,
configurable : true
} ) ;
LoggingControl2 . getConfig = function ( ) {
return {
globalTag : _logger _js _ _WEBPACK _IMPORTED _MODULE _1 _ _ . default . GLOBAL _TAG ,
forceGlobalTag : _logger _js _ _WEBPACK _IMPORTED _MODULE _1 _ _ . default . FORCE _GLOBAL _TAG ,
enableVerbose : _logger _js _ _WEBPACK _IMPORTED _MODULE _1 _ _ . default . ENABLE _VERBOSE ,
enableDebug : _logger _js _ _WEBPACK _IMPORTED _MODULE _1 _ _ . default . ENABLE _DEBUG ,
enableInfo : _logger _js _ _WEBPACK _IMPORTED _MODULE _1 _ _ . default . ENABLE _INFO ,
enableWarn : _logger _js _ _WEBPACK _IMPORTED _MODULE _1 _ _ . default . ENABLE _WARN ,
enableError : _logger _js _ _WEBPACK _IMPORTED _MODULE _1 _ _ . default . ENABLE _ERROR ,
enableCallback : _logger _js _ _WEBPACK _IMPORTED _MODULE _1 _ _ . default . ENABLE _CALLBACK
} ;
} ;
LoggingControl2 . applyConfig = function ( config ) {
_logger _js _ _WEBPACK _IMPORTED _MODULE _1 _ _ . default . GLOBAL _TAG = config . globalTag ;
_logger _js _ _WEBPACK _IMPORTED _MODULE _1 _ _ . default . FORCE _GLOBAL _TAG = config . forceGlobalTag ;
_logger _js _ _WEBPACK _IMPORTED _MODULE _1 _ _ . default . ENABLE _VERBOSE = config . enableVerbose ;
_logger _js _ _WEBPACK _IMPORTED _MODULE _1 _ _ . default . ENABLE _DEBUG = config . enableDebug ;
_logger _js _ _WEBPACK _IMPORTED _MODULE _1 _ _ . default . ENABLE _INFO = config . enableInfo ;
_logger _js _ _WEBPACK _IMPORTED _MODULE _1 _ _ . default . ENABLE _WARN = config . enableWarn ;
_logger _js _ _WEBPACK _IMPORTED _MODULE _1 _ _ . default . ENABLE _ERROR = config . enableError ;
_logger _js _ _WEBPACK _IMPORTED _MODULE _1 _ _ . default . ENABLE _CALLBACK = config . enableCallback ;
} ;
LoggingControl2 . _notifyChange = function ( ) {
var emitter = LoggingControl2 . emitter ;
if ( emitter . listenerCount ( "change" ) > 0 ) {
var config = LoggingControl2 . getConfig ( ) ;
emitter . emit ( "change" , config ) ;
}
} ;
LoggingControl2 . registerListener = function ( listener ) {
LoggingControl2 . emitter . addListener ( "change" , listener ) ;
} ;
LoggingControl2 . removeListener = function ( listener ) {
LoggingControl2 . emitter . removeListener ( "change" , listener ) ;
} ;
LoggingControl2 . addLogListener = function ( listener ) {
_logger _js _ _WEBPACK _IMPORTED _MODULE _1 _ _ . default . emitter . addListener ( "log" , listener ) ;
if ( _logger _js _ _WEBPACK _IMPORTED _MODULE _1 _ _ . default . emitter . listenerCount ( "log" ) > 0 ) {
_logger _js _ _WEBPACK _IMPORTED _MODULE _1 _ _ . default . ENABLE _CALLBACK = true ;
LoggingControl2 . _notifyChange ( ) ;
}
} ;
LoggingControl2 . removeLogListener = function ( listener ) {
_logger _js _ _WEBPACK _IMPORTED _MODULE _1 _ _ . default . emitter . removeListener ( "log" , listener ) ;
if ( _logger _js _ _WEBPACK _IMPORTED _MODULE _1 _ _ . default . emitter . listenerCount ( "log" ) === 0 ) {
_logger _js _ _WEBPACK _IMPORTED _MODULE _1 _ _ . default . ENABLE _CALLBACK = false ;
LoggingControl2 . _notifyChange ( ) ;
}
} ;
return LoggingControl2 ;
} ( ) ;
LoggingControl . emitter = new ( events _ _WEBPACK _IMPORTED _MODULE _0 _ _ _default ( ) ) ( ) ;
_ _webpack _exports _ _2 [ "default" ] = LoggingControl ;
} ,
"./src/utils/polyfill.js" : function ( _ _unused _webpack _module , _ _webpack _exports _ _2 , _ _webpack _require _ _2 ) {
"use strict" ;
_ _webpack _require _ _2 . r ( _ _webpack _exports _ _2 ) ;
var Polyfill = function ( ) {
function Polyfill2 ( ) {
}
Polyfill2 . install = function ( ) {
Object . setPrototypeOf = Object . setPrototypeOf || function ( obj , proto ) {
obj . _ _proto _ _ = proto ;
return obj ;
} ;
Object . assign = Object . assign || function ( target ) {
if ( target === void 0 || target === null ) {
throw new TypeError ( "Cannot convert undefined or null to object" ) ;
}
var output = Object ( target ) ;
for ( var i = 1 ; i < arguments . length ; i ++ ) {
var source = arguments [ i ] ;
if ( source !== void 0 && source !== null ) {
for ( var key in source ) {
if ( source . hasOwnProperty ( key ) ) {
output [ key ] = source [ key ] ;
}
}
}
}
return output ;
} ;
if ( typeof self . Promise !== "function" ) {
_ _webpack _require _ _2 ( "./node_modules/es6-promise/dist/es6-promise.js" ) . polyfill ( ) ;
}
} ;
return Polyfill2 ;
} ( ) ;
Polyfill . install ( ) ;
_ _webpack _exports _ _2 [ "default" ] = Polyfill ;
} ,
"./src/utils/utf8-conv.js" : function ( _ _unused _webpack _module , _ _webpack _exports _ _2 , _ _webpack _require _ _2 ) {
"use strict" ;
_ _webpack _require _ _2 . r ( _ _webpack _exports _ _2 ) ;
function checkContinuation ( uint8array , start , checkLength ) {
var array = uint8array ;
if ( start + checkLength < array . length ) {
while ( checkLength -- ) {
if ( ( array [ ++ start ] & 192 ) !== 128 )
return false ;
}
return true ;
} else {
return false ;
}
}
function decodeUTF8 ( uint8array ) {
var out = [ ] ;
var input = uint8array ;
var i = 0 ;
var length = uint8array . length ;
while ( i < length ) {
if ( input [ i ] < 128 ) {
out . push ( String . fromCharCode ( input [ i ] ) ) ;
++ i ;
continue ;
} else if ( input [ i ] < 192 ) {
} else if ( input [ i ] < 224 ) {
if ( checkContinuation ( input , i , 1 ) ) {
var ucs4 = ( input [ i ] & 31 ) << 6 | input [ i + 1 ] & 63 ;
if ( ucs4 >= 128 ) {
out . push ( String . fromCharCode ( ucs4 & 65535 ) ) ;
i += 2 ;
continue ;
}
}
} else if ( input [ i ] < 240 ) {
if ( checkContinuation ( input , i , 2 ) ) {
var ucs4 = ( input [ i ] & 15 ) << 12 | ( input [ i + 1 ] & 63 ) << 6 | input [ i + 2 ] & 63 ;
if ( ucs4 >= 2048 && ( ucs4 & 63488 ) !== 55296 ) {
out . push ( String . fromCharCode ( ucs4 & 65535 ) ) ;
i += 3 ;
continue ;
}
}
} else if ( input [ i ] < 248 ) {
if ( checkContinuation ( input , i , 3 ) ) {
var ucs4 = ( input [ i ] & 7 ) << 18 | ( input [ i + 1 ] & 63 ) << 12 | ( input [ i + 2 ] & 63 ) << 6 | input [ i + 3 ] & 63 ;
if ( ucs4 > 65536 && ucs4 < 1114112 ) {
ucs4 -= 65536 ;
out . push ( String . fromCharCode ( ucs4 >>> 10 | 55296 ) ) ;
out . push ( String . fromCharCode ( ucs4 & 1023 | 56320 ) ) ;
i += 4 ;
continue ;
}
}
}
out . push ( String . fromCharCode ( 65533 ) ) ;
++ i ;
}
return out . join ( "" ) ;
}
_ _webpack _exports _ _2 [ "default" ] = decodeUTF8 ;
}
} ;
var _ _webpack _module _cache _ _ = { } ;
function _ _webpack _require _ _ ( moduleId ) {
var cachedModule = _ _webpack _module _cache _ _ [ moduleId ] ;
if ( cachedModule !== void 0 ) {
return cachedModule . exports ;
}
var module2 = _ _webpack _module _cache _ _ [ moduleId ] = {
exports : { }
} ;
_ _webpack _modules _ _ [ moduleId ] . call ( module2 . exports , module2 , module2 . exports , _ _webpack _require _ _ ) ;
return module2 . exports ;
}
_ _webpack _require _ _ . m = _ _webpack _modules _ _ ;
! function ( ) {
_ _webpack _require _ _ . n = function ( module2 ) {
var getter = module2 && module2 . _ _esModule ? function ( ) {
return module2 [ "default" ] ;
} : function ( ) {
return module2 ;
} ;
_ _webpack _require _ _ . d ( getter , { a : getter } ) ;
return getter ;
} ;
} ( ) ;
! function ( ) {
_ _webpack _require _ _ . d = function ( exports2 , definition ) {
for ( var key in definition ) {
if ( _ _webpack _require _ _ . o ( definition , key ) && ! _ _webpack _require _ _ . o ( exports2 , key ) ) {
Object . defineProperty ( exports2 , key , { enumerable : true , get : definition [ key ] } ) ;
}
}
} ;
} ( ) ;
! function ( ) {
_ _webpack _require _ _ . g = function ( ) {
if ( typeof globalThis === "object" )
return globalThis ;
try {
return this || new Function ( "return this" ) ( ) ;
} catch ( e ) {
if ( typeof window === "object" )
return window ;
}
} ( ) ;
} ( ) ;
! function ( ) {
_ _webpack _require _ _ . o = function ( obj , prop ) {
return Object . prototype . hasOwnProperty . call ( obj , prop ) ;
} ;
} ( ) ;
! function ( ) {
_ _webpack _require _ _ . r = function ( exports2 ) {
if ( typeof Symbol !== "undefined" && Symbol . toStringTag ) {
Object . defineProperty ( exports2 , Symbol . toStringTag , { value : "Module" } ) ;
}
Object . defineProperty ( exports2 , "__esModule" , { value : true } ) ;
} ;
} ( ) ;
var _ _webpack _exports _ _ = _ _webpack _require _ _ ( "./src/index.js" ) ;
return _ _webpack _exports _ _ ;
} ( ) ;
} ) ;
}
} ) ;
// dep:flv_js
var flv _js _default = require _flv ( ) ;
export {
flv _js _default as default
} ;
/ * !
* @ 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 v4 . 2.8 + 1e68 dce6
* /
//# sourceMappingURL=flv_js.js.map