Commit graph

2023 commits

Author SHA1 Message Date
Nicolas Dufresne
dbdbcfe7ff v4l2videoenc: Fix negotiation caps leak
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/merge_requests/649>
2020-06-26 19:24:21 +00:00
Nicolas Dufresne
7bbe4653a4 v4l2videoenc: Skip negotiation of profiles/level if no codec
The codec structure is optional and not used for fwht test codec. This
was leading to a crash dereferencing NULL pointer.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/merge_requests/650>
2020-06-26 13:37:21 -04:00
Mathieu Duponchelle
ceece207e0 docs: mark more types as plugin API 2020-06-23 12:07:47 -04:00
Jordan Petridis
3e2420361a Use gst_element_class_set_metadata when passing dynamic strings
gst_element_class_set_metadata is meant to only be used with
static or inlined strings, which isn't the case for the 2 elements
here resulting in use-after-free later on.

https://gstreamer.freedesktop.org/documentation/gstreamer/gstelement.html?gi-language=c#gst_element_class_set_static_metadata

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/merge_requests/622>
2020-06-11 20:39:33 +03:00
Mathieu Duponchelle
f63299ff2f plugins: uddate gst_type_mark_as_plugin_api() calls 2020-06-06 00:42:25 +02:00
Mathieu Duponchelle
37c619f995 plugins: Use gst_type_mark_as_plugin_api() for all non-element plugin types 2020-06-03 22:44:09 -04:00
Nicolas Dufresne
3ea71a63f6 v4l2: videodec: Fix broken template caps
The profiles and levels were applied to the common caps instead of the copy.
That had the side effect of setting profiles/level from one CODEC onto
another. Leaving to encoder not being registered or not-negotiated errors.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/merge_requests/599>
2020-05-22 19:11:47 +00:00
Nicolas Dufresne
d93664d65d v4l2: codec: Fix GValue leak
The levels and profiles probe function returned a dynamically allocated GValue
that was leaked. Simplify this by using a stack allocated GValue and a boolean
return value.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/merge_requests/599>
2020-05-22 19:11:47 +00:00
Nicolas Dufresne
24e08553d6 v4l2codec: Remove uneeded factorisation
There is only one user of that function and the split only increase
complexicity.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/merge_requests/599>
2020-05-22 19:11:47 +00:00
Nicolas Dufresne
bfb1506381 v4l2src: Ignore non-increasing sequence number
With older kernel, older driver or just broken drivers, the sequence number
may not be increasing. This simply ignore the sequence in this case. This
would otherwise miss-leading large amount of lost frame being reported.

Fixes #729

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/merge_requests/598>
2020-05-20 21:35:06 +00:00
Nirbheek Chauhan
fbd4afc64c meson: Pass native: false to add_languages()
This is needed for cross-compiling without a build machine compiler
available. The option was added in 0.54, but we only need this in
Cerbero and it doesn't break older versions so it should be ok.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/merge_requests/589>
2020-05-13 19:25:33 +05:30
Nicolas Dufresne
8e3184a213 v4l2videodec: Increase internal bitstream pool size
This patch will now set the maximum of buffers to 32, allowing to grow the
pool for drivers that supports that and will respect the minimum buffers
reported by the driver. This was made to fix a stall with the virtio CODEC
driver.

Fixes #672
2020-04-15 20:19:48 +00:00
Nicolas Dufresne
6bf9f4bd77 v4l2bufferpool: request the maximum number of buffers for USERPTR
This is to match what we now do for DMABuf importation.
2020-04-08 16:37:30 +00:00
Michael Olbrich
94e323c10f v4l2bufferpool: request the maximum number of buffers for DMABUF
There are often only two buffers queued in the kernel so no new buffers are
requested.

With every qbuf, the kernel receives a new DMABUF for the specified index.
This most likely differs from the last DMABUF and the old cached entry is
released. This results in a lot of map/unmap overhead if the kernel driver
needs a mapping for the buffer.

With a larger queue, it's quite likely, that both old and new DMABUFs are
also mapped for another index. So the map/unmap is skipped, because the
mapping is reference counted.

The corresponding allocated buffers don't contain any actual memory, so
allocating them is quite cheep. So the log message is updated to clarify
this.
2020-04-08 16:37:30 +00:00
Guillaume Desmottes
d1501f0952 v4l2: add alternate interlace mode
When using this mode each frame is split in two fields, each one being
transferred using its own buffer.
This is implemented with the V4L2_FIELD_ALTERNATE field format in v4l2.

This mode is enabled using a caps filter such as
"v4l2src ! video/x-raw\(format:Interlaced\)"

Here are the main changes related to this feature:

- use the INTERLACED caps feature with this mode.

- in this mode both fields of a given frame have the same sequence/offset
so adjust the algorithm checking for lost field/frame accordingly.

- double pool's min number of buffers as each frame requires 2 buffers.

Fix #504
Co-authored-by: Zeeshan Ali <zeenix@collabora.co.uk>
2020-03-25 12:42:12 +01:00
Guillaume Desmottes
0834ef15ce v4l2: display field when setting or trying format
Ease debugging interlacing pipelines.
2020-03-25 12:14:41 +01:00
Guillaume Desmottes
8a69e26f16 v4l2: pass v4l2object to GST_V4L2_MIN_BUFFERS()
Will be used to double the number of buffers in alternate interlace
mode.
2020-03-25 12:14:41 +01:00
Guillaume Desmottes
00893baef9 v4l2: use GST_VIDEO_INFO_FIELD_HEIGHT()
Use GST_VIDEO_INFO_FIELD_HEIGHT() instead of GST_VIDEO_INFO_HEIGHT()
when we actually want the field height rather than the frame height.
So far both are equals but that won't longer be the case when
implementing alternate interlace mode.
2020-03-25 12:14:41 +01:00
Seungha Yang
b0f4831481 v4l2bufferpool: Use unique name for v4l2bufferpool object
Assign unique sequence number to an object name for better debugging
2020-03-23 17:48:19 +00:00
Gordon Hart
05e8dd42e7 v4l2src: decrease gst_v4l2src_create log verbosity
Lower the verbosity of the 'sync' log message emitted
each buffer from gst_v4l2src_create down to LOG(6)
from INFO(4). This brings the logging behavior of
v4l2src closer to the GStreamer guidelines, which
recommend the INFO level be reserved for rare or
one-off messages.
2020-03-10 20:33:04 +00:00
Guillaume Desmottes
48a7381602 v4l2: map GST_VIDEO_FORMAT_BGR15
The GstVideoFormat to v4l2 conversion was missing for BGR15.
2020-02-05 18:22:20 +05:30
Guillaume Desmottes
0f907205de v4l2: fix crash on invalid caps
gst_v4l2_object_set_format_full() was returning FALSE without setting
an error. Caller code (gst_v4l2src_fixate()) was then derefing a
NULL pointer when trying to handle the error.
2020-02-05 18:22:20 +05:30
Stéphane Cerveau
b928517f1e good: use of g_value_dup_string
Use helper method to get string from GValue.
2019-12-20 09:30:26 +00:00
Olivier Crête
f66fc2a694 osxaudio: Remove deprecated GTimeVal 2019-12-18 19:48:34 +00:00
Nicolas Dufresne
3bd544418c v4l2bufferpool: Queue number of allocated buffers to capture
Before we do streamon, we queue all capture buffers by calling
resurrect. When the driver supports CREATE_BUFS, this would lead
to buffers being allocated till the maximum of 32 is reached.

Instead, we now save the number of allocated buffers and queue this
amount.
2019-11-20 11:03:19 -05:00
Nicolas Dufresne
23089e9cc3 v4l2object: Workaround bad TRY_FMT colorimetry implementation
libv4l2 reset the colorpace to 0 and does not do any request to the
driver. This yields an invalid colorspace which currently cause a
negotiation failure. This workaround by ignoring bad values during the
TRY_FMT step.
2019-11-18 18:29:48 +00:00
Niels De Graef
7cf4ab6229 Don't pass default GLib marshallers for signals
By passing `NULL` to `g_signal_new` instead of a marshaller, GLib will
actually internally optimize the signal (if the marshaller is available
in GLib itself) by also setting the valist marshaller. This makes the
signal emission a bit more performant than the regular marshalling,
which still needs to box into `GValue` and call libffi in case of a
generic marshaller.

Note that for custom marshallers, one would use
`g_signal_set_va_marshaller()` with the valist marshaller instead.
2019-11-17 15:32:30 +00:00
Guillaume Desmottes
e9c10713a3 v4l2object: update match_buffer_layout() debug messages
It's no longer used only to try importing buffers.
2019-11-05 14:54:40 +05:30
Guillaume Desmottes
91002389b9 v4l2object: try matching buffer layout from downstream
Ask v4l2 to produce buffers matching the buffer layout requested
downstream.
2019-11-05 14:54:40 +05:30
Guillaume Desmottes
31c753a3fb v4l2object: factor out gst_v4l2_object_match_buffer_layout()
No semantic change.
2019-11-05 14:52:22 +05:30
Guillaume Desmottes
a195d5a4a6 v4l2transform: use alignments from upstream when importing on sink
Try configuring the v4l2 output with the alignments from upstream when
importing its buffers. This allows us to support importing with
non-standard strides and/or heights if supported by the driver.
2019-11-02 12:47:43 +01:00
Guillaume Desmottes
a92000ebb9 v4l2object: add support for vertical padding when importing buffers
We were already supporting horizontal padding by setting bytesperline to
the buffer stride but not vertical one.

We are now updating the format height with the padded height and crop to
the actual video resolution if needed.
2019-11-02 12:47:43 +01:00
Guillaume Desmottes
07930aea73 v4l2object: fix debug message if driver rejects stride
The 'want' and 'got' strides were inversed.
2019-11-02 12:47:43 +01:00
Guillaume Desmottes
3a05ef4798 v4l2: improve logs when importing buffers
Log strides and offsets from upstream.

Also fix a typo.
2019-11-02 12:47:43 +01:00
James Cowgill
51b83d5ca1 v4l2videodec: ensure pool exists before orphaning it
In commit e2ff87732d ("v4l2videodec: support orphaning") support for
orphaning the capture buffer pool was added when the format is
renegotiated. However, the commit forgot to check that a pool existed
before doing this. This is needed because it's possible for the format
to be renegotiated before a capture pool is allocated, which would
result in trying to orphan a NULL pool and lead to a NULL pointer
dereference.

Fix this by checking a pool exists first. If the pool doesn't exist,
there are no buffers to be reclaimed, so skip the allocation query in
that case.
2019-10-29 14:46:22 +00:00
Edward Hervey
8e1c224fbc good: Avoid usage of deprecated API
GTimeval and related functions are now deprecated in glib.
Replacement APIs have been present since 2.26
2019-10-16 07:46:58 +00:00
Javier Celaya
3f21c89bb0 osxaudio: misspelled dependency
When building osxaudio, the required 'AudioToolbox' dependency is
misspelled as 'AudioToolBox', which crashes the build with error:
ld: framework not found AudioToolBox
2019-10-14 15:33:30 +00:00
Tim-Philipp Müller
c9a47c0c8d Remove autotools build system 2019-10-14 11:04:18 +01:00
Tim-Philipp Müller
6e8e3910d3 v4l2videoenc: fix wrong type cast
Follow-up to commit 1b752c0f !361
2019-10-13 12:46:58 +01:00
HuQian
9dcb626e3a is a typo here? gstv4l2object.c 2019-10-12 15:26:40 +00:00
Kevin Song
9d42b2dd5d v4l2videodec: Check stop in flush() to avoid race condition.
Backward playback will drain and flush every frame. Stop playback
when backward playback have race condition between exit thread and
streaming thread flush. Add one check to avoid it.

Fixes #639
2019-10-11 12:27:12 +00:00
Fuwei Tang
1b752c0fa8 v4l2videoenc: fix type conversion errors 2019-10-11 10:45:58 +08:00
Aaron Boxer
46989dca96 documentation: fix a number of typos 2019-10-05 22:38:11 +00:00
Philipp Zabel
5c8d8723d2 v4l2: Add MPEG-2 profile and level support
Add support for V4L2 MPEG-2 decoders reporting supported profiles and
levels.
2019-09-27 08:47:20 +02:00
Philipp Zabel
2b1658fca2 v4l2object: add support for ABGR, xBGR, RGBA, and RGBx formats
Map them to the new V4L2_PIX_FMT_{BGRA32,BGRX32,RGBA32,RGBX32} pixel
formats.
2019-09-25 10:44:13 +02:00
Philipp Zabel
06a084d70c v4l2: update kernel headers to latest from media tree
Update to the latest installed headers (output of make headers_install)
from the media tree, keeping the slight modifications to the includes.

This includes typo fixes in enum v4l2_mpeg_video_multi_slice_mode,
MPEG-2 level and profile enums, new FWHT and H.264 Qp controls, new
RGB(A) formats, and new continuous bytestream and dynamic resolution
format flags.
2019-09-25 10:44:13 +02:00
Matthew Waters
b0522aa8f7 osxvideosink: call superclass in reshape
Fixes macos werror build

../sys/osxvideo/cocoawindow.m:437:1: error: method possibly missing a [super reshape] call [-Werror,-Wobjc-missing-super-calls]
}
^
2019-08-30 14:12:29 +10:00
Nicolas Dufresne
45b6514f33 v4l2: Fix type compatibility issue with glibc 2.30
From now on, we will use linux/types.h on Linux, and use typedef of the
various flavour of BSD.

Fixes #635
2019-08-10 11:01:26 +01:00
Seungha Yang
dbb4849a32 v4l2: Remove misleading comments
gst_pad_template_new() does not take ownership of the caps
2019-07-09 19:51:20 +09:00
Song Bing
c74a5d870d v4l2transform: set right buffer count.
Set right buffer count to avoid one buffer.
2019-07-04 17:37:30 +00:00
Song Bing
f49d610ebe v4l2videodec: Fix drain() function return type
Return right type for drain() function.
2019-06-24 14:43:21 +00:00
Tim-Philipp Müller
92e4ecef4c v4l2: fix compiler warning due to c99-ism 2019-06-24 09:42:31 +00:00
Philippe Normand
4fb749d99f v4l2: Fix H.264 level 3 string representation
The string_to_level function handles "3" so the level_to_string function should
do the same, to prevent caps negotiation issues.
2019-06-05 10:23:40 +01:00
Philippe Normand
6ce195e9d1 v4l2: Profile and level probing support for encoders and decoders
There used to be some profile/level support in encoders. This code was moved to
GstV4l2Codecs and is now also used for decoders. The caps templates for the
H.264, H.265, MPEG4, VP8 and VP9 encoders and decoders should now reflect the
profiles and levels advertised by the kernel.
2019-06-05 10:23:40 +01:00
Damian Hobson-Garcia
a493bcd549 v4l2object: Orphan buffer pool on object_stop if supported
Use V4L2 buffer orphaning, on recent kernels so that
the device can be restarted immediately with
a new buffer pool during renogatiation.
2019-06-03 19:09:24 +00:00
Damian Hobson-Garcia
50dfbf1c0d v4l2bufferpool: Free orphaned allocator resources when buffers are released
Allocator resources cannot be freed when a buffer pool is orphaned
while its buffers are in use. They should, however, be freed once those
buffers are no longer needed. This patch disposes of any buffers
belonging to an orphaned pool as they are released, and makes sure
that the allocator is cleaned up when the last buffer is returned.
2019-06-03 19:09:24 +00:00
Damian Hobson-Garcia
1b9a0f1c2d v4l2bufferpool: return TRUE when buffer pool orphaning succeeds
When trying to orphan a buffer pool, successfully return and unref
the pool when the pool is either successfully stopped or orphaned.
Indicate failure and leave the pool untouched otherwise.
2019-06-03 19:09:24 +00:00
Mathieu Duponchelle
f554369ed5 doc: remove xml from comments 2019-05-29 22:20:40 +02:00
Tim-Philipp Müller
bf14759477 dv, gtk, qt, osxaudio, osxvideo, waveform: add to plugins list
Makes sure the paths for these plugins are included in the
uninstalled plugin paths list. And also for the docs.

Fixes #604
2019-05-29 14:56:37 +00:00
Thibault Saunier
38c5ba90b3 doc: Fix some docstrings 2019-05-13 17:00:00 -04:00
Thibault Saunier
af01988534 doc: Port documentation to hotdoc 2019-05-13 11:34:56 -04:00
Thibault Saunier
0a6a62aa76 docs: Port all docstring to gtk-doc markdown 2019-05-13 10:24:40 -04:00
Guillaume Desmottes
443c16e1e3 v4l2: fix use after free when handling events
The sink_event parent function may consume the event so we shouldn't use
it after having calling it.
2019-04-16 14:53:15 +05:30
Dan Kegel
dfe1f6d803 osxvideo: fix mac os 10.14 build
lockFocusIfCanDraw is deprecated in mac os 10.14.  Apple suggests a
different way to do what that does, but for now, just suppress the deprecation.

There's no way to disable just that deprecation, so shut them all down.

OpenGL is also deprecated in mac os 10.14.  There is a gentle way to
turn off just those deprecations (GL_SILENCE_DEPRECATION), but since
this commit turns them all off, that's moot.

https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/issues/577
2019-04-08 16:27:13 -07:00
Philipp Zabel
603c7a52fd v4l2: remove __user define from types-compat.h
Remove the now unused __user define.
2019-04-05 16:01:55 +00:00
Philipp Zabel
40db843efd v4l2object: use opRGB colorspace and xfer func defines
AdobeRGB defines have been renamed to opRGB in the kernel headers,
use the new names.
2019-04-05 16:01:55 +00:00
Philipp Zabel
e2ff87732d v4l2videodec: support orphaning
Recent kernels allow REQBUFS(0) on a queue that still has buffers in
use (mmapped or exported via dmabuf), orphaning all buffers on the queue.
If this is supported, the v4l2videodec element does not have to send a
drain request downstream.
2019-04-05 16:01:55 +00:00
Philipp Zabel
dfc20013cc v4l2bufferpool: support orphaning
Now that the v4l2allocator allows orphaning the V4L2 buffer queue, add
support for orphaning in the v4l2bufferpool. gst_v4l2_buffer_pool_orphan
can be used as a replacement for gst_v4l2_buffer_pool_stop, without
having to wait for buffers to be returned to the pool.
2019-04-05 16:01:55 +00:00
Philipp Zabel
0948ce0478 v4l2allocator: support orphaning
Recent kernels allow REQBUFS(0) on a queue that still has buffers in
use (mmapped or exported via dmabuf), orphaning all buffers on the queue.

Orphaning the allocator causes it to release all buffers with
REQBUFS(0), even if they are still in use. An orphaned allocator can
only be stopped. It can not be restarted or create new buffers.
2019-04-05 16:01:55 +00:00
Philipp Zabel
5d904530c1 v4l2: update kernel headers to latest from media tree
Update to the latest installed headers (output of make headers_install)
from the media tree, keeping the slight modifications to the includes.

This includes new HEVC controls, the AdobeRGB -> opRGB rename, a new
capabilities field for v4l2_requestbuffers and v4l2_create_buffers, new
32-bit YUV formats, and request_fd changes.
2019-04-05 16:01:55 +00:00
Guillaume Desmottes
e3c4b80750 v4l2src: preserve features when fixating caps
The caps features were lost when sorting caps structures in
gst_v4l2src_fixate(). This was breaking alternate as
GST_CAPS_FEATURE_FORMAT_INTERLACED was removed from the caps.
2019-04-05 13:22:58 +00:00
Philipp Zabel
16e5b32bc1 v4l2videoenc: set GstVideoCodecFrame sync point flag
The V4L2 elements already set the delta unit buffer flag when dequeueing
the buffer, but gst_video_encoder_finish_frame overwrites it from the
passed codec frame's sync point flag. Set the flag correctly.
2019-03-21 18:05:51 +00:00
Philippe Normand
75f26bc954 v4l2: Set Hardware classifier on encoders 2019-03-18 10:51:15 +00:00
Philippe Normand
3296a4b7e2 v4l2: Set Hardware classifier on video decoders 2019-03-18 10:51:07 +00:00
Philipp Zabel
cdf15e9032 v4l2transform: don't segfault if flushed without pools
The v4l2output and v4l2capture v4l2objects can have pool == NULL if they
have been stopped before.
2019-03-17 13:17:21 +00:00
Philipp Zabel
8b068fb78b v4l2sink: fix pool-less allocation query handling
This fixes a critical warning if the last-sample property is enabled:

  (gst-launch-1.0:391): GStreamer-CRITICAL **: 01:12:57.428: gst_object_unref: assertion 'object != NULL' failed

If the allocation query does not contain any allocation pools,
gst_query_parse_nth_allocation_pool will leave the local pool,
min, and max variables undefined, so check the array length first.
If pool is NULL, do not call gst_object_unref.
2019-03-08 22:01:14 +01:00
Mauro Carvalho Chehab
dc7bd48326 v4l2: accept Bayer as possible input/output for V4L2 codecs
A V4L2 transform codec may input/output data on Bayer format.

Add support for that.
2019-02-26 13:59:46 +00:00
Mauro Carvalho Chehab
55c1274dba v4l2: fix a typo on a debug message at v4l2_calls
suppored -> supported
2019-02-26 13:59:46 +00:00
Matthew Waters
0acbf40060 v4l2dec: also remove the colorimetry and chroma-site fields
If a different format is chosen, then these values are incorrect.
2019-02-26 07:04:54 +00:00
Tim-Philipp Müller
64a991d7b8 meson: ximage: check for XShmAttach()
Fixes FIXME.
2019-01-22 09:52:14 +00:00
Tim-Philipp Müller
e234932dc7 meson: add options for ximagesrc xshm, xfixes, xdamage checks
And rename x11 option to ximagesrc.

Fixes #553
2019-01-22 09:52:03 +00:00
Guillaume Desmottes
e7b84b0f6c v4l2: mark caps from probe as MAY_BE_LEAKED 2019-01-17 15:05:45 +00:00
Guillaume Desmottes
bb2063f632 v4l2transform: fix cdata caps leaks
The cdata structure was freed but not its caps.
It was already done in gst_v4l2_video_dec_subclass_init() and
gst_v4l2_video_enc_subclass_init().
2019-01-17 15:05:45 +00:00
Guillaume Desmottes
dab84b14dd v4l2: Avoid code duplication
The function gst_v4l2_object_add_interlace_mode() has repeating code so
it's best use a loop instead. That will make it easy and simple to add
additional interlace modes in a following patch.
2018-12-17 15:30:47 +00:00
Zeeshan Ali
40fee8eeeb v4l2: Make use of gst_video_interlace_mode_to_string()
Instead of a custom map to translate the interlace modes to strings, let's
make use of the base API provided.
2018-12-17 15:30:47 +00:00
Nicola Murino
6525abfc63 osxcoreaudio: fix typo
kAudioFormatFlagIsSignedInteger is a format flags

Closes #394
2018-12-17 13:45:36 +01:00
Justin Kim
34233baae1 osxvideo: meson: Add dependencies by using appleframeworks
Otherwise, it fails to link.

gst-build#13
2018-12-14 12:21:58 +09:00
Maciej Wolny
ec655de288 Remove duplicate declarations
This causes 'redefinition of typedef ...' errors on GCC 4.5.3
2018-12-04 11:13:02 +00:00
Jordan Petridis
515ada7e22
Run gst-indent through the files
This is required before we enabled an indent test in the CI.

https://gitlab.freedesktop.org/gstreamer/gstreamer-project/issues/33
2018-11-28 05:52:16 +02:00
Nicolas Dufresne
3b22a604b5 v4l2: Properly fix Android build
The previous patch did not even compile on any possible platform or C
standard. That commit also didn't have a proper commit message.

Android ships Linux with a different signature for ioctl. They first
released an ioctl with int as request type, and later "fixed" it by
adding an override with unsign, which is still not matching Linux and
BSD implementation which uses unsigned long int.
2018-11-21 18:58:38 -05:00
Xavier Claessens
0e2d0adac5 Fix ioctl() signature on Android 2018-11-21 16:11:02 -05:00
Nicolas Dufresne
dbaca549ab v4l2object: Read driver selected interlace mode
If there was no interlace-mode field in the caps. Read back the value
selected by the driver. This way, if the driver does not support
progressive, then it will automatically negotiate the returned mode
unless this mode is not supported by GStreamer.

This method was already used for colorimetry. Just like colorimetry, the
interlace mode is not longer probed by v4l2src dues to performance
issues.

Fixes #511
2018-11-07 19:29:51 -05:00
Wonchul Lee
560a6155bd v4l2bufferpool: fix typo resurect to resurrect
https://bugzilla.gnome.org/show_bug.cgi?id=797273
2018-10-24 12:03:13 +01:00
Amit Pandya
15429ee411 v4l2videoenc: Add HEVC support
Add HEVC encoder support.

https://bugzilla.gnome.org/show_bug.cgi?id=797141
2018-10-24 12:01:59 +01:00
Nicolas Dufresne
f2fa61b6c5 vl42allocator: Don't dup exported dmabufs
We can now use the new GstFAllocator to ask the allocator not to close
the wrapped FD. This way the dup is no longer needed.
2018-10-24 11:55:32 +01:00
Nicolas Dufresne
b25a01fab9 v4l2allocator: Don't dup imported DMABuf FD
There is no specific needs to duplicate the FD. Unlike the exportation,
we don't depend on code that will call close. This will make debugging
easyer since the traced FD will match the exporter.
2018-10-24 11:55:32 +01:00
Nicola Murino
3573f71c91 osxaudio: add support for parsing more channel layouts ...
... and fallback to gst_audio_info_set_format for not yet supported layouts.

Fix audio playback on iOS 12.
Based on patch from Byron Schiel <byron@canary.is>

https://bugzilla.gnome.org/show_bug.cgi?id=796919
2018-09-24 15:50:23 +03:00
Song Bing
1dc6881a13 v4l2videodec: Add HEVC decoder support
https://bugzilla.gnome.org/show_bug.cgi?id=771686
2018-09-13 20:48:09 -04:00
Nicolas Dufresne
2510b5937d v4l2videodec: Move capture probe after input format is set
This is to support Amlogic CODEC driver which does not provide a full
list of formats when the driver is initially opened. GStreamer does
not strictly need this full list initially, but only later, in order
to negotiate with downstream if multiple format can be selected.

With this change, we will no longer probe twice the device, since the
probed list can be directly used for negotation.
2018-09-13 20:48:09 -04:00
Ezequiel Garcia
7f42b12e8c v4l2: Add a debug message beforing waiting for codec stop
Add a debug message right before waiting for the driver.
This is useful in order to debug drivers without a properly
implemented decoder or encoder stop command.
2018-09-13 20:48:09 -04:00
Ezequiel Garcia
09f9b37b0b v4l2: Add a debug message indicating probe operation
It's useful to see the v4l2 element running the probe
operation, to confirm it's turned on and working.
2018-09-13 20:48:09 -04:00
Ezequiel Garcia
63535d9086 v4l2: Add JPEG encoding support
This commit adds the support for V4L JPEG stateful encoders.
2018-09-13 20:48:09 -04:00
Ezequiel Garcia
944debd3db v4l2: Add FWHT codec support
The recently added vicodec (virtual codec) V4L driver
uses the Fast Walsh-Hadamard Transform for encoding
and decoding.

Add support for it.
2018-09-13 20:48:09 -04:00
Nicolas Dufresne
6e1ad47db1 v4l2: Sync kernel header with linuxtv tree
This notably add HEVC and FWHT support, and VP8/9 profiles are now an
enumeration and their control exposed as a menu.
2018-09-13 20:48:09 -04:00
Nicolas Dufresne
43c5db3c72 v4l2object: Fix indentation 2018-09-12 20:49:41 -04:00
Nicolas Dufresne
4d0f5f056e v4l2object: Protect against zero PAR num/demu
This fixes an assertion when the driver implement CROPCAP but does
not set the PAR.
2018-09-12 20:49:41 -04:00
Nirbheek Chauhan
5ca7a02371 meson: Fix osxaudio build on iOS
Must define HAVE_IOS, and use appleframeworks dependency to ensure the
right frameworks are picked up.
2018-09-01 09:30:23 +05:30
Nicolas Dufresne
66351255f7 v4l2object: Only offer MMAP/DMABUF pool
The propose allocation was offering a pool even in DMABUF_IMPORT or
USERPTR mode. These pool are internal only.
2018-08-31 15:44:02 -04:00
Nicolas Dufresne
fe5236be87 v4l2transform: Add "disable-passthrough" property
This allow forcing going through the transform driver even if there
isn't an conversion happening. This is usedful when the m2m driver can
be used to adapt the type of memory between two drivers.
2018-08-31 15:43:53 -04:00
Nicolas Dufresne
480a7bcab8 v4l2bufferpool: Validate stride/offset when importing
This will prevent situation where buffer size allow importing but rendering
goes wrong due to a miss-match in expected stride and offset.

https://bugzilla.gnome.org/show_bug.cgi?id=583890
2018-08-27 13:41:30 -04:00
Nicolas Dufresne
1c729be537 v4l2object: Add a method to try and import buffers
This method will check if a buffer, base on it's video meta,
can be imported. It will also try and adapt the request stride
in case this is the only that miss-match.

https://bugzilla.gnome.org/show_bug.cgi?id=583890
2018-08-27 13:41:30 -04:00
Nicolas Dufresne
d6d8187345 v4l2allocator: Trace the buffer index we import to
https://bugzilla.gnome.org/show_bug.cgi?id=583890
2018-08-27 13:41:30 -04:00
Nicolas Dufresne
73555b5440 v4l2bufferpool: Fix typo in error message
https://bugzilla.gnome.org/show_bug.cgi?id=583890
2018-08-27 13:41:30 -04:00
Nicolas Dufresne
77c052f0e8 v4l2bufferpool: Only queue buffer if preparation worked
The preparation code imports the buffer, doing bunch of
validation. Only queue the buffer in the driver if the
importation worked. This way we don't rely on the driver
to validate.

https://bugzilla.gnome.org/show_bug.cgi?id=583890
2018-08-27 13:41:30 -04:00
Nicolas Dufresne
24368c1162 v4l2object: Only allow DMABuf export for STREAMING device
DMABuf exportation requires mmap, which requires STREAMING
capabilities.

https://bugzilla.gnome.org/show_bug.cgi?id=583890
2018-08-27 13:41:30 -04:00
Nicolas Dufresne
90a70e08b7 v4l2bufferpool: Activate the other pool first
This change has no effect. We will need to acquire a buffer from the
pool later in order to validate / adapt with the video alignment for
the downstream buffers.

https://bugzilla.gnome.org/show_bug.cgi?id=583890
2018-08-27 13:41:30 -04:00
Nicolas Dufresne
fe3a70fefd v4l2src: Simplify format handling
Always initially use try_format(), delaying set_format() to when the
allocation is being negotiated. This avoid having two code paths, and
will be help adding support for properly importing buffers of specific
strides and offsets.

https://bugzilla.gnome.org/show_bug.cgi?id=583890
2018-08-27 13:41:30 -04:00
Philipp Zabel
00143ca554 v4l2object: complete colorspace info in debug log
The desired colorimetry is logged with all parameters (colorpsace,
range, matrix, and transfer function), but of the values actually
set by the driver, only colorspace is logged. Complete the debug
log message to display all colorimetry parameters:

  Desired colorspace is 8:1:1:1
  Got format of 640x480, format YU12, nb planes 1, colorspace 8

->

  Desired colorspace is 8:1:1:1
  Got format of 640x480, format YU12, nb planes 1, colorspace 8:0:0:0

https://bugzilla.gnome.org/show_bug.cgi?id=796940
2018-08-21 12:01:41 -04:00
Philipp Zabel
91dd9c1929 v4l2object: fix typo in comment
https://bugzilla.gnome.org/show_bug.cgi?id=796940
2018-08-21 12:01:41 -04:00
Philipp Zabel
02d3f9748b v4l2object: improve colorspace handling for JPEG sources
gstjpegdec sets 1:4:0:0 colorimetry (full range BT.601 YCbCr encoding
with unknown primaries and unknown transfer function). This currently
gets translated to bt601 or bt709 depending on resolution.
Both cases result in a negotiation failure:

    ERROR: from element /GstPipeline:pipeline0/v4l2video0convert:v4l2video0convert0: Device '/dev/video0' does not support 1:4:0:0 colorimetry

Improve the guessing game by selecting JPEG colorimetry (JPEG colorspace
with sRGB transfer function) under these specific conditions, and loosen
the matching so that 1:4:0:0 input gets accepted if the device is
actually configured to 1:4:7:1 (V4L2_PIX_FMT_JPEG default).

https://bugzilla.gnome.org/show_bug.cgi?id=796940
2018-08-21 12:01:41 -04:00
Philipp Zabel
9595fd08e3 v4l2object: stop V4L2 from zeroing extended colorimetry for non-mplane
Setting the priv field to a magic value stops V4L2 core from zeroing
the extended colorimetry fields quantization, ycbcr_enc, and xfer_func
for non-mplane queues.

https://bugzilla.gnome.org/show_bug.cgi?id=796940
2018-08-21 12:01:41 -04:00
Zeeshan Ali
af27ecae3f v4l2: Remove a trailing whitespace
Otherwise, the latest gst-indent check doesn't pass.
2018-08-19 15:39:16 +02:00
Nirbheek Chauhan
b7e78d84b4 meson: Add build files for osxaudio, osxvideo, waveform
osxaudio is for macOS and iOS
osxvideo is for macOS
waveform is for Windows
2018-08-17 20:05:25 +05:30
Iñigo Huguet
3f360e8f15 v4l2src: fix first input used is always used next times
The input from an v4l2 device that was used the first time was
remembered for next times, and set again always the pipeline is
set to READY state. This was making that users wasn't able to
select a different input without having to create a new pipeline.

This patch makes that v4l2src element forget previous used input
when going to NULL state, so it will check again for the current
selected input when going again to READY state. Users can change
to NULL state, select a new input with a VIDIOC_S_INPUT ioctl
and change to PLAYING again.

https://bugzilla.gnome.org/show_bug.cgi?id=796908
2018-08-02 08:00:44 -04:00
Nirbheek Chauhan
248342f942 meson: Fix oss4 header checks
Otherwise, oss4 ends up getting built when force-disabled.
2018-08-01 03:18:58 +05:30
Nirbheek Chauhan
1c645f83f6 meson: Fix missing variable in v4l2 build 2018-08-01 01:11:05 +05:30
Nirbheek Chauhan
8f807477eb meson: Add feature options for all plugins
Checks for GL, Qt5, and C++ are still automagic. FIXMEs have been
added for these so they can be fixed later.

https://bugzilla.gnome.org/show_bug.cgi?id=795107
2018-07-27 18:42:54 +05:30
Nicolas Dufresne
9e79821b1d v4l2bufferpool: Validate that capture buffers were queued
When the pool is started, we allocate and release buffer, expecting
the pool release-buffer handler to queue them. Though, as we rely
on release function, there is no direct way to detect that this
process didn't work.

To check this, validate that the number of queued buffer is the same
as the number of allocated buffers. This allow returning an error
when buffer importation was refused by the driver.

https://bugzilla.gnome.org/show_bug.cgi?id=583890
2018-07-13 23:13:44 -04:00
Nicolas Dufresne
3b364cea94 v4l2bufferpool: Only return eos for M2M devices
This will avoid sending EOS on v4l2src when a driver sends an empty
buffers. This case would be a bug in the driver, but yet the camera
should keep running.

This also removes the check for corrupted buffers, as this check is
already done later.

https://bugzilla.gnome.org/show_bug.cgi?id=794842
2018-07-13 22:58:57 -04:00
Nicolas Dufresne
3735e57fb2 v4l2: Add a macro to check for M2M
https://bugzilla.gnome.org/show_bug.cgi?id=794842
2018-07-13 22:58:57 -04:00
Nicolas Dufresne
0649b0ab0f v4l2allocator: Fix userptr importation
The length passed to the driver was always 0 instead of the size of
the memory. This would fail validation in videobuf2.
2018-07-13 22:58:35 -04:00
Nicolas Dufresne
38b68cbbd7 v4l2bufferpool: Remove duplicate check
We were calling gst_v4l2_is_buffer_valid() before and inside
gst_v4l2_buffer_pool_qbuf() as we needed to access the group. The second
check failed since the writability of the buffer get inherited from the
GstMemory, which lead to pipeline failure. As we cannot avoid the extra
ref, it would be racy otherwise, just pass the group to _dbuf() so it
does not have to call gst_v4l2_is_buffer_valid() again.

https://bugzilla.gnome.org/show_bug.cgi?id=796692
2018-07-12 15:17:44 -04:00
Nicolas Dufresne
b12b8b0b22 v4l2src: Try to avoid TRY_FMT when camera is streaming
Some camera firmware crash is TRY_FMT is called during streaming. As a
side effect. This try and detect that the same format as currently
running is about to be tried, and skip renegotiation.

https://bugzilla.gnome.org/show_bug.cgi?id=796789
2018-07-11 19:05:00 -04:00
Nicolas Dufresne
c87f9eb37b v4l2videodec: Protect double calls to set_format()
In some cases, set_format() may get called twice before the output
format is set. Running an allocation query in this case is both not
needed and will cause assertion due tot he NULL caps.
2018-07-09 14:01:00 -04:00
Michael Tretter
442c377b87 v4l2transform: Implement stable element name
The first converter to be found will now gain the name v4l2convert.
Other converters will be named after the m2m dev node end point they are
attached to.

https://bugzilla.gnome.org/show_bug.cgi?id=784958
2018-07-01 15:45:53 -04:00
Nicolas Dufresne
6704fbb044 v4l2videoenc: Only renegotiate with upstream
When the decoder get linked further, it will receive a renegotiation
event from downstream. This case is not supported and should be ignored.

This fixes issues when this encoder is used inside an GstRtspServer
pipeline.

https://bugzilla.gnome.org/show_bug.cgi?id=796525
2018-06-29 10:39:04 -04:00
Peter Seiderer
8ab3b91a8b v4l2transform: fold property set/get PROP_OUTPUT_IO_MODE case into default
https://bugzilla.gnome.org/show_bug.cgi?id=796714
2018-06-28 16:50:28 -04:00
Nicolas Dufresne
5fc67b248b v4l2videoenc: Don't set colorimetry on capture
The colorimetry will be set along with the raw format and those fields
will then be copied from sink to src caps by the gst encoder.

https://bugzilla.gnome.org/show_bug.cgi?id=791471
2018-06-27 17:06:30 -04:00
Nicolas Dufresne
b677ae3cb6 v4l2object: Really always set colorimetry
This fixes patch dd1c5aed65 which
pretended to always set colorimetry but the patch was incomplete.
This is again best effort considering the spec says that for CAPTURE
you may only read this value.
2018-06-27 16:57:29 -04:00
Michael Tretter
35ab185d75 v4l2videodec: do not call streamon while pool is flushing
gst_v4l2_buffer_pool_flush() executes streamoff for the output, but
streamoff->streamon for the capture of the decoder.
gst_v4l2_buffer_pool_streamon() on capture assumes that is able to
resurrect the buffers from the pool, but acquiring buffers fails if the
buffer pool is still flushing.

The decoder needs to stop flushing the pools before calling
gst_v4l2_buffer_pool_flush() to restart the v4l2 device. Otherwise
starting the decoding thread might fail, because there are no buffers in
the capture pool.

This fixes a regression that was introduced in 97985a335c
("v4l2videodec: Add dynamic resolution change support").

https://bugzilla.gnome.org/show_bug.cgi?id=796681
2018-06-27 16:32:23 -04:00
Philipp Zabel
32fa1e7a65 v4l2object: use S_SELECTION instead of S_CROP in gst_v4l2_object_set_crop
The S_CROP call doesn't work on mem2mem output queues. Use the
S_SELECTION call to set the crop rectangle and only fall back to
S_CROP for ancient kernels.
This will allow v4l2videoenc to set the coded size on the output
queue via S_FMT and then set the visible size via the crop rectangle,
as required by the V4L2 codec API.

https://bugzilla.gnome.org/show_bug.cgi?id=796672
2018-06-27 16:31:39 -04:00
Marian Mihailescu
58e9341384 v4l2videoenc: activate capture pool after output pool
Some drivers need output buffers set before capture buffers.
CODA cannot set output format if capture is streaming.
Exynos MFC fails on output STREAMON if capture is already streaming.
This patch delays capture activation until output is configured and
streaming

https://bugzilla.gnome.org/show_bug.cgi?id=796693
2018-06-27 16:28:10 -04:00
Nicolas Dufresne
90eade28f2 v4l2bufferpool: Drop truncated frames
Drop truncated frames regardless if they have the ERROR flag or not.
Truncated frame causes video frame map failure in many elements
including cluttersink, glupload etc.
2018-06-07 15:26:32 -04:00
Nicolas Dufresne
e943a11bab v4l2bufferpool: Try return input buffer soon
In this patch we use a non-blocking poll in order to return all input
buffers (buffers from v4l2-output queue). This prevent holding too long
on upstreaming buffer in importing.

https://bugzilla.gnome.org/show_bug.cgi?id=794904
2018-06-07 15:26:32 -04:00
Nicolas Dufresne
f72c7131ae v4l2object: Don't open the device in get property
This is both racy and inefficient. This function is still missing some
locking which will be address in later patch.

https://bugzilla.gnome.org/show_bug.cgi?id=796185
2018-05-28 12:58:45 -04:00
Edward Hervey
e555596d48 v4l2: Fix typo in debug messages
It's a decoder, not an encoder :)

https://bugzilla.gnome.org/show_bug.cgi?id=795941
2018-05-12 08:04:03 +02:00
Nirbheek Chauhan
65536f25dd meson: Update option names to omit disable_ and with- prefixes
Also yield common options to the outer project (gst-build in our case)
so that they don't have to be set manually.
2018-05-05 20:31:01 +05:30
Guillaume Desmottes
2bbe877a6e v4l2: rely on gst_v4l2_dup() to set no_initial_format and keep_aspect
gst_v4l2_dup() will now take care of setting
v4l2capture->no_initial_format and keep_aspect instead of doing it
manually.

Fix a typo as keep_aspect was set twice on v4l2output but never on
v4l2capture.

https://bugzilla.gnome.org/show_bug.cgi?id=795028
2018-04-26 15:36:16 -04:00
Xavier Claessens
edd9c8f6b8 Meson: Generate pc file for all plugins in good
https://bugzilla.gnome.org/show_bug.cgi?id=794568
2018-04-25 11:07:06 +01:00
Whoopie
2d774554e9 v4l2object: Disable DMABuf for emulated formats
libv4l2 does not prevent exporting DMABuf even when emulated formats are
in use. As a side effect, userspace ends up with buffers of the original
formats which will cause issues.

https://bugzilla.gnome.org/show_bug.cgi?id=795097
2018-04-11 22:19:10 -04:00