|
@@ -5,8 +5,18 @@ import { Logger } from '@nestjs/common';
|
|
import { DataChannel } from 'node-datachannel';
|
|
import { DataChannel } from 'node-datachannel';
|
|
import * as path from 'path';
|
|
import * as path from 'path';
|
|
import { statSync, createReadStream } from 'fs';
|
|
import { statSync, createReadStream } from 'fs';
|
|
-import multistream from 'multistream';
|
|
|
|
-import { Readable } from 'stream';
|
|
|
|
|
|
+// import multistream from 'multistream';
|
|
|
|
+import { PassThrough, Readable } from 'stream';
|
|
|
|
+
|
|
|
|
+const MergeSteam = (...streams) => {
|
|
|
|
+ let pass = new PassThrough();
|
|
|
|
+ let waiting = streams.length;
|
|
|
|
+ for (const stream of streams) {
|
|
|
|
+ pass = stream.pipe(pass, { end: false });
|
|
|
|
+ stream.once('end', () => waiting-- === 0 && pass.end());
|
|
|
|
+ }
|
|
|
|
+ return pass;
|
|
|
|
+};
|
|
|
|
|
|
@Injectable()
|
|
@Injectable()
|
|
export class SceneService implements OnModuleInit {
|
|
export class SceneService implements OnModuleInit {
|
|
@@ -174,18 +184,25 @@ export class SceneService implements OnModuleInit {
|
|
|
|
|
|
// const steamTotalSize = metaData.length + steamStat.size;
|
|
// const steamTotalSize = metaData.length + steamStat.size;
|
|
|
|
|
|
-
|
|
|
|
const steam = createReadStream(clipPath, {
|
|
const steam = createReadStream(clipPath, {
|
|
highWaterMark: chunk_size - block,
|
|
highWaterMark: chunk_size - block,
|
|
});
|
|
});
|
|
|
|
+ const steam1 = createReadStream(clipPath);
|
|
|
|
+ const coordBuffSteam = Readable.from(coordBuff.toString());
|
|
|
|
+
|
|
|
|
+ const mergeSteam = MergeSteam(coordBuffSteam, steam1);
|
|
|
|
|
|
- // const mergeSteam = MergeSteam(coordBuff, steam);
|
|
|
|
|
|
+ console.log('mergeSteam', mergeSteam);
|
|
|
|
|
|
let steamByteLength = 0;
|
|
let steamByteLength = 0;
|
|
|
|
|
|
|
|
+ mergeSteam.on('data', (data: Buffer) => {
|
|
|
|
+ console.log('mergeSteam', data);
|
|
|
|
+ });
|
|
|
|
+
|
|
steam.on('data', (data: Buffer) => {
|
|
steam.on('data', (data: Buffer) => {
|
|
// console.log('data', data.byteLength);
|
|
// console.log('data', data.byteLength);
|
|
- console.log('steamStat-size', steamStat.size);
|
|
|
|
|
|
+ console.log('data-size', data);
|
|
const blockBuffStart = Buffer.alloc(block);
|
|
const blockBuffStart = Buffer.alloc(block);
|
|
|
|
|
|
let packBuffer = Buffer.concat([blockBuffStart, data]);
|
|
let packBuffer = Buffer.concat([blockBuffStart, data]);
|