diff options
author | Hans Verkuil <hverkuil@xs4all.nl> | 2006-06-29 00:57:21 +0200 |
---|---|---|
committer | Hans Verkuil <hverkuil@xs4all.nl> | 2006-06-29 00:57:21 +0200 |
commit | 24461bbacbddc49d1b13d6f2da9f66e13e68a680 (patch) | |
tree | d8ed9c785a26f63343e51760f293df04db22dc1c /test/qv4l2/qv4l2.cpp | |
parent | 53ec74d7833a44ba5f7c4cf9d852b641c7510397 (diff) | |
download | mediapointer-dvb-s2-24461bbacbddc49d1b13d6f2da9f66e13e68a680.tar.gz mediapointer-dvb-s2-24461bbacbddc49d1b13d6f2da9f66e13e68a680.tar.bz2 |
Add support for a/v input/output selection
From: Hans Verkuil <hverkuil@xs4all.nl>
Add missing audio output enumeration to v4l2-ctl.
Add input/output and audio input/output selection to qv4l2.
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Diffstat (limited to 'test/qv4l2/qv4l2.cpp')
-rw-r--r-- | test/qv4l2/qv4l2.cpp | 99 |
1 files changed, 99 insertions, 0 deletions
diff --git a/test/qv4l2/qv4l2.cpp b/test/qv4l2/qv4l2.cpp index e3d6bf775..2299b9be7 100644 --- a/test/qv4l2/qv4l2.cpp +++ b/test/qv4l2/qv4l2.cpp @@ -118,6 +118,7 @@ void ApplicationWindow::setDevice(const QString &device) fd = ::open(device, O_RDONLY); if (fd >= 0) { + addGeneralTab(); addTabs(); } if (QWidget *current = tabs->currentPage()) { @@ -128,6 +129,79 @@ void ApplicationWindow::setDevice(const QString &device) setCentralWidget(tabs); } +void ApplicationWindow::addGeneralTab() +{ + int cnt = 0; + QVBox *vbox = new QVBox(tabs); + QGrid *grid = new QGrid(4, vbox); + grid->setSpacing(3); + tabs->addTab(vbox, "General"); + + struct v4l2_input vin; + memset(&vin, 0, sizeof(vin)); + if (ioctl(fd, VIDIOC_ENUMINPUT, &vin) >= 0) { + QLabel *label = new QLabel("Input", grid); + label->setAlignment(Qt::AlignRight); + QComboBox *combo = new QComboBox(grid); + while (ioctl(fd, VIDIOC_ENUMINPUT, &vin) >= 0) { + combo->insertItem((char *)vin.name); + vin.index++; + } + connect(combo, SIGNAL(activated(int)), SLOT(inputChanged(int))); + cnt++; + } + + struct v4l2_output vout; + memset(&vout, 0, sizeof(vout)); + if (ioctl(fd, VIDIOC_ENUMOUTPUT, &vout) >= 0) { + QLabel *label = new QLabel("Output", grid); + label->setAlignment(Qt::AlignRight); + QComboBox *combo = new QComboBox(grid); + while (ioctl(fd, VIDIOC_ENUMOUTPUT, &vout) >= 0) { + combo->insertItem((char *)vout.name); + vout.index++; + } + connect(combo, SIGNAL(activated(int)), SLOT(outputChanged(int))); + cnt++; + } + + struct v4l2_audio vaudio; + memset(&vaudio, 0, sizeof(vaudio)); + if (ioctl(fd, VIDIOC_ENUMAUDIO, &vaudio) >= 0) { + QLabel *label = new QLabel("Input Audio", grid); + label->setAlignment(Qt::AlignRight); + QComboBox *combo = new QComboBox(grid); + vaudio.index = 0; + while (ioctl(fd, VIDIOC_ENUMAUDIO, &vaudio) >= 0) { + combo->insertItem((char *)vaudio.name); + vaudio.index++; + } + connect(combo, SIGNAL(activated(int)), SLOT(inputAudioChanged(int))); + cnt++; + } + + struct v4l2_audioout vaudioout; + memset(&vaudioout, 0, sizeof(vaudioout)); + if (ioctl(fd, VIDIOC_ENUMAUDOUT, &vaudioout) >= 0) { + QLabel *label = new QLabel("Output Audio", grid); + label->setAlignment(Qt::AlignRight); + QComboBox *combo = new QComboBox(grid); + while (ioctl(fd, VIDIOC_ENUMAUDOUT, &vaudioout) >= 0) { + combo->insertItem((char *)vaudioout.name); + vaudioout.index++; + } + connect(combo, SIGNAL(activated(int)), SLOT(outputAudioChanged(int))); + cnt++; + } + + if (cnt & 1) { + new QWidget(grid); + new QWidget(grid); + } + QWidget *stretch = new QWidget(grid); + stretch->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Ignored); +} + void ApplicationWindow::addTabs() { struct v4l2_queryctrl qctrl; @@ -629,6 +703,31 @@ void ApplicationWindow::closeEvent( QCloseEvent* ce ) ce->accept(); } +void ApplicationWindow::inputChanged(int input) +{ + ioctl(fd, VIDIOC_S_INPUT, &input); +} + +void ApplicationWindow::outputChanged(int output) +{ + ioctl(fd, VIDIOC_S_OUTPUT, &output); +} + +void ApplicationWindow::inputAudioChanged(int input) +{ + struct v4l2_audio vaudio; + memset(&vaudio, 0, sizeof(vaudio)); + vaudio.index = input; + ioctl(fd, VIDIOC_S_AUDIO, &vaudio); +} + +void ApplicationWindow::outputAudioChanged(int output) +{ + struct v4l2_audioout vaudioout; + memset(&vaudioout, 0, sizeof(vaudioout)); + vaudioout.index = output; + ioctl(fd, VIDIOC_S_AUDOUT, &vaudioout); +} void ApplicationWindow::about() { |