private IEnumerator SdiInputCoroutine() { yield return(new WaitForEndOfFrame()); yield return(new WaitForEndOfFrame()); UtyGLNvSdi.SdiSetupLogFile(); UtyGLNvSdi.SdiInputSetBufferSize(options.inputRingBufferSize); UtyGLNvSdi.SdiInputSetCaptureFields(options.inputCaptureFields); // Issue a plugin event with an integer identifier. // The plugin can distinguish between different based on this ID. GL.IssuePluginEvent(UtyGLNvSdi.GetSdiInputRenderEventFunc(), (int)SdiRenderEvent.Initialize); yield return(new WaitForEndOfFrame()); if (options.inputCaptureFields) { CreateTextures(8, UtyGLNvSdi.SdiInputWidth(), UtyGLNvSdi.SdiInputHeight() / 2); } else { CreateTextures(4, UtyGLNvSdi.SdiInputWidth(), UtyGLNvSdi.SdiInputHeight()); } yield return(new WaitForEndOfFrame()); GL.IssuePluginEvent(UtyGLNvSdi.GetSdiInputRenderEventFunc(), (int)SdiRenderEvent.Setup); GL.IssuePluginEvent(UtyGLNvSdi.GetSdiInputRenderEventFunc(), (int)SdiRenderEvent.StartCapture); yield return(new WaitForEndOfFrame()); sdiEnabled = true; while (UtyGLNvSdi.SdiInputIsCapturing()) { // Wait until all frame rendering is done yield return(new WaitForEndOfFrame()); // Get status of the capture (GL_SUCCESS_NV, GL_FAILURE_NV, GL_PARTIAL_SUCCESS_NV) //Debug.Log(UtyGLNvSdi.SdiInputCaptureStatus().ToString()); // Capture frame from device GL.IssuePluginEvent(UtyGLNvSdi.GetSdiInputRenderEventFunc(), (int)SdiRenderEvent.CaptureFrame); } }
private IEnumerator SdiIOCoroutine() { yield return(new WaitForEndOfFrame()); UtyGLNvSdi.SdiInputSetBufferSize(options.inputRingBufferSize); UtyGLNvSdi.SdiInputSetCaptureFields(options.inputCaptureFields); // // Input/Ouput Initialization // GL.IssuePluginEvent(UtyGLNvSdi.GetSdiInputRenderEventFunc(), (int)SdiRenderEvent.Initialize); GL.IssuePluginEvent(UtyGLNvSdi.GetSdiOutputRenderEventFunc(), (int)SdiRenderEvent.Initialize); yield return(new WaitForEndOfFrame()); if (UtyGLNvSdi.SdiError() == 0) { // // Input Setup // if (options.inputCaptureFields) { CreateSdiInputTextures(8, UtyGLNvSdi.SdiInputWidth(), UtyGLNvSdi.SdiInputHeight() / 2); } else { CreateSdiInputTextures(4, UtyGLNvSdi.SdiInputWidth(), UtyGLNvSdi.SdiInputHeight()); } GL.IssuePluginEvent(UtyGLNvSdi.GetSdiInputRenderEventFunc(), (int)SdiRenderEvent.Setup); GL.IssuePluginEvent(UtyGLNvSdi.GetSdiInputRenderEventFunc(), (int)SdiRenderEvent.StartCapture); yield return(new WaitForEndOfFrame()); // // Output Setup // UtyGLNvSdi.SdiOutputSetGlobalOptions(); UtyGLNvSdi.SdiOutputSetVideoFormat( options.videoFormat, options.syncSource, options.outputDelay, options.outputHorizontalDelay, options.outputVerticalDelay, options.outputDual, options.outputRingBufferSize); UtyGLNvSdi.SdiOutputComputePresentTimeFromCapture(true); yield return(new WaitForEndOfFrame()); GL.IssuePluginEvent(UtyGLNvSdi.GetSdiOutputRenderEventFunc(), (int)SdiRenderEvent.Setup); int texWidth = 1920; int texHeight = 1080; bool interlaced = true; float aspect = 1.0f; UtyGLNvSdi.GetSizeFromVideoFormat(options.videoFormat, ref texWidth, ref texHeight, ref aspect, ref interlaced); if (!SetupOutputTextures(texWidth, texHeight, aspect, interlaced, options.outputDual)) { UnityEngine.Debug.LogError("GLNvSdi_Plugin could not setup sdi textures for input/output"); } sdiEnabled = true; //while (true) //{ // // Wait until all frame rendering is done // yield return new WaitForEndOfFrame(); // // Capture frame from device // GL.IssuePluginEvent(UtyGLNvSdi.GetSdiInputRenderEventFunc(), (int)SdiRenderEvent.CaptureFrame); // // Present frame // GL.IssuePluginEvent(UtyGLNvSdi.GetSdiOutputRenderEventFunc(), (int)SdiRenderEvent.PresentFrame); //} } }