笔记.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. handleSignal
  19. /*****************************************************************************************************************************************************************************************************************/
  20. 旋转:
  21. 发送数据:
  22. {
  23. "data": {
  24. "action_type": 1014,
  25. "rotation_action": {
  26. "vertical_move": 0,
  27. "horizontal_move": -0.003703703703703704
  28. }
  29. },
  30. "sampleRate": 0.02
  31. }
  32. 心跳:
  33. 发送数据:{"data":{"action_type":1009,"echo_msg":{"echoMsg":"1650272307696"}},"track":false}
  34. 漫游:
  35. 发送数据:
  36. {
  37. "data": {
  38. "action_type": 1,
  39. "clicking_action": {
  40. "clicking_point": {
  41. "x": 1396.4945740787787,
  42. "y": 2173.158025839534,
  43. "z": 1.5306104000406329
  44. },
  45. "clicking_type": 3,
  46. "extra": "",
  47. "attitude": "walk"
  48. },
  49. "clicking_state": {
  50. "roomTypeId": "",
  51. "person": 0,
  52. "avatarId": "",
  53. "skinId": "",
  54. "roomId": "",
  55. "isHost": false,
  56. "isFollowHost": false,
  57. "skinDataVersion": "",
  58. "avatarComponents": "",
  59. "nickName": "",
  60. "movingMode": 0,
  61. "attitude": "",
  62. "areaName": "",
  63. "pathName": "",
  64. "pathId": "",
  65. "avatarSize": 1,
  66. "extra": "",
  67. "prioritySync": false,
  68. "player": {
  69. "position": {
  70. "x": 1540,
  71. "y": 2310,
  72. "z": 0
  73. },
  74. "angle": {
  75. "pitch": 0,
  76. "yaw": 0,
  77. "roll": 0
  78. }
  79. },
  80. "camera": {
  81. "position": {
  82. "x": 1939.5182,
  83. "y": 2329.627,
  84. "z": 150
  85. },
  86. "angle": {
  87. "pitch": 0,
  88. "yaw": 182.8125,
  89. "roll": 0
  90. }
  91. },
  92. "cameraCenter": {
  93. "x": 1540,
  94. "y": 2310,
  95. "z": 0
  96. }
  97. }
  98. }
  99. }
  100. 发送数据:{"data":{"action_type":1004,"get_neighbor_points_action":{"point":{"x":1400,"y":2175,"z":0},"level":1,"containSelf":true,"searchRange":1000}}}