Commit graph

801 commits

Author SHA1 Message Date
Nicolas Dufresne
46ffef798c v4l2object: Ensure size before configuring the pool 2014-05-08 15:56:36 -04:00
Nicolas Dufresne
5a61fb7f25 v4l2object: Set minimum buffers to 2
All the element requires at least two buffers. This is not used for RW mode.
2014-05-08 15:56:36 -04:00
Nicolas Dufresne
3393083497 v4l2object: Remove unused MAX_BUFFERS define 2014-05-08 15:56:36 -04:00
Nicolas Dufresne
8f6bd0dbc0 v4l2object: Don't hardcode min/max use default instead 2014-05-08 15:56:36 -04:00
Nicolas Dufresne
f6d425bf0f v4l2transform: Install PROP_CAPTURE_IO_MODE with right ID 2014-05-08 15:56:36 -04:00
Nicolas Dufresne
1635697f7e v4l2transform: decide_allocation returns a boolean 2014-05-08 15:56:36 -04:00
Nicolas Dufresne
cf788c9ec7 v4l2videodec: Install PROP_CAPTURE_IO_MODE with right ID 2014-05-08 15:56:36 -04:00
Nicolas Dufresne
527df8b888 v4l2transform: Add propose_allocation
This should remove 1 copy between the decoder and the transform.
2014-05-08 15:56:36 -04:00
Nicolas Dufresne
0488984f82 v4l2: Move propose allocation to v4l2object 2014-05-08 15:56:36 -04:00
Nicolas Dufresne
f810196b3e v4l2transform: Fixup caps query 2014-05-08 15:56:36 -04:00
Nicolas Dufresne
d4c24cc52f v4l2transform: Setup cropping if needed 2014-05-08 15:56:36 -04:00
Nicolas Dufresne
2676ac9075 v4l2transform: Expose BGRA and ARGB formats 2014-05-08 15:56:35 -04:00
Nicolas Dufresne
10b67e9913 v4l2transform: Ensure output pool is activated
That pool may be different then the internal pool.
2014-05-08 15:56:35 -04:00
Nicolas Dufresne
91efa79ed9 v4l2transform: Ensure internal buffer pools actication 2014-05-08 15:56:35 -04:00
Nicolas Dufresne
7a4b076099 v4l2transform: Move subinstance subclass init near other init 2014-05-08 15:56:35 -04:00
Nicolas Dufresne
6d5ffe8da2 v4l2transform: Stop stream before closing the devices. 2014-05-08 15:56:35 -04:00
Víctor Manuel Jáquez Leal
4f7ee5c130 v4l2transform: copy metdata 2014-05-08 15:56:35 -04:00
Nicolas Dufresne
b781156625 Implement GstV4l2Transform
Implement a v4l2 element that wraps HW video converters.
2014-05-08 15:56:35 -04:00
Nicolas Dufresne
0028de808b v4l2: Probe for CREATE_BUFS in order to correctly set pool min/max
In order to correctly set the pool min/max, we need to probe for CREATE_BUFS
ioctl. This can be done as soon as the format has been negotiated using a
count of 0.
2014-05-08 15:56:35 -04:00
Nicolas Dufresne
8d6e72a299 v4l2: Move capture eos handling in _process()
Now that we might be copying out buffer (e.g. downstream don't support video
meta bug we need it) we need to move the EOS handling inside the process
method.
2014-05-08 15:56:35 -04:00
Nicolas Dufresne
49065b1693 v4l2object: Fix support for planar format in 1 v4l2 mplane
So far we where only setting saving the first plane stride in the meta. This was
leading to wrong values in GstVideoMeta.
2014-05-08 15:56:35 -04:00
Nicolas Dufresne
a6a8c2b5eb v4l2videodec: Cleanly fail if set_format is never called 2014-05-08 15:56:35 -04:00
Nicolas Dufresne
a8e81bd81e v4l2: Expose RGB32 formats with and without alpha
As soon a the alpha component can be set, we can expose the RGB32 and BGR32
format as ARGB and BGRA as long we can deterministically set the alpha padding
value.
2014-05-08 15:56:35 -04:00
Nicolas Dufresne
403909d873 v4l2: Correctly check if video meta is needed
Correctly check if video meta is needed. In buffer pool, trust need_video_meta
flag in order to decide if configuration should succeed.
2014-05-08 15:56:35 -04:00
Nicolas Dufresne
f70bb08411 v4l2object: Fix tiled stride request
Fix stride request for tiled format and improve logging.
2014-05-08 15:56:35 -04:00
Nicolas Dufresne
36dfdff84c v4l2object: Ensure video and crop meta are enabled if needed
In certain cases we cannot live without video meta and/or crop meta
being enabled in our internal buffer pool. Ensure this is always the case,
regardless of having support for allocation query.
2014-05-08 15:56:35 -04:00
Nicolas Dufresne
e9eba56cd3 v4l2videodec: Ensure internal pool are activated 2014-05-08 15:56:35 -04:00
Nicolas Dufresne
a8024fef04 v4l2videodec: Check that pool where allocated before flushing them
Upon error, the pools might not have been allocated yet, hence we should not
try and flush them (even though we still want to make sure the processing thread
is fully stopped).
2014-05-08 15:56:35 -04:00
Nicolas Dufresne
6196026c76 v4l2bufferpool: Enforce activation outside of process
Enforce pool being activate from before calling pool process. This should
help catching basic errors in the usage of buffer pool.
2014-05-08 15:56:35 -04:00
Nicolas Dufresne
efe68f086f v4l2object: don't use own pool if downstream don't support video meta 2014-05-08 15:56:35 -04:00
Nicolas Dufresne
2f00119e3b v4l2bufferpool: Use obj->n_v4l2_planes for correct number of planes
Buffer pool was guessing wrongly the number of planes rather
then reading the value from obj->n_v4l2_planes. This was causing
format YU12 (I420) to fail upon check.
2014-05-08 15:56:35 -04:00
Nicolas Dufresne
f3ce6fd25b v4l2object: Fix handling of contiuous vs non-contiguous support
The complex mechanic to try and choose the right thing did not work. Instead,
simply probe the non-contiguous format first and then the contiguous one.
This is in fact very low overhead, as there is a relatively small number of
pixel format supported by each devices.
2014-05-08 15:56:35 -04:00
Nicolas Dufresne
a7286563ee v4l2: Add initial support for alignment and cropping 2014-05-08 15:56:35 -04:00
Nicolas Dufresne
70e7868f18 v4l2object: Rename setup_format() method into acquire_format()
The setup_format() was confusing since it does not set anything, in fact
it reads the setup from the driver and save it.
2014-05-08 15:56:35 -04:00
Nicolas Dufresne
8cf1c330d5 v4l2object: Move type declaration to the top 2014-05-08 15:56:35 -04:00
Nicolas Dufresne
b4d89b9809 v4l2videodec: Protect NULL pool while going to READY
When the pipeline fails early, the pool might be unset before the processing
thread has run once. Add protection against that.
2014-05-08 15:56:35 -04:00
Nicolas Dufresne
b5dde037b4 v4l2object: Fail cleanly if pixel format is unkown or not raw video
Certain decoder has been found to not choose a format automatically. Running
v4l2videodec on these would assert. This patch will make it fail cleanly
instead.
2014-05-08 15:56:35 -04:00
Nicolas Dufresne
7e379e8fff v4l2videodec: Clear the input state pointer after unref
If caps are set again, we have a risk od returning from set_format with a
input_state pointing to dead memory. Clearing the pointer after unref fix
this issue.
2014-05-08 15:56:35 -04:00
Nicolas Dufresne
7101c4341a v4l2videodec: handle stop being called without flush
Uppon certain downstream error, stop() is called without a flush(). This mean that
the streaming thread may still be running even though unlock has been called.
Now calling flush to reset the decoder state if we are processing.
2014-05-08 15:56:35 -04:00
Nicolas Dufresne
fb852669de v4l2videodec: Default to template in caps query 2014-05-08 15:56:35 -04:00
Nicolas Dufresne
27a617d75f v4l2videodec: Ensure processing thread has stopped when draining 2014-05-08 15:56:35 -04:00
Nicolas Dufresne
6f48c74f2a v4l2videodec: Don't drain if processing thread is inactive 2014-05-08 15:56:35 -04:00
Tim-Philipp Müller
17c107d4e4 v4l2: minor fix for closing the fd
The fd returned by open() could theoretically be 0 as well.

Coverity CID 1211823.
2014-05-05 12:07:25 +01:00
Nicolas Dufresne
717bbbbe70 v4l2devicemonitor: Port to use GstV4l2Iterator
https://bugzilla.gnome.org/show_bug.cgi?id=727925
2014-05-03 23:11:35 -04:00
Nicolas Dufresne
aa74871080 v4l2: Use single pass iterator for M2M probe
Instead of having each M2M class do their own probing, use the
GstV4l2Iterator and probe all devices in a single pass.

https://bugzilla.gnome.org/show_bug.cgi?id=727925
2014-05-03 23:11:35 -04:00
Nicolas Dufresne
726fc3b524 v4l2: Add a common device enumerator
This will allow removing code duplication (hence bugs duplication).

https://bugzilla.gnome.org/show_bug.cgi?id=727925
2014-05-03 23:11:35 -04:00
Nicolas Dufresne
f7d34bd237 v4l2videodec: Simplify sub-instanciation mechanism
Simplify sub-instanciation by defining an absract type and using subtype
class and instance init callback. This also fixes a bug where the template
pads get initialized too late.

https://bugzilla.gnome.org/show_bug.cgi?id=727925
2014-05-03 23:11:34 -04:00
Nicolas Dufresne
e06c9f7fce v4l2: Cleanup plugin registration
There is no plan to introduce special sources for jpeg, te v4l2src works fine
for this.

https://bugzilla.gnome.org/show_bug.cgi?id=727925
2014-05-03 23:11:34 -04:00
Nicolas Dufresne
7ff514fec6 v4l2: Correctly map RGB32 format
In v4l2 specification, RGB32 has the alpha, or pading, first, not last.
See http://linuxtv.org/downloads/v4l-dvb-apis/packed-rgb.html .

https://bugzilla.gnome.org/show_bug.cgi?id=540941
2014-04-30 15:36:07 -04:00
Sebastian Dröge
ab02b1db6c v4l2videodec: Initialise ioctl struct with zeroes before passing it to ioctl() 2014-04-16 17:23:52 +02:00
Nicolas Dufresne
e5ef2db489 v4l2: Fix support for caps without width, height, framerate or format
For format like mpegts, width and height is rarely in the negotiated caps. This
patch fixes failure when setting format, and prevent introducing width, height,
framerate and format to the caps when fixating.

https://bugzilla.gnome.org/show_bug.cgi?id=725860
2014-04-01 14:28:08 -04:00
William Manley
517f50f54f v4l2src: Fix support for mpegts streams
It seems that GStreamer's mpegts elements (tsdemux, tsparse) require caps
`video/mpegts,systemstream=true`.  As far as I can see the significance
of systemstream is to indicate that this is a container format rather than
an elementary stream.  As this is the case (and I can't understand how it
could not be the case with mpegts) I add systemstream=true to v4l2src's
caps.

This allows v4l2src to be linked with tsdemux for playback from my
Hauppauge HD-PVR with the pipeline:

    v4l2src ! queue ! tsdemux ! video/x-h264 ! decodebin ! xvimagesink

In combination with the next commit this fixes using Hauppauge HD-PVR with
GStreamer 1.0+.
2014-03-29 17:21:17 -04:00
Vincent Penquerc'h
4d0e1a4536 v4l2: attempt to fix infinite (for small version of infinite) loop 2014-03-29 17:09:02 -04:00
Rico Tzschichholz
f3caba6847 v4l2: fix distcheck
Make sure ext/*.h are dist'ed
2014-03-28 19:35:53 +00:00
Olivier Crête
cfa5877899 v4l2: Implement GstDeviceMonitor subclass
https://bugzilla.gnome.org/show_bug.cgi?id=678402
2014-03-16 20:37:54 -04:00
Olivier Crête
fdceedb77c v4l2: Remove GstPropertyProbe leftovers 2014-03-16 19:24:59 -04:00
Nicolas Dufresne
155d666845 v4l2: Add types compatiblity for other OS
Adds type compatiblity with other OS like BSD. This uses types mapping macro to
avoid conflict with existing defined types. We resuse glib types as these are
already available on supported platforms. This is GCC only because of the
le32 type that uses bitwise attribute.

https://bugzilla.gnome.org/show_bug.cgi?id=726453
2014-03-16 17:32:03 +01:00
Nicolas Dufresne
11103c6c47 v4l2: Remove XV support
XV support for v4l2 never became upstream and ended up being
commented out with an undef for a long time now.
2014-03-15 13:54:47 +01:00
Nicolas Dufresne
418a4940a8 v4l2: Use a copy of videodev2.h header
With years the amount of ifdef have grown up and we are not even sure if the
old code path compiles. Each time we need to update the v4l2 framework to add
the new feature, we break compilation on older kernel. With exception of two
controls in the video orientation control, this patch get rid of all ifdef by
including the latest version of videodev2.h inside GStreamer.

Fixes https://bugzilla.gnome.org/show_bug.cgi?id=723446
2014-03-15 13:54:47 +01:00
William Manley
4f47442c7f v4l2: Fix typo contol -> control
https://bugzilla.gnome.org/show_bug.cgi?id=725632
2014-03-08 19:29:58 -05:00
William Manley
d3bd3ecc3e v4l2: Normalise control names in the same way as v4l2-ctl
V4L2 kernel drivers allow configuration of the hardware settings via a
mechanism called controls.  These can be referred to by name such as
"Brightness" and "White Balance Temperature".  The user-space command line
client for setting these controls (v4l2-ctl) normalises these names such
that they only contain lower case alphanumeric characters and the
underscore '_'.  e.g:

    Kernel                     v4l2-ctl
    ----------------------------------------------------
    Brightness                 brightness
    White Balance Temperature  white_balance_temperature
    Focus (absolute)           focus_absolute

GStreamer seems to want to follow this pattern but failed for controls with
more than one consecutive non-alphanum character.  e.g. GStreamer would
produce "focus__absolute_" rather than "focus_absolute".

This commit fixes that issue.  Backwards compatibility is preserved by
normalising all control names before comparison.

https://bugzilla.gnome.org/show_bug.cgi?id=725632
2014-03-08 19:27:54 -05:00
Hugues Fruchet
a2d00122ed v4l2object: do not emit "parsed" caps for vp8
VP8 doesn't require parsing (vp8parse doesn't exist, so negotiation with demux fails
if "parsed" is set in caps).

https://bugzilla.gnome.org/show_bug.cgi?id=724636
2014-02-25 16:11:23 -05:00
Nicolas Dufresne
82f2bf052a v4l2: Don't require parser for VP8
Until GStreamer has one (see bug722760), we should not require a parser for VP8.

https://bugzilla.gnome.org/show_bug.cgi?id=722128
2014-02-25 14:29:11 -05:00
Nicolas Dufresne
a1db7e8c6c v4l2: CAPTURE_MPLANE is well tested now
https://bugzilla.gnome.org/show_bug.cgi?id=722128
2014-02-25 14:29:10 -05:00
Benjamin Gaignard
2a870d7d9b v4l2videodec: Create one element per device
For each videoCdevice probe it input/output capabilities
if it match with video decoder requirement register a new element.

Signed-off-by: Benjamin Gaignard <benjamin.gaignard@linaro.org>

https://bugzilla.gnome.org/show_bug.cgi?id=722128
2014-02-25 14:29:10 -05:00
Nicolas Dufresne
bd51c37196 v4l2videodec: Calculate latency from device information
Decoders or other devices that expose a minimum buffers required produce
an first output. We use this information to calculate latency.

https://bugzilla.gnome.org/show_bug.cgi?id=722128
2014-02-25 14:29:10 -05:00
Nicolas Dufresne
61183670c0 v4l2videodec: Implement v4l2videodec
Implement an element that can driver V4L2 M2M decoder device.

https://bugzilla.gnome.org/show_bug.cgi?id=722128
2014-02-25 14:29:10 -05:00
Mark Nauwelaerts
433d4f902d v4l2: make some more controls configurable
... at least if one tries hard enough using extra-controls property.
2014-02-23 13:06:43 +01:00
Mark Nauwelaerts
43a9c7652b v4l2src: handle old and odd driver behaviour when listing controls 2014-02-22 21:31:43 +01:00
Tim-Philipp Müller
5535a824a4 v4l2src: also unset INTERLACED flag on buffers if frame is not interlaced
https://bugzilla.gnome.org/show_bug.cgi?id=724899
2014-02-21 19:48:42 +00:00
Simon Farnsworth
b4820460d8 v4l2src: Flag interlaced buffers as interlaced.
We correctly indicate the field ordering on interlaced buffers, but fail to
flag them as containing interlaced video, which we need to do here because
we signal interlace-mode=mixed in our caps. This means that downstream
elements (like vaapipostproc from gstreamer-vaapi) don't recognise these
buffers as in need of deinterlacing.

Fix this by setting the interlaced flag on all interlaced buffers.

Signed-off-by: Simon Farnsworth <simon.farnsworth@onelan.co.uk>

https://bugzilla.gnome.org/show_bug.cgi?id=724899
2014-02-21 19:48:06 +00:00
Ryan Lortie
a46f667853 v4l2: guard use of ENODATA with #ifdef
Not all systems with v4l have ENODATA defined, so check that we have it
before attempting to use it.

https://bugzilla.gnome.org/show_bug.cgi?id=722953
2014-01-25 18:51:41 +01:00
Michael Olbrich
3978f6ae6c v4l2: set GST_BUFFER_FLAG_DELTA_UNIT when appropriate
https://bugzilla.gnome.org/show_bug.cgi?id=722394
2014-01-17 10:04:34 -05:00
Michael Olbrich
3d2bd4ff49 v4l2bufferpool: don't ref the newly created allocator
Otherwise the allocator will never be deleted.

https://bugzilla.gnome.org/show_bug.cgi?id=712612
2014-01-17 08:32:28 -05:00
Nicolas Dufresne
4cffae36e3 v4l2: Add NV12_64Z32 support
https://bugzilla.gnome.org/show_bug.cgi?id=722127
2014-01-14 16:51:52 -05:00
Vincent Penquerc'h
b80e3a4690 v4l2: fix build break using V4L2_CAP_VIDEO_M2M_MPLANE
This may not be defined. Since the previous version used
only the other define (V4L2_CAP_VIDEO_OUTPUT_MPLANE), fall
back on this only when not available.
2014-01-13 09:14:00 +00:00
Julien Isorce
55da3bc885 v4l2bufferpool: check set_config return value in gst_v4l2_buffer_pool_new
https://bugzilla.gnome.org/show_bug.cgi?id=720568
2014-01-10 17:20:21 -05:00
Nicolas Dufresne
b39c838ece v4l2object: Add parsed=1 field for encoded output
https://bugzilla.gnome.org/show_bug.cgi?id=720568
2014-01-10 17:20:21 -05:00
Nicolas Dufresne
5be7d39a3f v4l2object: Don't leak empty caps
https://bugzilla.gnome.org/show_bug.cgi?id=720568
2014-01-10 17:20:21 -05:00
Julien Isorce
a54b34121f v4l2bufferpool: do not stop a stream not previously started
https://bugzilla.gnome.org/show_bug.cgi?id=720568
2014-01-10 17:20:21 -05:00
Nicolas Dufresne
986e5b460d v4l2object: Don't enforce dimension field on encoded formats
Don't enforce having width, height and framerate in template caps for encoded
formats. These don't always need to be exposed and may break negotiation for
decoder and decoding sink. If needed, these field will be automatically added
when probed caps are known.

https://bugzilla.gnome.org/show_bug.cgi?id=720568
2014-01-10 17:20:21 -05:00
Julien Isorce
ba81eeb16b v4l2object: unref downstream pool
https://bugzilla.gnome.org/show_bug.cgi?id=720568
2014-01-10 17:20:21 -05:00
Julien Isorce
c701dcd16c v4l2bufferpool: add gst_v4l2_buffer_pool_flush
STREAMOFF set all v4l2buffers to DEQUEUE state.

Then for CAPTURE we call QBUF on each buffer.
For OUTPUT the buffers are just push back in the GstBufferPool
base class 's queue.
But the loop actually looks like the same.

https://bugzilla.gnome.org/show_bug.cgi?id=720568
2014-01-10 17:20:21 -05:00
Benjamin Gaignard
062f4f8710 v4l2object: Add vp8 support
https://bugzilla.gnome.org/show_bug.cgi?id=720568
2014-01-10 17:13:23 -05:00
Nicolas Dufresne
e017666645 v4l2object: Don't force framerate field for OUTPUT
If there is nothing that seems to force a certain framerate on output device, it is
preferable to simply not set that feild. This allow negotiation with tsdemux in a
decoder for example.

https://bugzilla.gnome.org/show_bug.cgi?id=720568
2014-01-10 17:13:23 -05:00
Nicolas Dufresne
97cf8f4d17 v4l2object: _v4l2fourcc_to_structure() can be static
This function is not used anymore outside v4l2object.

https://bugzilla.gnome.org/show_bug.cgi?id=720568
2014-01-10 17:13:23 -05:00
Nicolas Dufresne
fdd7bcc78c v4l2object: Add MPEG1/2 support
https://bugzilla.gnome.org/show_bug.cgi?id=720568
2014-01-10 17:13:23 -05:00
Nicolas Dufresne
0c8ec43a12 v4l2object: Ask for a decent buffer size when dealing with encoded formats
https://bugzilla.gnome.org/show_bug.cgi?id=720568
2014-01-10 17:13:23 -05:00
Nicolas Dufresne
86646ce03b v4l2bufferpool: On warn on size change if n_planes > 1
https://bugzilla.gnome.org/show_bug.cgi?id=720568
2014-01-10 17:13:23 -05:00
Julien Isorce
79f2c06883 v4l2object: check if translated format is valid
Also add a FIXME in gst_v4l2_object_setup_format
to note that the whole function has to be improved
in order to support ENCODED formats.
It requires to have an encoder device which we do not
have right now.

https://bugzilla.gnome.org/show_bug.cgi?id=720568
2014-01-10 17:13:23 -05:00
Nicolas Dufresne
520dda092a v4l2object: Validate returned dimensions
https://bugzilla.gnome.org/show_bug.cgi?id=720568
2014-01-10 17:13:23 -05:00
Nicolas Dufresne
61ce7b1a62 v4l2object: Ensure max is not smaller then min in decide_allocation
https://bugzilla.gnome.org/show_bug.cgi?id=720568
2014-01-10 17:13:23 -05:00
Nicolas Dufresne
b261287745 v4l2object: Don't keep the max paramter when using our own pool
https://bugzilla.gnome.org/show_bug.cgi?id=720568
2014-01-10 17:13:23 -05:00
Nicolas Dufresne
994c5d2c93 v4l2bufferpool: Respect the suggested min buffer
https://bugzilla.gnome.org/show_bug.cgi?id=720568
2014-01-10 17:13:23 -05:00
Nicolas Dufresne
a77d2a64c1 v4l2object: Allocate pool if needed in decide_allocation
https://bugzilla.gnome.org/show_bug.cgi?id=720568
2014-01-10 17:13:23 -05:00
Nicolas Dufresne
d79eea15fa v4l2object: Add V4L2_CID_MIN_BUFFERS_FOR_CAPTURE support
https://bugzilla.gnome.org/show_bug.cgi?id=720568
2014-01-10 17:13:23 -05:00
Nicolas Dufresne
3cf85c9083 v4l2: Move decide allocation into v4l2object
https://bugzilla.gnome.org/show_bug.cgi?id=720568
2014-01-10 17:13:23 -05:00
Nicolas Dufresne
34a8cb09c8 v4l2object: Implement _setup_format()
This method allow setting up the object from the currently configured format on the
device. This is useful for M2M element where input data decides the format that will
be set on capture side.

https://bugzilla.gnome.org/show_bug.cgi?id=720568
2014-01-10 17:13:23 -05:00
Nicolas Dufresne
41c37a2c6c v4l2object: Split out saving format from set_format()
https://bugzilla.gnome.org/show_bug.cgi?id=720568
2014-01-10 17:13:23 -05:00
Julien Isorce
582f913667 v4l2object: set only one plane for encoded format
https://bugzilla.gnome.org/show_bug.cgi?id=720568
2014-01-10 17:13:23 -05:00
Nicolas Dufresne
e2c32ec997 v4l2object: Move code block where it belongs
https://bugzilla.gnome.org/show_bug.cgi?id=720568
2014-01-10 17:13:23 -05:00
Nicolas Dufresne
689672ef17 v4l2object: Don't check format specific information
The number of plane, and the stride does not represent a capability change. Same caps
can have different stride from the default GstVideoInfo and the number of planes will
never change for 1 format.

https://bugzilla.gnome.org/show_bug.cgi?id=720568
2014-01-10 17:13:22 -05:00
Nicolas Dufresne
5faa20b044 v4l2object: Move the extrapolation of stride at the right place
Now that we have a stride array, we should extrapolate only when
eeded (non multi-planar buffer).

https://bugzilla.gnome.org/show_bug.cgi?id=720568
2014-01-10 17:13:22 -05:00
Nicolas Dufresne
5f1e47da24 v4l2object: Move back assertions where they should be
https://bugzilla.gnome.org/show_bug.cgi?id=720568
2014-01-10 17:13:22 -05:00
Nicolas Dufresne
a64de44a0c v4l2object: Move mplane logic into gst_v4l2_object_get_caps_info()
It makes the gst_v4l2_object_set_format() slightly simplier and will make that
logic reusable. Note that gst_v4l2_object_has_mplane() will always return the
same value for one device. There is no need to check against the caps as this
has already been done by _open.

https://bugzilla.gnome.org/show_bug.cgi?id=720568
2014-01-10 17:13:22 -05:00
Nicolas Dufresne
4956b46bab v4l2object: Split _v4l2fourcc_to_video_format
https://bugzilla.gnome.org/show_bug.cgi?id=720568
2014-01-10 17:13:22 -05:00
Nicolas Dufresne
e1be685c34 v4l2bufferpool: Request buffers only once
VIDIOC_REQBUFS allocates buffer, it has no place inside set_config. Also, some driver do
no allow multiple calls to this ioctl.

https://bugzilla.gnome.org/show_bug.cgi?id=720568
2014-01-10 17:13:22 -05:00
Nicolas Dufresne
b80169a16a v4l2object: Don't validate dimension for encoded format
We set the dimensions just in case but don't validate them
afterwards. For some codecs the dimensions are *not* in the
bitstream, IIRC VC1 in ASF mode for example.

https://bugzilla.gnome.org/show_bug.cgi?id=720568
2014-01-10 17:13:22 -05:00
Nicolas Dufresne
4a85f90c79 v4l2object: Quirks for dev without initial format
Most M2M have undefined behaviour initially when VIDIOC_G_FMT is called.

https://bugzilla.gnome.org/show_bug.cgi?id=720568
2014-01-10 17:13:22 -05:00
Nicolas Dufresne
080f58166e v4l2object: Add gst_v4l2_object_open_shared()
https://bugzilla.gnome.org/show_bug.cgi?id=720568
2014-01-10 17:13:22 -05:00
Nicolas Dufresne
cf32d6ec43 v4l2object: Implement gst_v4l2_dup()
This will duplicated the FD from another object and copy over the probed result.

https://bugzilla.gnome.org/show_bug.cgi?id=720568
2014-01-10 17:13:22 -05:00
Nicolas Dufresne
7fd6dc08b9 v4l2object: make IO_MODE enum public
This is to allow adding a second io-mode property on M2M device like decoder so
input and output can be controlled separatly.

https://bugzilla.gnome.org/show_bug.cgi?id=720568
2014-01-10 17:13:22 -05:00
Nicolas Dufresne
203e245134 v4l2: better handle quirks activation
This way we can activate deactivate those quirks all at once at one
place.

https://bugzilla.gnome.org/show_bug.cgi?id=720568
2014-01-10 17:13:22 -05:00
Nicolas Dufresne
092e7605d3 v4l2: Fix h264 caps
V4L2_PIX_FMT_H264 is documentated as byte-stream (with start code). The ensure proper
negotiation with element like h264parse.

https://bugzilla.gnome.org/show_bug.cgi?id=720568
2014-01-10 17:13:22 -05:00
Nicolas Dufresne
e821de3494 v4l2object: Split caps in different categories
This is need to correctly expose capabilities on specialized devices
like decoders and encoders.

https://bugzilla.gnome.org/show_bug.cgi?id=720568
2014-01-10 17:13:13 -05:00
Sebastian Rasmussen
3f8b423516 v4l2: Handle v4l2_ioctl() errors even in error handling
Fixes https://bugzilla.gnome.org/show_bug.cgi?id=721268
2014-01-03 10:59:57 +01:00
Julien Isorce
3c70741e45 v4l2bufferpool: add support for multi-planar V4l2 API in DMABUF mode
Fixes bug https://bugzilla.gnome.org/show_bug.cgi?id=712754
2013-12-04 09:28:25 +00:00
Julien Isorce
303cec48db v4l2: refactor by emulating one v4l2_plane in non-MPLANE mode
so that the buffer informations can be retrieved the same way
in both MPLANE and non-MPLANE mode.

Here "emulating" means "manually fill in the plane".

Fixes bug https://bugzilla.gnome.org/show_bug.cgi?id=712754
2013-12-04 09:28:08 +00:00
Julien Isorce
61ae84b50d v4l2: add support for multi-planar V4L2 API
This api is in linux kernel since version 2.6.39,
and present in all version 3.

The commit that adds the API in master branch of the
linux kernel source is:
f8f3914cf9

v4l2 doc: "Some devices require data for each input
or output video frame to be placed in discontiguous
memory buffers"

There are newer structures 'struct v4l2_pix_format_mplane'
and 'struct v4l2_plane'.
So the pixel format is not setup with the same API when using
multi-planar.

Also for gst-v4l2, one of the difference is that in GstV4l2Meta
there are now one mem pointer for each maped plane.

When not using multi-planar, this commit takes care of keeping
the same code path than previously. So that the 2 cases are
in two different blocks triggered from V4L2_TYPE_IS_MULTIPLANAR.

Fixes bug https://bugzilla.gnome.org/show_bug.cgi?id=712754
2013-12-04 09:27:20 +00:00
Nicolas Dufresne
90ac945dcc v4l2object: Use space instead of tabs
https://bugzilla.gnome.org/show_bug.cgi?id=712754
2013-11-25 13:44:50 -05:00
Nicolas Dufresne
f18290226a v4l2object: Fix header indentation so it's readable again
It's unfortunate to have to do this, but with the mix of tabs and space, plus all the random
indentation this header has become very hard to read.

https://bugzilla.gnome.org/show_bug.cgi?id=712754
2013-11-25 13:44:35 -05:00
Michael Olbrich
f8f2fc3e86 v4l2: clear cached caps on close
A different device with different caps may be used for the next open.

https://bugzilla.gnome.org/show_bug.cgi?id=712611
2013-11-21 14:14:24 -05:00
Tim-Philipp Müller
d506409af5 docs: get rid of 'Since: 0.10.x' markers
And some gtk-doc markup fixes.
2013-11-18 14:47:35 +00:00
Marc Leeman
be01e80e6b v4l2object: print FOURCC_FORMAT when enumerating
https://bugzilla.gnome.org/show_bug.cgi?id=712206
2013-11-13 13:52:49 +01:00
Marc Leeman
bc87f39a90 v4l2: init v4l2_buffer to 0x0 before ioctl
https://bugzilla.gnome.org/show_bug.cgi?id=712137
2013-11-12 13:08:33 -05:00
Peter Korsgaard
94f3d6fc07 v4l2bufferpool: O_CLOEXEC needs _GNU_SOURCE
On some systems (E.G. uClibc and older Glibc versions), O_CLOEXEC is only
defined when _GNU_SOURCE is specified, so do so.

_GNU_SOURCE needs to be defined before any system headers are included,
so move the fcntl.h section up.

https://bugzilla.gnome.org/show_bug.cgi?id=709423
2013-10-04 14:33:43 +02:00
Tim-Philipp Müller
51ff79842d v4l2src: print probed caps as caps again in debug log
This got lost during refactoring.
2013-10-03 18:33:01 +01:00
Robert Krakora
141a1fc296 v4l2bufferpool: Restore original GstMemory in buffer if it has been changed
https://bugzilla.gnome.org/show_bug.cgi?id=706083
2013-09-23 11:58:39 -04:00
Olivier Crête
19021e7176 v4l2: Remove commented out line 2013-09-19 17:39:17 -04:00
Olivier Crête
d1e16f7b0c v4l2bufferpool: dmabuf is not a singleton anymore
https://bugzilla.gnome.org/show_bug.cgi?id=707793
2013-09-18 15:13:59 -04:00
Mathieu Duponchelle
374a97a3e9 v4l2: Use newly #defined metadata names. 2013-09-09 15:39:17 +02:00
Sebastian Dröge
478f0dcfe7 v4l2bufferpool: Fix missing condition in previous commit 2013-09-09 14:46:42 +02:00
Sebastian Dröge
1e7c3e4520 v4l2bufferpool: Also fix strides for other semi-planar video formats 2013-09-09 14:45:55 +02:00
Andreea Fulger
78adf28a61 v4l2bufferpool: Fix stride for NV12/NV21
https://bugzilla.gnome.org/show_bug.cgi?id=707758
2013-09-09 14:45:55 +02:00
Tim-Philipp Müller
1dfc1f2686 Don't use setlocale in plugins()
Only apps should call setlocale(), not libraries.
2013-09-01 21:18:38 +01:00
Olivier Crête
d595c08aca v4l2: Add forward declaration for gst_v4l2_object_get_format_list 2013-08-19 13:19:42 -04:00
Olivier Crête
48caa1712a v4l2: De-duplicate caps probing between src and sink 2013-08-19 13:08:18 -04:00
Olivier Crête
24286f1612 v4l2: Use G_DEFINE_ macros for added thread safety 2013-08-19 12:48:35 -04:00
Tim-Philipp Müller
fdddc35f20 v4l2: remove unused enumtypes and use generic marshaller 2013-08-04 11:03:49 +01:00
Michael Olbrich
07e4dd3424 v4l2: bufferpool: don't forget to release buffer on error
If the pool is stopped while gst_v4l2_buffer_pool_dqbuf() waits for a
buffer then the return value is GST_FLOW_FLUSHING. In this case the buffer
to queue must also be released. Otherwise is will never be deleted or
returned to its pool.

https://bugzilla.gnome.org/show_bug.cgi?id=703764
2013-07-08 16:27:19 +02:00
Michael Olbrich
5c99fefa04 v4l2: don't extract data from caps twice
gst_video_info_from_caps() always extract width, height, interlace mode and
framerate now. It is no longer necessary to do it again for encoded
formats.

https://bugzilla.gnome.org/show_bug.cgi?id=703399
2013-07-02 10:08:46 +02:00
Wim Taymans
821d99a503 v4l2: don't redefine the PERFORMANCE debug variable
It is already defined in core.

fixes https://bugzilla.gnome.org/show_bug.cgi?id=702732
2013-06-20 15:35:11 +02:00
Sjoerd Simons
8e43c0ec9e v4l2: Optimize negotiation by removing the query filter
As cameras tend to have a quite specific set of capabilities (specific
framerates for each resolution), getting the peer caps filtered by our
probed caps can cause a big increase in the caps size which slows down
things quire a bit.

As for negotiation v4l2 iterates through the caps of the peer to find the
first intersection with the probed caps, getting the fully expanded
intersection of capabilities is not useful.

Using the same testcase as for bug #702632, adding this patch on top of
the patches suggested there speeds up getting the inital frame from
around ~14-15 seconds to around ~3-4 seconds.

https://bugzilla.gnome.org/show_bug.cgi?id=702638
2013-06-19 15:05:25 +02:00
Michael Olbrich
a1c34b5407 v4l2: make sure the element is not deleted before the pool
The pool accesses data from the v4l2object so it must exist at least
as long as the pool. Refcount the element which controls the object
live-time.

https://bugzilla.gnome.org/show_bug.cgi?id=701650
2013-06-07 20:07:42 +02:00
Michael Olbrich
0769a78dd1 v4l2: iterate controls with V4L2_CTRL_FLAG_NEXT_CTRL if possible
In v2.6.18 control classes where added to the v4l2 API.
Iterating over CIDs starting with V4L2_CID_BASE will only find controls for
the first control class.
By iterating with V4L2_CTRL_FLAG_NEXT_CTRL all controls are found.

This is necessary to make controls from other control classes available in
the extra-controls property.

If V4L2_CTRL_FLAG_NEXT_CTRL is not defined at compile time or not supported
at runtime then the old mechanism for iterating is used.

https://bugzilla.gnome.org/show_bug.cgi?id=701540
2013-06-05 13:00:21 +02:00
Michael Olbrich
74d217c44b v4l2: improve pixel aspect ratio handling
Instead of just assuming a aspect ratio of 1/1 use VIDIOC_CROPCAP to ask
the device.
This also add a pixel-aspect-ratio property to overwrite the value from the
driver and a force-aspect-ratio property to ignore it.

https://bugzilla.gnome.org/show_bug.cgi?id=700285
2013-06-04 17:37:15 +02:00
Stirling Westrup
86405d6ee7 v4l2: Fix compilation with older kernels
https://bugzilla.gnome.org/show_bug.cgi?id=701595
2013-06-04 17:04:11 +02:00
Michael Olbrich
3417a791ac v4l2: call VIDIOC_REQBUFS with count = 0 in pool_finalize
Without this the following sequence fails:

- set_caps()
  - object_stop() (does nothing)
  - set_format() -> VIDIOC_S_FMT
- set_config() -> VIDIOC_REQBUFS with count = N
- set_caps()
  - object_stop()
    - pool_finalize()
  - set_format() -> VIDIOC_S_FMT => EBUSY

Usually the pool is started after set_config(), in which case object_stop()
will result in a pool_stop and therefore VIDIOC_REQBUFS with count = 0 but
that is not guaranteed.
Also calling VIDIOC_REQBUFS with count = 0 in pool_finalize() if necessary
fixes this problem.

Fixes https://bugzilla.gnome.org/show_bug.cgi?id=701543
2013-06-04 10:45:06 +02:00
Michael Olbrich
496995a7d5 v4l2: rework sink buffer refcounting
This is a followup patch for #700781, which is not quite correct.
The buffer handling is quite complicated here.
The original code intended to the the following:

- gst_v4l2_buffer_pool_process() calls QBUF and adds the buffer to the
  local list.
- The sink calls gst_buffer_unref() which returns the buffer to the pool
  but not the 'free list'.
- Some time later DQBUF returns the buffer and
  gst_v4l2_buffer_pool_release_buffer() puts in on the 'free list'.

If the buffer must be copied then (parent_class)->acquire_buffer() is
called directly to keep the buffer in the pool.

This has two problems:
1. If gst_v4l2_buffer_pool_release_buffer() is called before the buffer is
   returned to the pool, then the buffer is put on the 'free list' twice.
   This can happen if a reference to the buffer is kept outside the sink,
   of if DQBUF returns the buffer, that was just queued with QBUF.
2. If buffers are copied, then all buffers are in the pool at all times. As
   a result gst_v4l2_buffer_pool_stop() and gst_v4l2_buffer_pool_dqbuf()
   can access pool->buffers at the same time, which can lead to memory
   corruption.

The patch for #700781 fixes those problems, but with the side effect that
there are always buffers outside the pool (because they are queued) and
the pool is never stopped.
This patch fixes this by releasing the reference to the buffer after
handling it (to avoid problem 2.) so it can be returned to the pool.
gst_v4l2_buffer_pool_release_buffer() is only called if the buffer is
already in the pool (to avoid problem 1.).

Fixes https://bugzilla.gnome.org/show_bug.cgi?id=701375
2013-06-03 11:55:48 +02:00
Sebastian Dröge
82e7826af0 v4l2: Only conditionally use V4L2_CTRL_TYPE_INTEGER_MENU, it's not available in older versions 2013-05-29 20:35:41 +02:00