summaryrefslogtreecommitdiff
path: root/v4l2-apps
diff options
context:
space:
mode:
authorMauro Carvalho Chehab <mchehab@redhat.com>2008-11-20 10:58:02 -0200
committerMauro Carvalho Chehab <mchehab@redhat.com>2008-11-20 10:58:02 -0200
commit4bed69bfcb36161bcd89a7a61b6a912c32fea813 (patch)
treeb40092bb4cc41424343b1a4fd3d90b63f7f01fb3 /v4l2-apps
parentf7addb7035dedd9ba701c586fec16b234dde4a77 (diff)
parentc6f9ed52d0eb5d04c1c65914976d81315a872839 (diff)
downloadmediapointer-dvb-s2-4bed69bfcb36161bcd89a7a61b6a912c32fea813.tar.gz
mediapointer-dvb-s2-4bed69bfcb36161bcd89a7a61b6a912c32fea813.tar.bz2
merge: http://linuxtv.org/hg/~pinchartl/uvcvideo
From: Mauro Carvalho Chehab <mchehab@redhat.com> Priority: normal Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'v4l2-apps')
-rw-r--r--v4l2-apps/test/capture_example.c21
-rw-r--r--v4l2-apps/util/qv4l2/qv4l2.cpp58
-rw-r--r--v4l2-apps/util/qv4l2/qv4l2.h3
3 files changed, 69 insertions, 13 deletions
diff --git a/v4l2-apps/test/capture_example.c b/v4l2-apps/test/capture_example.c
index a15ef3c09..0cd129885 100644
--- a/v4l2-apps/test/capture_example.c
+++ b/v4l2-apps/test/capture_example.c
@@ -47,6 +47,7 @@ struct buffer *buffers;
static unsigned int n_buffers;
static int out_buf;
static int force_format;
+static int frame_count = 70;
static void errno_exit(const char *s)
{
@@ -171,7 +172,7 @@ static void mainloop(void)
{
unsigned int count;
- count = 1000;
+ count = frame_count;
while (count-- > 0) {
for (;;) {
@@ -558,19 +559,21 @@ static void usage(FILE *fp, int argc, char **argv)
{
fprintf(fp,
"Usage: %s [options]\n\n"
+ "Version 1.3\n"
"Options:\n"
- "-d | --device name Video device name [/dev/video0]\n"
+ "-d | --device name Video device name [%s]\n"
"-h | --help Print this message\n"
- "-m | --mmap Use memory mapped buffers\n"
+ "-m | --mmap Use memory mapped buffers [default]\n"
"-r | --read Use read() calls\n"
"-u | --userp Use application allocated buffers\n"
"-o | --output Outputs stream to stdout\n"
"-f | --format Force format to 640x480 YUYV\n"
+ "-c | --count Number of frames to grab [%i]\n"
"",
- argv[0]);
+ argv[0],dev_name,frame_count );
}
-static const char short_options[] = "d:hmruof";
+static const char short_options[] = "d:hmruofc:";
static const struct option
long_options[] = {
@@ -581,6 +584,7 @@ long_options[] = {
{ "userp", no_argument, NULL, 'u' },
{ "output", no_argument, NULL, 'o' },
{ "format", no_argument, NULL, 'f' },
+ { "count", required_argument, NULL, 'c' },
{ 0, 0, 0, 0 }
};
@@ -630,6 +634,13 @@ int main(int argc, char **argv)
force_format++;
break;
+ case 'c':
+ errno = 0;
+ frame_count = strtol(optarg, NULL, 0);
+ if (errno)
+ errno_exit(optarg);
+ break;
+
default:
usage(stderr, argc, argv);
exit(EXIT_FAILURE);
diff --git a/v4l2-apps/util/qv4l2/qv4l2.cpp b/v4l2-apps/util/qv4l2/qv4l2.cpp
index a93608af2..eb1506531 100644
--- a/v4l2-apps/util/qv4l2/qv4l2.cpp
+++ b/v4l2-apps/util/qv4l2/qv4l2.cpp
@@ -31,6 +31,7 @@
#include <fcntl.h>
#include <sys/ioctl.h>
#include <errno.h>
+#include <dirent.h>
#include "fileopen.xpm"
@@ -41,6 +42,7 @@ ApplicationWindow::ApplicationWindow()
fd = -1;
+ videoDevice = NULL;
sigMapper = NULL;
QToolBar * fileTools = new QToolBar( this, "file operations" );
fileTools->setLabel( "File Operations" );
@@ -129,17 +131,57 @@ void ApplicationWindow::setDevice(const QString &device)
setCentralWidget(tabs);
}
-void ApplicationWindow::choose()
+void ApplicationWindow::selectdev(int index)
+{
+ setDevice(videoDevice->text(index));
+}
+
+void ApplicationWindow::add_dirVideoDevice(char *dirname)
{
- QString fn = QFileDialog::getOpenFileName( "/dev/v4l", QString::null,
- this);
- if ( !fn.isEmpty() ) {
- setDevice(fn);
- }
- else
- statusBar()->message( "Loading aborted", 2000 );
+ DIR *dir;
+ struct dirent *entry;
+ char *vid = "video";
+ char *rad = "radio";
+ char *vbi = "vbi";
+ char name[512], *p;
+
+ dir = opendir(dirname);
+ if (!dir)
+ return;
+
+ strcpy(name, dirname);
+ strcat(name, "/");
+ p = name + strlen(name);
+
+ entry = readdir(dir);
+ while (entry) {
+ if (!strncmp(entry->d_name, vid, strlen(vid)) ||
+ !strncmp(entry->d_name, rad, strlen(rad)) ||
+ !strncmp(entry->d_name, vbi, strlen(vbi))) {
+ strcpy(p, entry->d_name);
+
+ videoDevice->insertItem(name);
+ }
+ entry = readdir(dir);
+ }
+ closedir(dir);
}
+void ApplicationWindow::choose()
+{
+ if (videoDevice)
+ delete videoDevice;
+
+ videoDevice = new QPopupMenu(this);
+
+ add_dirVideoDevice("/dev");
+ add_dirVideoDevice("/dev/v4l");
+
+ connect(videoDevice, SIGNAL(activated(int)), this, SLOT(selectdev(int)));
+
+ videoDevice->show();
+ videoDevice->setFocus();
+}
void ApplicationWindow::closeEvent( QCloseEvent* ce )
{
diff --git a/v4l2-apps/util/qv4l2/qv4l2.h b/v4l2-apps/util/qv4l2/qv4l2.h
index 1a0a8e15d..805c5d612 100644
--- a/v4l2-apps/util/qv4l2/qv4l2.h
+++ b/v4l2-apps/util/qv4l2/qv4l2.h
@@ -59,12 +59,14 @@ protected:
void closeEvent( QCloseEvent* );
private slots:
+ void selectdev(int);
void choose();
void ctrlAction(int);
void about();
private:
+ void add_dirVideoDevice(char *dirname);
void addTabs();
void finishGrid(QWidget *vbox, QGrid *grid, unsigned ctrl_class, bool odd);
void addCtrl(QGrid *grid, const struct v4l2_queryctrl &qctrl);
@@ -88,6 +90,7 @@ private:
QString filename;
QSignalMapper *sigMapper;
QTabWidget *tabs;
+ QPopupMenu *videoDevice;
int fd;
CtrlMap ctrlMap;
WidgetMap widgetMap;