Ejemplo n.º 1
0
 public DocCapImageArgs(CaptureTypes msgType, SsiImageTypes imgType, byte[] imageData, bool onHID)
 {
     this.m_msgType   = msgType;
     this.m_imgType   = imgType;
     this.m_imageData = imageData;
     this.m_onHID     = onHID;
 }
Ejemplo n.º 2
0
    // public methods ----------------------------------

    public override Result CapturePrepare(CaptureTypes captureType)
    {
        if (process != null)
        {
            return(new Result(false, ""));
        }

        return(new Result(true, ""));
    }
Ejemplo n.º 3
0
 private void Start(ITransport transport, CaptureTypes requestedCaptureTypes)
 {
     foreach (var captureDevice in EnabledCaptureDevices)
     {
         if ((captureDevice.Metadata.Types & requestedCaptureTypes) != 0)
         {
             captureDevice.Value.Start(transport);
         }
     }
     _runningCaptureTypes = requestedCaptureTypes;
 }
Ejemplo n.º 4
0
 private void Stop()
 {
     foreach (var captureDevice in EnabledCaptureDevices)
     {
         if ((captureDevice.Metadata.Types & _runningCaptureTypes) != 0)
         {
             captureDevice.Value.Stop();
         }
     }
     _runningCaptureTypes = 0;
 }
Ejemplo n.º 5
0
        private void SetScreenArea(CaptureTypes type)
        {
            screenLeft = screenTop = 0;
            useArea    = false;

            /*if(type == SettingsManager.CaptureTypes.VideoFull)
             * {
             *  foreach (Screen screen in Screen.AllScreens)
             *  {
             *      this._screenArea = Rectangle.Union(_screenArea, screen.Bounds);
             *      this._width = _screenArea.Width;
             *      this._height = _screenArea.Height;
             *  }
             * }*/
            if (type == CaptureTypes.VideoArea)
            {
                using (SelectableVideoArea f = new SelectableVideoArea())
                {
                    if (f.ShowDialog() == DialogResult.OK)
                    {
                        this.WindowState = FormWindowState.Minimized;
                        this._screenArea = f.AreaBounds;

                        decimal prop       = (decimal)4 / 3;
                        decimal realProp   = (decimal)f.w / f.h + 1;
                        bool    makeLonger = realProp < prop;
                        int     w          = Convert.ToInt32(makeLonger ? f.h * prop : f.w);
                        int     h          = Convert.ToInt32(makeLonger ? f.h : f.w / prop);

                        if ((w & 1) != 0)
                        {
                            w = w + 1;
                        }
                        if ((h & 1) != 0)
                        {
                            h = h + 1;
                        }

                        this._width  = w;
                        this._height = h;
                        screenLeft   = f.AreaBounds.Left;
                        screenTop    = f.AreaBounds.Top;
                        useArea      = true;
                    }
                }
            }
            if (type == CaptureTypes.VideoFull)
            {
                this._screenArea = Screen.PrimaryScreen.Bounds;
                this._width      = this._screenArea.Width;
                this._height     = this._screenArea.Height;
            }
        }
Ejemplo n.º 6
0
        private string GetKeysCombo(CaptureTypes type)
        {
            CheckBox shift = null, alt = null, ctrl = null;
            ComboBox key = null;

            switch (type)
            {
            case CaptureTypes.ScreenArea:
                shift = chbAreaScreenShift;
                alt   = chbAreaScreenAlt;
                ctrl  = chbAreaScreenCtrl;
                key   = cmbAreaScreen;
                break;

            case CaptureTypes.ScreenFull:
                shift = chbFullScreenShift;
                alt   = chbFullScreenAlt;
                ctrl  = chbFullScreenCtrl;
                key   = cmbFullScreen;
                break;

            case CaptureTypes.VideoArea:
                shift = chbAreaVideoShift;
                alt   = chbAreaVideoAlt;
                ctrl  = chbAreaVideoCtrl;
                key   = cmbAreaVideo;
                break;

            case CaptureTypes.VideoFull:
                shift = chbFullVideoShift;
                alt   = chbFullVideoAlt;
                ctrl  = chbFullVideoCtrl;
                key   = cmbFullVideo;
                break;
            }
            List <string> res = new List <string>();

            if (shift.Checked)
            {
                res.Add("Shift");
            }
            if (alt.Checked)
            {
                res.Add("Alt");
            }
            if (ctrl.Checked)
            {
                res.Add("Ctrl");
            }
            res.Add(key.SelectedItem.ToString());
            return(string.Join("+", res));
        }
Ejemplo n.º 7
0
        /*
         * private void Start(bool selectArea)
         * {
         *  try
         *  {
         *      this.StartRec(selectArea);
         *  }
         *  catch (Exception exc)
         *  {
         *      MessageBox.Show(exc.Message);
         *  }
         * }*/

        private void StartRec(CaptureTypes type)
        {
            if (_isRecording == false)
            {
                this.SetScreenArea(type);
                this._isRecording = true;
                now  = DateTime.Now;
                name = $"{now.ToString().Replace(" ", "_").Replace(".", "_").Replace(":", "_") }.avi";
                path = Path.Combine(SettingsManager.videos_path, name);

                _writer.Open(path, _width, _height, fps, codec, bitrate);
                this._streamVideo           = new ScreenCaptureStream(this._screenArea);
                this._streamVideo.NewFrame += new NewFrameEventHandler(this.video_NewFrame);
                this._streamVideo.Start();
            }
        }
Ejemplo n.º 8
0
 public void Sync(ITransport transport, CaptureTypes requestedCaptureTypes)
 {
     if (requestedCaptureTypes == _runningCaptureTypes)
     {
         return;
     }
     lock (this)
     {
         if (requestedCaptureTypes == _runningCaptureTypes)
         {
             return;
         }
         Stop();
         Start(transport, requestedCaptureTypes);
     }
 }
Ejemplo n.º 9
0
        public static void StartRec(CaptureTypes type)
        {
            if (_isRecording == false)
            {
                SetScreenArea(type);
                _isRecording = true;
                now          = DateTime.Now;
                name         = $"{now.ToString().Replace(" ", "_").Replace(".", "_").Replace(":", "_") }.avi";
                path         = Path.Combine(SettingsManager.videos_path, name);

                _writer.Open(path, _width, _height, fps, codec, bitrate);
                _streamVideo           = new ScreenCaptureStream(_screenArea);
                _streamVideo.NewFrame += new NewFrameEventHandler(video_NewFrame);
                _streamVideo.Start();
                MainWindow.TrayApp.ShowBalloonTip(2000, "TankiTools", $"{L18n.Get("TrayApp", "Balloon_VideoStarted")}", ToolTipIcon.None);
            }
        }
Ejemplo n.º 10
0
        private static void SetScreenArea(CaptureTypes type)
        {
            screenLeft = screenTop = 0;
            useArea    = false;

            if (type == CaptureTypes.VideoArea)
            {
                using (SelectableVideoArea f = new SelectableVideoArea())
                {
                    if (f.ShowDialog() == DialogResult.OK)
                    {
                        _screenArea = f.AreaBounds;

                        decimal prop       = (decimal)4 / 3;
                        decimal realProp   = (decimal)f.w / f.h + 1;
                        bool    makeLonger = realProp < prop;
                        int     w          = Convert.ToInt32(makeLonger ? f.h * prop : f.w);
                        int     h          = Convert.ToInt32(makeLonger ? f.h : f.w / prop);

                        if ((w & 1) != 0)
                        {
                            w = w + 1;
                        }
                        if ((h & 1) != 0)
                        {
                            h = h + 1;
                        }

                        _width     = w;
                        _height    = h;
                        screenLeft = f.AreaBounds.Left;
                        screenTop  = f.AreaBounds.Top;
                        useArea    = true;
                    }
                }
            }
            if (type == CaptureTypes.VideoFull)
            {
                _screenArea = Screen.PrimaryScreen.Bounds;
                _width      = _screenArea.Width;
                _height     = _screenArea.Height;
            }
        }
Ejemplo n.º 11
0
        public static bool RegisterHotkeys(CaptureTypes type, string combo, bool save = true, bool suppress = false)
        {
            IntPtr hWnd     = Util.Main.Handle;
            int    modifier = NOMOD;
            int    key      = 0;
            int    id       = 0;

            foreach (string _key in combo.Split('+'))
            {
                if (_key == "Shift")
                {
                    modifier += SHIFT;
                }
                if (_key == "Alt")
                {
                    modifier += ALT;
                }
                if (_key == "Ctrl")
                {
                    modifier += CTRL;
                }
                else
                {
                    key = (int)GetKey(_key);
                }
            }
            id = modifier ^ key ^ hWnd.ToInt32() + combo.GetHashCode();
            bool result = RegisterHotKey(hWnd, id, modifier, key);

            if (result && save)
            {
                HotkeyIds[type] = id;
            }
            if (!suppress && !result)
            {
                MessageBox.Show($"{L18n.Get("Settings", "Text_cannotregister")} {combo}",
                                "", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            return(result);
        }
Ejemplo n.º 12
0
    public override Result CapturePrepare(CaptureTypes captureType)
    {
        if (process != null)
        {
            return(new Result(false, ""));
        }

        string tempFile = Util.GetWebcamPhotoTempFileNamePost(videoDeviceToFilename());

        Util.FileDelete(tempFile);

        List <string> parameters = new List <string>();
        //-noborder -nosound -tv driver=v4l2:gain=1:width=400:height=400:device=/dev/video0:fps=10:outfmt=rgb16 tv:// -vf screenshot=/tmp/chronojump-last-photo
        //parameters.Insert (0, "-noborder"); //on X11 can be: title "Chronojump"". -noborder makes no accept 's', or 'q'

        int i = 0;

        if (UtilAll.GetOSEnum() == UtilAll.OperatingSystems.LINUX)
        {
            parameters.Insert(i++, "-title");               //on X11 can be: title "Chronojump"". -noborder makes no accept 's', or 'q'
            if (captureType == CaptureTypes.PHOTO)
            {
                parameters.Insert(i++, "Chronojump snapshot");
            }
            else             //if(captureType == CaptureTypes.VIDEO)
            {
                parameters.Insert(i++, "Chronojump video record");
            }
        }
        else
        {
            parameters.Insert(i++, "-noborder");
        }

        parameters.Insert(i++, "-nosound");
        parameters.Insert(i++, "-tv");
        parameters.Insert(i++, "driver=v4l2:gain=1:width=400:height=400:device=" + videoDevice + ":fps=10:outfmt=rgb16");
        parameters.Insert(i++, "tv://");
        parameters.Insert(i++, "-vf");
        parameters.Insert(i++, "screenshot=" + Util.GetWebcamPhotoTempFileNamePre(videoDeviceToFilename()));

        process = new Process();
        bool success = ExecuteProcess.RunAtBackground(ref process, executable, parameters, true, false, true, true, true);          //redirectInput, redirectOutput, redirectError

        if (!success)
        {
            streamWriter = null;
            process      = null;
            return(new Result(false, "", programMplayerNotInstalled));
        }

        /*
         * experimental double camera start
         */
        /*
         * List<string> parametersB = parameters;
         * parametersB[4] = "driver=v4l2:gain=1:width=400:height=400:device=/dev/video1:fps=10:outfmt=rgb16";
         * parametersB[7] = "screenshot=/tmp/b/chronojump-last-photo";
         * Process processB = new Process();
         * ExecuteProcess.RunAtBackground (processB, executable, parametersB, true); //redirectInput
         */
        /*
         * experimental double camera end
         */


        streamWriter = process.StandardInput;
        Running      = true;

        return(new Result(true, ""));
    }
 public ExportCaptureDeviceAttribute(string id, CaptureTypes types)
     : base(typeof(ICaptureDevice))
 {
     ID    = id;
     Types = types;
 }
Ejemplo n.º 14
0
 public abstract Result CapturePrepare(CaptureTypes captureType);