Beispiel #1
0
        bool Connect()
        {
            car = new TcpClient();
            IPAddress Adresse;

            if (!IPAddress.TryParse(textBox1.Text, out Adresse))
            {
                MessageBox.Show("Keine gültige IP-Adresse!");
                return(false);
            }
            String URL = "http://" + Adresse.ToString() + ":8090/test.mjpg";

            try { car.Connect(Adresse, 9001); }
            catch (Exception e) { MessageBox.Show("Verbindungsfehler Oo" + e.Message); return(false); }
            Stream clst = car.GetStream();

            biRea = new BinaryReader(clst);
            biWri = new BinaryWriter(clst);
            int Wert = biRea.ReadInt16();

            biWri.Write((Int16)Math.Floor((decimal)Wert / 2 + 2));
            if (biRea.ReadBoolean())
            {
                //Annehmen der Verbindung. Bei Verdacht (whyever XD) ein false senden!
                biWri.Write(true);
                lbStatus.Text         = "Verbindung hergestellt. Viel Spaß! :D";
                ImgGetter             = new MjpegProcessor.MjpegDecoder();
                ImgGetter.FrameReady += mjpeg_FrameReady;
                ImgGetter.ParseStream(new Uri("http://" + textBox1.Text + ":8090/test.mjpg"));
                return(true);
            }
            return(false);
        }
Beispiel #2
0
        //private void ImageOneShot()
        //{
        //    BitmapImage imageSource = new BitmapImage();
        //    imageSource.BeginInit();
        //    imageSource.UriSource = new Uri(GetImageUrl(ImageIndex++));
        //    imageSource.EndInit();
        //    image.Source = imageSource;
        //    //imageSource.DownloadCompleted += new EventHandler(LoadNextImage);
        //}

        private bool CameraStart()
        {
            mjpeg = new MjpegDecoder();
            mjpeg.ParseStream(new Uri(String.Format("http://{0}:{1}/?action=stream", ipAddress, port)));
            mjpeg.FrameReady += (object _sender, MjpegProcessor.FrameReadyEventArgs _e) =>
            {
                frame = _e.BitmapImage;
            };
            return(true);
        }
        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();
        }
Beispiel #4
0
        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();
        }
Beispiel #5
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();
        }
Beispiel #6
0
        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();
        }