diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/mainwindow.cc | 3 | ||||
-rw-r--r-- | src/mainwindow.h | 3 | ||||
-rw-r--r-- | src/simplertp.cc | 6 | ||||
-rw-r--r-- | src/v4l.cc | 10 | ||||
-rw-r--r-- | src/v4l.h | 3 |
5 files changed, 18 insertions, 7 deletions
diff --git a/src/mainwindow.cc b/src/mainwindow.cc index a0a2986..e4df3f2 100644 --- a/src/mainwindow.cc +++ b/src/mainwindow.cc @@ -29,7 +29,8 @@ #include <QLabel> #include <stdio.h> -MainWindow::MainWindow() +MainWindow::MainWindow(QString v4ldev) + : v4l(v4ldev) { connect(&v4l, SIGNAL(newImage(QImage)), this, SLOT(newImage(QImage))); setCentralWidget(new QLabel()); diff --git a/src/mainwindow.h b/src/mainwindow.h index 419c302..fb87dae 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -28,13 +28,14 @@ #define __SIMPLERTP_MAINWINDOW_H__ #include <QMainWindow> +#include <QString> #include "v4l.h" class MainWindow : public QMainWindow { Q_OBJECT public: - MainWindow(); + MainWindow(QString v4ldev); public slots: void newImage(QImage img); diff --git a/src/simplertp.cc b/src/simplertp.cc index 6cff1ff..d833cf1 100644 --- a/src/simplertp.cc +++ b/src/simplertp.cc @@ -32,7 +32,11 @@ int main(int argc, char *argv[]) { QApplication app(argc, argv); - MainWindow wnd; + QString v4ldev = "/dev/video0"; + + if(argc > 1) v4ldev = argv[1]; + + MainWindow wnd(v4ldev); wnd.show(); return app.exec(); @@ -66,7 +66,7 @@ struct buffer { size_t length; }; -static const char *dev_name; +static char *dev_name; static enum io_method io = IO_METHOD_MMAP; static int fd = -1; struct buffer *buffers; @@ -788,14 +788,19 @@ int main(int argc, char **argv) } #endif/*0*/ -V4L::V4L() +V4L::V4L(QString device) { + dev_name = strdup(device.toStdString().c_str()); + v4l = this; // Set global V4L object pointer. + start(); } V4L::~V4L() { + free(dev_name); + v4l = NULL; // Unset global V4L object pointer. // TODO: Stop thread.... somehow. @@ -803,7 +808,6 @@ V4L::~V4L() void V4L::run() { - dev_name = "/dev/video0"; force_format = true; open_device(); @@ -29,11 +29,12 @@ #include <QThread> #include <QImage> +#include <QString> class V4L : public QThread { Q_OBJECT public: - V4L(); + V4L(QString device = "/dev/video0"); ~V4L(); void run(); |