Commit graph

771 commits

Author SHA1 Message Date
Nicolas Dufresne
a114a32d22 v4l2allocator: Valid FD are bigger or equal to zero 2014-05-08 15:56:36 -04:00
Nicolas Dufresne
d3383f9d4c v4l2object: Don't leak downstream pool in propose_allocation
parse_nth_allocation_pool() give a ref on the pool, we need to unref it
when done.
2014-05-08 15:56:36 -04:00
Nicolas Dufresne
eee61f39e5 v4l2: Introduce DMABUF_IMPORT IO mode 2014-05-08 15:56:36 -04:00
Nicolas Dufresne
1ab90ababa v4l2: Add dmabuf export support
This can be enabled sing io-mode=dmabuf. This will enabled mmap base
drivers to export the buffers as dmabuf.
2014-05-08 15:56:36 -04:00
Nicolas Dufresne
7b00d7ac46 v4l2allocator: Guaranty queued state integrety
Because of the buf in videobuf2, dqbuf may leave the DONE flag being,
which would implied that the buffer is queued. As this has been broken
for 4 years, simply guaranty the state flags integrity when doing
qbuf/dqbuf.

See https://patchwork.linuxtv.org/patch/23641/
2014-05-08 15:56:36 -04:00
Nicolas Dufresne
783417ee9f v4l2transform: Implement open/close 2014-05-08 15:56:36 -04:00
Nicolas Dufresne
23e273acb2 v4l2transform: Ensure output pool is configured 2014-05-08 15:56:36 -04:00
Nicolas Dufresne
026f79b5bd v4l2transform: Check if caps have changes before asserting
In set_caps, now checks if caps actually changed and succeed if they didn't
change.
2014-05-08 15:56:36 -04:00
Nicolas Dufresne
a89986ebd5 v4l2videodec: Ensure pool is configured 2014-05-08 15:56:36 -04:00
Nicolas Dufresne
83f053e980 v4l2object: Always set a size when deciding allocation 2014-05-08 15:56:36 -04:00
Nicolas Dufresne
acebdd86da v4l2object: Improved decide allocation
Improve decide allocation so it properly configure both local and downstream
buffer pools. Also read back the pool config if it was changed to to driver
limitations.
2014-05-08 15:56:36 -04:00
Nicolas Dufresne
cf6c7e9846 v4l2bufferpool: Do not pre-configure the pool
Pre-configuring the pool is error prone, since it may hide a configuration failure and
endup with a pool that is not configured the way it should (e.g. no video meta, wrong
queue size, etc.)
2014-05-08 15:56:36 -04:00
Nicolas Dufresne
fa6cd1d25a v4l2bufferpool: Preserve downstream minimum even in RW 2014-05-08 15:56:36 -04:00
Nicolas Dufresne
7b8bb7188b v4l2bufferpool: Turn cropmeta into a custom option
Turn crop meta into a custom option and make sure it's there is needed.
2014-05-08 15:56:36 -04:00
Nicolas Dufresne
db3d2f35f0 v4l2bufferpool: Early catch short allocation
Catch short allocation after saving the format. This is not a catch all, but should catch
most of the miss-behaving drivers when doing S_FMT/G_FMT and avoid potential crash.
2014-05-08 15:56:36 -04:00
Nicolas Dufresne
2b0ac06ade v4l2bufferpool: Port to use GstV4l2Allocator 2014-05-08 15:56:36 -04:00
Nicolas Dufresne
fd13e9e96d Implement V4l2 Allocator
This goal of this allocator is mainly to allow tracking the memory.
Currently, when a buffer memory has been modified, the buffer and it's
memory is disposed and lost until the stream is restarted.
2014-05-08 15:56:36 -04:00
Nicolas Dufresne
1b4561cf35 v4l2object: Don't advertise crop meta
Currently we advertise crop meta, but not element handle support this meta.
2014-05-08 15:56:36 -04:00
Nicolas Dufresne
a721e54922 v4l2object: Setup pool already send element error 2014-05-08 15:56:36 -04:00
Nicolas Dufresne
409cccb477 v4l2object: Workaround decoder that set num_planes to 0 in the format
Some well known decoder wrongly set num_planes to 0 in their format instead of
one. In this case we would endup with no size when deciding buffer allocation.
2014-05-08 15:56:36 -04:00
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