Commit graph

398 commits

Author SHA1 Message Date
Sebastian Dröge
746acfc423 livesync: Report latency query results when handling latency query too
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/1781>
2024-09-21 08:40:00 +00:00
Sebastian Dröge
1a8a1dcf17 livesync: Use the actual output buffer duration of gap filler buffers
Otherwise the following can happen:

  - 25fps stream
  - buffer with PTS 0ms, duration 20ms arrives, is output
  - buffer with PTS 40ms, duration 20ms arrives
  - is considered early because 20ms < 40ms
  - filler buffer with PTS 20ms and 40ms duration is output
  - buffer with PTS 40ms is output

After this change no filler would be inserted because the gap is smaller
than the duration of a filler buffer.

Also, previously the 40ms duration would be used if a filler was
previously output because in that case the cached output buffer duration
would've already been patched from 20ms to 40ms.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/1648>
2024-07-02 17:07:57 +01:00
Sebastian Dröge
7088a06982 livesync: Add sync property for allowing to output buffers as soon as they arrive
By default livesync will wait for each buffer on the clock. If sync is
set to false, it will output buffers immediately once they're available
and only waits on the clock for outputting gap filler buffers.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/1643>
2024-06-28 17:31:34 +01:00
Sebastian Dröge
000e9c92d2 livesync: Synchronize on the first buffer too
Previously the first buffer would be output immediately and
synchronization would only happen from the second buffer onwards.
This would mean that the first buffer would potentially be output too
early.

Instead, if there is no known output timestamp yet but a buffer with a
timestamp, first of all take its start as the initial output timestamp
and synchronize on that buffer.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/1643>
2024-06-28 17:31:34 +01:00
Sebastian Dröge
6d177f5d3c livesync: Use let-else in a few more places
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/1643>
2024-06-28 17:31:34 +01:00
Sebastian Dröge
de4bfa2028 livesync: Allow queueing up to latency buffers
This was already reported by the latency query, and not doing this would
require to always put a queue before livesync.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/1643>
2024-06-28 17:31:34 +01:00
Sebastian Dröge
998b4734bf Fix various new clippy 1.79 warnings
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/1627>
2024-06-18 10:01:13 +00:00
Philippe Normand
23403b5c9a Fix clippy warnings after upgrade to Rust 1.77
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/1531>
2024-04-08 15:15:26 +03:00
Sebastian Dröge
77e91e96ff livesync: Ignore another racy test
Same problem as https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/issues/328

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/1508>
2024-03-21 13:30:20 +02:00
Guillaume Desmottes
40402f8e58 livesync: disable racy tests
https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/issues/328
https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/issues/357

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/1508>
2024-03-20 16:24:55 +01:00
Guillaume Desmottes
14ed7b0db1 togglerecord: disable racy test_two_stream_close_open_nonlivein_liveout test
See https://gitlab.freedesktop.org/gdesmott/gst-plugins-rs/-/jobs/56183085

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/1508>
2024-03-20 16:24:55 +01:00
Sebastian Dröge
149eff08b7 utils: Update for renamed clippy lint in 1.76
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/1460>
2024-02-12 18:11:19 +02:00
Sebastian Dröge
16e001e3f2 Update dependency versions for gtk-rs-core / gtk4-rs / gstreamer-rs and local crates 2024-02-08 19:40:08 +02:00
Sebastian Dröge
92891a61e8 Fix a couple of compiler/clippy warnings with --no-default-features
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/1452>
2024-02-08 13:02:55 +02:00
Bilal Elmoussaoui
d25a222bf9 Drop direct muldiv dependency
It is re-exproted in gstreamer's prelude

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/1446>
2024-02-05 15:34:31 +01:00
Bilal Elmoussaoui
0615a16124 Use workspace features for crates metadata/deps
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/1446>
2024-02-05 15:34:31 +01:00
Sebastian Dröge
1a55c70114 Switch git dependencies to explicitly name branch
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/1445>
2024-02-05 12:51:36 +02:00
Sebastian Dröge
4ad101b53b Use once_cell crate directly again
The glib crate does not depend on it anymore and also does not re-export
it anymore.

Also switch some usages of OnceCell to OnceLock from std.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/1441>
2024-01-31 18:07:57 +02:00
Michael Tretter
4bb867bf52 livesync: add support for image formats
The livesync element is also useful for Motion JPEG streams. However,
Motion JPEG uses image/ caps instead of video/ caps.

The framerate is defined for image/, too.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/1440>
2024-01-29 11:07:30 +00:00
Guillaume Desmottes
33a1d8de3d tracers: buffer-lateness: display some stats about late buffers
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/1437>
2024-01-29 09:24:08 +00:00
Guillaume Desmottes
d5740ea844 tracers: buffer-lateness: add argument to display only late buffers
Help to easily spot places where buffers are late when plotting big
pipelines.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/1437>
2024-01-29 09:24:08 +00:00
Guillaume Desmottes
c616423edb livesync: properly format jitter in debug logs
Easier to read that way.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/1430>
2024-01-16 13:46:34 +01:00
Sebastian Dröge
1ef47cb48e Fix a few new clippy 1.75 warnings
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/1415>
2023-12-22 16:40:18 +02:00
Guillaume Desmottes
6dfd1c1496 use new debug and parse API
Changes from https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/merge_requests/1355

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/1403>
2023-12-04 15:58:21 +01:00
Seungha Yang
8a04a38631 fallbacksrc: Fix timeout scheduling
Other thread can schedule the timeout (e.g., unblock signal
or active pad change) while state lock is released

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/1384>
2023-11-15 09:17:39 +00:00
Sebastian Dröge
636c76b03b uriplaylistbin: Fix new clippy warning
warning: the borrowed expression implements the required traits
    --> utils/uriplaylistbin/src/uriplaylistbin/imp.rs:1691:32
     |
1691 |         self.obj().remove_many(&children_ref).unwrap();
     |                                ^^^^^^^^^^^^^ help: change this to: `children_ref`

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/1391>
2023-11-13 17:41:06 +02:00
Sebastian Dröge
16b917abb1 Update for gst::Rank API changes 2023-11-02 14:10:59 +02:00
Sebastian Dröge
855b03a9ea Use let-else instead of match for weak reference upgrades
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/1375>
2023-10-30 11:34:35 +02:00
Jan Alexander Steffens (heftig)
e3e58ac0be livesync: Remove the stop from outgoing segments
Our buffer duplication can extend a segment indefinitely.

Fixes: https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/issues/452
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/1372>
2023-10-25 19:34:47 +02:00
Jan Alexander Steffens (heftig)
f1ba498b52 livesync: Keep existing buffer duration in some cases
Resize a repeat buffer only if caps gave us a duration to use, or we
consider its current duration unreasonable.

In particular, for audio streams we should prefer reusing the buffer
size upstream gave us, as we did before 6633cc4046.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/1372>
2023-10-25 19:34:47 +02:00
Jan Alexander Steffens (heftig)
59beade079 livesync: Split fallback_duration into in_ and out_duration
Make it independent of the `latency`; this was inconsistent anyway,
where the default latency of zero got you a fallback duration of 100 ms
and something else got you half the latency.

Maintain a separate duration for the `in` and the `out` side so we
change the duration of repeat buffers after a caps change, not just
before.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/1372>
2023-10-25 19:08:16 +02:00
Guillaume Desmottes
f94ecfc7a6 livesync: display jitter when waiting on clock
We already log the result of the clock wait call so may as well log the
returned jitter.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/1370>
2023-10-25 14:26:19 +02:00
Guillaume Desmottes
13dae0f0d0 livesync: log new pending segments
The debug print of the event does not display details about the segment:
  Unqueueing Some(Event(Event { ptr: 0x7fa3e0002580, type: "segment", seqnum: Seqnum(479), structure: Some(GstEventSegment { segment: (GstSegment) ((GstSegment*) 0x7fa3e8001d00) }) }))

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/1370>
2023-10-25 14:24:35 +02:00
Jan Alexander Steffens (heftig)
ee93448de7 livesync: example: Add identities single-segment=1
These let us change the runtime offset of the test buffers via pad
offsets without pushing new segments into livesync, which is necessary
to demo the late-threshold behavior.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/1369>
2023-10-25 12:55:06 +02:00
Jan Alexander Steffens (heftig)
6633cc4046 livesync: Use fallback_duration for audio repeat buffers as well
Don't depend on upstream giving us sanely-sized buffers if we want to
repeat.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/1369>
2023-10-25 12:55:06 +02:00
Jan Alexander Steffens (heftig)
4ac7d0415b livesync: Separate out_buffer duplicate status from GAP flag
Otherwise we might get confused by upstream GAP buffers.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/1369>
2023-10-25 12:10:40 +02:00
Jan Alexander Steffens (heftig)
2f36bd5d77 livesync: Handle flags and late buffer patching after queueing
This makes the chain function almost independent of the output state. We
still do the early discard check with `buffer_is_backwards` so we don't
try to queue buffers we can't use, allowing us to fast-forward upstream
without blocking on the src task.

Don't accept `LateOverThreshold` buffers when we have `pending_caps` or
a `pending_segment`. We need to apply these first before we can sensibly
patch buffers from the new stream.

Deduplicate most of the output buffer patching code into a new
`patch_output_buffer` method.

For: https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/issues/450
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/1369>
2023-10-25 11:52:41 +02:00
Jan Alexander Steffens (heftig)
7c48a299c3 livesync: Simplify num_duplicate counting
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/1369>
2023-10-25 11:52:40 +02:00
Jan Alexander Steffens (heftig)
17a2448237 livesync: Move num_in counting to the src task
This is in preparation for moving more accept/discard logic to the src
task, so we can only count `num_in` here.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/1369>
2023-10-25 11:52:40 +02:00
Jan Alexander Steffens (heftig)
1740a8e363 livesync: Move a notify closer to the interesting state change
Move the `notify_all` to where we pop the buffer. We're moving within a
single state lock so no change in behavior.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/1369>
2023-10-25 11:52:40 +02:00
Jan Alexander Steffens (heftig)
44f2195674 livesync: Replace an if-let with match
No change in behavior, yet. Separate commit to ease reviewing.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/1369>
2023-10-25 11:52:40 +02:00
Jan Alexander Steffens (heftig)
62791bfb47 livesync: Clean up state handling
- Separate resetting state more cleanly, introducing `set_flushing`,
  `sink_reset` and `src_reset`.
- Clear the queue early when we flush, in order to unblock waits on
  query responses.
- Return an error when we fail to start, pause or stop the task.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/1369>
2023-10-25 11:52:40 +02:00
Jan Alexander Steffens (heftig)
d663f708ef livesync: Log a category error when we are missing the segment
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/1369>
2023-10-25 11:52:40 +02:00
Jan Alexander Steffens (heftig)
6567041a3d livesync: Improve audio duration fixups
- An entirely missing duration is now only logged at debug level instead
  of pretending the duration was zero and warning about it.
- Silently fix up a duration difference up to one sample.
- Error when we fail to calculate the duration; don't try to apply the
  `fallback_duration` to a non-video stream.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/1369>
2023-10-25 11:52:40 +02:00
Jan Alexander Steffens (heftig)
0a45f776e0 livesync: Simplify start_src_task and src_loop
This should effect no change in behavior.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/1369>
2023-10-25 11:03:15 +02:00
Jan Alexander Steffens (heftig)
01386b8451 livesync: Rename activatemode methods to *_activatemode
This matches the other plugins.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/1369>
2023-10-25 11:03:14 +02:00
Sebastian Dröge
d468e1e4a6 Clean up usage of pad probes
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/1361>
2023-10-17 08:44:06 +03:00
Guillaume Desmottes
f92dc28696 fallbackswitch: protect src pad stream lock using Cond
Should prevent stream and State deadlocks, see https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/issues/202

Fix #202
Hopefully fix #192 as well.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/1300>
2023-08-14 14:18:41 +02:00
Guillaume Desmottes
d3da30be6d fallbackswitch: prevent deadlocks in chain function
Calling schedule_timeout() may result in handle_timeout() being called right away,
which will need pad state locks which was still hold in chain().

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/1300>
2023-08-14 13:16:37 +02:00
Guillaume Desmottes
100333c021 fallbackswitch: ensure strict ordering when taking mutexes
Should prevent deadlocks.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/1300>
2023-08-14 13:16:37 +02:00