Ejemplo n.º 1
0
        /// <summary>
        /// 移除 View 绑定参数
        /// </summary>
        /// <param name="engine">TRTCCloud 实例,用户注册视频数据回调。</param>
        public void RemoveEngine(ITRTCCloud engine)
        {
            if (mLocalView)
            {
                TXLiteAVVideoViewManager.GetInstance().RemoveView("", mStreamType, this);
            }
            else
            {
                TXLiteAVVideoViewManager.GetInstance().RemoveView(mUserId, mStreamType, this);
            }
            int count = TXLiteAVVideoViewManager.GetInstance().Count;

            if (engine != null)
            {
                if (count == 0)
                {
                    engine.setLocalVideoRenderCallback(TRTCVideoPixelFormat.TRTCVideoPixelFormat_Unknown,
                                                       TRTCVideoBufferType.TRTCVideoBufferType_Unknown, null);
                }
                if (!mLocalView && !TXLiteAVVideoViewManager.GetInstance().HasUserId(mUserId))
                {
                    engine.setRemoteVideoRenderCallback(mUserId, TRTCVideoPixelFormat.TRTCVideoPixelFormat_Unknown,
                                                        TRTCVideoBufferType.TRTCVideoBufferType_Unknown, null);
                }
            }
            lock (mArgbFrame)
                ReleaseBuffer(mArgbFrame);
            mUserId     = "";
            mOccupy     = false;
            mLocalView  = false;
            mFirstFrame = false;
            mRenderMode = TRTCVideoFillMode.TRTCVideoFillMode_Fit;
            this.InvalidateVisual();
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 设置 View 绑定参数
        /// </summary>
        /// <param name="userId">需要渲染画面的 userId,如果是本地画面,则传空字符串。</param>
        /// <param name="type">渲染类型</param>
        /// <param name="engine">TRTCCloud 实例,用户注册视频数据回调。</param>
        /// <param name="local">渲染本地画面,SDK 返回的 userId 为""</param>
        /// <returns>true:绑定成功,false:绑定失败</returns>
        public bool RegEngine(string userId, TRTCVideoStreamType type, ITRTCCloud engine, bool local = false)
        {
            if (mOccupy)
            {
                return(false);
            }
            mLocalView  = local;
            mUserId     = userId;
            mStreamType = type;
            int count = TXLiteAVVideoViewManager.GetInstance().Count;

            if (engine != null)
            {
                if (count == 0)
                {
                    engine.setLocalVideoRenderCallback(TRTCVideoPixelFormat.TRTCVideoPixelFormat_BGRA32,
                                                       TRTCVideoBufferType.TRTCVideoBufferType_Buffer, TXLiteAVVideoViewManager.GetInstance());
                }
                if (!mLocalView)
                {
                    engine.setRemoteVideoRenderCallback(userId, TRTCVideoPixelFormat.TRTCVideoPixelFormat_BGRA32,
                                                        TRTCVideoBufferType.TRTCVideoBufferType_Buffer, TXLiteAVVideoViewManager.GetInstance());
                }
            }
            if (mLocalView)
            {
                TXLiteAVVideoViewManager.GetInstance().AddView("", type, this);
            }
            else
            {
                TXLiteAVVideoViewManager.GetInstance().AddView(userId, type, this);
            }
            lock (mArgbFrame)
                ReleaseBuffer(mArgbFrame);
            mOccupy = true;
            this.InvalidateVisual();
            return(true);
        }
Ejemplo n.º 3
0
 /// <summary>
 /// 清除所有映射信息
 /// </summary>
 public static void RemoveAllRegEngine()
 {
     TXLiteAVVideoViewManager.GetInstance().RemoveAllView();
 }