Commit graph

193 commits

Author SHA1 Message Date
François Laignel
28a62e622e ts/scheduler: rename awake / wake_up as unpark 2022-08-09 13:17:21 +00:00
François Laignel
833331ab66 ts/Task: wake up after the triggering event is pushed
The scheduler is awaken when aborting a task loop, but not after
a triggering event is pushed. This can cause throttling to induce
long state transitions for pipelines with many streams.

Observed for Unprepare with:

GST_DEBUG=ts-benchmark:4 ../../target/debug/examples/benchmark 2000 ts-udpsrc 2 20 5000
2022-08-09 13:17:21 +00:00
François Laignel
374671cb6f ts/udpsink: fix default clients not leading to socket configuration
During MR !793, the socket configuration mechanism was changed to
use commands passed to the Task via a channel. This worked properly
for user changes via settings and signals, however the default
clients setting was not used.

A simple solution could have been to send a command at initialization
to add the default clients, but it was considered a better solution
to just wait for the Task preparation to configure the sockets based
on the value of settings.clients at that time, thus avoiding
unnecessary successive removals and additions of clients which could
have happened before preparation.

Of course, users can still add or remove clients as before, before
and after Task preparation.

See also https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/793
2022-08-09 12:43:36 +00:00
Bilal Elmoussaoui
52973d975e Update per glib::SignalBuilder changes 2022-07-21 20:03:13 +02:00
François Laignel
18f85a1543 generic/fmp4: use opt_ops 2022-07-20 15:56:04 +00:00
François Laignel
6a2df92453 Revert "fmp4mux: Dequeue as many buffers as are available in each aggregate call"
This reverts commit 402500f79c.

This commit introduces race conditions. It was intended as solving
an issue with some pipelines which had their queues filling up,
causing the streams to stall. It is reverted as this solution is
considered a workaround for another issue.

See discussion in:

https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/803
2022-07-20 15:56:04 +00:00
François Laignel
44b05b4285 generic/fmp4: update Signed return type
See: https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/merge_requests/1068
2022-07-19 15:40:43 +02:00
François Laignel
5c5c15d36a Simplify Formatted value handling
See https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/merge_requests/1059
2022-07-11 21:21:54 +02:00
François Laignel
907d89c998 ts/tests/pad: minor ckeanups 2022-07-09 17:03:21 +00:00
François Laignel
d6a9106ffa ts/tcpclientsrc: reduce sync primitives in async hot path 2022-07-09 17:03:21 +00:00
François Laignel
7e826385c7 ts: Queue & Proxy: minor cleanups 2022-07-09 17:03:21 +00:00
François Laignel
5720faa808 ts/appsrc: reduce sync primitives in async hot path 2022-07-09 17:03:21 +00:00
François Laignel
a1b89c1fb9 ts/udpsrc: reduce sync primitives in async hot path
- Moved UdpSrcPadHandlerState and related funtions to UdpSrcTask.
- Moved Socket preparation in UdpSrcTask. No longer need for
  Context::enter.
2022-07-09 17:03:21 +00:00
François Laignel
885d3de7bb ts/udpsink: reduce sync primitives in async hot path
The way the runtime::Task is implemented, UdpSinkTask is available
as a mutable ref in all the TaskImpl functions, which offers the
opportunity to avoid using Mutexes.

Main higlights:

- Removed the back and forth calls between UdpSinkPadHandler
  and UdpSinkTask.
- Udp sockets are now part of UdpSinkTask, which is also in
  charge of preparing them instead of leaving this to UdpSink.
  This removed the need for Context::enter since
  TaskImpl::prepare already operates under the target Context.
- In order for the clients list to be visible from the UdpSink,
  this list was maintained by UdpSinkPadHandler which was also
  in charge of (un)configuring the Udp sockets. The sockets are
  now part of UdpSinkTask, which is also in charge of the
  (un)configuration. Add/remove/replace requests are passed as
  commands to the UdpSinkTask via a channel.
- The clients list visible to the UdpSink is now part of the
  Settings (it is also a read/write property). Since the actual
  socket (un)configuration is asynchronously handled by the Task,
  the clients list is updated by the add/remove/replace signals
  and set_property("clients", ..). Should a problem occur during
  the async (un)configuration, and only in this case, the
  UdpSinkTask would update the clients lists in Settings
  accordingly so that it stays consistent with the internal state.
- The function clear_clients was renamed as replace_with_clients.
- clients is now based on a BTreeSet instead of a Vec. All the
  managing functions perform some sort of lookup prior to updating
  the collection. It also ease implementation.
- Removed the UdpSinkPadHandler RwLock. Using flume channels, we
  are able to clone the Receiver so it can be stored in UdpSink
  and reused when preparing the UdpSinkTask.
2022-07-09 17:03:21 +00:00
Sebastian Dröge
8e90abfebb fmp4mux: Handle PTS<segment.start when requesting keyframes 2022-06-30 16:51:03 +03:00
Sebastian Dröge
e52d1fa317 fmp4mux: Ensure that DTS (or PTS for intra-only streams) are monotonically increasing 2022-06-30 16:51:03 +03:00
Sebastian Dröge
402500f79c fmp4mux: Dequeue as many buffers as are available in each aggregate call 2022-06-30 16:51:03 +03:00
Sebastian Dröge
7e2cf613b4 fmp4mux: Add debug output for each fragment's start PTS 2022-06-30 16:51:03 +03:00
Sebastian Dröge
3d7a38f7d4 fmp4mux: Fix draining if there are no GOPs for a stream 2022-06-30 16:51:03 +03:00
Sebastian Dröge
a1553a8411 fmp4mux: Fix some clippy warnings 2022-06-30 16:51:03 +03:00
Sebastian Dröge
191a48ca41 fmp4mux: Write header as late as possible
Especially do it only after the initial fragment's information are all
known.
2022-06-30 16:51:03 +03:00
Sebastian Dröge
4ef0e26762 fmp4mux: Refactor timestamp handling for writing out data
Pass less data around and calculate the values we need to work with
earlier.
2022-06-30 16:50:59 +03:00
Sebastian Dröge
0a02d8c096 fmp4mux: Write tref box for ONVIF timed metadata tracks to reference the first video track 2022-06-30 16:35:56 +03:00
Sebastian Dröge
6edb188899 fmp4mux: Fix usage of first_sample_flags/default_sample_flags
Previously first_sample_flags was never used so if the first sample was
a keyframe and all others not then each sample got its own flags.
2022-06-30 16:35:56 +03:00
Sebastian Dröge
51c7d0652e Fix/silence a couple new clippy warnings 2022-06-30 16:07:32 +03:00
François Laignel
a45f944edd ts/async_wrapper: remove fd from reactor before dropping its handle
The I/O handle was dropped prior to removing it from the reactor,
which caused `Poller::delete` to fail due to an invalid file
descriptor. This used to happen silently unless the same fd was
added again, e.g. by changing states in the pipeline as follow:

    Null -> Playing -> Null -> Playing.

In which case `Poller::add` failed due to an already existing file.

This commit makes sure the fd is removed from the reactor prior to
dropping the handle. In order to achieve this, a new task is spawned
on the `Context` on which the I/O was originally registered, allowing
it to access the proper `Reactor`. The I/O can then safely be dropped.

Because the I/O handle is moved to the spawned future, this solution
requires adding the `Send + 'static` bounds to the I/O handle used
within the `Async` wrapper. This appears not too restrictive for
existing implementations though. Other attempts were considered,
but they would cause deadlocks.

This new approach also solves a potential race condition where a
fd could be re-registered in a `Reactor` before it was removed.
2022-06-30 11:13:39 +00:00
François Laignel
06273ed628 ts: add test pipeline::socket_play_null_play 2022-06-30 11:13:39 +00:00
Sebastian Dröge
cb84206457 Fix a couple of new 1.62 clippy warnings 2022-06-28 14:52:20 +03:00
Sebastian Dröge
dccd4c3306 sodium: Update to no-deprecated clap 3.2 API
See https://github.com/clap-rs/clap/issues/3822
2022-06-14 10:39:31 +03:00
Sebastian Dröge
d6fa921822 fmp4mux: Use saturing_sub() in more places
On unclean input, PTS/DTS might go backwards a bit and in those cases
calculate a duration of 0 instead of panicking.
2022-05-20 15:03:06 +03:00
Sebastian Dröge
6bca5a9962 fmp4mux: Implement interleaving based on start timestamps instead of accumulated durations
Durations might accumulate rounding errors and streams might not
actually start at the same time. For that reason also start with the
stream that has the lowest timestamp.
2022-05-20 15:03:06 +03:00
Sebastian Dröge
d7bd4c1c93 fmp4mux: Implement handling of GAP events 2022-05-20 15:03:04 +03:00
Sebastian Dröge
987e4efc02 fmp4mux: In live pipelines use the current fragment end time as timeout
This allows muxing even if some streams are sparse or have big gaps.
2022-05-20 15:02:46 +03:00
Sebastian Dröge
ffea0e2d2d fmp4mux: Add support for ONVIF timed XML metadata 2022-05-19 17:55:07 +03:00
Sebastian Dröge
e4634ca2fe fmp4mux: Add ONVIF variant with support for additional codecs
This variant supports H264/5, JPEG, alaw, mulaw and G726.
2022-05-19 17:55:07 +03:00
Sebastian Dröge
0206178279 fmp4mux: Check for force-keyunit events on both pads in the multistream test 2022-05-19 17:55:07 +03:00
Sebastian Dröge
4bc0ae09fa fmp4mux: Use saturing subtraction to calculate sample durations
PTS/DTS might go backwards if the input is borderline broken but that
shouldn't cause a panic.
2022-05-13 10:54:23 +00:00
Sebastian Dröge
cfb59100d6 fmp4mux: Add test for muxing of multiple streams 2022-05-12 18:31:02 +03:00
Sebastian Dröge
e06665b92d fmp4mux: Add support for multiple input streams 2022-05-12 18:31:02 +03:00
Sebastian Dröge
31a32a7e2e fmp4mux: Add support for writing out multiple tracks in the serialization code
Not yet exposed from the element.
2022-05-12 18:31:02 +03:00
Sebastian Dröge
c09b7b9e41 fmp4mux: Port to aggregator as base class as preparation for supporting multiple streams 2022-05-12 18:31:02 +03:00
Sebastian Dröge
23cc00ce4b fmp4mux: Write sample flags in tfhd if there's only a single sample
Instead of declaring them to be in the `tfhd` but not writing them into
the `tfhd` but also not the `trun`.
2022-05-12 18:31:02 +03:00
Mathieu Duponchelle
943a138d49 ts-jitterbuffer: set jbuf delay when instantiating it
The internal (C) jitterbuffer needs to know about the configured
latency when calculating a PTS, as it otherwise may consider that
the packet is too late, trigger a resync and cause the element to
discard the packet altogether.

I could not identify when this was broken, but the net effect was
that in the current state, ts-jitterbuffer was discarding up to
half of all the incoming packets.
2022-05-11 06:29:22 +00:00
Sebastian Dröge
2f16b5dd3e threadshare: Use into_glib_ptr() instead of into_ptr() 2022-05-08 13:31:10 +03:00
Julien Vary
f908cbaffd fmp4mux: adding headers when data resumes after EOS 2022-04-28 11:39:55 -04:00
Tim-Philipp Müller
90c203857a threadshare: fix build on Windows 2022-04-27 00:13:46 +01:00
Sebastian Dröge
9e3f713aa9 Update to m3u8-rs 4.0 2022-04-14 07:41:18 +00:00
Vivia Nikolaidou
b5a3a99825 m3u8-rs: Depend on version exactly 3.0.0
https://github.com/rutgersc/m3u8-rs/pull/46#issuecomment-1094867533
2022-04-11 13:22:44 +03:00
Sebastian Dröge
5af52f94a8 threadshare: Remove glib::SendUnique usage
It's being removed from the GLib bindings because it does not add much
value.
2022-04-09 08:41:58 +00:00
Sebastian Dröge
803e452889 Update minimum supported GStreamer version to 1.14 2022-04-07 12:41:54 +03:00