xushiting преди 3 години
родител
ревизия
8e1656d25f

+ 71 - 0
src/main/java/com/fdkk/fdkkmeta/ctroller/TestRTCController.java

@@ -0,0 +1,71 @@
+package com.fdkk.fdkkmeta.ctroller;
+
+import java.util.List;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.PostMapping;
+
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.fdkk.fdkkmeta.domain.entity.mysql.RoomEntity;
+import com.fdkk.fdkkmeta.service.RotateFrameService;;
+
+public class TestRTCController {
+	
+	private static final int Echo = 1009;
+	private static final int GetNewUserState = 1009;
+	
+    @Autowired
+    RotateFrameService rotateFrameService;
+
+    @PostMapping("/init")
+    public int Init(HttpServletRequest request,HttpServletResponse response) {
+    	//创建用户
+    	try {
+    		String user_id = request.getParameter("user_id");
+    		String nick_name = request.getParameter("nick_name");
+    		String skin_id = request.getParameter("skin_id");
+    		String avatar_id = request.getParameter("avatar_id");
+    		String room_id = request.getParameter("room_id");
+    		String app_id = request.getParameter("app_id");
+    		
+    		JSONObject initFrameInfo = rotateFrameService.getInitFrameInfo(app_id);
+    		String frameId = initFrameInfo.getString("frameId");
+    		String breakPointId = initFrameInfo.getString("breakPointId");
+    		//保存到user
+    		return 1;
+    	}
+    	catch(Exception e) {
+    		e.printStackTrace();
+    		return -1;
+    	}
+    }
+    
+    @PostMapping("/rotate")
+    public int rotate(HttpServletRequest request,HttpServletResponse response) {
+    	try {
+    		String action_type = request.getParameter("action_type");
+    		String trace_id = request.getParameter("trace_id");
+    		String user_id = request.getParameter("user_id");
+    		JSONObject rotation_action = (JSONObject)request.getAttribute("rotation_action");
+    		double horizontal_move = rotation_action.getDoubleValue("horizontal_move");
+
+    		double hAngle = horizontal_move * 90;
+    		
+    		int offFrameIndex = (int)Math.ceil(hAngle);
+    		int currentFrame = 0;      //从数据库里读取
+    		
+    		currentFrame +=offFrameIndex;
+    		currentFrame = currentFrame % 359;
+    		
+    		return 1;
+    	}
+    	catch(Exception e) {
+    		e.printStackTrace();
+    		return -1;
+    	}
+    }
+}

+ 56 - 0
src/main/java/com/fdkk/fdkkmeta/grpcService/sceneGrpcServer.java

@@ -73,5 +73,61 @@ public class sceneGrpcServer extends SceneGrpcServiceGrpc.SceneGrpcServiceImplBa
         responseObserver.onNext(builder.build());
         responseObserver.onCompleted();
     }
+    
+    @Override
+    public void init(InitRequest request, StreamObserver<NormalReply> responseObserver)   {
+    	try {
+    	
+    	}
+    	catch(Exception e) {
+    		e.printStackTrace();
+    	}
+    }
 
+    @Override
+    public void rotate(RotateRequest request, StreamObserver<NormalReply> responseObserver)   {
+    	try {
+    	
+    	}
+    	catch(Exception e) {
+    		e.printStackTrace();
+    	}
+    }
+    
+    @Override
+    public void move(MoveRequest request, StreamObserver<MoveReply> responseObserver)   {
+     	try {
+        	/*
+        	 * 1.从user表里获得当前人物所在的breakPoint_id
+        	 * 2.根据breakPoint_id,从breakpoints表里获得对应的起始坐标
+        	 * 3.根据request中的clicking_action里的clicking_point(目的地)以及当前起始坐标计算出路径
+        	 * 4.返回整个路径的一段
+        	 * 
+        	 * */
+    	}
+    	catch(Exception e) {
+    		e.printStackTrace();
+    	}
+    }
+    
+    @Override
+    public void getBreakPoint(BreakPointRequest request, StreamObserver<BreakPointReply> responseObserver)   {
+     	try {
+        	
+    	}
+    	catch(Exception e) {
+    		e.printStackTrace();
+    	}
+    }
+    
+    //操作杆
+    @Override
+    public void joystick(JoystickRequest request, StreamObserver<NormalReply> responseObserver)   {
+     	try {
+        	
+    	}
+    	catch(Exception e) {
+    		e.printStackTrace();
+    	}
+    }
 }

+ 2 - 0
src/main/java/com/fdkk/fdkkmeta/service/RotateFrameService.java

@@ -1,5 +1,6 @@
 package com.fdkk.fdkkmeta.service;
 
+import com.alibaba.fastjson.JSONObject;
 import com.fdkk.fdkkmeta.base.IBaseService;
 import com.fdkk.fdkkmeta.domain.entity.mysql.MoveFrameEntity;
 import com.fdkk.fdkkmeta.domain.entity.mysql.RotateFrameEntity;
@@ -11,4 +12,5 @@ import java.util.List;
  */
 public interface RotateFrameService extends IBaseService<RotateFrameEntity> {
     List<RotateFrameEntity> findBySceneId(String sceneId);
+    JSONObject getInitFrameInfo(String app_id);
 }

+ 6 - 0
src/main/java/com/fdkk/fdkkmeta/service/impl/RotateFrameImpl.java

@@ -1,5 +1,6 @@
 package com.fdkk.fdkkmeta.service.impl;
 
+import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.fdkk.fdkkmeta.mapper.RotateFrameMapper;
@@ -24,5 +25,10 @@ public class RotateFrameImpl extends BaseServiceImpl<RotateFrameMapper, RotateFr
         wrapper.eq(RotateFrameEntity::getSceneId, sceneId);
         return list(wrapper);
     }
+    
+    public JSONObject getInitFrameInfo(String app_id) {
+    	//取app_id对应的frame,且breakPointId和frameIndex都是0
+    	return new JSONObject();
+    }
 
 }

+ 215 - 2
src/main/proto/scene.proto

@@ -9,19 +9,32 @@ option java_package = "com.fdkk.fdkkmeta.grpc";
 service SceneGrpcService {
   rpc testMethod (SceneRequest) returns (SceneReply){}
   rpc getRoute (RouteRequest) returns (RouteReply){}
-
+  rpc init (InitRequest) returns (NormalReply){}
+  rpc rotate (RotateRequest) returns (NormalReply){}
+  rpc move (MoveRequest) returns (MoveReply){}
+  rpc getBreakPoint (BreakPointRequest) returns (BreakPointReply){}
+  rpc joystick (JoystickRequest) returns (NormalReply){} //操作杆
 }
 // 全局对象
 message Point {
-  string x=1;
+  string x=1;     //应该换成double
   string y=2;
   string z=3;
 }
+
+// 全局对象
+message AngleUe4 {
+  int32 pitch=1;
+  int32 yaw=2;
+  int32 roll=3;
+}
+
 // 全局对象
 message RouteArray{
   int32 id=1;
   Point location=2;
 }
+
 // getRoute入参对象
 message RouteRequest {
   Point s_location=1;
@@ -44,3 +57,203 @@ message SceneReply {
   string res=1;
 }
 
+/***********************************************************/
+message Space {
+   Point position=1;
+   AngleUe4 angle=2;
+}
+
+message State {
+   string roomTypeId=1;
+   int32 person=2;
+   string avatarId=3;
+   string skinId=4;
+   string roomId=5;
+   bool isHost=6;
+   bool isFollowHost=7;
+   string skinDataVersion=8;
+   string avatarComponents=9;
+   string nickName=10;
+   int32 movingMode=11;
+   string attitude=12;
+   string areaName=13;
+   string pathName=14;
+   string pathId=15;
+   int32 avatarSize=16;
+   string extra=17;
+   bool prioritySync=18;
+   Space player=19;
+   Space camera=20;
+   Point cameraCenter=21;
+}
+
+message RenderInfo{
+   int32 renderType=1;
+   string videoFrame=2;
+   int32 cameraStateType=3;
+   int32 isMoving=4;
+   int32 needIfr=5;
+   int32 isVideo=6;
+   int32 stillFrame=7;
+   int32 isRotating=8;
+   int32 isFollowing=9;
+   repeated string clientPanoTitlesBitmap=10;
+   string clientPanoTreceId=11;
+   string prefetchVideoId=12;
+   bool noMedia=13;
+} 
+
+message Event{
+   string id=1;
+   int32 type =2;
+   repeated Point points=3;
+   string rotateEvent=4;
+   string removeVisitorEvent=5;
+}
+
+message UserState{
+   string userId=1;
+   State playerState=2;
+   RenderInfo renderInfo=3;
+   Event event=4;
+   int32 relation=5;
+}
+/***********************************************************/
+
+// init入参对象
+message InitRequest {
+  string user_id=1;
+  string nick_name=2;
+  string skin_id=3;
+  string avatar_id=4;
+  string room_id=5;
+  string app_id=6;
+}
+
+/**********************************************************/
+//全局对象,旋转的参数
+message rotation_action{
+  int32 vertical_move=1;
+  double horizontal_move=2;
+}
+
+// rotate入参对象
+message RotateRequest {
+  int32 action_type=1;
+  string rotation_action=2;
+  string trace_id=3;
+  string user_id=4;
+}
+
+/**********************************************************/
+//正常的反馈
+message NormalReply {
+   repeated string traceIds=1;
+   string vehicle=2;
+   repeated UserState newUserStates=3;
+   repeated int32 actionResponses=4;
+   int32 getStateType=5;
+   int32 code=6;
+   string msg=7;
+   string frameSrc=8;              //视频路径
+}
+
+/**********************************************************/
+//
+message ClickingAction {
+   Point clicking_point=1;
+   int32 clicking_type=2;
+   string extra=3;
+   string attitude=4;
+}
+
+// 开始请求漫游
+message StartMoveRequest {
+  int32 action_type=1;
+  ClickingAction clicking_action=2;
+  State clicking_state=3;
+  string trace_id=4;
+  string user_id=5;
+}
+
+// 请求移动下一段
+message MoveNextNeighborRequest {
+  int32 user_id=1;
+  string trace_id=2;
+  bool next=3;
+}
+
+// 结束移动下一段(一般是有新的请求)
+message EndMoveNextNeighborRequest {
+  int32 user_id=1;
+  string trace_id=2;
+  bool next=3;
+}
+
+// move出参对象
+// 这需要自定义
+message MoveReply {
+   repeated string traceIds=1;
+   string vehicle=2;
+   repeated UserState newUserStates=3;      //自己的话,不要有player,camera和cameraCenter。自己对应的这三个属性在8,9,10上,到webrtc服务器上组装
+   repeated int32 actionResponses=4;
+   int32 getStateType=5;
+   int32 code=6;
+   string msg=7;
+   //每一段的人物和相机坐标,第一段可能还有初始旋转
+   repeated Space player=8;
+   repeated Space camera=9;
+   repeated Point cameraCenter=10;
+   bool isEnd=11;     //false表示可以继续移动,true表示这次移动已经结束
+}
+/**********************************************************/
+
+/**********************************************************/
+message DirAction{
+  int32 move_angle=1;
+  int32 speed_level=2;
+}
+
+//控制杆移动
+message JoystickRequest {
+  int32 action_type=1;
+  DirAction dir_action=2;
+  string trace_id=3;
+  string user_id=4;
+  string packet_id=5;
+}
+/**********************************************************/
+
+/**********************************************************/
+message NeighborPointsAction{
+  Point point=1;
+  int32 level=2;
+  bool containSelf=3;
+  int32 searchRange=4;
+}
+
+// move入参对象
+message BreakPointRequest{
+  int32 action_type=1;
+  NeighborPointsAction get_neighbor_points_action=2;
+  string trace_id=3;
+  string user_id=4;
+}
+// move出参对象
+message BreakPointReply {
+  int32 actionType=1;
+  int32 pointType=2;
+  string extra=3;
+  string traceId=4;
+  string packetId=5;
+  repeated Point nps=6;
+  int32 peopleNum=7;
+  string zoneId=8;
+  string echoMsg=9;
+  string reserveDetail=10;
+  repeated string userWithAvatarList=11;
+  repeated UserState newUserStates=12;
+  int32 code=13;
+  string msg=14;
+}
+/**********************************************************/