Commit graph

314 commits

Author SHA1 Message Date
Sebastian Dröge fceacf7081 Update for gst::Array / gst::List API improvements
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/985>
2022-11-27 01:12:46 +02:00
François Laignel e1afa43aa3 ts/udpsink: handle items in the PadSinkHandler
... instead of forwarding them to a Task via a channel.

This improves CPU usage by 5% according to `udpsrc-benchmark-sender`
with the `tuning` feature using default audio test buffers and
400 streams on the same ts-context.

It is expected to improve latency significantly. This is inferred
from `ts-standalone`: latency shrinks from around 5ms to 1.5µs
using the `task` sink compared to the `async-mutex` sink.

The async Mutex is mandatory here as we need to hold the lock
across await points.
2022-11-09 07:55:04 +00:00
François Laignel 29a490f6dc ts: introduce ts-audiotestsrc
This makes it easy to generate "listenable" signals and to evaluate
discontinuities.

When the `tuning` feature is activated and the `main-elem` property
is set, the element can log the parked duration in %, which is an
image of the CPU usage for the ts-context.

This commit adds a test mode to `udpsrc-benchmark-sender` which
generates default audio buffers from `ts-audiotestsrc`. The `rtp`
mode is modified so that it uses `ts-audiotestsrc`.
2022-11-09 07:55:04 +00:00
François Laignel 9b96cfc452 ts/standalone: add new Sinks
Contrary to the existing Task Sink, the Async and Sync Mutex Sinks
handle buffers in the `PadSinkHandler` directly. The Async Mutex
Sink uses an async Mutex for the `PadSinkHandlerInner` while the
Sync Mutex Sink uses... a sync Mutex.

All Sinks share the same settings and stats manager.

Use the `--sink` command line option to select the sink (default is
`sync-mutex` since it allows evaluating the framework with as little
overhead as possible.

Also apply various fixes:

- Only keep the segment start instead of the full `Segment`. This
  helps with cache locality (`Segment` is a plain struct with many
  fields) and avoids downcasting the generic `Segment` upon each
  buffer handling.
- Box the `Stat`s. This should improve cache locality a bit.
- Fix EOS handling which took ages for no benefits in this
  particular use case.
- Use a macro to raise log level in the main element.
- Move error handling during item processing in `handle_loop_error`.
  This function was precisely designed for this and it should reduce
  the `handle_item`'s Future size.
2022-11-09 07:55:04 +00:00
François Laignel 4616f0a4a4 ts/standalone: move current sink under task_sink 2022-11-09 07:55:04 +00:00
Sebastian Dröge 360e4275ed threadshare: Update to concurrent-queue 2 2022-11-09 09:15:38 +02:00
Sebastian Dröge a8250abbf1 Fix various new clippy warnings 2022-11-01 10:27:48 +02:00
Sebastian Dröge f2223cf2cb Update versions to 0.10.0-alpha.1 2022-10-24 19:31:19 +03:00
François Laignel 5ca033049e ts/pad: use gst::Pad in handlers trait functions...
... instead of the `Pad{Src,Sink}Ref` wrappers:

- In practice, only the `gst::Pad` is useful in these functions.
  Some of these which need a `Pad{Src,Sink}Ref`, but it's the one
  for the opposite stream direction. In those cases, it is accessed
  via the element's implementation.
- It saves a few `clone`s.
- The implementations usually use the `gst::Pad` for logging.
  They no longer need to access it via `pad.gst_pad()`.
2022-10-24 13:15:13 +02:00
François Laignel 554ce7e7d6 ts/pad: don't pass self as ref in remaining handler traits functions
- They are either unit types or `Clone` (in which case they are implemented
  as pointers).
- Internally, we already use an owned version, so there's no need to get a
  reference.
- It facilitates implementation if the handler must be moved into a closure
  or a `Future`.
2022-10-24 12:01:09 +02:00
Sebastian Dröge 9a68f6e221 Move from imp.instance() to imp.obj()
It's doing the same thing and is shorter.
2022-10-23 23:08:46 +03:00
François Laignel 86776be58c Remove & for obj in log macros
This is no longer necessary.

See https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/merge_requests/1137
2022-10-23 21:22:31 +02:00
Sebastian Dröge f045099fc1 Fix GObject type names, GStreamer debug category names and element factory names
Fixes https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/issues/198
2022-10-23 20:46:08 +03:00
Sebastian Dröge 211cd095d6 Add new mux subdirectory for container formats
Contains the (incomplete) flavors FLV demuxer and the fragmented MP4
muxer for now.

Fixes https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/issues/173
2022-10-23 20:25:08 +03:00
Sebastian Dröge 20ad9175d8 Make GStreamer plugin/crate/library/directory names and descriptions consistent
Fixes https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/issues/238
2022-10-23 20:25:08 +03:00
Sebastian Dröge f058a5e229 Various minor cleanups 2022-10-22 19:50:24 +03:00
François Laignel 6319d104a8 Take advantage of Into<Option<_>> args
Commit 24b7cfc8 applied changes related to nullability as declared
by gir. One consequence was that some functions signature ended up
requiring users to pass `Some(val)` when they could use `val`
before.

This commit applies changes on `gstreamer-rs` which, will honoring
the nullability stil allow users to pass `val` for the few affected
functions.

This commit also fixes the signature for `Element::request_new_pad`
which was updated upstream.
2022-10-21 11:54:24 +02:00
Sebastian Dröge 12400b6b87 Update everything for element factory builder API changes
And set properties as part of object construction wherever it makes
sense.
2022-10-19 19:43:29 +03:00
Sebastian Dröge 24b7cfc841 Update for GStreamer API changes 2022-10-18 19:26:52 +03:00
François Laignel 8011eadfd2 Use new format constructors
See https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/merge_requests/1128
2022-10-18 10:36:59 +00:00
Vivia Nikolaidou 9b1361b538 plugins: Use .into() instead of gst::Fraction::new() where applicable 2022-10-14 18:21:28 +03:00
Vivia Nikolaidou f11b0fa5eb plugins, examples, tutorials: Use AudioCapsBuilder and VideoCapsBuilder
Simplify caps creation code
2022-10-13 19:24:57 +00:00
Sebastian Dröge e49138516c Update for pad default functions API changes 2022-10-12 19:50:15 +03:00
François Laignel 2bffdec691 ts: better use of imp & elem args in Pad{Sink,Src}Handlers
This is a follow-up to commit 7ee4afac.

This commit cleans up the `Pad{Sink,Src}Handler` by

- Keeping arguments which are strictly necessary.
- Passing arguments by value for the trait functions which return
  a `Future`. The arguments which were previously passed by reference
  were `clone`d internally and then `clone`d again in most
  implementations.

There are unfortunate differences in trait function signatures
between those which return a `Future` and the sync functions. This
is due to the requirement for the arguments to be moved to the
resulting `Future`, whereas sync functions can rely on references.
One particular notable difference is the use of the `imp` in sync
functions instead of the `elem` in functions returning a `Future`.
Because the `imp` is not guaranteed to implement `Clone`, we can't
move it to the resulting `Future`, so the `elem` is used.
2022-10-12 12:35:20 +02:00
François Laignel bc5b51687d fix formatted values constructors
In restrospect, building formatted values using operations on the
`ONE` constant doesn't seem idiomatic. This commit uses new panicking
constructors instead.

See https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/merge_requests/1122
2022-10-11 15:06:53 +02:00
François Laignel bd14e476f1 Fix direct access to the inner specific formatted values
This is no longer available as this could lead to building a defined
value in Rust which could be interpreted as undefined in C due to
the sentinel `u64::MAX` for `None`.

Use the constants (e.g. `ONE`, `K`, `M`, ...) and operations to build
a value and deref (`*`) to get the quantity as an integer.
2022-10-10 19:28:13 +02:00
Sebastian Dröge 7ee4afacf4 Change *Impl trait methods to only take &self and not Self::Type in addition 2022-10-10 15:03:25 +03:00
François Laignel 7818ac658b Use GFV::none_for_format where applicable 2022-10-08 18:29:10 +02:00
Sebastian Dröge 4c57a97d4d Update for glib::Object::new() API changes 2022-10-07 23:54:53 +03:00
Nirbheek Chauhan 1d4d3e4cb0 build: Update versions to be 0.9.0-alpha.1
0.9.0 is the next release, so we can't name things that already.

Also the version in meson.build was 0.13.0, which is completely wrong.
2022-10-04 21:27:23 +05:30
Sebastian Dröge 9b85dcc03b fmp4mux: Drop GAP buffers before doing ONVIF UTC time re-timestamping
GAP buffers won't have the reference timestamp meta.
2022-10-02 09:27:50 +00:00
Sebastian Dröge 36ce8bd4f7 fmp4mux: Implement a better strategy for splitting fragments and deciding which buffers go into which fragment
It is now guaranteed that each fragment is at most fragment-duration
long unless the one and only GOP of the fragment is longer than that.
The first (non-EOS) stream determines the duration of each fragment and
all other streams are drained to at most the fragment end timestamp
determined this way.

In addition the next fragment's target time is now at the end of the
previous fragment plus fragment-duration instead of using
  first-fragment + N*fragment-duration
regardless of where fragments were split before.

That is, fmp4mux now uses the same strategy as used by splitmuxsink and
as is required e.g. by HLS with regards to the target duration.
2022-10-02 09:27:50 +00:00
Sebastian Dröge b63627025e fmp4mux: Split huge drain function into separate functions 2022-09-29 10:40:41 +03:00
Sebastian Dröge 4ba4b00235 examples: Update to clap 4 2022-09-29 09:48:53 +03:00
Mathieu Duponchelle 18f08ae5dc jitterbuffer: fix typo when calculating max_misorder_time 2022-09-21 16:02:54 +02:00
Mac Thi Kieu Van 98fc0d5bd6 ts-jitterbuffer: Declare request-pt-map signal 2022-09-21 11:31:06 +00:00
Sebastian Dröge 7e13ea4ba9 fmp4mux: Drop gap buffers before further processing
They would potentially change timestamps and will break in ONVIF mode.
2022-09-16 14:54:33 +03:00
François Laignel 1be30b8ecc ts/scheduler: fix shutdown
A strong handle reference was held in the `block_on_priv` `Result`
handler in the thread for the `Scheduler::start` code path, which
lead to the `Handler` strong count not dropping to 0 when it
should, leading to the shutdown request not being triggered.

Use an Arc<AtomicBool> instead of a oneshot channel for shutdown.
The main Future is always polled and never relies on a waker, a
`poll_fn` is cheap and does the job.

Unpark the scheduler after posting a request to shutdown.
2022-09-13 07:29:50 +00:00
François Laignel ab327be9af ts/scheduler: improve tasks / io & timers polling balance
Set a limit to the nb of task checked before checking the reactor
and the main future again.
2022-09-13 07:29:50 +00:00
François Laignel d39aabe054 ts/Task: don't drain sub tasks after state transition and iteration
Subtasks are used when current async processing needs to execute
a `Future` via a sync function (eg. a call to a C function).
In this case `Context::block_on` would block the whole `Context`,
leading to a deadlock.

The main use case for this is the `Pad{Src,Sink}` functions:
when we `PadSrc::push` and the peer pad is a `PadSink`, we want
`PadSrc::push` to complete after the async function on the
`PadSink` completes. In this case the `PadSink` async function
is added as a subtask of current scheduler task and
`PadSrc::push` only returns when the subtask is executed.

In `runtime::Task` (`Task` here is the execution Task with a
state machine, not a scheduler task), we used to spawn state
transition actions and iteration loop (leading to a new
scheduler Task). At the time, it seemed convenient for the user
to automatically drain sub tasks after a state transition action
or an iteration. User wouldn't have to worry about this, similarly
to the `Pad{Src,Sink}` case.

In current implementation, the `Task` state machine now operates
directly on the target `Context`. State transtions actions and
the iteration loop are no longer spawned. It seems now useless to
abstract the subtasks draining from the user. Either they
transitively use a mechanism such as `Pad{Src,Sink}` which already
handles this automatically, or they add substasks on purpose, in
which case they know better when subtasks must be drained.
2022-09-13 07:29:50 +00:00
François Laignel af12bce141 ts/executor: clear the reactor instead of closing it...
... so that it can be reused on current thread for subsequent
Scheduler instantiations (e.g. block_on) without the need to
reallocate internal data structures.
2022-09-13 07:29:50 +00:00
François Laignel 61c62ee1e8 ts/timers: multiple improvements
This commit improves threadshare timers predictability
by better making use of current time slice.

Added a dedicate timer BTreeMap for after timers (those
that are guaranteed to fire no sooner than the expected
instant) so as to avoid previous workaround which added
half the max throttling duration. These timers can now
be checked against the reactor processing instant.

Oneshot timers only need to be polled as `Future`s when
intervals are `Stream`s. This also reduces the size for
oneshot timers and make user call `next` on intervals.
Intervals can also implement `FusedStream`, which can help
when used in features such as `select!`.

Also drop the `time` module, which was kepts for
compatibility when the `executor` was migrated from tokio
based to smol-like.
2022-09-13 07:29:50 +00:00
François Laignel 235ded35fd ts: add feature to add counters for performance evaluation
Add a `tuning` feature which adds counters that help with performance
evaluation. The only counter added so far accumulates the duration a
Scheduler has been parked, which is pretty accurate an indication of
CPU usage of the Scheduler.
2022-09-13 07:29:50 +00:00
François Laignel 72acbebff0 ts/standalone: multiple improvements
- Reworked buffer push.
- Reworked stats.
- Make first elements logs stand out. This make it possible to
  follow what's going on with pipelines containing 1000s of
  elements.
- Actually handle EOS.
- Use more significant defaults.
- Allow building without `clap` feature.
2022-09-13 07:29:50 +00:00
François Laignel 2355be1cef ts/jitterbuffer: extra robustness for Windows CI
jitterbuffer tests crash on Windows CI sometimes. Activating logs
showed time values which are probably not expected in a regular
environment, but which can happen there. Adding extra robustness
to `next_wakeup` computation seems to fix the problem judging by
the few runs I triggered.
2022-09-12 18:42:34 +00:00
Jordan Petridis 005fbafb30 threadshare: disable tests that can't work on windows
These depend on socket properties that are not available on windows
2022-09-05 11:47:20 +03:00
Sebastian Dröge 1a40186485 Update for GLib ParamSpec builder API changes 2022-09-05 11:45:47 +03:00
Sebastian Dröge 46dddaf31c Update minimum supported Rust version to 1.63 2022-09-04 21:31:55 +03:00
Thibault Saunier 664e2b75bd tsjitterbuffer: Fix latency type when getting property 2022-09-02 21:41:35 +00:00
Thibault Saunier 67e651f57c Allow "unused_doc_comments" as we use hotdoc and not rustdoc 2022-08-29 18:33:22 -04:00
Thibault Saunier 31a53bba8a Generate plugins documentation using hotdoc
Which will automatically be integrated in gstreamer documentation
2022-08-29 18:33:22 -04:00
Mathieu Duponchelle 052092cd2e onvifmetadata: removing encoding field
The encoding of ONVIF metadata is always UTF-8. ONVIF metadata may
or may not be encoded with gzip, but we don't see a use case for
transporting compressed ONVIF metadata between elements for now.
2022-08-24 08:57:12 +00:00
Vivia Nikolaidou 5606111345 plugins: Simplify code using ParamSpecBuilder 2022-08-22 17:58:43 +03:00
Sebastian Dröge 84f6484140 fmp4mux: Consider invalid running times as zero and before anything else
The code tried to do this before but didn't consider the case where the
first pad has a valid running time, in which case the buffer with the
invalid running time would never be dequeued and the muxer would never
output anything.
2022-08-22 15:20:10 +03:00
François Laignel 2bb071a950 ts/runtime: slight optimizations for sub tasks related operations
Using callgrind with the standalone test showed opportunities for
improvements for sub tasks addition and drain.

All sub task additions were performed after making sure we were
operating on a Context Task. The Context and Task were checked
again when adding the sub task.

Draining sub tasks was perfomed in a loop on every call places,
checking whether there were remaining sub tasks first. This
commit implements the loop and checks directly in
`executor::Task::drain_subtasks`, saving one `Mutex` lock and
one `thread_local` access per iteration when there are sub
tasks to drain.

The `PadSink` functions wrapper were performing redundant checks
on the `Context` presence and were adding the delayed Future only
when there were already sub tasks.
2022-08-18 18:42:18 +02:00
François Laignel 57da8e649d ts/examples: introduce a standalone pipeline test
Implement a test that initializes pipelines with minimalistic
theadshare src and sink. This can help with the evaluation of
changes to the threadshare runtime or with element
implementation details. It makes it easy to run flamegraph or
callgrind and to focus on the threadshare runtime overhead.
2022-08-18 18:42:18 +02:00
Sebastian Dröge 374bb8323f Fix build after glib SignalBuilder::param_types() API change 2022-08-17 23:37:39 +03:00
Sebastian Dröge 2c99f66ea5 fmp4mux: Dequeue the earliest buffer from any pad first instead of dequeueing up to a whole fragment from the same pad
This keeps the fill levels of each sinkpad in sync.
2022-08-17 19:23:18 +03:00
François Laignel 21da753607 ts/udpsink: move sync on buffer to try_next
By moving sync on buffer ts to `try_next`, the resulting delay
can be cancelled when a state transition occurs.

To prevent item loss, this requires first peeking the incoming
item from the channel without popping it. After the delay has
elasped, we can pop the item as the last await point in
`try_next`: either it will be cancelled before popping or the
popped item will be passed on to `handle_item`.

Also add `flush` which was missing from `stop` and `flush_start`
transition actions.
2022-08-13 13:03:43 +02:00
Sebastian Dröge b464e74d41 fmp4mux: Require parsed ONVIF timed metadata 2022-08-12 18:51:26 +03:00
Sebastian Dröge e4081872c5 fmp4mux: Use UTC times from reference timestamp meta in ONVIF mode 2022-08-12 18:51:26 +03:00
Sebastian Dröge 5376596557 fmp4mux: Write ONVIF Export File Format CorrectStartTime box for ONVIF variant 2022-08-12 18:51:06 +03:00
Sebastian Dröge ef7ed2d953 fmp4mux: Remove obsolete #[allow(clippy::too_many_arguments)] 2022-08-12 10:06:10 +03:00
François Laignel 33e601d33e ts: migrate elements to try_next / handle_item
See previous commit for details.

Also switched to panicking for some programming errors.
2022-08-10 20:10:08 +02:00
François Laignel 8b54c3fed6 ts/Task: split iterate into try_next and handle_item
Previous Task iteration model suffered from the following
shortcomings:

- When an iteration was engaged it could be cancelled at
  await points by Stop or Flush state transitions,
  which could lead to inconsistent states.
- When an iteration was engaged it could not be cancelled
  by a Pause state transition so as to prevent data loss.
  This meant we couldn't block on the Pause request because
  the mechanism couldn't guarantee Paused would be reached
  in a timely manner.

This commit split the Task iteration into:

- `try_next`: this function returns a future that awaits
  for a new iteration to begin. The regular use case is
  to return an item to process. The item can be left to
  `()` if `try_next` acts as a tick generator. It can
  also return an error. This function can be cancelled at
  await points when a state transition request occurs.
- `handle_item`: this function is called with the item
  returned by `try_next` and is guaranteed to run to
  completion even if a transition request is received.

Note that this model plays well with the common Future
cancellation pitfalls in Rust.
2022-08-10 20:02:53 +02:00
Sebastian Dröge bdaa39e267 threadshare: Fix some new clippy beta warnings
warning: this expression borrows a value the compiler would automatically borrow
   --> generic/threadshare/src/runtime/executor/async_wrapper.rs:402:19
    |
402 |             match (&mut *self).get_mut().read(buf) {
    |                   ^^^^^^^^^^^^ help: change this to: `(*self)`
    |
    = note: `#[warn(clippy::needless_borrow)]` on by default
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow
2022-08-10 12:58:28 +03:00
François Laignel fb7929dda6 ts: update elements for new TransitionStatus
See previous commit
2022-08-09 19:48:06 +02:00
François Laignel d4061774a4 ts/Task: return a future for state transitions
State transitions request functions hid the synchronization
details to the caller:

- If the transition was requested from a Context, a subtask was
  added or the transition ack was not awaited if the new transition
  was requested from a running transition or an iteration function.
- If the transition was not requested from a Context, current
  thread was blocked until the ack was received.

This strategy facilitated code in elements, but it suffered from
the following shortcomings:

- The `prepare` transition request didn't comply with the above
  strategy and would always return an `Async` form. This was
  designed to accomodate the `Prepare` function for elements
  such as `ts-tcpclientsrc` which takes times due to the
  TCP socket connection delays. The idea was that the actual
  transition result would be available after calling `start`.
  This was a disadvantage for elements which would prefer to
  error immediately in the event of a preparation failure.
- Hidding the transition request synchronization to the caller
  meant that they had no options but relying on the internal
  mechanism. E.g.: it was not possible to `start` from another
  async runtime without blocking. Also it was not possible
  to request a transition and choose not to await for the
  ack.

This commit introduces a more flexible API for state
transitions requests:

- The transition request function now return a `TransitionStatus`,
  which is a Future.
- When an error occurs immediately (e.g. the transition
  request is not autorized due to current state of the Task),
  the `TransitionStatus` is resolved immediately and can be
  `check`ed for errors. This is useful for functions such as
  `pepare` in the case of `ts-tcpclientsrc` (see above).
  This is also useful for `pause`, because in current design,
  the transition is always async. Note however, that `pause` is
  forseen to adhere to the same behaviour as the other transition
  requests in the near future [1].
- If the caller chooses to await for the ack and they don't know
  if they are running on a ts Context (e.g. in `Pad{Src,Sink}`
  handlers), they can call `await_maybe_on_context`. This is mostly
  the same behaviour as the one that used to be performed internaly.
- If the caller knows for sure they can't possibly block an async
  executor, they can call `block_on` which is more explicite, but
  will nonetheless make sure no ts Context is being blocked. This
  last check was introduced as it was considered low overhead
  while it should ease preventing missues in cases where the above
  functions should be used.

[1]: https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/793#note_1464400
2022-08-09 19:48:06 +02:00
François Laignel 625fce3934 ts/Task: spawn StateMachine on ts Context
Task state machines used to execute in an executor from the Futures
crate. State transitions actions and iteration functions were then
spawned on the target threadshare Context.

This commit directly spawns the task state machine on the threadshare
Context. This simplifies code a bit and paves the way for the changes
described in [1].

Also introduces struct `StateMachineHandle`, which gather together
fields to communicate and synchronize with the StateMachine. Renamed
`StateMachine::run` as `spawn` and return `StateMachineHandle`.

[1]: https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/793#note_1464400
2022-08-09 19:48:06 +02:00
François Laignel 0858dfedb4 ts-udpsrc: align default port with C counterpart
... and also with the default settings for ts-udpsink.
2022-08-09 17:42:53 +02:00
Sebastian Dröge d058c96596 fmp4: Update to m3u8-rs 5 2022-08-09 13:40:39 +00:00
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