private void IPVideoSending(object param)
        {
            try
            {
                while (IsIpVideoSending)
                {
                    Thread.Sleep(IPVideoSendInterval);
                    if (btIPVideoSample == null) continue;
                    IndexVideoMessage++;
                    var mes = new SendBytes()
                    {
                        From = ServerName,
                        To = new List<string>(),
                        Data = btIPVideoSample.Clone() as byte[],
                        IndexMessage = IndexVideoMessage,
                        TimeStamp = DateTime.Now
                    };

                    if (isUDP_Video == false)
                        Participant.VideoIPSample(mes);
                    else UDP_IP_VIDEO.SendBigBuffer(mes.Data);

                    lock (btIPVideoSample)
                    {
                        btIPVideoSample = null;
                    }
                }
            }
            catch(Exception ex)
            {

            }
        }
 public void VideoIPSample(SendBytes message)
 {
 }
 public void VideoSample(SendBytes sb)
 {
     if (sb.From == ServerName) return;
 }
 public void AudioIPSample(SendBytes sendBytes)
 {
     if (sendBytes.From == ServerName) return;
       //  throw new NotImplementedException();
 }
        public void VideoIPSample(SendBytes message)
        {
            if (message.From != ServerName || !IsIpVideoRecived) return;
            if (/*message.IndexMessage < IndexVideoMessage || */ServiceTime - message.TimeStamp > TimeSpan.FromMilliseconds(2000))
            {
                MissVideoMessage++;
                OnPropertyChanged("TestInfo2");

                return;
            }
            IndexVideoMessage = message.IndexMessage;

            MainDispatcher.Invoke((Action<byte[]>)(GetIpVideo), DispatcherPriority.Send, message.Data.Clone() as byte[]);
        }
        public void AudioIPSample(SendBytes sb)
        {
         //   return;
            if (ServiceTime - sb.TimeStamp > TimeSpan.FromMilliseconds(2000))
            {
                MissAudioMessage++;
                OnPropertyChanged("TestInfo2");

                return;
            }
            IndexAudioMessage = sb.IndexMessage;

            GC.Collect();
            var AudioSample = VoiceCapturedEventArgs.Deserialise(sb.Data.Clone() as byte[]);

            if (sb.From == ServerName)
            {
                if (!IsIpAudioRecived) return;
            }

            lock (lst_bufSampAudio)
            {
                if (bFlagMixVoice)
                {
                    bool bFlag = false;
                    foreach (ClassMultiAudio t in lst_bufSampAudio.Where(t => t.from == sb.From))
                    {
                        if (t.IndexMessage > AudioSample.IndexMessage)
                        {
                            continue;
                        }

                        t.IndexMessage = AudioSample.IndexMessage;
                        t.DtRec = DateTime.Now;
                        t.AudioStream.Write(AudioSample.Source, 0, AudioSample.Source.Length);
                        bFlag = true;
                    }

                    if (bFlag == false)
                    {
                        var cl = new ClassMultiAudio()
                        {
                            from = sb.From,
                            IndexMessage = AudioSample.IndexMessage
                        };
                        cl.DtRec = DateTime.Now;
                        cl.AudioStream.Write(AudioSample.Source, 0, AudioSample.Source.Length);
                        lst_bufSampAudio.Add(cl);

                    }
                }
                else mFifo.Write(AudioSample.Source, 0, AudioSample.Source.Length);
                RecByte += AudioSample.Source.Length;


            }

        //    throw new NotImplementedException();
        }
        public void AudioSample(SendBytes sb)
        {
            if (sb.From == Room) return;
            if (sb.To.Contains(Room) == false && sb.From != "server") return;

            var AudioSample = VoiceCapturedEventArgs.Deserialise(sb.Data.Clone() as byte[]);
            
            GC.Collect();

            if (sb.From == ServerName)
            {
                if (!IsIpAudioRecived) return;
            }
            lock (this)
            {
                this.MainDispatcher.BeginInvoke(
                DispatcherPriority.Normal,
                (ThreadStart)delegate()
                {
                    if (sb.From != null)
                    {
                        string str = sb.To.Aggregate("", (current, var) => current + (var + " "));
                        //TestInfo2 = "thisR =" + Room + "    audio R:" + From + "  To " + str;
                    }
                    else
                    {
                       // TestInfo2 = "";
                    }
                });

                if(bFlagMixVoice)
                {
                    bool bFlag = false;

                    foreach (ClassMultiAudio t in lst_bufSampAudio.Where(t => t.from == sb.From))
                    {
                        if (t.IndexMessage > AudioSample.IndexMessage)
                        {
                            continue;
                        }
                        t.DtRec = DateTime.Now;
                        t.IndexMessage = AudioSample.IndexMessage;
                        t.AudioStream.Write(AudioSample.Source, 0, AudioSample.Source.Length);
                        bFlag = true;
                    }
                       
                    if (bFlag == false)
                    {
                        var cl = new ClassMultiAudio()
                                     {
                                         from = sb.From,
                                         IndexMessage = AudioSample.IndexMessage,
                                         DtRec = DateTime.Now
                                     };
                        cl.AudioStream.Write(AudioSample.Source, 0, AudioSample.Source.Length);
                        lst_bufSampAudio.Add(cl);

                    }   
                }
                else mFifo.Write(AudioSample.Source, 0, AudioSample.Source.Length);
                RecByte += AudioSample.Source.Length;


            }
        }
        public void VideoSample(SendBytes sb)
        {
            if (sb.From == Room || !sb.To.Contains(Room) || !ContainsConferenceRoom(sb.From)) return;

         //   byte[] btVideo = btVideoSample.Clone() as byte[];

            MainDispatcher.BeginInvoke((Action<byte[]>)((btVideo) => 
            {
                MemoryStream ms = new MemoryStream(btVideo);
                BitmapImage bmp = new BitmapImage();
                bmp.BeginInit();
                bmp.StreamSource = ms;
                bmp.EndInit();

                foreach (var item in ConferenceRoom.Where(p => p.SName == sb.From))
                {
                    ConferenceClass item1 = item;

                    if (item1 != null)
                    {
                        MainDispatcher.BeginInvoke((Action<BitmapImage>)((t) => { item1.ConferenceImage = t; }), bmp);
                    }
                }
            }),
            DispatcherPriority.Send, sb.Data.Clone() as byte[]);

        }