public VideoChatClientViewModel()
        {
            try
            {
                UDP_VIDEO_Server = new UDP_Server() { ServerIP = "224.0.0.1", ServerPort = 5000 };
                UDP_VIDEO_Server.evRecBuf += (CurUDP_Server_evRecBuf);
                UDP_VIDEO_Server.Start();

                UDP_AUDIO_Server = new UDP_Server() { ServerIP = "224.0.0.1", ServerPort = 6000 };
                UDP_AUDIO_Server.evRecBuf += (UDP_AUDIO_Server_evRecBuf);
                UDP_AUDIO_Server.Start();
                /*
                UDP_VIDEO_Conference_Client = new UDP_Client() { ServerIP = "224.0.0.1", ServerPort = 7000 };
                UDP_VIDEO_Conference_Client.Start();

                UDP_VIDEO_Conference_Server = new UDP_Server() { ServerIP = "224.0.0.1", ServerPort = 7000 };
                UDP_VIDEO_Conference_Server.evRecBuf += (UDP_VIDEO_Conference_Server_evRecBuf);
                UDP_VIDEO_Conference_Server.Start();

                UDP_AUDIO_Conference_Client = new UDP_Client() { ServerIP = "224.0.0.1", ServerPort = 8000 };
                UDP_AUDIO_Conference_Client.Start();

                UDP_AUDIO_Conference_Server = new UDP_Server() { ServerIP = "224.0.0.1", ServerPort = 8000 };
                UDP_AUDIO_Conference_Server.evRecBuf += (UDP_AUDIO_Conference_Server_evRecBuf);
                UDP_AUDIO_Conference_Server.Start();*/
            }
            catch (Exception ex)
            {
                MessageBox.Show("Ошибка создания UDP серверов\n" + ex.ToString());
            }

            ConferenceRoom = new ObservableCollection<ConferenceClass>();

            for(int i=0;i<4;i++)
            {
                string sRoom = MachineSettings.ButtonNumberToRoom(31 + i);

                var cc = new ConferenceClass() { SName = sRoom };
                cc.PropertyChanged += VideoChatClientViewModel_PropertyChanged;
                ConferenceRoom.Add(cc);
            }

            WebCamDevices = MultimediaUtil.VideoInputDevices;
            RunConferencService();

            if (waveOut == null) 
                waveOut = new WaveOutPlayer(-1, waveFormat, 4096, 2, Filler);
            if (WaveIn == null)
                WaveIn = new WaveInRecorder(-1, waveFormat, 4096, 2);

            tmrSendVideo.Interval = SendVideoInerval;
            tmrSendVideo.Tick += (_1,_2) => 
            {
                if (Participant == null 
                    || MyVideoFrame == null 
                    || SelectedConferenceRoom.Count == 0) return;

                tmrSendVideo.Stop();
                if (IsUDPConference==false)
                {
                    participant.VideoSample(
                        new SendBytes
                            {
                                From = Room,
                                Data = MyVideoFrame.Clone() as byte[],
                                To = SelectedConferenceRoom
                            });
                }
                else
                {
                    var um = 
                        new UPD_Message()
                            {
                                From = Room,
                                Data = MyVideoFrame.Clone() as byte[],
                                To = SelectedConferenceRoom
                            };
                    UDP_VIDEO_Conference_Client.SendBigBuffer(um.ToByte());
                }
                tmrSendVideo.Start();
            };
            tmrSendVideo.Start();
            InitControlDevice();
            CheckAutoStart();

        }
Пример #2
0
        public static UPD_Message FromByte(byte[] bBuf)
        {
            var um = new UPD_Message();
            var ms = new MemoryStream(bBuf);
            var bf = new BinaryFormatter();

            um = (UPD_Message)bf.Deserialize(ms);
            ms.Close();
            return um;
        }