Commit graph

19219 commits

Author SHA1 Message Date
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
Stéphane Cerveau
0b1c2f715a identity: Fix a minor leak using meta_str 2020-03-13 12:14:08 +01: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
Matthew Waters
4154baedb1 basetransform: allow not passthrough if generate_output is implemented
This allows an element to not require implementing transform or
transform_ip.
2020-03-11 23:00:20 +11:00
Sebastian Dröge
8fb1fe4620 clocksync: Use g_cond_signal() instead of g_cond_broadcast()
There can only be a single waiter: on the streaming thread.
2020-03-09 21:32:28 +02:00
Sebastian Dröge
be8a15b0f9 identity: Use g_cond_signal() instead of g_cond_broadcast()
There can only be a single waiter: on the streaming thread.
2020-03-09 21:31:48 +02:00
Sebastian Dröge
c7ddc5eb79 identity: Unblock condition variable on FLUSH_START
... and immediately return FLUSHING from the streaming thread instead of
waiting potentially forever.

Fixes https://gitlab.freedesktop.org/gstreamer/gstreamer/issues/516
2020-03-09 20:27:58 +02:00
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
Mathieu Duponchelle
26ffe05ccd gstaggregator: fix the prototype of sink_event_pre_queue
This is not an API breakage, as implementors are already
expected to return a GstFlowReturn
2020-03-05 07:50:42 +00:00
Seungha Yang
0a185c24b5 gst-launch: Follow up to missing s/g_print/gst_print/g
Required to avoid broken log string on Windows but missed
in the commit of 493a3261a9
2020-03-03 18:57:45 +09:00
Seungha Yang
604766a882 tests: info: Fix thread-id pattern matching on Windows
The format modifier for thread-id prints hex value without "0x" prefix on Windows.
2020-03-02 04:16:50 +00:00
Tim-Philipp Müller
b8f5cb5a3a tracers: rusage: use thread-local storage for per-thread stats
.. instead of looking things up by thread id from a GHashTable,
which also happens to have no locking around insertion/lookup.
2020-02-28 15:54:38 +00:00
Tim-Philipp Müller
04aad3f4cf tracers: rusage: fix minor string leak in constructor 2020-02-28 15:54:38 +00:00
Johan Bjäreholt
ef0df31c5e gst-stats: Fix missing NULL checks
gst-inspect-1.0 segfaults on tracing logs where it fails to find
element stats. So on the pipelines where we get the following WARNING
during execution will afterwards crash with a segfault as the
g_ptr_array has a index for it but it is just a NULL pointer.

WARN default gst-stats.c:444:do_message_stats: no element stats found for ix=X

An example of an pipeline which can reproducibly create a trace log
where this occurs would be this

GST_DEBUG="GST_TRACER:7" GST_TRACERS="stats;rusage;latency" gst-launch-1.0 videotestsrc num-buffers=120 ! autovideosink &> trace.log
gst-stats-1.0 trace.log
2020-02-28 15:14:58 +00:00
Olivier Crête
19f414c0d1 basesink: Improve clarity of latency query maths debug message
Add the equation to the debug message to make it easier for non-GStreamer
experts to understand why their pipeline has latency.
2020-02-27 16:53:18 +00:00
Nirbheek Chauhan
0bf31fb1d8 tests: Maintain compatibility with GLib 2.48
That's the minimum version of GLib we require right now.

Fixes https://gitlab.freedesktop.org/gstreamer/gstreamer/issues/514
2020-02-26 19:22:32 +00:00
Jan Schmidt
81d55fb479 clocksync: Add new clocksync element
The clocksync element is a generic element that can be
placed in a pipeline to synchronise passing buffers to the
clock at that point. This is similar to 'identity sync=true',
but because it isn't GstBaseTransform-based, it can process
GstBufferLists without breaking them into separate GstBuffers
2020-02-26 16:36:29 +00:00
Seungha Yang
2af630b0c1 gst-inspect: Add define guard for g_log_writer_supports_color()
g_log_writer_supports_color() was introduced since GLib 2.50.0
which is slightly higher version than our minimum required GLib version.
2020-02-26 22:35:26 +09:00
Nirbheek Chauhan
e9085043c1 Don't use glib format modifiers with sscanf or printf
We do not have a way to know the format modifiers to use with string
functions provided by the system. `G_GUINT64_FORMAT` and other string
modifiers only work for glib string formatting functions. We cannot
use them for string functions provided by the stdlib. See:
https://developer.gnome.org/glib/stable/glib-Basic-Types.html#glib-Basic-Types.description

F.ex.:

```
 ../tools/gst-stats.c:921:11: error: too many arguments for format [-Werror=format-extra-args]
   printf ("Number of Buffers passed: %" G_GUINT64_FORMAT "\n", num_buffers);
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../tools/gst-stats.c:922:11: error: unknown conversion type character 'l' in format [-Werror=format=]
   printf ("Number of Events sent: %" G_GUINT64_FORMAT "\n", num_events);
           ^~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /builds/nirbheek/cerbero/cerbero-build/dist/windows_x86_64/include/glib-2.0/glib/gtypes.h:32,
                 from /builds/nirbheek/cerbero/cerbero-build/dist/windows_x86_64/include/glib-2.0/glib/galloca.h:32,
                 from /builds/nirbheek/cerbero/cerbero-build/dist/windows_x86_64/include/glib-2.0/glib.h:30,
                 from ../gst/gst.h:27,
                 from ../tools/tools.h:28,
                 from ../tools/gst-stats.c:30:
/builds/nirbheek/cerbero/cerbero-build/dist/windows_x86_64/lib/glib-2.0/include/glibconfig.h:69:28: note: format string is defined here
 #define G_GUINT64_FORMAT "llu"
                            ^
```

and

```
../tests/misc/netclock-replay.c: In function 'main':
../tests/misc/netclock-replay.c:98:23: error: unknown conversion type character 'l' in format [-Werror=format=]
     if (sscanf (line, "%" G_GUINT64_FORMAT " %" G_GUINT64_FORMAT " %"
                       ^~~
In file included from /builds/nirbheek/cerbero/cerbero-build/dist/windows_x86/include/glib-2.0/glib/gtypes.h:32,
                 from /builds/nirbheek/cerbero/cerbero-build/dist/windows_x86/include/glib-2.0/glib/galloca.h:32,
                 from /builds/nirbheek/cerbero/cerbero-build/dist/windows_x86/include/glib-2.0/glib.h:30,
                 from ../tests/misc/../../libs/gst/net/gstntppacket.c:38,
                 from ../tests/misc/netclock-replay.c:31:
/builds/nirbheek/cerbero/cerbero-build/dist/windows_x86/lib/glib-2.0/include/glibconfig.h:69:28: note: format string is defined here
 #define G_GUINT64_FORMAT "llu"
                            ^
```

This is needed for upgrading glib inside Cerbero which builds with
`-Werror` on Windows:
https://gitlab.freedesktop.org/gstreamer/cerbero/merge_requests/419
2020-02-25 21:22:28 +05:30
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
Matus Gajdos
826230ba1b baseparse: fix memory leak
A buffer to be skipped wasn't unref'd in gst_base_parse_chain().

Fixes #406
2020-02-15 17:58:23 +00:00
Olivier Crête
447cae6229 leak tracer: Initialize GValue 2020-02-15 11:19:54 +00:00
Thibault Saunier
14cd8b8348 leaks: Do not trace refs for object we do not follow
When the user sets filters, we should not trace ref counts of object that
are not traced. This optimizes the tracer by potentially avoiding
generating useless backtraces.
2020-02-14 23:07:53 +00:00
Zebediah Figura
d28e0b4147 baseparse: Set the private duration before posting a duration-changed message
Otherwise an application cannot rely on a subsequent call to e.g. gst_pad_query_duration() succeeding.
2020-02-14 18:17:38 +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
Seungha Yang
66819febd9 docs: Fix bold markdown syntax for GST_DEBUG_NO_COLOR
Fixing markdown syntax
2020-02-13 15:43:45 +09: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
Sebastian Dröge
6ab1cdf51d basetransform: Make gst_base_transform_reconfigure() public
This has the same function as the negotiate() functions in various other
base classes and is required to be able to completely re-implement
submit_input_buffer() in subclasses.
2020-02-10 13:19:26 +02:00
Thibault Saunier
baa5aae24b baseparse: Don't set meaningless buffer dts from segment->start
When we do not have any information about DTSs we shouldn't try to make
them up, moreover after seeking `segment->start` has nothing to do with
the next buffer timing (and is probably after the actual buffer timestamp)
and since, since fa8312472f
we do:

```
if (buffer->dts > buffer->dts)
    buffer->pts = buffer->dts
```

we end up setting `buffer->pts = segment->start` which is plain
broken and leads to downstream decoder accept the first buffer
as it will be inside the segment (its pts==segment->start) which
basically means accurate seeking behaves mostly the same way as
keyframe seeks.

Fixes https://gitlab.freedesktop.org/gstreamer/gstreamer/issues/492
2020-02-04 18:14:05 +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
Sebastian Dröge
48f14c5e5e aggregator: Initialize source pad segment position to -1 when resetting
This allows start-time selection in gst_aggregator_pad_chain_internal()
to actually work as that code assumes it to be -1 for actually
overriding the value.

Fixes https://gitlab.freedesktop.org/gstreamer/gstreamer/issues/500
2020-01-23 19:27:14 +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
Mathieu Duponchelle
4f9cac06e4 gst-launch: handle ERROR messages in the sync handler
Errors causing the pipeline to fail going from NULL to PAUSED
were not displayed, and the pipeline was not dumped either in
those cases.

In addition, dumping the pipeline from the sync handler means
the dump matches exactly the state of the pipeline at the
moment the error was posted.
2019-12-27 10:06:45 +00:00
Seungha Yang
b5c19c7426 gst-inspect: Increase array size for printing rank name
Now the rank value can be MAX_INT (2147483647)
2019-12-26 19:49:00 +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
Mathieu Duponchelle
8140da74ba tests: remove system-dependent tests
We now have GstTestClock-based tests that validate the same logic,
without inducing spurious timing failures / overly relying on sleeps.

Fixes: #346
Fixes: #347
Fixes: #348

Co-authored by: Thibault Saunier <tsaunier@igalia.com>
2019-12-20 16:46:39 +00:00
Thibault Saunier
767e0e46e9 tests-clock: Fix race in test_late_crank
There was a case where we started waiting on the clock before setting
the clock time, leading to the wait succeeding instead of being late:

    gsttestclock.c:1073:F:testclock:test_late_crank:0: '1 * GST_SECOND' (1000000000) is not equal to 'context.jitter' (-4000000000)

Fixes https://gitlab.freedesktop.org/gstreamer/gstreamer/issues/426

Co-authored by: Mathieu Duponchelle <mathieu@centricular.com>
2019-12-20 15:51:45 +00:00
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