private IAgoraRtcEngine GetEngine()
        {
            var engine = AgoraRtcEngine.Get(AgoraEngineType);

            if (_needUpdateInfo && engine != null)
            {
                if (_videoStreamManager == null)
                {
                    _videoStreamManager = ((AgoraRtcEngine)engine).GetVideoStreamManager();
                }

                if (_videoStreamManager != null)
                {
                    _videoStreamManager.EnableVideoFrameCache(VideoPixelWidth, VideoPixelHeight, Uid, ChannelId);
                }
                _needUpdateInfo = false;
                _needResize     = true;
                FreeMemory();
                _cachedVideoFrame = new IrisRtcVideoFrame
                {
                    type     = VIDEO_FRAME_TYPE.FRAME_TYPE_RGBA,
                    y_stride = VideoPixelWidth * 4,
                    height   = VideoPixelHeight,
                    y_buffer = Marshal.AllocHGlobal(VideoPixelWidth * VideoPixelHeight * 4)
                };
            }

            return(engine);
        }
        void OnDestroy()
        {
            AgoraLog.Log(string.Format("VideoSurface channel: ${0}, user:{1} destroy", ChannelId, Uid));

            if (GetEngine() != null && _videoStreamManager != null)
            {
                _videoStreamManager.DisableVideoFrameCache(Uid, ChannelId);
                _videoStreamManager = null;
            }

            FreeMemory();
            DestroyTexture();
        }