public void CommitFrame (Frame frame) { // Invert var correctedFrame = AcquireFrame(); correctedFrame.timestamp = frame.timestamp; Graphics.Blit(frame, correctedFrame, transformMat); RenderTexture.ReleaseTemporary(frame); frame = correctedFrame; // Submit #if DEFERRED_READBACK dispatch.Dispatch(() => dispatch.Dispatch(() => { // Defer readback for (at least) one frame if (!IsRecording) return; #endif var currentRT = RenderTexture.active; RenderTexture.active = frame; framebuffer.ReadPixels(new Rect(0, 0, configuration.width, configuration.height), 0, 0, false); RenderTexture.active = currentRT; RenderTexture.ReleaseTemporary(frame); var pixelBuffer = framebuffer.GetRawTextureData(); var bufferHandle = GCHandle.Alloc(pixelBuffer, GCHandleType.Pinned); NatCorderBridge.EncodeFrame(bufferHandle.AddrOfPinnedObject(), frame.timestamp); bufferHandle.Free(); #if DEFERRED_READBACK })); #endif }
public void CommitFrame(Frame frame) { var handle = ((RenderTexture)frame).GetNativeTexturePtr(); framePool.Add(handle, frame); NatCorderBridge.EncodeFrame(handle, frame.timestamp); }
public virtual void CommitFrame (Frame frame) { // Submit #if DEFERRED_READBACK dispatch.Dispatch(() => { if (dispatch != null) dispatch.Dispatch(() => { // Defer readback for (at least) one frame if (!IsRecording) { RenderTexture.ReleaseTemporary(frame); return; } #endif var currentRT = RenderTexture.active; RenderTexture.active = frame; framebuffer.ReadPixels(new Rect(0, 0, configuration.width, configuration.height), 0, 0, false); RenderTexture.active = currentRT; RenderTexture.ReleaseTemporary(frame); var pixelBuffer = framebuffer.GetRawTextureData(); var bufferHandle = GCHandle.Alloc(pixelBuffer, GCHandleType.Pinned); NatCorderBridge.EncodeFrame(bufferHandle.AddrOfPinnedObject(), frame.timestamp); bufferHandle.Free(); #if DEFERRED_READBACK }); else RenderTexture.ReleaseTemporary(frame); }); #endif }
public void Commit(Frame frame) { // Make upright RenderTexture surface = Acquire(); Graphics.Blit(frame, surface, transformMat); RenderTexture.ReleaseTemporary(frame); // Commit var handle = surface.GetNativeTexturePtr(); framePool.Add(handle, surface); NatCorderBridge.EncodeFrame(handle, frame.timestamp); }