笔记.txt 1.1 KB

123456789101112131415161718192021222324
  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赋值(每帧的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里)上,显示最终的效果