00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00024
00025 #ifndef QVMPLAYERREADER_H
00026 #define QVMPLAYERREADER_H
00027
00028 #include <QVBaseReader>
00029
00030 #include <QFile>
00031 #include <QProcess>
00032 #include <QString>
00033 #include <QThread>
00034 #include <QUrl>
00035
00036 #include <QNamedPipe>
00037 #include <QVImage>
00038
00039 #ifndef DOXYGEN_IGNORE_THIS
00040
00041
00042
00043
00044
00045 class QVCheckOKMPlayer: public QThread
00046 {
00047 friend class QVMPlayerReader;
00048
00049 Q_OBJECT
00050 private:
00051 QVCheckOKMPlayer(QFile & fifo_file,int max_time_ms_to_wait_for_open);
00052
00053 QFile & _fifo_file;
00054 int _max_time_ms_to_wait_for_open;
00055
00056 void run();
00057
00058 private slots:
00059 void writeErrorInFifo();
00060 };
00061 #endif
00062
00063 class QVMPlayerReader : public QVBaseReader, public QObject
00064 {
00065 public:
00066 QVMPlayerReader():
00067 open_options(QVVideoReader::Default),
00068 path(QString()),
00069 schema(QString()),
00070 camera_opened(FALSE),
00071 frames_grabbed(0),
00072 live_camera(FALSE),
00073 imgY(QVImage<uChar>()),
00074 imgU(QVImage<uChar>()),
00075 imgV(QVImage<uChar>()),
00076 cols(0),
00077 rows(0),
00078 fps(0),
00079 time_length(0),
00080 time_pos(0),
00081 end_of_video(FALSE)
00082 { };
00083
00084 ~QVMPlayerReader() { if (camera_opened) close(); };
00085
00086 bool open( const QString & url_string,
00087 unsigned int & suggested_cols,
00088 unsigned int & suggested_rows,
00089 unsigned int & suggested_fps,
00090 QVVideoReader::OpenOptions & suggested_opts,
00091 QVVideoReader::TSourceMode & source_mode);
00092
00093 int getLength() { return fps*time_length; };
00094
00095 int getPos() { return fps*time_pos; };
00096
00097 bool grab(QVImage<uChar> &imgY, QVImage<uChar> &imgU, QVImage<uChar> &imgV);
00098
00099 bool close();
00100
00101 bool seek(int pos);
00102
00103 private:
00104 QVVideoReader::OpenOptions open_options;
00105 QStringList mplayer_args;
00106 QProcess *mplayer;
00107 QString path, schema;
00108 QNamedPipe *namedPipe;
00109 QFile fifoInput;
00110 bool camera_opened;
00111 unsigned int frames_grabbed;
00112 bool live_camera;
00113 QVImage<uChar> imgY, imgU, imgV;
00114 int cols, rows, fps;
00115 double time_length, time_pos;
00116 bool end_of_video;
00117
00118 void initMPlayerArgs(QString urlString, unsigned int suggested_cols, unsigned int suggested_rows);
00119 int interpretMPlayerOutput();
00120 bool performGrab();
00121 };
00122
00123 #endif // QVMPLAYERREADER_H