summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBent Bisballe Nyeng <deva@aasimon.org>2014-09-19 17:50:15 +0200
committerBent Bisballe Nyeng <deva@aasimon.org>2014-09-19 17:50:15 +0200
commit65fd912c67ad76ad7ef6dee1ade7d76d26b08efd (patch)
treec9e3813e9de70d1074b9d042639e482ff3749b28
parentcddfe69635bcb66bc254d20f4973eeabb4061b7e (diff)
Add video device argument.
-rw-r--r--src/mainwindow.cc3
-rw-r--r--src/mainwindow.h3
-rw-r--r--src/simplertp.cc6
-rw-r--r--src/v4l.cc10
-rw-r--r--src/v4l.h3
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();
diff --git a/src/v4l.cc b/src/v4l.cc
index c83da06..e649209 100644
--- a/src/v4l.cc
+++ b/src/v4l.cc
@@ -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();
diff --git a/src/v4l.h b/src/v4l.h
index 877843c..2fe474e 100644
--- a/src/v4l.h
+++ b/src/v4l.h
@@ -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();