Ejemplo n.º 1
0
    void OnEnable()
    {
        if (!SystemInfo.graphicsDeviceVersion.StartsWith("OpenGL"))
        {
            enabled = false;
            return;
        }

        sdiEnabled  = false;
        IOCoroutine = SdiIOCoroutine();

        timeCodeData = new int[8] {
            0, 0, 0, 0, 0, 0, 0, 0
        };
        timeCodeHandle = GCHandle.Alloc(timeCodeData, GCHandleType.Pinned);

#if !UNITY_EDITOR
        if (!GLNvSdiOptions.Load(UtyGLNvSdi.ConfigFileName, ref options))
        {
            GLNvSdiOptions.Save(UtyGLNvSdi.ConfigFileName, options);
        }
#endif

        if (options.logToFile)
        {
            UtyGLNvSdi.SdiSetupLogFile();
        }

        StartCoroutine(IOCoroutine);
    }
Ejemplo n.º 2
0
    void OnEnable()
    {
        if (!SystemInfo.graphicsDeviceVersion.StartsWith("OpenGL"))
        {
            enabled = false;
            return;
        }

        sdiEnabled     = false;
        InputCoroutine = SdiInputCoroutine();


#if !UNITY_EDITOR
        if (!GLNvSdiOptions.Load(UtyGLNvSdi.ConfigFileName, ref options))
        {
            GLNvSdiOptions.Save(UtyGLNvSdi.ConfigFileName, options);
        }
#endif

        if (options.logToFile)
        {
            UtyGLNvSdi.SdiSetupLogFile();
        }

        options.inputCaptureFields = false;

        StartCoroutine(InputCoroutine);
    }
Ejemplo n.º 3
0
    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);
        }
    }