Пример #1
0
    public void Awake()
    {
        try
        {
            if (AVProMovieCapturePlugin.Init())
            {
                Debug.Log("[AVProMovieCapture] Init plugin version: " + AVProMovieCapturePlugin.GetPluginVersion().ToString("F2") + " with GPU " + SystemInfo.graphicsDeviceVersion);
#if AVPRO_MOVIECAPTURE_GLISSUEEVENT_52
                _renderEventFunction = AVProMovieCapturePlugin.GetRenderEventFunc();
                _freeEventFunction   = AVProMovieCapturePlugin.GetFreeResourcesEventFunc();
#endif
            }
            else
            {
                Debug.LogError("[AVProMovieCapture] Failed to initialise plugin version: " + AVProMovieCapturePlugin.GetPluginVersion().ToString("F2") + " with GPU " + SystemInfo.graphicsDeviceVersion);
            }
        }
        catch (DllNotFoundException e)
        {
            Debug.LogError("[AVProMovieCapture] Unity couldn't find the DLL, did you move the 'Plugins' folder to the root of your project?");
            throw e;
        }

        _isDirectX11 = SystemInfo.graphicsDeviceVersion.StartsWith("Direct3D 11");

        SelectCodec(_listVideoCodecsOnStart);
        SelectAudioCodec(_listVideoCodecsOnStart);
        SelectAudioDevice(_listVideoCodecsOnStart);
    }
Пример #2
0
    private void OnRenderImage(RenderTexture source, RenderTexture dest)
    {
        if (_capturing && !_paused)
        {
#if true
            while (_handle >= 0 && !AVProMovieCapturePlugin.IsNewFrameDue(_handle))
            {
                System.Threading.Thread.Sleep(1);
            }
            if (_handle >= 0)
            {
                if (_audioCapture && _audioDeviceIndex < 0 && !_noAudio && _isRealTime)
                {
                    int           audioDataLength = 0;
                    System.IntPtr audioDataPtr    = _audioCapture.ReadData(out audioDataLength);
                    if (audioDataLength > 0)
                    {
                        AVProMovieCapturePlugin.EncodeAudio(_handle, audioDataPtr, (uint)audioDataLength);
                    }
                }

                // In Direct3D the RT can be flipped vertically

                /*if (source.texelSize.y < 0)
                 * {
                 *
                 * }*/

                Graphics.Blit(source, dest);

                _lastSource = source;
                _lastDest   = dest;

                if (dest != _originalTarget)
                {
                    Graphics.Blit(dest, _originalTarget);
                }

#if AVPRO_MOVIECAPTURE_GLISSUEEVENT_52
                GL.IssuePluginEvent(AVProMovieCapturePlugin.GetRenderEventFunc(), AVProMovieCapturePlugin.PluginID | (int)AVProMovieCapturePlugin.PluginEvent.CaptureFrameBuffer | _handle);
#else
                GL.IssuePluginEvent(AVProMovieCapturePlugin.PluginID | (int)AVProMovieCapturePlugin.PluginEvent.CaptureFrameBuffer | _handle);
#endif
                GL.InvalidateState();

                UpdateFPS();

                return;
            }
#endif
        }

        // Pass-through
        Graphics.Blit(source, dest);

        _lastSource = source;
        _lastDest   = dest;
    }
Пример #3
0
    public void Awake()
    {
        try
        {
            float pluginVersion = AVProMovieCapturePlugin.GetPluginVersion();

            // Check that the plugin version number is not too old
            if (pluginVersion < ScriptVersion)
            {
                Debug.LogWarning("[AVProMovieCapture] Plugin version number " + pluginVersion.ToString("F2") + " is older than script version number " + ScriptVersion.ToString("F2") + ".  It looks like the plugin didn't upgrade correctly.  To resolve this please restart Unity and try to upgrade the package again.");
            }

            if (AVProMovieCapturePlugin.Init())
            {
                Debug.Log("[AVProMovieCapture] Init plugin version: " + pluginVersion.ToString("F2") + " with GPU " + SystemInfo.graphicsDeviceVersion);

#if AVPRO_MOVIECAPTURE_GLISSUEEVENT_52
                _renderEventFunction = AVProMovieCapturePlugin.GetRenderEventFunc();
                _freeEventFunction   = AVProMovieCapturePlugin.GetFreeResourcesEventFunc();
#endif
            }
            else
            {
                Debug.LogError("[AVProMovieCapture] Failed to initialise plugin version: " + pluginVersion.ToString("F2") + " with GPU " + SystemInfo.graphicsDeviceVersion);
            }
        }
        catch (DllNotFoundException e)
        {
            Debug.LogError("[AVProMovieCapture] Unity couldn't find the DLL, did you move the 'Plugins' folder to the root of your project?");
            throw e;
        }

        _isDirectX11 = SystemInfo.graphicsDeviceVersion.StartsWith("Direct3D 11");

        SelectCodec(_listVideoCodecsOnStart);
        SelectAudioCodec(_listVideoCodecsOnStart);
        SelectAudioDevice(_listVideoCodecsOnStart);
    }