Exemplo n.º 1
0
    void Update()
    {
        if (m_Pipeline == null)
        {
            return;
        }

        Vector2 sz;

        if (m_Pipeline.GrabFrame(out sz))
        {
            Resize((int)sz.x, (int)sz.y);
            if (m_Texture == null)
            {
                Debug.LogWarning(string.Format("[{0}] The GUBTexture does not have a texture assigned and will not paint.", name + GetInstanceID()));
            }
            else
            {
                m_Pipeline.BlitTexture(m_Texture.GetNativeTexturePtr(), m_Texture.width, m_Texture.height);
            }
            if (m_FirstFrame)
            {
                if (m_AdaptiveBitrateLimit != 1.0F)
                {
                    SetAdaptiveBitrateLimit(m_AdaptiveBitrateLimit);
                }
                if (m_Events.m_OnStart != null)
                {
                    m_Events.m_OnStart.Invoke();
                }
                m_FirstFrame = false;
            }
        }
    }
    void LateUpdate()
    {
        Vector2 sz = Vector2.zero;

        if (m_Pipeline.GrabFrame(ref sz))
        {
            double start_resize = Time.realtimeSinceStartup;
            if (change == 1)
            {
                //Resize((int)sz.x, (int)sz.y);
                change = 0;
            }
            //Debug.Log("\n Resize = " + (int)sz.x + "," + (int)sz.y);
            //Debug.Log("\n The time taken by Resize = " + (Time.realtimeSinceStartup - start_resize));

            if (m_Texture == null)
            {
                Debug.LogWarning(string.Format("[{0}] The GUBTexture does not have a texture assigned and will not paint.", name + GetInstanceID()));
            }
            else
            {
                double start_btext = Time.realtimeSinceStartup;
                m_Pipeline.BlitTexture(m_Texture.GetNativeTexturePtr(), m_Texture.width, m_Texture.height);
                // Debug.Log("\n The time taken by textureupdate = " + (Time.realtimeSinceStartup - start_btext));

                /*
                 * if (change == 1)
                 * {
                 *  sum_start += Time.realtimeSinceStartup - start_time;
                 *  Debug.Log("\n the time difference between changing and grabbing a frame = " + (Time.realtimeSinceStartup - start_time));
                 *  count++;
                 *  Debug.Log("\n Avg = " + sum_start / count + ", total_time = " + sum_start + ", count = " + count);
                 *  change = 0;
                 * }
                 */
            }

            /*
             * if (m_FirstFrame)
             * {
             *  Debug.Log("\n the adaptive bit rate is = " + m_AdaptiveBitrateLimit);
             *  if (m_AdaptiveBitrateLimit != 1.0F)
             *  {
             *      SetAdaptiveBitrateLimit(m_AdaptiveBitrateLimit);
             *      Debug.Log("\n the adaptive bit rate is = " + m_AdaptiveBitrateLimit);
             *  }
             *
             *  if (m_Events.m_OnStart != null)
             *  {
             *      m_Events.m_OnStart.Invoke();
             *  }
             *
             *  m_FirstFrame = false;
             * }
             */
        }
    }