Commit graph

2687 commits

Author SHA1 Message Date
Jan Schmidt 867bfb840e 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

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/733>
2021-01-13 11:25:58 +00:00
Mathieu Duponchelle fa8ea66418 queue2: don't post unnecessary buffering message, refine locking
This is a follow up to review comments in !297

+ The posting of the buffering message in READY_TO_PAUSED isn't
  needed, removing it made the test fail, but the correct fix
  was simply to link elements together

+ Move code to relock the queue and set last_posted_buffering_percent
  and percent_changed inside the buffering_post_lock in create_write().
  This makes locking consistent with post_buffering()

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/297>
2020-09-20 01:12:15 +01:00
Carlos Rafael Giani f66959c275 queue2: Fix missing/dropped buffering messages at startup
This fixes a bug that occurs when an attempt is made to post a buffering
message before the queue2 was assigned a bus. One common situation where
this happens is when the use-buffering property is set to TRUE before the
queue2 was added to a bin.

If the result of gst_element_post_message() is not checked, and the
aforementioned situation occurs, then last_posted_buffering_percent and
percent_changed will still be updated, as if posting the message succeeded.
Later attempts to post again will not do anything because the code then
assumes that a message with the same percentage was previously posted
successfully and posting again is redundant.

Updating these variables only if posting succeed and explicitely
posting a buffering message in the READY->PAUSED state change ensure that
a buffering message is posted as early as possible.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/297>
2020-09-20 01:12:14 +01:00
Thibault Saunier c666a9a7e1 value: Fix segfault comparing empty GValueArrays
Adding a test
2020-06-07 01:41:52 +01:00
Jan Schmidt 177d0fa1c2 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-06-07 00:47:41 +01:00
Ondřej Hruška 7b0e6f3e62 gstdatetime: Add missing NULL check to gst_date_time_new_local_time
Also add a unit test for this.

Fixes #524
2020-06-04 22:59:10 +00:00
Miguel Paris 687c0f0ce7 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-06-04 21:49:02 +00:00
Nicolas Dufresne 53bf06c088 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-08-08 18:49:40 +01:00
Edward Hervey 53e879c750 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-08-08 09:49:31 +01:00
Mathieu Duponchelle 5f21596795 tests: basesrc: unref gst_bus_timed_pop_filtered return 2019-04-17 23:03:56 +02:00
Mathieu Duponchelle fee108f7cf basesrc: do not send EOS when automatic_eos is FALSE 2019-04-05 18:00:29 +00: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
Antonio Ospite 763d01f437 tests: add the valgrind suppression file from the "common" module
Other gstreamer repositories have their own valgrind suppression file
directly in the repository.

Add a suppression file to the core gstreamer repository too, this makes
it easier to use it with gst-build which does not check out the common
module.

This is also a little step towards the removal of the common submodule.

NOTE: the added file is the latest version from the "common" repository
but it has been renamed from gst.supp to gstreamer.supp for symmetry
with the suppression files in the other repositories.
2019-03-24 18:11:41 +00:00
Seungha Yang ec0e4ae0c3 tests: fdsrc: Exclude unit test on Windows
Since elements_fdsrc.test_num_buffers uses blocking pipe on Windows,
the test will never be finished. But emulating non-blocking fd without
win32 APIs on Windows is a little tricky.
2019-03-10 11:48:31 +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
Edward Hervey ef8f045ff9 test: Set PTS on proper variable
This would previously set the PTS on a random address causing various
memory corruption
2019-01-29 12:01:59 +01:00
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
Edward Hervey fe6c905659 examples: Remove dead assignments
Those values are always set after before usage
2018-12-15 11:08:09 +01: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
KimTaeSoo afcae3f05b baseparse: Add unit test for short reads
Before the previous commit, buffer pulling count and chain function call
counts are not equal due to EOS. After the modification, these counts
are equal so unit test is passing.

https://gitlab.freedesktop.org/gstreamer/gstreamer/merge_requests/33
https://gitlab.freedesktop.org/gstreamer/gstreamer/issues/294
2018-11-28 17:46:12 +02: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
Matthew Waters 4fc4ad87d5 query: add a new bitrate query
Allows determining from downstream what the expected bitrate of a stream
may be which is useful in queue2 for setting time based limits when
upstream does not provide timing information.

Implement bitrate query handling in queue2

https://gitlab.freedesktop.org/gstreamer/gst-plugins-base/issues/60
2018-11-07 15:04:14 +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
Tim-Philipp Müller af5717b364 tests: netclock-replay: fix build with new api export/import
Can't mix/match imports and exports from the same library
here, so just include all .c files needed instead and don't
link to gstnet at all then.

https://bugzilla.gnome.org/show_bug.cgi?id=797185
2018-09-24 08:39:39 +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
Nirbheek Chauhan cbd02b9584 meson: Always use a dependency object for dependencies
Fixes a configure error with gst-build:

subprojects/gst-plugins-base/meson.build:235:2: ERROR:  Fetched variable 'gst_check_dep' in the subproject 'gstreamer' is not a dependency object.
2018-09-05 16:33:43 +05:30
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 3ee4896bef filesink: Use SYNC_AFTER flag in seeking test
Otherwise it's not guaranteed that buffers are actually on disk after
pushing them, and reading the file via g_file_get_contents() might not
include them yet.
2018-08-17 17:26:17 +03:00
Tim-Philipp Müller 6d34f57cb6 meson: add option to disable build of GStreamer unit test library 2018-08-10 01:23:35 +01:00