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

« back to all changes in this revision

Viewing changes to README.lib

  • 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
Introduction
 
2
------------
 
3
 
 
4
libv4l is a collection of libraries which adds a thin abstraction layer on
 
5
top of video4linux2 devices. The purpose of this (thin) layer is to make it
 
6
easy for application writers to support a wide variety of devices without
 
7
having to write seperate code for different devices in the same class.
 
8
 
 
9
All libv4l components are licensed under the GNU Lesser General Public
 
10
License version 2 or (at your option) any later version.
 
11
 
 
12
libv4l consists of 3 different libraries:
 
13
 
 
14
 
 
15
libv4lconvert
 
16
-------------
 
17
 
 
18
libv4lconvert started as a library to convert from any (known) pixelformat to
 
19
V4l2_PIX_FMT_BGR24, RGB24, YUV420 or YVU420.
 
20
 
 
21
The list of know source formats is large and continually growing, so instead
 
22
of keeping an (almost always outdated) list here in the README, I refer you
 
23
to the source, see the list of defines at the top of
 
24
libv4lconvert/libv4lconvert.c for the full list.
 
25
For more details on the v4lconvert_ functions see libv4lconvert.h.
 
26
 
 
27
Later on libv4lconvert was expanded to also be able to do various video
 
28
processing functions to improve webcam video quality on a software basis. So
 
29
the name no longer 100% covers the functionality. The video processing is
 
30
split in to 2 parts, libv4lconvert/control and libv4lconvert/processing.
 
31
 
 
32
The control part is used to offer video controls which can be used to control
 
33
the video processing functions made available by libv4lconvert/processing.
 
34
These controls are stored application wide (until reboot) by using a
 
35
persistent shared memory object.
 
36
 
 
37
libv4lconvert/processing offers the actual video processing functionality.
 
38
 
 
39
 
 
40
libv4l1
 
41
-------
 
42
 
 
43
This offers functions like v4l1_open, v4l1_ioctl, etc. which can by used to
 
44
quickly make v4l1 applications work with v4l2 devices. These functions work
 
45
exactly like the normal open/close/etc, except that libv4l1 does full emulation
 
46
of the v4l1 api on top of v4l2 drivers, in case of v4l1 drivers it will just
 
47
pass calls through. For more details on the v4l1_ functions see libv4l1.h .
 
48
 
 
49
 
 
50
libv4l2
 
51
-------
 
52
 
 
53
This offers functions like v4l2_open, v4l2_ioctl, etc. which can by used to
 
54
quickly make v4l2 applications work with v4l2 devices with weird formats.
 
55
libv4l2 mostly passes calls directly through to the v4l2 driver. When the
 
56
app does a TRY_FMT / S_FMT with a not supported format libv4l2 will get in
 
57
the middle and emulate the format (if an app wants to know which formats the
 
58
hardware can _really_ do it should use ENUM_FMT, not randomly try a bunch of
 
59
S_FMT's). For more details on the v4l2_ functions see libv4l2.h .
 
60
 
 
61
 
 
62
wrappers
 
63
--------
 
64
 
 
65
The functionality provided by libv4l1 for v4l1 apps and libv4l2 for v4l2 apps
 
66
can also be used by existing apps without modifying them. For this purpose
 
67
2 wrapper libraries are provided which can be preloaded before starting the
 
68
application using the LD_PRELOAD environment variable. These wrappers will
 
69
then intercept calls to open/close/ioctl/etc. and if these calls directed
 
70
towards a video device the wrapper will redirect the call to the libv4lX
 
71
counterparts.
 
72
 
 
73
The preloadable libv4l1 wrapper which adds v4l2 device compatibility to v4l1
 
74
applications is called v4l1compat.so. The preloadable libv4l2 wrapper which
 
75
adds support for various pixelformats to v4l2 applications is called
 
76
v4l2convert.so.
 
77
 
 
78
Example usage (after install in default location):
 
79
$ export LD_PRELOAD=/usr/local/lib/libv4l/v4l1compat.so
 
80
$ camorama
 
81
 
 
82
 
 
83
Prerequisites
 
84
-------------
 
85
 
 
86
libv4l requires shmem file system support in the kernel (CONFIG_SHMEM).
 
87
 
 
88
 
 
89
Installation Instructions
 
90
-------------------------
 
91
 
 
92
Simple type the following commands from the libv4l-x.y.z directory
 
93
(adjusting PREFIX as desired):
 
94
make
 
95
make install PREFIX=/usr/local
 
96
 
 
97
Note: make install also supports the DESTDIR=... parameter for installation
 
98
into chroots.
 
99
 
 
100
If you require static libraries to also be built, these can be compiled
 
101
along with the dynamic equivalents by defining LINKTYPE to 'static', e.g.:
 
102
 
 
103
make LINKTYPE=static
 
104
make install LINKTYPE=static
 
105
 
 
106
 
 
107
FAQ
 
108
---
 
109
 
 
110
Q: Why libv4l, whats wrong with directly accessing v4l2 devices ?
 
111
Q: Do we really need yet another library ?
 
112
A: Current webcam using applications like ekiga contain code to handle many
 
113
different specific pixelformats webcam's use, but that code only supports a
 
114
small subset of all native webcam (compressed) pixelformats. Other current
 
115
v4l2 applications do not support anything but rgb pixelformats (xawtv for
 
116
example) and this will not work with most webcams at all.
 
117
 
 
118
With gspca being ported to v4l2 and thus decoding to normal formats being
 
119
removed from the device driver as this really belongs in userspace, ekiga
 
120
would need to be extended with many more often chip dependent formats, like
 
121
the bayer compression used by the spca561 and the (different) compression used
 
122
by the pac207 and the (again different) compression used by the sn9c102. Adding
 
123
support for all these formats should not be done at the application level, as
 
124
then it needs to be written for each application seperately. Licensing issues
 
125
with the decompressors will then also become a problem as just cut and pasting
 
126
from one application to another is bound to hit license incompatibilities.
 
127
 
 
128
So clearly this belongs in a library, and in a library with a license which
 
129
allows this code to be used from as many different applications as possible.
 
130
Hence libv4l was born.
 
131
 
 
132
 
 
133
Q: Under which license may I use and distribute libv4l?
 
134
A: The libv4l libraries are licensed under the GNU Library General Publishing
 
135
License version 2 or (at your option) any later version. See the included
 
136
COPYING.LIB file. The decompression helpers are licensed under the GNU
 
137
Library Publishing License version 2 (as they are derived from kernel code)
 
138
 
 
139
 
 
140
Q: Okay so I get the use of having a libv4lconvert, but why libv4l1 ?
 
141
A: Many v4l2 drivers do not offer full v4l1 compatibility. They often do not
 
142
implemented the CGMBUF ioctl and v4l1 style mmap call. Adding support to all
 
143
these drivers for this is a lot of work and more importantly unnecessary
 
144
adds code to kernel space.
 
145
 
 
146
Also even if the CGMBUF ioctl and v4l1 style mmap are supported, then most
 
147
cams still deliver pixelformats which v4l1 applications do not understand.
 
148
 
 
149
This libv4l1 was born as an easy way to get v4l1 applications to work with
 
150
v4l2 devices without requiring full v4l1 emulation (including format
 
151
conversion) in the kernel, and without requiring major changes to the
 
152
applications.
 
153
 
 
154
 
 
155
Q: Why should I use libv4l2 in my app instead of direct device access
 
156
   combined with libv4lconvert?
 
157
A: libv4l2 is mainly meant for quickly and easily adding support for more
 
158
pixelformats to existing v4l2 applications. So if you feel better directly
 
159
accessing the device in combination with libv4lconvert thats fine too.
 
160
 
 
161
Notice that libv4l2 also does emulation of the read() call on devices which
 
162
do not support it in the driver. In the background this uses mmap buffers
 
163
(even on devices which do support the read call). This mmap gives libv4lconvert
 
164
zero-copy access to the captured frame, and then it can write the converted
 
165
data directly to the buffer the application provided to v4l2_read(). Thus
 
166
another reason to use liv4l2 is to get the no memcpy advantage of the mmap
 
167
capture method combined with the simplicity of making a simple read() call.
 
168
 
 
169
 
 
170
Q: Where to send bugreports / questions?
 
171
A: Please send libv4l questions / bugreports to the:
 
172
   Linux Media Mailing List <linux-media@vger.kernel.org>
 
173
   Subscription is not necessary to send mail to this list. If you're not
 
174
   subscribed please put yourself in the CC of your original mail so you
 
175
   will receive replies.