~ubuntu-branches/debian/sid/v4l-utils/sid

« back to all changes in this revision

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

  • Committer: Bazaar Package Importer
  • Author(s): Gregor Jasny
  • Date: 2010-05-07 20:48:34 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20100507204834-ga01cxhz3fekk47r
Tags: 0.8.0-1
* New upstream version
* Switch to 3.0 (quilt) source format
* Re-enable pristine-tar
* Split utils package into command line and the Qt based qv4l2
  (Closes: #576422)
* Update upstream URL

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* v4l2-api: low-level wrapper around v4l2 devices
2
 
 *
3
 
 * Copyright (C) 2009 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 V4L2_API_H
21
 
#define V4L2_API_H
22
 
 
23
 
#include <QString>
24
 
#include <linux/videodev2.h>
25
 
#include <libv4lconvert.h>
26
 
 
27
 
class v4l2
28
 
{
29
 
public:
30
 
        v4l2() : m_fd(-1) {}
31
 
        v4l2(v4l2 &old) :
32
 
                m_fd(old.m_fd),
33
 
                m_device(old.m_device),
34
 
                m_useWrapper(old.m_useWrapper),
35
 
                m_capability(old.m_capability)
36
 
        {}
37
 
 
38
 
        bool open(const QString &device, bool useWrapper = true);
39
 
        void close();
40
 
        int read(unsigned char *p, int size);
41
 
        int ioctl(unsigned cmd, void *arg);
42
 
        bool ioctl(const QString &descr, unsigned cmd, void *arg);
43
 
        void *mmap(size_t length, __off64_t offset);
44
 
        int munmap(void *_start, size_t length);
45
 
 
46
 
        inline int fd() const { return m_fd; }
47
 
        inline bool useWrapper() const { return m_useWrapper; }
48
 
        inline __u32 caps() const { return m_capability.capabilities; }
49
 
        inline const QString &device() const { return m_device; }
50
 
        static QString pixfmt2s(unsigned pixelformat);
51
 
 
52
 
        virtual void error(const QString &text);
53
 
 
54
 
        bool querycap(v4l2_capability &cap);
55
 
        bool queryctrl(v4l2_queryctrl &qc);
56
 
        bool querymenu(v4l2_querymenu &qm);
57
 
        bool g_tuner(v4l2_tuner &tuner);
58
 
        bool g_input(int &input);
59
 
        bool s_input(int input);
60
 
        bool g_output(int &output);
61
 
        bool s_output(int output);
62
 
        bool g_audio(v4l2_audio &audio);
63
 
        bool s_audio(int input);
64
 
        bool g_audout(v4l2_audioout &audout);
65
 
        bool s_audout(int output);
66
 
        bool s_std(v4l2_std_id std);
67
 
        bool g_std(v4l2_std_id &std);
68
 
        bool g_frequency(v4l2_frequency &freq);
69
 
        bool s_frequency(v4l2_frequency &freq);
70
 
        bool s_frequency(int freq);
71
 
        bool g_fmt_cap(v4l2_format &fmt);
72
 
        bool g_fmt_out(v4l2_format &fmt);
73
 
        bool try_fmt(v4l2_format &fmt);
74
 
        bool s_fmt(v4l2_format &fmt);
75
 
        bool enum_input(v4l2_input &in, bool init = false);
76
 
        bool enum_output(v4l2_output &out, bool init = false);
77
 
        bool enum_audio(v4l2_audio &audio, bool init = false);
78
 
        bool enum_audout(v4l2_audioout &audout, bool init = false);
79
 
        bool enum_std(v4l2_standard &std, bool init = false, int index = 0);
80
 
        bool enum_fmt_cap(v4l2_fmtdesc &std, bool init = false, int index = 0);
81
 
        bool enum_fmt_out(v4l2_fmtdesc &std, bool init = false, int index = 0);
82
 
        bool enum_framesizes(v4l2_frmsizeenum &frm, __u32 init_pixfmt = 0, int index = 0);
83
 
        bool enum_frameintervals(v4l2_frmivalenum &frm, __u32 init_pixfmt = 0, __u32 w = 0, __u32 h = 0, int index = 0);
84
 
 
85
 
        bool reqbufs_mmap_cap(v4l2_requestbuffers &reqbuf, int count = 0);
86
 
        bool reqbufs_user_cap(v4l2_requestbuffers &reqbuf, int count = 0);
87
 
        bool dqbuf_mmap_cap(v4l2_buffer &buf);
88
 
        bool dqbuf_user_cap(v4l2_buffer &buf);
89
 
        bool qbuf(v4l2_buffer &buf);
90
 
        bool qbuf_mmap_cap(int index);
91
 
        bool qbuf_user_cap(int index, void *ptr, int length);
92
 
        bool streamon_cap();
93
 
        bool streamoff_cap();
94
 
 
95
 
        bool reqbufs_mmap_out(v4l2_requestbuffers &reqbuf, int count = 0);
96
 
        bool reqbufs_user_out(v4l2_requestbuffers &reqbuf);
97
 
        bool dqbuf_mmap_out(v4l2_buffer &buf);
98
 
        bool dqbuf_user_out(v4l2_buffer &buf);
99
 
        bool qbuf_mmap_out(int index, int bytesused);
100
 
        bool qbuf_user_out(void *ptr, int length);
101
 
        bool streamon_out();
102
 
        bool streamoff_out();
103
 
 
104
 
private:
105
 
        void clear() { error(QString()); }
106
 
 
107
 
private:
108
 
        int             m_fd;
109
 
        QString         m_device;
110
 
        bool            m_useWrapper;           // true if using the libv4l2 wrappers
111
 
        v4l2_capability m_capability;
112
 
};
113
 
 
114
 
#endif