Commit graph

1450 commits

Author SHA1 Message Date
Aurélien Zanelli
114b84c1a3 v4l2allocator: fix gst_v4l2_allocator_stop prototype
gst_v4l2_allocator_stop returns a GstV4l2Return, not a gboolean.

https://bugzilla.gnome.org/show_bug.cgi?id=739792
2014-12-01 10:08:54 -05:00
Aurélien Zanelli
74eb903727 v4l2bufferpool: unref pool when v4l2_allocator_new() fails
https://bugzilla.gnome.org/show_bug.cgi?id=739791
2014-12-01 10:08:40 -05:00
Nicolas Dufresne
cfa5a9d938 v4l2: Remove last include to linux/videodev2.h
We now use and update our internal copy so we no longer have to ifdef
the entire code for features and defines that where added over the
years.

https://bugzilla.gnome.org/show_bug.cgi?id=740905
2014-11-30 17:55:19 -05:00
Nicolas Dufresne
ea4d9745e4 Revert "v4l2allocator: Remove unused variable"
This reverts commit ad4480d534.
2014-11-24 10:36:54 -05:00
Nicolas Dufresne
43d5a523f1 Revert "v4l2: move vb_queue probing from allocator to v4l2object"
This reverts commit ec6b8b84af.
2014-11-24 10:36:30 -05:00
Nicolas Dufresne
3591a91067 Revert "v4l2object: allow to automatic selection of dmabuf"
This reverts commit e6c2ad5571.
2014-11-24 10:33:29 -05:00
Nicolas Dufresne
ad4480d534 v4l2allocator: Remove unused variable
this was introduced by commit ec6b8b

https://bugzilla.gnome.org/show_bug.cgi?id=699382
2014-11-21 11:44:24 -05:00
Nicolas Dufresne
b9992e4347 v4l2: Handle corrupted buffer with empty payload
This allow skipping buffer flagged with ERROR that has no payload.
This is typical behaviour when a recovererable error occured during
capture in the driver, but that no valid data was ever written into that
buffer. This patch also translate V4L2_BUF_FLAG_ERROR into
GST_BUFFER_FLAG_CORRUPTED. Hence decoding error produce
by decoder due to missing frames will now be correctly marked. Finally,
this fixes a buffer leak when EOS is reached.

https://bugzilla.gnome.org/show_bug.cgi?id=740040
2014-11-21 11:29:19 -05:00
Benjamin Gaignard
e6c2ad5571 v4l2object: allow to automatic selection of dmabuf
If the v4l2 queue support dmabuf select this buffer pool mode
and update the query with allocator.
This patch only concern exporting dmabuf and not importing dmabuf
fd from downstream element.

https://bugzilla.gnome.org/show_bug.cgi?id=699382
2014-11-21 11:29:04 -05:00
Benjamin Gaignard
ec6b8b84af v4l2: move vb_queue probing from allocator to v4l2object
The goal is to make those information available in v4l2_object
to be able later to select the best allocation method for the pool

https://bugzilla.gnome.org/show_bug.cgi?id=699382
2014-11-21 11:28:18 -05:00
Aurélien Zanelli
36532f5070 v4l2allocator: fix error message if allocator is already active
https://bugzilla.gnome.org/show_bug.cgi?id=739789
2014-11-07 10:42:40 -05:00
Nicolas Dufresne
3282df51a4 v4l2bufferpool: Improve buffer validation
Improve buffer validation by making sure each memory are the right
one and that each memory is writable. This fixes tearing issues in
case downstream uses gst_buffer_make_writable() or other type
of GstBuffer copy where memory are only reffed.

https://bugzilla.gnome.org/show_bug.cgi?id=739754
2014-11-07 10:42:40 -05:00
Aurélien Zanelli
8fdfb58ec4 v4l2bufferpool: fix typo in flags
https://bugzilla.gnome.org/show_bug.cgi?id=739549
2014-11-03 08:59:50 -05:00
Tim-Philipp Müller
cde3ce38e1 v4l2src: fix a couple of minor leaks 2014-11-02 23:41:24 +00:00
Simon Farnsworth
02040d507c v4l2: Clean up interlace support
Rather than try and guess interlace support as part of checking supported
sizes, look for interlace support specifically in its own function.

As a cleanup, use V4L2_FIELD_ANY when probing sizes, which should result in
the driver doing the right thing.

With my capture setup, this gets me the following sample caps:

For 1080i resolution:
video/x-raw, format=(string)YUY2, width=(int)1920, height=(int)1080, pixel-aspect-ratio=(fraction)1/1, interlace-mode=(string)interleaved, framerate=(fraction){ 25/1, 30/1 }

For 720p resolution:
video/x-raw, format=(string)YUY2, width=(int)1280, height=(int)720, pixel-aspect-ratio=(fraction)1/1, interlace-mode=(string)progressive, framerate=(fraction){ 50/1, 60/1 }

For 576i/p resolution (both possible at the point of query):
video/x-raw, format=(string)YUY2, width=(int)720, height=(int)576, pixel-aspect-ratio=(fraction)1/1, interlace-mode=(string){ progressive, interleaved }, framerate=(fraction){ 25/1, 50/1 }

This, in turn, makes 576i work correctly; with the old code,
the caps would be interlace-mode=progressive for interlaced video.

https://bugzilla.gnome.org/show_bug.cgi?id=726194
2014-11-01 11:46:13 -04:00
Aurélien Zanelli
1dcc883261 v4l2bufferpool: cleanly handle streamon failure for output device
On streamon failure, the queued buffer is not released from the
bufferpool class point of view because it is queued to the driver and
the flush logic is not performed since we are not in streaming state.
It causes the v4l2 bufferpool to always return that stop method failed
and to leak v4l2 objects and buffers.

This commit solve this by performing the flush logic in error case, ie
flushing the allocator and restoring queued buffer state to non-queued.

https://bugzilla.gnome.org/show_bug.cgi?id=738102
2014-10-29 16:24:20 -04:00
Aurélien Zanelli
8e9c752eca v4l2bufferpool: implement dispose method
Unref objects in dispose method rather than in finalize in order to
prevent circular reference.

https://bugzilla.gnome.org/show_bug.cgi?id=738102
2014-10-29 16:24:11 -04:00
Aurélien Zanelli
7ed27c264c v4l2bufferpool: check that allocator is non null when stopping pool
Otherwise, we could dereference NULL allocator when the stop method is
called by the GstBufferPool's finalize method.

https://bugzilla.gnome.org/show_bug.cgi?id=738102
2014-10-29 16:24:01 -04:00
Nicolas Dufresne
cc709d06de v4l2sink: Implement unlock/unlock_stop
This will prevent deadlocks, but will also properly flush the pool and allocator
when going to READY state. It should also fix issues reported on mailing list
when seeking is performed.

https://bugzilla.gnome.org/show_bug.cgi?id=738152
2014-10-29 16:22:14 -04:00
Tim-Philipp Müller
31b8cfecc2 pulse, v4l2: add missing G_END_DECLS in some places 2014-10-28 21:32:06 +00:00
Aurélien Zanelli
cfb4c02187 v4l2object: set colorspace for output devices
When the v4l2 device is an output device, the application shall set the
colorspace. So map GStreamer colorimetry info to V4L2 colorspace and set
on set_format. In case we have no colorimetry information, we try to
guess it according to pixel format and video size.

https://bugzilla.gnome.org/show_bug.cgi?id=737579
2014-09-29 21:23:01 -04:00
Tim-Philipp Müller
46df0cedb7 v4l2: remove redundant struct declaration 2014-09-27 16:01:21 +01:00
Linus Svensson
5fc970d686 ximagesrc: Fix build problem without XFIXES 2014-09-22 17:26:06 +03:00
Sebastian Dröge
d8a4435fd8 osxaudio: OSStatus is not a fourcc, so don't print it as one... 2014-09-17 13:55:18 +03:00
Antonio Ospite
80fa912b06 ximagesrc: Remove unused screen-num property
The screen number can be still specified as part of the display-name
property (e.g. for screen 1 of display 0 use display-name=":0.1").

https://bugzilla.gnome.org/show_bug.cgi?id=736122
2014-09-16 10:36:10 +03:00
Antonio Ospite
7554bd3916 ximagesrc: Draw the cursor only when it is active in the capturing region
Use XQueryPointer to check that the pointer is actually active inside
the capturing region.

This prevents drawing the cursor when the pointer is partially outside
of the captured region but not active inside the region; in particular
this avoids drawing the "window resize" cursor shapes to the captured
image when the mouse pointer crosses a window border.

NOTE that this is not only an optimization, this also happen to fix
a serious problem in multi-screen setups.

Because XFixes gives no information of what screen the pointer is on,
ximagesrc was always drawing the cursor on the captured screen even if
the mouse pointer was on another screen.

For example, when capturing from screen 1 (i.e. display-name=":0.1") the
cursor was drawn in the captured image even when the mouse pointer was
actually on screen 0, which is wrong and visually confusing.

https://bugzilla.gnome.org/show_bug.cgi?id=690646
2014-09-16 10:32:39 +03:00
Antonio Ospite
3705f08bad ximagesrc: Fix drawing the cursor when it is outside the capturing region
When the cursor is partially or totally out of the capturing region on
the top side or on the left side, it gets drawn fully inside of the
region with its coordinates rounded up to the left or to the top border.

This is immediately noticeable when using the xid property to capture
a specific window.

To fix the issue, allow negative cx and cx coordinates when checking the
boundaries before drawing the cursor.

NOTE that the boundaries checking calculations still allows the cursor
to be drawn when it is only partially outside of the capturing region,
but this makes sense and gives a more pleasing visual behaviour.

https://bugzilla.gnome.org/show_bug.cgi?id=690646
2014-09-16 10:32:33 +03:00
Antonio Ospite
cb70a7f6a7 ximagesrc: Fix the destination coordinates of the cursor
XFixes provides the cursor coordinates relative to the root window, this
is not taken into account when using the xid property to capture
a specific window, the result is that the cursor gets drawn at the wrong
position.

In order to fix this consider the window location when calculating the
cursor position in the destination image.

https://bugzilla.gnome.org/show_bug.cgi?id=690646
2014-09-16 10:32:22 +03:00
Peter Korsgaard
d3eea8f606 v4l2allocator: O_CLOEXEC needs _GNU_SOURCE
Similar to 94f3d6fc / bz 709423

On some systems (E.G. uClibc and older Glibc versions), O_CLOEXEC is only
defined when _GNU_SOURCE is specified, so do so.

https://bugzilla.gnome.org/show_bug.cgi?id=736670
2014-09-16 10:20:22 +03:00
Ognyan Tonchev
b417c3409b v4l2sink: Unref pool after usage
https://bugzilla.gnome.org/show_bug.cgi?id=736384
2014-09-10 08:26:18 -04:00
Nicolas Dufresne
de6db03b53 v4l2transform: Don't rank it for now
This will prevent the converter to be picked automatically in case
someone implement dynamic converter selection support. I'd like this
to be ranked only for known device, as it's hard to be sure a device is
a converter suited for general purpose. Re-negotiation is also needed
before we can rank it.

https://bugzilla.gnome.org/show_bug.cgi?id=733607
2014-09-09 19:03:50 -04:00
Nicolas Dufresne
b706103fab v4l2: Detect bad drivers timestamps
Even though the UVC driver do a great deal of effort to prevent bad
timestamp to be sent to userspace, there still exist UVC hardware that
are so buggy that the timestamp endup nearly random. This code detect
and ignore timestamp from these drivers, making these camera usable.
This has been tested on both invalid and valid cameras, making sure it
does not trigger for valid cameras.

https://bugzilla.gnome.org/show_bug.cgi?id=732910
2014-09-09 18:50:59 -04:00
Nicolas Dufresne
5c933fa781 v4l2allocator: Workaround driver that don't support REQBUFS(0)
There is still around 18 drivers not yet ported to videobuf2. These driver
don't support freeing buffetrs through REQBUFS(0) hence for these the
memory type probing fails. In order to gain back our previous behaviour in
presence of these, we implement a workaround that assuming MMAP is
supported. Note that an allocator is only created for device with
STREAMING support in the device capabilities. In such case one of MMAP,
USERPTR and DMABUF is required. Though DMABUF came afterward, so is
not an option and in practice none of these drivers will only do USERPTR.

https://bugzilla.gnome.org/show_bug.cgi?id=735660

Also-by: Hans de Goede <hdegoede@redhat.com>
2014-09-09 18:45:34 -04:00
Nicolas Dufresne
743c6a4475 v4l2: Merge min_buffers_for* variable into one
Reuse the same min_buffers variable for both capture and output, this
reduce the length of lines and make the code more readable.

https://bugzilla.gnome.org/show_bug.cgi?id=736072
2014-09-09 18:39:23 -04:00
Aurélien Zanelli
3afec4dd01 v4l2: set min_latency for output device according to required minimum number of buffers
Since we can get the minimum number of buffers needed by an output
device to work, use it to set min_latency which will determine how many
buffers are queued.

https://bugzilla.gnome.org/show_bug.cgi?id=736072
2014-09-09 18:39:23 -04:00
Hans de Goede
116649371e v4l2: get_nearest_size: Fix "Unsupported field type" errors
Most V4L2 ioctls like try_fmt will adjust input fields to match what the
hardware can do rather then returning -EINVAL. As is docmented here:
http://linuxtv.org/downloads/v4l-dvb-apis/vidioc-g-fmt.html

EINVAL is only returned if the buffer type field is invalid or not supported.

So upon requesting V4L2_FIELD_NONE devices which can only do interlaced
mode will change the field value to e.g. V4L2_FIELD_BOTTOM as only returning
half the lines is the closest they can do to progressive modes.

In essence this means that we've failed to get a (usable) progessive mode
and should fall back to interlaced mode.

This commit adds a check for having gotten a usable field value after the first
try_fmt, to force fallback to interlaced mode even if the try_fmt succeeded,
thereby fixing get_nearest_size failing on these devices.

https://bugzilla.gnome.org/show_bug.cgi?id=735660
2014-08-29 16:15:11 -04:00
Hans de Goede
8ad0509a1c v4l2: get_nearest_size: Always reinit all struct fields on retry
They may have been modified by the ioctl even if it failed. This also makes
the S_FMT fallback path try progressive first, making it consistent with the
preferred TRY_FMT path.

https://bugzilla.gnome.org/show_bug.cgi?id=735660
2014-08-29 16:14:56 -04:00
Nicolas Dufresne
2c870ff167 ximagesrc: Fix warning about missing return value 2014-07-31 09:53:53 -04:00
Nicolas Dufresne
c82052e723 ximagesrc: Add missing return value to Buffer dispose function
Depending ont he build, the method could return FALSE, hence never
free the buffers, or already TRUE and lead to a crash:

Fixes: https://bugzilla.gnome.org/show_bug.cgi?id=733695
2014-07-31 09:14:10 -04:00
Thiago Santos
550be3e51b v4l2bufferpool: clear gcond 2014-07-26 12:19:18 -03:00
Nicolas Dufresne
287517d6a9 Revert "v4l2bufferpool: Workaround elements not requesting any buffers"
This was a tempory workaround, we should fix the encoders that do not
negotatiate the amount of buffers they need.

This reverts commit d03bcba3db.
2014-07-25 14:30:33 -04:00
Nicolas Dufresne
3df949c745 v4l2object: Don't share own pool if min exceed V4L2 capacity
If the minimum required buffer exceed V4L2 capacity, don't share down
pool. This allow support very high latency, like with x264enc default
encoding settings.

https://bugzilla.gnome.org/show_bug.cgi?id=732288
2014-07-25 14:18:47 -04:00
Aurélien Zanelli
010272a796 v4l2object: query minimum required buffers for output
Some v4l2 devices could require a minimum buffers different from default
values. Rather than blindly propose a pool with min-buffers set to the
default value, it ask the device using control ioctl.

https://bugzilla.gnome.org/show_bug.cgi?id=733750
2014-07-25 13:43:09 -04:00
Aurélien Zanelli
de799f4d84 v4l2sink: use directly 'obj' instead of 'v4l2sink->v4l2object'
https://bugzilla.gnome.org/show_bug.cgi?id=733616
2014-07-25 13:42:33 -04:00
Aurélien Zanelli
57ae11ac6f v4l2: set debug messages according to device type and IO mode
https://bugzilla.gnome.org/show_bug.cgi?id=733616
2014-07-25 13:42:00 -04:00
Nicolas Dufresne
e196906b99 v4l2object: Remove is_active checks
These checks are no longer required with recent change to the bufferpool. This
should allow changing the configuartion, hence the way forward renegotiation
support.

https://bugzilla.gnome.org/show_bug.cgi?id=728268
2014-07-25 13:39:50 -04:00
Nicolas Dufresne
d7876e5597 v4l2bufferpool: Fix copy threshold implementation
We cannot allocate new buffer in acquire, otherwise the base class
is not aware and get confused. Instead, copy in _process(). This leads
to crash on finalize.

Fixes regression, see https://bugzilla.gnome.org/show_bug.cgi?id=732912
2014-07-11 13:45:30 -04:00
Nicolas Dufresne
0ac0cbcc0e v4l2allocator: Use qdata instead of parenting to DmabufMemory
Parenting V4l2Memory to DmabufMemory was in conflict with recent
optimization in DmabufMemory to avoid dup(), and didn't work with
memory sharing. Instead, use a qdata and it's destroy notify.

https://bugzilla.gnome.org/show_bug.cgi?id=730441
2014-07-11 09:49:27 +02:00
Nicolas Dufresne
d03bcba3db v4l2bufferpool: Workaround elements not requesting any buffers
This is a workaround for element that don't request buffers when
they should.

https://bugzilla.gnome.org/show_bug.cgi?id=732288
2014-07-10 18:22:10 -04:00
Nicolas Dufresne
12a3bdbd09 v4l2src: Ensure internal pool activation
Before we would hit an assertion "'gst_buffer_pool_is_active (bpool)' failed"
if the internal pool was not used to push buffer downstrea, hence not
given to the baseclass.

https://bugzilla.gnome.org/show_bug.cgi?id=732912
2014-07-09 15:26:12 -04:00