Commit graph

2194 commits

Author SHA1 Message Date
Mathieu Duponchelle d2299180c9 multiqueue: fix link-like syntax in doc 2020-04-28 00:33:22 +02:00
dhilshad c8bcb9db18 downloadbuffer:fix pushing buffer before stream start event
downloadbuffer source pad pushes the first buffer before pushing
Stream Start and Segment event, when working in Push mode.

Fix:Pushing Stream Start and Segment after coming out of
wait for data, and before pushing the buffer to next element.

Fixes #534
2020-04-17 15:16:18 +00:00
Vivia Nikolaidou 4679c2ed6f multiqueue: Add current-level-{buffers, bytes, time} pad properties
To get the current buffers/bytes/time levels of the corresponding
internal queue
2020-04-09 18:03:35 +03:00
Vivia Nikolaidou 74938f07c2 multiqueue: Add stats property
The returned "stats" structure contains, for now, one array called
"queues" with one GstStructure per internal queue, containing said
queue's current level of bytes, buffers, and time.
2020-04-09 17:57:43 +03:00
Vivia Nikolaidou cbdc259865 downloadbuffer, multiqueue, queue2: Fix watermark docs
It is not explicitly specified anywhere in the docs that 0% buffering is
at low-watermark and 100% buffering is at high-watermark. It was
specified only in the sources.
2020-04-06 18:19:06 +03:00
Seungha Yang 13bee5ae0c filesink: Fix for updating the index of memory to write in the next iteration
current_buf_mem_idx stands for the index of memory of the corresponding
buffer which is scheduled to be written in the next iteration.
If all memory objects were scheduled to be written in the current
iteration, reset the index to zero so that starting from the first
memory object of the next buffer.
2020-03-31 19:05:30 +09:00
Seungha Yang 5c74c8c4f8 filesink: Fix crash caused by zero-size memory allocation
If size of vector is greater than one, we are allocating zero-size
memory and trying invalid memcpy operation
2020-03-28 16:20:51 +09:00
Sebastian Dröge dcb2be3282 filesink: Add a new full buffer mode to filesink
Previously the default and full modes were the same. Now the default
mode is like before: it accumulates all buffers in a buffer list until
the threshold is reached and then writes them all out, potentially in
multiple writes.

The new full mode works by always copying memory to a single memory area
and writing everything out with a single write once the threshold is
reached.
2020-03-26 11:31:03 +00:00
Sebastian Dröge 93ffec7b2e filesink/fdsink: Write 1 iovec directly without copying if there's no writev() support 2020-03-26 11:31:03 +00:00
Sebastian Dröge c15f1b2bec fdsink/filesink: Refactor writev() code to prevent stack overflows
If buffer lists with too many buffers would be written before, a stack
overflow would happen because of memory linear with the number of
GstMemory would be allocated on the stack. This could happen for example
when filesink is configured with a very big buffer size.

Instead now move the buffer and buffer list writing into the helper
functions and at most write IOV_MAX memories at once. Anything bigger
than that wouldn't be passed to writev() anyway and written differently
in the previous code, so this also potentially speeds up writing for
these cases.

For example the following pipeline would crash with a stackoverflow:
gst-launch-1.0 audiotestsrc ! filesink buffer-size=1073741824 location=/dev/null
2020-03-26 11:31:03 +00:00
Stéphane Cerveau 0b1c2f715a identity: Fix a minor leak using meta_str 2020-03-13 12:14:08 +01:00
Sebastian Dröge 8fb1fe4620 clocksync: Use g_cond_signal() instead of g_cond_broadcast()
There can only be a single waiter: on the streaming thread.
2020-03-09 21:32:28 +02:00
Sebastian Dröge be8a15b0f9 identity: Use g_cond_signal() instead of g_cond_broadcast()
There can only be a single waiter: on the streaming thread.
2020-03-09 21:31:48 +02:00
Sebastian Dröge c7ddc5eb79 identity: Unblock condition variable on FLUSH_START
... and immediately return FLUSHING from the streaming thread instead of
waiting potentially forever.

Fixes https://gitlab.freedesktop.org/gstreamer/gstreamer/issues/516
2020-03-09 20:27:58 +02:00
Jan Schmidt 81d55fb479 clocksync: Add new clocksync element
The clocksync element is a generic element that can be
placed in a pipeline to synchronise passing buffers to the
clock at that point. This is similar to 'identity sync=true',
but because it isn't GstBaseTransform-based, it can process
GstBufferLists without breaking them into separate GstBuffers
2020-02-26 16:36:29 +00:00
Peter Seiderer afa802e4aa filesink: handle fsync interrupted by signal (EINTR)
According to [1] EINTR is a possible errno for fsync() and it happens in
reality on linux (video writing via splitmuxsink with robust muxing enabled
on a cifs mounted network share), so handle it as all other EINTR
(do/while(errno == EINTR)).

Fixes:

  GError.message: Error while writing to file "vidoe_001.mp4". GError.domain: 2372 GError.code: 10 from: FileSink debug: gstfilesink.c(849): gst_file_sink_render (): /GstPipeline:Pipeline/GstSplitMuxSink:SplitMuxSink/GstBin:QueueBin/GstFileSink:FileSink: Interrupted system call

Signed-off-by: Peter Seiderer <ps.report@gmx.net>
2019-12-12 20:49:36 +01:00
Niels De Graef 0ca0a9d982 queue2: Use g_object_notify_by_pspec
`g_object_notify()` actually takes a global lock to look up the
`GParamSpec` that corresponds to the given property name. It's not a
huge performance hit, but it's easily avoidable by using the
`_by_pspec()` variant.
2019-10-31 11:06:48 +01:00
Sebastian Dröge d25a88e3a1 tee: First deactivate the pad and then remove it when releasing pads
This reverts a96002bb28, which is not
necessary anymore. If we release the pad after removing it then none of
the deactivation code will actually be called because the pad has no
parent anymore, and we require a parent on the pad for deactivation to
happen.

This can then, among other things, cause a streaming thread to be still
stuck in a pad probe because the pad was never flushed, and waiting
there forever because now the pad will actually never be flushed anymore.
2019-10-24 22:49:41 +00:00
Sebastian Dröge 7f7da6a0d0 tee: Check for the removed pad flag also in the slow pushing path
If a pad is currently being released we don't want to forward the
FLUSHING flow return but instead consider it as NOT_LINKED. FLUSHING
would also cause upstream to be FLUSHING.

This part was missed in a3c4a3201a and
resulted in a different (and wrong) workaround in
a96002bb28.
2019-10-24 22:49:41 +00:00
Sebastian Dröge aa29864317 tee: Lock mutex before reading the removed flag of the pads
Otherwise we're not guaranteed to read the very latest value that
another thread might've written in there when the pad was released, and
could instead work with an old value.
2019-10-24 22:49:41 +00:00
Tim-Philipp Müller 10d9e18f02 Remove autotools build system 2019-10-13 16:10:42 +01:00
Xavier Claessens d109dd2752 dataurisrc: Do not include trailing \0 into buffer 2019-10-07 17:47:47 +00:00
Aaron Boxer 509f6201e1 documentation: fix a number of typos 2019-10-06 11:12:11 -04:00
Niels De Graef 4812c4087f Don't pass default GLib marshallers for signals
By passing NULL to `g_signal_new` instead of a marshaller, GLib will
actually internally optimize the signal (if the marshaller is available
in GLib itself) by also setting the valist marshaller. This makes the
signal emission a bit more performant than the regular marshalling,
which still needs to box into `GValue` and call libffi in case of a
generic marshaller.

Note that for custom marshallers, one would use
`g_signal_set_va_marshaller()` with the valist marshaller instead.
2019-09-09 12:16:24 +00:00
Jim Mason a4aa2256d1 consolidated IOV_MAX/UIO_MAXIOV handling per GLib + legacy behaviour for osx/ios 2019-09-07 12:32:40 +01:00
Jim Mason dc5250e751 gst_writev: respect IOV_MAX for the writev iovec array #439 2019-09-06 19:23:01 +01:00
Matthew Waters 43622119bb file/fdsrc: use struct stat64 on android to match stat64()
Fixes android werror failures:

../plugins/elements/gstfdsrc.c:244:25: error: incompatible pointer types passing 'struct stat *' to parameter of type 'struct stat64 *' [-Werror,-Wincompatible-pointer-types]
    if (fstat (src->fd, &stat_results) < 0)
                        ^~~~~~~~~~~~~
/home/matt/Projects/cerbero/build/android-ndk-18/sysroot/usr/include/sys/stat.h:159:38: note: passing argument to parameter '__buf' here
int fstat64(int __fd, struct stat64* __buf) __RENAME_STAT64(fstat, 3, 21);
                                     ^
../plugins/elements/gstfdsrc.c:560:23: error: incompatible pointer types passing 'struct stat *' to parameter of type 'struct stat64 *' [-Werror,-Wincompatible-pointer-types]
  if (fstat (src->fd, &stat_results) < 0)
                      ^~~~~~~~~~~~~
/home/matt/Projects/cerbero/build/android-ndk-18/sysroot/usr/include/sys/stat.h:159:38: note: passing argument to parameter '__buf' here
int fstat64(int __fd, struct stat64* __buf) __RENAME_STAT64(fstat, 3, 21);
                                     ^

  if (fstat (fd, &stat_results) < 0)
                 ^~~~~~~~~~~~~
/home/matt/Projects/cerbero/build/android-ndk-18/sysroot/usr/include/sys/stat.h:159:38: note: passing argument to parameter '__buf' here
int fstat64(int __fd, struct stat64* __buf) __RENAME_STAT64(fstat, 3, 21);
                                     ^

  if (fstat (src->fd, &stat_results) < 0)
                      ^~~~~~~~~~~~~
../../../../../android-ndk-18/sysroot/usr/include/sys/stat.h:159:38: note: passing argument to parameter '__buf' here
int fstat64(int __fd, struct stat64* __buf) __RENAME_STAT64(fstat, 3, 21);
                                     ^
../plugins/elements/gstfilesrc.c:477:23: error: incompatible pointer types passing 'struct stat *' to parameter of type 'struct stat64 *' [-Werror,-Wincompatible-pointer-types]
  if (fstat (src->fd, &stat_results) < 0)
                      ^~~~~~~~~~~~~
../../../../../android-ndk-18/sysroot/usr/include/sys/stat.h:159:38: note: passing argument to parameter '__buf' here
int fstat64(int __fd, struct stat64* __buf) __RENAME_STAT64(fstat, 3, 21);
                                     ^
2019-08-28 15:46:33 +10:00
Mathieu Duponchelle 3f93290151 funnel: fix documentation
funnel no longer sends its own segment since:

bbb26f8756

Update the documentation to reflect that
2019-08-06 13:30:12 +00:00
Alicia Boya García b50abd9f4e downloadbuffer: Check for flush after seek
In gst_download_buffer_wait_for_data(), when a seek is made with
perform_seek_to_offset() the `qlock` is released temporarily. Therefore,
the flushing condition can be set during this period and should be
checked.

This was not being checked before, causing occasional deadlocks when
GST_DOWNLOAD_BUFFER_WAIT_ADD_CHECK() was called.

GST_DOWNLOAD_BUFFER_WAIT_ADD_CHECK() assumes that the caller has already
checked that we're not flushing before, since this is done when
acquiring the lock; so if we release it temporarily somewhere, we need
to check for flush again.

Without that check, the function would keep waiting for the condition
variable to be notified before checking for flushing condition again,
and that may very well never happen. This was reproduced when during pad
deactivation when running WebKit in gdb.
2019-07-22 15:06:20 +00:00
Nicolas Dufresne 86b9f78788 identity: Non-live upstream have no max latency
sync=TRUE implementation changes the latency query of a non-live
upstream into live, though it wrongly set the upstream max latency to 0.
As non-live sources won't loose data if we wait longer, this should have
been reported as have no max latency limite (-1).
2019-07-19 22:12:29 -04:00
Philippe Normand be56bd9aff identity: Fix the ts-offset property getter
Previous code was a copy/paste from the property setter function.
2019-07-11 17:53:53 +01:00
Thibault Saunier 7a2d32abda multiqueue: Fix possible NULL pointer dereferencing
In the hotdoc inspector for example, pads are instantiated with
g_object_new, other code paths to get/set properties already make
that check.

And update doc cache
2019-07-02 17:27:32 -04:00
Thibault Saunier 27fbaf9d44 multiqueue: Hold weak references to pads/multiqueue in SingleQueue
Without holding a ref we have no guarantees that the SingleQueue
doesn't have dangling pointers on those objects during its destruction.
2019-06-28 15:30:54 -04:00
Thibault Saunier 6a20fcc97a multiqueue: Stop using the gst_pad_element_private API
There was a race where we could still get the pad event function
called when its private member were already unset, leading to
a segfault in the event handler:

```
0  gst_multi_queue_src_event (pad=<optimized out>, parent=<optimized out>, event=0x7f3ff0007600) at ../subprojects/gstreamer/plugins/elements/gstmultiqueue.c:2534
2534          ret = gst_pad_push_event (sq->sinkpad, event);
[Current thread is 1 (Thread 0x7f406c0258c0 (LWP 21925))]
(gdb) bt
0  0x00007f4062ec1399 in gst_multi_queue_src_event (pad=<optimized out>, parent=<optimized out>, event=0x7f3ff0007600 [GstEvent]) at ../subprojects/gstreamer/plugins/elements/gstmultiqueue.c:2534
1  0x00007f406b40f46d in gst_validate_pad_monitor_src_event_check (handler=0x7f4062ec1360 <gst_multi_queue_src_event>, event=0x7f3ff0007600 [GstEvent], parent=0x7f3fcc01f090 [GstMultiQueue|multiqueue167], pad_monitor=0x7f3fe809e7c0 [GstValidatePadMonitor|validatepadmonitor2213]) at ../subprojects/gst-devtools/validate/gst/validate/gst-validate-pad-monitor.c:2101
2  0x00007f406b40f46d in gst_validate_pad_monitor_src_event_func (pad=<optimized out>, parent=0x7f3fcc01f090 [GstMultiQueue|multiqueue167], event=0x7f3ff0007600 [GstEvent]) at ../subprojects/gst-devtools/validate/gst/validate/gst-validate-pad-monitor.c:2374
3  0x00007f406b904387 in gst_pad_send_event_unchecked (pad=pad@entry=0x7f3fdc027650 [GstPad|src_0], event=event@entry=0x7f3ff0007600 [GstEvent], type=<optimized out>, type@entry=GST_PAD_PROBE_TYPE_EVENT_UPSTREAM) at ../subprojects/gstreamer/gst/gstpad.c:5772
4  0x00007f406b90481b in gst_pad_push_event_unchecked (pad=pad@entry=0x7f4058182fc0 [GstPad|sink], event=event@entry=0x7f3ff0007600 [GstEvent], type=type@entry=GST_PAD_PROBE_TYPE_EVENT_UPSTREAM) at ../subprojects/gstreamer/gst/gstpad.c:5417
5  0x00007f406b90f016 in gst_pad_push_event (pad=0x7f4058182fc0 [GstPad|sink], event=event@entry=0x7f3ff0007600 [GstEvent]) at ../subprojects/gstreamer/gst/gstpad.c:5554
6  0x00007f406a1c99ba in gst_video_decoder_src_event_default (decoder=0x7f3fe81c6060 [GstTheoraDec|theoradec46], event=<optimized out>) at ../subprojects/gst-plugins-base/gst-libs/gst/video/gstvideodecoder.c:1532
7  0x00007f406b40f46d in gst_validate_pad_monitor_src_event_check (handler=0x7f406a1ca270 <gst_video_decoder_src_event>, event=0x7f3ff0007600 [GstEvent], parent=0x7f3fe81c6060 [GstTheoraDec|theoradec46], pad_monitor=0x7f4028163aa0 [GstValidatePadMonitor|validatepadmonitor2216]) at ../subprojects/gst-devtools/validate/gst/validate/gst-validate-pad-monitor.c:2101
8  0x00007f406b40f46d in gst_validate_pad_monitor_src_event_func (pad=<optimized out>, parent=0x7f3fe81c6060 [GstTheoraDec|theoradec46], event=0x7f3ff0007600 [GstEvent]) at ../subprojects/gst-devtools/validate/gst/validate/gst-validate-pad-monitor.c:2374
```

This make the GstSingleQueue a MiniObject, mainly so it is properly
refcounted.

This also make use of the GstMultiQueuePad class for srcpads which
is totally valid as srcpads and sinkpads share the same SingleQueue
object.
2019-06-25 12:53:05 -04:00
Guillaume Desmottes f2d37d5132 gstelements_private: sync gst_buffer_get_flags_string() with new flags 2019-06-20 13:49:14 +05:30
Thibault Saunier eaa39398cc multiqueue: never unref queries we do not own
The `query` argument of gst_pad_query is "transfer none".

Query objects are "borrowed" by the pad query handlers and those
should never unref them.

This was leading to double freed queries in a very racy way with nested
GESTimelines.
2019-06-20 00:19:24 -04:00
Håvard Graff 3260b2f630 queue: don't report 0 max-latency for leaky queue if max was already 0. 2019-06-13 15:21:03 +00:00
Sebastian Dröge aaa4353368 concat: Improve debug output a bit 2019-06-05 01:12:42 +00:00
Sebastian Dröge 584c4c6282 concat: Reset last_stop on FLUSH_STOP too
Otherwise when seeking backwards we would keep the last_stop at the last
position we saw until playback passed the seek position again, and if
switching to the next pad happens in the meantime we would set the wrong
offset in the outgoing segment.
2019-06-05 01:12:42 +00:00
Mathieu Duponchelle ca17a6c791 doc: remove xml from comments 2019-05-29 21:33:42 +02:00
Benjamin Otte 73f6f466c2 dataurisrc: Fix crash when semicolon is aprt of data
This URI is valid:
  data:,;base64
(It encodes the literal string ";base64")

But would lead to a crash because the code assumed the semicolon would
be placed before the colon.
2019-05-21 17:22:04 +02:00
Benjamin Otte 3c2312ce6b dataurisrc: Allow case-insensitive scheme
Quoting RFC 2396:

  For resiliency, programs interpreting URI should treat upper case
  letters as equivalent to lower case in scheme names (e.g., allow
  "HTTP" as well as "http").
2019-05-21 17:15:52 +02:00
Sebastian Dröge eec9bd8db3 filesink: Implement workaround for some (network) filesystems that spuriously return EACCES on write
This seems to happen when another client is accessing the file at the
same time, and retrying after a short amount of time solves it.

Sometimes partial data is written at that point already but we have no
idea how much it is, or if what was written is correct (it sometimes
isn't) so we always first seek back to the current position and repeat
the whole failed write.

It happens at least on Linux and macOS on SMB/CIFS and NFS file systems.

Between write attempts that failed with EACCES we wait 10ms, and after
enough consecutive tries that failed with EACCES we simply time out.

In theory a valid EACCES for files to which we simply have no access
should've happened already during the call to open(), except for NFS
(see open(2)).

This can be enabled with the new max-transient-error-timeout property, and
a new o-sync boolean property was added to open the file in O_SYNC mode
as without that it's not guaranteed that we get EACCES for the actual
writev() call that failed but might only get it at a later time.

Fixes https://gitlab.freedesktop.org/gstreamer/gstreamer/issues/305
2019-05-16 14:15:02 +03:00
Thibault Saunier a0c65067e0 Port to hotdoc 2019-05-13 16:34:09 -04:00
Thibault Saunier 5b2da0835e doc: Fix and add some missing docstrings 2019-05-13 11:33:49 -04:00
Jonny Lamb 63170d52ae identity: fixes to the eos-after and error-after properties
I copied `error-after` to make the `eos-after` property, but it turned
out there were some problems with that one, so this patch: adds
separate counters (so setting to NULL and reusing the element will
still work); clarifies the properties' min values; and reports an
error when both are set.
2018-12-18 22:55:28 +00:00
Edward Hervey 1bca404191 queue2: Add details of query in debug log 2018-12-17 09:41:45 +01:00
Jonny Lamb 460c0edbfb identity: add eos-after property
Using `num-buffers` can be unpredictable as buffer sizes are often
arbitrary (filesrc, multifilesrc, etc.). The `error-after` property on
`identity` is better but obviously reports an error afterwards. This
adds `eos-after` which does exactly the same thing but reports EOS
instead.
2018-12-11 21:14:11 +00:00
Philippe Normand 9f5e65f0a2 input-selector: Let context queries pass through
By doing so GL source elements can successfully reuse the GL context and display
of downstream elements. This change fixes an issue in playbin when using
gltestsrc where the context query made by the source element would fail and the
source element would create a second (useless) GLDisplay.
2018-11-28 11:00:21 +00:00
Jordan Petridis 84512152c1
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:58:53 +02:00