Esempio n. 1
0
    void Initialize()
    {
        GStreamer.GUBUnityDebugLogPFN log_handler = null;
        if (Application.isEditor)
        {
            log_handler = (int level, string message) => Debug.logger.Log((LogType)level, "GUB", message);
        }

        GStreamer.Ref("2", log_handler);
        m_instanceHandle = GCHandle.Alloc(this);
        m_Pipeline       = new GstUnityBridgePipeline(name + GetInstanceID(), OnFinish, null, null, (System.IntPtr)m_instanceHandle);
    }
Esempio n. 2
0
    public void Initialize()
    {
        m_HasBeenInitialized = true;

        m_EventProcessor = GetComponent <EventProcessor>();
        if (m_EventProcessor == null)
        {
            m_EventProcessor = gameObject.AddComponent <EventProcessor>();
        }

        GStreamer.GUBUnityDebugLogPFN log_handler = null;
        if (Application.isEditor && m_DebugOutput.m_Enabled)
        {
            log_handler = (int level, string message) => Debug.logger.Log((LogType)level, "GUB", message);
        }

        GStreamer.Ref(m_DebugOutput.m_GStreamerDebugString.Length == 0 ? null : m_DebugOutput.m_GStreamerDebugString, log_handler);

        m_instanceHandle = GCHandle.Alloc(this);
        m_Pipeline       = new GstUnityBridgePipeline(name + GetInstanceID(), OnFinish, OnError, OnQos, (IntPtr)m_instanceHandle);

        Resize(m_Width, m_Height);

        Material mat = m_TargetMaterial;

        if (mat == null && GetComponent <Renderer>())
        {
            // If no material is given, use the first one in the Renderer component
            mat = GetComponent <Renderer>().material;
        }

        if (mat != null)
        {
            string tex_name = m_IsAlpha ? "_AlphaTex" : "_MainTex";
            mat.SetTexture(tex_name, m_Texture);
            mat.SetTextureScale(tex_name, new Vector2(Mathf.Abs(mat.mainTextureScale.x) * (m_FlipX ? -1F : 1F),
                                                      Mathf.Abs(mat.mainTextureScale.y) * (m_FlipY ? -1F : 1F)));
        }
        else
        if (GetComponent <GUITexture>())
        {
            GetComponent <GUITexture>().texture = m_Texture;
        }
        else
        {
            Debug.LogWarning(string.Format("[{0}] There is no Renderer or guiTexture attached to this GameObject, and TargetMaterial is not set.", name + GetInstanceID()));
        }
    }
    /// <summary>
    /// Loads GStreamer and makes the ref for the GStreamer's Log_handler.
    /// </summary>
    void LoadGStreamer()
    {
        try
        {
            GStreamer.AddPluginsToPath();
        }
        catch
        {
            Debug.LogWarning("GStreamer not loaded correctly.");
        }

        GStreamer.GUBUnityDebugLogPFN log_handler = null;
        if (Application.isEditor && GStreamerDebugActivated)
        {
            log_handler = (int level, string message) => Debug.logger.Log((LogType)level, "GUB", message);
        }

        GStreamer.Ref(GStreamerDebugString.Length == 0 ? null : GStreamerDebugString, log_handler);
    }