summaryrefslogtreecommitdiff
path: root/v4l2-apps/test/qv4l2/qv4l2.h
blob: 1145af41758c6a2f45887502b6c2195e65c73646 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
/****************************************************************************
** $Id: qt/application.h   3.3.6   edited Aug 31 2005 $
**
** Copyright (C) 1992-2005 Trolltech AS.  All rights reserved.
**
** This file is part of an example program for Qt.  This example
** program may be used, distributed and modified without limitation.
**
*****************************************************************************/

#ifndef APPLICATION_H
#define APPLICATION_H

#include <qmainwindow.h>
#include <qtabwidget.h>
#include <qsignalmapper.h>
#include <qgrid.h>
#include <map>
#include <vector>

#define __user
#include <linux/videodev2.h>

class QComboBox;
class QSpinBox;

typedef std::vector<unsigned> ClassIDVec;
typedef std::map<unsigned, ClassIDVec> ClassMap;
typedef std::map<unsigned, struct v4l2_queryctrl> CtrlMap;
typedef std::map<unsigned, QWidget *> WidgetMap;

enum {
	CTRL_UPDATE_ON_CHANGE = 0x10,
	CTRL_DEFAULTS,
	CTRL_REFRESH,
	CTRL_UPDATE
};

class ApplicationWindow: public QMainWindow
{
    Q_OBJECT

public:
    ApplicationWindow();
    ~ApplicationWindow();

    void setDevice(const QString &device);

protected:
    void closeEvent( QCloseEvent* );

private slots:
    void choose();
    void ctrlAction(int);
    void inputChanged(int);
    void outputChanged(int);
    void inputAudioChanged(int);
    void outputAudioChanged(int);
    void standardChanged(int);
    void freqTableChanged(int);
    void freqChannelChanged(int);
    void freqChanged(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);
    void refresh(unsigned ctrl_class);
    void setDefaults(unsigned ctrl_class);
    int getVal(unsigned id);
    long long getVal64(unsigned id);
    void setVal(unsigned id, int v);
    void setVal64(unsigned id, long long v);
    QString getCtrlFlags(unsigned flags);
    void setWhat(QWidget *w, unsigned id, long long v);
    bool doIoctl(QString descr, unsigned cmd, void *arg);
    void updateVideoInput();
    void updateVideoOutput();
    void updateAudioInput();
    void updateAudioOutput();
    void updateStandard();
    void updateFreq();
    void updateFreqChannel();

    QString filename;
    QSignalMapper *sigMapper;
    QTabWidget *tabs;
    int fd;
    CtrlMap ctrlMap;
    WidgetMap widgetMap;
    ClassMap classMap;
    struct v4l2_tuner tuner;

    // General tab
    QComboBox *videoInput;
    QComboBox *videoOutput;
    QComboBox *audioInput;
    QComboBox *audioOutput;
    QComboBox *tvStandard;
    QSpinBox  *freq;
    QComboBox *freqTable;
    QComboBox *freqChannel;
};


#endif