File indexing completed on 2024-05-12 16:23:35

0001 /***************************************************************************
0002  *   Copyright (C) 2005-2008 by Bjoern Erik Nilsen & Fredrik Berg Kjoelstad*
0003  *   bjoern.nilsen@bjoernen.com & fredrikbk@hotmail.com                    *
0004  *                                                                         *
0005  *   This program is free software; you can redistribute it and/or modify  *
0006  *   it under the terms of the GNU General Public License as published by  *
0007  *   the Free Software Foundation; either version 2 of the License, or     *
0008  *   (at your option) any later version.                                   *
0009  *                                                                         *
0010  *   This program is distributed in the hope that it will be useful,       *
0011  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
0012  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
0013  *   GNU General Public License for more details.                          *
0014  *                                                                         *
0015  *   You should have received a copy of the GNU General Public License     *
0016  *   along with this program; if not, write to the                         *
0017  *   Free Software Foundation, Inc.,                                       *
0018  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
0019  ***************************************************************************/
0020 #ifndef COMMANDLINEGRABBER_H
0021 #define COMMANDLINEGRABBER_H
0022 
0023 #include "src/config.h"
0024 #include "imagegrabber.h"
0025 
0026 #include <string>
0027 using std::string;
0028 
0029 
0030 /**
0031  * Abstract class for the different video grabbers used by the VideoView
0032  * widgets.
0033  *
0034  * @author Bjoern Erik Nilsen & Fredrik Berg Kjoelstad
0035  */
0036 class CommandLineGrabber : public ImageGrabber {
0037 public:
0038     /**
0039      * Initializes the member variables.
0040      * @param filePath path to the output file grabbed from a device
0041      * @param prePoll the pre-poll command to be run before grabbing
0042      * @param startProcess command line for starting the process
0043      * @param stopProcess command line for stopping the process
0044      * @param isProcess true if the process is running in daemon mode, false otherwise
0045      */
0046     CommandLineGrabber(const char* filePath);
0047     ~CommandLineGrabber();
0048     bool setPrePollCommand(const char *command);
0049     bool setStartCommand(const char *command);
0050     bool setStopCommand(const char *command);
0051     bool isGrabberProcess();
0052     
0053     /**
0054      * Starts the grabber if it is marked to be run in daemon mode.
0055      * @return true on success, false otherwise
0056      */
0057     bool init();
0058     
0059     /**
0060      * Grabs one picture from the device.
0061      * @return true on success, false otherwise
0062      */
0063     bool grab();
0064     
0065     /**
0066      * Shut downs the grabber process either if it is run in daemon
0067      * mode or "single grab" mode.
0068      * @return true on success, false otherwise
0069      */
0070     bool tearDown();
0071 
0072 private:
0073     string prePoll;
0074     string startProcess;
0075     string stopProcess;
0076     bool isInitSuccess;
0077     
0078     string parseCommand(const char* command);
0079 };
0080 
0081 #endif