Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
router.get(/^(.*)\/media-(\d+)\.ts$/, Movie.openMovie, (req, res) => {
let index = parseInt(req.params[1], 10);
if (req.fragmentList.count() < index) {
throw new errors.NotFoundError('Chunk Not Found');
}
let fragment = req.fragmentList.get(index - 1);
let sampleBuffers = VideoLib.FragmentReader.readSamples(fragment, req.file);
let buffer = VideoLib.HLSPacketizer.packetize(fragment, sampleBuffers);
res.header('Content-Type', 'video/MP2T');
if (config.drmEnabled) {
res.send(Movie.encryptChunk(req.params[0], buffer));
} else {
res.send(buffer);
}
});