Ejemplo n.º 1
0
        public void onRenderVideoFrame(string userId, TRTCVideoStreamType streamType, TRTCVideoFrame frame)
        {
            // 大小视频是占一个视频位,底层支持动态切换。
            if (streamType == TRTCVideoStreamType.TRTCVideoStreamTypeSmall)
            {
                streamType = TRTCVideoStreamType.TRTCVideoStreamTypeBig;
            }
            TXLiteAVVideoView view = null;

            lock (mMapViews)
            {
                foreach (var item in mMapViews)
                {
                    if (item.Key.Equals(GetKey(userId, streamType)) && item.Value != null)
                    {
                        view = item.Value;
                        break;
                    }
                }
            }
            if (view != null)
            {
                view.AppendVideoFrame(frame.data, (int)frame.width, (int)frame.height, frame.videoFormat, frame.rotation);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 移除自定义渲染 View 并解绑渲染回调
        /// </summary>
        private void RemoveCustomVideoView(Panel parent, string userId, TRTCVideoStreamType streamType, bool local = false)
        {
            TXLiteAVVideoView videoView = null;
            string            key       = String.Format("{0}_{1}", userId, streamType);

            if (mVideoViews.TryGetValue(key, out videoView))
            {
                videoView.RemoveEngine(mTRTCCloud);
                parent.Children.Remove(videoView);
                mVideoViews.Remove(key);
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 添加自定义渲染 View 并绑定渲染回调
        /// </summary>
        private void AddCustomVideoView(Panel parent, string userId, TRTCVideoStreamType streamType, bool local = false)
        {
            TXLiteAVVideoView videoView = new TXLiteAVVideoView();

            videoView.RegEngine(userId, streamType, mTRTCCloud, local);
            videoView.SetRenderMode(DataManager.GetInstance().videoFillMode);
            videoView.Width  = 320;
            videoView.Height = 240;
            videoView.Margin = new Thickness(5, 5, 5, 5);
            parent.Children.Add(videoView);
            string key = String.Format("{0}_{1}", userId, streamType);

            mVideoViews.Add(key, videoView);
        }
Ejemplo n.º 4
0
 public void RemoveView(string userId, TRTCVideoStreamType type, TXLiteAVVideoView view)
 {
     lock (mMapViews)
     {
         foreach (var item in mMapViews.ToList())
         {
             if (item.Key.Equals(GetKey(userId, type)))
             {
                 if (item.Value != null)
                 {
                     item.Value.Dispose();
                 }
                 mMapViews.Remove(item.Key);
                 break;
             }
         }
     }
 }
Ejemplo n.º 5
0
 public void AddView(string userId, TRTCVideoStreamType type, TXLiteAVVideoView view)
 {
     lock (mMapViews)
     {
         bool find = false;
         foreach (var item in mMapViews)
         {
             if (item.Key.Equals(GetKey(userId, type)))
             {
                 find = true;
                 break;
             }
         }
         if (!find)
         {
             mMapViews.Add(GetKey(userId, type), view);
         }
     }
 }
Ejemplo n.º 6
0
        /// <summary>
        /// 退房后执行的清理操作和关闭 SDK 内部功能。
        /// </summary>
        private void Uninit()
        {
            mTRTCCloud.stopAllRemoteView();
            mTRTCCloud.stopLocalPreview();
            foreach (var item in mVideoViews)
            {
                if (item.Value != null)
                {
                    item.Value.RemoveEngine(mTRTCCloud);
                    this.videoContainer.Children.Remove(item.Value);
                }
            }
            TXLiteAVVideoView.RemoveAllRegEngine();

            mTRTCCloud.stopLocalAudio();
            mTRTCCloud.muteLocalAudio(true);
            mTRTCCloud.muteLocalVideo(true);

            mTRTCCloud.removeCallback(this);
            mTRTCCloud.setLogCallback(null);
        }