|
@@ -118,7 +118,7 @@ export class MetaGateway
|
|
|
this.peer.onGatheringStateChange((state) => {
|
|
|
console.log('GatheringState:', state);
|
|
|
});
|
|
|
- this.gameChanel = this.peer.createDataChannel('start-game');
|
|
|
+ this.gameChanel = this.peer.createDataChannel('game-input');
|
|
|
|
|
|
this.peer.onDataChannel((dc) => {
|
|
|
console.log('onDataChannel', dc);
|
|
@@ -127,8 +127,8 @@ export class MetaGateway
|
|
|
this.gameChanel.onOpen(() => {
|
|
|
console.log('channel is open');
|
|
|
clearInterval(this.timer);
|
|
|
- let i = 0;
|
|
|
- const paths = path.join(__dirname, '../ws/video/earth');
|
|
|
+ let i = 1;
|
|
|
+ const paths = path.join(__dirname, '../ws/video/v11');
|
|
|
console.error('__dirname', __dirname);
|
|
|
console.error('paths', paths);
|
|
|
if (this.gameChanel.isOpen()) {
|
|
@@ -136,10 +136,18 @@ export class MetaGateway
|
|
|
this.sendWertcHeartPack(this.gameChanel);
|
|
|
}
|
|
|
this.timer = setInterval(() => {
|
|
|
- if (i < 10) {
|
|
|
- const steam = createReadStream(paths + `/${i}`);
|
|
|
+ if (i < 9) {
|
|
|
+ const steam = createReadStream(paths + `/${i}.h264`);
|
|
|
+ // const steam = createReadStream(paths + `/test2`);
|
|
|
steam.on('data', (data: Buffer) => {
|
|
|
- this.gameChanel.sendMessageBinary(data);
|
|
|
+ // console.log(data.buffer);
|
|
|
+ const frame = new DataView(data.buffer);
|
|
|
+ // frame.setUint32(0, 1437227610);
|
|
|
+ // frame.setUint16(6, 36);
|
|
|
+ // frame.setUint16(24, 0);
|
|
|
+ // frame.setUint16(26, 0);
|
|
|
+ // frame.setUint32(28, 0);
|
|
|
+ this.gameChanel.sendMessageBinary(Buffer.from(frame.buffer));
|
|
|
});
|
|
|
}
|
|
|
i++;
|
|
@@ -149,6 +157,9 @@ export class MetaGateway
|
|
|
console.log('gameChanel close');
|
|
|
this.stopSendWertcHeartPack();
|
|
|
});
|
|
|
+ this.gameChanel.onMessage((event) => {
|
|
|
+ console.log('gameChanel onMessage', event);
|
|
|
+ });
|
|
|
this.gameChanel.onError(() => {
|
|
|
console.log('gameChanel close');
|
|
|
this.stopSendWertcHeartPack();
|
|
@@ -189,7 +200,6 @@ export class MetaGateway
|
|
|
@SubscribeMessage('start')
|
|
|
handlerWebrtcStart(client: any, payload: any) {
|
|
|
console.log('start', payload);
|
|
|
-
|
|
|
}
|
|
|
|
|
|
afterInit(server: Server) {
|