Commit graph

1093 commits

Author SHA1 Message Date
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
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
Linus Svensson
47c50b086e datetime: Add constructor for timestamps in microseconds 2019-11-25 13:31:11 +01: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
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
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
Edward Hervey
7aee718394 gstpad: Probes that return HANDLED can reset the data info field
Before GST_PAD_PROBE_HANDLED was introduced, we had to handle the case
where some probes would reset the probe info data field to NULL. This would
be considered an invalid use-case.

But with GST_PAD_PROBE_HANDLED it is totally fine to reset that, since
the probe has "handled" it.
2019-05-16 15:13:48 +02:00
Mathieu Duponchelle
2fa15d5371 event: add new seek parameter, "trickmode-interval"
When performing a key unit trickmode seek, it may be useful to
specify a minimum interval between the output frames, either
in very high rate cases, or as a protection against streams
that may contain an overly large amount of key frames.

One use case is ONVIF Section 6.5.3:

<https://www.onvif.org/specs/stream/ONVIF-Streaming-Spec.pdf>
2019-04-01 17:13:32 +00:00
Tim-Philipp Müller
dfd9fd7f82 tests: fix leak in buffer test_wrapped_bytes test 2019-03-06 09:04:54 +00:00
Mathieu Duponchelle
5dc149f4f2 gstbuffer: store meta in add order
The previous implementation of add was implemented as a prepend,
switch to append as that seems like the expected order.
2019-03-04 12:57:02 +00:00
Tim-Philipp Müller
f62ee97592 buffer: store sequence number for metas
For metas where order might be significant if multiple metas are
attached to the same buffer, so store a sequence number with the
meta when adding it to the buffer. This allows users of the meta
to make sure metas are processed in the right order.

We need a 64-bit integer for the sequence number here in the API,
a 32-bit one might overflow too easily with high packet/buffer
rates. We could do it rtp-seqnum style of course, but that's a
bit of a pain.

We could also make it so that gst_buffer_add_meta() just keeps metas in
order or rely on the order we add the metas in, but that seems too
fragile overall, when buffers (incl. metas) get merged or split.

Also add a compare function for easier sorting.

We store the seqnum in the MetaItem struct here and not in the
GstMeta struct since there's no padding in the GstMeta struct.
We could add a private struct to GstMeta before the start of
GstMeta, but that's what MetaItem effectively is implementation-
wise. We can still change this later if we want, since it's all
private.

Fixes #262
2019-02-12 17:53:08 +00:00
Nirbheek Chauhan
febfabb39f misc: Fix various compiler warnings on MinGW
gstharness.c: Use G_GSIZE_FORMAT instead of hard-coding %zu
error: unknown conversion type character 'z' in format [-Werror=format]

gst-inspect.c: GPid is void* on non-UNIX, and we only use it on UNIX
error: initialization makes pointer from integer without a cast [-Werror]

gstmeta.c: Use and then discard value
error: value computed is not used [-Werror=unused-value]

With this, gstreamer builds with -Werror on MinGW
2019-02-05 18:45:54 +05:30
Seungha Yang
5b19d30d24 tests: info: Fix spurious validation
Should be equality check, not assignment.
Additionally, use fail_unless_equals_* macro for better readability
and debugging easier, if possible.
2019-01-24 10:14:18 +09:00
Jordan Petridis
20ee2db955
tests: gstdatetime: move gst_date_time_new* and time() calls closer
While extremelly rare, time and gst_date_time_new_* will have
diff values and potentially trigger an assertion. Thus move
the calls as closely together as possible to mitigate this.
2019-01-11 12:54:54 +02:00
Jan Alexander Steffens (heftig)
a129b7df9c tests: Add more int range fixation tests 2019-01-09 23:03:08 +00:00
Sebastian Dröge
74b9e72ec6 pipeline: Call gst_task_cleanup_all() before checking reference counts after shutdown
We have to ensure that all background threads from thread pools are shut
down, or otherwise they might not have had a chance yet to drop their
last reference to the pipeline and then the assertion for a reference
count of 1 on the pipeline fails.
2019-01-03 14:05:31 +00:00
Sebastian Dröge
8b58cb03b2 pipeline: Use the test clock in all unit tests
And check for exact times as we can now do that thanks to the test clock
being deterministic.

Fixes https://gitlab.freedesktop.org/gstreamer/gstreamer/issues/313
2019-01-03 14:05:31 +00:00
Tim-Philipp Müller
156d33f30a tests: remove unused gststream.h file
Looks like an earlier version of the .c file.
2018-12-31 15:25:11 +00:00
Seungha Yang
2c0951774b tests: datetime: Fix failure on Windows
The documentation for WIN32 mktime indicates that for struct tm*
before January 1, 1970, that -1 is returned, and since mktime is timezone
dependent, the struct tm corresponding to 1:00, Jan. 1, 1970 might be failed.

See also
https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/mktime-mktime32-mktime64
2018-12-17 23:37:59 +09:00
Sebastian Dröge
2682f378c8 pad: Let threads in the test take ownership of a strong reference to their pads
Otherwise it can easily happen that the pad is destroyed before the
thread disappears, as happened sometimes in the test_pad_probe_block_add_remove
test where joining of the thread was done *after* the pad was unreffed
and destroyed.

Fixes https://gitlab.freedesktop.org/gstreamer/gstreamer/issues/339
2018-12-14 18:38:21 +02:00
Guillaume Desmottes
e03f086fae gstcaps: add gst_caps_set_features_simple()
Convenient helper setting a caps feature on all the structures of a
caps.
2018-12-11 16:39:30 +01:00
Dardo D Kleiner
ec5e781e6b buffer: Add more exhaustive test for gst_buffer_foreach_meta() meta removal
Existing test for iterating/removing buffer meta data was insufficient
to detect linked list corruption when removing multiple items, and could
also suffer from such corruption in attempting to count remaining items.
Modified the one test and added several others to exercise multiple
scenarios.

Validates fix for issue #332.
2018-12-05 20:50:45 +00:00
Jordan Petridis
84512152c1
Run gst-indent through the files
This is required before we enabled an indent test in the CI.

https://gitlab.freedesktop.org/gstreamer/gstreamer-project/issues/33
2018-11-28 05:58:53 +02:00
Seungha Yang
94ac598204 tests: caps: Add more broken caps test case 2018-11-12 20:12:50 +09:00
Havard Graff
1335110409 tests: fix tests when compiling with glib_checks=disabled
We won't be able to do ASSERT_CRITICAL, but the main body of the tests
are still valid, and given we ship GStreamer with this configuration, it
is important to be able to run some tests against it.
2018-11-10 15:37:36 +00:00
Havard Graff
320ac0ce1a test/datetime: fix test for windows
In the previous configuration, mktime returned -1 on Windows 10 compiled
with MSVC using meson.

Fix this by moving the hour one forward.
2018-11-10 15:37:36 +00:00
Havard Graff
4a7739f4b6 tests/uri: fix test after GHashTable changes in GLib 2.59
Maybe the implementation should not be dependent on a "random" hash-table
ordering, but at least this shows the problem clearly.
2018-11-10 15:37:36 +00:00
Havard Graff
4b3872f757 gstpad: use hook_id instead of hook in called_probes list
A pointer to a hook in this list can easily not be unique, given both
the slice-allocator reusing memory, and the OS re-using freed blocks
in malloc.

By doing many repeated add and remove of probes, this becomes very easily
reproduced.

Instead use hook_id, which *is* unique for a added GHook.
2018-11-06 10:04:00 +01:00
Matthew Waters
ddfcc28c8b gst/buffer: add a new function for wrapping GBytes
One restriction on the GBytes is that the data cannot be NULL as this is
explicitly forbidden by GstMemory.

Fixes https://gitlab.freedesktop.org/gstreamer/gstreamer/issues/318
2018-11-06 16:12:42 +11:00
Jan Schmidt
80015d69a7 segment: Allow stop == -1 in gst_segment_to_running_time() and rate < 0
If a segment has stop == -1, then gst_segment_to_running_time()
would refuse to calculate a running time for negative rates,
but gst_segment_do_seek() allows this scenario and uses a
valid duration for calculations.

Make the 2 functions consistent by using any configured duration
to calculate a running time too in that case.

https://bugzilla.gnome.org/show_bug.cgi?id=796559
2018-10-29 04:03:56 +11:00
Olivier Crête
5658ae9986 tests: Use GstTestClock for processing-deadline test
Use the test clock instead of using a real one to make it
easier to run in valgrind.

https://bugzilla.gnome.org/show_bug.cgi?id=797291
2018-10-17 16:42:50 -04:00
Tim-Philipp Müller
5947ff970e tests: pipeline: fix leak 2018-10-16 10:48:40 +01:00
Jan Schmidt
01758dcf6a tests: Use a different rate in a segment test.
Using a rate of 1.1 in the test is causing the test to
fail on 32-bit because ceil(1.1 * 10) can round to 12.

Instead use a rate 2.0 that can be expressed as floating
point number and doesn't trigger the problem.

https://bugzilla.gnome.org/show_bug.cgi?id=797154
2018-09-17 22:13:22 +10:00
Jan Schmidt
4aeac4b551 gstsegment: Add check for gst_segment_offset_running_time()
Add a check for gst_segment_offset_running_time() that values
are taken directly from the segment base if possible.
2018-08-28 01:54:02 +10:00
Jan Schmidt
260b9791fc gstsegment: Handle positions before the segment properly
Fixes for gst_segment_position_from_running_time_full() when
converting running_times that precede the segment start (or
stop in a negative rate segment)

The return value was incorrectly negated in those cases.

Add some more unit test checks for those cases, and especially
for segments with offsets.
2018-08-28 01:54:02 +10:00
Tim-Philipp Müller
f87d38c186 tests: meta: fix msvc compiler warnings
gstmeta.c(167): warning C4090: 'function': different 'const' qualifiers
gstmeta.c(172): warning C4090: 'function': different 'const' qualifiers
gstmeta.c(211): warning C4090: 'function': different 'const' qualifiers
gstmeta.c(216): warning C4090: 'function': different 'const' qualifiers
2018-08-26 11:45:58 +02:00
Sebastian Dröge
2aa9ad9c62 Revert "pad: Handle changing sticky events in pad probes"
This reverts commit 11e0f451eb.

When pushing a sticky event out of a pad with a pad probe or pad offset,
those should not be applied to the event that is actually stored in the
event but only in the event sent downstream. The pad probe and pad
offsets are conceptually *after* the pad, added by external code and
should not affect any internal state of pads/elements.

Also storing the modified event has the side-effect that a re-sent event
would arrive with any previous modifications done by the same pad probe
again inside that pad probe, and it would have to check if its
modifications are already applied or not.

For sink pads and generally for events arriving in a pad, some further
changes are still needed and those are tracked in
  https://bugzilla.gnome.org/show_bug.cgi?id=765049

In addition, the commit also had a refcounting problem with events,
causing already destroyed events to be stored inside pads.
2018-07-23 23:17:54 +03:00
Olivier Crête
f79b871a6a pipeline tests: Add test for processing latency 2018-07-16 11:54:15 -04:00
Sebastian Dröge
cb51bd6b31 bufferlist: Prevent gst_buffer_list_foreach() from modifying non-writeable lists
Previously gst_buffer_list_foreach() could modify (drop or replace)
buffers in non-writable lists, which could cause all kinds of problems
if other code also has a reference to the list and assumes that it stays
the same.

https://bugzilla.gnome.org/show_bug.cgi?id=796692
2018-07-09 09:45:45 +02:00
Sebastian Dröge
111faa58c0 buffer: Add test to ensure that memories in a non-writable buffer are not writable
https://bugzilla.gnome.org/show_bug.cgi?id=796692
2018-07-09 09:45:45 +02:00
Sebastian Dröge
13a45c0a38 bufferlist: Add test to ensure that buffers in an non-writable list are not writable
https://bugzilla.gnome.org/show_bug.cgi?id=796692
2018-07-09 09:45:45 +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
Guillaume Desmottes
6dba0d91ed gst_structure_to_string: display actual value of pointers
We used to always display "NULL" which was pretty confusing when
debugging.

https://bugzilla.gnome.org/show_bug.cgi?id=794355
2018-06-15 11:37:24 +02:00
Tim-Philipp Müller
a5ecb465a9 bufferlist: fix abort due to underflow when creating 0-sized list
gst_buffer_list_new_sized(0) will cause an underflow in a calculation
which then makes it try to allocate huge amounts of memory, which
may lead to aborts.

https://bugzilla.gnome.org/show_bug.cgi?id=795758
2018-05-05 16:20:05 +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