笔记.txt 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. ActionsHandler类中,函数sendData根据用户操作发送不同的数据到服务器
  2. 服务器接受来自sendData的请求数据后,发送视频流(通过webrtc里的inputChannel.onmessage)
  3. 前端主线程接受到数据后,开始执行
  4. this.workers.dataHandle(r.data) ——> unmarshalStream函数里,通过this.decoderWorker.postMessage(z, [D.buffer])将视频数据传输到worker
  5. worker里,通过self.onmessage接受到来自主线程的请求并开始执行,然后通过self.postMessage发送请求并传输数据(怀疑将视频流解析成每一帧的yuv数据)到主线程
  6. 主线程通过decoderWorker.onmessage来接受来自worker的数据并执行,主要是执行函数:ReceiveDecodeMessage
  7. ReceiveDecodeMessage函数里给cachedStreams/cachedMetas/cachedPtss/cachedRender赋值(每帧的yuv数据)
  8. UpdateYUV通过定时器定时运行,并读取cachedStreams的数据,如下:
  9. this.cachedStreams[e] != null && this.executeFunction("stream", {
  10. stream: this.cachedStreams[e],
  11. width: this.cachedResolution[e].width,
  12. height: this.cachedResolution[e].height,
  13. pts: this.cachedPtss[e]
  14. });
  15. stream函数因为提前注册过,一旦调用executeFunction,就会执行registerFunction("stream")
  16. registerFunction("stream")里会调用updateRawYUVData
  17. updateRawYUVData函数会将stream传送到材质贴图(_videoRawYUVTexArray里)上,显示最终的效果
  18. /*****************************************************************************************************************************************************************************************************************/
  19. 旋转:
  20. 发送数据:
  21. {
  22. "data": {
  23. "action_type": 1014,
  24. "rotation_action": {
  25. "vertical_move": 0,
  26. "horizontal_move": -0.003703703703703704
  27. }
  28. },
  29. "sampleRate": 0.02
  30. }
  31. 心跳:
  32. 发送数据:{"data":{"action_type":1009,"echo_msg":{"echoMsg":"1650272307696"}},"track":false}
  33. 漫游:
  34. 发送数据:
  35. {
  36. "data": {
  37. "action_type": 1,
  38. "clicking_action": {
  39. "clicking_point": {
  40. "x": 1396.4945740787787,
  41. "y": 2173.158025839534,
  42. "z": 1.5306104000406329
  43. },
  44. "clicking_type": 3,
  45. "extra": "",
  46. "attitude": "walk"
  47. },
  48. "clicking_state": {
  49. "roomTypeId": "",
  50. "person": 0,
  51. "avatarId": "",
  52. "skinId": "",
  53. "roomId": "",
  54. "isHost": false,
  55. "isFollowHost": false,
  56. "skinDataVersion": "",
  57. "avatarComponents": "",
  58. "nickName": "",
  59. "movingMode": 0,
  60. "attitude": "",
  61. "areaName": "",
  62. "pathName": "",
  63. "pathId": "",
  64. "avatarSize": 1,
  65. "extra": "",
  66. "prioritySync": false,
  67. "player": {
  68. "position": {
  69. "x": 1540,
  70. "y": 2310,
  71. "z": 0
  72. },
  73. "angle": {
  74. "pitch": 0,
  75. "yaw": 0,
  76. "roll": 0
  77. }
  78. },
  79. "camera": {
  80. "position": {
  81. "x": 1939.5182,
  82. "y": 2329.627,
  83. "z": 150
  84. },
  85. "angle": {
  86. "pitch": 0,
  87. "yaw": 182.8125,
  88. "roll": 0
  89. }
  90. },
  91. "cameraCenter": {
  92. "x": 1540,
  93. "y": 2310,
  94. "z": 0
  95. }
  96. }
  97. }
  98. }
  99. 发送数据:{"data":{"action_type":1004,"get_neighbor_points_action":{"point":{"x":1400,"y":2175,"z":0},"level":1,"containSelf":true,"searchRange":1000}}}