Commit graph

55 commits

Author SHA1 Message Date
Sebastian Dröge 8335bdb0b7 Update versions to 0.11.4 2024-02-13 11:13:23 +02:00
Michael Tretter 9f7bb6102c 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/1457>
2024-02-12 17:46:36 +02:00
Guillaume Desmottes ddc15b92a5 livesync: properly format jitter in debug logs
Easier to read that way.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/1457>
2024-02-12 17:45:46 +02:00
Sebastian Dröge 4c8db5623f Update versions to 0.11.3 2023-12-18 12:13:48 +02:00
Sebastian Dröge 151702d264 Update versions to 0.11.2 2023-11-11 20:52:45 +02:00
Jan Alexander Steffens (heftig) b4855f1ba8 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/1388>
2023-11-10 16:02:42 +02:00
Jan Alexander Steffens (heftig) d65504aeb8 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/1388>
2023-11-10 16:02:36 +02:00
Jan Alexander Steffens (heftig) 48020dfbf5 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/1388>
2023-11-10 16:02:31 +02:00
Guillaume Desmottes 352d947655 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/1388>
2023-11-10 16:02:27 +02:00
Guillaume Desmottes 559825a551 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/1388>
2023-11-10 16:02:22 +02:00
Jan Alexander Steffens (heftig) 34ce94932f 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/1388>
2023-11-10 16:02:17 +02:00
Jan Alexander Steffens (heftig) 7c2f05c271 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/1388>
2023-11-10 16:02:12 +02:00
Jan Alexander Steffens (heftig) 0b80e3aa47 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/1388>
2023-11-10 16:02:07 +02:00
Jan Alexander Steffens (heftig) ccf1171776 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/1388>
2023-11-10 16:02:00 +02:00
Jan Alexander Steffens (heftig) 8deb2d26a8 livesync: Simplify num_duplicate counting
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/1388>
2023-11-10 16:01:55 +02:00
Jan Alexander Steffens (heftig) 3a7bf71483 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/1388>
2023-11-10 16:01:49 +02:00
Jan Alexander Steffens (heftig) 9ad3c42e21 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/1388>
2023-11-10 16:01:41 +02:00
Jan Alexander Steffens (heftig) 80ba5b980d 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/1388>
2023-11-10 16:01:37 +02:00
Jan Alexander Steffens (heftig) 391b244b9e 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/1388>
2023-11-10 16:01:32 +02:00
Jan Alexander Steffens (heftig) 04b7a1afd6 livesync: Log a category error when we are missing the segment
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/1388>
2023-11-10 16:01:27 +02:00
Jan Alexander Steffens (heftig) 79f58785d9 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/1388>
2023-11-10 16:01:22 +02:00
Jan Alexander Steffens (heftig) 913fb606fc 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/1388>
2023-11-10 16:01:16 +02:00
Jan Alexander Steffens (heftig) 90a22950d2 livesync: Rename activatemode methods to *_activatemode
This matches the other plugins.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/1388>
2023-11-10 16:01:11 +02:00
Sebastian Dröge 2b8728103f Update versions to 0.11.1 2023-10-04 23:35:35 +03:00
Sebastian Dröge b360b5247e Update gst-plugin-version-helper version requirement to 0.8
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/1350>
2023-10-04 19:15:53 +03:00
Sebastian Dröge 383d8e2668 Add version to gst-plugin-gtk4 dependencies 2023-08-10 17:12:16 +03:00
Sebastian Dröge 982b5d6ef9 Add version to the gst-plugin-version-helper dependency 2023-08-10 16:56:04 +03:00
Sebastian Dröge 67c3732b94 Update dependencies to release branches of gtk-rs / gtk4-rs / gstreamer-rs 2023-08-09 18:14:18 +03:00
Sebastian Dröge 9b1853c1de Update versions to 0.11.0 2023-08-09 18:04:38 +03:00
Sebastian Dröge 3b41f206bc Don't generate .def files for plugins
Fixes https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/issues/389

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/1299>
2023-08-09 13:54:34 +03:00
Sebastian Dröge 31b1cb8ca6 Update minimum supported Rust version to 1.70
gtk-rs will update soonish too.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/1280>
2023-07-19 09:19:34 +03:00
Bilal Elmoussaoui dd2d7d9215 Use re-exported once_cell
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/1268>
2023-07-06 17:50:49 +03:00
Bilal Elmoussaoui 2cc98bf410 Adapt to glib::Continue rename
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/1268>
2023-07-06 17:50:49 +03:00
Sebastian Dröge 1119ed6620 livesync: Wait for the end timestamp of the previous buffer before looking at queue
Previously livesync was waiting for the start timestamp of the current
buffer after looking at the queue and right before pushing it
downstream. This meant that it generally looked too early at the queue
and especially that upstream had to provide the next buffer already at
the start timestamp of the previous one.

Instead, now wait before looking at the queue and wait for the end
timestamp of the previous buffer. Once the previous buffer has expired,
a new buffer really needs to be available or otherwise a filler buffer
has to be pushed downstream.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/1250>
2023-06-20 13:01:39 +00:00
Jan Alexander Steffens (heftig) 52ded6e8cc livesync: Improve EOS handling
I've looked at the GstQueue code again and tried making livesync behave
better with EOS. This isn't very well tested, though. My goal was to
make this look saner but I think this should be reviewed by someone who
knows the queue code.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/1251>
2023-06-20 13:18:17 +02:00
François Laignel 7ba0073052 use Pad builders for optional name definition
Also, apply auto-naming in the following cases

* When building from a non wildcard-named template, the name of the template is
  automatically assigned to the Pad. User can override with a specific name by
  calling `name()` on the `PadBuilder`.
* When building with a target and no name was provided via the above, the
  GhostPad is named after the target.

See https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/issues/448
Auto-naming discussion: https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/merge_requests/1255#note_1891181

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/1197>
2023-05-12 12:55:31 +02:00
Sebastian Dröge 47159ad3c2 Make sure to keep around and drop bus watches after usage in all the examples 2023-04-14 12:46:43 +03:00
Tim-Philipp Müller 8845f6a4c6 git: replace LICENSE file symlinks with copies
Git will de-duplicate the contents for us anyway, and
symlinks can cause problems with some versions of git
and also on Windows.

https://github.com/mesonbuild/meson/issues/11646
https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4326

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/1157>
2023-04-04 14:26:37 +01:00
Vivia Nikolaidou c6e1efa0fe livesync: Actually assume zero upstream latency when query fails
The code said "assuming zero" but left latency at None instead of
Some(0), failing to unwrap the value later.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/1153>
2023-03-31 17:40:32 +03:00
Talha Khan a12a8c566d livesync: Support variable framerate in fallback buffer duration calc
Avoids a divide by zero error

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/1123>
2023-03-10 09:18:28 +00:00
Sebastian Dröge ff2f7a8505 livesync: Correctly calculate fallback buffer duration from framerate
Numerator and denominator were switched.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/1108>
2023-02-28 12:52:11 +02:00
Sebastian Dröge 9fc1404415 Update minimum supported Rust version to 1.66
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/1096>
2023-02-20 11:09:01 +02:00
Sebastian Dröge 1e13dbb99c Update versions to 0.11.0-alpha.1 2023-02-10 00:23:56 +02:00
Jan Alexander Steffens (heftig) f55c32ed37 livesync: Document State's fields
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/1083>
2023-02-09 13:07:33 +01:00
Jan Alexander Steffens (heftig) 953773a314 livesync: Improve formatting
Move some code around to make it a bit more readable. No change in
behavior.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/1083>
2023-02-09 13:07:33 +01:00
Jan Alexander Steffens (heftig) c1bfeb4c23 livesync: Fix log message capitalization
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/1083>
2023-02-09 13:07:33 +01:00
Jan Alexander Steffens (heftig) 0af7151ae9 livesync: Extract LiveSync::flow_error
And add details so it behaves more like the `GST_ELEMENT_FLOW_ERROR`
macro.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/1083>
2023-02-09 13:07:32 +01:00
Jan Alexander Steffens (heftig) f03ee95bf0 livesync: Extract audio_info_from_caps
And adjust it slightly so it never panics.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/1083>
2023-02-09 13:07:32 +01:00
Jan Alexander Steffens (heftig) c971c4d1d5 livesync: Move single segment prop
Keep it with the settings, not after the stats.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/1083>
2023-02-09 13:07:32 +01:00
Jan Alexander Steffens (heftig) 165b5f8c50 livesync: Fix queueing
The logic of the element requires the next buffer to be available
immediately after we are done pushing the previous, otherwise we insert
a repeat.

Making the src loop handle events and queries broke this, as upstream is
almost guaranteed not to deliver a buffer in time if we allow non-buffer
items to block upstream's push.

To fix this, replace our single-item `Option` with a `VecDeque` that we
allow to hold an unlimited number of events or queries, but only one
buffer at a time.

In addition, the code was confused about the current caps and segment.

This wasn't an issue before making the src loop handle events and
queries, as only the sinkpad cared about the current segment, using it
to buffers received, and only the srcpad cared about the current caps,
sending it just before sending the next received buffer.

Now the sinkpad cares about caps (through `update_fallback_duration`)
and the srcpad cares about the segment (when not in single-segment
mode).

Fix this by
  - making `in_caps` always hold the current caps of the sinkpad,
  - adding `pending_caps`, which is used by the srcpad to store
    caps to be sent with the next received buffer,
  - adding `in_segment`, holding the current segment of the sinkpad,
  - adding `pending_segment`, which is used by the srcpad to store
    the segment to be sent with the next received buffer,
  - adding `out_segment`, holding the current segment of the srcpad.

Maybe a fix for
https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/issues/298.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/1082>
2023-02-09 12:44:47 +01:00