|
|
@@ -277,6 +277,7 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
|
|
|
if (src.length > 0) {
|
|
|
this.lastRenderMedia = src;
|
|
|
const clipPath = this.configService.get('app.prefix') + src;
|
|
|
+ delete redisMeta.mediaSrc;
|
|
|
const stream: StreamFrameType = {
|
|
|
frame: -1,
|
|
|
clipPath: clipPath,
|
|
|
@@ -621,48 +622,6 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
|
|
|
// console.log('this', this.rewalking);
|
|
|
}
|
|
|
}
|
|
|
- // if (this.latestWalkingRequest && this.onMoving.value) {
|
|
|
- // this.logger.log('stop-data-1', frame);
|
|
|
- // this.moveQueueSubscription.unsubscribe();
|
|
|
- // this.moveQueueSubscription = null;
|
|
|
- // this.moveQueue.clean();
|
|
|
- // //step1 执行stop方法
|
|
|
- // const metaData: StreamReplyType = frame.metaData;
|
|
|
- // 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;
|
|
|
- // const cameraAngle = newUserStates.playerState.camera.angle;
|
|
|
- // const playerAngle = newUserStates.playerState.player.angle;
|
|
|
- // this.logger.log(
|
|
|
- // 'stop-data-2',
|
|
|
- // trace_id,
|
|
|
- // userId,
|
|
|
- // cameraAngle,
|
|
|
- // cameraAngle,
|
|
|
- // );
|
|
|
- // console.log('moveService.stop-2:' + breakPointId);
|
|
|
- // const redisMeta = await this.moveService.stop(
|
|
|
- // trace_id,
|
|
|
- // userId,
|
|
|
- // breakPointId,
|
|
|
- // cameraAngle,
|
|
|
- // playerAngle,
|
|
|
- // );
|
|
|
- // this.logger.log('stop-redisMeta', JSON.stringify(redisMeta));
|
|
|
- // // 2. 中断重新walking
|
|
|
- // console.log(
|
|
|
- // 'walking-step-reWalking-1',
|
|
|
- // request.trace_id + ',' + this.latestWalkingRequest.trace_id,
|
|
|
- // );
|
|
|
-
|
|
|
- // this.logger.debug('重新行走---handleReWalking');
|
|
|
- // console.log('重新行走---handleReWalking');
|
|
|
- // this.handleReWalking(this.latestWalkingRequest);
|
|
|
- // }
|
|
|
}
|
|
|
},
|
|
|
);
|
|
|
@@ -887,7 +846,7 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
|
|
|
// if (this.isJoystickHasStream) {
|
|
|
// await this.sleep(20);
|
|
|
// }
|
|
|
- await this.sleep(20);
|
|
|
+ // await this.sleep(20);
|
|
|
this.frameCnt.next(hasPush.frame);
|
|
|
this.moveService.sendingFrameForJoystick = false;
|
|
|
const data = joystickRes as StreamReplyType;
|
|
|
@@ -959,16 +918,16 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
|
|
|
this.hasJoystickFocusRepeat = true;
|
|
|
this.globalOptLock = true;
|
|
|
this.testTimer += 1;
|
|
|
- console.log('gemer-test-complementFrame-有值');
|
|
|
+ console.log('complementFrame-有值');
|
|
|
const start = performance.now();
|
|
|
this.handlePushJoyStickSteamSeq(complementFrame);
|
|
|
const stop = performance.now();
|
|
|
- console.log('gemer-test-handlePushJoyStickSteam', this.testTimer);
|
|
|
+ console.log('handlePushJoyStickSteam', this.testTimer);
|
|
|
const inMillSeconds = stop - start;
|
|
|
const rounded = Number(inMillSeconds).toFixed(3);
|
|
|
- console.log(`gemer-test-complementFrame调用时间---->${rounded}`);
|
|
|
+ console.log(`complementFrame调用时间---->${rounded}`);
|
|
|
} else {
|
|
|
- console.log('gemer-test-complementFrame-空1');
|
|
|
+ console.log('complementFrame-空1');
|
|
|
this.logger.log('joystick opt done');
|
|
|
this.logger.log('joystick 交权给空流,当前pts', hasPush.frame);
|
|
|
this.hasJoystickFocusRepeat = false;
|
|
|
@@ -1026,9 +985,9 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
|
|
|
* @param seqs StreamReplyType[]
|
|
|
*/
|
|
|
handleSeqMoving(seqs: StreamReplyType[]) {
|
|
|
- if (!this.moveQueueSubscription) {
|
|
|
- this.handleMoveSteam();
|
|
|
- }
|
|
|
+ // if (!this.moveQueueSubscription) {
|
|
|
+ // this.handleMoveSteam();
|
|
|
+ // }
|
|
|
// this.logger.log('moving-seqs', seqs.length);
|
|
|
this.onMoving.next(true);
|
|
|
this.holdSteam();
|
|
|
@@ -1050,100 +1009,105 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
|
|
|
DIR: frame.DIR,
|
|
|
mType: type,
|
|
|
};
|
|
|
- this.moveQueue.next(stream);
|
|
|
+ // this.moveQueue.next(stream);
|
|
|
+ this.handleMoveSteam(stream);
|
|
|
});
|
|
|
}
|
|
|
|
|
|
- handleMoveSteam() {
|
|
|
- this.moveQueueSubscription = this.moveQueue.subscribe(
|
|
|
- async (stream: StreamFrameType) => {
|
|
|
- try {
|
|
|
- if (!this.isStopJointing) {
|
|
|
- const metaData: StreamReplyType = JSON.parse(stream.metaData);
|
|
|
- if (this.moveframeCnt === -1) {
|
|
|
- this.moveframeCnt = this.frameCnt.getValue();
|
|
|
- }
|
|
|
- this.moveframeCnt += 1;
|
|
|
- // this.latestBreakPointId = metaData.endBreakPointId;
|
|
|
+ handleMoveSteam = seqExeAsyncFn(this.handleMoveSteamFn);
|
|
|
|
|
|
- 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: ' +
|
|
|
- stream.clipPath +
|
|
|
- ', mType: ' +
|
|
|
- stream.mType +
|
|
|
- ', DIR: ' +
|
|
|
- stream.DIR,
|
|
|
- // stream.metaData,
|
|
|
- );
|
|
|
- this.logger.log(
|
|
|
- '[media-move-lastMovingPointArray]',
|
|
|
- this.lastMovingPointArray?.length,
|
|
|
- );
|
|
|
- // 记录lastMoveStreamFrame给打断逻辑使用
|
|
|
- this.lastMoveStreamFrame.next(streamData);
|
|
|
- // this.lastMoveStreamFrameBk = streamData;
|
|
|
- this.holdSteam();
|
|
|
- // this.globalOptLock = true;
|
|
|
- //console.log('20220627test:handleMoveSteam:' + stream.clipPath)
|
|
|
- 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 (res.done) {
|
|
|
- this.frameCnt.next(res.frame);
|
|
|
- //关节点入库
|
|
|
- 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);
|
|
|
- this.lastMovingPointArray.splice(isLastFrameIndex, 1);
|
|
|
- this.moveSliceLastFrame.next(currentMeta);
|
|
|
- }
|
|
|
-
|
|
|
- clearTimeout(this._moveTimeout);
|
|
|
- this._moveTimeout = setTimeout(() => {
|
|
|
- this.logger.log('move 交权给空流,当前pts', res.frame);
|
|
|
- this.rewalking = false;
|
|
|
- this.frameCnt.next(res.frame);
|
|
|
- this.rotateframeCnt = -1;
|
|
|
- this.onMoving.next(false);
|
|
|
- this.onJoysticking.next(false);
|
|
|
- this.lastMovingPointArray = [];
|
|
|
- this.hasJoystickMoveRequest = false;
|
|
|
- this.cleanMoveSteam();
|
|
|
- this.globalOptLock = false;
|
|
|
- this.resumeStream();
|
|
|
- this.logger.log('move end');
|
|
|
- }, 200);
|
|
|
- } else {
|
|
|
- console.error('流地址有误::', res.frame, JSON.stringify(res));
|
|
|
- this.logger.error(
|
|
|
- `movesteam::当前帧:${res.frame}` + JSON.stringify(res),
|
|
|
- );
|
|
|
- this.resumeStream();
|
|
|
- }
|
|
|
+ async handleMoveSteamFn(stream: StreamFrameType) {
|
|
|
+ try {
|
|
|
+ if (!this.isStopJointing) {
|
|
|
+ const metaData: StreamReplyType = JSON.parse(stream.metaData);
|
|
|
+ // if (this.moveframeCnt === -1) {
|
|
|
+ // this.moveframeCnt = this.frameCnt.getValue();
|
|
|
+ // }
|
|
|
+ // this.moveframeCnt += 1;
|
|
|
+ // this.latestBreakPointId = metaData.endBreakPointId;
|
|
|
+ this.moveframeCnt = this.frameCnt.value + 1;
|
|
|
+ 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: ' +
|
|
|
+ stream.clipPath +
|
|
|
+ ', mType: ' +
|
|
|
+ stream.mType +
|
|
|
+ ', DIR: ' +
|
|
|
+ stream.DIR,
|
|
|
+ // stream.metaData,
|
|
|
+ );
|
|
|
+ this.logger.log(
|
|
|
+ '[media-move-lastMovingPointArray]',
|
|
|
+ this.lastMovingPointArray?.length,
|
|
|
+ );
|
|
|
+ // 记录lastMoveStreamFrame给打断逻辑使用
|
|
|
+ this.lastMoveStreamFrame.next(streamData);
|
|
|
+ // this.lastMoveStreamFrameBk = streamData;
|
|
|
+ this.holdSteam();
|
|
|
+ // this.globalOptLock = true;
|
|
|
+ //console.log('20220627test:handleMoveSteam:' + stream.clipPath)
|
|
|
+ const frameTimeStart = performance.now();
|
|
|
+ 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 (res.done) {
|
|
|
+ const frameTimeEnd = performance.now();
|
|
|
+ const frameAverage = frameTimeEnd - frameTimeStart;
|
|
|
+ console.log('walking-frameAverage', frameAverage);
|
|
|
+ await this.sleep(40);
|
|
|
+ this.frameCnt.next(res.frame);
|
|
|
+ //关节点入库
|
|
|
+ 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);
|
|
|
+ this.lastMovingPointArray.splice(isLastFrameIndex, 1);
|
|
|
+ this.moveSliceLastFrame.next(currentMeta);
|
|
|
}
|
|
|
- } catch (error) {
|
|
|
- this.logger.error('handleMoveSteam::error', error);
|
|
|
+
|
|
|
+ clearTimeout(this._moveTimeout);
|
|
|
+
|
|
|
+ this._moveTimeout = setTimeout(() => {
|
|
|
+ this.logger.log('move 交权给空流,当前pts', res.frame);
|
|
|
+ this.rewalking = false;
|
|
|
+ this.frameCnt.next(res.frame);
|
|
|
+ this.rotateframeCnt = -1;
|
|
|
+ this.onMoving.next(false);
|
|
|
+ this.onJoysticking.next(false);
|
|
|
+ this.lastMovingPointArray = [];
|
|
|
+ this.hasJoystickMoveRequest = false;
|
|
|
+ this.cleanMoveSteam();
|
|
|
+ this.globalOptLock = false;
|
|
|
+ this.resumeStream();
|
|
|
+ this.logger.log('move end');
|
|
|
+ }, 200);
|
|
|
+ } else {
|
|
|
+ console.error('流地址有误::', res.frame, JSON.stringify(res));
|
|
|
+ this.logger.error(
|
|
|
+ `movesteam::当前帧:${res.frame}` + JSON.stringify(res),
|
|
|
+ );
|
|
|
+ this.resumeStream();
|
|
|
}
|
|
|
- },
|
|
|
- );
|
|
|
+ }
|
|
|
+ } catch (error) {
|
|
|
+ this.logger.error('handleMoveSteam::error', error);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
cleanMoveSteam() {
|
|
|
@@ -1178,7 +1142,7 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
|
|
|
this.channel.onBufferedAmountLow(() => {
|
|
|
console.error('onBufferedAmountLow', this.channel.bufferedAmount());
|
|
|
//64k->65536 128k->131072
|
|
|
- this.channel.setBufferedAmountLowThreshold(65536);
|
|
|
+ this.channel.setBufferedAmountLowThreshold(262144);
|
|
|
this.logger.error('onBufferedAmountLow', this.channel.bufferedAmount());
|
|
|
});
|
|
|
}
|