src/simple-thumbnail-generator.js
function SimpleThumbnailGenerator(options, generatorOptions) {
	options = options || {};
	generatorOptions = generatorOptions || {};

	if (!options.manifestFileName) {
		throw new Error("manifestFileName required.");
	}

	if (typeof(options.logger) === "undefined") {
		this._logger = Logger.get('SimpleThumbnailGenerator');
	}
	else {
		if (options.logger === null) {
			this._logger = nullLogger;
		}
		else {
			this._logger = options.logger;
		}
	}
	this._generatorOptions = generatorOptions;
	this._manifestFileName = options.manifestFileName;
	this._expireTime = options.expireTime || 0;
	this._segmentRemovalTimes = {
		// the sn of the first fragment in the array
		offset: null,
		// the times when the corresponding fragments were removed
		times: []
	};
	// {sn, thumbnails, removalTime}
	// thumbnails is array of {time, name}
	this._segments = [];
	this._playlistRemoved = false;
	this._playlistEnded = false;
	this._generator = new ThumbnailGenerator(Object.assign({}, generatorOptions, {
		// if the user doesn't provide a temp directory get a general one
		tempDir: generatorOptions.tempDir || utils.getTempDir()
	}));
	this._gcTimerId = setInterval(this._gc.bind(this), 30000);
	this._emitter = ee({});
	this._registerGeneratorListeners();
	this._updateManifest();
}
function SimpleThumbnailGenerator(options, generatorOptions) {
	options = options || {};
	generatorOptions = generatorOptions || {};

	if (!options.manifestFileName) {
		throw new Error("manifestFileName required.");
	}

	if (typeof(options.logger) === "undefined") {
		this._logger = Logger.get('SimpleThumbnailGenerator');
	}
	else {
		if (options.logger === null) {
			this._logger = nullLogger;
		}
		else {
			this._logger = options.logger;
		}
	}
	this._generatorOptions = generatorOptions;
	this._manifestFileName = options.manifestFileName;
	this._expireTime = options.expireTime || 0;
	this._segmentRemovalTimes = {
		// the sn of the first fragment in the array
		offset: null,
		// the times when the corresponding fragments were removed
		times: []
	};
	// {sn, thumbnails, removalTime}
	// thumbnails is array of {time, name}
	this._segments = [];
	this._playlistRemoved = false;
	this._playlistEnded = false;
	this._generator = new ThumbnailGenerator(Object.assign({}, generatorOptions, {
		// if the user doesn't provide a temp directory get a general one
		tempDir: generatorOptions.tempDir || utils.getTempDir()
	}));
	this._gcTimerId = setInterval(this._gc.bind(this), 30000);
	this._emitter = ee({});
	this._registerGeneratorListeners();
	this._updateManifest();
}
function SimpleThumbnailGenerator ( options , generatorOptions ) { options = options || { } ; generatorOptions = generatorOptions || { } ; if ( ! options . manifestFileName ) { throw new Error ( "manifestFileName required." ) ; } if ( typeof ( options . logger ) === "undefined" ) { this . _logger = Logger . get ( 'SimpleThumbnailGenerator' ) ; } else { if ( options . logger === null ) { this . _logger = nullLogger ; } else { this . _logger = options . logger ; } } this . _generatorOptions = generatorOptions ; this . _manifestFileName = options . manifestFileName ; this . _expireTime = options . expireTime || 0 ; this . _segmentRemovalTimes = { // the sn of the first fragment in the array offset : null , // the times when the corresponding fragments were removed times : [ ] } ; // {sn, thumbnails, removalTime} // thumbnails is array of {time, name} this . _segments = [ ] ; this . _playlistRemoved = false ; this . _playlistEnded = false ; this . _generator = new ThumbnailGenerator ( Object . assign ( { } , generatorOptions , { // if the user doesn't provide a temp directory get a general one tempDir : generatorOptions . tempDir || utils . getTempDir ( ) } ) ) ; this . _gcTimerId = setInterval ( this . _gc . bind ( this ) , 30000 ) ; this . _emitter = ee ( { } ) ; this . _registerGeneratorListeners ( ) ; this . _updateManifest ( ) ; }
Starts generating the thumbnails using the configuration in `generatorOptions`.
Removes thumbnails when they their segments are removed from the playlist after `expireTime` seconds.
@constructor
@param {String} options.manifestFileName The name for the manifest file.
@param {Object} options The time in seconds to keep thumbnails for before deleting them, once their segments have left the playlist. Defaults to 0.
@param {Number} [options.expireTime] The time in seconds to keep thumbnails for before deleting them, once their segments have left the playlist. Defaults to 0.
@param {Number} [options.logger] An object with `debug`, `info`, `warn` and `error` functions, or null, to disable logging.
@param {Object} [generatorOptions] Configuraton for `ThumbnailGenerator`.
Starts generating the thumbnails using the configuration in generatorOptions . Removes thumbnails when they their segments are removed from the playlist after expireTime seconds .