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 | |
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>
-rw-r--r-- | test/qv4l2/qv4l2.cpp | 99 | ||||
-rw-r--r-- | test/qv4l2/qv4l2.h | 5 | ||||
-rw-r--r-- | test/v4l2-ctl.cpp | 13 |
3 files changed, 117 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() { diff --git a/test/qv4l2/qv4l2.h b/test/qv4l2/qv4l2.h index f3ecf7262..75b423ebf 100644 --- a/test/qv4l2/qv4l2.h +++ b/test/qv4l2/qv4l2.h @@ -51,11 +51,16 @@ protected: private slots: void choose(); void ctrlAction(int); + void inputChanged(int); + void outputChanged(int); + void inputAudioChanged(int); + void outputAudioChanged(int); void about(); private: void addTabs(); + void addGeneralTab(); void finishGrid(QWidget *vbox, QGrid *grid, unsigned ctrl_class, bool odd); void addCtrl(QGrid *grid, const struct v4l2_queryctrl &qctrl); void updateCtrl(unsigned id); diff --git a/test/v4l2-ctl.cpp b/test/v4l2-ctl.cpp index 6e044e563..63bc3e82a 100644 --- a/test/v4l2-ctl.cpp +++ b/test/v4l2-ctl.cpp @@ -1099,6 +1099,19 @@ int main(int argc, char **argv) } } + if (options[OptListAudioOutputs]) { + struct v4l2_audioout vaudio; /* list audio outputs */ + vaudio.index = 0; + printf("ioctl: VIDIOC_ENUMAUDOUT\n"); + while (ioctl(fd, VIDIOC_ENUMAUDOUT, &vaudio) >= 0) { + if (vaudio.index) + printf("\n"); + printf("\tOutput : %d\n", vaudio.index); + printf("\tName : %s\n", vaudio.name); + vaudio.index++; + } + } + if (options[OptSetAudioInput]) { if (doioctl(fd, VIDIOC_S_AUDIO, &vaudio, "VIDIOC_S_AUDIO") == 0) printf("Audio input set to %d\n", vaudio.index); |