|
@@ -38,7 +38,7 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
|
|
private rotateService: RotateService,
|
|
private rotateService: RotateService,
|
|
private moveService: MoveService,
|
|
private moveService: MoveService,
|
|
private getRouterService: GetRouterService, // @InjectQueue('rotate') private rotateQueue: Queue, // @InjectQueue('walking') private walkingQueue: Queue,
|
|
private getRouterService: GetRouterService, // @InjectQueue('rotate') private rotateQueue: Queue, // @InjectQueue('walking') private walkingQueue: Queue,
|
|
- ) { }
|
|
|
|
|
|
+ ) {}
|
|
@Client(grpcClientOptions) private readonly client: ClientGrpc;
|
|
@Client(grpcClientOptions) private readonly client: ClientGrpc;
|
|
|
|
|
|
public _frameInteval: NodeJS.Timeout;
|
|
public _frameInteval: NodeJS.Timeout;
|
|
@@ -208,7 +208,13 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
|
|
|
|
|
|
init(request: InitRequest) {
|
|
init(request: InitRequest) {
|
|
try {
|
|
try {
|
|
- this.rotateService.init(request.app_id, request.user_id,request.skin_id,request.roomId,request.avatar_id);
|
|
|
|
|
|
+ this.rotateService.init(
|
|
|
|
+ request.app_id,
|
|
|
|
+ request.user_id,
|
|
|
|
+ request.skin_id,
|
|
|
|
+ request.roomId,
|
|
|
|
+ request.avatar_id,
|
|
|
|
+ );
|
|
this.cacheService.getClient();
|
|
this.cacheService.getClient();
|
|
console.log('rotateService::init');
|
|
console.log('rotateService::init');
|
|
this.startSub = this.startSteaming.subscribe((flag) => {
|
|
this.startSub = this.startSteaming.subscribe((flag) => {
|
|
@@ -270,7 +276,7 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
|
|
const redisMeta: StreamReplyType = await this.rotateService.seqExeRotate(
|
|
const redisMeta: StreamReplyType = await this.rotateService.seqExeRotate(
|
|
request,
|
|
request,
|
|
);
|
|
);
|
|
-
|
|
|
|
|
|
+
|
|
if (redisMeta && 'mediaSrc' in redisMeta) {
|
|
if (redisMeta && 'mediaSrc' in redisMeta) {
|
|
if (redisMeta.mediaSrc?.length) {
|
|
if (redisMeta.mediaSrc?.length) {
|
|
const src = redisMeta.mediaSrc.split('?')[0];
|
|
const src = redisMeta.mediaSrc.split('?')[0];
|
|
@@ -291,7 +297,7 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
|
|
const rounded = Number(inMillSeconds).toFixed(3);
|
|
const rounded = Number(inMillSeconds).toFixed(3);
|
|
this.logger.log(
|
|
this.logger.log(
|
|
`[timer]-rotate-入队列前: ${rounded}ms -->` +
|
|
`[timer]-rotate-入队列前: ${rounded}ms -->` +
|
|
- JSON.stringify(stream),
|
|
|
|
|
|
+ JSON.stringify(stream),
|
|
);
|
|
);
|
|
if (!this.stopRotated) {
|
|
if (!this.stopRotated) {
|
|
await this.seqExehandleRotateStream(stream);
|
|
await this.seqExehandleRotateStream(stream);
|
|
@@ -488,16 +494,16 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
|
|
const playerAngle = newUserStates.playerState.player.angle;
|
|
const playerAngle = newUserStates.playerState.player.angle;
|
|
this.logger.log(
|
|
this.logger.log(
|
|
'stop-data-0' +
|
|
'stop-data-0' +
|
|
- 'trace_id: ' +
|
|
|
|
- trace_id +
|
|
|
|
- 'userId:' +
|
|
|
|
- userId +
|
|
|
|
- 'breakPointId :' +
|
|
|
|
- breakPointId +
|
|
|
|
- 'cameraAngle :' +
|
|
|
|
- JSON.stringify(cameraAngle) +
|
|
|
|
- 'playerAngle: ' +
|
|
|
|
- JSON.stringify(playerAngle),
|
|
|
|
|
|
+ 'trace_id: ' +
|
|
|
|
+ trace_id +
|
|
|
|
+ 'userId:' +
|
|
|
|
+ userId +
|
|
|
|
+ 'breakPointId :' +
|
|
|
|
+ breakPointId +
|
|
|
|
+ 'cameraAngle :' +
|
|
|
|
+ JSON.stringify(cameraAngle) +
|
|
|
|
+ 'playerAngle: ' +
|
|
|
|
+ JSON.stringify(playerAngle),
|
|
);
|
|
);
|
|
//debugger;
|
|
//debugger;
|
|
console.log('moveService.stop-1:' + breakPointId);
|
|
console.log('moveService.stop-1:' + breakPointId);
|
|
@@ -661,15 +667,15 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
|
|
console.log('进入1 - searchRoad');
|
|
console.log('进入1 - searchRoad');
|
|
this.logger.log(
|
|
this.logger.log(
|
|
'handleWalking-users' +
|
|
'handleWalking-users' +
|
|
- JSON.stringify(this.moveService.users) +
|
|
|
|
- ' this.user_id: ' +
|
|
|
|
- this.user_id,
|
|
|
|
|
|
+ JSON.stringify(this.moveService.users) +
|
|
|
|
+ ' this.user_id: ' +
|
|
|
|
+ this.user_id,
|
|
);
|
|
);
|
|
this.logger.log(
|
|
this.logger.log(
|
|
'handleWalking-currentUser' +
|
|
'handleWalking-currentUser' +
|
|
- JSON.stringify(user) +
|
|
|
|
- ' this.user_id: ' +
|
|
|
|
- this.user_id,
|
|
|
|
|
|
+ JSON.stringify(user) +
|
|
|
|
+ ' this.user_id: ' +
|
|
|
|
+ this.user_id,
|
|
);
|
|
);
|
|
console.log('path-start' + user.breakPointId);
|
|
console.log('path-start' + user.breakPointId);
|
|
|
|
|
|
@@ -699,7 +705,10 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
|
|
for (let i = 0; i <= walkingRes.length - 1; i++) {
|
|
for (let i = 0; i <= walkingRes.length - 1; i++) {
|
|
Array.from(walkingRes[i]).forEach(
|
|
Array.from(walkingRes[i]).forEach(
|
|
(item: StreamReplyType, index: number) => {
|
|
(item: StreamReplyType, index: number) => {
|
|
- console.log('20220628test:handleWalking->'+item['newUserStates'][0].renderInfo.isMoving)
|
|
|
|
|
|
+ console.log(
|
|
|
|
+ '20220628test:handleWalking->' +
|
|
|
|
+ item['newUserStates'][0].renderInfo.isMoving,
|
|
|
|
+ );
|
|
//const IDRflag = index % 5 === 0 ? 1 : 3;
|
|
//const IDRflag = index % 5 === 0 ? 1 : 3;
|
|
const IDRflag = item.isIDR ? 1 : 3;
|
|
const IDRflag = item.isIDR ? 1 : 3;
|
|
const dir = this.isHeaderOrLast(
|
|
const dir = this.isHeaderOrLast(
|
|
@@ -725,16 +734,16 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
|
|
if (seqs?.length) {
|
|
if (seqs?.length) {
|
|
this.logger.log(
|
|
this.logger.log(
|
|
'walking --队列总览:' +
|
|
'walking --队列总览:' +
|
|
- ' 总段数: ' +
|
|
|
|
- walkingRes.length +
|
|
|
|
- ' 镜头帧数:' +
|
|
|
|
- walkingRes[0].length +
|
|
|
|
- ' 行走段数:' +
|
|
|
|
- (walkingRes[0]?.length
|
|
|
|
- ? walkingRes.length - 1
|
|
|
|
- : walkingRes.length) +
|
|
|
|
- ' 队列总帧数:' +
|
|
|
|
- seqs.length,
|
|
|
|
|
|
+ ' 总段数: ' +
|
|
|
|
+ walkingRes.length +
|
|
|
|
+ ' 镜头帧数:' +
|
|
|
|
+ walkingRes[0].length +
|
|
|
|
+ ' 行走段数:' +
|
|
|
|
+ (walkingRes[0]?.length
|
|
|
|
+ ? walkingRes.length - 1
|
|
|
|
+ : walkingRes.length) +
|
|
|
|
+ ' 队列总帧数:' +
|
|
|
|
+ seqs.length,
|
|
);
|
|
);
|
|
const stop = performance.now();
|
|
const stop = performance.now();
|
|
const inMillSeconds = stop - start;
|
|
const inMillSeconds = stop - start;
|
|
@@ -792,7 +801,7 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
|
|
//console.log('joystickRes有mediaSrc', joystickRes.mediaSrc);
|
|
//console.log('joystickRes有mediaSrc', joystickRes.mediaSrc);
|
|
console.log(
|
|
console.log(
|
|
'handlejoystick-angle->相机角度-------------------------:' +
|
|
'handlejoystick-angle->相机角度-------------------------:' +
|
|
- joystickRes['newUserStates'][0].playerState.camera.angle.yaw,
|
|
|
|
|
|
+ joystickRes['newUserStates'][0].playerState.camera.angle.yaw,
|
|
);
|
|
);
|
|
let streamData: StreamFrameType | StreamMetaType;
|
|
let streamData: StreamFrameType | StreamMetaType;
|
|
|
|
|
|
@@ -814,11 +823,11 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
|
|
};
|
|
};
|
|
console.log(
|
|
console.log(
|
|
'handlejoystick-hasMedia->-------------------------:' +
|
|
'handlejoystick-hasMedia->-------------------------:' +
|
|
- ' frame: ' +
|
|
|
|
- streamData.frame +
|
|
|
|
- mediaSrc +
|
|
|
|
- ' IDR :' +
|
|
|
|
- setDIR,
|
|
|
|
|
|
+ ' frame: ' +
|
|
|
|
+ streamData.frame +
|
|
|
|
+ mediaSrc +
|
|
|
|
+ ' IDR :' +
|
|
|
|
+ setDIR,
|
|
);
|
|
);
|
|
} else {
|
|
} else {
|
|
streamData = {
|
|
streamData = {
|
|
@@ -837,8 +846,8 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
|
|
const hasPush = hasMedia
|
|
const hasPush = hasMedia
|
|
? await this.streamService.pushFrameToSteam(streamData as StreamFrameType)
|
|
? await this.streamService.pushFrameToSteam(streamData as StreamFrameType)
|
|
: await this.streamService.pushMetaDataToSteam(
|
|
: await this.streamService.pushMetaDataToSteam(
|
|
- streamData as StreamMetaType,
|
|
|
|
- );
|
|
|
|
|
|
+ streamData as StreamMetaType,
|
|
|
|
+ );
|
|
|
|
|
|
if (hasPush.done) {
|
|
if (hasPush.done) {
|
|
this.isJoystickHasStream = true;
|
|
this.isJoystickHasStream = true;
|
|
@@ -875,9 +884,9 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
|
|
if (complementFrame) {
|
|
if (complementFrame) {
|
|
console.log(
|
|
console.log(
|
|
'20220627test-complementFrame 进行' +
|
|
'20220627test-complementFrame 进行' +
|
|
- complementFrame.mediaSrc +
|
|
|
|
- '***' +
|
|
|
|
- this.frameCnt.value,
|
|
|
|
|
|
+ complementFrame.mediaSrc +
|
|
|
|
+ '***' +
|
|
|
|
+ this.frameCnt.value,
|
|
);
|
|
);
|
|
// 第二次或N次进入时如果有值直接重新进入流主程
|
|
// 第二次或N次进入时如果有值直接重新进入流主程
|
|
this.holdSteam();
|
|
this.holdSteam();
|
|
@@ -950,7 +959,7 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
|
|
const joystickRes = await this.moveService.seqExeJoystick(request);
|
|
const joystickRes = await this.moveService.seqExeJoystick(request);
|
|
this.logger.log(
|
|
this.logger.log(
|
|
'joystick-breakPointId:' +
|
|
'joystick-breakPointId:' +
|
|
- this.moveService.users[this.user_id].breakPointId,
|
|
|
|
|
|
+ this.moveService.users[this.user_id].breakPointId,
|
|
);
|
|
);
|
|
// 有数据 [0]是rotate数据,[1-infinity]是walking数据
|
|
// 有数据 [0]是rotate数据,[1-infinity]是walking数据
|
|
//this.logger.log('joystickRes', JSON.stringify(joystickRes));
|
|
//this.logger.log('joystickRes', JSON.stringify(joystickRes));
|
|
@@ -1035,14 +1044,14 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
|
|
};
|
|
};
|
|
this.logger.log(
|
|
this.logger.log(
|
|
'[media-move]: ' +
|
|
'[media-move]: ' +
|
|
- ', moveframeCnt: ' +
|
|
|
|
- this.moveframeCnt +
|
|
|
|
- ', clipPath: ' +
|
|
|
|
- stream.clipPath +
|
|
|
|
- ', mType: ' +
|
|
|
|
- stream.mType +
|
|
|
|
- ', DIR: ' +
|
|
|
|
- stream.DIR,
|
|
|
|
|
|
+ ', moveframeCnt: ' +
|
|
|
|
+ this.moveframeCnt +
|
|
|
|
+ ', clipPath: ' +
|
|
|
|
+ stream.clipPath +
|
|
|
|
+ ', mType: ' +
|
|
|
|
+ stream.mType +
|
|
|
|
+ ', DIR: ' +
|
|
|
|
+ stream.DIR,
|
|
// stream.metaData,
|
|
// stream.metaData,
|
|
);
|
|
);
|
|
this.logger.log(
|
|
this.logger.log(
|
|
@@ -1140,6 +1149,7 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
|
|
// this.startStream();
|
|
// this.startStream();
|
|
// this.handleStream();
|
|
// this.handleStream();
|
|
this.channel.onBufferedAmountLow(() => {
|
|
this.channel.onBufferedAmountLow(() => {
|
|
|
|
+ console.error('onBufferedAmountLow-rtt', this.peer.rtt());
|
|
console.error('onBufferedAmountLow', this.channel.bufferedAmount());
|
|
console.error('onBufferedAmountLow', this.channel.bufferedAmount());
|
|
//64k->65536 128k->131072
|
|
//64k->65536 128k->131072
|
|
this.channel.setBufferedAmountLowThreshold(262144);
|
|
this.channel.setBufferedAmountLowThreshold(262144);
|
|
@@ -1300,14 +1310,17 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
|
|
try {
|
|
try {
|
|
this.logger.log('frame', frame);
|
|
this.logger.log('frame', frame);
|
|
console.log(
|
|
console.log(
|
|
- 'mock' +
|
|
|
|
- ' maxMessageSize: ' +
|
|
|
|
- this.channel.maxMessageSize() +
|
|
|
|
- ' bytesReceived: ' +
|
|
|
|
- this.peer.bytesReceived() +
|
|
|
|
- ' bytesSent: ' +
|
|
|
|
- this.peer.bytesSent(),
|
|
|
|
- ' state: ' + this.peer.state(),
|
|
|
|
|
|
+ 'networkState:::--->' +
|
|
|
|
+ ' maxMessageSize: ' +
|
|
|
|
+ this.channel.maxMessageSize() +
|
|
|
|
+ ' bytesReceived: ' +
|
|
|
|
+ this.peer.bytesReceived() +
|
|
|
|
+ ' bytesSent: ' +
|
|
|
|
+ this.peer.bytesSent() +
|
|
|
|
+ ' rtt: ' +
|
|
|
|
+ this.peer.rtt() +
|
|
|
|
+ ' state: ' +
|
|
|
|
+ this.peer.state(),
|
|
);
|
|
);
|
|
if (frame === 1) {
|
|
if (frame === 1) {
|
|
// redisData = await this.rotateService.echo(this.user_id, true);
|
|
// redisData = await this.rotateService.echo(this.user_id, true);
|
|
@@ -1328,7 +1341,7 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
|
|
delete redisData.mediaSrc;
|
|
delete redisData.mediaSrc;
|
|
this.logger.log(
|
|
this.logger.log(
|
|
`user:${this.user_id}:first render stream` +
|
|
`user:${this.user_id}:first render stream` +
|
|
- JSON.stringify({ path: clipPath, meta: redisData }),
|
|
|
|
|
|
+ JSON.stringify({ path: clipPath, meta: redisData }),
|
|
);
|
|
);
|
|
const status = await this.pushFirstRender(
|
|
const status = await this.pushFirstRender(
|
|
clipPath,
|
|
clipPath,
|
|
@@ -1357,17 +1370,17 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
|
|
|
|
|
|
console.log(
|
|
console.log(
|
|
'空白流条件-->:' +
|
|
'空白流条件-->:' +
|
|
- isOk +
|
|
|
|
- ' onMoving: ' +
|
|
|
|
- this.onMoving.value +
|
|
|
|
- ' onRotating: ' +
|
|
|
|
- this.onRotating.value +
|
|
|
|
- ' onJoysticking: ' +
|
|
|
|
- this.onJoysticking.value +
|
|
|
|
- ' onSteaming: ' +
|
|
|
|
- this.onSteaming +
|
|
|
|
- ' firstRender: ' +
|
|
|
|
- this.firstRender,
|
|
|
|
|
|
+ isOk +
|
|
|
|
+ ' onMoving: ' +
|
|
|
|
+ this.onMoving.value +
|
|
|
|
+ ' onRotating: ' +
|
|
|
|
+ this.onRotating.value +
|
|
|
|
+ ' onJoysticking: ' +
|
|
|
|
+ this.onJoysticking.value +
|
|
|
|
+ ' onSteaming: ' +
|
|
|
|
+ this.onSteaming +
|
|
|
|
+ ' firstRender: ' +
|
|
|
|
+ this.firstRender,
|
|
);
|
|
);
|
|
}
|
|
}
|
|
|
|
|