Commit graph

54 commits

Author SHA1 Message Date
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
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
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
Nicolas Dufresne
462800e9c6 v4l2videodec: Keep part of the input buffer
Instead of completely getting rid of the input buffer, copy
the metadata, the flags and the timestamp into an empty buffer.
This way the decoder base class can copy that information again
to the output buffer.

https://bugzilla.gnome.org/show_bug.cgi?id=758424
2016-06-07 17:03:40 -04:00
Nicolas Dufresne
a0a590369a v4l2videodec: Coding style fixes 2016-06-07 17:02:47 -04:00
Nicolas Dufresne
3b5cac3659 v4l2: Add an error return to _try/_set_format
This way one can easily ignore errors. Previously, error were always
posted ont he bus.

https://bugzilla.gnome.org/show_bug.cgi?id=766172
2016-06-07 17:02:43 -04:00
Philipp Zabel
96d82357f2 v4l2videodec: use decoder stop command instead of queueing empty buffers
Only if the decoder stop command fails, keep queueing empty buffers to
signal end of stream as before.

https://bugzilla.gnome.org/show_bug.cgi?id=733864
2016-06-07 10:49:43 -04:00
Peter Seiderer
ddf7d9d6de v4l2videodec: add gst_v4l2_decoder_cmd helper
https://bugzilla.gnome.org/show_bug.cgi?id=733864
2016-06-07 10:49:43 -04:00
Philipp Zabel
1f31715c98 v4l2videodec: use visible size, not coded size, for downstream negotiation filter
gst_v4l2_probe_caps() returns the coded size, not the visible size. Subtract
the known padding from probed caps with the coded size before using them as
filter for caps negotiation with downstream elements.

https://bugzilla.gnome.org/show_bug.cgi?id=766382
2016-06-06 17:35:47 -04:00
Tim-Philipp Müller
30a3551163 v4l2src: fix indentation 2016-02-19 15:03:41 +00:00
Philipp Zabel
c75a69d415 v4l2: videodec: choose format from caps
https://bugzilla.gnome.org/show_bug.cgi?id=733827
2015-11-25 14:32:28 -05:00
Nicolas Dufresne
4ecd25d267 v4l2: Fix capture/output-io-mode properties
There was some miss-match in the implementation. This makes it
concistent, though functionally it worked, except the video decoder
output-io-mode getter.
2015-11-19 15:35:36 -05:00
Nicolas Dufresne
f3f4bdd676 v4l2videodec: Proxy getcaps
Replace the sink_query with new getcaps() virtual and use the proxy
helper with the probed caps. This allow upstream element taking decision
base on what is supported downstream.
2015-01-13 16:55:43 -05:00
Nicolas Dufresne
5c67ba7f88 v4l2videodec: Prevent renegotiation
Renegotiation isn't supported, simply prevent it the way we do in
v4l2src.
2015-01-09 16:59:53 -05:00
Nicolas Dufresne
c4aaff5c92 v4l2videodec: Don't unlock the stream lock twice 2015-01-09 16:55:55 -05:00
Nicolas Dufresne
b9992e4347 v4l2: Handle corrupted buffer with empty payload
This allow skipping buffer flagged with ERROR that has no payload.
This is typical behaviour when a recovererable error occured during
capture in the driver, but that no valid data was ever written into that
buffer. This patch also translate V4L2_BUF_FLAG_ERROR into
GST_BUFFER_FLAG_CORRUPTED. Hence decoding error produce
by decoder due to missing frames will now be correctly marked. Finally,
this fixes a buffer leak when EOS is reached.

https://bugzilla.gnome.org/show_bug.cgi?id=740040
2014-11-21 11:29:19 -05:00
Nicolas Dufresne
743c6a4475 v4l2: Merge min_buffers_for* variable into one
Reuse the same min_buffers variable for both capture and output, this
reduce the length of lines and make the code more readable.

https://bugzilla.gnome.org/show_bug.cgi?id=736072
2014-09-09 18:39:23 -04:00
Nicolas Dufresne
e2fd7e274e v4l2bufferpool: Port to bufferpool flush_start/stop method
Port the buffer pool to use the new flush_start/flush_stop virtual
methods added to GstBufferPool.

https://bugzilla.gnome.org/show_bug.cgi?id=727611
2014-05-26 13:43:30 -04:00
Nicolas Dufresne
2e89f4ecff Revert "v4l2bufferpool: Port to bufferpool flush_start/stop method"
This reverts commit 2e0fb42e86.

Conflicts:
	sys/v4l2/gstv4l2allocator.c
	sys/v4l2/gstv4l2bufferpool.c
	sys/v4l2/gstv4l2videodec.c
2014-05-24 20:00:14 -04:00
Nicolas Dufresne
57726911f8 v4l2videodec: don't stop if loop returned FLUSHING
The decodeing thread returning flushing isn't an error, we should simply
try starting the task again. If it's actually flushing, it will stop again by itself.
2014-05-24 15:38:53 -04:00
Nicolas Dufresne
3acbd9cb99 v4l2videodec: Handle early task stop 2014-05-24 15:38:53 -04:00
Nicolas Dufresne
a65ab6378d v4l2videodec: Handle gst_pad_start_task() failure 2014-05-24 15:38:53 -04:00
Nicolas Dufresne
1e48ad8fa8 v4l2videodec: Add trace for FLUSH_START/STOP handling 2014-05-24 15:38:53 -04:00
Nicolas Dufresne
c9dcc63eb8 v4l2videodec: Fix use of atomic value 2014-05-24 15:38:53 -04:00
Nicolas Dufresne
03ed348d95 v4l2videodec: Fix handle_frame error handling 2014-05-24 15:38:53 -04:00
Nicolas Dufresne
2e0fb42e86 v4l2bufferpool: Port to bufferpool flush_start/stop method 2014-05-24 15:38:53 -04:00
Nicolas Dufresne
7df99f7469 v4l2videodec: Handle flush while in start_streaming
We need to handle the case where a flush occure while the streaming
thread is being brought up. In this case, the flushing state of the poll
object is cleared. To solve this, we simply set the capture poll to flushing
again, this way we know the thread will exit. The decoder streamlock
is used to synchronize with handle frame.
2014-05-16 21:49:00 -04:00
Nicolas Dufresne
077fcbcf15 v4l2: Cleanup M2M properties
M2M devices were sharing the same properties as src and sink. Most of
these made no sense. This patch reduces the number of propeties and
makes io-mode clearer by having capture-io-mode and output-io-mode. This
also accidently fixed a bug in gstv4l2transform io-mode code, where the
capture io-mode could not be set.

https://bugzilla.gnome.org/show_bug.cgi?id=729591
2014-05-15 19:06:52 -04:00
Nicolas Dufresne
541a9670d2 v4l2videodec: Handle start_streaming error
https://bugzilla.gnome.org/show_bug.cgi?id=730207
2014-05-15 12:22:04 -04:00
Nicolas Dufresne
bff156bc57 v4l2videodec: Print the flow return causing the loop to leave
https://bugzilla.gnome.org/show_bug.cgi?id=730207
2014-05-15 12:21:59 -04:00
Nicolas Dufresne
f384047be3 v4l2videodec: Don't lock the decoder when stopping task
That src pad task may need to take the lock when being pulled
down. takeing that lock can lead to a deadlock.

https://bugzilla.gnome.org/show_bug.cgi?id=730207
2014-05-15 12:21:54 -04:00
Nicolas Dufresne
a4b5811d22 v4l2: Split flush in start/stop_streaming
This allow calling start streaming later for capture device. Currently it breaks
in dmabuf-import because downstream is holding a buffer that will only be
released after stream-start.

https://bugzilla.gnome.org/show_bug.cgi?id=730207
2014-05-15 12:21:44 -04:00
Nicolas Dufresne
82a806e63b v4l2: Replace miss-use of crop meta in favour of proper offset
This moves away from copying information and store everything inside
the GstVideoInfo structure. The alignement exposed by v4l2 api
is now handled using proper offset.
2014-05-08 15:56:37 -04:00
Nicolas Dufresne
815c9b7d35 v4l2bufferpool: Acquire cannot return a buffer from another pool
Return a buffer from an otherpool has unwanted side effects that lead to leaks and
prevents deactivating the pool. Instead, we change the _process() API so it can
replace the internal buffer with the buffer from the downstream pool. This implied
moving from _fill() to _create() method in the src.
2014-05-08 15:56:37 -04:00
Nicolas Dufresne
a89986ebd5 v4l2videodec: Ensure pool is configured 2014-05-08 15:56:36 -04:00
Nicolas Dufresne
cf788c9ec7 v4l2videodec: Install PROP_CAPTURE_IO_MODE with right ID 2014-05-08 15:56:36 -04:00
Nicolas Dufresne
8d6e72a299 v4l2: Move capture eos handling in _process()
Now that we might be copying out buffer (e.g. downstream don't support video
meta bug we need it) we need to move the EOS handling inside the process
method.
2014-05-08 15:56:35 -04:00
Nicolas Dufresne
a6a8c2b5eb v4l2videodec: Cleanly fail if set_format is never called 2014-05-08 15:56:35 -04:00
Nicolas Dufresne
e9eba56cd3 v4l2videodec: Ensure internal pool are activated 2014-05-08 15:56:35 -04:00
Nicolas Dufresne
a8024fef04 v4l2videodec: Check that pool where allocated before flushing them
Upon error, the pools might not have been allocated yet, hence we should not
try and flush them (even though we still want to make sure the processing thread
is fully stopped).
2014-05-08 15:56:35 -04:00
Nicolas Dufresne
70e7868f18 v4l2object: Rename setup_format() method into acquire_format()
The setup_format() was confusing since it does not set anything, in fact
it reads the setup from the driver and save it.
2014-05-08 15:56:35 -04:00
Nicolas Dufresne
b4d89b9809 v4l2videodec: Protect NULL pool while going to READY
When the pipeline fails early, the pool might be unset before the processing
thread has run once. Add protection against that.
2014-05-08 15:56:35 -04:00
Nicolas Dufresne
7e379e8fff v4l2videodec: Clear the input state pointer after unref
If caps are set again, we have a risk od returning from set_format with a
input_state pointing to dead memory. Clearing the pointer after unref fix
this issue.
2014-05-08 15:56:35 -04:00
Nicolas Dufresne
7101c4341a v4l2videodec: handle stop being called without flush
Uppon certain downstream error, stop() is called without a flush(). This mean that
the streaming thread may still be running even though unlock has been called.
Now calling flush to reset the decoder state if we are processing.
2014-05-08 15:56:35 -04:00
Nicolas Dufresne
fb852669de v4l2videodec: Default to template in caps query 2014-05-08 15:56:35 -04:00
Nicolas Dufresne
27a617d75f v4l2videodec: Ensure processing thread has stopped when draining 2014-05-08 15:56:35 -04:00
Nicolas Dufresne
6f48c74f2a v4l2videodec: Don't drain if processing thread is inactive 2014-05-08 15:56:35 -04:00
Nicolas Dufresne
aa74871080 v4l2: Use single pass iterator for M2M probe
Instead of having each M2M class do their own probing, use the
GstV4l2Iterator and probe all devices in a single pass.

https://bugzilla.gnome.org/show_bug.cgi?id=727925
2014-05-03 23:11:35 -04:00
Nicolas Dufresne
f7d34bd237 v4l2videodec: Simplify sub-instanciation mechanism
Simplify sub-instanciation by defining an absract type and using subtype
class and instance init callback. This also fixes a bug where the template
pads get initialized too late.

https://bugzilla.gnome.org/show_bug.cgi?id=727925
2014-05-03 23:11:34 -04:00