public ImageStreamingServer(string url)
        {
            _Clients     = new List <Socket>();
            _Thread      = null;
            decoderLevel = 1;
            this.url     = url;
            this.decoder = new MjpegDecoder();
            decoder.ParseStream(new Uri(url));
            decoder.Error       += decoder_Error;
            this.Interval        = 50;
            decoder.OnJpegEvent += decoder_OnJpegEvent;

            tmr.Elapsed += tmr_Elapsed;
            tmr.Start();
        }
        public ImageStreamingServer(string url )
        {
            _Clients = new List<Socket>();
            _Thread = null;
            decoderLevel = 1;
            this.url = url;
            this.decoder = new MjpegDecoder();
            decoder.ParseStream(new Uri(url));
            decoder.Error += decoder_Error;
            this.Interval = 50;
            decoder.OnJpegEvent += decoder_OnJpegEvent;

            tmr.Elapsed += tmr_Elapsed;
            tmr.Start();
        }
        void tmr_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
        {
            try
            {
                if (this.lastUpdateTime == null || IsInTimer)
                {
                    return;
                }

                IsInTimer = true;
                if (DateTime.Now.Subtract(this.lastUpdateTime).TotalSeconds > 20)
                {
                    System.Threading.Thread.Sleep(1000);
                    try
                    {
                        // if (decoder != bull)
                        decoder.Error       -= decoder_Error;
                        decoder.OnJpegEvent -= decoder_OnJpegEvent;
                        decoder.StopStream();
                    }
                    catch {; }
                    lastUpdateTime = DateTime.Now;
                    if (decoderLevel == 1)
                    {
                        this.decoder         = new MjpegDecoder();
                        decoder.Error       += decoder_Error;
                        decoder.OnJpegEvent += decoder_OnJpegEvent;
                        this.Interval        = 50;
                        decoder.ParseStream(new Uri(url));
                    }
                    else if (decoderLevel == 2)
                    {
                        this.decoder         = new MjpegDecoder();
                        decoder.Error       += decoder_Error;
                        this.Interval        = 50;
                        decoder.OnJpegEvent += decoder_OnJpegEvent;
                        decoder.ParseStream(new Uri(url), username, password);
                    }
                }
            }
            catch {; }
            finally
            {
                IsInTimer = false;
            }
            //throw new NotImplementedException();
        }
        public ImageStreamingServer(string url, string username, string password)
        {
            decoderLevel  = 2;
            this.url      = url;
            this.username = username;
            this.password = password;
            _Clients      = new List <Socket>();
            _Thread       = null;

            this.decoder = new MjpegDecoder();
            decoder.ParseStream(new Uri(url), username, password);
            decoder.Error       += decoder_Error;
            this.Interval        = 50;
            decoder.OnJpegEvent += decoder_OnJpegEvent;
            tmr.Elapsed         += tmr_Elapsed;
            tmr.Start();
        }
        public ImageStreamingServer(string url,string username,string password)
        {
            decoderLevel = 2;
            this.url = url;
            this.username = username;
            this.password = password;
            _Clients = new List<Socket>();
            _Thread = null;

            this.decoder = new MjpegDecoder();
            decoder.ParseStream(new Uri(url),username,password);
            decoder.Error += decoder_Error;
            this.Interval = 50;
            decoder.OnJpegEvent += decoder_OnJpegEvent;
            tmr.Elapsed += tmr_Elapsed;
            tmr.Start();
        }
        void tmr_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
        {
            try
            {

                if (this.lastUpdateTime == null || IsInTimer)
                    return;

                IsInTimer = true;
                if (DateTime.Now.Subtract(this.lastUpdateTime).TotalSeconds > 20)
                {

                    System.Threading.Thread.Sleep(1000);
                    try
                    {
                        // if (decoder != bull)
                        decoder.Error -= decoder_Error;
                        decoder.OnJpegEvent -= decoder_OnJpegEvent;
                        decoder.StopStream();

                    }
                    catch { ;}
                    lastUpdateTime = DateTime.Now;
                    if (decoderLevel == 1)
                    {
                        this.decoder = new MjpegDecoder();
                        decoder.Error += decoder_Error;
                        decoder.OnJpegEvent += decoder_OnJpegEvent;
                        this.Interval = 50;
                        decoder.ParseStream(new Uri(url));

                    }
                    else if (decoderLevel == 2)
                    {
                        this.decoder = new MjpegDecoder();
                        decoder.Error += decoder_Error;
                        this.Interval = 50;
                        decoder.OnJpegEvent += decoder_OnJpegEvent;
                        decoder.ParseStream(new Uri(url), username, password);

                    }
                }

            }
            catch { ;}
            finally
            {
                IsInTimer = false;
            }
            //throw new NotImplementedException();
        }