Commit graph

2070 commits

Author SHA1 Message Date
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
Nicolas Dufresne ebf8a6d0c0 v4l2object: Only use BT2020_12 for BT2020 v4l2 colorspace
BT2020_12 is not represented in V4L2, so drivers providing full colority
for BT2020 will set V4L2_XFER_FUNC_709 transfer function. To fix the
issue, we bump this to BT2020_12 if the resoltion is 4K, but we should
only do that if the colorspace is BT2020 to start with, otherwise it's
not possible to use normal BT709 for 4K 8bit formats.
2018-04-11 22:19:10 -04:00
Nicolas Dufresne dd1c5aed65 v4l2object: Always set the colorimetry in S_FMT
So far we were only setting colorimetry for OUTPUT devices (v4l2sink or
m2m sink pad). This prevented selecting through caps negotiation the
colorimetry for CAPTURE devices (v4l2src or m2m src pad). This is rarely
selectable, but trying is harmless.
2018-04-11 22:19:10 -04:00
Seungha Yang c4d13683f6 v4l2: Fix unknown type name ‘off_t’ error
Fix following build error

gstv4l2object.h:197:17: error: unknown type name ‘off_t’
       gint fd,  off_t offset);
                 ^

https://bugzilla.gnome.org/show_bug.cgi?id=794533
2018-03-27 13:46:58 -04:00
Nirbheek Chauhan 13dd93aca1 meson: Add deviceprovider changes to directsoundsink
These were missed when they were added to Makefile.am
2018-03-10 19:00:12 +05:30
Nicolas Dufresne 7d4702e2fb v4l2: Fix support for 32bit mmap
https://bugzilla.gnome.org/show_bug.cgi?id=793103
2018-03-07 14:16:24 -05:00
Nirbheek Chauhan 3e5d92243b directsoundsink: Downgrade rank to match directsoundsrc in -bad
As stated in commit c2956036b8 in -bad,
the wasapi elements are now better than directsound, and should be
preferred if they are available.

For a later release, once the elements have more testing, we can
consider moving them to -good.
2018-03-01 15:41:37 +05:30
Tim-Philipp Müller 072c070e6c docs: remove pointless Since: 0.10.x markers 2018-02-15 00:58:38 +00:00
Jérôme Laheurte 891425d537 osxvideosink: fix build on macOS versions < 12.0
Use value instead of version macro when testing for mac OS version,
since the define for the newer version may not be defined when
compiling against older versions.

https://bugzilla.gnome.org/show_bug.cgi?id=788402
2018-02-08 15:49:59 +00:00
Sebastian Dröge 342d8403f3 directsoundsink: Add missing \ in multi-line #define 2018-01-25 21:22:10 +02:00
Sebastian Dröge b5364f94be directsoundsink: Add support for a DeviceProvider
https://bugzilla.gnome.org/show_bug.cgi?id=792782
2018-01-25 20:20:01 +02:00
Guillaume Desmottes f7e280bf0d v4l2: fix division by 0 for complex video formats
So complex video formats have 0 as pstride. Don't try to divide the
stride in such cases.

https://bugzilla.gnome.org/show_bug.cgi?id=792596
2018-01-17 13:32:58 -05:00
Guillaume Desmottes 3bbfd15047 v4l2: display stride and width values if stride is too small
https://bugzilla.gnome.org/show_bug.cgi?id=792596
2018-01-17 13:32:58 -05:00
Peter Seiderer d2f9040e1d v4l2videodec: add property set/get PROP_CAPTURE_IO_MODE error handling
https://bugzilla.gnome.org/show_bug.cgi?id=791841
2018-01-12 09:21:18 -05:00
Peter Seiderer 2cd772b97a v4l2videodec: fold property set/get PROP_OUTPUT_IO_MODE case into default
https://bugzilla.gnome.org/show_bug.cgi?id=791841
2018-01-12 09:21:18 -05:00
Peter Seiderer f579ece0fb v4l2videoenc: add property set/get PROP_CAPTURE_IO_MODE error handling
https://bugzilla.gnome.org/show_bug.cgi?id=791841
2018-01-12 09:21:18 -05:00
Peter Seiderer 5c0cf56193 v4l2videoenc: fold property set/get PROP_OUTPUT_IO_MODE case into default
https://bugzilla.gnome.org/show_bug.cgi?id=791841
2018-01-12 09:21:18 -05:00
Peter Seiderer 189822350b v4l2videoenc: fix capture-io-mode property get
https://bugzilla.gnome.org/show_bug.cgi?id=791841
2018-01-12 09:21:18 -05:00
Nicolas Dufresne 21b01acef1 v4l2src: Maintain downstream caps order
The g_list_insert_sorted() will behave like prepend when the compare
function returns 0. In our case, we want to maintain the order hence
append. This fixes this issue and improve the sorting algorithm to make
a 10x10 prefered over 10x200 with a preference of 10x8 (and similar
cases which was badly handled). This fixes generally fixes issue were a
sub-optimal format / size is picked.

https://bugzilla.gnome.org/show_bug.cgi?id=792435
2018-01-11 17:51:13 -05:00
Nicolas Dufresne b3afa0dc1d v4l2videoenc: Also re-enabled paused task
When we only run _finish(), the task is never stopped externally,
instead it's only paused from the inside. We still want to restart
it in this case.
2018-01-11 11:27:38 -05:00
Nicolas Dufresne d90b6ec459 v4l2videoenc: Call stop on object before renegotiation
Otherwise renegotiation fails as we are still streaming.

https://bugzilla.gnome.org/show_bug.cgi?id=791338
2018-01-08 17:20:52 -05:00
Nicolas Dufresne a46756bd56 v4l2videoenc: Remove dead code
gst_v4l2_object_stop() will free and nullify the pool, so the
following if will never be true.

https://bugzilla.gnome.org/show_bug.cgi?id=791338
2018-01-08 17:20:52 -05:00
Nicolas Dufresne 4aa5298f56 v4l2videoenc: Delay capture pool activation
This is support CODA driver which prevents setting the output format if
the capture is streaming.

https://bugzilla.gnome.org/show_bug.cgi?id=791338
2018-01-08 17:20:52 -05:00
Nicolas Dufresne 97985a335c v4l2videodec: Add dynamic resolution change support
This implements a "big hammer" reallocation method. We effectively
drain and stop both side of the decoder and restart. This though is
the most generic method. This change should enable on most drivers
adaptive streaming.

https://bugzilla.gnome.org/show_bug.cgi?id=752962
2018-01-08 17:16:22 -05:00
Nicolas Dufresne 4632f33334 v4l2deviceprovider: Don't do slow probes
This is problematic in the current design at it seriously slow down
startup of applications. As of now, no known application uses the
colorimetry and the interlace-modes for anything (the two fields that
won't be probed). So let's disable it, in the long term we'll try and
find a way to interact with the provider so applicaiton could opt-in
these slow probing methods for more advance configuration.
2017-12-22 10:30:49 -05:00
Nicolas Dufresne 80815c292a v4l2object: Don't redefine mmap64
On Linux, there exist a case where mmap64 is already a define to mmap,
so avoid the redefine warning here.
2017-12-22 10:30:49 -05:00
Ting-Wei Lan 4026211154 v4l2object: Don't use mmap64 if off_t is 64-bit
The difference between mmap and mmap64 is the type of 'offset' argument.
mmap64 always uses a 64-bit interger as offset, while mmap uses off_t,
whose size can vary on different operating systems or architectures.

However, not all operating systems support mmap64. Fortunately, although
FreeBSD only has mmap, its off_t is always 64-bit regardless of
architectures, so we can simply use mmap when sizeof(off_t) == 8.

https://bugzilla.gnome.org/show_bug.cgi?id=791779
2017-12-22 10:30:49 -05:00
Nicolas Dufresne 24f01944ee Revert "v4l2object: Use mmap64 to match libv4l2 signature"
This reverts commit b61bba4848.
2017-12-22 10:30:13 -05:00
Ting-Wei Lan 784348235a v4l2object: Check for mmap64 before using it
mmap64 is not available on FreeBSD.

https://bugzilla.gnome.org/show_bug.cgi?id=791779
2017-12-21 21:58:29 -05:00
Nicolas Dufresne e575e4eda8 v4l2object: Use a debug object for tracing
This way we can pass the pad name instead of the element for tracing
which helps identifying which v4l2object is used withing M2M element
like decoder, encoder and transform. For the reference, pads are name
<parent-name>:<pad-name>.
2017-12-13 14:42:25 -05:00
Philipp Zabel 5e05cadb17 v4l2videodec: Handle drivers that only round up height
Commit 1f31715c98 ("v4l2videodec: use visible size, not coded size,
for downstream negotiation filter") added support for removing the
padding obtained as the difference between width/height from G_FMT and
visible width/height from G_SELECTION from the probed caps obtained
via TRY_FMT.
This patch fixes the padding removal for drivers that only round up
height, but not width, to the padded frame size. This might happen
because horizontal padding can be handled by line stride (bytesperline),
but there is no such thing as plane stride in the V4L2 API for
single-buffer planar formats.

https://bugzilla.gnome.org/show_bug.cgi?id=791271
2017-12-06 14:01:02 -05:00
Florent Thiéry a315810640 v4l2object: Fix dmabuf support detection
This resulted in improper selection of dmabuf on unsupported drivers.
The checked ioctl errno was not correct.

https://bugzilla.gnome.org/show_bug.cgi?id=790940
2017-11-29 10:13:44 -05:00
Jan Alexander Steffens (heftig) 7e4bc6d418 v4l2deviceprovider: Ignore touch sensing devices
With GST_V4L2_USE_LIBV4L2=1, my laptop's touchpad shows up as a video
source device in gst-device-monitor, but attempting to stream from it
fails because the device doesn't actually support any video formats.

name  : Synaptics RMI4 Touch Sensor
class : Video/Source
caps  : video/x-raw, format=(string)I420, framerate=(fraction)[ 0/1, 2147483647/1 ], width=(int)0, height=(int)0, interlace-mode=(string)progressive, pixel-aspect-ratio=(fraction)1/1;
        video/x-raw, format=(string)YV12, framerate=(fraction)[ 0/1, 2147483647/1 ], width=(int)0, height=(int)0, interlace-mode=(string)progressive, pixel-aspect-ratio=(fraction)1/1;
        video/x-raw, format=(string)BGR, framerate=(fraction)[ 0/1, 2147483647/1 ], width=(int)0, height=(int)0, interlace-mode=(string)progressive, pixel-aspect-ratio=(fraction)1/1;
        video/x-raw, format=(string)RGB, framerate=(fraction)[ 0/1, 2147483647/1 ], width=(int)0, height=(int)0, interlace-mode=(string)progressive, pixel-aspect-ratio=(fraction)1/1;
properties:
        udev-probed = true
        device.bus_path = /sys/devices/rmi4-00/rmi4-00.fn54/video4linux/v4l-touch0
        sysfs.path = /sys/devices/rmi4-00/rmi4-00.fn54/video4linux/v4l-touch0
        device.subsystem = video4linux
        device.product.name = "Synaptics\ RMI4\ Touch\ Sensor"
        device.capabilities = :capture:
        device.api = v4l2
        device.path = /dev/v4l-touch0
        v4l2.device.driver = rmi4_f54
        v4l2.device.card = "Synaptics\ RMI4\ Touch\ Sensor"
        v4l2.device.bus_info = rmi4:rmi4-00.fn54
        v4l2.device.version = 265480 (0x00040d08)
        v4l2.device.capabilities = 2501902337 (0x95200001)
        v4l2.device.device_caps = 354418689 (0x15200001)
gst-launch-1.0 v4l2src device=/dev/v4l-touch0 ! ...

v4l2-ctl -d /dev/v4l-touch0 --list-formats reports:

ioctl: VIDIOC_ENUM_FMT
        Index       : 0
        Type        : Video Capture
        Pixel Format: 'TD16'
        Name        : 16-bit signed deltas

        Index       : 1
        Type        : Video Capture
        Pixel Format: 'TD08'
        Name        : 8-bit signed deltas

        Index       : 2
        Type        : Video Capture
        Pixel Format: 'TU16'
        Name        : 16-bit unsigned touch data

https://bugzilla.gnome.org/show_bug.cgi?id=789197
2017-11-06 19:34:22 -05:00
Nicolas Dufresne 57d7ae8496 v4l2allocator: Add support for data_offset
In MPLANE mode, the driver may set data_offset, which represent some
padding at the start of the buffer used internally. This portion of the
data need to be skipped, though it is included in bytesused.

This patch removes frame size sanity check as the method used will no
longer work. This check was simply there to help detect broken kernel
drivers. It would be re-implement by estimating the plane size, which is
not totally trivial and may be too much work for a simple debug check.

https://bugzilla.gnome.org/show_bug.cgi?id=733501
2017-11-03 15:47:11 -04:00
Philippe Renon 09af01a088 directsoundsink: simplify how DirecSoundBuffer is cleared
we always want to clear the whole buffer so no need to
start from offset even if the offset is always zero.

https://bugzilla.gnome.org/show_bug.cgi?id=788847
2017-10-12 10:32:34 +03:00
Philippe Renon 24561309f9 directsoundsink: fix comment
https://bugzilla.gnome.org/show_bug.cgi?id=788847
2017-10-12 10:32:34 +03:00
Philippe Renon 73993149ec directsoundsink: don't call set_volume with private scaled volume
use get_volume() instead to get unscaled volume

https://bugzilla.gnome.org/show_bug.cgi?id=788847
2017-10-12 10:32:34 +03:00
Philippe Renon d519d14ad9 directsoundsink: remove duplicate volume initialization
https://bugzilla.gnome.org/show_bug.cgi?id=788847
2017-10-12 10:32:34 +03:00
Nicolas Dufresne 33e595b41c v4l2videoenc: Fix driver capability dectection
Use the right set of caps when checking if caps intersect. That makes
the check only select the supported devices.
2017-10-07 17:33:41 -04:00
Nicolas Dufresne cebb5baaa6 v4l2videoenc/dec: Don't leak template caps 2017-10-07 17:33:41 -04:00
Nicolas Dufresne 9ad90f3bf2 v4l2videodec: Protect against null pool in _stop
This may happen if the negotiation fails, as we will have never
created the pools.
2017-10-07 17:33:41 -04:00
Tim-Philipp Müller 97285753fc v4l2: fix build without libv4l
https://bugzilla.gnome.org/show_bug.cgi?id=779466
2017-10-07 15:39:47 +01:00
Enrico Jorns e9c00c083b v4l2object: auto-detect dmabuf export for V4L2_IO_AUTO on capture side
Issue an invalid VIDIOC_EXPBUF ioctl to the driver to check if the
driver supports dmabuf export. If the driver does not implement the
IOCTL, the error is ENOTTY. Any other error codes mean that the driver
implements VIDIOC_EXPBUF.

https://bugzilla.gnome.org/show_bug.cgi?id=779466
2017-10-05 21:20:19 -04:00
Nicolas Dufresne fb26575b73 v4l2videodec: Don't leak codec name 2017-09-19 17:55:58 -04:00
Nicolas Dufresne 1f902e2f6e v4l2bufferpool: Don't stop streaming when pool is flushing
The purpose of being able to flush the buffer pool is only to
unlock any blocked operation. Doing streamoff/streamon had the
side effect of turning off and on the camera. As we do a flush_start
/ flush_stop sequence when shutting down, that would cause a really
quick sequence of streamoff/streamon/streamoff/close which was
causing some cameras to stop working.

https://bugzilla.gnome.org/show_bug.cgi?id=783945
2017-09-19 17:33:35 -04:00
Nicolas Dufresne a08d7cdef5 v4l2src: Ensure all caps a fixated
The code relied on the list compare function to fixate the caps
but if the caps only has one structure, the compare function will
never get called. Capture device for which there is only one
structure in the caps would then get some assertion and later
fail badly.

Instead, fixate before inserting into the list and split the reading
and the fixation of the structures.
2017-09-13 16:05:08 -04:00
Nicolas Dufresne c56eb21a82 v4l2object: Don't leak the par value 2017-09-13 11:52:09 -04:00
Ian Jamison 85ec6430d9 v4l2object: Handle BT2020 for colorspace and transfer
This was not fully handled in switches and
ub gst_v4l2_object_get_colorspace();

https://bugzilla.gnome.org/show_bug.cgi?id=787313
2017-09-06 11:33:53 -04:00
Ian Jamison fc5d9c34a7 v4l2object: Fix colorimetry transfer lookup for 4K video
https://bugzilla.gnome.org/show_bug.cgi?id=787160
2017-09-06 11:33:53 -04:00
Nicolas Dufresne 05a5ab0e55 v4l2src: Check if caps have changed after try_fmt
try_fmt will update the caps colorimetry and interlace-mode. Before this
call, those field are missing. The caps equality check was always
failing when a spurious reconfigure event was received.
2017-09-06 11:33:53 -04:00
Cyril Lashkevich f2372b46bc v4l2bufferpool: Don't mark jpeg frames as deltas
JPEG formats are encoded, but they never have keyframe flag. But in
fact they are keyframes

https://bugzilla.gnome.org/show_bug.cgi?id=785990
2017-08-08 11:09:52 -04:00
Philippe Normand acb50ce82e osxvideo: rename library according to the plugin name
https://bugzilla.gnome.org/show_bug.cgi?id=785880
2017-08-06 13:26:01 +01:00
Nicolas Dufresne d8b18f6b8f v4l2bufferpool: Don't drop buffer ref on qbuf
This function no longer take ownership of the buffer.

CID 1414800
2017-08-02 17:18:43 -04:00
Nicolas Dufresne 0e9fe263ca v4l2: Enable VP9 format
This was missing, preventing the encoder and decoder to work
properly. This also adds support for camera that would produce
VP9 (if that exists).
2017-08-02 17:13:55 -04:00
Nicolas Dufresne a13c24dc8c v4l2: Remove spurious CATEGORY_EXTERN
These have been copy pasted all over the place and are not used anymore.
All object have it's own category now. This fixes build warning since
the VP9 decoder had vp8 category declared.
2017-08-02 12:28:38 -04:00
Nicolas Dufresne 783ac9a9f9 v4l2videoenc: Move the profile/level negotation in the base class
This removes duplicated code across different codec.
2017-08-02 11:28:23 -04:00
Nicolas Dufresne b0fb95b956 v4l2videoenc: Turn gst_v4l2_is_video_enc into a helper
This reduces the amount of code needed in each codec class.
2017-08-02 09:36:08 -04:00
Nicolas Dufresne 040e25218a v4l2: Add VP8/9 encoder support 2017-08-01 16:01:11 -04:00
Nicolas Dufresne b61bba4848 v4l2object: Use mmap64 to match libv4l2 signature
https://bugzilla.gnome.org/show_bug.cgi?id=785628
2017-08-01 15:05:35 -04:00
Nicolas Dufresne ba8aa440bb v4l2bufferpool: Copy flags and timestamp when importing
Whenever we import from downstream pool (userptr or dmabuf-import), we
should copy over the flags and timestamp, otherwise downstream will not
get proper synchronization or will not be able to notice frames that has
corruption in it.

https://bugzilla.gnome.org/show_bug.cgi?id=785680
2017-08-01 09:48:46 -04:00
Nicolas Dufresne 2c7dfff047 v4l2: Add H263 Encoder support 2017-07-31 16:46:25 -04:00
Nicolas Dufresne 27cdcaf363 v4l2: Add missing no-inst header 2017-07-27 13:51:25 -04:00
Nicolas Dufresne c5d0264bc9 v4l2: Add interface for MPEG4 encoding 2017-07-27 12:12:00 -04:00
Nicolas Dufresne 1762c2e713 v4l2: Ignore register issue and keep probing
Don't stop registering the other dynamic plugins if one registration
fails.
2017-07-27 12:12:00 -04:00
Nicolas Dufresne 6fa565247d v4l2: Update external files with latest
This is copied from the linux kernel with only some include changes so
it works outside the kernel headers.
2017-07-26 20:36:15 -04:00
Nicolas Dufresne 5a6fe4ed29 v4l2: Fix compilation without libv4l2 2017-07-24 16:45:40 -04:00
Nicolas Dufresne 2ee90e2b39 v4l2: Keep ref to element in allocator/pool
Removes the FIXME/Question in the buffer pool and add a ref to the
element in the GstAllocator too. This ref is strictly required to keep
the GstV4l2Object structure around.
2017-07-24 16:27:36 -04:00
Nicolas Dufresne 33f508d508 v4l2object: Removed unused members 2017-07-24 14:27:05 -04:00
Nicolas Dufresne 31d8a1d929 v4l2: Add run-time environment to enable libv4l2
The library has started preventing a lot of interesting use cases,
like CREATE_BUFS, DMABuf, usage of TRY_FMT. As the libv4l2 is totally
inactive and not maintained, we decided to disable it. As a convenience
we added a run-time environment that let you enable it for testing.

  GST_V4L2_USE_LIBV4L2=1

This of course only works if you have enabled libv4l2 at build time.
2017-07-24 14:19:02 -04:00
Nicolas Dufresne 4bcec1b190 v4l2object: Fix colorimetry validation
While not documented, gst_video_colorimetry_matches() only accepts well
known names. Looking at the code and unit test, this seems to be on
purpose, so fixing by parsing the string and compating the colorimetry
structures.
2017-07-21 23:34:59 -04:00
Nicolas Dufresne ef633e28f8 v4l2encoder: Fix negotiation error handling
The subclass negotiated function will call set_format, if that fails the
pool will not be created. We ended up with an assertion.

GStreamer-CRITICAL **: gst_buffer_pool_set_active: assertion 'GST_IS_BUFFER_POOL (pool)' failed
2017-07-21 15:40:24 -04:00
Nicolas Dufresne b3e089d415 v4l2src: Speedup camera startup by skipping try_fmt
In this commit, we enabled skip_try_fmt_probes quirk in order to speed
up the start which is known to be disastrously slow with certain USB
cameras.

This has the side effect that we needed to rewrite the entire
negotiation process in a way that we iterate over the possible caps
until we find one that works.

The new negotiation method consist of extracting a preferred structure
from the peer caps and using this to fixate and sort the caps. To
reflect the old behaviour, we sort all resolution strictly bigger
to the preferred one with the closes one first. The rest is appended,
keeping the same order. We then normalize the caps in case there was
some list of interlace-mode or colorimetry left. We finally iterate
over all fixed caps and try it. 99% of the time, the first or the
second one should work, whit the result of a single S_FMT being issues.

From there, it will be relatively easy to introduce new negotiation
algorithm. The current algorithm is made for optimal image quality
with a scaling sink that sets it's window resolution as preference.
This the case if for:

  v4l2src ! videoconvert ! videoscale ! ximagesink

Other strategy would be needed to optimize for non-scaling sink like
ximagesink or kmssink when the driver does not scale.

https://bugzilla.gnome.org/show_bug.cgi?id=785156
2017-07-21 15:29:10 -04:00
Nicolas Dufresne cae0b9a2d2 v4l2object: Introduce quirk to skip slow probes
skip_try_fmt_probes quirk is set, V4L2 object will not probe for
interlace-mode and colorimetry to avoid relying on try_fmt. This quirk
will be used by v4l2src to avoid desastrous startup time with slow
USB webcams.

When this quirk is enabled, caller will have to iterate over the
negotiated caps as it may contains unsupported formats. If the peer
didn't choose a specific interlace-mode, or colorimetry, the value
chosen by the driver is set into the caps. For this reason, when this
mode is enabled, gst_v4l2_object_set_format() will require writable
caps.

https://bugzilla.gnome.org/show_bug.cgi?id=785156
2017-07-21 15:29:10 -04:00
Nicolas Dufresne 7d3b2628df v4l2object: always set the GstV4l2Error on error
Some of the error case were conditional to using try_fmt or not.
This is slightly unexpected, always set the error so the caller
can decide.

https://bugzilla.gnome.org/show_bug.cgi?id=785156
2017-07-21 15:29:10 -04:00
Nicolas Dufresne 059ccf9749 v4l2object: Minor style fix and useful trace
https://bugzilla.gnome.org/show_bug.cgi?id=785156
2017-07-21 15:29:10 -04:00
Nicolas Dufresne c00d4cae3c v4l2object: Fix try/s_fmt errors
According to the spec,TRY_FMT cannot return EBUSY, though it can
return EINVAL if it was not possible to update the format to
something supported.

https://bugzilla.gnome.org/show_bug.cgi?id=785156
2017-07-21 15:29:10 -04:00
Nicolas Dufresne 558e9f4e57 v4l2object: Validate colorimetry in S/TRY_FMT
This is in preparation for removing slow TRY_FMT probes for
colorimetry. As we won't have tried that colorimetry we cannot
assume the driver will accept it.

https://bugzilla.gnome.org/show_bug.cgi?id=785156
2017-07-21 15:29:10 -04:00
Nicolas Dufresne 336c8a7dad v4l2object: Validate field in S/TRY_FMT
This is in preparation from removing the slow TRY_FMT probes for
interlacing. As we won't have tried that interlace-mode already
we need to validate that the driver isn't refusing it.

https://bugzilla.gnome.org/show_bug.cgi?id=785156
2017-07-21 15:29:10 -04:00
Nicolas Dufresne a3545637de directsound: Fix .c file name in Makefile
This was broken by accident, bad search and replace.
2017-07-20 17:21:05 -04:00
Nicolas Dufresne 7edf41b470 waveform: Fix DLL name to match plugin name
https://bugzilla.gnome.org/show_bug.cgi?id=785168
2017-07-20 15:46:38 -04:00
Nicolas Dufresne 608abe4a7f directsound: Fix DLL name to match plugin name
https://bugzilla.gnome.org/show_bug.cgi?id=785168
2017-07-20 15:46:38 -04:00
Nicolas Dechesne 52c017caca v4l2videodec: add some useful debug messages
Add a couple of useful debug traces , they happened to be useful to
debug/investigate a 4K video playback issue with v4l2, so let's make these
changes more permanent.

Signed-off-by: Nicolas Dechesne <nicolas.dechesne@linaro.org>

https://bugzilla.gnome.org/show_bug.cgi?id=785109
2017-07-19 10:25:11 -04:00
Nicolas Dufresne 6d0a9abdf0 v4l2: Fix 4K colorimetry
Since 1.6, the transfer function for BT2020 has been changed from BT709
to BT2020_12. It's the same function, but with more precision. As a side
effect, the V4L2 colorpsace didn't match GStreamer colorspace. When
GStreamer ended up making a guess, it would not match anything supported
by V4L2 anymore. This this by using BT2020_12 for BT2020 colorspace and
BT2020 transfer function in replacement of BT709 whenever a 4K
resolution is detected.
2017-07-18 12:03:17 -04:00
Nicolas Dufresne 08643993df v4l2object: Only check CROPCAP for par once
The pixel aspect ratio is documented to not change unless the TV
Standard is changed. So this mean that this will be uniform across all
possible format and resolutions.

https://bugzilla.gnome.org/show_bug.cgi?id=784674
2017-07-18 12:03:17 -04:00
Nicolas Dufresne a6d224521e v4l2: UVC driver is named uvcvideo these days
The quirk to avoid probing interlacing didn't work anymore as the driver
is now name uvcvideo. This should slightly speed up camera startup.
2017-07-17 20:48:28 -04:00
Nicolas Dufresne 83cb5ef957 v4l2object: Remove unused defines 2017-07-17 20:48:28 -04:00
Nicolas Dufresne 9b9cba3798 v4l2: Make gst_v4l2_get_capabilities static
It's not used outside of v4l2_calls.c
2017-07-17 20:48:28 -04:00
Nicolas Dufresne bec03858fa v4l2: Merge v4l2_calls.h into gstv4l2object.h
First step of a larger cleanup, all function from v4l2_calls are in fact
methods on GstV4l2Object. This split makes the code really confusing.
This also remove no longer unused macros.
2017-07-17 20:48:28 -04:00
Nicolas Dufresne 3bbd43f7eb v4l2object: Trace unknown fourcc as text
This makes it easier to find out what is not supported.
2017-07-14 13:31:30 -04:00
Nicolas Dufresne 06424c438e v4l2: Don't probe for unneeded format
For v4l2videodec/enc, we generate elements per formats, and in
this case we can speed up the start up by only probing the format
we care about.
2017-07-14 13:31:30 -04:00
Nicolas Dufresne 724a3ceec5 v4l2videodec: Implement stable element names
Before that, each m2m node would be wrapped as a single, multi-format
decoder element. As a unique name was needed, we where using the device
name, which changes between re-boots. This led to unpredictable element
names. In this patch, we generate an element per codec, using
v4l2<codec>dec name. If there is multiple decoder for the same format,
the following elements will be named v4l2<node><codec>dec.

https://bugzilla.gnome.org/show_bug.cgi?id=784908
2017-07-14 13:31:30 -04:00
Matt Fischer 52a5658030 v4l2: Block recursive calls to resurect_buffer
When resurrecting a buffer, the subsequent free call can result
in the group-released handler being called again, which causes
a recursive loop.  This patch blocks the signal handler during
the time that it executes, ensuring that the loop will not occur.

https://bugzilla.gnome.org/show_bug.cgi?id=759292
2017-06-29 15:54:42 -04:00
Guillaume Desmottes 47ca2ce499 v4l2: increase by one the number of allocated buffers
Increasing this number fix a buffer starvation problem I'm hitting
with a "v4l2src ! kmssink" pipeline.

kmssink requests 2 buffer as it keeps a reference on the last rendered
one. So we were allocating 3 buffers for the pipeline.
Once the first 2 buffers have been pushed we ended up with:
- one buffer queued in v4l2
- one being pushed
- one kept as last rendered

If this 3rd buffer is released after that v4l2 used the first one to
capture we end up with a buffer starvation problem as no buffer is currently
queued in v4l2 for capture.

Fixing this by adding one extra buffer to the pipeline so when one
buffer is being pushed downstream the other can already be queued to
capture the next frame.

We were already adding 3 buffers if downstream didn't reply to the
allocation query. I reduced this number to 2 to compensate the extra
buffer which is now always added.

https://bugzilla.gnome.org/show_bug.cgi?id=783049
2017-06-29 15:13:18 -04:00
Matt Fischer e8a4678738 v4l2allocator: Fix memory leak with dmabuf
This patch fixes a memory leak that is caused if the dmabuf file
descriptor dup fails.  Previously, _cleanup_failed_alloc() would
not unref the memory because mems_allocated had not yet been
incremented.

https://bugzilla.gnome.org/show_bug.cgi?id=784302
2017-06-28 17:03:05 -04:00
Tim-Philipp Müller dd23afb6d4 sys: remove sunaudio plugin
Even though hooked up to the build system, it's clear that no one
has ever built or used this with GStreamer 1.x. It wants to link
against libgstinterfaces, which no longer exists. And uses 0.10-style
raw audio caps. And the last meaningful change was done in 2009.
Let's just remove it.
2017-06-23 20:02:43 +01:00
Tim-Philipp Müller 2271fee77e meson: build oss4 plugin
https://bugzilla.gnome.org/show_bug.cgi?id=784134
2017-06-23 19:36:03 +01:00
Tim-Philipp Müller 1fa24b0be3 meson: build oss plugin
https://bugzilla.gnome.org/show_bug.cgi?id=784134
2017-06-23 19:34:16 +01:00
Nicolas Dufresne b9532fc6fb v4l2videoenc: Make sure min_buffers is valid
When upstream does no use the v4l2videoenc pool, we need to activate
that internal pool. Though, we relied the driver to provide a minimum
required buffer, which Qualcomm Venus driver don't currently provide.

https://bugzilla.gnome.org/show_bug.cgi?id=783361
2017-06-05 10:55:28 -04:00
Edward Hervey 246f21ac2f v4l2videoenc: Don't leak VideoCodecState
CID #1409852
2017-05-26 17:52:19 +02:00
Nicolas Dufresne 85218c69b9 v4l2videoenc: Remove unused function 2017-05-24 14:19:27 -04:00
Nicolas Dufresne 9f936c9244 v4l2: Don't redefine __bitwise if already set
https://bugzilla.gnome.org/show_bug.cgi?id=728438
2017-05-24 14:00:22 -04:00
Ayaka 27310365d5 v4l2: Add Video Encoder support
This implements H264 encoding support using generic V4L2 interface. It is
reported to work with Samsung MFC driver, IXM.6 CODA driver and
Qualcomm mainline Venus driver. Other platform should be supported as
none of this work is platform specific.

The implementation consist of a GstV4l2VideoEnc base class, which
implements the core streaming functionality. This base class is implemented
by GstV4l2H264Enc class that implements the caps negotiation specific to
H264 profiles and level. This implementation supports hardware with multiple
H264 encoder. Though, to make it simplier to use, the first discovered H264
encoder will be named v4l2h264enc. Other encoder found during discovery will
have a unique name like v4l2video0h264enc.

This work is the combined work of multiple developpers in the last 3
years. Thanks to all of the contributors:

  Ayaka <ayaka@soulik.info>
  Frédéric Sureau <frederic.sureau@vodalys.com>
  Jean-Michel Hautbois <jean-michel.hautbois@veo-labs.com>
  Nicolas Dufresne <nicolas.dufresne@collabora.com>
  Pablo Anton <pablo.anton@vodalys-labs.com>

https://bugzilla.gnome.org/show_bug.cgi?id=728438
2017-05-24 14:00:22 -04:00
Nicolas Dufresne 7dc57e381b v4l2videodec: Remove unused forward declaration
https://bugzilla.gnome.org/show_bug.cgi?id=728438
2017-05-24 14:00:22 -04:00
Ayaka 17e52f6ac2 v4l2pool: Fix wrong error message
https://bugzilla.gnome.org/show_bug.cgi?id=728438
2017-05-24 14:00:22 -04:00
Ayaka 342de49bf6 v4l2: increase pre-allocated encoded buffer size
As of today, the MFC encoder often need to exceed that 1 MB
size for encoded buffer we fixed earlier for decoding.

https://bugzilla.gnome.org/show_bug.cgi?id=728438
2017-05-24 14:00:22 -04:00
Josep Torra d699dc615e osxaudio: fixes playback of mono streams with no channel-mask field in caps
Fixes a negotiation error seen when trying to playback of a .MOV file with
a mono AAC audio stream decoded by avcdec_aac that doesn't set channel-mask
field but sink was requiring channel-mask=0x3.
2017-05-20 18:33:42 +02:00
Josep Torra 7348ed5faa osxvideo: fix macOS 10.12 deprecation warnings
Add #defines to allow older versions of macOS to use the new constant names.
2017-05-20 11:37:27 +02:00
Sebastian Dröge 2c6016667b gst: Clear floating flag in constructor of all GstObject subclasses that are not owned by any parent
https://bugzilla.gnome.org/show_bug.cgi?id=743062
2017-05-17 10:41:01 +03:00
Nicolas Dufresne b68d936ae0 Remove plugin specific static build option
Static and dynamic plugins now have the same interface. The standard
--enable-static/--enable-shared toggle are sufficient.
2017-05-16 14:41:19 -04:00
Dustin Spicuzza a303a7971c directsoundsink: Use GstClock API instead of Sleep() for waiting
It's more accurate and allows cancellation.

https://bugzilla.gnome.org/show_bug.cgi?id=773681
2017-05-08 17:33:38 +02:00
Nirbheek Chauhan 2d44b53ff6 directsoundsink: Fix corner case causing large CPU usage
We were unnecessarily looping/goto-ing repeatedly when we had exactly
the amount of data as the free space, and also when the free space was
too small. This, as it turns out, is a very common scenario with
Directsound on Windows.

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

We have to do polling here because the event notification API that
Directsound exposes cannot be used with live playback since all events
must be registered in advance with the capture buffer, you cannot
add/remove them once playback has begun. Directsoundsrc had the same
problem.

See also: https://bugzilla.gnome.org/show_bug.cgi?id=781249
2017-05-08 16:02:46 +02:00
Nirbheek Chauhan 0700b1f0b0 directsoundsink: Clean up some debug logging
Don't need to print the function name, gstreamer does it for you.

https://bugzilla.gnome.org/show_bug.cgi?id=773681
2017-05-08 16:02:46 +02:00
Todor Tomov 081bae2849 v4l2object: Copy timestamp when importing buffers
This is needed for V4L2_OUTPUT interface, and is harmless of
V4L2_CAPTURE interfaces. This will fix timestamp in cases like:

  v4l2src io-mode=dmabuf ! v4l2videoNenc output-io-mode=dmabuf-import !  ...

Same apply for userptr.

https://bugzilla.gnome.org/show_bug.cgi?id=781119
2017-04-10 12:49:39 -04:00
Thibault Saunier 7b7a809818 v4l2dec: Fix race when going from PAUSED to READY
Running `gst-validate-launcher -t validate.file.playback.change_state_intensive.vorbis_vp8_1_webm`
on odroid XU4 (s5p-mfc v4l2 driver) often leads to:

  ERROR:../subprojects/gst-plugins-good/sys/v4l2/gstv4l2videodec.c:215:gst_v4l2_video_dec_stop: assertion failed: (g_atomic_int_get (&self->processing) == FALSE)

This happens when the following race happens:

- T0: Main thread
- T1: Upstream streaming thread
- T2. v4l2dec processing thread)

[The decoder is in PAUSED state]

T0. The validate scenario runs `Executing (36/40) set-state: state=null repeat=40`
T1- The decoder handles a frame
T2- A decoded frame is push downstream
T2- Downstream returns FLUSHING as it is already flushing changing state
T2- The decoder stops its processing thread and sets `->processing = FALSE`
T1- The decoder handles another frame
T1- `->process` is FALSE so the decoder restarts its streaming thread
T0- In v4l2dec-> stop the processing thread is stopped
NOTE: At this point the processing thread loop never started.
T0- assertion failed: (g_atomic_int_get (&self->processing) == FALSE)

Here I am removing the whole ->processing logic to base it all on the
GstTask state to avoid duplicating the knowledge.

https://bugzilla.gnome.org/show_bug.cgi?id=778830
2017-04-07 11:31:03 -03:00
Nicolas Dufresne 3342d86d9b v4l2videodec: Fix 32bit only printf format
The previous patch was using %llu for 64bits printf, which is 32bit
specific. We also trace the latency in time human readable form now.
2017-04-05 09:46:31 -04:00
Philipp Zabel ce5c0b8f92 v4l2object: set streamparm for outputs that support it
Without a specified framerate from the sink, the decoder frame interval
should be set using the framerate of the encoded video stream.
Therefore, the v4l2object should be able to change the framerate on the
output if the V4L2 device accepts it.

This is also necessary for mem2mem encoders so that their bitrate
calculation code may work correctly and they may report the correct
frame duration on the capture queue.

https://bugzilla.gnome.org/show_bug.cgi?id=779466
2017-04-05 09:26:05 -04:00
Philipp Zabel 1d43f6d852 v4l2videodec: only set latency if the frame duration is valid
If the duration of the v4l2object is GST_CLOCK_TIME_NONE, because the
sink did not specify a framerate in the caps and the driver accepts the
framerate, the decoder element uses GST_CLOCK_TIME_NONE to calculate and
set the element latency.

While this is a bug of the capture driver, the decoder element should
not use the invalid duration to calculate a latency, but print a warning
instead.

https://bugzilla.gnome.org/show_bug.cgi?id=779466
2017-04-05 09:20:19 -04:00
Olivier Crête b30dee98e6 v4l2sink: Block in preroll_wait on unlock
The correct behaviour of anything stuck in the ->render() function
between ->unlock() and ->unlock_stop() is to call
gst_base_sink_wait_preroll() and only return an error if this returns an
error, otherwise, it must continue where it left off!

https://bugzilla.gnome.org/show_bug.cgi?id=774945
2017-04-05 09:05:03 -04:00
Carlos Rafael Giani 79d9cd44b6 v4l2object: Also add videometa if there is padding to the right and bottom
https://bugzilla.gnome.org/show_bug.cgi?id=780478
2017-03-24 13:57:10 -04:00
Nicolas Dufresne 37c491ceff v4l2: Fix meson plugin shared object name
It didn't match between AutoMake and Meson, and the Meson name
didn't math the plugin name (video4linux2).
2017-03-17 20:59:44 -04:00
Olivier Crête dac03fa87c v4l2: Remove unused macro 2017-03-14 16:38:02 -04:00
Olivier Crête 75d2a57783 v4l2: Remove unused definitions 2017-03-14 16:35:25 -04:00
Nicolas Dufresne ca0ed8a134 Fix plugin filenames to match plugin names
- libgstpulse.so becomes libgstpulseaudio.so
- libgstsouphttpsrc.so becomes libgstsoup.so
- libgstoss4audio.so becomes libgstoss4.so

https://bugzilla.gnome.org/show_bug.cgi?id=779344
2017-03-08 20:04:20 -05:00
Edgard Lima 8635258046 Update Edgard Lima's email
https://bugzilla.gnome.org/show_bug.cgi?id=779230
2017-02-27 00:34:19 +00:00
Nicolas Dufresne 0b83e4ceaf v4l2object: Update image size when extrapolating
Update the image size according the amount of data we are going to
read/write. This workaround bugs in driver where the sizeimage provided
by TRY/S_FMT represent the buffer length (maximum size) rather then the expected
bytesused (buffer size).

https://bugzilla.gnome.org/show_bug.cgi?id=775564
2017-02-22 03:53:30 -05:00
Reynaldo H. Verdejo Pinochet b460f18f17 v4l2: fix typo in _acquire_format() error messages
Fixes:

https://bugzilla.gnome.org/show_bug.cgi?id=778815
2017-02-21 10:17:56 -08:00
Juan Pablo Ugarte b6723ecd3c v4l2object: mark singleton caps as "may be leaked" objects.
Set MAY_BE_LEAKED flag on static pads returned by gst_v4l2_object_get_*_caps()
functions. Made functions thread safe by using g_once_init[enter|leave]
funtions.

https://bugzilla.gnome.org/show_bug.cgi?id=778453
2017-02-10 16:35:53 -05:00
Jean-Christophe Trotin 7f763f2710 v4l2allocator: reference memory before the buffer is queued
In gst_v4l2_allocator_qbuf(), the memory is referenced after the
buffer is queued. Once queued (VIDIOC_QBUF), the buffer might be handled
by the V4L2 driver (e.g. decoded) and dequeued (gst_v4l2_allocator_dqbuf),
through a different thread, before the memory is referenced (gst_memory_ref).
In this case, in gst_v4l2_allocator_dqbuf(), the memory is unreferenced
(gst_memory_unref) before having been referenced: the memory refcount
reaches 0, and the memory is freed.
So, to avoid this crossing case, in gst_v4l2_allocator_qbuf(), the
memory shall be referenced before the buffer is queued.

https://bugzilla.gnome.org/show_bug.cgi?id=777399
2017-01-24 11:30:57 -05:00
Enrico Jorns eb25b058f9 v4l2: Remove usage and definition of LOG_CAPS macro
Unlike former definitions of LOG_CAPS, the current implementation simply
expands to GST_DEBUG_OBJECT. The LOG_CAPS macro is rarely used and most
uses duplicate already existing GST_DEBUG_OBJECT lines. Therefore, the
caps are often printed twice which unnecessarily clutters the debug log.

Replace LOG_CAPS calls with GST_DEBUG_OBJECT, remove LOG_CAPS calls, and
delete the definition of LOG_CAPS.

https://bugzilla.gnome.org/show_bug.cgi?id=776899
2017-01-16 10:29:47 -05:00
Jean-Christophe Trotin 1c2e2d83ce v4l2bufferpool: remove duplicated line of code
https://bugzilla.gnome.org/show_bug.cgi?id=777330
2017-01-16 10:19:34 -05:00
Jean-Christophe Trotin 2b80cd14b0 v4l2allocator: fix memory type in allocator probe
The buffer memory type provided to the VIDIOC_CREATE_BUFS ioctl shall
be set with the value ("memory") given as input parameter of the
gst_v4l2_allocator_probe() function.

https://bugzilla.gnome.org/show_bug.cgi?id=777327
2017-01-16 10:19:18 -05:00
Tim-Philipp Müller d7b2820b73 Fix indentation 2017-01-09 19:05:10 +00:00
Víctor Manuel Jáquez Leal 6ec3cc70b2 v4l2object: Don't check size in a non-list value
After commit 1ea9735a I see these error while using the webcam
integrated in my laptop:

GStreamer-CRITICAL **: gst_value_list_get_size: assertion 'GST_VALUE_HOLDS_LIST (value)' failed

The issue is gst_v4l2src_value_simplify() was doing its job of
generating a single value, rather than the original list. That why,
when getting the list size, a critical warning was raised.

This patch takes advantage of the compiler optimizations to verify
first if the list was simplified, thus use it directly, otherwise,
if it is a list, verify its size.

https://bugzilla.gnome.org/show_bug.cgi?id=776106
2016-12-14 19:22:36 +01:00
Arun Raghavan 1ea9735afb v4l2object: Don't set empty interlace-mode list
If for some reason we fail to probe formats (all try_fmt calls fail, for
example), this is not a critical error, but we end up with an empty list
of interlace modes. This causes all subsequent negotiation to fail.

This patch fixes interlace-mode setting to be skipped if we failed to
detect any.

https://bugzilla.gnome.org/show_bug.cgi?id=775702
2016-12-08 10:13:39 +05:30
Philipp Zabel 86f243bb12 gstv4l2bufferpool: lock flush_stop against regular qbuf
These can be called from different threads and both manipulate the
pool->buffers array. Lock them properly and let flush_stop move the
array contents into a temporary array on the stack to avoid having
to call release_buffer under the object lock.

https://bugzilla.gnome.org/show_bug.cgi?id=775015
2016-11-24 11:47:07 -05:00
Philipp Zabel 6b5807654b gstv4l2bufferpool: remove critical error message when process is called on an inactive pool
If the pool is inactive, it is guaranteed to also be flushing, so the
following check will return GST_FLOW_FLUSHING anyway.
This can happen if a v4l2src is blocking on DQBUF in create and is sent
an EOS event on another thread. In that case the pool is set to
flushing/inactive without locking, the v4l2src is unblocked, and may
call pool_process with a valid buffer on the already inactive pool.

https://bugzilla.gnome.org/show_bug.cgi?id=775014
2016-11-24 11:47:07 -05:00
Philipp Zabel 65826f819a v4l2src: release buffer if create fails
gst_base_src_get_range does not expect a buffer to be returned in
the error case, so we are leaking a reference here if create fails.

https://bugzilla.gnome.org/show_bug.cgi?id=775014
2016-11-24 11:47:07 -05:00
William Manley 56b1d088a9 v4l2: Warn, don't assert if v4l gives us a buffer with a too large size
I've seen problems where the `bytesused` field of `v4l2_buffer` would be
a silly number causing the later call to:

    gst_memory_resize (group->mem[i], 0, group->planes[i].bytesused);

to result in this error to be printed:

    (pulsevideo:11): GStreamer-CRITICAL **: gst_memory_resize: assertion 'size + mem->offset + offset <= mem->maxsize' failed

besides causing who-knows what other problems.

We make the assumption that this buffer has still been dequeued correctly
so just clamp to a valid size so downstream elements won't end up in
undefined behaviour.

The invalid `v4l2_buffer` I saw from my capture device was:

    buffer = {
      index = 0,
      type = 1,
      bytesused = 534748928, // <- Invalid
      flags = 8260, // V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC | V4L2_BUF_FLAG_ERROR | V4L2_BUF_FLAG_DONE
      field = 01330, // <- Invalid
      timestamp = {
        tv_sec = 0,
        tv_usec = 0
      },
      timecode = {
        type = 0,
        flags = 0,
        frames = 0 '\000',
        seconds = 0 '\000',
        minutes = 0 '\000',
        hours = 0 '\000',
        userbits = "\000\000\000"
      },
      sequence = 0,
      memory = 2,
      m = {
        offset = 3537219584,
        userptr = 140706665836544, // Could be nonsense, not sure
        planes = 0x7ff8d2d5b000,
        fd = -757747712
      },
      length = 2764800,
      reserved2 = 0,
      reserved = 0
    }

This is from gdb with my own annotations added.

This was with gst-plugins-good 1.8.1, a Magewell XI100DUSB-HDMI video
capture device and kernel 3.13 using a dodgy HDMI cable which is great at
breaking HDMI capture devices.  I'm using io-mode=userptr and have built
gst-plugins-good without libv4l.

https://bugzilla.gnome.org/show_bug.cgi?id=769765
2016-11-01 20:12:56 +02:00
Tobias Schneider 932adb1968 v4l2object: fix extra-controls leak
Gst struct v4l2object->extra_controls is created if user sets appropriate
option but it is not freed on destruction of v4l2object.

https://bugzilla.gnome.org/show_bug.cgi?id=773580
2016-10-31 12:06:27 -04:00
Scott D Phillips 91e9a94492 meson: directsound: Add ole32 library dependency
https://bugzilla.gnome.org/show_bug.cgi?id=773114
2016-10-21 06:01:16 -03:00
Gaurav Gupta 1950b72e2b waveformsink: Fix Memory leak using GST_PTR_FORMAT
https://bugzilla.gnome.org/show_bug.cgi?id=772497
2016-10-20 13:14:10 +03:00
Nicolas Dufresne 8cec944149 osxaudio: Distribute device provider files
Those where missing the the dev release tarballs for 1.9.2 which
prevented building from tarball on OSX platform
2016-09-07 15:35:06 -04:00
Jan Schmidt 9cc497e5c3 osxvideo: Remove QuickTime references.
QuickTime.h is no longer available on OS X 10.12 (Sierra),
and both the header and the framework seem unnecessary
for compilation - at least as of 10.11 (El Capitan).

https://bugzilla.gnome.org/show_bug.cgi?id=770526
2016-08-31 05:52:37 +10:00
Nirbheek Chauhan b09f478e80 Add support for Meson as alternative/parallel build system
https://github.com/mesonbuild/meson

With contributions from:

Tim-Philipp Müller <tim@centricular.com>
Jussi Pakkanen <jpakkane@gmail.com> (original port)

Highlights of the features provided are:
* Faster builds on Linux (~40-50% faster)
* The ability to build with MSVC on Windows
* Generate Visual Studio project files
* Generate XCode project files
* Much faster builds on Windows (on-par with Linux)
* Seriously fast configure and building on embedded

... and many more. For more details see:

http://blog.nirbheek.in/2016/05/gstreamer-and-meson-new-hope.html
http://blog.nirbheek.in/2016/07/building-and-developing-gstreamer-using.html

Building with Meson should work on both Linux and Windows, but may
need a few more tweaks on other operating systems.
2016-08-20 11:21:12 +01:00
Nirbheek Chauhan 4048a4e137 v4l2: consistently check #ifdef HAVE_GUDEV instead of #if
Both work with autotools but they definitely don't mean the same thing, cause
problems with other build systems, and are bad form. Existence should always be
checked with #ifdef or #if defined.
2016-08-18 20:20:20 +01:00
Nirbheek Chauhan af1d49d039 directsound: port away from old DirectX API
D3DX has been deprecated for the last 4 years and latest versions of
Windows no longer ship headers for it. This is fine as long as you're
building with Cerbero's Wine-based DirectX headers, but sucks if you
want to build against the actual Windows SDK.

We were just using it to get error strings anyway, so just use the
generic error string API.
2016-08-18 20:20:15 +01:00
Nicolas Dufresne ab075b2013 v4l2provider: Fix device type detection
The type detection would lead to assertion as it would try
to create a device without having found any type for it. It
also didn't detect MPLANE devices properly.
2016-07-11 19:17:49 -04:00
Nicolas Dufresne f0678d73b1 v4l2object: Don't assert when used by the monitor
The monitor sets the object->element object as a GstObject. This
works for debug traces, but will assert for ELEMENT_ERROR. This
was the only case where that could happen. Add a check for that.
2016-07-11 19:17:49 -04:00
Nicolas Dufresne e62bd2f7d8 v4l2object: Indent very long line 2016-07-11 19:17:49 -04:00
Nicolas Dufresne 5a9c0aa9f5 v4l2: Also copy device_caps in gst_v4l2_dup
This fixes regression where M2M error out saying they have no output
format (the V4L2 CAPTURE side).

https://bugzilla.gnome.org/show_bug.cgi?id=768195
2016-07-10 21:37:24 -04:00
Luis de Bethencourt eaa01071e0 v4l2: fix multiplanar capture
After switching to using V4L2_CAP_DEVICE_CAPS we lost support for
multiplanar device types. After some research, it looks like
vcap.capabilities treated the multiplanar flag of output and capture
devices equally, but not the new device_caps.

https://bugzilla.gnome.org/show_bug.cgi?id=768195
2016-07-08 19:03:51 +01:00
Luis de Bethencourt 67c2b93106 v4l2: fix v4l2 probe build error
A typo in gst_v4l2_probe_and_register() caused a build error when building
with --enable-v4l2-probe. Fixing it.

gstv4l2.c: In function 'gst_v4l2_probe_and_register':
gstv4l2.c:150:25: error: 'struct v4l2_capability' has no member named 'capabilitites'
       device_caps = vcap.capabilitites;
2016-07-07 23:55:33 +01:00
Reynaldo H. Verdejo Pinochet dfdc15c548 v4l2src: use gst_caps_intersect_full in negotiate()
Instead of reimplementing the GST_CAPS_INTERSECT_FIRST
interection mode.

https://bugzilla.gnome.org/show_bug.cgi?id=768195
2016-07-07 17:46:06 -04:00
Reynaldo H. Verdejo Pinochet 4b16b16aaf v4l2: use opened device caps instead of physical device ones
The same physical device can export multiple devices. In
this case, the capabilities field now contains a union of
all caps available from all exported V4L2 devices alongside
a V4L2_CAP_DEVICE_CAPS flag that should be used to decide
what capabilities to consider. In our case, we need the
ones from the exported device we are using.

https://bugzilla.gnome.org/show_bug.cgi?id=768195
2016-07-07 17:46:06 -04:00