Commit graph

96 commits

Author SHA1 Message Date
Piotr Brzeziński 5e45a1b1bd macos: Set activation policy in osxvideosink and glimagesink
Upon creating a window, glimagesink and osxvideosink now set the policy to
NSApplicationActivationPolicyRegular, which lets us show an icon in the Dock
for convenience and appear in the top menu bar like other apps.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4573>
2023-05-12 01:14:44 +02:00
Piotr Brzeziński f60c87769f macos: Remove old NSApp workaround related code
This is no longer needed since the introduction of `gst_macos_main()` in 1.22.
Before that existed, we had a patch for GLib in Cerbero, which did work but made it
impossible to update GLib at all. The code being removed was a fail-safe in case of
running without said patch being applied. It's no longer needed, since for macOS
we just wrap our GStreamer with an NSApplication using `gst_macos_main()`.

Warnings will be displayed if no NSApp/NSRunLoop is found wherever needed,
pointing the user towards using the new API.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4366>
2023-05-11 20:30:19 +02:00
Piotr Brzeziński 560d20a2c0 osxvideosink: fix deadlock upon closing output window
Invoking gst_osx_video_sink_osxwindow_destroy() can currently cause a deadlock
because showFrame() keeps trying to get the same lock as well. Moving the lock
closer to where it's actually needed seems to be enough to fix the issue for now.

Reported-by: Alexande B <abobrikovich@gmail.com>
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4559>
2023-05-11 06:35:02 +00:00
Nicolas Dufresne 3bd43672ec v4l2: device provider: Fix GMainLoop leak
On very quick start/stop, the mainloop may never be run. As a side
effect, our idle stop function is not really being ran, so we can't rely
on that to free the main loop. Simply unref the mainloop when the
thread have completely stop.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4521>
2023-05-03 10:04:58 +00:00
Nicolas Dufresne 51fa6a2656 v4l2: pool: Flush events on capture queue
Unfortunately streamoff does not flush the events, and this can cause all
sort of issues. Flush events on capture queue. We also return
GST_V4L2_FLOW_RESOLUTION_CHANGE in case a resolution change was seen.
This allow skipping streamon(capture) on flush, which could lead to a
configuration miss-match, or failure if the buffers aren't of the right
size.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4437>
2023-05-01 15:08:10 -04:00
Nicolas Dufresne 00492234bd v4l2: videodec: Detect flushes while setting up the capture
As we missed the fact we were flushing, we could create and activate
that buffer pool, and wait on it, causing a hang. We detect that we
are flushing by checking the related pad state.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4437>
2023-05-01 13:45:39 -04:00
Nicolas Dufresne c9841a5383 v4l2: bufferpool: Don't copy buffer when flushing
Threshold handling can race with flushing operation. This can lead to
avoidable buffer copies. Simply check and return the flushing status.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4437>
2023-05-01 13:45:16 -04:00
Nicolas Dufresne c6be3d7505 v4l2: videodec: Don't forcibly drain on resolution changes
Let the driver detects the change and reconfigure the capture side
transparently from there. This avoid reallocation of the output buffers,
and eliminates the need to stop and restart the capture task. This is
only happening if the driver have support for this, otherwise the old
behaviour is maintained.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4437>
2023-05-01 13:44:53 -04:00
Nicolas Dufresne f58d5dfd30 v4l2: videodec: Remove the spurious srccaps probe
We don't need to probe the srccaps in set_format() anymore, this
handled already in the capture thread while setting up the capture
queue.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4437>
2023-05-01 13:44:41 -04:00
Nicolas Dufresne 4a53beeb1f v4l2: videodec: Improve few logs
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4437>
2023-05-01 13:44:37 -04:00
Nicolas Dufresne fca61fad4d v4l2: videodec: Only warn of incomplete drain on success
We may have hit an error, or just flushing in order to stop the thread,
in which case, not having drain everything is expected and not a
driver bug.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4437>
2023-05-01 13:44:19 -04:00
Nicolas Dufresne 4dded20929 v4l2: bufferpool: Don't assert when orphaning is not needed
This may happen when shutting down and should not cause
any harm. This removes the associated assert when shutting
down the pipeline, notably with CTRL+C.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4437>
2023-05-01 13:43:36 -04:00
Nicolas Dufresne 66849fbdd1 v4l2: videodec: Wait for source change event
Stop doing capture buffer allocation based on guesses
and wait for the source change event when available.
Unlike stateless decoder, the stateful decoder is not aware of
the coded resolution, and this may lead to the wrong result
even when using TRY_FMT.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4437>
2023-05-01 13:43:16 -04:00
Nicolas Dufresne 5c820862fd v4l2: object: Move the GstPoll into v4l2object
Moves the GstPoll from the buffer pool into v4l2object. This will be
needed to poll for events before the pool has been created.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4437>
2023-05-01 13:43:03 -04:00
Nicolas Dufresne 457dd19a90 v4l2: object: Fix bogus debug objects pointers
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4437>
2023-05-01 13:42:59 -04:00
Nicolas Dufresne 52b916bdf5 v4l2: videodec: Move the capture setup into the processing loop
In previous implementation that job was split between handle_frame and
the processing loop and it wasn't clear if this mechanism was race
free. The capture setup would also be tried for every buffer, which was
not necessary.

This also simplify the handling of SRC_CH event, dropping the unneeded
atomic boolean.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4437>
2023-05-01 13:42:35 -04:00
Nicolas Dufresne 1ca7f6949e v4l2: videodec: Ensure object is inactive on failure
Sprinkle stop() calls in error case to guaranty that the capture object
is inactive on failure. Not doing so could allow some code to be called
in unexpected (and possibly undefined) conditions.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4437>
2023-05-01 13:42:02 -04:00
jeri.li 2b63e30852 v4l2bufferpool: add lock as atomic operation for seek
When seek flush, gst v4l2 buffer pool flush is not atomic which will
lead double enqueue buffer (qbuf) issue, and v4l2 buffer pool qbuf is
also not atomic which will lead no free buffer found in the pool.
1. add lock for calculate enqueue number in streamon function
2. add lock for v4l2 capture end streamoff in pool flush function
3. lock the whole funciton of v4l2 buffer pool qbuf, then the buffer
   pool index and qbuf operation are atomic

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4465>
2023-05-01 15:53:02 +00:00
Haihua Hu 1c488626da v4l2src: fix cannot reuse current caps when fixate caps in negotiation
when regotiation happens, v4l2src will check if it can reuse current caps,
but we need check if current caps is subset of all query caps from downstream
instead of check it with query caps one by one.

Assuming that the current caps is not the subset of first caps from query caps,
it will go to try fmt. when try fmt success, v4l2src will make pending_set_fmt
to TRUE and going to reset.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4500>
2023-05-01 15:05:26 +00:00
Nicolas Dufresne e709e2d97c meson: Add a wrap file for libgudev
And allow fallback to it.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4447>
2023-04-19 22:47:19 +00:00
Nicolas Dufresne 2e76371666 v4l2: Fix use after free of fmtdesc part 2
Add missing code in merge commit e890e6e8d8
("v4l2: Fix use after free of fmtdesc"). The v4l2object code was
missing.

Related to https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4317

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4411>
2023-04-13 13:54:32 -04:00
Nicolas Dufresne e890e6e8d8 v4l2: Fix use after free of fmtdesc
The decoder needs to force another enumeration of the format. For
this it was clearing the v4l2object insternal list, leaving a fmtdesc
pointer pointing to freed memory. This patch clears the fmtdesc pointer
that has just been free. It also makes sure the probe function does not
use the cached formats list. The probe function will restore the current
fmtdesc pointer based on the currently configured pixelformat.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4317>
2023-04-13 15:32:14 +00:00
Nicolas Dufresne 3a17200638 v4l2: videodec: Prefer acquired caps over anything downstream
As we don't have anything smart in the fixation process, we may endup with
a format that has a lower bitdepth, even if downstream can handle higher
depth. it is notably the case when negotiating with deinterlace, which places
is non-passthrough caps before its passthrough one. This makes the generic
fixation prefer the formats natively supported by deinterlace element over
the HW 10bit format. As some HW can downscale 10bit to 8bit, this can break
10bit decoding.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4317>
2023-04-13 15:32:13 +00:00
Nicolas Dufresne 89854fd2f3 v4l2: videodec: Remove leading space in comment
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4317>
2023-04-13 15:32:13 +00:00
Alexande B 452c06782e osxvideosink: fix broken aspect ration and frame drawing region
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3336>
2023-04-05 09:48:34 +00:00
Shengqi Yu 8cf21fe744 v4l2object: Add support for YVU420M format
This is a multi-planar format with planes non contiguous in memory. It
is intended to be used only in drivers and applications that support the
multi-planar API.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4287>
2023-03-31 13:42:05 +00:00
Michael Tretter a11f811155 v4l2object: mark jpeg as parsed
Assuming that V4L2 CAPTURE devices always use one buffer per JPEG image, we can
always mark JPEGs provided by a V4L2 element as parsed.

The V4L2 elements require that JPEG images sent to V4L2 OUTPUT devices must
always be parsed.

This is necessary to link a V4L2 CAPTURE device with a V4L2 OUTPUT device
without explicitly marking the stream as parsed or adding a jpegparse into the
pipeline.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4229>
2023-03-21 14:58:15 +00:00
Sebastian Dröge ccad9a7338 plugins: Fix various trivial clang compiler warnings
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4210>
2023-03-18 16:16:55 +02:00
Tim-Philipp Müller 0fc568c6b1 gst-plugins-good: re-indent with GNU indent 2.2.12
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4182>
2023-03-17 03:18:54 +00:00
Khem Raj 817339c4de v4l2: Define ioctl_req_t for posix/linux case
this is an issue seen with musl based linux distros e.g. alpine [1]
musl is not going to change this since it breaks ABI/API interfaces
Newer compilers are stringent ( e.g. clang16 ) which can now detect
signature mismatches in function pointers too, existing code warned but
did not error with older clang

Fixes
gstv4l2object.c:544:23: error: incompatible function pointer types assigning to 'gint (*)(gint, ioctl_req_t, ...)' (aka 'int (*)(int, unsigned long, ...)') from 'int (int, int, ...)' [-Wincompatible-function-pointer-types]
    v4l2object->ioctl = ioctl;
                      ^ ~~~~~

[1] https://gitlab.alpinelinux.org/alpine/aports/-/issues/7580

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3950>
2023-02-14 20:36:28 +00:00
Pawel Stawicki 492d2b6498 v4l2h264dec: Fix Raspberry Pi4 will not play video in application
Ensure object v4l2object->pool will be released by
correctly releasing the temporary thread-safety lock

Fixes issue #1729

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3786>
2023-01-25 16:07:50 +00:00
Tim-Philipp Müller f6950b4537 v4l2: drop use of GSlice
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3695>
2023-01-24 15:25:07 +00:00
Nicolas Dufresne c4cd94f465 v4l2src: Fix crash in renegotiation
This regression was introduce by fix for making buffer pool thread safe. When
we renegotiate, the pool will be setup after we set the format. But the code
has been simplified to only get the pool once before, which caused a null
pointer deref.

Fixes 94ba019 ("v4l2: Fix SIGSEGV on 'change state' during 'format change'")
Related to !3481
Fixes #1626

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3513>
2022-12-02 19:25:52 +00:00
Pawel Stawicki 94ba019397 v4l2: Fix SIGSEGV on 'change state' during 'format change'
Ensure all access to v4l2object->pool imply taking a lock and a hard ref on the pool

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3481>
2022-12-01 12:47:54 +00:00
Elliot Chen 63ff99ca8e v4l2: bypass check some transfer types in colorimetry
v4l2 will report fail for some streams whose colorimetry value such as 2:4:8:3.
Can bypass check these transfer types in colorimetry to avoid error.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3440>
2022-11-23 13:06:29 +00:00
Nicolas Dufresne 5980fb76e7 video: Add arbitrary tile dimensions support
In current tile representation, only tiles with power of two
width and height in bytes are supported. This limitation
prevents adding more complex tiles formats.

In this patch, we deprecate tile_ws and tile_hs from GstVideoFormatInfo and
replace if with an array of GstVideoTileInfo. Each plane tiles are then
described with their pixels width/height, line stride and total size.
The helper gst_video_format_info_get_tile_sizes() that depends on the
deprecated API is also being removed. This can simply be removed as it wasn't
in any stable release yet.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3424>
2022-11-18 22:59:29 +00:00
F. Duncanh d77fe9495a v4l2videodec: Fixes three H.264/HEVC ITU conformance tests
Postpone the cleanup of any consecutive sequence of lost frames
which starts at frame 0, until frame 100 is dequeued from driver.

This allows fluster tests JVT/CVWP2_TOSHIBA_E, JVC/CVWP3_TOSHIBA_E
and HEVC/POC_A_Bossen_3 that sends out-of-order frames to successfully
complete  (e.g., test of Amphion vpu driver).

Fixes #1569

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3398>
2022-11-16 10:00:03 +00:00
Jakub Adam 2125dbbd0b ximagesrc: grab the server while capturing screen image
Makes sure screen resolution doesn't change in the middle of the
process.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/1562>
2022-10-27 18:42:38 +00:00
Jakub Adam c93afcc99c ximagesrc: change video resolution when X11 screen gets resized
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/1562>
2022-10-27 18:42:38 +00:00
Edward Hervey c37182b6b9 oss4: Fix debug category initialization
Fixes https://gitlab.freedesktop.org/gstreamer/gstreamer/-/issues/1456

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3158>
2022-10-11 13:02:54 +00:00
Elliot Chen e76e98d109 v4l2videodec: add cap negotiation fail check in the capture configuration change
The capture configuration change may cause negotiation fail.
Need to check it to avoid enter the endless loop.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/2960>
2022-09-17 21:21:22 +00:00
Thibault Saunier 6a4425e46a meson: Call pkgconfig.generate in the loop where we declare plugins dependencies
Removing some copy pasted code

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/2970>
2022-09-01 21:17:35 +00:00
Jianhui Dai 625e74100d v4l2allocator: Fix invalid imported dmabuf fd
Fix a typo that set userptr to dmabuf fd. It leads to failure of
dmabuf-import io-mode.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/2935>
2022-08-24 09:59:14 +00:00
Nicolas Dufresne d126f65485 v4l2bufferpool: Fix debug trace
The tracing of the buffer pointer was done on the secondary pointer, which
does not match with other traces of the same buffer. This made the trace
confusing and less useful.

Fixes #1379

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/2893>
2022-08-16 14:33:24 +00:00
fduncanh 197b72f32a v4l2object.c: add support for Apple's full-range bt709 colorspace variant
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/2793>
2022-07-26 15:14:41 +00:00
Elliot Chen e0564b04c6 v4l2: fix the critical log when unreference the buffer with no data
In the trick mode, driver may queue a valid buffer follow by an
empty buffer which has no valid data to indicate EOS.For the empty
buffer whose memory is multi-plane, need to resize it before
unreference it.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/2731>
2022-07-25 16:44:05 +08:00
Nirbheek Chauhan 41bf3f6c1b osxaudio: Fix deprecation in macOS 12.0
kAudioObjectPropertyElementMaster has been renamed to
kAudioObjectPropertyElementMain

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/2761>
2022-07-16 06:16:17 +00:00
fduncanh 735723c230 v4l2videodec: replace multiple decoder bug warnings with single one
Achieve this by dropping frames after a drain if the driver failed to so.
This works around RaspberryPi driver issue [1].

[1] https://github.com/raspberrypi/linux/issues/5059#issuecomment-

Fixes #1103

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/2518>
2022-07-02 23:56:00 +00:00
fduncanh dfeb8198e4 v4l2videodec: replace multiple decoder bug warnings by a single warning
(warning due to incorrectly dropped frames at initial caps adjustment)

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/2517>
2022-06-29 19:50:15 +00:00
Nicolas Dufresne 7c40fcb66e v4l2videodec: Fix activation of internal pool
If the driver does not support VIDIOC_CREATE_BUFS ioctl, the pool
configuration may get changed, which requires a validation. This would
fail to activate a pool in a case it shouldn't normally fail unless we
are out of memory.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/2456>
2022-06-28 16:19:53 +00:00