Ejemplo n.º 1
0
    void OnDisable()
    {
        if (sdiEnabled)
        {
            StopCoroutine(OutputCoroutine);

            GL.IssuePluginEvent(UtyGLNvSdi.GetSdiOutputRenderEventFunc(), (int)SdiRenderEvent.Shutdown);
            sdiEnabled = false;
        }
    }
Ejemplo n.º 2
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);
     }
 }
Ejemplo n.º 3
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();
    }
Ejemplo n.º 4
0
    private IEnumerator SdiOutputCoroutine()
    {
        UtyGLNvSdi.SdiOutputSetGlobalOptions();
        UtyGLNvSdi.SdiOutputSetVideoFormat(
            options.videoFormat,
            options.syncSource,
            options.outputDelay,
            options.outputHorizontalDelay,
            options.outputVerticalDelay,
            options.outputDual,
            options.outputRingBufferSize);

        yield return(new WaitForEndOfFrame());

        GL.IssuePluginEvent(UtyGLNvSdi.GetSdiOutputRenderEventFunc(), (int)SdiRenderEvent.Initialize);
        yield return(new WaitForEndOfFrame());


        if (UtyGLNvSdi.SdiError() == 0)
        {
            GL.IssuePluginEvent(UtyGLNvSdi.GetSdiOutputRenderEventFunc(), (int)SdiRenderEvent.Setup);

            if (!SetupOutputTextures())
            {
                UnityEngine.Debug.LogError("GLNvSdi_Plugin could not setup sdi textures for output");
            }

            sdiEnabled = true;

            while (true)
            {
                yield return(new WaitForEndOfFrame());

                GL.IssuePluginEvent(UtyGLNvSdi.GetSdiOutputRenderEventFunc(), (int)SdiRenderEvent.PresentFrame);
            }
        }
    }
Ejemplo 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);

            //}
        }
    }