~ubuntu-branches/ubuntu/precise/v4l-utils/precise

« back to all changes in this revision

Viewing changes to utils/qv4l2-qt4/qv4l2.h

  • Committer: Bazaar Package Importer
  • Author(s): Gregor Jasny
  • Date: 2010-02-28 19:44:15 UTC
  • Revision ID: james.westby@ubuntu.com-20100228194415-067hdj8rvawj91zw
Tags: upstream-0.7.90
ImportĀ upstreamĀ versionĀ 0.7.90

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* qv4l2: a control panel controlling v4l2 devices.
 
2
 *
 
3
 * Copyright (C) 2006 Hans Verkuil <hverkuil@xs4all.nl>
 
4
 *
 
5
 * This program is free software; you can redistribute it and/or
 
6
 * modify it under the terms of the GNU General Public License
 
7
 * as published by the Free Software Foundation; either version 2
 
8
 * of the License, or (at your option) any later version.
 
9
 *
 
10
 * This program is distributed in the hope that it will be useful,
 
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
13
 * GNU General Public License for more details.
 
14
 *
 
15
 * You should have received a copy of the GNU General Public License
 
16
 * along with this program; if not, write to the Free Software
 
17
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 
18
 */
 
19
 
 
20
#ifndef QV4L2_H
 
21
#define QV4L2_H
 
22
 
 
23
#include <QMainWindow>
 
24
#include <QTabWidget>
 
25
#include <QSignalMapper>
 
26
#include <QLabel>
 
27
#include <QGridLayout>
 
28
#include <QSocketNotifier>
 
29
#include <QImage>
 
30
#include <map>
 
31
#include <vector>
 
32
 
 
33
#include "v4l2-api.h"
 
34
 
 
35
class QComboBox;
 
36
class QSpinBox;
 
37
class GeneralTab;
 
38
class QCloseEvent;
 
39
class CaptureWin;
 
40
 
 
41
typedef std::vector<unsigned> ClassIDVec;
 
42
typedef std::map<unsigned, ClassIDVec> ClassMap;
 
43
typedef std::map<unsigned, struct v4l2_queryctrl> CtrlMap;
 
44
typedef std::map<unsigned, QWidget *> WidgetMap;
 
45
 
 
46
enum {
 
47
        CTRL_UPDATE_ON_CHANGE = 0x10,
 
48
        CTRL_DEFAULTS,
 
49
        CTRL_REFRESH,
 
50
        CTRL_UPDATE
 
51
};
 
52
 
 
53
enum CapMethod {
 
54
        methodRead,
 
55
        methodMmap,
 
56
        methodUser
 
57
};
 
58
 
 
59
struct buffer {
 
60
        void   *start;
 
61
        size_t  length;
 
62
};
 
63
 
 
64
 
 
65
class ApplicationWindow: public QMainWindow, public v4l2
 
66
{
 
67
        Q_OBJECT
 
68
 
 
69
public:
 
70
        ApplicationWindow();
 
71
        virtual ~ApplicationWindow();
 
72
 
 
73
private slots:
 
74
        void closeDevice();
 
75
        void closeCaptureWin();
 
76
 
 
77
public:
 
78
        void setDevice(const QString &device, bool rawOpen);
 
79
 
 
80
        // capturing
 
81
private:
 
82
        CaptureWin *m_capture;
 
83
 
 
84
        bool startCapture(unsigned buffer_size);
 
85
        void stopCapture();
 
86
        void startOutput(unsigned buffer_size);
 
87
        void stopOutput();
 
88
        struct buffer *m_buffers;
 
89
        struct v4l2_format m_capSrcFormat;
 
90
        struct v4l2_format m_capDestFormat;
 
91
        unsigned char *m_frameData;
 
92
        unsigned m_nbuffers;
 
93
        struct v4lconvert_data *m_convertData;
 
94
        CapMethod m_capMethod;
 
95
 
 
96
private slots:
 
97
        void capStart(bool);
 
98
        void capFrame();
 
99
 
 
100
        // gui
 
101
private slots:
 
102
        void opendev();
 
103
        void openrawdev();
 
104
        void ctrlAction(int);
 
105
 
 
106
        void about();
 
107
 
 
108
public:
 
109
        virtual void error(const QString &text);
 
110
        void error(int err);
 
111
        void errorCtrl(unsigned id, int err);
 
112
        void errorCtrl(unsigned id, int err, long long v);
 
113
        void info(const QString &info);
 
114
        virtual void closeEvent(QCloseEvent *event);
 
115
 
 
116
private:
 
117
        void addWidget(QGridLayout *grid, QWidget *w, Qt::Alignment align = Qt::AlignLeft);
 
118
        void addLabel(QGridLayout *grid, const QString &text, Qt::Alignment align = Qt::AlignRight)
 
119
        {
 
120
                addWidget(grid, new QLabel(text, parentWidget()), align);
 
121
        }
 
122
        void addTabs();
 
123
        void finishGrid(QGridLayout *grid, unsigned ctrl_class);
 
124
        void addCtrl(QGridLayout *grid, const struct v4l2_queryctrl &qctrl);
 
125
        void updateCtrl(unsigned id);
 
126
        void refresh(unsigned ctrl_class);
 
127
        void setDefaults(unsigned ctrl_class);
 
128
        int getVal(unsigned id);
 
129
        long long getVal64(unsigned id);
 
130
        void setVal(unsigned id, int v);
 
131
        void setVal64(unsigned id, long long v);
 
132
        QString getCtrlFlags(unsigned flags);
 
133
        void setWhat(QWidget *w, unsigned id, long long v);
 
134
        void updateVideoInput();
 
135
        void updateVideoOutput();
 
136
        void updateAudioInput();
 
137
        void updateAudioOutput();
 
138
        void updateStandard();
 
139
        void updateFreq();
 
140
        void updateFreqChannel();
 
141
 
 
142
        GeneralTab *m_genTab;
 
143
        QAction *m_capStartAct;
 
144
        QString m_filename;
 
145
        QSignalMapper *m_sigMapper;
 
146
        QTabWidget *m_tabs;
 
147
        QSocketNotifier *m_capNotifier;
 
148
        QImage *m_capImage;
 
149
        int m_row, m_col, m_cols;
 
150
        CtrlMap m_ctrlMap;
 
151
        WidgetMap m_widgetMap;
 
152
        ClassMap m_classMap;
 
153
};
 
154
 
 
155
extern ApplicationWindow *g_mw;
 
156
 
 
157
#endif