|
@@ -717,73 +717,77 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
|
|
|
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]: ' +
|
|
|
- ', moveframeCnt: ' +
|
|
|
- this.moveframeCnt +
|
|
|
- ', clipPath: ' +
|
|
|
- stream.clipPath +
|
|
|
- ', mType: ' +
|
|
|
- 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);
|
|
|
+ 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: ' +
|
|
|
+ stream.clipPath +
|
|
|
+ ', mType: ' +
|
|
|
+ stream.mType +
|
|
|
+ ', DIR: ' +
|
|
|
+ stream.DIR,
|
|
|
+ // stream.metaData,
|
|
|
+ );
|
|
|
+ this.logger.log(
|
|
|
+ '[media-move-lastMovingPointArray]',
|
|
|
+ this.lastMovingPointArray?.length,
|
|
|
+ );
|
|
|
+ // 记录lastMoveStreamFrame给打断逻辑使用
|
|
|
+ this.lastMoveStreamFrame.next(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');
|
|
|
+ }, 300);
|
|
|
+ }
|
|
|
+ } catch (error) {
|
|
|
+ this.logger.error('handleMoveSteam::error', error);
|
|
|
}
|
|
|
},
|
|
|
);
|