Commit graph

171 commits

Author SHA1 Message Date
Samuel Thibault 31047b878f ptp-helper: Add GNU/Hurd support
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/6970>
2024-05-30 16:14:29 +00:00
Sebastian Dröge 2a58e6de8f gstreamer: ptp-helper: Use u64 instead of c_ulong for ifa_flags on Solaris/Illumos
See https://gitlab.freedesktop.org/gstreamer/gstreamer/-/issues/3553#note_2429400

Patch by Marcel Telka <marcel@telka.sk>.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/6934>
2024-05-28 09:06:57 +03:00
Sebastian Dröge 1c88b06912 gstreamer: ptp-helper: Use if_nametoindex and setsockopt on Solaris / Illumos too
Patch by Marcel Telka <marcel@telka.sk>.

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

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/6925>
2024-05-26 12:34:26 +03:00
Sebastian Dröge 354623a246 gstreamer: ptp-helper: Don't import Context trait multiple times unnecessarily
This only affected the Solaris / Illumos code path.

Patch by Marcel Telka <marcel@telka.sk>.

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

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/6925>
2024-05-26 12:34:21 +03:00
Sebastian Dröge 8bff6b4988 gstreamer: ptp-helper: Use c_ulong for ifa_flags on Solaris/Illumos
Based on a patch by Marcel Telka <marcel@telka.sk>.

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

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/6925>
2024-05-26 12:34:13 +03:00
Sebastian Dröge 1f12493787 gstreamer: Solaris/Illumos require linking to libnsl / libsocket for various socket APIs
Patch by Tim Mooney <Tim.Mooney@ndsu.edu> from OpenIndiana/oi-userland

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/6925>
2024-05-26 12:33:50 +03:00
Sebastian Dröge 0ef396359c gst: Move GstQueueArray as GstVecDeque to core
And change lengths and indices from guint to gsize for a more correct type.

Also deprecate GstQueueArray and implement it in terms of GstVecDeque.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/6779>
2024-05-06 18:25:42 +00:00
Johan Sternerup deddcbdc66 basesrc: protect segment_seqnum/pending with object lock
In a few places the object lock was not taken when writing to
segment_pending and segment_seqnum.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/6671>
2024-04-22 18:13:46 +00:00
Johan Sternerup a3f8f036fe gstbasesrc: Do not hold LIVE_LOCK while sending events
An application that triggers a state transition from PLAYING to PAUSED
needs to acquire the LIVE_LOCK. Consequently the LIVE_LOCK must not be
taken while pushing anything on the pads because this operation might
get blocked by something that cannot be unblocked without the
application being able to proceed with the state transitions for other
elements in the pipeline. This commit extends the previous behaviour
where the live lock was released before pushing buffers (indirectly
through the unlock before subclass->create) to now also include
unlocking before pushing events.

The issue was discovered in a case for WebRTC where the application
tried to shut down a pipeline but an event originating from a video
source element (based on basesrc) was in the process of being pushed
down the pipeline when it got stuck on the STREAM_LOCK for the pad after
the rtpgccbwe element. This lock in turn was held by the rtcpgccbwe
element as it was in the process of pushing data down the pipeline but
was stuck on the blocking probes installed on dtlssrtpenc to prevent
data from flowing before dtls keys had been negotiated. What should have
happened here is that the blocking probes should be removed, but that
can only happen if the application may continue driving the state
transitions.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/6671>
2024-04-22 18:13:46 +00:00
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