Commit graph

2730 commits

Author SHA1 Message Date
Edward Hervey 67df099241 check: uri: Check return value
CID #1455381

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/472>
2020-05-08 12:11:20 +02:00
Edward Hervey 9daf1ca44e check: gstvalue: Check return value
As is done everywhere else

CID #1455540

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/472>
2020-05-08 12:11:20 +02:00
Edward Hervey f085dabebc check: testclock: Check return values
As done everywhere else.

CID #1455383
CID #1455524

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/472>
2020-05-08 12:11:20 +02:00
Edward Hervey b6c9491c92 check: gst_promise_reply() takes ownership
Copy the structure temporarily to check it further down.

CID #1455392

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/472>
2020-05-08 12:10:38 +02:00
Edward Hervey 78b0baa7c9 check: Don't leak test string
Turns out the length returned by `__gst_vasprintf()` doesn't include the final
`\0`.

CID #1455430

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/472>
2020-05-08 12:10:38 +02:00
Matej Knopp cab5b22f21 taglist: Fix crash when comparing two lists of the same length but with different items
Fixes #549

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/469>
2020-05-08 11:04:14 +03:00
Jan Schmidt e329e1f769 tests/input selector: Fix a shutdown crash
Hold a ref to the pad we're planning on sending EOS too, so that
it doesn't disappear if things shut down before the thread gets
to actually send the EOS event.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/467>
2020-05-07 03:30:43 +10:00
Sebastian Dröge 687c65994e clocksync: Remove handoff signals
They're not really useful on this element and were just a leftover from
identity.

Fixes https://gitlab.freedesktop.org/gstreamer/gstreamer/-/issues/540

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/443>
2020-05-04 09:21:02 +03:00
Sebastian Dröge ed1022fa81 Use gst_object_unref() / gst_object_clear() instead of the GObject ones
To allow the refcounting tracer to work better. In childproxy/iterator
these might be plain GObjects but gst_object_unref() also works on them.
In other places where it is never GstObject, g_object_unref() is kept.
2020-04-20 16:28:52 +00:00
Thibault Saunier 88f0312624 value: Fix segfault comparing empty GValueArrays
Adding a test
2020-04-12 20:33:43 -04:00
Jan Schmidt e94ad24b9f baseparse: Don't return more data than asked for in pull_range()
Even when pulling a new 64KB buffer from upstream, don't return
more data than was asked for in the pull_range() method and then
return less later, as that confused subclasses like h264parse.

Add a unit test that when a subclass asks for more data, it always
receives a larger buffer on the next iteration, never less.

Fixes https://gitlab.freedesktop.org/gstreamer/gstreamer/-/issues/530
2020-04-08 19:13:25 +10:00
Nicolas Dufresne e272ae281f task: Introduce gst_task_resume() API
This new API allow resuming a task if it was paused, while leaving it to
stopped stated if it was stopped or not started yet. This new API can be
useful for callback driver workflow, where you basically want to pause and
resume the task when buffers are notified while avoiding the race with a
gst_task_stop() coming from another thread.
2020-04-01 15:13:59 +00:00
Jan Schmidt e906197c62 baseparse: Fix upstream read caching
When running in pull mode (for e.g. mp3 reading),
baseparse currently reads 64KB from upstream, then mp3parse
consumes typically around 417/418 bytes of it. Then
on the next loop, it will read a full fresh 64KB again,
which is a big waste.

Fix the read loop to use the available cache buffer first
before going for more data, until the cache drops to < 1KB.

Fixes https://gitlab.freedesktop.org/gstreamer/gstreamer/issues/518
2020-04-01 18:36:19 +11:00
Matthew Waters b3afd1a2fc flowcombiner: passthrough the flow return if there are no pads
What may happen is that during the course of processing a buffer,
all of the pads in a flow combiner may disappear.  In this case, we
would return NOT_LINKED.  Instead return whatever the input flow return
was.
2020-03-26 02:31:52 +00:00
Ondřej Hruška 99f7226344 gstdatetime: Add missing NULL check to gst_date_time_new_local_time
Also add a unit test for this.

Fixes #524
2020-03-22 14:00:41 +00: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
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
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
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
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
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
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
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
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
Mathieu Duponchelle 25d7914395 tests: fix pipelines_parse_launch.delayed_link flakiness
Fixes #345

There were two causes for the flakiness, one much rarer than
the other.

The test sets up a source with a sometimes pad added during
the transition of a wrapper bin from READY to PAUSED.

It runs 4 iterations, the last of which makes it so the
negotiation fails.

In that case, the intention as correctly presented by the following
comment:

/* [..] ie, the pipeline should create ok but fail to change state */

However the implementation of run_delayed_test was neither calling
get_state on the pipeline (it called it on the wrapper bin), nor
checking that the return of get_state was FAILURE (it actually
checked that it was not).

This led to an obvious race condition, and was fixed by calling
get_state on the pipeline, then checking that in this specific
case (expect_link == FALSE), the state change has actually failed.

The second, rarer race condition is at set_state time. When we
don't expect the link to succeed, the return of set_state may
either be FAILURE or ASYNC, depending on timing. This was fixed
by taking expect_link into account when checking the return value
of set_state.

Co-authored by: Thibault Saunier <tsaunier@igalia.com>
2019-12-14 11:25:20 +00:00
Olivier Crête 0a8d14acc9 Remove deprecated GTimeVal
GTimeVal won't work past 2038
2019-12-10 19:18:32 -05:00
Linus Svensson 47c50b086e datetime: Add constructor for timestamps in microseconds 2019-11-25 13:31:11 +01:00
Tulio Beloqui a11f53e131 harness: fixed race condition on forward pad while forwarding sticky events to sink harness
Co-authored-by: Camilo Celis <camilo@pexip.com>
Co-authored-by: Havard Graff <hgr@pexip.com>
2019-11-13 20:33:51 +00:00
Tim-Philipp Müller 10d9e18f02 Remove autotools build system 2019-10-13 16:10:42 +01:00
Edward Hervey 6babf1f086 core: Avoid usage of deprecated API
GTimeval and related functions are now deprecated in glib.
Replacement APIs have been present since 2.26
2019-10-10 15:53:16 +02:00
Xavier Claessens d109dd2752 dataurisrc: Do not include trailing \0 into buffer 2019-10-07 17:47:47 +00:00
Aaron Boxer 509f6201e1 documentation: fix a number of typos 2019-10-06 11:12:11 -04:00
Mathieu Duponchelle 0dafe6e639 gstvalue: use value_nick for serialization
not value_name . This was causing incorrect launch lines to be
displayed by gst-device-monitor, and the deserialization code
below works with nicks.
2019-09-17 01:09:05 +00:00
Sebastian Dröge 04a7334140 info: Deprecate gst_debug_category_free()
And change it to do nothing at all.

As debug categories don't use reference counting and they can be
retrieved from anywhere at any time by name, it is fundamentally unsafe
to free them at any point in time except for right before the end of the
process.

No code apart from a unit test seems to be currently using the function,
so deprecate it and also change it to do nothing at all.
2019-07-15 11:35:07 +03:00
Nirbheek Chauhan b3c4ed7144 tests: Add test for new activity-tracking leaktracer API 2019-07-02 15:13:26 +05:30
Nirbheek Chauhan 5524137d7e tests: Add test for new live-objects leaktracer API
Needs a valgrind suppression for:

==11119== Warning: invalid file descriptor -1 in syscall close()
==11119== Warning: invalid file descriptor -1 in syscall close()
==11119== Syscall param write(buf) points to uninitialised byte(s)
==11119==    at 0x4C4AFAD: syscall (in /usr/lib64/libc-2.29.so)
==11119==    by 0x4E70DF9: write_validate (Ginit.c:112)
==11119==    by 0x4E70DF9: UnknownInlinedFun (Ginit.c:148)
==11119==    by 0x4E70DF9: mincore_validate (Ginit.c:131)
==11119==    by 0x4E70CC3: UnknownInlinedFun (Ginit.c:208)
==11119==    by 0x4E70CC3: access_mem (Ginit.c:242)
==11119==    by 0x4E75536: UnknownInlinedFun (libunwind_i.h:168)
==11119==    by 0x4E75536: apply_reg_state (Gparser.c:863)
==11119==    by 0x4E75A71: _ULx86_64_dwarf_step (Gparser.c:952)
==11119==    by 0x4E71BD3: _ULx86_64_step (Gstep.c:71)
==11119==    by 0x48BAF47: generate_unwind_trace (gstinfo.c:2726)
==11119==    by 0x48BC92E: gst_debug_get_stack_trace (gstinfo.c:2908)
==11119==    by 0x49B2BB2: handle_object_created.part.0 (gstleaks.c:384)
==11119==    by 0x488134E: gst_object_constructed (gstobject.c:141)
==11119==    by 0x49EC61B: g_object_new_internal (gobject.c:1845)
==11119==    by 0x49EE347: g_object_new_valist (gobject.c:2128)
==11119==    by 0x49EE69C: g_object_new (gobject.c:1648)
==11119==    by 0x48CA59D: gst_pad_new_from_template (gstpad.c:867)
==11119==    by 0x68C209E: gst_base_src_init (gstbasesrc.c:454)
==11119==    by 0x4A0A0C3: g_type_create_instance (gtype.c:1858)
==11119==    by 0x49EC42C: g_object_new_internal (gobject.c:1805)
==11119==    by 0x49EDB14: g_object_new_with_properties (gobject.c:1973)
==11119==    by 0x49EE6C0: g_object_new (gobject.c:1645)
==11119==    by 0x48AF91A: gst_element_factory_create (gstelementfactory.c:372)
==11119==  Address 0x1ffeffe000 is on thread 1's stack
==11119==  in frame #6, created by generate_unwind_trace (gstinfo.c:2695)

Fixed in libunwind commit:
b256722d49

Needs a separate suppression for Debian because the callstack is
different there.
2019-07-02 15:13:26 +05:30
Nicolas Dufresne 8a9b20a18b bufferpool: Fix the buffer size reset code
The offset in gst_buffer_resize() is additive. So to move back the
offset to zero, we need to pass the opposite of the current offset. This
was raised through the related unit test failingon 32bit as on 64bit
the alignment padding was enough to hide the issue. The test was
modified to also fail on 64bit. This patch will remove spurious
assertions like:

  assertion 'bufmax >= bufoffs + offset + size' failed

Fixes #316
2019-07-01 16:49:04 -04:00
Carlos Rafael Giani 6412988975 basesrc: Add public gst_base_src_negotiate () function
This is useful for when format changes occur mid-stream.
2019-07-01 11:16:09 +02:00
Nicolas Dufresne 91543bd78d testclock: Allow calling crank with a past entry
At the moment, we can only use crank if the pending entry is in the
future. This patch leaves the clock time to the same point if the
pending entry was in the past. This still execute a single entry. This
will be needed for the jitterbuffer, since as soon as we stop waking up
the jitterbuffer when the timer is reschedule later, we may endup with
such case in the unit tests.

Related to #608
2019-06-27 20:09:43 +00:00
Mathieu Duponchelle 25383eaa5c aggregator: refactor flushing logic
Instead of tracking "pending_flush_*" on the pads and the
aggregator, we now simply track the last seqnum for flush start
and flush stop events on the pads, and use it to determine whether
we should enter or exit our flushing state.

See https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/issues/977
2019-06-10 23:04:31 +02:00
Mathieu Duponchelle 7cc933dec7 valgrind: revert generic suppression of ld-related errors
the replacement suppression casts way too large a net, ignoring
all leaks in the main thread
2019-06-06 03:47:05 +02:00
Mathieu Duponchelle 2fadd20cc9 valgrind: ignore dlopen leaks when parsing launch lines 2019-06-06 00:04:51 +00:00
Mathieu Duponchelle c7e4497a53 valgrind: suppress intentional debug list item leak 2019-06-06 00:04:51 +00:00
Niels De Graef 56d19cbf75 meson: Bump minimal GLib version to 2.44
This means we can use some newer features and get rid of some
boilerplate code using the `G_DECLARE_*` macros.

As discussed on IRC, 2.44 is old enough by now to start depending on it.
2019-06-03 08:51:40 +02:00