Commit graph

162 commits

Author SHA1 Message Date
Sebastian Dröge 9eb3ab3a59 ptp: Silence warning about some unused trait methods
These are not used yet but will likely be useful in the future.
Rust 1.79 (nightly) is warning about them being unused.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/6601>
2024-04-10 14:33:46 +00:00
Mark Nauwelaerts e019093fbf adapter: align documentation to actual behavior
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/6535>
2024-04-04 16:55:35 +00:00
Sebastian Dröge 6d3ed65179 basesrc: Clear submitted buffer lists consistently with buffers
And handle the case of a NULL buffer being returned cleanly, which is
valid as long as a buffer list is returned instead. Previously this
would cause an assertion because of calling gst_buffer_unref() with
NULL.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/6460>
2024-03-27 16:16:10 +00:00
Taruntej Kanakamalla 6a67ae1bfa net/gstptpclock: fix double free of domain data during deinit
The attempt to free the domain data is happeing twice during the ptp deinit.
Once while iterating through the list domain_data and second while iterating
through the list domain_clocks, so this is crashing the application
trying to gst_ptp_deinit

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/6443>
2024-03-27 17:54:46 +05:30
Sebastian Dröge 6c3d09e279 ptp: Initialize expected DELAY_REQ seqnum to an invalid value
This allows distinguishing pending syncs that didn't have a DELAY_REQ
sent from ones that did but used a seqnum of 0, like the very first one.

Specifically, if the first one or more syncs are still pending and we
send the first DELAY_REQ for a later pending sync, then the DELAY_RESP
would've been wrongly associated to the very first pending sync because
of the seqnum.

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

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/6361>
2024-03-13 22:24:56 +00:00
Antonio Larrosa bd97973ce0 registry, ptp: Canonicalize the library path returned by dladdr
On systems using UsrMerge (like openSUSE or Fedora), /lib64 is
a symlink to /usr/lib64. So dladdr is returning the path to
the gstreamer library in /lib64 in priv_gst_get_relocated_libgstreamer.
Later gst_plugin_loader_spawn tries to build the path to the
gst-plugin-scanner helper from /lib64 and ends up trying to use
/lib64/../libexec/gstreamer-1.0/gst-plugin-scanner which doesn't exist.

By canonicalizing the path with a call to realpath, gst-plugin-scanner
is found correctly under
/usr/lib64/../libexec/gstreamer-1.0/gst-plugin-scanner

Similar change applied to gstreamer/libs/gst/net/gstptpclock.c

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/6322>
2024-03-12 15:51:36 +00:00
François Laignel 7b5a5afa3a ptp clock: fix annotations for gst_ptp_clock_new
* Set `name` as `nullable` same as for gst_ntp_clock_new.
* Set return value as nullable as the constructor can fail.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/6251>
2024-03-06 12:17:17 +00:00
Sebastian Dröge 9ab9ceb964 ptp-helper: Fix clippy warning and simplify code a bit
warning: you seem to be trying to use `match` for an equality check. Consider using `if`
   --> ../subprojects/gstreamer/libs/gst/helpers/ptp/main.rs:246:17
    |
246 | /                 match ptp_message.message_type {
247 | |                     PtpMessageType::DELAY_REQ => {
248 | |                         if args.verbose {
249 | |                             trace!("Ignoring our own PTP message");
...   |
253 | |                     _ => (),
254 | |                 }
    | |_________________^

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/6245>
2024-03-06 09:17:53 +00:00
Sebastian Dröge 8859f257c2 ptp: Don't install test executable
And handle it like all our other test executables.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/6262>
2024-03-05 18:55:00 +00:00
Jochen Henneberg c6636533d4 ptp-helper: Allow sync to master clock on same host
If we drop all messages with the same clock id as ours we will also
drop all messages coming from a PTP clock on our host since both clock
ids are build from the same MAC address.

At least for Linux we do not see our own messages anyway since the
network stack can well distinguish between multicast send from our
socket or from another socket on the same machine. To make sure that
this works for all supported platforms just drop delay requests since
this is the only message that is sent from the GStreamer PTP clock.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/6172>
2024-02-22 07:52:35 +00:00
Guillaume Desmottes b6d8a55103 basesrc: add FIXME 2.0 about automatic_eos
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/1334>
2024-02-08 10:51:56 +01:00
Thibault Saunier 726dd5f09f basesrc: Lower verbosity of often happening warning
decodebin(3) runs a scheduling query before pads are activated which
ultimately triggers basesrc->start which will automatically call
`gst_base_src_start_complete` for any source that is not marked as
'async'. This calls will harmlessly bail out in `not_activated_yet`
so we should not warn in that case.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/6011>
2024-01-30 09:09:22 +00:00
Thibault Saunier a4156ebeee basesink: Preroll on out of segment buffers when not dropping them
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5980>
2024-01-29 18:57:33 +00:00
Thibault Saunier 9afab6107f gdb: Fix the way we wrap segments
Without that we end up with a reference to a GBoxed instead of the actual segment making the rest of the code fail

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5986>
2024-01-25 12:27:29 +00:00
Thibault Saunier f09da2db0e gdb: Fix issue with undeclared variable
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5986>
2024-01-25 12:27:29 +00:00
Thibault Saunier e98c515c58 gdb: Handle the case where the fundamental type table is optimized out
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5986>
2024-01-25 12:27:29 +00:00
Thibault Saunier f1070b4380 gdb: Fix python style
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5986>
2024-01-25 12:27:29 +00:00
Thibault Saunier 6258ee56d2 gdb: Workaround optimized out quark_seq_id
On fedora 38 (and it was the case in previous releases), the
quark_seq_id is optimized out so getting quarks from the
global variable always failed. This patch works around that by assuming
it is a valid quark whenever the quark_seq_id is not accessible.

This issue often manifested as Python Exception <class 'TypeError'>:
can only concatenate str (not "NoneType") to str when debugging as
other parts of the code assume that getting the quark for a GType name
will work.

Same as https://gitlab.gnome.org/GNOME/glib/-/merge_requests/3559

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5986>
2024-01-25 12:27:29 +00:00
Sebastian Dröge 5630294ce6 ptp-helper: Allow unused Stderr export
It's not used when building tests and would otherwise cause a warning.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5872>
2023-12-29 10:18:52 +02:00
Nicolas Dufresne 73338aa1ae doc: baseparse: Clarify consumed vs output size
When we finish a frame, we pass a size which semantic can easily be confused.
Improve the documentation to clarify that the parameter size is the amount of
input data being consumed and, if set, the output_buffer size can differ.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5754>
2023-12-19 16:08:08 -05:00
Alexander Slobodeniuk 97e748466e aggregator: fix use-after-free in queries processing
Test included.
The problem appears when aggregator drops the query while
it's being proccessed by the klass->sink_query handler.
This can happen on FLUSH_START event. If the query is still
in the queue, it can be safely dropped, but if it's already
in the klass->sink_query() handler, then sink pad has no
choice and has to wait for the proccessing to complete.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5765>
2023-12-13 00:06:38 +01:00
Thibault Saunier 6dc86b1f91 basesrc: Expose automatic-eos as a property
It is useful for appsrc for example and no good reason to not expose it as a property

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5725>
2023-12-05 14:04:05 +00:00
Jan Alexander Steffens (heftig) 393e254255 baseparse: Reset metadata for reverse playback fragment buffers
Don't let the adapter leak uncontrollable values.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5718>
2023-11-27 14:38:45 +00:00
Jan Alexander Steffens (heftig) 3319d152a8 baseparse: Add missing gst_buffer_make_writable
When the subclass attempts to finish without an explicit `out_buffer`,
we take a buffer from our adapter. We need to make this buffer writable
before copying the metadata.

This led to data races such as in the following pipeline, which randomly
messed up the buffer PTS:

    gst-launch-1.0 -e audiotestsrc timestamp-offset=5555 num-buffers=100 \
      ! opusenc ! tee name=t ! queue ! opusparse ! fakesink silent=0 \
      t. ! queue ! opusparse ! fakesink silent=0 -v | grep '0000, dur'

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5718>
2023-11-27 14:38:44 +00:00
Jordan Yelloz 66f51f642f bad: Added W3C Media Source Extensions library
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/2992>
2023-11-19 13:48:43 +00:00
Sebastian Dröge ba5684d0d7 ptp: Add ttl configuration to gst_ptp_init_full()
This allows configuring the TTL that is used for multicast packets sent
out on the sockets, and is defaulting to 1 as before. The default might
change at some point.

In some networks multiple hops are needed to reach the PTP clock and
this allows to configure GStreamer in a way that works in such networks.

At a later time, per-domain or per-interface TTL configurations might be
added when needed.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5649>
2023-11-16 12:26:02 +00:00
Sebastian Dröge 12159cb294 ptp: Add new gst_ptp_init_full()
This takes a free-form GstStructure as parameter that allows to easily
extend it with new configuration at a later time without having to add
new API.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5649>
2023-11-16 12:26:02 +00:00
Sebastian Dröge ffa30637c4 ptp: Use SO_BINDTOIFINDEX / SO_BINDTODEVICE on Linux
This makes sure we really really really only get packets from the
desired interface as passing a device to IP_ADD_MEMBERSHIP apparently
does not have this effect alone.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5584>
2023-11-02 11:42:44 +00:00
Sebastian Dröge d6adaccf6d ptp: Check once a second for timeouts
While the minimum timeout duration is 5s, checking only every 5s means
that we would notice this 4.9s too late in the worst case.

Checking once a second reduces this considerably while keeping the
number of wakeups still low.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5520>
2023-11-02 09:11:09 +00:00
Sebastian Dröge 9ba8107ec6 ptp: Only warn if the clock id and interface of a timed out matches the current one
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5520>
2023-11-02 09:11:09 +00:00
Sebastian Dröge bd985ea608 ptp: Only time out SYNCs if we're actually waiting for a FOLLOW_UP
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5520>
2023-11-02 09:11:09 +00:00
Sebastian Dröge c7421c0f16 ptp: Downgrade clocks that don't send FOLLOW_UPs / DELAY_RESPs
This allows to select a different clock if there is one that is
for the same grandmaster clock and has fewer timeouts.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5520>
2023-11-02 09:11:09 +00:00
Sebastian Dröge ea7861a757 ptp: Don't switch domain's master clock if it is equivalent to the previous one
Otherwise it can happen that we regularly switch back and forth between
clocks under certain circumstances for no good reason.

Also remove redundant comparison when comparing the steps removed between two
clocks.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5520>
2023-11-02 09:11:09 +00:00
Sebastian Dröge 9e51f1f182 aggregator: Allow passing unparented pads to gst_aggregator_pad_is_inactive()
It's very difficult to ensure that a pad is still child of the
aggregator during aggregation, so simply consider unparented pads as
inactive instead of asserting.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5510>
2023-10-25 07:56:41 +00:00
Sebastian Dröge 35c3689c44 aggregator: Also release clipped buffer when releasing an aggregator pad
Instead of waiting until the pad is actually finalized.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5510>
2023-10-25 07:56:41 +00:00
Sebastian Dröge 70ee7293e0 aggregator: Take pad lock while releasing buffers when removing pads
Accessing the buffers in all other places requires the pad lock and not
taking it here can cause access to already freed buffers if there's
concurrent access from another thread.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5510>
2023-10-25 07:56:40 +00:00
Sebastian Dröge 134a66277e ptp: Fix a couple of stylistic clippy warnings
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5441>
2023-10-06 13:39:34 +03:00
Alexander Slobodeniuk 5ad1f00605 aggregator: fix start-time-selection=first on negative rate
When the property "start-time-selection" is set to "first", it
calculates the start time of the output from the buffer pts
(converting it to running time of the segment), but if the
rate is negative, the real start is not the pts, but the
pts + duration, because it plays from the end of the buffer
to it's start.
As a result of this bug, in the negative rate, when the
start-time-selection=first, the first frame is dropped
by the videoaggregator (reproduced on d3d11compositor).

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5276>
2023-09-28 16:32:37 +00:00
Xavier Claessens 0ab48250a9 GstCustomMeta: Use simplified API where possible
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5385>
2023-09-27 18:46:34 +00:00
Nicolas Dufresne 7e3f8e7907 basesrc: Delay unlocking so we can hold the STREAM_LOCK
unlock_stop() is expected to be run while the streaming thread is idle. To
guaranty this is the case, we should take the streamlock, but its not
possible to take this lock during state transitions from PAUSED to
PLAYING as the wait function that we want to terminate is holding it.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4961>
2023-09-06 17:34:45 +00:00
Nicolas Dufresne 47d79eedc9 basesrc: Retry create() if we are back from pause
After a create() call, which may have returned FLUSHING or a filled buffer,
if it possible that we detect that we are now in pause. As live sourced
don't produce data in pause, drop the buffer is any and later retry creating
a buffer. This will ensure that we resume from pause while avoiding displaying
ancient frame.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4961>
2023-09-06 17:34:45 +00:00
soak e506f9c23e basesrc: Restore pause/resume in derived classes
When the pipeline goes from Playing to Paused, this change will invoke
unlock in the derived class. When the pipeline goes from Paused to
Playing, this change will invoke unlock_stop in the derived class.

This feature was removed in commit 523de1a9 and is now being restored.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4961>
2023-09-06 17:34:45 +00:00
Sebastian Dröge a0522c8193 ptp: Fix compilation with rustc 1.48
That's currently the minimum version we declare in meson.build but the
latest changes introduced some usage of 1.62 features.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5265>
2023-08-31 06:05:18 +00:00
Sebastian Dröge 967aa2abca ptp: Listen with different sockets on individual interfaces
This allows us to portably know on which interface a multicast packet
arrived, and to send back any packets for that clock on the correct
interface.

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

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5232>
2023-08-30 12:19:46 +00:00
Piotr Brzeziński 601e31fe6e queuearray: Add sorting and sorted pushing
Adds gst_queue_array_sort for sorting and gst_queue_array_push_sorted{,struct} for pushing in a sorted order.
All three functions accept a comparison GCompareDataFunc along with optional user_data to pass to it.

In gst_queue_array_sort a small workaround was needed to correctly sort non-struct arrays. Like what _find() already
does, we need to dereference our pointers first, to make sure we can use the same comparison functions everywhere.
This is done via a small wrapper around the provided comparison function.
The array can also wrap around (tail ends up 'before' the head), in which case we have to reorder the array (similar to
what do_expand() does) to then be able to use an existing sorting function, like g_qsort_with_data().

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5112>
2023-08-16 06:54:55 +00:00
Alicia Boya García 9ca194d8cc harness: Fix race condition when torn down during the handling of a non-serialized query or event
It's possible and normal to tear down a harness while the pipeline is
running. At the same time, it's desired for the
`gst_harness_pad_link_tear_down()` function to be synchronous.

This has created the conflict where the main thread may request a
harness to be torn down while it's in use or about to be used by a pad
in the streaming thread.

The previous implementation of `gst_harness_pad_link_tear_down()` tried
to handle this by taking the stream lock of the harnessed pad and
resetting all the pad functions while holding it. That approach was
however insufficient to handle the case where a non-serialized event
or query is being handled or about to be handled in a different thread.

This edge case was one race condition behind the flakes in the flvmux
check tests -- the rest being covered by https://gitlab.freedesktop.org/gstreamer/gstreamer/-/issues/2803.

This patch fixes the problem by adding an intermediate ref-counted
object, GstHarnessLink, which replaces the usage of the HARNESS_KEY
association. GstHarnessLink allows the pad functions such as event,
query and chain to borrow a reference to GstHarness and more
importantly, to lock the GstHarnessLink during their usage to block
(delay) its destruction until no users are left, and guarantee that any
future user will not receive an invalid GstHarness handle past its
destruction.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5017>
2023-07-12 13:18:00 +00:00
Jan Schmidt 0461103965 basesrc: Don't hold the object lock while pushing an event
Release the object lock before pushing a segment event.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4951>
2023-06-30 16:05:57 +00:00
Seungha Yang eb87bbc1ba gst: Don't use DllMain in case of static build
That might cause duplicated symbol linking error if app has its own
DllMain

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4905>
2023-06-20 19:14:49 +00:00
Seungha Yang 513d897d6e aggregator: Resume srcpad task on stream-start only when running
Race condition without this patch:
- srcpad task is being stopped in gst_aggregator_stop_srcpad_task()
- at that moment, in pre-queue event handler, gst_pad_get_task_state()
  returned GST_TASK_PAUSED
- then in srcpad task got stopped in gst_aggregator_stop_srcpad_task()
- finally srcpad task got resumed in pre-queue event handler

To address it, checks "running" flag in pre-queue event handler.
Both pre-queue stream-start event handler and "running" flag
are protected by SRC_LOCK already.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4847>
2023-06-14 16:57:35 +00:00
Elliot Chen 308a9f9466 typefindhelper: avoid printing error log
some plugins such as wavparse may need find if type of media
contained in the given data and will print error log if there
is no matching factory.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4814>
2023-06-14 10:25:53 +00:00