Exemplo n.º 1
0
        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();
        }
Exemplo n.º 2
0
 private bool CameraStop()
 {
     mjpeg.StopStream();
     return(true);
 }