void Update() { if (Decoder == null) { return; } var NewFrameNumber = Decoder.GetNextFrame(ref Planes, ref PlaneFormats); if (!NewFrameNumber.HasValue) { return; } if (EnableDebug) { Debug.Log(this.name + " decoded frame " + NewFrameNumber.Value + ". Planes x" + Planes.Count); } OnDepthTextureUpdated.Invoke(Planes[0]); // update material if (CloudMaterial != null && LastPacketMeta != null) { UpdateMaterial(CloudMaterial, LastPacketMeta, Planes[0]); } }
void Update() { if (Decoder == null) { return; } var NewFrame = Decoder.GetNextFrame(ref FramePlanes, ref FramePlaneFormats); if (NewFrame.HasValue) { Debug.Log("Decoded frame " + NewFrame.Value); } }
// returns if any frames decoded. bool DecodeNextFrameImage() { if (Decoder == null) { return(false); } // only pull out next frame, if we WANT the pending frame times if (PendingOutputFrameTimes == null) { return(false); } if (PendingOutputFrameTimes.Count == 0) { Debug.Log("Not expecting any more frames added extra PendingOutputFrameTimes " + (DecodeToVideoTimeMs + 1)); //return false; PendingOutputFrameTimes.Add(DecodeToVideoTimeMs + 1); } // not reached next frame yet if (DecodeToVideoTimeMs < PendingOutputFrameTimes[0]) { Debug.Log("DecodeToVideoTimeMs " + DecodeToVideoTimeMs + " < PendingOutputFrameTimes[0] " + PendingOutputFrameTimes[0]); return(false); } var FrameTime = Decoder.GetNextFrame(ref PlaneTextures, ref PlaneFormats); // nothing decoded if (!FrameTime.HasValue) { if (Decoder.HadEndOfStream) { if (VerboseDebug) { Debug.Log("EndOfStream detected"); } if (!OnFinishedCalled) { Debug.Log("OnFinished call"); // set this flag before calling, as the call may cause a reset OnFinishedCalled = true; OnFinished.Invoke(); } } return(false); } var ExpectedTime = PendingOutputFrameTimes[0]; // gr: there's something off here, we don't seem to decode early frames // is the decoder skipping frames? (no!) or are the times offset? // anyway, once we get a frame in the future, we shouldn't expect any older ones, so clear the pending list up to this frame if (FrameTime.Value != ExpectedTime) { if (VerboseDebug) { Debug.Log("Decoded frame " + FrameTime.Value + ", expected " + ExpectedTime + " when seeking to " + DecodeToVideoTimeMs); } } // remove all the frames we may have skipped over while (PendingOutputFrameTimes.Count > 0) { if (PendingOutputFrameTimes[0] > FrameTime.Value) { break; } PendingOutputFrameTimes.RemoveAt(0); } OnNewFrame(); OnNewFrameTime.Invoke("" + FrameTime.Value); if (LastFrameTime.HasValue && LastFrameTime.Value == FrameTime.Value) { if (VerboseDebug) { Debug.Log("Decoded last frame"); } if (!OnFinishedCalled) { OnFinished.Invoke(); } } return(true); }