Commit graph

112 commits

Author SHA1 Message Date
Vincent Penquerc'h
3968dc7688 v4l2src: make this work more than once in a row
We used to skip frame rate setup if the camera was already setup
with the requested frame rate. This breaks some cameras though,
causing them to not output data (several models of Thinkpad cameras
have this problem at least).
So, don't skip.

https://bugzilla.gnome.org/show_bug.cgi?id=638300
2011-08-26 10:33:10 +02:00
Sjoerd Simons
8edb15d12f v4l2src: Use fraction compare util function.
Use the fraction compare utility to compare function, not the
handcrafted one. The handcrafted one is buggy as it doesn't take into
account rounding error. For example comparing a framerate of 20/1 on a
camera configured as 30/1 fps would yield true: 1 == (1 * 20)/30 and not
re-configure the camera. Fixes #656104
2011-08-07 16:41:53 +02:00
Rob Clark
6c8268dbfd v4l2: add interlaced support 2010-12-29 11:46:42 -06:00
Rob Clark
0cec72b97e v4l2sink: Add support for blocking dequeue.
We'd prefer to throttle the decoder if we run out of buffers, to keep a bound
on memory usage.  Also, for OMAP4 it is a requirement of the decoder to not
alternate between memory alloced by the display driver and malloc'd userspace
memory.
2010-12-29 11:46:40 -06:00
Stefan Kost
1f4f4581d8 v4l2src: don't skip calculating the duration 2010-09-10 17:00:58 +03:00
Stefan Kost
23106e243b v4l2: precalculate duration
Have frame duration in the instance struct and calculate it after changing the caps.
2010-06-22 15:46:51 +03:00
Benjamin Otte
1055aaa9cb Add -Wredundant-decls warning flag
Also fix compile issues
2010-03-17 19:35:10 +01:00
Stefan Kost
21a8cb1e06 v4l2src: don't deref NULL
Error out when the pool gets shutdown.
2010-01-25 17:23:43 +02:00
Stefan Kost
8576a11dae Revert "v4l2src: don't deref NULL"
This reverts commit 3d9d34bd60.
2010-01-25 17:21:13 +02:00
Stefan Kost
3d9d34bd60 v4l2src: don't deref NULL
Error out when the pool gets shutdown.
2010-01-25 14:16:22 +02:00
Stefan Kost
1a945a32cc v4l2: log buffer copies on queue underrun in perf category
v4l2src has a slow path where it does buffer-copies when it runs out of queued
buffers. Log this to performance category to help monitoring it.
2009-09-11 22:19:23 +03:00
Wim Taymans
796dec5920 v4l2src: add support for mpeg formats 2009-09-07 18:28:51 +02:00
Rob Clark
99e2ac121d v4l2sink: change where buffers get dequeued
It seems to cause strange occasional high latencies (almost 200ms) when dequeuing buffers from _buffer_alloc().  It is simpler and seems to work much better to dqbuf from the same thread that is queuing the next buffer.
2009-08-04 09:22:29 +02:00
Rob Clark
f19cfbda96 v4l2: Add v4l2sink element
This also does the following changes:
(1) pull the bufferpool code out into gstv4l2bufferpool.c, and make a
    bit more generic so it can be used both for v4l2src and v4l2sink
(2) move some of the device probing/configuration/caps stuff into
    gstv4l2object.c so it does not have to be duplicated between
    v4l2src and v4l2sink

Fixes bug #590280.
2009-08-04 09:16:56 +02:00
Elaine Xiong
085f87d85f v4l2: Fix v4l2src on OpenSolaris
The v4l2 driver for USB webcams on OpenSolaris does not support select()
calls. Detect when select() fails, and skip polling the device afterward,
which restores the pre 0.10.14 behaviour on OpenSolaris.

Signed-off-by: Jan Schmidt <thaytan@noraisin.net>
2009-07-19 11:42:13 +01:00
Stefan Kost
ad5702d492 v4l2src: move duplicated timestamping and buffer metadata code to _create()
This will include the latency changes also in the mmap case.
2009-03-25 10:08:41 +02:00
Stefan Kost
652a7fb91f v4l2src: remove win32 ifdefs introduced by commit cff3f46760eac74c9bbd7a36aca44fedf327424b
V4l2src is under sys and does not exists/run under windows anyway.
2009-03-25 10:06:48 +02:00
Stefan Kost
1d16c9cc27 v4l2src: log details if we have them, needed for #575391 2009-03-15 23:26:56 +02:00
Stefan Kost
f86b485f3b v4l2src: fix pads, so that they are subset of template caps
Do not add w=0 | h=0. When we can't get a framerate add fraction range.
2009-03-06 21:57:53 +02:00
Sjoerd Simons
b6755a7000 Wait for a frame to become available before capturing it
Use GstPoll to wait for the fd of the video device to become readable before
trying to capture a frame. This speeds up stopping v4l2src a lot as it no
longer has to wait for the next frame, especially when capturing with low
framerates or when the video device just never generates a frame (which seems a
common issue for uvcvideo devices)

Fixes bug #563574.
2009-03-01 19:55:26 +01:00
Levente Farkas
d2fc4cb3ba v4l2src: Make sort_by_frame_size conditionally compiled
sort_by_frame_size is declared static and only used inside
an ifdef, so use the same ifdef to define the function.  Fixes #572185

Signed-off-by: David Schleef <ds@schleef.org>
2009-02-23 09:20:49 -08:00
Tim-Philipp Müller
2e0d8e8b93 sys/v4l2/v4l2src_calls.c: Turns out we don't always get the frame sizes in a predefined order from lowest to highest ...
Original commit message from CVS:
* sys/v4l2/v4l2src_calls.c:
(gst_v4l2src_probe_caps_for_format_and_size), (sort_by_frame_size),
(gst_v4l2src_probe_caps_for_format):
Turns out we don't always get the frame sizes in a predefined
order from lowest to highest resolution, so let's just sort the
list by frame size once we've queried the possible resolutions
rather than assume any particular order. Fixes probed caps for
the camera in my HP2133 mini notebook and makes v4l2src default
to a decent size.
2008-11-17 14:04:20 +00:00
Bastien Nocera
a50de826a2 Optionally use libv4l to access v4l2 devices. Fixes bug #545033.
Original commit message from CVS:
Patch by: Bastien Nocera <hadess at hadess dot net>,
Hans de Goede <jwrdegoede at fedoraproject dot org>
* configure.ac:
* sys/v4l2/Makefile.am:
* sys/v4l2/gstv4l2src.c: (gst_v4l2src_get_read):
* sys/v4l2/v4l2_calls.c: (gst_v4l2_get_capabilities),
(gst_v4l2_fill_lists), (gst_v4l2_open), (gst_v4l2_close),
(gst_v4l2_get_norm), (gst_v4l2_set_norm), (gst_v4l2_get_frequency),
(gst_v4l2_set_frequency), (gst_v4l2_signal_strength),
(gst_v4l2_get_attribute), (gst_v4l2_set_attribute),
(gst_v4l2_get_input), (gst_v4l2_set_input):
* sys/v4l2/v4l2_calls.h:
* sys/v4l2/v4l2src_calls.c: (gst_v4l2_buffer_finalize),
(gst_v4l2_buffer_new), (gst_v4l2_buffer_pool_finalize),
(gst_v4l2_buffer_pool_new), (gst_v4l2_buffer_pool_activate),
(gst_v4l2src_fill_format_list),
(gst_v4l2src_probe_caps_for_format_and_size),
(gst_v4l2src_probe_caps_for_format), (gst_v4l2src_grab_frame),
(gst_v4l2src_set_capture), (gst_v4l2src_capture_init),
(gst_v4l2src_capture_start), (gst_v4l2src_capture_stop),
(gst_v4l2src_get_nearest_size):
Optionally use libv4l to access v4l2 devices. Fixes bug #545033.
2008-11-04 12:32:48 +00:00
Wim Taymans
46fe1e3fa0 sys/v4l2/v4l2src_calls.c: Guard more uncommon formats with ifdefs so that we can compile on older versions.
Original commit message from CVS:
* sys/v4l2/v4l2src_calls.c: (gst_v4l2src_format_get_rank):
Guard more uncommon formats with ifdefs so that we can compile on older
versions.
2008-10-31 10:08:50 +00:00
Stefan Kost
2ea5c05241 sys/v4l2/: Fix memory leaks. Small code cleanups : No need for empty _init(). No need to memset instance structures. ...
Original commit message from CVS:
* sys/v4l2/gstv4l2object.c:
* sys/v4l2/gstv4l2src.c:
* sys/v4l2/gstv4l2src.h:
* sys/v4l2/v4l2_calls.c:
* sys/v4l2/v4l2src_calls.c:
Fix memory leaks. Small code cleanups : No need for empty _init(). No
need to memset instance structures. Some more FIXME's.
2008-08-26 12:27:11 +00:00
Wim Taymans
713e800026 sys/v4l2/gstv4l2src.c: Add S910 and PWC formats with a low priority.
Original commit message from CVS:
* sys/v4l2/gstv4l2src.c: (gst_v4l2src_v4l2fourcc_to_structure),
(gst_v4l2_get_caps_info):
Add S910 and PWC formats with a low priority.
* sys/v4l2/v4l2src_calls.c: (gst_v4l2src_format_get_rank),
(gst_v4l2src_probe_caps_for_format):
Add more debugging.
2008-08-21 12:12:00 +00:00
Edward Hervey
5cf61c6a80 sys/v4l2/gstv4l2src.c: Properly set the maximum latency value, in the same way it is done in v4lsrc.
Original commit message from CVS:
* sys/v4l2/gstv4l2src.c: (gst_v4l2src_query):
Properly set the maximum latency value, in the same way it is done in
v4lsrc.
* sys/v4l2/v4l2src_calls.c:
Simplify fraction equality check, no need to use GValues for this.
2008-08-13 08:33:57 +00:00
Edward Hervey
27e20eadc0 sys/v4l2/gstv4l2src.c: Add warning messages stating exactly why the latency query failed.
Original commit message from CVS:
* sys/v4l2/gstv4l2src.c: (gst_v4l2src_query):
Add warning messages stating exactly why the latency query failed.
* sys/v4l2/v4l2src_calls.c: (gst_v4l2src_set_capture):
In some cases, the negotiated framerate might be the default one which
is already set internally. But we still need to mark it down in fps_n
and fps_d so that the latency query can happen properly.
2008-08-12 12:04:24 +00:00
Jan Schmidt
ab01993d33 sys/v4l2/v4l2src_calls.c: When outputting a pad template range for the size, include a framerate range too, to avoid ...
Original commit message from CVS:
* sys/v4l2/v4l2src_calls.c: (gst_v4l2src_probe_caps_for_format):
When outputting a pad template range for the size, include a framerate
range too, to avoid 'not a real subset of template caps' errors.
2008-08-07 10:22:32 +00:00
Sebastian Dröge
92ed8f6a74 Don't use declarations after statements and variable length arrays.
Original commit message from CVS:
* ext/raw1394/gstdv1394src.c: (gst_dv1394src_uri_set_uri):
* ext/speex/gstspeexenc.c: (gst_speex_enc_sink_getcaps):
* ext/wavpack/gstwavpackenc.c: (gst_wavpack_enc_set_wp_config):
* sys/v4l2/gstv4l2src.c: (gst_v4l2src_fixate):
* sys/v4l2/v4l2src_calls.c: (gst_v4l2src_probe_caps_for_format):
* tests/examples/equalizer/demo.c: (message_handler):
* tests/examples/spectrum/demo-audiotest.c: (message_handler):
* tests/examples/spectrum/demo-osssrc.c: (message_handler):
Don't use declarations after statements and variable length arrays.
2008-07-08 12:51:34 +00:00
Daniel Drake
23078b431b sys/v4l2/v4l2src_calls.c: Try progressive video if interlaced fails. Fixes bug #541956 and the usage of v4l2src on OLPC.
Original commit message from CVS:
Patch by: Daniel Drake <dsd at gentoo dot org>
* sys/v4l2/v4l2src_calls.c: (gst_v4l2src_set_capture),
(gst_v4l2src_get_nearest_size):
Try progressive video if interlaced fails. Fixes bug #541956
and the usage of v4l2src on OLPC.
2008-07-07 21:28:58 +00:00
William M. Brack
61597d99e9 sys/v4l2/v4l2src_calls.c: Fix potential caps leak.
Original commit message from CVS:
Patch by: William M. Brack <wbrack at mmm dot com dot hk>
* sys/v4l2/v4l2src_calls.c: (gst_v4l2src_probe_caps_for_format):
Fix potential caps leak.
If we can't get the framerate with an ioctl, try to get it with the
current norm. Fixes #520092.
2008-05-26 15:39:26 +00:00
William M. Brack
dfe8d582fc sys/v4l2/v4l2src_calls.c: If we fail to get the frame intervals, simply don't touch the framerates on the template ca...
Original commit message from CVS:
Patch by: William M. Brack <wbrack at mmm dot com dot hk>
* sys/v4l2/v4l2src_calls.c:
(gst_v4l2src_probe_caps_for_format_and_size):
If we fail to get the frame intervals, simply don't touch the framerates
on the template caps instead of discarding the format. See #520092.
2008-05-26 15:14:55 +00:00
Tim-Philipp Müller
d31a648d75 sys/v4l2/v4l2src_calls.c: Remove superfluous DEBUG macro.
Original commit message from CVS:
* sys/v4l2/v4l2src_calls.c: (gst_v4l2src_set_capture):
Remove superfluous DEBUG macro.
2008-03-25 12:39:22 +00:00
William M. Brack
e605a94e40 sys/v4l2/v4l2src_calls.c: Check whether the device supports setting the framerate before trying to set it and then po...
Original commit message from CVS:
Based on patch by: William M. Brack <wbrack at mmm com hk>
* sys/v4l2/v4l2src_calls.c: (fractions_are_equal),
(gst_v4l2src_set_capture):
Check whether the device supports setting the framerate before
trying to set it and then posting a warning or error if it doesn't
work (#516649, #520092). Also compare fractions more correctly.
2008-03-25 12:33:09 +00:00
William M. Brack
a6019fc0bf sys/v4l2/v4l2src_calls.c: Make sure the probed frame sizes are reversed in the resulting caps also when using V4L2_FR...
Original commit message from CVS:
Patch by: William M. Brack <wbrack at mmm com hk>
* sys/v4l2/v4l2src_calls.c:
(gst_v4l2src_probe_caps_for_format_and_size),
(gst_v4l2src_probe_caps_for_format):
Make sure the probed frame sizes are reversed in the resulting
caps also when using V4L2_FRMSIZE_STEPWISE (so they end up
highest resolution first); also remove unused variable.
(Partly fixes #520092)
2008-03-17 19:50:58 +00:00
Sebastian Dröge
45aeb687d2 sys/v4l2/v4l2src_calls.c: Chain up the finalize functions. Fixes bug #515984.
Original commit message from CVS:
* sys/v4l2/v4l2src_calls.c: (gst_v4l2_buffer_finalize),
(gst_v4l2_buffer_class_init), (gst_v4l2_buffer_pool_finalize),
(gst_v4l2_buffer_pool_class_init):
Chain up the finalize functions. Fixes bug #515984.
2008-02-12 11:38:54 +00:00
Jan Schmidt
38baf136e6 sys/v4l2/v4l2_calls.c: Treat ENOTTY (driver does not implement ioctl) the same as
Original commit message from CVS:
* sys/v4l2/v4l2_calls.c: (gst_v4l2_fill_lists):
Treat ENOTTY (driver does not implement ioctl) the same as
EINVAL since it implies there are no available standards.
* sys/v4l2/v4l2src_calls.c: (gst_v4l2src_probe_caps_for_format),
(gst_v4l2src_get_nearest_size):
Replace gst_v4l2src_get_size_limits with 2 calls to new function
gst_v4l2src_get_nearest_size, and get it to use VIDIOC_S_FMT to
probe if the driver does not support VIDIOC_TRY_FMT for whatever
reason, and if we aren't yet actively capturing.
* sys/v4l2/v4l2src_calls.h:
Remove replaced function declaration.
2008-01-31 16:12:28 +00:00
Brian Cameron
a973a4f154 configure.ac: Detect video4linux headers on Solaris too.
Original commit message from CVS:
* configure.ac:
Detect video4linux headers on Solaris too.
* sys/v4l2/gstv4l2colorbalance.h:
* sys/v4l2/gstv4l2object.h:
* sys/v4l2/v4l2_calls.c:
* sys/v4l2/v4l2src_calls.c: (gst_v4l2_buffer_finalize),
(gst_v4l2_buffer_new):
Make v4l2 build on Solaris.
Patch by: Brian Cameron  <brian.cameron at sun dot com>
Fixes: #510505
2008-01-21 19:35:58 +00:00
Tim-Philipp Müller
8d0960ec26 sys/v4l2/: Init some structs to zero before we pass them to ioctl, which avoids valgrind warnings. Also fix a small ...
Original commit message from CVS:
* sys/v4l2/v4l2_calls.c: (gst_v4l2_fill_lists):
* sys/v4l2/v4l2src_calls.c: (gst_v4l2src_fill_format_list):
Init some structs to zero before we pass them to ioctl, which
avoids valgrind warnings.  Also fix a small memory leak.
2007-12-11 11:50:54 +00:00
Edgard Lima
66ca1b2280 Always copy buffers by default (handle safer with bugged drivers) and added a property to make it possible to use mma...
Original commit message from CVS:
Always copy buffers by default (handle safer with bugged drivers) and added a property to make it possible to use mmap effectively (no copy if possible) when application wants to. Fixes: #480557.
2007-11-15 12:22:10 +00:00
Tim-Philipp Müller
a597c1d4e3 sys/v4l2/v4l2src_calls.c: but the corresponding ioctl() call fails even though the driver claims to support this form...
Original commit message from CVS:
* sys/v4l2/v4l2src_calls.c: (gst_v4l2src_probe_caps_for_format):
If VIDIOC_ENUM_FRAMESIZES is defined (= recent kernel), but the
corresponding ioctl() call fails even though the driver claims to
support this format, just fall back to the pre-2.6.19 kernel
routine that creates caps with suitable height and width ranges
(see #448278).
2007-11-13 17:19:13 +00:00
Tim-Philipp Müller
94c519cead sys/v4l2/v4l2src_calls.c: Fix 'unused variable' compiler warning when compiling against older kernel headers.
Original commit message from CVS:
* sys/v4l2/v4l2src_calls.c:
Fix 'unused variable' compiler warning when compiling against
older kernel headers.
2007-10-26 15:03:06 +00:00
Edgard Lima
7ec35b117e sys/v4l2/v4l2src_calls.c: Fixes "v4l2src ! queue ! xvimagesink". The queue ask for buffer too early. It is temporary ...
Original commit message from CVS:

* sys/v4l2/v4l2src_calls.c: (gst_v4l2src_grab_frame):
Fixes "v4l2src ! queue ! xvimagesink". The queue ask for buffer too
early. It is temporary until we find something better.
2007-10-22 19:14:08 +00:00
Wim Taymans
279fe5fac6 sys/v4l2/v4l2src_calls.c: Add some more debug info. Generate an error when we run out of buffers for some reason. See...
Original commit message from CVS:
* sys/v4l2/v4l2src_calls.c: (gst_v4l2_buffer_finalize),
(gst_v4l2src_grab_frame):
Add some more debug info. Generate an error when we run out of buffers
for some reason. See #480557.
2007-10-18 14:55:38 +00:00
Tim-Philipp Müller
a769e5e70a sys/v4l2/: When probing the formats and sizes a camera supports, make sure the best ones (highest resolution, prefere...
Original commit message from CVS:
* sys/v4l2/gstv4l2src.c:
* sys/v4l2/v4l2src_calls.c:
When probing the formats and sizes a camera supports, make
sure the best ones (highest resolution, prefered format)
end up at the beginning of the probed caps and the less
desirable ones at the end.  This is important because the
order within the caps matters for things like fixation and
negotiation, ie. what format is chosen in the end.
With recent kernels, the current probing code will end up
querying the supported sizes from lowest resolution to
highest resolution, adding them to the probed caps in that
order, resulting to v4l2src fixating to the lowest possible
resolution if downstream does not express a size preference.
Also make up a somewhat random ranking of prefered output
formats for the same reason. Fixes #485828.
2007-10-13 12:03:44 +00:00
Wim Taymans
3b78ab50ef sys/v4l2/v4l2src_calls.c: Fix framerate detection code some more.
Original commit message from CVS:
* sys/v4l2/v4l2src_calls.c:
(gst_v4l2src_probe_caps_for_format_and_size):
Fix framerate detection code some more.
Handle the case where there is a weird step in the stepwise framerates.
Don't overwrite the min interval with the framerate, use a temp variable
instead.
Use max in the Continuous framerate intervals instead of step, which is
1 according to the docs. Fixes #475424.
2007-09-11 15:37:55 +00:00
Wim Taymans
cd79aec473 sys/v4l2/v4l2src_calls.c: Don't overwrite our GValue with 0 but instead use the previously computed value. Fixes #471...
Original commit message from CVS:
* sys/v4l2/v4l2src_calls.c:
(gst_v4l2src_probe_caps_for_format_and_size):
Don't overwrite our GValue with 0 but instead use the previously
computed value. Fixes #471823 some more.
2007-09-07 16:04:14 +00:00
Tim-Philipp Müller
7c69e90236 sys/v4l2/: Implement LATENCY queries in the crudest way possible so I don't have to use sync=false any longer when te...
Original commit message from CVS:
* sys/v4l2/gstv4l2src.c:
* sys/v4l2/gstv4l2src.h:
* sys/v4l2/v4l2src_calls.c:
Implement LATENCY queries in the crudest way possible so I don't
have to use sync=false any longer when testing with videosinks.
2007-09-05 14:43:16 +00:00
Wim Taymans
c9d0575c74 sys/v4l2/v4l2src_calls.c: Add some more debugging in the framerate function.
Original commit message from CVS:
* sys/v4l2/v4l2src_calls.c:
(gst_v4l2src_probe_caps_for_format_and_size):
Add some more debugging in the framerate function.
Iterate stepwise framerate up to and _including_ the max and if nothing
was added to the list, add a dummy 0/1 to 100/1 framerate so that we
don't end up with an empty list.
2007-09-05 00:12:46 +00:00