Esempio n. 1
0
    private IEnumerator SdiInputCoroutine()
    {
        yield return(new WaitForEndOfFrame());

        UtyGLNvSdi.SdiInputSetBufferSize(options.inputRingBufferSize);
        UtyGLNvSdi.SdiInputSetCaptureFields(false);

        // 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());

        SetupTextures();

        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);
        }
    }
Esempio n. 2
0
    void OnDisable()
    {
        if (sdiEnabled)
        {
            StopCoroutine(InputCoroutine);

            GL.IssuePluginEvent(UtyGLNvSdi.GetSdiInputRenderEventFunc(), (int)SdiRenderEvent.Shutdown);
            sdiEnabled = false;
        }
    }
Esempio n. 3
0
 public void UpdateFrame()
 {
     if (sdiEnabled)
     {
         // Capture frame from device
         GL.IssuePluginEvent(UtyGLNvSdi.GetSdiInputRenderEventFunc(), (int)SdiRenderEvent.CaptureFrame);
         // Present frame
         GL.IssuePluginEvent(UtyGLNvSdi.GetSdiOutputRenderEventFunc(), (int)SdiRenderEvent.PresentFrame);
     }
 }
Esempio n. 4
0
    void OnDisable()
    {
        if (sdiEnabled)
        {
            StopCoroutine(IOCoroutine);

            GL.IssuePluginEvent(UtyGLNvSdi.GetSdiOutputRenderEventFunc(), (int)SdiRenderEvent.Shutdown);
            GL.IssuePluginEvent(UtyGLNvSdi.GetSdiInputRenderEventFunc(), (int)SdiRenderEvent.Shutdown);
            sdiEnabled = false;
        }

        DestroyTextures();
        timeCodeHandle.Free();
    }
Esempio n. 5
0
    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);

            //}
        }
    }