|
@@ -2,7 +2,7 @@ import { Injectable, OnModuleDestroy, OnModuleInit } from '@nestjs/common';
|
|
|
import { ClientGrpc, Client } from '@nestjs/microservices';
|
|
|
import { grpcClientOptions } from './grpc-scene.options';
|
|
|
import { Logger } from '@nestjs/common';
|
|
|
-import { DataChannel } from 'node-datachannel';
|
|
|
+import { DataChannel, PeerConnection } from 'node-datachannel';
|
|
|
import { BehaviorSubject } from 'rxjs';
|
|
|
// import * as streamBuffers from 'stream-buffers';
|
|
|
import { ActionType } from './actionType';
|
|
@@ -16,7 +16,6 @@ import { DelayQueue, RxQueue, DebounceQueue } from '../queue/mod';
|
|
|
import { MoveService } from 'src/move/move.service';
|
|
|
import { GetRouterService } from 'src/get-router/get-router.service';
|
|
|
import { ConfigService } from '@nestjs/config';
|
|
|
-import { join } from 'path';
|
|
|
|
|
|
@Injectable()
|
|
|
export class SceneService implements OnModuleInit, OnModuleDestroy {
|
|
@@ -27,7 +26,7 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
|
|
|
private rotateService: RotateService,
|
|
|
private moveService: MoveService,
|
|
|
private getRouterService: GetRouterService, // @InjectQueue('rotate') private rotateQueue: Queue, // @InjectQueue('walking') private walkingQueue: Queue,
|
|
|
- ) {}
|
|
|
+ ) { }
|
|
|
@Client(grpcClientOptions) private readonly client: ClientGrpc;
|
|
|
|
|
|
public _frameInteval: NodeJS.Timeout;
|
|
@@ -44,9 +43,11 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
|
|
|
private moveframeCnt = -1;
|
|
|
private joystickFrameCnt = -1;
|
|
|
private rotateFirstIDR = true;
|
|
|
+ private rotateStopThrottle = false; //防止多次瞬间解触发
|
|
|
|
|
|
private sceneGrpcService: SceneGrpcService;
|
|
|
private channel: DataChannel;
|
|
|
+ private peer: PeerConnection;
|
|
|
private logger: Logger = new Logger('SceneService');
|
|
|
private frameCntInterval = 1000;
|
|
|
private user_id: string;
|
|
@@ -96,6 +97,12 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
|
|
|
clipPath: '',
|
|
|
metaData: '',
|
|
|
});
|
|
|
+ public lastMoveStreamFrameBk: StreamFrameType = {
|
|
|
+ frame: -1,
|
|
|
+ clipPath: '',
|
|
|
+ metaData: '',
|
|
|
+ };
|
|
|
+
|
|
|
public users = {};
|
|
|
|
|
|
// initUsers(app_id, userId) {
|
|
@@ -225,33 +232,8 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
|
|
|
init(request: InitRequest) {
|
|
|
try {
|
|
|
this.rotateService.init(request.app_id, request.user_id);
|
|
|
+ this.cacheService.getClient();
|
|
|
// 加载
|
|
|
- // let path: string;
|
|
|
- // if (process.env.NODE_ENV === 'development') {
|
|
|
- // path = join(
|
|
|
- // __dirname,
|
|
|
- // `../ws/${request.app_id}/points-${request.app_id}.json`,
|
|
|
- // );
|
|
|
- // console.log('测试服JSON', path);
|
|
|
- // }
|
|
|
- // if (process.env.NODE_ENV === 'production') {
|
|
|
- // path = join(
|
|
|
- // `${this.configService.get('app.prefix')}/${request.app_id}/points-${
|
|
|
- // request.app_id
|
|
|
- // }.json`,
|
|
|
- // );
|
|
|
- // console.log('正式服JSON', path);
|
|
|
- // }
|
|
|
-
|
|
|
- // this.moveService.loadJSON(path);
|
|
|
- // this.getRouterService.loadJSON(path);
|
|
|
- this.startSteaming.next(true);
|
|
|
- this.startStream();
|
|
|
- this.handleStream();
|
|
|
-
|
|
|
- // this.moveService.init(request.app_id, request.user_id);
|
|
|
-
|
|
|
- // this.initUsers(request.app_id, request.user_id);
|
|
|
} catch (error) {
|
|
|
this.logger.error('error', error);
|
|
|
}
|
|
@@ -276,8 +258,6 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
|
|
|
*/
|
|
|
|
|
|
async handleRotate(request) {
|
|
|
- // this.roRequestQueueSub = this.roRequestQueue.subscribe(
|
|
|
- // async (request: RotateRequest) => {
|
|
|
// try {
|
|
|
if (this.firstRender) {
|
|
|
if (!this.roQueueSubscription) {
|
|
@@ -286,9 +266,20 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
|
|
|
let redisMeta: StreamReplyType;
|
|
|
this.onRotating.next(true);
|
|
|
const start = performance.now();
|
|
|
- // 当move时处理 _rotateCount是移动端同时触发的问题
|
|
|
- if (this.onMoving.value && this._rotateCount > 5) {
|
|
|
+ // 当move时处理 _rotateCount是移动端同时触发的问题,rotateStopThrottle是减少重复抖动stop的处理。
|
|
|
+ if (
|
|
|
+ this.onMoving.getValue() &&
|
|
|
+ this._rotateCount > 5 &&
|
|
|
+ !this.rotateStopThrottle
|
|
|
+ ) {
|
|
|
+ this.rotateStopThrottle = true;
|
|
|
const lastStreamFrame = this.lastMoveStreamFrame.getValue();
|
|
|
+ this.logger.log('lastStreamFrame', JSON.stringify(lastStreamFrame));
|
|
|
+ // this.logger.log(
|
|
|
+ // 'lastMoveStreamFrameBk',
|
|
|
+ // JSON.stringify(lastMoveStreamFrameBk),
|
|
|
+ // );
|
|
|
+
|
|
|
const metaData: StreamReplyType = JSON.parse(
|
|
|
lastStreamFrame.metaData,
|
|
|
) as any as StreamReplyType;
|
|
@@ -300,21 +291,29 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
|
|
|
if (metaData.traceIds.indexOf(request.trace_id) > -1) {
|
|
|
return;
|
|
|
}
|
|
|
-
|
|
|
+ console.log('currentUser-user_id', this.user_id);
|
|
|
const newUserStates: NewUserStatesType = metaData.newUserStates.find(
|
|
|
(item) => item.userId === this.user_id,
|
|
|
);
|
|
|
+
|
|
|
const trace_id = metaData.traceIds[0];
|
|
|
const userId = newUserStates.userId;
|
|
|
- const breakPointId = metaData.endBreakPointId;
|
|
|
+ //TODO 临时,可能数据会不对
|
|
|
+ const breakPointId = metaData.endBreakPointId || metaData.breakPointId;
|
|
|
const cameraAngle = newUserStates.playerState.camera.angle;
|
|
|
const playerAngle = newUserStates.playerState.player.angle;
|
|
|
this.logger.log(
|
|
|
- 'stop-data-0',
|
|
|
- trace_id,
|
|
|
- userId,
|
|
|
- cameraAngle,
|
|
|
- cameraAngle,
|
|
|
+ 'stop-data-0' +
|
|
|
+ 'trace_id: ' +
|
|
|
+ trace_id +
|
|
|
+ 'userId:' +
|
|
|
+ userId +
|
|
|
+ 'breakPointId :' +
|
|
|
+ breakPointId +
|
|
|
+ 'cameraAngle :' +
|
|
|
+ JSON.stringify(cameraAngle) +
|
|
|
+ 'playerAngle: ' +
|
|
|
+ JSON.stringify(playerAngle),
|
|
|
);
|
|
|
//debugger;
|
|
|
console.log('moveService.stop-1:'+breakPointId)
|
|
@@ -361,7 +360,11 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
|
|
|
const stop = performance.now();
|
|
|
const inMillSeconds = stop - start;
|
|
|
const rounded = Number(inMillSeconds).toFixed(3);
|
|
|
- this.logger.log(`[timer]-rotate-入队列前: ${rounded}ms`);
|
|
|
+ this.logger.log(
|
|
|
+ `[timer]-rotate-入队列前: ${rounded}ms -->` +
|
|
|
+ JSON.stringify(stream),
|
|
|
+ );
|
|
|
+
|
|
|
this.roQueue.next(stream);
|
|
|
} else {
|
|
|
// this.onRotating.next(false);
|
|
@@ -385,7 +388,7 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
|
|
|
this.handleWalking(request);
|
|
|
}
|
|
|
|
|
|
- console.log('moveSliceLastFrameSub', this.moveSliceLastFrameSub);
|
|
|
+ console.log('moveSliceLastFrameSub', !!this.moveSliceLastFrameSub);
|
|
|
|
|
|
// 监听每小段最后一帧
|
|
|
if (!this.moveSliceLastFrameSub) {
|
|
@@ -395,9 +398,9 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
|
|
|
//TODO 正在行走时,有新的reqest
|
|
|
if (this.latestWalkingRequest && this.onMoving.value) {
|
|
|
this.logger.log('stop-data-1', frame);
|
|
|
+ this.moveQueueSubscription.unsubscribe();
|
|
|
+ this.moveQueueSubscription = null;
|
|
|
this.moveQueue.clean();
|
|
|
- // this.moveQueueSubscription.unsubscribe();
|
|
|
- // this.moveQueueSubscription = null;
|
|
|
//step1 执行stop方法
|
|
|
const metaData: StreamReplyType = frame.metaData;
|
|
|
const newUserStates: NewUserStatesType =
|
|
@@ -430,6 +433,14 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
|
|
|
'walking-step-reWalking-1',
|
|
|
request.trace_id + ',' + this.latestWalkingRequest.trace_id,
|
|
|
);
|
|
|
+ // 中断清除上一次最后小段队列
|
|
|
+ if (this.moveSliceLastFrameSub) {
|
|
|
+ this.moveSliceLastFrameSub.unsubscribe();
|
|
|
+ this.moveSliceLastFrameSub = null;
|
|
|
+ }
|
|
|
+
|
|
|
+ this.logger.debug('重新行走---handleReWalking');
|
|
|
+ console.log('重新行走---handleReWalking');
|
|
|
this.handleReWalking(this.latestWalkingRequest);
|
|
|
}
|
|
|
},
|
|
@@ -451,7 +462,20 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
|
|
|
this._rotateCount = 0;
|
|
|
const user = this.moveService.users[this.user_id];
|
|
|
console.log('进入1 - searchRoad');
|
|
|
+ this.logger.log(
|
|
|
+ 'handleWalking-users' +
|
|
|
+ JSON.stringify(this.moveService.users) +
|
|
|
+ ' this.user_id: ' +
|
|
|
+ this.user_id,
|
|
|
+ );
|
|
|
+ this.logger.log(
|
|
|
+ 'handleWalking-currentUser' +
|
|
|
+ JSON.stringify(user) +
|
|
|
+ ' this.user_id: ' +
|
|
|
+ this.user_id,
|
|
|
+ );
|
|
|
console.log('path-start' + user.breakPointId);
|
|
|
+
|
|
|
const path = await this.getRouterService.searchRoad(
|
|
|
user.appId,
|
|
|
user.breakPointId,
|
|
@@ -516,7 +540,17 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
|
|
|
const seqs = Array.from(walkingRes).flat() as any as StreamReplyType[];
|
|
|
|
|
|
if (seqs?.length) {
|
|
|
- this.logger.log('walking --总序列--seqs-2:' + seqs.length);
|
|
|
+ this.logger.log(
|
|
|
+ 'walking --队列总览:' +
|
|
|
+ ' 总段数: ' +
|
|
|
+ walkingRes.length +
|
|
|
+ ' 镜头帧数:' +
|
|
|
+ walkingRes[0].length +
|
|
|
+ ' 行走段数:' +
|
|
|
+ (walkingRes.length - 1) +
|
|
|
+ ' 队列总帧数:' +
|
|
|
+ seqs.length,
|
|
|
+ );
|
|
|
const stop = performance.now();
|
|
|
const inMillSeconds = stop - start;
|
|
|
const rounded = Number(inMillSeconds).toFixed(3);
|
|
@@ -571,7 +605,7 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
|
|
|
const joystickRes = await this.moveService.seqExeJoystick(request);
|
|
|
this.logger.log(
|
|
|
'joystick-breakPointId:' +
|
|
|
- this.moveService.users[this.user_id].breakPointId,
|
|
|
+ this.moveService.users[this.user_id].breakPointId,
|
|
|
);
|
|
|
// 有数据 [0]是rotate数据,[1-infinity]是walking数据
|
|
|
this.logger.log('joystickRes-1', joystickRes);
|
|
@@ -674,11 +708,12 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
|
|
|
if (!this.moveQueueSubscription) {
|
|
|
this.handleMoveSteam();
|
|
|
}
|
|
|
- this.logger.log('moving-seqs', seqs.length);
|
|
|
+ // this.logger.log('moving-seqs', seqs.length);
|
|
|
this.onMoving.next(true);
|
|
|
this.holdSteam();
|
|
|
//TODO Remove
|
|
|
// clearTimeout(this._JoyStickingTimeout);
|
|
|
+ this.moveQueue.clean();
|
|
|
|
|
|
seqs.forEach((frame: StreamReplyType) => {
|
|
|
const mediaSrc = frame.mediaSrc;
|
|
@@ -716,27 +751,28 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
|
|
|
// this.clickQueueSub.unsubscribe();
|
|
|
// this.clickQueueSub = null;
|
|
|
// }
|
|
|
+ this.rotateStopThrottle = false;
|
|
|
}
|
|
|
handleMoveSteam() {
|
|
|
this.moveQueueSubscription = this.moveQueue.subscribe(
|
|
|
async (stream: StreamFrameType) => {
|
|
|
- const metaData: StreamReplyType = JSON.parse(stream.metaData);
|
|
|
-
|
|
|
- if (this.moveframeCnt === -1) {
|
|
|
- this.moveframeCnt = this.frameCnt.getValue();
|
|
|
- }
|
|
|
- this.moveframeCnt += 1;
|
|
|
- this.latestBreakPointId = metaData.endBreakPointId;
|
|
|
-
|
|
|
- const streamData: StreamFrameType = {
|
|
|
- frame: this.moveframeCnt,
|
|
|
- clipPath: stream.clipPath,
|
|
|
- metaData: stream.metaData,
|
|
|
- serverTime: this.mockserverTime,
|
|
|
- DIR: stream.DIR,
|
|
|
- };
|
|
|
- this.logger.log(
|
|
|
- '[media-move]: ' +
|
|
|
+ try {
|
|
|
+ const metaData: StreamReplyType = JSON.parse(stream.metaData);
|
|
|
+ if (this.moveframeCnt === -1) {
|
|
|
+ this.moveframeCnt = this.frameCnt.getValue();
|
|
|
+ }
|
|
|
+ this.moveframeCnt += 1;
|
|
|
+ this.latestBreakPointId = metaData.endBreakPointId;
|
|
|
+
|
|
|
+ const streamData: StreamFrameType = {
|
|
|
+ frame: this.moveframeCnt,
|
|
|
+ clipPath: stream.clipPath,
|
|
|
+ metaData: stream.metaData,
|
|
|
+ serverTime: this.mockserverTime,
|
|
|
+ DIR: stream.DIR,
|
|
|
+ };
|
|
|
+ this.logger.log(
|
|
|
+ '[media-move]: ' +
|
|
|
', moveframeCnt: ' +
|
|
|
this.moveframeCnt +
|
|
|
', clipPath: ' +
|
|
@@ -745,56 +781,69 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
|
|
|
stream.mType +
|
|
|
', DIR: ' +
|
|
|
stream.DIR,
|
|
|
- // stream.metaData,
|
|
|
- );
|
|
|
- this.logger.log(
|
|
|
- '[media-move-lastMovingPointArray]',
|
|
|
- this.lastMovingPointArray?.length,
|
|
|
- );
|
|
|
- this.lastMoveStreamFrame.next(streamData);
|
|
|
- const res = await this.streamService.pushFrameToSteam(streamData);
|
|
|
+ // stream.metaData,
|
|
|
+ );
|
|
|
+ this.logger.log(
|
|
|
+ '[media-move-lastMovingPointArray]',
|
|
|
+ this.lastMovingPointArray?.length,
|
|
|
+ );
|
|
|
+ // 记录lastMoveStreamFrame给打断逻辑使用
|
|
|
+ this.lastMoveStreamFrame.next(streamData);
|
|
|
+ // this.lastMoveStreamFrameBk = streamData;
|
|
|
+ const res = await this.streamService.pushFrameToSteam(streamData);
|
|
|
|
|
|
- const isLastFrameIndex = this.lastMovingPointArray.findIndex(
|
|
|
- (item) => item.mediaSrc === metaData.mediaSrc,
|
|
|
- );
|
|
|
- //this.logger.log('path-update-index', isLastFrameIndex);
|
|
|
- //每一段的最后一帧
|
|
|
- if (isLastFrameIndex > -1) {
|
|
|
- //this.logger.log('path-update-array', this.lastMovingPointArray);
|
|
|
- const currentMeta = this.lastMovingPointArray[isLastFrameIndex];
|
|
|
- const userId = this.user_id;
|
|
|
- const breakPointId = currentMeta.metaData.endBreakPointId;
|
|
|
- const lastReply = currentMeta.metaData;
|
|
|
- this.moveService.updateUser(userId, breakPointId, lastReply);
|
|
|
- //debugger
|
|
|
- this.lastMovingPointArray.splice(isLastFrameIndex, 1);
|
|
|
- //TODO 队列每一段最后one frame
|
|
|
- this.moveSliceLastFrame.next(currentMeta);
|
|
|
- }
|
|
|
+ const isLastFrameIndex = this.lastMovingPointArray.findIndex(
|
|
|
+ (item) => item.mediaSrc === metaData.mediaSrc,
|
|
|
+ );
|
|
|
+ //this.logger.log('path-update-index', isLastFrameIndex);
|
|
|
+ //每一段的最后一帧
|
|
|
+ if (isLastFrameIndex > -1) {
|
|
|
+ //this.logger.log('path-update-array', this.lastMovingPointArray);
|
|
|
+ const currentMeta = this.lastMovingPointArray[isLastFrameIndex];
|
|
|
+ const userId = this.user_id;
|
|
|
+ const breakPointId = currentMeta.metaData.endBreakPointId;
|
|
|
+ const lastReply = currentMeta.metaData;
|
|
|
+ this.moveService.updateUser(userId, breakPointId, lastReply);
|
|
|
+ //debugger
|
|
|
+ this.lastMovingPointArray.splice(isLastFrameIndex, 1);
|
|
|
+ //TODO 队列每一段最后one frame
|
|
|
+ this.moveSliceLastFrame.next(currentMeta);
|
|
|
+ }
|
|
|
|
|
|
- if (res.done) {
|
|
|
- clearTimeout(this._moveTimeout);
|
|
|
- this._moveTimeout = setTimeout(() => {
|
|
|
- this.logger.log('move 交权给空流,当前pts', res.frame);
|
|
|
- this.rewalking = false;
|
|
|
- this.frameCnt.next(res.frame);
|
|
|
- this.resumeStream();
|
|
|
- this.rotateframeCnt = -1;
|
|
|
- this.onMoving.next(false);
|
|
|
- this.onJoysticking.next(false);
|
|
|
- this.cleanMoveSteam();
|
|
|
- this.lastMovingPointArray = [];
|
|
|
- this.hasJoystickMoveRequest = false;
|
|
|
- this.logger.log('move end');
|
|
|
- }, 300);
|
|
|
+ if (res.done) {
|
|
|
+ clearTimeout(this._moveTimeout);
|
|
|
+ this._moveTimeout = setTimeout(() => {
|
|
|
+ this.logger.log('move 交权给空流,当前pts', res.frame);
|
|
|
+ this.rewalking = false;
|
|
|
+ this.frameCnt.next(res.frame);
|
|
|
+ this.resumeStream();
|
|
|
+ this.rotateframeCnt = -1;
|
|
|
+ this.onMoving.next(false);
|
|
|
+ this.onJoysticking.next(false);
|
|
|
+ this.cleanMoveSteam();
|
|
|
+ this.lastMovingPointArray = [];
|
|
|
+ this.hasJoystickMoveRequest = false;
|
|
|
+ this.logger.log('move end');
|
|
|
+ }, 200);
|
|
|
+ } else {
|
|
|
+ this.logger.error(
|
|
|
+ `movesteam::当前帧:${res.frame}` + JSON.stringify(res),
|
|
|
+ );
|
|
|
+ }
|
|
|
+ } catch (error) {
|
|
|
+ this.logger.error('handleMoveSteam::error', error);
|
|
|
}
|
|
|
},
|
|
|
);
|
|
|
}
|
|
|
|
|
|
- handleDataChanelOpen(channel: DataChannel): void {
|
|
|
+ handleDataChanelOpen(channel: DataChannel, peer: PeerConnection): void {
|
|
|
this.channel = channel;
|
|
|
+ this.peer = peer;
|
|
|
this.streamService.setChannel(channel);
|
|
|
+ this.startSteaming.next(true);
|
|
|
+ this.startStream();
|
|
|
+ this.handleStream();
|
|
|
}
|
|
|
|
|
|
handleDataChanelClose(): void {
|
|
@@ -925,8 +974,7 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
|
|
|
|
|
|
const IDRflag = this._rotateCurrentFame % 5 === 0 ? 1 : 3;
|
|
|
this.logger.log(
|
|
|
- `当前rotate ,mainframeCnt:${this.frameCnt.getValue()}, _rotateCurrentFame:${
|
|
|
- this._rotateCurrentFame
|
|
|
+ `当前rotate ,mainframeCnt:${this.frameCnt.getValue()}, _rotateCurrentFame:${this._rotateCurrentFame
|
|
|
} IDRflag:${IDRflag}`,
|
|
|
);
|
|
|
stream.DIR = this.rotateFirstIDR ? 1 : IDRflag;
|
|
@@ -937,12 +985,12 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
|
|
|
|
|
|
this.logger.log(
|
|
|
'[media-rotate]: ' +
|
|
|
- ', frame: ' +
|
|
|
- stream.frame +
|
|
|
- ', rotateframeCnt: ' +
|
|
|
- this.rotateframeCnt +
|
|
|
- ', clipPath: ' +
|
|
|
- stream.clipPath,
|
|
|
+ ', frame: ' +
|
|
|
+ stream.frame +
|
|
|
+ ', rotateframeCnt: ' +
|
|
|
+ this.rotateframeCnt +
|
|
|
+ ', clipPath: ' +
|
|
|
+ stream.clipPath,
|
|
|
// stream.metaData,
|
|
|
);
|
|
|
// this.logger.log(
|
|
@@ -993,12 +1041,22 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
|
|
|
}
|
|
|
handleStream() {
|
|
|
this.logger.log('this.frameCntSubscription', this.frameCntSubscription);
|
|
|
+ let redisData;
|
|
|
if (!this.frameCntSubscription) {
|
|
|
this.frameCntSubscription = this.frameCnt.subscribe(async (frame) => {
|
|
|
try {
|
|
|
this.logger.log('frame', frame);
|
|
|
+ console.log(
|
|
|
+ 'mock' +
|
|
|
+ ' maxMessageSize: ' +
|
|
|
+ this.channel.maxMessageSize() +
|
|
|
+ ' bytesReceived: ' +
|
|
|
+ this.peer.bytesReceived() +
|
|
|
+ ' bytesSent: ' +
|
|
|
+ this.peer.bytesSent(),
|
|
|
+ );
|
|
|
if (frame === 1) {
|
|
|
- const redisData = await this.rotateService.echo(this.user_id, true);
|
|
|
+ redisData = await this.rotateService.echo(this.user_id, true);
|
|
|
this.logger.log('获取-首屏', redisData);
|
|
|
this.onSteaming = true;
|
|
|
this.holdSteam();
|
|
@@ -1006,14 +1064,11 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
|
|
|
const mediaSrc: string = redisData.mediaSrc || '';
|
|
|
if (mediaSrc.length > 0) {
|
|
|
const src = mediaSrc.split('?')[0];
|
|
|
- // 临时本地替换路经
|
|
|
- // src = src.replace('/10086/', '');
|
|
|
- // const clipPath = join(__dirname, `../ws/${src}`);
|
|
|
const clipPath = this.configService.get('app.prefix') + src;
|
|
|
delete redisData.mediaSrc;
|
|
|
this.logger.log(
|
|
|
`user:${this.user_id}:first render stream` +
|
|
|
- JSON.stringify({ path: clipPath, meta: redisData }),
|
|
|
+ JSON.stringify({ path: clipPath, meta: redisData }),
|
|
|
);
|
|
|
const status = await this.pushFirstRender(
|
|
|
clipPath,
|
|
@@ -1028,7 +1083,7 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
|
|
|
}
|
|
|
}
|
|
|
} else {
|
|
|
- this.logger.error(`首屏::无数据:${frame}`);
|
|
|
+ this.logger.error(`first render problem:${frame}`);
|
|
|
}
|
|
|
}
|
|
|
if (
|
|
@@ -1057,6 +1112,9 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
|
|
|
}
|
|
|
}
|
|
|
} catch (error) {
|
|
|
+ if (this.frameCnt.getValue() === 1) {
|
|
|
+ this.logger.error('首屏读取redis有误:', redisData, error.message);
|
|
|
+ }
|
|
|
this.stopStream();
|
|
|
this.logger.error('handleStream', error.message);
|
|
|
}
|