Commit graph

3195 commits

Author SHA1 Message Date
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
Bastian Köcher
cd3e55c38e gstreamer: fix install dir for configure files
Nixos installs into a non-standard includedir.

https://bugzilla.gnome.org/show_bug.cgi?id=794856
2018-07-07 12:42:17 +02: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
Edward Hervey
80dfb7bb3f gst: Use memcpy() instead of strncpy() where appropriate
strncpy() is assumed to be for strings so the compiler assumes that
it will need an extra byte for the string-terminaning NULL.

For cases where we know it's actually "binary" data, just copy it
with memcpy.

https://bugzilla.gnome.org/show_bug.cgi?id=795756
2018-05-07 17:05:36 +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
Nirbheek Chauhan
4fb02fc85b 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:30:43 +05:30
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
Thibault Saunier
0b86481adf harness: Handle harness->element not being a GstBin
It is totally valid but in gst_harness_find_element we were not
handling that case.

https://bugzilla.gnome.org/show_bug.cgi?id=795308
2018-04-17 10:15:06 -03: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
Alessandro Decina
cf2be53b24 meson: use gnome.mkenums_simple() to generate controller enumtypes 2018-03-22 12:50:24 +00:00
Alessandro Decina
58a2b5ab27 meson: delete unused variable 2018-03-22 11:52:38 +00:00
Sebastian Dröge
29e81988fb net: Include gstnetcontrolmessagemeta.h in net.h 2018-03-21 10:20:14 +02:00
Tim-Philipp Müller
d86a90550b net: GST_EXPORT -> GST_NET_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:57:37 +00:00
Tim-Philipp Müller
6b286fb7dd controller: GST_EXPORT -> GST_CONTROLLER_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:57:37 +00:00
Tim-Philipp Müller
357e7c7b02 check: GST_EXPORT -> GST_CHECK_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:57:36 +00: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
d67623c7a9 meson: enable more warnings
Modeled on the autotools build, -W flags are only
added if the compiler supports them.

https://bugzilla.gnome.org/show_bug.cgi?id=793958
2018-03-01 17:20:48 +01: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
Michele Dionisio
0af74cb599 ptp: fix build failure with #undef USE_MEASUREMENT_FILTERING
"Label ‘out’ used but not defined", since it's also used by
the USE_MEDIAN_PRE_FILTERING branch.

https://bugzilla.gnome.org/show_bug.cgi?id=785631
2018-01-18 17:45:28 +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
Tim-Philipp Müller
88dfd9ee48 libs: check: print stacktrace on unexpected criticals 2018-01-11 12:27:18 +00:00
Håvard Graff
fbbe6c646e meson: make check and tests build on Windows with msvc 2018-01-11 09:50:24 +00:00
Edward Hervey
9d335a80d0 gstharness: Remove double free 2018-01-02 10:02:45 +01: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
Matthew Waters
fa302587dd check/harness: fix transfer annotations on buffer passing functions 2017-12-13 11:23:03 +11: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
16d9954dd5 harness: make bindings use the GBytes variant for _take_all_data() 2017-12-05 16:42:57 +00:00
Havard Graff
e08834bff3 harness: use new take_all_data() function in _dump_to_file(). 2017-12-05 15:37:14 +00:00
Tim-Philipp Müller
d8e7fc40b1 harness: add gst_harness_take_all_data() + _take_all_data_as_{bytes,buffer}()
Convenience function to just grab all pending data
from the harness, e.g. if we just want to check if
it matches what we expect and we don't care about
the chunking or buffer metadata.

Based on patch by: Havard Graff <havard.graff@gmail.com>
2017-12-05 15:37:00 +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
Stefan Sauer
c1e6f94157 aggregator: don't compare templ instance pointers
One can pass the PadTemplate from the element_class or the one from the factory.
While they have the same content, the addresses are different.
2017-12-02 15:10:26 +00:00
Olivier Crête
78aa10b5bb aggregator: Set to running in a single place
Only set to running when the thread is actually started.
2017-12-02 15:10:26 +00:00
Olivier Crête
96583f0d18 aggregator: Document more locking 2017-12-02 15:10:26 +00:00
Olivier Crête
dc346ca245 aggregator: Hold object lock while manipulating the segment
Make sure the object lock is held when aggregator->segment is
modified.
2017-12-02 15:10:26 +00:00
Olivier Crête
b95f3e8455 aggregator: Remove dead code
This code will never be called as max>=min in all cases. If the upstream
latency query returned min>max, the function already returned and all
values that are added to those have max>= min.
2017-12-02 15:10:26 +00:00
Sebastian Dröge
bbd11aea40 aggregator: Add create_new_pad() vfunc to allow subclasses to override the default behaviour
Not all aggregator subclasses will have a single pad template called sink_%u
and might do something special depending on what the application requests.

https://bugzilla.gnome.org/show_bug.cgi?id=757018
2017-12-02 15:10:26 +00:00
Sebastian Dröge
41b4a78b6b aggregator: Convert GST_ERROR_OBJECT() for seek events to GST_DEBUG_OBJECT() 2017-12-02 15:10:26 +00:00
Sebastian Dröge
3db4239aab aggregator: For the start time selection, only set the segment position
segment.time and segment.start can stay the same, and were always the same
before anyway because of a mistake.

https://bugzilla.gnome.org/show_bug.cgi?id=755623
2017-12-02 15:10:26 +00:00
Sebastian Dröge
92a80e6490 aggregator: Don't forward QOS events to sinkpads that had no buffer yet
Otherwise they will receive a QOS event that has earliest_time=0 (because we
can't have negative timestamps), and consider their buffer as too late

https://bugzilla.gnome.org/show_bug.cgi?id=754356
2017-12-02 15:10:26 +00:00
Olivier Crête
a7845e80f1 aggregator: Keep at least two buffers in the queue in live mode
When in live mode, the queue needs to hold the currently processed
buffer and one more at least.

https://bugzilla.gnome.org/show_bug.cgi?id=754851
2017-12-02 15:10:26 +00:00
Sebastian Dröge
265ac95553 aggregator: Document that get_next_time() should return running time
https://bugzilla.gnome.org/show_bug.cgi?id=753196
2017-12-02 15:10:26 +00:00
Olivier Crête
2c19653410 aggregator: Also ignore start-time on seek from gst_element_send_event()
https://bugzilla.gnome.org/show_bug.cgi?id=753806
2017-12-02 15:10:26 +00:00
Olivier Crête
22dc57f84e aggregator: Queue "latency" buffers at each sink pad.
In the case where you have a source giving the GstAggregator smaller
buffers than it uses, when it reaches a timeout, it will consume the
first buffer, then try to read another buffer for the pad. If the
previous element is not fast enough, it may get the next buffer even
though it may be queued just before. To prevent that race, the easiest
solution is to move the queue inside the GstAggregatorPad itself. It
also means that there is no need for strange code cause by increasing
the min latency without increasing the max latency proportionally.

This also means queuing the synchronized events and possibly acting
on them on the src task.

https://bugzilla.gnome.org/show_bug.cgi?id=745768
2017-12-02 15:10:26 +00:00
Olivier Crête
5db97caef7 aggregator: Default to "zero" start time selection mode as documented 2017-12-02 15:10:26 +00:00
Olivier Crête
1b3f1b1a4e aggregator: Ignore the "first" mode if the segment not a time segment 2017-12-02 15:10:26 +00:00
Sebastian Dröge
3030d1b501 aggregator: Add property to select how to decide on a start time
Before aggregator based elements always started at running time 0,
now it's possible to select the first input buffer running time or
explicitly set a start-time value.

https://bugzilla.gnome.org/show_bug.cgi?id=749966
2017-12-02 15:10:26 +00:00
Sebastian Dröge
9ab98e9b22 aggregator: Query the peer latency again on the next opportunity after a pad was added or removed
Adding a pad will add a new upstream that might have a bigger minimum latency,
so we might have to wait longer. Or it might be the first live upstream, in
which case we will have to start deadline based aggregation.

Removing a pad will remove a new upstream that might have had the biggest
latency, so we can now stop waiting a bit earlier. Or it might be the last
live upstream, in which case we can stop deadline based aggregation.
2017-12-02 15:10:26 +00:00
Thiago Santos
07247f01ca aggregator: add a convenience macro to get the source pad
Easier than casting or acessing the parent everywhere
2017-12-02 15:10:26 +00:00
Olivier Crête
0a35f550b2 aggregator: Document that the latency is in ns 2017-12-02 15:10:26 +00:00
Jan Schmidt
b16697d286 aggregator: Push EOS on error return.
Before shutting down the srcpad task due to a
downstream error, push an EOS to give downstream
a chance to shut down somewhat cleanly.
2017-12-02 15:10:26 +00:00
Reynaldo H. Verdejo Pinochet
656b7a0594 aggregator: document gap handling behavior
https://bugzilla.gnome.org/show_bug.cgi?id=746249
2017-12-02 15:10:26 +00:00
Reynaldo H. Verdejo Pinochet
3f56fb7189 aggregator: drop stale white space at warning 2017-12-02 15:10:26 +00:00
Reynaldo H. Verdejo Pinochet
c955254758 aggregator: implement gap handling
https://bugzilla.gnome.org/show_bug.cgi?id=746249
2017-12-02 15:10:26 +00:00
Olivier Crête
e73a173224 aggregator: Unify downstream flow return and flushing
Also means that having a non-OK downstream flow return
wakes up the chain functions.

https://bugzilla.gnome.org/show_bug.cgi?id=747220
2017-12-02 15:10:26 +00:00
Olivier Crête
30eb13a16d aggregator: Flushing is always in pad lock, no need to atomics
The usage of atomics was always doubtful as it was used to release a
GCond

https://bugzilla.gnome.org/show_bug.cgi?id=747220
2017-12-02 15:10:26 +00:00
Olivier Crête
c55b6be463 aggregator: Reset pending_eos on pad flush
https://bugzilla.gnome.org/show_bug.cgi?id=747220
2017-12-02 15:10:26 +00:00
Olivier Crête
d88e064019 aggregator: Unify code to set a pad flushing
https://bugzilla.gnome.org/show_bug.cgi?id=747220
2017-12-02 15:10:26 +00:00
Olivier Crête
5a0e2c4c47 aggregator: Query latency on first incoming buffer.
And keep on querying upstream until we get a reply.

Also, the _get_latency_unlocked() method required being calld
with a private lock, so removed the _unlocked() variant from the API.
And it now returns GST_CLOCK_TIME_NONE when the element is not live as
we think that 0 upstream latency is possible.

https://bugzilla.gnome.org/show_bug.cgi?id=745768
2017-12-02 15:10:26 +00:00
Olivier Crête
46e33e84fd aggregator: Be more aggressive with invalid replies to our latency query
https://bugzilla.gnome.org/show_bug.cgi?id=745768
2017-12-02 15:10:26 +00:00
Matthew Waters
87b25fb7a5 aggregatory: don't redefine GST_FLOW_CUSTOM_SUCCESS 2017-12-02 15:10:26 +00:00
Arun Raghavan
b7155695f8 aggregator: Use standard upstream latency querying logic
The same functionality is duplicated in the default latency querying
now.
2017-12-02 15:10:26 +00:00
Olivier Crete
5ac166a5d9 aggregator: Use src_lock to protect latency related members
One has to use the src_lock anyway to protect the min/max/live so they
can be notified atomically to the src thread to wake it up on changes,
such as property changes. So no point in having a second lock.

Also, the object lock was being held across a call to
GST_ELEMENT_WARNING, guaranteeing a deadlock.
2017-12-02 15:10:26 +00:00
Olivier Crête
77698267db aggregator: Remove untrue comment 2017-12-02 15:10:26 +00:00
Olivier Crête
8f8430ee9e aggregator: Don't try to push tags while flush seeking
The downstream segment could have been flushed already, so
need to re-send the segment event before re-sending the tags.

https://bugzilla.gnome.org/show_bug.cgi?id=742684
2017-12-02 15:10:26 +00:00
Sebastian Dröge
83203e9dc4 aggregator: Use the sinkpads iterator directly to query upstream latencies
While gst_aggregator_iterate_sinkpads() makes sure that every pad is only
visited once, even when the iterator has to resync, this is not all we have
to do for querying the latency. When the iterator resyncs we actually have
to query all pads for the latency again and forget our previous results. It
might have happened that a pad was removed, which influenced the result of
the latency query.
2017-12-02 15:10:26 +00:00
Sebastian Dröge
075cfd8d7b aggregator: Move gst_aggregator_get_latency_unlocked() a bit
It was between another function and its helper function before, which was
confusing when reading the code as it had nothing to do with the other
functions.
2017-12-02 15:10:26 +00:00
Sebastian Dröge
2b932dc551 aggregator: Fail the latency query if one of the upstream queries fails 2017-12-02 15:10:26 +00:00
Olivier Crête
a42c4740ec aggregator: Document locking order
https://bugzilla.gnome.org/show_bug.cgi?id=742684
2017-12-02 15:10:26 +00:00
Olivier Crête
ad2cd52bae aggregator: Rename confusinly named SRC_STREAM_LOCK macros to SRC_LOCK
This will match the name of the lock itself. It is also not a stream
lock as it not recursive and not held while pushing.

https://bugzilla.gnome.org/show_bug.cgi?id=742684
2017-12-02 15:10:26 +00:00
Olivier Crête
3c17c777ee aggregator: Rename confusingly named stream lock to flush lock
This lock is not what is commonly known as a "stream lock" in GStremer,
it's not recursive and it's taken from the non-serialized FLUSH_START event.

https://bugzilla.gnome.org/show_bug.cgi?id=742684
2017-12-02 15:10:26 +00:00
Olivier Crête
aa78cf96f4 aggregator: Fix macro indendation
Changes no code

https://bugzilla.gnome.org/show_bug.cgi?id=742684
2017-12-02 15:10:26 +00:00
Tim-Philipp Müller
e1aba92514 aggregator: drop GAP events until we handle them properly 2017-12-02 15:10:26 +00:00
Tim-Philipp Müller
1fe5f9db71 aggregator: use new gst_aggregator_pad_drop_buffer() 2017-12-02 15:10:26 +00:00
Tim-Philipp Müller
950b772a0d aggregator: add gst_aggregator_pad_drop_buffer()
steal_buffer() + unref seems to be a wide-spread idiom
(which perhaps indicates that something is not quite
right with the way aggregator pad works currently).
2017-12-02 15:10:26 +00:00
Tim-Philipp Müller
4e97321898 aggregator: only post latency message if anything changed
Perhaps we should check for element state as well and
only post it if in PLAYING state.
2017-12-02 15:10:26 +00:00
Sebastian Dröge
d97d363b1f Improve and fix LATENCY query handling
This now follows the design docs everywhere, especially the maximum latency
handling.

https://bugzilla.gnome.org/show_bug.cgi?id=744106
2017-12-02 15:10:26 +00:00
Sebastian Dröge
1609e1d696 aggregator: Pause srcpad task on flow errors
Otherwise we will call the task function over and over again until
upstream finally handled the flow return and shuts us down.
2017-12-02 15:10:26 +00:00
Sebastian Dröge
9213f24716 aggregator: Streamline latency calculations
Min latency can never be invalid, latency property can never be invalid
either. So no need to check for all these things in various places.
2017-12-02 15:10:26 +00:00
Sebastian Dröge
07d9bf9cab aggregator: If upstream has no max latency but the subclass has, take the subclass max latency 2017-12-02 15:10:26 +00:00
Sebastian Dröge
e57b62be72 aggregator: Fix min>max latency error check
We have to include the upstream latency, our own latency and the subclass
latency in the calculations.

FIXME: This is still not entirely correct
2017-12-02 15:10:26 +00:00
Sebastian Dröge
87a2fbab60 aggregator: Don't add the latency property to the max latency
It has no meaning for the max latency and is only used to increase the min
latency.
2017-12-02 15:10:26 +00:00
Thibault Saunier
24abac9fce aggregator: Cleanup locking around AggregatorPad flush related fields
And document the locking

https://bugzilla.gnome.org/show_bug.cgi?id=742684
2017-12-02 15:10:26 +00:00
Mathieu Duponchelle
14f35e8a78 aggregator: keep chain functions as dumb as possible.
+ A pad chain function has no business checking other pads,
  that's what the aggregate thread is for.

https://bugzilla.gnome.org/show_bug.cgi?id=742684
2017-12-02 15:10:26 +00:00
Thibault Saunier
97eab82ddf aggregator: More fixes around locking when accessing protected private fields
In some more places we were accessing GstAggregator->segment
and GstAggregator->seqnum without holding the GST_OBJECT_LOCK

https://bugzilla.gnome.org/show_bug.cgi?id=742684
2017-12-02 15:10:26 +00:00
Thibault Saunier
ae12041f0c aggregator: Make the PAD_LOCK private
Instead of using the GST_OBJECT_LOCK we should have
a dedicated mutex for the pad as it is also associated
with the mutex on the EVENT_MUTEX on which we wait
in the _chain function of the pad.

The GstAggregatorPad.segment is still protected with the
GST_OBJECT_LOCK.

Remove the gst_aggregator_pad_peak_unlocked method as it does not make
sense anymore with a private lock.

https://bugzilla.gnome.org/show_bug.cgi?id=742684
2017-12-02 15:10:26 +00:00
Thibault Saunier
5f176b724b aggregator: Hide GstAggregatorPad buffer and EOS fileds
And add a getter for the EOS.

The user should always use the various getters to access
those fields

https://bugzilla.gnome.org/show_bug.cgi?id=742684
2017-12-02 15:10:26 +00:00
Olivier Crête
0588222925 aggregator: Document locking of GstAggregatorPrivate members
Most of them are protected by the object lock, specify
which ones use a different lock.

https://bugzilla.gnome.org/show_bug.cgi?id=742684
2017-12-02 15:10:26 +00:00
Olivier Crête
fd326639ea aggregator: Document how the segment is protected
Document that it can only be accessed with the object lock.

https://bugzilla.gnome.org/show_bug.cgi?id=742684
2017-12-02 15:10:26 +00:00
Olivier Crête
be58999bff aggregator: Protect all latency related members with the object lock
The locking was not consistent, now consistently use the object lock.

https://bugzilla.gnome.org/show_bug.cgi?id=742684
2017-12-02 15:10:26 +00:00
Olivier Crête
1d5f3fe084 aggregator: Document locking for gst_aggregator_get_latency_unlocked()
Renamed it to _unlocked() to make it clear.

https://bugzilla.gnome.org/show_bug.cgi?id=742684
2017-12-02 15:10:26 +00:00
Olivier Crête
142073cc79 aggregator: Protect the srcpad caps negotiation with the stream lock
Instead of adding another lock, use the srcpad stream lock, which is already
taken anyway to push out the new caps if needed.

https://bugzilla.gnome.org/show_bug.cgi?id=742684
2017-12-02 15:10:26 +00:00
Olivier Crête
9add348012 aggregator: Protect the tags with the object lock
The tags related variables were sometimes protected, sometimes not and
sometimes atomic. Put them all under the object lock.

https://bugzilla.gnome.org/show_bug.cgi?id=742684
2017-12-02 15:10:26 +00:00
Olivier Crête
25faafaf58 aggregator: Consistenly lock the flow_return state
Use the object's lock to protect it.

https://bugzilla.gnome.org/show_bug.cgi?id=742684
2017-12-02 15:10:26 +00:00
Olivier Crête
90f3cb4af0 aggregator: Consistently lock some members
Some members sometimes used atomic access, sometimes where not locked at
all. Instead consistently use a mutex to protect them, also document
that.

https://bugzilla.gnome.org/show_bug.cgi?id=742684
2017-12-02 15:10:26 +00:00
Olivier Crête
2b7d4e2404 aggregator: Protect exported pad members with the pad's object lock
https://bugzilla.gnome.org/show_bug.cgi?id=742684
2017-12-02 15:10:26 +00:00
Olivier Crête
3217e82791 aggregator: Replace event lock with pad's object lock
Reduce the number of locks simplify code, what is protects
is exposed, but the lock was not.

Also means adding an _unlocked version of gst_aggregator_pad_steal_buffer().

https://bugzilla.gnome.org/show_bug.cgi?id=742684
2017-12-02 15:10:26 +00:00
Olivier Crête
6379433a70 aggregator: Protect data with the same mutex as GCond
Whenever a GCond is used, the safest paradigm is to protect
the variable which change is signalled by the GCond with the same
mutex that the GCond depends on.

https://bugzilla.gnome.org/show_bug.cgi?id=742684
2017-12-02 15:10:26 +00:00
Nirbheek Chauhan
d33e6a191e aggregator: Nitpick spacing/punctuation in debug logging 2017-12-02 15:10:26 +00:00
Olivier Crête
ec5ff5f308 aggregator: Remove pointless atomic
It is only modified from the streaming thread
2017-12-02 15:10:26 +00:00
Olivier Crête
53dd0c650f aggregator: Fix query leak 2017-12-02 15:10:26 +00:00
Sebastian Dröge
4534253145 aggregator: Print jitter from clock waiting in the debug logs 2017-12-02 15:10:26 +00:00
Tim-Philipp Müller
f4ad5f0cdf aggregator: don't use iterator when setting flush pending on pads 2017-12-02 15:10:26 +00:00
Tim-Philipp Müller
0db6fc999b aggregator: check if pads are ready more efficiently
No need to use an iterator for this which creates a temporary
structure every time and also involves taking and releasing the
object lock many times in the course of iterating. Not to mention
all that GList handling in gst_aggregator_iterate_sinkpads().
2017-12-02 15:10:26 +00:00
Tim-Philipp Müller
100d860ad2 aggregator: name vfunc arguments consistently 2017-12-02 15:10:26 +00:00
Tim-Philipp Müller
50908e60d0 aggregator: add g-i transfer and scope annotations 2017-12-02 15:10:26 +00:00
Tim-Philipp Müller
6af6dcb0f7 aggregator: register names of iterate_sinkpads functions with debug system 2017-12-02 15:10:26 +00:00
Tim-Philipp Müller
417445c065 aggregator: reduce debug messages for taking/releasing logs to TRACE level
Don't spam debug log with this stuff.
2017-12-02 15:10:26 +00:00
Tim-Philipp Müller
c5e3fe807a aggregator: move property member into private structure
Our locking (or lack thereof) while accessing this also
looks generally quite dodgy.
2017-12-02 15:10:26 +00:00
Tim-Philipp Müller
b813456233 aggregator: remove empty dispose function 2017-12-02 15:10:26 +00:00
Tim-Philipp Müller
71ec8e2879 aggregator: give private functions namespace prefix
Especially the GST_DEBUG_FUNCPTR ones.
2017-12-02 15:10:26 +00:00
Tim-Philipp Müller
3793bb8ad9 aggregator: fix up some docs comments in header 2017-12-02 15:10:26 +00:00
Tim-Philipp Müller
7302a42ac1 aggregator: remove now-unused system clock member 2017-12-02 15:10:26 +00:00
Tim-Philipp Müller
9f417fb08e aggregator: make GstAggregatorPadForeachFunc take an GstAggregatorPad 2017-12-02 15:10:26 +00:00
Tim-Philipp Müller
601554df70 aggregator: bring start/stop vfunc semantics in line with other baseclasses
Sub-class should not have to chain up to GstAggregator's start/stop
vfuncs, same as in GstBaseSrc, GstBaseSink, GstBaseTransform etc.
2017-12-02 15:10:26 +00:00
Tim-Philipp Müller
a7e2a01098 aggregator: remove pointless GST_DEBUG_FUNCPTR
Not useful for GObject vfuncs.
2017-12-02 15:10:26 +00:00
Tim-Philipp Müller
760d3c5611 aggregator: remove duplicate pad parent_class variable
G_DEFINE_TYPE already provides one, just need to use it.
2017-12-02 15:10:26 +00:00
Tim-Philipp Müller
85171e3512 aggregator: add _CAST() variants for cast macros 2017-12-02 15:10:26 +00:00
Tim-Philipp Müller
5350d8c653 aggregator: make padding larger
Esp. the class structures, can't have enough
spare space for virtual functions.
2017-12-02 15:10:26 +00:00
Nirbheek Chauhan
ced334d397 aggregator: Log to the pad instead of the element
More correct way of doing the same thing as before
2017-12-02 15:10:26 +00:00
Sebastian Dröge
8da3d1e596 aggregator: Make sure that the minimum latencies are never GST_CLOCK_TIME_NONE 2017-12-02 15:10:26 +00:00
Sebastian Dröge
4846f06b41 aggregator: Wait for the minimum latency, not the maximum
The minimum latency is the latency we have to wait at least
to guarantee that all upstreams have produced data. The maximum
latency has no meaning like that and shouldn't be used for waiting.
2017-12-02 15:10:26 +00:00
Nirbheek Chauhan
d18b6de2e6 aggregator: Clamp the min latency at the max if it's greater 2017-12-02 15:10:26 +00:00
Nirbheek Chauhan
b49805a840 aggregator: Print the sinkpad name while logging latency queries
Very useful while debugging.
2017-12-02 15:10:26 +00:00
Nirbheek Chauhan
bbde713640 aggregator: Take the stream lock when iterating sink pads
When iterating sink pads to collect some data, we should take the stream lock so
we don't get stale data and possibly deadlock because of that. This fixes
a definitive deadlock in _wait_and_check() that manifests with high max
latencies in a live pipeline, and fixes other possible race conditions.
2017-12-02 15:10:26 +00:00
Sebastian Dröge
9bac89113e aggregator: Don't leak flush-start events 2017-12-02 15:10:26 +00:00
Sebastian Dröge
f2814fa5e3 aggregator: Also change the default latency to 0, not just the minimum 2017-12-02 15:10:26 +00:00
Sebastian Dröge
6697f1521a aggregator: Fix docs and default value of the latency property 2017-12-02 15:10:26 +00:00
Sebastian Dröge
4c477549d2 aggregator: Also include the subclass latency in the result of the latency query 2017-12-02 15:10:26 +00:00
Sebastian Dröge
5caf89da37 aggregator: Post a latency message if the value of the latency property changes 2017-12-02 15:10:26 +00:00
Sebastian Dröge
7240852e55 aggregator: Wake up the src thread after handling a latency query
Due to changed latencies or changed live-ness we might have to
adjust if we wait on a deadline at all and how long.
2017-12-02 15:10:26 +00:00
Sebastian Dröge
a20863a7ec aggregator: Don't count the number of times we need to wake up but instead check all conditions for waiting again
This simplifies the code and also makes sure that we don't forget to check all
conditions for waiting.

Also fix a potential deadlock caused by not checking if we're actually still
running before starting to wait.
2017-12-02 15:10:26 +00:00
Sebastian Dröge
b1dcc7efb0 aggregator: Add function to allow subclasses to set their own latency
For audiomixer this is one blocksize, for videoaggregator this should
be the duration of one output frame.
2017-12-02 15:10:26 +00:00
Sebastian Dröge
435a477f63 aggregator: Add a timeout parameter to ::aggregate()
When this is TRUE, we really have to produce output. This happens
in live mixing mode when we have to output something for the current
time, no matter if we have enough input or not.
2017-12-02 15:10:26 +00:00
Sebastian Dröge
bf5652f84a aggregator: Some minor cleanup 2017-12-02 15:10:26 +00:00
Matthew Waters
f4b86a6d8c aggregator: make the src pad task drive the pipeline for live pipelines
This removes the uses of GAsyncQueue and replaces it with explicit
GMutex, GCond and wakeup count which is used for the non-live case.

For live pipelines, the aggregator waits on the clock until either
data arrives on all sink pads or the expected output buffer time
arrives plus the timeout/latency at which time, the subclass
produces a buffer.

https://bugzilla.gnome.org/show_bug.cgi?id=741146
2017-12-02 15:10:26 +00:00
Sebastian Dröge
47d0efacf2 aggregator: Unblock events/queries immediately if the pad is flushing
https://bugzilla.gnome.org/show_bug.cgi?id=740376
2017-12-02 15:10:26 +00:00
Sebastian Dröge
f3c741e74e aggregator: Drop serialized events/queries if the pad is flushing
https://bugzilla.gnome.org/show_bug.cgi?id=740376
2017-12-02 15:10:26 +00:00
Sebastian Dröge
0ad159dfb4 aggregator: Block serialized events/queries until the pad has consumed all buffers
Otherwise the caps of the pad might change while the subclass still works with
a buffer of the old caps, assuming the the current pad caps apply to that
buffer. Which then leads to crashes and other nice effects.

https://bugzilla.gnome.org/show_bug.cgi?id=740376
2017-12-02 15:10:26 +00:00
Sebastian Dröge
e3b42c8acb aggregator: Fix typo in debug output 2017-12-02 15:10:26 +00:00
Matthew Waters
4bdbb7a98f aggregator: add _get_latency() for subclass usage
API: gst_aggregator_get_latency

https://bugzilla.gnome.org/show_bug.cgi?id=739996
2017-12-02 15:10:26 +00:00
Vineeth T M
376de6cef3 audiomixer: critical error for blocksize, timeout min/max values
Audiomixer blocksize, cant be 0, hence adjusting the minimum value to 1
timeout value of aggregator is defined with MAX of MAXINT64,
but it cannot cross G_MAXLONG * GST_SECOND - 1
Hence changed the max value of the same

https://bugzilla.gnome.org/show_bug.cgi?id=738845
2017-12-02 15:10:26 +00:00
Matthew Waters
3c8198e99f aggregator: add latency query handling 2017-12-02 15:10:26 +00:00
Matthew Waters
efdcc6c8eb aggregator: add a timeout property determining buffer wait time
Determines the amount of time that a pad will wait for a buffer before
being marked unresponsive.

Network sources may fail to produce buffers for an extended period of time,
currently causing the pipeline to stall possibly indefinitely, waiting for
these buffers to appear.

Subclasses should render unresponsive pads with either silence (audio), the
last (video) frame or what makes the most sense in the given context.
2017-12-02 15:10:26 +00:00
Jan Alexander Steffens (heftig)
e8c34afd5f aggregator: Replace GMainContext with GAsyncQueue (v2)
The previous implementation kept accumulating GSources,
slowing down the iteration and leaking memory.

Instead of trying to fix the main context flushing, replace
it with a GAsyncQueue which is simple to flush and has
less overhead.

https://bugzilla.gnome.org/show_bug.cgi?id=736782
2017-12-02 15:10:26 +00:00