more video streaming fixes
This commit is contained in:
@@ -91,52 +91,26 @@ const proccessData = (
|
||||
if (range) {
|
||||
let bytesSent = 0;
|
||||
|
||||
const skipStream = streamSkip(range.skip);
|
||||
|
||||
const totalData: Buffer[] = [];
|
||||
decipher.on("data", (data: Buffer) => {
|
||||
// console.log("data", data.length);
|
||||
if (bytesSent + data.length > range.chunksize) {
|
||||
const currentDataLength = bytesSent + data.length;
|
||||
const difference = currentDataLength - range.chunksize;
|
||||
const neededData = data.slice(0, data.length - difference);
|
||||
console.log("needed data", data.length - difference);
|
||||
// console.log(
|
||||
// "needed data",
|
||||
// neededData.length,
|
||||
// range.end - range.start,
|
||||
// bytesSent
|
||||
// );
|
||||
res.write(neededData);
|
||||
totalData.push(neededData);
|
||||
} else {
|
||||
res.write(data);
|
||||
totalData.push(data);
|
||||
}
|
||||
//totalData.push(data);
|
||||
|
||||
bytesSent += data.length;
|
||||
});
|
||||
|
||||
readStream.pipe(decipher);
|
||||
// decipher.on("finish", () => {
|
||||
// eventEmitter.emit("finish");
|
||||
// });
|
||||
decipher.on("finish", () => {
|
||||
// console.log("finish", totalData);
|
||||
const buffer = Buffer.concat(totalData);
|
||||
console.log("buffer", buffer.length);
|
||||
// res.write(buffer);
|
||||
res.end();
|
||||
|
||||
eventEmitter.emit("finish");
|
||||
});
|
||||
// readStream
|
||||
// .pipe(decipher)
|
||||
// .pipe(res)
|
||||
// .on("finish", () => {
|
||||
// eventEmitter.emit("finish");
|
||||
// });
|
||||
|
||||
readStream.pipe(decipher);
|
||||
} else {
|
||||
readStream
|
||||
.pipe(decipher)
|
||||
|
||||
Reference in New Issue
Block a user