Commit graph

8621 commits

Author SHA1 Message Date
Edward Hervey cd751c2de3 gstvalue: Avoid expensive fallback on intersection
The type checks at the end of `gst_value_intersect` to call the flagset
intersection are relatively expensive.

If we already know that:
* There was a compare function but it didn't return GST_VALUE_EQUAL
* AND none of the registered intersect functions failed

Then we know they can't intersect and can return early.

Trims ~20% of the instruction calls
2020-03-19 13:32:34 +01:00
Edward Hervey 34b6929a0f gstvalue: Optimize some list<=>list functions
For subtracting a list from another, the previous implementation would
do a double subtraction of one from another (which would create temporary
arrays/values which would then be discarded). Instead iterate and do
the comparision directly.

For intersecting a list with another, we can directly iterate both at
once and therefore avoid doing a *full* check of all values of the list
against all other values of the list.
2020-03-18 17:53:34 +01:00
Edward Hervey 917dd0881c gstvalue: Inline GstValueList/GstValueArray
This tries to inline as much as possible array/list and its contents
in order to avoid double allocation/freeing. This also improves the
locality of data.

The internal value is still API/ABI compatible with the *public*
GArray structure. This allows READ-ONLY backwards compatibility with
any external users that assume that the content of a list/array value
is backed by a GArray.
2020-03-18 17:53:34 +01:00
Miguel Paris 2ef0fd1862 bufferlist: foreach: always remove as parent if buffer is changed
In case the buffer is not writable, the parent (the BufferList) is not
removed before calling func. So if it is changed, the parent (the BufferList)
of the previous buffer should be removed after calling func.
2020-03-18 14:43:08 +01:00
Edward Hervey 1e9dcac0fb bufferlist: Add check for overflow 2020-03-18 11:10:13 +01:00
Edward Hervey 5318a03888 gststructure: Optimize pre-allocation of structures
For all the structure creation using valist/varargs we calculate
the number of fields we will need to store. This ensures all callers
will end up with a single allocation.
2020-03-18 09:10:23 +01:00
Edward Hervey 1b568fa01f gststructure: Inline array and contents
Instead of having 3 allocations:
* One for GstStructure
* One for GArray
* One for the array *within* GArray

We try to limit this to a single allocation, inlining everything. This
reduces the number of micro-allocations and improves locality of data
access.
2020-03-18 09:10:23 +01:00
Thibault Saunier a1aebe73d5 value: Handle NULL caps for comparisons
Having a NULL caps in a GValue is legal and we should handle it
properly for comparisons.
2020-03-14 00:35:10 +00:00
Thibault Saunier 109bdd0c25 value: Refactor parsing lists to allow trailing comas
Before that commit `{test, }` wouldn't be accepted as an array
because of the trailing coma, the commit fixes that.

At the same time, the code has been refactored to avoid special casing
the first element of the list, making `{,}` or `<,>` valid lists.
2020-03-12 14:50:20 +00:00
Guillaume Desmottes 3c6da9325a clock: remove documentation link on GTimeVal
Looks like it's been removed from glib.devhelp2 on Fedora 31.

Fix #508
2020-03-12 05:02:33 +00:00
Sebastian Dröge b55d6c0b02 systemclock: Don't start the system clock at 0 on Windows
We kept the start time around and subtracted it everywhere for "easy of
debugging", but we don't do anything like this anywhere else and it
only complicates the code unnecessarily.
2020-03-09 15:17:08 +02:00
Sebastian Dröge daf7df28dd systemclock: Don't divide by zero on Windows if high performance timers are not available 2020-03-09 15:16:00 +02:00
Sebastian Dröge 5edc20188a caps: Don't assert in fixate() on EMPTY/ANY caps and document EMPTY/ANY behaviour on more functions
fixate() will return empty caps if it gets empty caps passed and assert
early if any caps are provided as there's no meaningful way of fixating
any caps.

truncate() and simplify() will return the input caps in case of
any/empty caps as before, but slightly optimized and as documented
behaviour.

Also add tests for this and a few other operations behaviour on
empty/any caps.
2020-03-09 10:10:09 +00:00
Tim-Philipp Müller 602b13c6c3 debugutils: skip "parent" property for elements when dumping pipeline graph
Seems unnecessary to print the parent name for every
element in the pipeline graph, it's clear from the
graph what the parent element is and it's hard to
imagine a case where this is useful info rather than
just distracting spam. So far this was only done for
pads, but we should just do it for everything.
2020-02-19 19:01:25 +00:00
Sebastian Dröge 733246f1b4 bus: Make setting/replacing/clearing the sync handler thread-safe
Previously we would use the object lock only for storing the sync
handler and its user_data in a local variable, then unlock it and only
then call the sync handler. Between unlocking and calling the sync
handler it might be unset and the user_data be freed, causing it to be
called with a freed pointer.

To prevent this add a refcounting wrapper struct around the sync
handler, hold the object lock while retrieving it and increasing the
reference count and only actually free it once the reference count
reaches zero.

As a side-effect we can now also allow to actually replace the sync
handler. Previously it was only allowed to clear it after initially
setting it according to the docs, but the code still allowed to clear it
and then set a different one.

Fixes https://gitlab.freedesktop.org/gstreamer/gstreamer/issues/506
2020-02-14 14:41:46 +00:00
Henry Wilkes 412e97beb4 caps: keep ANY caps empty internally
Keep the ANY caps empty internally when appending and merging
caps/structures. Previously, an ANY caps could end up containing
internal structures, which could be fetched by the user, and gave the
caps a non-zero length.

Also, made sure that `gst_caps_set_features_simple` frees the features
if caps is empty.
2020-02-12 14:41:40 +00:00
Henry Wilkes 407e32588d caps: fix is_strictly_equal
Fixed gst_caps_is_strictly_equal() to take into account whether either of
the caps are ANY caps. Previously, two ANY caps could be considered not
strictly equal if one of them still contained some remnant *internal*
structure (this can happen if an ANY caps has emerged from an append or
merge operation). Also, an ANY caps with no remnant internal structures
was considered strictly equal to an EMPTY caps. Similarly, a non-ANY caps
was considered strictly equal to an ANY caps if its remnant internal
structures happened to match.

Also changed gst_caps_is_fixed to take into account that an ANY caps
should not be considered fixed even if it contains a single remnant
internal fixed structure. This affects gst_caps_is_equal(), which uses a
separate method if both caps are fixed. Previously, this meant that a
non-ANY fixed caps was considered equal to an ANY caps if it contained a
single matching remnant internal structure.

Added some tests for these two equality methods, which covers the above
examples, as well as asserts existing behaviour.

Fixes #496
2020-02-12 14:41:40 +00:00
Olivier Crête b4ba9ec089 systemclock: No need to check for CLOCK_TAI in the meson
POSIX defines CLOCK_MONOTONIC to always be a macro, so I think
it's safe to assume that CLOCK_TAI will also be.
2020-01-27 17:16:14 +00:00
Ederson de Souza 216d6dd0f0 GstSystemClock: Add GST_CLOCK_TYPE_TAI
GST_CLOCK_TYPE_TAI is GStreamer abstraction for CLOCK_TAI. Main
motivation for this patch is support for transmission offloading features
- when network packets are timestamped with the time they are deemed to
be actually transmitted. Linux API for that requires that time to be
in CLOCK_TAI coordinate.

With GST_CLOCK_TYPE_TAI, applications can use CLOCK_TAI directly on
their pipelines, avoiding the need to cross timestamp packet times. By
leveraging system's CLOCK_TAI, applications also don't need to keep track
of leap seconds - less burden for them. Just keep system's CLOCK_TAI
accurate and use it.
2020-01-27 17:16:14 +00:00
Sebastian Dröge 47765e164b bin: Don't consider having a group-id or being STREAM_START if we have not a single STREAM_START message
This would cause us to set GST_GROUP_ID_INVALID as group-id in the
aggregated STREAM_START message if there are no sinks at all or none of
them have a STREAM_START message, which is simply wrong.

If we have not a single STREAM_START message then the bin should not be
considered STREAM_START.
2020-01-25 00:02:20 +02:00
Sebastian Dröge 1b2f968efc event/message: Don't allow setting invalid group ids
They are optional on STREAM_START messages/events but if available
should have at least a valid value.

For STREAM_GROUP_DONE events don't allow creating it with an invalid
group id as this does not make any sense.
2020-01-24 17:53:30 +02:00
Jan Alexander Steffens (heftig) f018b4eddc
bin: Fix deep-element-removed log message
child and bin were switched.

https://gitlab.freedesktop.org/gstreamer/gstreamer/merge_requests/354
2020-01-09 20:08:38 +01:00
Thibault Saunier 20301a8820 docs: Document the new 'redirect-location' error message detail field 2020-01-06 17:47:40 -03:00
Stefan Sauer 19b28788cf parse: add support for presets
Add new parse syntax: @preset="<preset-name>" to load presets.
Fixes #86
2019-12-28 04:02:16 +00:00
Seungha Yang 52706146f5 pluginfeature: Allow updating initial rank of plugin feature
Introducing "GST_PLUGIN_FEATURE_RANK" environment variable in order for users
to adjust rank of plugin(s) via environment.

A "feature" and "rank" key-value pair should be separable by ":",
and each key-value pair is recognized per "," delimiters. The rank
can be a numerical value or one of pre-defined rank values
such as "NONE", "MARGINAL", "SECONDARY", and "PRIMARY" in case-insensitive manner.

In addition to pre-defined { NONE, MARGINAL, SECONDARY, PRIMARY },
"MAX" can be passed to key value used to ensure having a higher rank
than other plugin features.

Example)
- GST_PLUGIN_FEATURE_RANK=qtdemux:256,h264parse:NONE
Set rank of qtdemux plugin to 256 (primary) and 0 (none) for h264parse.
2019-12-26 19:49:00 +00:00
Nirbheek Chauhan 72daeee2c4 gstinfo: Add new API for getting debug log lines
If you're using a custom log handler, you had to reverse-engineer the
debug log format and create your own format function. Now, you can
call `gst_debug_log_get_line()` and it will return a string (without
ANSI escape color codes) representation instead.

This is useful in situations when you need to log the ordinary
gst_debug log to a resource that can't be opened as a `FILE` handle.

Also includes a test.
2019-12-25 08:50:17 +05:30
Niels De Graef 0cb3940c94 bin: Add method to find elements by factory name
A common use case of a dynamically built pipeline is that you want to
(conditionally) find a certain element, e.g. the `rtpbin`s in a
`uridecodebin`. If that element has a fixed name inside its parent bin
(and only has a single instance) this can be easily done by
`gst_bin_get_by_name()`.

If there are multiple instances of the element however, you can only use
`gst_bin_iterate_all_by_interface()`, but this doesn't work if you don't
have the specific `GType` (which is often the case, due to plugins being
dynamically loaded). As such, another fallback could be to use the
well-known name of the element's factory (in case of our example, this
is of course `"rtpbin"`).
2019-12-20 14:29:19 +01:00
Stéphane Cerveau 1d549ea324 gstreamer: use of g_value_dup_string
Use helper method to get string from GValue.
2019-12-18 15:57:54 +01:00
Peter Seiderer 4a827e11b4 pluginloader: handle fsync interrupted by signal (EINTR)
According to [1] EINTR is a possible errno for fsync(),
so handle it as all other EINTR (do/while(errno == EINTR)).

Signed-off-by: Peter Seiderer <ps.report@gmx.net>
2019-12-12 20:49:36 +01:00
Peter Seiderer 96aa27910a registry: handle fsync interrupted by signal (EINTR)
According to [1] EINTR is a possible errno for fsync(),
so handle it as all other EINTR (do/while(errno == EINTR)).

Signed-off-by: Peter Seiderer <ps.report@gmx.net>
2019-12-12 20:49:36 +01:00
Olivier Crête 0a8d14acc9 Remove deprecated GTimeVal
GTimeVal won't work past 2038
2019-12-10 19:18:32 -05:00
Mathieu Duponchelle e79def14a5 device, elementfactory: relax floating requirement
Using g_assert() is a bit too extreme, as it will abort the whole
program unless G_DISABLE_ASSERTS is true.

Switch to g_critical()
2019-12-10 13:31:50 +01:00
Sebastian Dröge 020eb2c346 bus: Clean up #ifdefs to compile with debugging enabled in all combinations
Thanks to Roland Jon for finding this.
2019-12-05 08:21:54 +00:00
Mathieu Duponchelle a90220cce1 device, elementfactory: don't enforce floating status
The reference we receive when calling g_object_new should be
floating, but we can't force it at our level.

Switch from g_object_force_floating() to a simple assertion.

See https://gitlab.freedesktop.org/gstreamer/gst-python/issues/27
2019-12-05 01:44:35 +00:00
Sebastian Dröge 7af50da2c9 bus: Use new GSource dispose function
Without this it is possible that we have a GSource with reference count
0 stored in the GstBus that is currently in the process of being
destroyed. gst_bus_remove_watch() might then access it, increase its
reference count to 1 again, call GSource API on it and then unref it,
which will then finalize it a second time.

The dispose function allows the GSource to be resurrected until it
returned so the above would be safe now.

This caused some spurious crashes during shutdown in various
applications.
2019-12-04 08:24:04 +00:00
Edward Hervey 3b71c4a4e7 GstBuffer: size-related optimization
Avoid calling generic function when it's possible to directly
return/get sizes
2019-11-27 14:25:19 +00:00
Edward Hervey e3d2eb1f16 GstBuffer: Inline fast-path for merged memory 2019-11-27 14:25:19 +00:00
Tim-Philipp Müller 6c2dfe5ebe docs: mention gst_parse_bin_from_description() in gst_parse_launch() docs 2019-11-27 09:41:36 +00:00
Linus Svensson 47c50b086e datetime: Add constructor for timestamps in microseconds 2019-11-25 13:31:11 +01:00
Stéphane Cerveau 8a20d66b10 gstbuffer: update documentation
remove unclear documentation about GST_BUFFER_FLAG_MARKER
2019-11-18 00:15:31 +00:00
Havard Graff 7b38def8e0 structure: add gst_structure_take
(╯°□°)╯︵ ┻━┻
2019-11-14 10:08:38 +00:00
Wonchul Lee 5c6314d68b event: Fix gir warning
It fixes below gir warnings.
../subprojects/gstreamer/gst/gstevent.c:2246: Warning: Gst:
gst_event_new_instant_rate_sync_time: unknown parameter
'rate_multiplier' in documentation comment, should be 'rate'
../subprojects/gstreamer/gst/gstevent.c:2296: Warning: Gst:
gst_event_parse_instant_rate_sync_time: unknown parameter
'rate_multiplier' in documentation comment, should be 'rate'
2019-11-12 15:19:28 +09:00
Víctor Manuel Jáquez Leal 78041a7748 gst/parse: define pure-parser depending on bison version
After release bison 2.5 the declaration %pure-parser was deprecated
in favor of %define api.pure

Nonetheless, until bison 3.4, the declaration was treated as backward
compatibility, but now bison shows a warning:

  warning: deprecated directive, use ‘%define api.pure’

The patch's approach is to handle both directives according with the
used bison's version, by string replacement at source configuration
stage.
2019-11-05 12:55:08 +01:00
Nayana Topolsky e8c782d119 pad: clear sticky event tag upon stream-start
When playing gapless there were situations when some sticky events
like tags were stuck at some pad and then revived much later.
Therefore it is better to clear them upon stream-start.

Fixes #360
2019-11-04 12:01:47 +00:00
Seungha Yang d8b8a13285 taglist: Fix broken empty set character in code
Previous one was not a valid ASCII empty set character.
'tig' and 'git log -p' couldn't represent it as expected.
2019-11-03 19:06:58 +00:00
Jan Schmidt acf66273f5 pipeline: Instant rate change handling
Implement aggregation of INSTANT_RATE_REQUEST messages and sending of
INSTANT_RATE_SYNC_TIME events.
2019-11-03 19:47:40 +11:00
Sebastian Dröge 74412496cf event/message: Add new instant-rate-sync-time event and instant-rate-request message 2019-11-03 19:47:40 +11:00
Sebastian Dröge be3c4d00cf event: Add new GST_EVENT_INSTANT_RATE_CHANGE and GST_SEEK_FLAGS_INSTANT_RATE_CHANGE
A seek with that flag set must be non-flushing, not change the playback
direction and start/stop position. A seek handler will then send the new
GST_EVENT_INSTANT_RATE_CHANGE event downstream for downstream elements
to immediately apply the new playback rate before the new in-band segment
event arrives.
2019-11-03 19:47:40 +11:00
Víctor Manuel Jáquez Leal 9707db909d elementfactory: add GST_ELEMENT_FACTORY_TYPE_HARDWARE
This new symbol matches with the elements within "Hardware" class.
2019-11-02 15:11:12 +01:00
Sebastian Dröge 487a3f9a30 bin: Drop need-context messages without source instead of crashing 2019-10-22 09:46:19 +03:00