public bool UpdateFrame(UdpSocket udpSocket, SenderPacketSet senderPacketSet) { var videoMessageList = new List <Tuple <int, VideoSenderMessageData> >(); try { if (heartbeatStopWatch.Elapsed.TotalSeconds > HEARTBEAT_INTERVAL_SEC) { udpSocket.Send(PacketHelper.createHeartbeatReceiverPacketBytes(receiverSessionId), senderEndPoint); heartbeatStopWatch = Stopwatch.StartNew(); } if (senderPacketSet.ReceivedAny) { videoMessageAssembler.Assemble(udpSocket, senderPacketSet.VideoPacketDataList, senderPacketSet.FecPacketDataList, textureGroupUpdater.lastVideoFrameId, videoMessageList); audioPacketReceiver.Receive(senderPacketSet.AudioPacketDataList, kinectOrigin.Speaker.RingBuffer); receivedAnyStopWatch = Stopwatch.StartNew(); } else { if (receivedAnyStopWatch.Elapsed.TotalSeconds > HEARTBEAT_TIME_OUT_SEC) { UnityEngine.Debug.Log($"Timed out after waiting for {HEARTBEAT_TIME_OUT_SEC} seconds without a received packet."); return(false); } } } catch (UdpSocketException e) { UnityEngine.Debug.Log($"UdpSocketRuntimeError: {e}"); return(false); } textureGroupUpdater.UpdateFrame(udpSocket, videoMessageList); kinectOrigin.UpdateFrame(senderPacketSet.FloorPacketDataList); return(true); }
public void ReceivePackets(UdpSocket udpSocket, SenderPacketInfo senderPacketSet, Material material, RingBuffer ringBuffer) { videoMessageAssembler.Assemble(udpSocket, senderPacketSet.VideoPackets, senderPacketSet.ParityPackets, textureSetUpdater.lastFrameId, VideoMessages); if (textureSetUpdater.State == PrepareState.Unprepared && VideoMessages.Count > 0) { foreach (var videoMessage in VideoMessages.Values) { CoroutineRunner.Run(textureSetUpdater.Prepare(material, videoMessage)); break; } } audioReceiver.Receive(senderPacketSet.AudioPackets, ringBuffer); if (senderPacketSet.ReceivedAny) { receivedAnyStopWatch = Stopwatch.StartNew(); } }
public bool UpdateFrame(MonoBehaviour monoBehaviour, UdpSocket udpSocket, SenderPacketSet senderPacketSet) { // UpdateFrame() should not be called before Prepare(). Assert.AreEqual(PrepareState.Prepared, State); var videoMessageList = new List <Tuple <int, VideoSenderMessageData> >(); try { if (heartbeatStopWatch.Elapsed.TotalSeconds > HEARTBEAT_INTERVAL_SEC) { udpSocket.Send(PacketHelper.createHeartbeatReceiverPacketBytes(ReceiverSessionId), SenderEndPoint); heartbeatStopWatch = Stopwatch.StartNew(); } if (senderPacketSet.ReceivedAny) { // Use init packet to prepare rendering video messages. if (senderPacketSet.InitPacketDataList.Count > 0) { if (KinectOrigin.Screen.State == PrepareState.Unprepared) { KinectOrigin.Screen.StartPrepare(senderPacketSet.InitPacketDataList[0]); TextureGroupUpdater.StartPrepare(monoBehaviour, senderPacketSet.InitPacketDataList[0]); } } videoMessageAssembler.Assemble(udpSocket, senderPacketSet.VideoPacketDataList, senderPacketSet.FecPacketDataList, TextureGroupUpdater.lastVideoFrameId, videoMessageList); audioPacketReceiver.Receive(senderPacketSet.AudioPacketDataList, KinectOrigin.Speaker.RingBuffer); receivedAnyStopWatch = Stopwatch.StartNew(); } else { if (receivedAnyStopWatch.Elapsed.TotalSeconds > HEARTBEAT_TIME_OUT_SEC) { UnityEngine.Debug.Log($"Timed out after waiting for {HEARTBEAT_TIME_OUT_SEC} seconds without a received packet."); return(false); } } } catch (UdpSocketException e) { UnityEngine.Debug.Log($"UdpSocketRuntimeError: {e}"); return(false); } if (KinectOrigin.Screen.State == PrepareState.Preparing) { KinectOrigin.SetProgressText(SenderEndPoint, KinectOrigin.screen.Progress); KinectOrigin.ProgressTextVisibility = true; } else if (KinectOrigin.Screen.State == PrepareState.Prepared) { KinectOrigin.ProgressTextVisibility = false; } KinectOrigin.UpdateFrame(senderPacketSet.FloorPacketDataList); TextureGroupUpdater.UpdateFrame(udpSocket, videoMessageList); return(true); }