Beispiel #1
0
        public void RtsTest()
        {
            VideoChatForm vchatForm = VideoChatForm.GetInstance();
            RtsForm       rtsForm   = RtsForm.GetInstance();


            //当前不存在白板会话和音视频会话,才能开启新的会话
            if (rtsForm.RtsState == RtsFormState.kRtsInit && vchatForm.VchatInfo.state == VChatState.kVChatUnknow)
            {
                rtsForm.Show();
                rtsForm.SetRtsInfo("", _peerId, (NIM.NIMRts.NIMRtsChannelType.kNIMRtsChannelTypeTcp | NIM.NIMRts.NIMRtsChannelType.kNIMRtsChannelTypeVchat));
                rtsForm.RtsState = RtsFormState.kRtsInvite;
            }
            else
            {
                if (rtsForm.RtsState != RtsFormState.kRtsInit)
                {
                    rtsForm.Activate();
                }
                if (vchatForm.VchatInfo.state != VChatState.kVChatUnknow)
                {
                    vchatForm.Activate();
                }
            }
            //rtsForm.SetRtsInfo
        }
 private static void OnSessionConnectNotify(long channel_id, int code, string record_file, string video_record_file, long chat_time, ulong chat_rx, ulong chat_tx)
 {
     DemoTrace.WriteLine("Session Connect channel_id:" + channel_id.ToString() +
                         " code:" + code.ToString() + " record_file:" + record_file + " video_record_file" + video_record_file +
                         "chat_time:" + chat_time.ToString() + "chat_rx:" + chat_rx.ToString() + "chat_tx" + chat_tx.ToString());
     if (code == 200)
     {
         Action a = () =>
         {
             GetInstance().channel_id = channel_id;
             VideoChatForm vform     = VideoChatForm.GetInstance();
             VideoChatInfo vchatInfo = vform.VchatInfo;
             if (vchatInfo.state != VChatState.kVChatUnknow &&
                 vchatInfo.state != VChatState.VChatEnd &&
                 vchatInfo.state != VChatState.kVChatInviteRefuse)
             {
                 vchatInfo.state = VChatState.kVChating;
                 vform.VchatInfo = vchatInfo;
             }
         };
         _ownerMainForm.BeginInvoke(a);
         StartDevices();
     }
     else
     {
         NIM.VChatAPI.End();
         GetInstance().channel_id = 0;
     }
 }
Beispiel #3
0
        private void button2_Click(object sender, EventArgs e)
        {
            VideoChatForm vchatForm = VideoChatForm.GetInstance();
            RtsForm       rtsForm   = RtsForm.GetInstance();

            //当前不存在白板会话和音视频会话,才能开启新的会话
            if (rtsForm.RtsState == RtsFormState.kRtsInit && vchatForm.VchatInfo.state == VChatState.kVChatUnknow)
            {
                VideoChatInfo vchat_info = vchatForm.VchatInfo;
                vchat_info.state     = VChatState.kVChatInvite;
                vchat_info.uid       = _peerId;
                vchat_info.chat_mode = NIMVideoChatMode.kNIMVideoChatModeVideo;
                vchatForm.VchatInfo  = vchat_info;
                vchatForm.Show();
            }
            else
            {
                if (rtsForm.RtsState != RtsFormState.kRtsInit)
                {
                    rtsForm.Activate();
                }
                else if (vchatForm.VchatInfo.state != VChatState.kVChatUnknow)
                {
                    vchatForm.Activate();
                }
            }
        }
 private static void OnSessionInviteNotify(long channel_id, string uid, int mode, long time, string custom_info)
 {
     if (GetInstance().channel_id != 0 && channel_id != GetInstance().channel_id)
     {
         NIM.NIMVChatInfo info = new NIM.NIMVChatInfo();
         NIM.VChatAPI.CalleeAck(channel_id, false, info);
     }
     else
     {
         VideoChatForm vform      = VideoChatForm.GetInstance();
         RtsForm       rtsForm    = RtsForm.GetInstance();
         VideoChatInfo vchat_info = vform.VchatInfo;
         //当前不存在rts会话和音视频会话,才能开启新的会话
         if (rtsForm.RtsState == RtsFormState.kRtsInit && vchat_info.state == VChatState.kVChatUnknow)
         {
             vchat_info.channel_id = channel_id;
             vchat_info.uid        = uid;
             vchat_info.state      = VChatState.kVChatNotify;
             vchat_info.chat_mode  = (NIMVideoChatMode)mode;
             vform.VchatInfo       = vchat_info;
             Action a = () =>
             {
                 vform.Show();
             };
             _ownerMainForm.BeginInvoke(a);
         }
         else
         {
             NIM.NIMVChatInfo info = new NIM.NIMVChatInfo();
             NIM.VChatAPI.CalleeAck(channel_id, false, info);
         }
     }
 }
Beispiel #5
0
        private void VideoChatForm_FormClosed(object sender, FormClosedEventArgs e)
        {
            sendCaptureScreenDataTimer_.Stop();
            switch (vchat_info.state)
            {
            case VChatState.kVChatNotify:
            {
                NIM.VChatAPI.CalleeAck(vchat_info.channel_id, false, null);
            }
            break;

            case VChatState.kVChatInvite:
            case VChatState.kVChating:
                NIM.VChatAPI.End();
                break;

            case VChatState.VChatEnd:
                break;
            }

            {
                MultimediaHandler.ReceiveVideoFrameHandler  -= OnReceivedVideoFrame;
                MultimediaHandler.CapturedVideoFrameHandler -= OnCapturedVideoFrame;
            }

            _peerRegionGraphics.Dispose();
            _mineRegionGraphics.Dispose();
            videoChatForm_        = null;
            vchat_info.channel_id = 0;
            // _multimediaHandler = null;
        }
Beispiel #6
0
 public static VideoChatForm GetInstance()
 {
     if (videoChatForm_ == null)
     {
         videoChatForm_ = new VideoChatForm();
     }
     return(videoChatForm_);
 }
        private static void OnSessionHangupNotify(long channel_id, int code)
        {
            EndDevices();
            if (code == 200)
            {
                Action action = () =>
                {
                    //MessageBox.Show("已挂断");

                    VideoChatForm vform      = VideoChatForm.GetInstance();
                    VideoChatInfo vchat_info = vform.VchatInfo;
                    vchat_info.state = VChatState.VChatEnd;
                    vform.VchatInfo  = vchat_info;
                };
                _ownerMainForm.BeginInvoke(action);
            }
        }
 private static void OnSessionCalleeAckNotify(long channel_id, string uid, int mode, bool accept)
 {
     if (accept)
     {
         DemoTrace.WriteLine("对方接听");
     }
     else
     {
         NIMDemo.VideoChatForm vchat_form = VideoChatForm.GetInstance();
         if (vchat_form.VchatInfo.state == VChatState.kVChatInvite)
         {
             VideoChatInfo vchat_info = vchat_form.VchatInfo;
             vchat_info.state     = VChatState.kVChatInviteRefuse;
             vchat_form.VchatInfo = vchat_info;
         }
     }
 }
Beispiel #9
0
 void OnReceiveSessionRequest(string sessionId, int channelType, string uid, string custom)
 {
     InvokeOnForm(() =>
     {
         VideoChatForm vchatForm = VideoChatForm.GetInstance();
         RtsForm rtsForm         = RtsForm.GetInstance();
         //当前不存在白板会话和音视频会话,才能开启新的会话
         if (rtsForm.RtsState == RtsFormState.kRtsInit && vchatForm.VchatInfo.state == VChatState.kVChatUnknow)
         {
             rtsForm.Show();
             rtsForm.RtsState = RtsFormState.kRtsNotify;
             rtsForm.SetRtsInfo(sessionId, uid, (NIM.NIMRts.NIMRtsChannelType)channelType);
         }
         else
         {
             NIM.RtsAPI.Ack(sessionId, (NIM.NIMRts.NIMRtsChannelType)channelType, false, null, null);
         }
     });
 }