Commit graph

169 commits

Author SHA1 Message Date
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
François Laignel 59ca466081 ts: log max throttling when creating Context 2022-03-28 08:47:32 +00:00
François Laignel 1ef9ae6398 ts/jitterbuffer: don't wake up immediately...
... when next wakeup delay is shorter than the max throttling duration.

See https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/issues/169
2022-03-28 08:47:32 +00:00
François Laignel 8eb8ea0e7d ts/rt/Task: use light weight executor blocking on ack or join handle
Previous version used the Context::block_on_or_add_sub_task which
spawns a full-fledged executor with timer and io Reactor for no
reason when we just need to wait for a Receiver or JoinHandle.
2022-03-28 08:47:32 +00:00
François Laignel c1615d01e6 ts/rt/Task: awake the iteration loop when it needs to be aborted
When the iteration loop is throttling, the call to `abort` on the
`loop_abort_handle` returns immediately, but the actual `Future`
for the iteration loop is aborted only when the scheduler throttling
completes. State transitions which requires the loop to be aborted &
which are serialized at the pipeline level can incur long delays.

This commit makes sure the Task Context's scheduler is awaken as soon
as the task loop is aborted.
2022-03-28 08:47:32 +00:00
François Laignel 97985d6442 ts/examples: add rtp mode with jitter-buffer & trace stop duration 2022-03-28 08:47:32 +00:00
Sebastian Dröge 6cf7d28481 Use SPDX license format in Cargo.toml 2022-03-14 10:23:16 +02:00
Mathieu Duponchelle 526f34d98b fmp4mux: HLS live example
Producing two audio playlists, a video playlist and a super
manifest, and implementing basic trimming of old segments.
2022-03-02 10:01:38 +00:00
Mathieu Duponchelle 35d9247487 fmp4mux: HLS VOD example
Producing two audio playlists, a video playlist and a super
manifest
2022-03-02 10:01:38 +00:00
Sebastian Dröge b38f6cc731 Remove now unnecessary Send+Sync impls for element/etc subclasses
This is now automatically implemented.
2022-02-28 18:56:58 +02:00
François Laignel 72d9d3dc58 generic/threadshare: fix for nightly build 2022-02-22 00:18:28 +01:00
François Laignel 2cf84d5ce8 Update minimum supported Rust version to 1.57 2022-02-21 23:32:32 +01:00
François Laignel 422ea740ca Update to gst::_log_macro_
See the details:
https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/merge_requests/980
2022-02-21 20:50:01 +01:00
Sebastian Dröge 65fcd55160 Update for event/message/query view API changes 2022-01-19 15:07:45 +02:00
Sebastian Dröge b2d0172422 Replace Foo::from_instance(foo) with foo.imp() 2022-01-17 19:36:41 +02:00
Sebastian Dröge 51f8e963d6 Add SPDX-License-Identifier to all file headers 2022-01-15 21:18:47 +02:00
Sebastian Dröge 0c7764fa40 Update versions to 0.9.0 2022-01-15 20:33:49 +02:00
Sebastian Dröge ab14c50d1c Ignore clippy::non_send_fields_in_send_ty lint
It's useless in its current shape and wrongly triggering on all types.

See https://github.com/rust-lang/rust-clippy/issues/8045
2022-01-14 12:09:57 +02:00
Sebastian Dröge 81f5f0f60c Fix various clippy warnings 2022-01-12 19:51:08 +02:00
François Laignel 64dd588734 ts/runtime/scheduler: check must_awake before sleeping 2022-01-05 19:00:00 +01:00
François Laignel 1573522520 ts/runtime: rewrite runnable loop
Previous version relied on a plain loop / match / break because
I experimented different strategies. The while variant is better
for the final solution.
2022-01-05 18:59:43 +01:00
Sebastian Dröge e2ecd77654 sodium: Port examples to clap 3 2022-01-02 09:13:55 +00:00
François Laignel 5e4fc8b138 ts/executor: relax the static bound on enter
The function `enter` is executed in a blocking way from the caller's
point of view. This means that we can guaranty that the provided
function and its output will outlive the underlying Scheduler Task
execution. This requires an unsafe call to
`async_task::spawn_unchecked`. See:

https://docs.rs/async-task/latest/async_task/fn.spawn_unchecked.html
2021-12-25 11:25:56 +00:00
François Laignel 6163589ac7 ts/executor: replace tokio with smol-like implementation
The threadshare executor was based on a modified version of tokio
which implemented the throttling strategy in the BasicScheduler.
Upstream tokio codebase has significantly diverged from what it
was when the throttling strategy was implemented making it hard
to follow. This means that we can hardly get updates from the
upstream project and when we cherry pick fixes, we can't reflect
the state of the project on our fork's version. As a consequence,
tools such as cargo-deny can't check for RUSTSEC fixes in our fork.

The smol ecosystem makes it quite easy to implement and maintain
a custom async executor. This MR imports the smol parts that
need modifications to comply with the threadshare model and implements
a throttling executor in place of the tokio fork.

Networking tokio specific types are replaced with Async wrappers
in the spirit of [smol-rs/async-io]. Note however that the Async
wrappers needed modifications in order to use the per thread
Reactor model. This means that higher level upstream networking
crates such as [async-net] can not be used with our Async
implementation.

Based on the example benchmark with ts-udpsrc, performances seem on par
with what we achieved using the tokio fork.

Fixes https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/issues/118

Related to https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/604
2021-12-25 11:25:56 +00:00
François Laignel db9c38aa93 ts/runtime: shuffle some structs to dedicated modules 2021-12-25 11:25:56 +00:00