Commit graph

2290 commits

Author SHA1 Message Date
Mathieu Duponchelle
ae57b1c76d aggregator: add buffer-consumed pad signal
The signal will be emitted when a buffer was consumed on
a pad, if the newly-added "emit-signals" property has been
set to TRUE.

Handlers connected to the signal will receive a valid reference on
the consumed buffer, allowing for example the retrieval of metas in
order to forward them once an output buffer is pushed out.
2019-04-05 12:13:54 +00:00
Tim-Philipp Müller
cef902814d bitwriter: mark as 'skip' for gobject-introspection
Silences g-ir-scanner warnings. We do the same for ByteWriter.
2019-03-23 17:53:07 +00:00
Matthew Waters
c6691abba1 aggregator: don't leak gap buffer when out of segment 2019-03-21 19:18:46 +11:00
Matthew Waters
619dfc91bb aggregator: take the pad lock around queue gap event removal
As is done for every other queue interaction
2019-03-21 19:18:46 +11:00
Matthew Waters
b8d00b9e6e baseparse: don't reset the disable-passthrough property value
Resetting as a result of _reset() on PAUSED->READY is unexpected.
2019-03-20 17:44:30 +11:00
Tim-Philipp Müller
41d5f22334 aggregator: fix typo in docs 2019-01-05 18:55:12 +00:00
Tim-Philipp Müller
33267b2ecc basesrc: ensure submitted buffer list is writable
Fixes flaky appsrc unit test where depending on scheduling
the submitted list might not be writable if submitted via
an action signal from the application thread.

Fixes gst-plugins-base#522
2018-12-19 00:34:40 +00:00
KimTaeSoo
bf1979e55f baseparse: Use buffer from short reads instead of pulling again
baseparse internally uses a 64kb buffer for pulling data from upstream.
If a 64kb pull is failing with a short read, it would previously pull
again the requested size.

Doing so is not only inefficient but also seems to cause problems with
some elements (rawvideoparse) where the second pull would fail with EOS.

Short reads are only allowed in GStreamer at EOS.

Closes https://gitlab.freedesktop.org/gstreamer/gstreamer/issues/294
2018-11-28 17:38:58 +02:00
Thomas Bluemel
36ab067905 clock: Keep weak reference to underlying clock
Fixes potential segmentation fault when using a GstClockID that
is referencing an already freed GstClock

Fixes https://gitlab.freedesktop.org/gstreamer/gstreamer/issues/187
2018-11-03 19:00:22 +02:00
Sebastian Dröge
fc3602aec8 queuearray: Only clear dropped item if it is not returned 2018-10-15 18:47:16 +03:00
Sebastian Dröge
2481e542c7 queuearray: Clear items when dropping them and a clear function was defined 2018-10-15 15:28:35 +03:00
Tim-Philipp Müller
135932872e aggregator: document new "min-upstream-latency" property is in nanosecs
https://bugzilla.gnome.org/show_bug.cgi?id=797213
2018-10-04 00:30:52 +01:00
Vivia Nikolaidou
22d0f40716 queuearray: Add set_clear_func and clear functions
gst_queue_array_clear will clear the GstQueueArray,
gst_queue_array_set_clear_func will set a clear function for each
element to be called on _clear and on _free.

https://bugzilla.gnome.org/show_bug.cgi?id=797218
2018-09-27 19:32:54 +03:00
Mathieu Duponchelle
62d7eaf3aa aggregator: add gtk-doc blurb for new min-upstream-latency prop 2018-09-27 13:20:10 +02:00
Mathieu Duponchelle
97e2e7a63d aggregator: add min-upstream-latency property.
This is exposed as a solution to the use case of plugging in
sources with a higher latency after the aggregator has started
playing with an initial set of sources, allowing to avoid resyncing.

https://bugzilla.gnome.org/show_bug.cgi?id=797213
2018-09-27 12:56:47 +02:00
Tim-Philipp Müller
57c8e0146f libs: figure out right export define in configure
Add new GST_API_EXPORT in config.h and use that for GST_*_API
decorators instead of GST_EXPORT.

The right export define depends on the toolchain and whether
we're using -fvisibility=hidden or not, so it's better to set it
to the right thing directly than hard-coding a compiler whitelist
in the public header.

We put the export define into config.h instead of passing it via the
command line to the compiler because it might contain spaces and brackets
and in the autotools scenario we'd have to pass that through multiple
layers of plumbing and Makefile/shell escaping and we're just not going
to be *that* lucky.

The export define is only used if we're compiling our lib, not by external
users of the lib headers, so it's not a problem to put it into config.h

Also, this means all .c files of libs need to include config.h
to get the export marker defined, so fix up a few that didn't
include config.h.

This commit depends on a common submodule commit that makes gst-glib-gen.mak
add an #include "config.h" to generated enum/marshal .c files for the
autotools build.

https://bugzilla.gnome.org/show_bug.cgi?id=797185
2018-09-24 08:39:37 +01:00
Tim-Philipp Müller
46ed0f0489 libs: fix 'inconsistent DLL linkage' warnings on Windows
For each lib we build export its own API in headers when we're
building it, otherwise import the API from the headers.

This fixes linker warnings on Windows when building with MSVC.

The problem was that we had defined all GST_*_API decorators
unconditionally to GST_EXPORT. This was intentional and only
supposed to be temporary, but caused linker warnings because
we tell the linker that we want to export all symbols even
those from externall DLLs, and when the linker notices that
they were in external DLLS and not present locally it warns.

What we need to do when building each library is: export
the library's own symbols and import all other symbols. To
this end we define e.g. BUILDING_GST_FOO and then we define
the GST_FOO_API decorator either to export or to import
symbols depending on whether BUILDING_GST_FOO is set or not.
That way external users of each library API automatically
get the import.

https://bugzilla.gnome.org/show_bug.cgi?id=797185
2018-09-23 23:23:01 +01:00
Mathieu Duponchelle
17798bca6d aggregator: define autoptr cleanup functions 2018-09-20 16:22:17 +02:00
Philippe Normand
d7c87910c2 baseparse: avg_bitrate calculation critical warning fix
The avg_bitrate is an unsigned int, so the gst_util_uin64_scale() function can't
be used for it, as it expects signed integers for the fraction parts arguments.

https://bugzilla.gnome.org/show_bug.cgi?id=797054
2018-08-31 15:35:35 +01:00
Nirbheek Chauhan
c389c59b22 meson: Maintain macOS ABI through dylib versioning
Requires Meson 0.48, but the feature will be ignored on older versions
so it's safe to add it without bumping the requirement.

Documentation:
https://github.com/mesonbuild/meson/blob/master/docs/markdown/Reference-manual.md#shared_library
2018-08-31 14:40:14 +05:30
Tim-Philipp Müller
f7b5151b58 bitwriter: fix compiler warning
Don't return a value from a function that doesn't
return a value using the returned value from a
function that also doesn't return a value.

gstbitwriter.h(265): warning C4098: 'gst_bit_writer_align_bytes_unchecked': 'void' function returning a value
2018-08-26 11:45:58 +02:00
Sebastian Dröge
49d212e908 aggregator: Fixup for previous commit to prevent infinite loop if no events are pending 2018-08-14 12:30:19 +03:00
Sebastian Dröge
08bd835f09 aggregator: Return an error directly if negotiation of a sink pad failed
And don't give buffers to subclasses in that case.

https://bugzilla.gnome.org/show_bug.cgi?id=796951
2018-08-14 10:23:23 +03:00
Tim-Philipp Müller
88bd7c61a7 bitwriter: fix g-i scanner warning
gstbitwriter.h:45: Warning: GstBase: "@bit_capacity" parameter unexpected at this location:
 * @bit_capacity: Capacity of the allocated @data
2018-08-12 20:07:02 +01:00
Sebastian Dröge
c31ef7fa51 typefindhelper: Mark gst_type_find_helper_get_range_full() as Since 1.14.3 2018-08-02 10:57:28 +03:00
Sebastian Dröge
41f1a40704 typefind: Add new gst_type_find_helper_get_range_full() that returns flow return
And make use of it in the typefind element. It's useful to distinguish
between the different errors why typefinding can fail, and especially to
not consider GST_FLOW_FLUSHING as an actual error.

https://bugzilla.gnome.org/show_bug.cgi?id=796894
2018-08-01 14:23:04 +03:00
Mathieu Duponchelle
27f53141e2 aggregator: annotate GstAggregatorClass::update_src_caps 2018-07-27 23:22:59 +02:00
Sebastian Dröge
a569347789 aggregator: Don't leak peer pad of inactive pads when (not) forwarding QoS events to them 2018-07-26 02:32:57 +03:00
Sebastian Dröge
7bee79426d typefindhelper: Mark extension in gst_type_find_helper_get_range() as allow-none
It always allowed NULL and even said so in the documentation.
2018-07-25 01:12:49 +03:00
Sebastian Dröge
d196b0b904 typefind: Add _with_extension() variants for typefinding data or a buffer
And make use of that in the typefind element to also be able to make use
of the extension in push mode. It previously only did that in pull mode
and this potentially speeds up typefinding and might also prevent false
positives.

https://bugzilla.gnome.org/show_bug.cgi?id=796865
2018-07-25 01:12:11 +03:00
Thibault Saunier
1f3ef7aa01 basetransform: Do not check if NULL is an emtpy caps
gst_base_transform_transform_caps can return NULL in various conditions
thus we should not treat its result as valid caps.

In all other places NULL is properly handled.
2018-07-18 21:18:56 -04:00
Olivier Crête
4f3aea316a sink: Only add processing latency if upstream is live
Only add it if upstream is live, otherwise leave the latency at 0.

https://bugzilla.gnome.org/show_bug.cgi?id=640610
2018-07-16 13:04:44 -04:00
Thibault Saunier
b4d93abb24 basesink: Minor GI warning fix. 2018-07-13 08:52:55 -04:00
Olivier Crête
a7f9c80220 basesink: Add processing deadline
The processing deadline is the acceptable amount of time to process the media
in a live pipeline before it reaches the sink. This is on top of the algorithmic
latency that is normally reported by the latency query. This should make
pipelines such as "v4lsrc ! xvimagesink" not claim that all frames are late
in the QoS events. Ideally, this should replace max_lateness for most applications.

https://bugzilla.gnome.org/show_bug.cgi?id=640610
2018-07-07 09:05:26 -04:00
Tim-Philipp Müller
2db8e3705f Update for g_type_class_add_private() deprecation in recent GLib
https://gitlab.gnome.org/GNOME/glib/merge_requests/7
2018-06-24 12:49:14 +02:00
Edward Hervey
d34f046029 baseparse: Ensure seqnum consistency
We need all relevant events of a segment to have consistent seqnum:
* GST_EVENT_SEGMENT
* GST_EVENT_EOS

If we are push-based and create a new segment, use the same seqnum
as the upstream event.

If we are pull-based, use the seqnum of that newly created segment
event everywhere
2018-06-05 17:02:18 +02:00
Mike Wey
51b97d7403 dataqueue: add some missing introspection annotations
https://bugzilla.gnome.org/show_bug.cgi?id=796488
2018-06-03 19:42:17 +01:00
Edward Hervey
dfe5467209 baseparse: Documentation improvements
* Remove references to old functions and methods
* Use proper #ClassName.vmethod() decorator for vmethod
2018-05-30 14:06:06 +02:00
Olivier Crête
05298b3093 aggregator: Add get_next_time function for live streams
Add a function to do the right thing for live streams.

https://bugzilla.gnome.org/show_bug.cgi?id=795486
2018-05-16 18:13:04 +02:00
Seungha Yang
69ddcc175f bitwriter: Fix build error
Fix implicit-function-declaration warning for meemst and memcpy

gstbitwriter.h:166:3: error: implicit declaration of function ‘memset’
   memset (bitwriter->data + clear_pos, 0, (new_bit_size >> 3) - clear_pos);
   ^

https://bugzilla.gnome.org/show_bug.cgi?id=795867
2018-05-07 08:35:47 +02:00
Wind Yuan
fb4fc8fc09 bitwriter: Add a generic bit writer
GstBitWriter provides a bit writer that can write any number of
bits into a memory buffer. It provides functions for writing any
number of bits into 8, 16, 32 and 64 bit variables.

https://bugzilla.gnome.org/show_bug.cgi?id=707543
2018-05-06 17:05:21 +02:00
Tim-Philipp Müller
583a4677af aggregator: since marker for new API
Was also backported.

https://bugzilla.gnome.org/show_bug.cgi?id=795332
2018-05-05 12:10:39 +02:00
luz.paz
98200ddd8d Source code typo fixes
https://bugzilla.gnome.org/show_bug.cgi?id=795610
2018-05-01 11:25:21 +01:00
luz.paz
4a402c1c7d Fix typos in comments and docs
Found via `codespell`

https://bugzilla.gnome.org/show_bug.cgi?id=795610
2018-05-01 11:18:03 +01:00
Olivier Crête
96c3a635ce aggregator: Improve doc for gst_aggregator_pad_has_buffer 2018-04-25 14:30:04 -04:00
Olivier Crête
dda9a99989 aggregator: Add API to check if a pad has a new buffer
https://bugzilla.gnome.org/show_bug.cgi?id=795332
2018-04-25 14:20:19 -04:00
Xavier Claessens
b00b1d5361 Meson: Use library() to build both static and shared libs
Meson supports building both static and shared libraries in a single
library() call. It has the advantage of reusing the same .o objects and
thus avoid double compilation.

https://bugzilla.gnome.org/show_bug.cgi?id=794627
2018-04-25 00:40:30 +01:00
Mathieu Duponchelle
4456792218 adapter: port the buffer list from GSList to GstQueueArray
Significantly reduces the amount of memory allocation operations.

https://bugzilla.gnome.org/show_bug.cgi?id=795167
2018-04-14 01:20:38 +02:00
Mathieu Duponchelle
03e27aa5f0 API: gst_queue_array_peek_nth
https://bugzilla.gnome.org/show_bug.cgi?id=795157
2018-04-14 00:14:56 +02:00
Mathieu Duponchelle
68761eecae gstqueuearray: make find() return a 0-based index
And make the drop() functions expect a 0-based index too,
this addresses a longstanding FIXME. This will not break
backward compatibility, because the drop() functions
were previously only meant to be used with the index
returned by find().

https://bugzilla.gnome.org/show_bug.cgi?id=795156
2018-04-14 00:01:35 +02:00
Mark Nauwelaerts
636d6ac37d base: fix some GIR annotations
Mostly related to out parameters and their transfer
2018-04-13 20:16:45 +02:00
Edward Hervey
09791e859c libs: Documentation fixes
* Symbols not properly exposed or wrongly named
2018-04-02 12:41:48 +02:00
Tim-Philipp Müller
7e2ace8618 base: GST_EXPORT -> GST_BASE_API
We need different export decorators for the different libs.
For now no actual change though, just rename before the release,
and add prelude headers to define the new decorator to GST_EXPORT.
2018-03-13 00:46:00 +00:00
Nicolas Dufresne
cbd03e26ce basesrc: Balance unlock/unlock_stop in _src_stop()
Otherwise it's possible that we won't be able to start again
depending the implementation. We do start/stop in normal use cases
whenever GST_QUERY_SCHEDULING happens before we are started.

https://bugzilla.gnome.org/show_bug.cgi?id=794149
2018-03-07 20:03:56 -05:00
Nicolas Dufresne
12c5d903c9 basesrc: No need to stop flushing in start_complete
The flushing state is handled a bit differently, there is no need
to stop flushing in start_complete. This would other result in
unlock_stop being called without unlock_start.

Unlike what the old comment says, there is no need to take the live
lock here, we are still single threaded at this point (app thread
or the state change thread). Also, we will wait for playing state
in create/getrange, no need to do that twice.

https://bugzilla.gnome.org/show_bug.cgi?id=794149
2018-03-07 20:03:56 -05:00
Sebastian Dröge
89eac59e92 queuearray: Implement pop_tail_struct() for completeness
All other variants of {peek,pop}_{head,tail}_{,struct} were already
implemented.

https://bugzilla.gnome.org/show_bug.cgi?id=794035
2018-03-05 09:39:57 +02:00
Olivier Crête
23b32d5600 queue: Ignore thresholds if a query is queued
The queue gets filled by the tail, so a query will always be the tail
object, not the head object. Also add a _peek_tail_struct() method to the
GstQueueArray to enable looking at the tail.

With unit test to prevent future regression.

https://bugzilla.gnome.org/show_bug.cgi?id=762875
2018-03-01 16:31:57 -05:00
Mathieu Duponchelle
8c10f1e2b4 gstaggregator: pads must inherit from #GstAggregatorPad
Document this, and take advantage of that fact to use
GstAggregator.srcpad.segment instead of GstAggregator.segment

https://bugzilla.gnome.org/show_bug.cgi?id=793942
2018-03-01 15:25:53 +01:00
Mathieu Duponchelle
a567cc13a5 Revert "gstaggregator: pads must inherit from #GstAggregatorPad"
This reverts commit 9774b3775d.

Pushed by mistake
2018-03-01 01:15:34 +01:00
Mathieu Duponchelle
9774b3775d gstaggregator: pads must inherit from #GstAggregatorPad
Document this, and take advantage of that fact to use
GstAggregator.srcpad.segment instead of GstAggregator.segment

https://bugzilla.gnome.org/show_bug.cgi?id=793942
2018-03-01 00:39:50 +01:00
Mathieu Duponchelle
f1aba33090 aggregator: allow src GstAggregatorPads
See https://bugzilla.gnome.org/show_bug.cgi?id=793917

https://bugzilla.gnome.org/show_bug.cgi?id=793934
2018-03-01 00:39:08 +01:00
Nicolas Dufresne
91798e16cc baseparse: Fix integer overflow in bitrate calculation
https://bugzilla.gnome.org/show_bug.cgi?id=793284
2018-02-22 16:14:57 -05:00
Nicolas Dufresne
a84b886a7d baseparse: Avoid overflow in update_interval calculation
https://bugzilla.gnome.org/show_bug.cgi?id=793284
2018-02-22 16:14:57 -05:00
Nicolas Dufresne
25aed8c7ff baseparse: Fix check for update_interval
update_interval may be -1

https://bugzilla.gnome.org/show_bug.cgi?id=793284
2018-02-22 16:14:57 -05:00
Tim-Philipp Müller
bbf8f50cde queuearray: add _peek_tail() and _pop_tail()
API: gst_queue_array_pop_tail()
API: gst_queue_array_peek_tail()

These will be needed later for appsrc.
2018-02-19 15:44:04 +00:00
Alicia Boya García
65dcb2adbf gstbasesink: Include segment.offset in the computation of position
Position queries with GST_FORMAT_TIME are supposed to return stream
time.

gst_base_sink_get_position() estimates the current stream time on its
own instead of using gst_segment_to_stream_time(), but the algorithm
used was not taking segment.offset into account, resulting in invalid
values when this field was set to a non-zero value.

https://bugzilla.gnome.org/show_bug.cgi?id=792434
2018-02-16 10:35:14 -03:00
Mathieu Duponchelle
5ce6487fa9 basetransform: annotate virtual methods 2018-01-31 13:36:15 +01:00
Mathieu Duponchelle
117200faeb aggregator: delegate buffer skipping to the aggregate thread
As we do that for serialized events as well, and the subclass will
most likely need to access pad->segment to make its decisions,
doing that from the sinkpad's streaming threads was racy.
2018-01-23 22:49:52 +01:00
Mathieu Duponchelle
9f69034d41 API: GstAggregatorPad.skip_buffer virtual method
Allows subclasses to prevent buffers from being queued.

https://bugzilla.gnome.org/show_bug.cgi?id=781928
2018-01-23 20:17:44 +01:00
Mathieu Duponchelle
ac7434088e basesrc: Annotate some of the virtual methods 2018-01-23 20:06:52 +01:00
Tim-Philipp Müller
bce246f39f aggregator: rename _get_buffer() -> _peek_buffer() and _steal -> _pop
https://bugzilla.gnome.org/show_bug.cgi?id=791204
2018-01-23 09:44:44 +00:00
Jun Xie
33e7269c37 typefindhelper: fix confusing debug log message
In case of a short buffer, the debug log is quite confusing.
Distinguish the two types of failure cases to make it clearer.

https://bugzilla.gnome.org/show_bug.cgi?id=792486
2018-01-15 16:31:44 +00:00
Stefan Sauer
ce00ec8bce aggregator: remove DEBUG_FUNCPTR
The new gst_element_do_foreach_pad() does not print the functions anymore.
2017-12-26 12:53:25 +01:00
Jan Alexander Steffens (heftig)
4636477d81 aggregator: Avoid a maybe-uninitialized warning
Arch Linux x86_64, gcc 7.2.1-2, -Og -g3
2017-12-24 11:39:14 +01:00
Nicolas Dufresne
443221c661 basetransform: Allow going passthrough inside decide_allocation
Sub-class may want to decide to go passthrough/in-place by inspecting
the support meta APIs. This patch duplicates the check for this mode,
so we still don't do uneeded allocation query while we allow sub-classes
to switch the behaviour during it's own decide_allocation call.

Notice that such sub-class need to reset the class to non-passthrough in
set_caps() in order for decide_allocation to be called again. This is
needed otherwise we'd be doing an allocation query in element in which
it make no sense (notably capsfilter).

https://bugzilla.gnome.org/show_bug.cgi?id=791453
2017-12-17 15:39:51 -05:00
Tim-Philipp Müller
18fe36a286 basesrc: add buffer list support
Add a gst_base_src_submit_buffer_list() function that allows subclasses
to produce a bufferlist containing multiple buffers in the ::create()
function. The buffers in the buffer list will then also be pushed out
in one go as a GstBufferList. This can reduce push overhead
significantly for sources with packetised inputs (such as udpsrc)
in high-throughput scenarios.

The _submit_buffer_list() approach was chosen because it is fairly
straight-forward, backwards-compatible, bindings-friendly (as opposed
to e.g. making the create function return a mini object instead),
and it allows the subclass maximum control: the subclass can decide
dynamically at runtime whether to return a list or a single buffer
(which would be messier if we added a create_list virtual method).

https://bugzilla.gnome.org/show_bug.cgi?id=750241
2017-12-07 12:17:09 +00:00
Tim-Philipp Müller
880c573e8d basesrc: minor code readability improvement 2017-12-07 12:17:09 +00:00
Tim-Philipp Müller
76b54099bd aggregator: add finish_buffer() vfunc
So subclasses can override the finish behaviour
and/or decorate or modify buffers before they
get pushed out.

https://bugzilla.gnome.org/show_bug.cgi?id=760981
2017-12-04 15:27:04 +00:00
Tim-Philipp Müller
e9483fbffb aggregator: disable tag merging and forwarding for now
Subclasses should handle this for now.
2017-12-04 12:29:05 +00:00
Tim-Philipp Müller
e6dbbb3854 aggregator: hook up to docs 2017-12-02 19:00:32 +00:00
Tim-Philipp Müller
cea9641fa9 aggregator: hook up to build system
https://bugzilla.gnome.org/show_bug.cgi?id=739010
2017-12-02 15:44:40 +00:00
Tim-Philipp Müller
39664da1f0 Move GstAggregator from -bad to core
Merge branch 'aggregator-move'

https://bugzilla.gnome.org/show_bug.cgi?id=739010
2017-12-02 15:27:22 +00:00
Mathieu Duponchelle
79d0239e2f aggregator: Remove klass->sinkpads_type
This posed problems for the python bindings (and possibly others).

Instead, subclasses now use add_pad_template_with_gtype.

https://bugzilla.gnome.org/show_bug.cgi?id=789986
2017-12-02 15:10:27 +00:00
Tim-Philipp Müller
4e4438de21 aggregator: add doc blurb for gst_aggregator_pad_is_eos() 2017-12-02 15:10:27 +00:00
Tim-Philipp Müller
41f7b04c81 aggregator: also remove now-unused PadForeachFunc declaration
https://bugzilla.gnome.org/show_bug.cgi?id=785679
2017-12-02 15:10:27 +00:00
Olivier Crête
e9fafb3e17 aggregator: Remove pad iterator function
Use new gst_element_foreach_sink_pad() from core instead.

https://bugzilla.gnome.org/show_bug.cgi?id=785679
2017-12-02 15:10:27 +00:00
Tim-Philipp Müller
2f3fbf24bc aggregator: use new gst_element_foreach_sink_pad()
Instead of gst_aggregator_iterate_sinkpads() which will
soon be removed.

https://bugzilla.gnome.org/show_bug.cgi?id=785679
2017-12-02 15:10:27 +00:00
Stefan Sauer
f51557dbc5 aggregator: add more comments 2017-12-02 15:10:27 +00:00
Stefan Sauer
063787d770 aggregator: fix type for latency property (int64 -> GStClockTime)
The value is used as GstClockTiem in the code. Adapt the hack^H^H^H^Hcode
in live-adder.
2017-12-02 15:10:27 +00:00
Olivier Crête
3d0dad59a0 aggregator: Don't take flush lock from output thread
Instead just take it in the chain function.

https://bugzilla.gnome.org/show_bug.cgi?id=784911
2017-12-02 15:10:27 +00:00
Olivier Crête
8b60b25917 aggregator: Don't block if adding to the tail of the queue
If we're adding to the tail of the queue, it's because we're converting
a gap event, so don't block there it means we're calling from the output
thread.

https://bugzilla.gnome.org/show_bug.cgi?id=784911
2017-12-02 15:10:27 +00:00
Stefan Sauer
a083391fb5 aggregator: review code related to time level
Add a comment for when the state matters. Use a local var for priv in
update_time_level() to improve readability. Move the our_latency local
var below the query results checks.
2017-12-02 15:10:27 +00:00
Stefan Sauer
23692ee688 aggregator: init latency values with 0 instead of FALSE 2017-12-02 15:10:27 +00:00
Stefan Sauer
fb3c9f3808 aggregator: code cleanup for event and query func
Only look up klass for non serialized events/queries. For events remove
superfluous assignment for the return value in the flushing case.
2017-12-02 15:10:27 +00:00
Stefan Sauer
8776900cf7 aggregator: simplify pad_event_func for FLUSH_STOP events
We want to skip serialization for FLUSH_STOP events (apparently). We can
simplify the code to add it to the top-level conditions. There was nothing
done in the first code path if the event was FLUSH_STOP.
2017-12-02 15:10:27 +00:00
Stefan Sauer
5509920c27 aggregator: drop special casing for eos
Just queue it like any other serialized event. This way we don't need to
check if there still are buffers in the queue.

Validated with the tests and gst-launch-1.0 pipelines.
2017-12-02 15:10:27 +00:00
Stefan Sauer
113a2c508b aggregator: add a doc-blob for the event_func 2017-12-02 15:10:27 +00:00
Stefan Sauer
45cef5726f aggregator: rename a local variable
The variable tracks wheter the queue is not empty, but num_buffers==0. That
means we have events or queries to process. Rename accordingly.
2017-12-02 15:10:27 +00:00
Stefan Sauer
498cdd8fac aggregator: remove commented code
The SEGMENT_DONE event does not require any special treatment. This is
commented out in 6efc106a67.
2017-12-02 15:10:27 +00:00
Stefan Sauer
656a2616f2 aggregator: move the comment for the locks to the lock macros
Looks like some code was inserted afterwards.
2017-12-02 15:10:27 +00:00
Stefan Sauer
5a06c3d12b aggregator: improve section docs
Mention how data ends up in the queues. Document the relation of the pad
functions and the class vmethods to get events and queries.
2017-12-02 15:10:27 +00:00
Stefan Sauer
4808f4836c aggregator: cleanup event forwarding
Don't copy the whole event struct. Set the input params when we call the
forwarding helper. Initialize the internal fields and return values in the
helper.
2017-12-02 15:10:27 +00:00
Stefan Sauer
a82e6bc650 aggregator: simplify src_event
Avoid extra ref/unref, we have a ref and do_seek unrefs. Just return the result
as we have. This lets us remove the local var plus the label.
2017-12-02 15:10:27 +00:00
Stefan Sauer
70d0945b35 aggregator: register func for do_events_and_queries
This fixes logging the func ptr from _iterate_sinkpads().
2017-12-02 15:10:27 +00:00
Stefan Sauer
bedc9de46c aggregator: only set clipped_buffer to NULL if needed 2017-12-02 15:10:27 +00:00
Stefan Sauer
06d62ccb94 aggregator: rename check_events
This function also handles queries. Update the code to loop until all events and
queuries are handled.
2017-12-02 15:10:27 +00:00
Stefan Sauer
1869886a96 aggregator: add a few more comments to PadPrivate struct 2017-12-02 15:10:27 +00:00
Stefan Sauer
82bde3446d aggregator: rename buffers field to data
The queue stores buffers, events and queries.
2017-12-02 15:10:27 +00:00
Stefan Sauer
caafb59af5 aggregator: documentaion fixes
Fix typos and remove params docs, where the param was moved.
2017-12-02 15:10:27 +00:00
Stefan Sauer
2cd988e763 aggregator: log all events
We already log a few events explicitly, just log them all with more detail.
2017-12-02 15:10:27 +00:00
Tim-Philipp Müller
bb9f3d2be5 aggregator: fix header formatting 2017-12-02 15:10:27 +00:00
Sebastian Dröge
70b4395e95 aggregator: Remove the GAP event from the queue before queueing up the GAP buffer
Otherwise check_events() will not remove the GAP event (as the queue
tail is not the event anymore but the GAP buffer), then the GAP buffer
is handled, then the GAP event is handled again, ... forever.
2017-12-02 15:10:27 +00:00
Tim-Philipp Müller
e018273183 aggregator: mark symbols explicitly for export with GST_EXPORT 2017-12-02 15:10:27 +00:00
Stefan Sauer
27708ff7c1 aggregator: remove duplicated code fragment
This code already runs above when (event || query).
2017-12-02 15:10:27 +00:00
Stefan Sauer
b609fd7138 aggregator: code cleanups
Fix comment typos, some copy'n'paste in logging. Add more doc comments.
2017-12-02 15:10:27 +00:00
Mathieu Duponchelle
4f81aa8742 aggregator: Invalidate pad's tail position ...
when dequeuing a segment event.

https://bugzilla.gnome.org/show_bug.cgi?id=784593
2017-12-02 15:10:27 +00:00
Stefan Sauer
7b82eb546f aggregator: fix "'aggclass' may be used uninitialized in this function" 2017-12-02 15:10:27 +00:00
Olivier Crête
474acca0a8 aggregator: Process serialized queries through the queue
This ensures that they really get processed in order with
buffers. Just waiting for the queue to be empty is sometimes not
enough as the buffers are dropped from the pad before the result is
pushed to the next element, sometimes resulting in surprising
re-ordering.
2017-12-02 15:10:27 +00:00
Olivier Crête
0500807b55 aggregator: Set flow to FLUSHING on pad stop
Fixes a rare race where the pad is being stopped while doing a query.
2017-12-02 15:10:27 +00:00
Olivier Crête
a001f6d587 aggregator: Request pad templates which are not request pad
https://bugzilla.gnome.org/show_bug.cgi?id=782920
2017-12-02 15:10:27 +00:00
Olivier Crête
6eda156b20 aggregator: Don't restrict sink pad names
Sink pads could have other names than sink_%u

https://bugzilla.gnome.org/show_bug.cgi?id=782920
2017-12-02 15:10:27 +00:00
Olivier Crête
c4209ba5d1 aggregator: Implement propose allocation
https://bugzilla.gnome.org/show_bug.cgi?id=782918
2017-12-02 15:10:27 +00:00
Olivier Crête
87299b640a aggregator: Check for the result of caps events
https://bugzilla.gnome.org/show_bug.cgi?id=782918
2017-12-02 15:10:27 +00:00
Olivier Crête
0e973bc4fc aggregator: Caps event always goes to the aggregate thread
So no need to check it here.

https://bugzilla.gnome.org/show_bug.cgi?id=782918
2017-12-02 15:10:27 +00:00
Olivier Crête
e76c35857d aggregator: Add downstream allocation query
https://bugzilla.gnome.org/show_bug.cgi?id=746529
2017-12-02 15:10:27 +00:00
Olivier Crête
838e01723f aggregator: Remove unused GST_FLOW_NOT_HANDLED 2017-12-02 15:10:27 +00:00
Matthew Waters
f35b05a2f2 aggregator: add simple support for caps handling
Modelled off the videoaggregator caps handling as that seems the most
mature aggregtor-using implementation that has caps handling there is.

https://bugzilla.gnome.org/show_bug.cgi?id=776931
2017-12-02 15:10:27 +00:00
Nicolas Dufresne
c54d253301 aggregator: Reset upstream latency on first buffer
In the case an aggregator is created and pads are requested but only
linked later, we end up never updating the upstream latency.
This was because latency queries on pads that are not linked succeed,
so we never did a new query once a live source has been linked, so the
thread was never started.

https://bugzilla.gnome.org/show_bug.cgi?id=757548
2017-12-02 15:10:27 +00:00
Olivier Crête
687ac8e4d5 aggregator: Always handle sync'ed events on output thread
Having all synchronized events always be handled on the output
thread should make synchronization easier.

https://bugzilla.gnome.org/show_bug.cgi?id=781673
2017-12-02 15:10:27 +00:00
Olivier Crête
2ce3234aa0 aggregator: Delay clipping to output thread
This is required because the synchronized events like caps or segments
may only be processed on the output thread.

https://bugzilla.gnome.org/show_bug.cgi?id=781673
2017-12-02 15:10:27 +00:00
Olivier Crête
5c2391a5e0 aggregator: Make pad eos as soon as all buffers are processed, dont way for events
https://bugzilla.gnome.org/show_bug.cgi?id=781673
2017-12-02 15:10:27 +00:00
Olivier Crête
744440ecf0 aggregator: Only count buffers when declaring queue full
https://bugzilla.gnome.org/show_bug.cgi?id=781673
2017-12-02 15:10:27 +00:00
Olivier Crête
2ab5a23a10 aggregator: Simplify clip function
The return value was ignored anyway

https://bugzilla.gnome.org/show_bug.cgi?id=781673
2017-12-02 15:10:27 +00:00
Olivier Crête
8936a692c1 aggregator: Only declare first buffer on actual buffer
The function needs to be unlocked if any data is received, but only
end the first buffer processing on an actual buffer, synchronized events
don't matter on the first buffer processing.

https://bugzilla.gnome.org/show_bug.cgi?id=781673
2017-12-02 15:10:27 +00:00
Olivier Crête
32b71d8707 aggregator: Set initial position on first buffer
Set the initial position on the first buffer, otherwise the queue
will grow without limits before the output thread is started.

https://bugzilla.gnome.org/show_bug.cgi?id=781673
2017-12-02 15:10:27 +00:00
Olivier Crête
b31eebc946 aggregator: Reset the pad's first buffer flag with the rest
There is not reason to have separate code to reset this one.

https://bugzilla.gnome.org/show_bug.cgi?id=781673
2017-12-02 15:10:27 +00:00
Olivier Crête
b7693464d0 aggregator: Reset pad on init
Factor out the pad reset code from the flushing and use it on init as well

https://bugzilla.gnome.org/show_bug.cgi?id=781673
2017-12-02 15:10:26 +00:00
Olivier Crête
06bc00ec98 aggregator: Fix indentation
https://bugzilla.gnome.org/show_bug.cgi?id=781673
2017-12-02 15:10:26 +00:00
Thibault Saunier
6e24e42d9a docs: Port all docstring to gtk-doc markdown 2017-12-02 15:10:26 +00:00
Thibault Saunier
47460d6326 aggregator: Make instance var name match between .c and .h
Making GI happy
2017-12-02 15:10:26 +00:00
Vincent Penquerc'h
d5f42683ef gstaggregator: fix event use after free
https://bugzilla.gnome.org/show_bug.cgi?id=781017
2017-12-02 15:10:26 +00:00
Thibault Saunier
5fefb1b866 aggregator: Use the event_full function for GstAggregatorPads
Allowing us to tell GstPad why we are failing an event, which might
be because we are 'flushing' even if the sinkpad is not in flush state
at that point.
2017-12-02 15:10:26 +00:00
Nicolas Dufresne
885c95c3ed Revert "aggregator: Start the task when linked"
This reverts commit 302580c381.
2017-12-02 15:10:26 +00:00
Nicolas Dufresne
3b05c55222 aggregator: Start the task when linked
Until now we would start the task when the pad is activated. Part of the
activiation concist of testing if the pipeline is live or not.
Unfortunatly, this is often too soon, as it's likely that the pad get
activated before it is fully linked in dynamic pipeline.

Instead, start the task when the first serialized event arrive. This is
a safe moment as we know that the upstream chain is complete and just
like the pad activation, the pads are locked, hence cannot change.

https://bugzilla.gnome.org/show_bug.cgi?id=757548
2017-12-02 15:10:26 +00:00
Nicolas Dufresne
834015009f aggregator: Check all pads for data when live
When live, we still need to inspect all pads queue in order to determin
if we have received the first buffer or not.

https://bugzilla.gnome.org/show_bug.cgi?id=765431
2017-12-02 15:10:26 +00:00
Nicolas Dufresne
a1e69783e5 aggregator: Fix locking when using the clock
This fixes a race where we check if there is a clock, then it get
removed and we endup calling gst_clock_new_single_shot_id() with a NULL
pointer instead of a valid clock and also calling gst_object_unref()
with a NULL pointer later.

https://bugzilla.gnome.org/show_bug.cgi?id=757548
2017-12-02 15:10:26 +00:00
Aurélien Zanelli
c9502ff3fc aggregator: remove duplicated test of flow_return in pad_chain_internal
https://bugzilla.gnome.org/show_bug.cgi?id=764549
2017-12-02 15:10:26 +00:00
Nirbheek Chauhan
9c0e67bc6e aggregator: Fix strcmp test for sink template 2017-12-02 15:10:26 +00:00
Nirbheek Chauhan
c18ef6d8a1 aggregator: Don't try to be too smart while allocating pad names
Previously, while allocating the pad number for a new pad, aggregator was
maintaining an interesting relationship between the pad count and the pad
number.

If you requested a sink pad called "sink_6", padcount (which is badly named and
actually means number-of-pads-minus-one) would be set to 6. Which means that if
you then requested a sink pad called "sink_0", it would be assigned the name
"sink_6" again, which fails the non-uniqueness test inside gstelement.c.

This can be fixed by instead setting padcount to be 7 in that case, but this
breaks manual management of pad names by the application since it then becomes
impossible to request a pad called "sink_2". Instead, we fix this by always
directly using the requested name as the sink pad name. Uniqueness of the pad
name is tested separately inside gstreamer core. If no name is requested, we use
the next available pad number.

Note that this is important since the sinkpad numbering in aggregator is not
meaningless. Videoaggregator uses it to decide the Z-order of video frames.
2017-12-02 15:10:26 +00:00
Luis de Bethencourt
c0a0102b41 aggregator: use GST_STIME_FORMAT for GstClockTimeDiff
No need to manually handle negative value of deadline, GST_STIME_FORMAT does
exactly this.
2017-12-02 15:10:26 +00:00