private void OpenStream(Item _selectItem)
        {
            _jpegLiveSource = new JPEGLiveSource(_selectItem);

            int width  = 800;
            int height = 600;

            try
            {
                _jpegLiveSource.Width  = width;
                _jpegLiveSource.Height = height;
                _jpegLiveSource.SetWidthHeight();
                SetStreamType();
                _jpegLiveSource.LiveModeStart = true;
                _jpegLiveSource.Init();
                _jpegLiveSource.LiveContentEvent += JpegLiveSource1LiveNotificationEvent;
                textBoxCount.Text = "0";
                _count            = 0;
            }
            catch (Exception ex)
            {
                System.Windows.MessageBox.Show("Could not Init:" + ex.Message);
                _jpegLiveSource = null;
            }
        }
Ejemplo n.º 2
0
        private void OnSelectCameraUC2(object sender, EventArgs e)
        {
            ItemPickerForm form = new ItemPickerForm();

            form.KindFilter = Kind.Camera;
            form.AutoAccept = true;
            form.Init(userContext2.Configuration.GetItems());

            // Ask user to select a camera
            if (form.ShowDialog() == DialogResult.OK)
            {
                Close2();

                _selectItem2             = form.SelectedItem;
                buttonSelectCamera2.Text = _selectItem2.Name;

                _jpegLiveSource2 = new JPEGLiveSource(_selectItem2);
                try
                {
                    _jpegLiveSource2.Width         = pictureBoxUC2.Width;
                    _jpegLiveSource2.Height        = pictureBoxUC2.Height;
                    _jpegLiveSource2.LiveModeStart = true;
                    _jpegLiveSource2.Init();
                    _jpegLiveSource2.LiveContentEvent += new EventHandler(JpegLiveSource1LiveNotificationEvent2);
                    //_jpegLiveSource.LiveStatusEvent += new EventHandler(JpegLiveStatusNotificationEvent);
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Could not Init:" + ex.Message);
                    _jpegLiveSource2 = null;
                }
            }
        }
Ejemplo n.º 3
0
        public bool Initialize(ICameraModel camera, int imageWidth, int imageHeight)
        {
            this._Width  = imageWidth;
            this._Height = imageHeight;
            Item cameraItem = null;

            try
            {
                //Инициализировать камеру
                cameraItem      = Configuration.Instance.GetItem(camera.Id);
                _JpegLiveSource = new JPEGLiveSource(cameraItem); //Исключение если камера не найдена
                //SetResolution();
                _JpegLiveSource.LiveModeStart = true;
                _JpegLiveSource.SetKeepAspectRatio(true, false);
                _JpegLiveSource.Width         = imageWidth;
                _JpegLiveSource.Height        = imageHeight;
                _JpegLiveSource.KeyFramesOnly = false;
                _JpegLiveSource.Init();
                _JpegLiveSource.LiveContentEvent += _JpegLiveSource_LiveContentEvent;
                //_JpegLiveSource.LiveStatusEvent += _JpegLiveSource_LiveStatusEvent;
                return(true);
            }
            catch (Exception)
            {
                _JpegLiveSource = null;
                cameraItem      = null;
                return(false);
            }
        }
Ejemplo n.º 4
0
 private void Close2()
 {
     if (_jpegLiveSource2 != null)
     {
         _jpegLiveSource2.LiveContentEvent += new EventHandler(JpegLiveSource1LiveNotificationEvent2);
         _jpegLiveSource2.Close();
         _jpegLiveSource2 = null;
     }
 }
Ejemplo n.º 5
0
 private void Close1()
 {
     if (_jpegLiveSource != null)
     {
         _jpegLiveSource.LiveContentEvent += new EventHandler(JpegLiveSource1LiveNotificationEvent);
         _jpegLiveSource.Close();
         _jpegLiveSource = null;
     }
 }
Ejemplo n.º 6
0
        /// <summary>
        /// General routine for asking for a stream
        /// </summary>
        /// <param name="streamid"></param>
        static void GetResLive(Guid streamid)
        {
            var jpegLive = new JPEGLiveSource(_camera);

            if (streamid != Guid.Empty)
            {
                jpegLive.StreamId = streamid;
            }
            _timeoutEvent = new Timer(TimeOutCallBack, null, 10000, 10000);

            jpegLive.LiveModeStart = true;
            jpegLive.Height        = 0;
            jpegLive.Width         = 0;
            jpegLive.Init();
            jpegLive.LiveContentEvent += jpegLiveContentEventHandler;

            _resetEvent.WaitOne();
            _timeoutEvent.Dispose();
            jpegLive.LiveContentEvent -= jpegLiveContentEventHandler;
        }
Ejemplo n.º 7
0
        private void OnSelectCameraUC1(object sender, EventArgs e)
        {
            ItemPickerForm form = new ItemPickerForm();

            form.KindFilter = Kind.Camera;
            form.AutoAccept = true;

            List <Item> system      = userContext1.Configuration.GetItemsByKind(Kind.Camera, ItemHierarchy.SystemDefined);
            List <Item> user        = userContext1.Configuration.GetItemsByKind(Kind.Camera, ItemHierarchy.UserDefined);
            var         systemItems = system.All(i => i.FQID.FolderType == FolderType.No);
            var         userItems   = user.All(i => i.FQID.FolderType == FolderType.No);

            form.Init(userContext1.Configuration.GetItems());

            // Ask user to select a camera
            if (form.ShowDialog() == DialogResult.OK)
            {
                Close1();

                _selectItem1      = form.SelectedItem;
                buttonSelect.Text = _selectItem1.Name;

                _jpegLiveSource = new JPEGLiveSource(_selectItem1);
                try
                {
                    _jpegLiveSource.Width         = pictureBoxRC1.Width;
                    _jpegLiveSource.Height        = pictureBoxRC1.Height;
                    _jpegLiveSource.LiveModeStart = true;
                    _jpegLiveSource.Init();
                    _jpegLiveSource.LiveContentEvent += new EventHandler(JpegLiveSource1LiveNotificationEvent);
                    //_jpegLiveSource.LiveStatusEvent += new EventHandler(JpegLiveStatusNotificationEvent);
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Could not Init:" + ex.Message);
                    _jpegLiveSource = null;
                }
            }
        }
Ejemplo n.º 8
0
        private void ItemSelected2(Item item)
        {
            _selectItem2             = item;
            buttonSelectCamera2.Text = _selectItem2.Name;

            Close2();

            _jpegLiveSource2 = new JPEGLiveSource(_selectItem2);
            try
            {
                _jpegLiveSource2.Width         = pictureBoxUC2.Width;
                _jpegLiveSource2.Height        = pictureBoxUC2.Height;
                _jpegLiveSource2.LiveModeStart = true;
                _jpegLiveSource2.Init();
                _jpegLiveSource2.LiveContentEvent += new EventHandler(JpegLiveSource1LiveNotificationEvent2);
                //_jpegLiveSource.LiveStatusEvent += new EventHandler(JpegLiveStatusNotificationEvent);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Could not Init:" + ex.Message);
                _jpegLiveSource2 = null;
            }
        }
Ejemplo n.º 9
0
        private void OnSelect1Click(object sender, EventArgs e)
        {
            if (_jpegLiveSource != null)
            {
                // Close any current displayed JPEG Live Source
                _jpegLiveSource.LiveContentEvent -= JpegLiveSource1LiveNotificationEvent;
                _jpegLiveSource.LiveStatusEvent  -= JpegLiveStatusNotificationEvent;
                _jpegLiveSource.Close();
                _jpegLiveSource   = null;
                pictureBox1.Image = new Bitmap(1, 1);
            }

            /*
             *          checkBoxAspect.Checked = false;
             *          checkBoxFill.Checked = false;
             *          checkBoxKeyFramesOnly.Checked = false;
             *          checkBoxCrop.Checked = false;
             */
            ClearAllFlags();
            ResetSelections();

            ItemPickerForm form = new ItemPickerForm();

            form.KindFilter = Kind.Camera;
            form.AutoAccept = true;
            form.Init(Configuration.Instance.GetItems());

            // Ask user to select a camera
            if (form.ShowDialog() == DialogResult.OK)
            {
                _selectItem1       = form.SelectedItem;
                buttonSelect1.Text = _selectItem1.Name;

                _jpegLiveSource = new JPEGLiveSource(_selectItem1);
                try
                {
                    SetResolution();
                    _jpegLiveSource.LiveModeStart = true;
                    _jpegLiveSource.SetKeepAspectRatio(checkBoxAspect.Checked, checkBoxFill.Checked);
                    checkBoxAspect.Enabled        = false;
                    checkBoxFill.Enabled          = false;
                    checkBoxKeyFramesOnly.Enabled = false;
                    comboBoxResolution.Enabled    = !checkBoxAspect.Checked;                    // Only allow resolution change, if filling available space
                    _jpegLiveSource.Width         = pictureBox1.Width;
                    _jpegLiveSource.Height        = pictureBox1.Height;
                    _jpegLiveSource.KeyFramesOnly = checkBoxKeyFramesOnly.Checked;
                    SetStreamType(pictureBox1.Width, pictureBox1.Height);
                    _jpegLiveSource.Init();
                    _jpegLiveSource.LiveContentEvent += JpegLiveSource1LiveNotificationEvent;
                    _jpegLiveSource.LiveStatusEvent  += JpegLiveStatusNotificationEvent;

                    labelCount.Text     = "0";
                    buttonPause.Enabled = true;
                    buttonLift.Enabled  = true;
                    _count = 0;
                } catch (Exception ex)
                {
                    MessageBox.Show("Could not Init:" + ex.Message);
                    _jpegLiveSource = null;
                }
            }
            else
            {
                _selectItem1                  = null;
                buttonSelect1.Text            = "Select Camera ...";
                labelCount.Text               = "0";
                labelSize.Text                = "";
                labelResolution.Text          = "";
                buttonPause.Enabled           = false;
                checkBoxAspect.Enabled        = true;
                checkBoxFill.Enabled          = true;
                checkBoxKeyFramesOnly.Enabled = true;
                buttonLift.Enabled            = false;
            }
        }