Commit graph

192 commits

Author SHA1 Message Date
Guillaume Desmottes
4bfd1f76f3 threadshare: fix GstClockTime formatting
GstClockTime is a guint64 whose format is platform dependent.
2020-04-01 15:02:54 +02:00
François Laignel
20a9eba4c8 threadshare: separate Task from PadSrc 2020-03-27 19:57:39 +01:00
François Laignel
89682aa6a8 threadshare/jitterbuffer: fix a race condition when stopping
Don't hold the `state` while stopping as the task might attempt to
lock it before reaching an `await` point.
2020-03-27 19:35:25 +01:00
François Laignel
116cf9bd3c threadshare/*src: rework pause/flush_start/flush_stop
This commit fixes several issues with the `Ts*Src` elements.

The pause functions used cancel_task which breaks the Task loop at await
points. For some elements, this implies making sure no item is being lost.
Moreover, cancelling the Task also cancels downstream processing, which
makes it difficult to ensure elements can handle all cases.

This commit reimplements Task::pause which allows completing the running
loop iteration before pausing the loop.

See https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/277#note_439529

In the Paused state, incoming items were rejected by TsAppSrc and DataQueue.

See https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/277#note_438455

- FlushStart must engage items rejection and cancel the Task.
- FlushStop must purge the internal stream & accept items again.

If the task was cancelled, `push_prelude` could set `need_initial_events`
to `true` when the events weren't actually pushed yet.

TsAppSrc used to renew its internal channel which could cause Buffer loss
when transitionning Playing -> Paused -> Playing.

See https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/issues/98
2020-03-21 18:46:03 +00:00
Sebastian Dröge
5dd80e0706 Fix/silence various new clippy warnings 2020-03-19 12:55:29 +02:00
Sebastian Dröge
dcf2befe52 threadshare/inputselector: Send a reconfigure event when the active pad changes 2020-03-19 11:37:27 +02:00
Sebastian Dröge
4c0ba5c374 threadshare/inputselector: Query all sinkpads for their latency and post latency messages when the pads change 2020-03-19 11:37:27 +02:00
Mathieu Duponchelle
c01ef0e774 threadshare/inputselector: port to new API 2020-03-19 11:37:27 +02:00
Sebastian Dröge
ad4597a40e threadshare/inputselector: Set DISCONT flag on first buffer after each pad switch 2020-03-19 11:37:25 +02:00
Sebastian Dröge
625798c5db threadshare/inputselector: Fix sticky event handling
Whenever a new sticky event arrives we must make sure to forward it
downstream before the next buffer.

Also make sure to unlock all our mutexes when they're not needed
anymore.
2020-03-19 11:37:22 +02:00
Sebastian Dröge
6c4108671f threadshare/inputselector: Implement a correct chain_list() function
Instead of directly forwarding the list, handle each buffer separately
for now. Previously we would directly forward the lists from any pad,
including inactive ones, downstream.
2020-03-19 11:37:18 +02:00
Mathieu Duponchelle
0b240b829e threadshare/inputselector: fix tearing down
GstElementClass.release_pad() may be called after the element
has transitioned back to NULL, we need to keep our sink_pads
map around until then.

They should also not be affected by state transitions at all but only be
removed once the user does so or the element is destroyed, so they need
to live independent of the state.
2020-03-19 11:20:24 +02:00
Sebastian Dröge
575efcab7e threadshare/inputselector: Port to latest API 2020-03-19 11:20:24 +02:00
Mathieu Duponchelle
b3becb01c3 threadshare: New input selector element 2020-03-19 11:20:24 +02:00
Sebastian Dröge
cbfd80d75f Update for new GLib boxed deriving API 2020-03-19 11:18:17 +02:00
Sebastian Dröge
56895f35bc threadshare/runtime: Add a dummy context when blocking the current thread
This allows downstreams to function as if a normal context thread is
operating upstream apart from not being able to spawn new tasks.

Fixes https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/issues/96
2020-03-16 15:19:39 +02:00
Sebastian Dröge
12dcca3f17 threadshare/runtime: Drain pending sub tasks in a loop
A pending sub task might add new pending sub tasks that have to be
handled first.
2020-03-16 15:02:30 +02:00
Sebastian Dröge
fa7cc9826d appsrc: Don't make pushing of buffers/eos asynchronous
We can directly use try_send(), which has the same effect.
2020-03-16 15:01:06 +02:00
Sebastian Dröge
d2ad227a2f threadshare/udpsink: Some more refactoring
Let's take locks less often.
2020-03-16 12:42:33 +02:00
Sebastian Dröge
85cbbf5240 threadshare/udpsink: Properly remove clients
Leave any multicast groups they might have joined.
2020-03-16 12:33:18 +02:00
Sebastian Dröge
ac574cd112 threadshare/udpsink: Minor cleanup / optimizations for client addition 2020-03-16 12:31:41 +02:00
Sebastian Dröge
9ddcae4ed2 threadshare: Fix some clippy warnings 2020-03-15 13:40:45 +02:00
François Laignel
bfedca6cfe threadshare/proxy: Port proxysrc/sink to new API 2020-03-15 13:18:02 +02:00
Mathieu Duponchelle
5f9e923a04 threadshare/jitterbuffer: Avoid buffer copies
Replaces the RTPJitterBufferItem.get_buffer() method with an
into_buffer() version, ensuring that when we make it mutable we
don't make a copy (unless necessary)
2020-03-15 13:18:02 +02:00
Sebastian Dröge
776708bee6 threadshare/jitterbuffer: Port jitterbuffer to new API and completely refactor 2020-03-15 13:17:59 +02:00
François Laignel
95b2641056 threadshare/queue: Port queue to the new API 2020-03-15 13:17:26 +02:00
Sebastian Dröge
ded3af31c1 threadshare/tcpclientsrc: Port tcpclientsrc to new API 2020-03-15 13:17:26 +02:00
Mathieu Duponchelle
5f5f0fe866 threadshare/udpsink: Port udpsink to new API 2020-03-15 13:17:26 +02:00
François Laignel
d9cd48287e threadshare/appsrc: Port appsrc to new API 2020-03-15 13:17:26 +02:00
Sebastian Dröge
f5eb91ebe2 threadshare/udpsrc: Port udpsrc to new API 2020-03-15 13:17:26 +02:00
François Laignel
4c584fd162 threadshare: Pad{Src,Sink}::unprepare: release all functions 2020-03-15 13:17:26 +02:00
Sebastian Dröge
e729324cce threadshare: Refactor infrastructure
The biggest changes are
- Many functions are not asynchronous anymore as it would be difficult
  to run them correctly with our mix of synchronous C code and Rust
  code.
- The pad context and its corresponding custom event are gone and
  instead thread local storage and task local storage are used. This
  makes it easier to correctly pass it through the different layers
  of Rust and C code and back.
- Sink events have a different function for serialized and oob events,
  src events are handled correctly by default now by simply forwarding
  them.
- Task::prepare() has a separate variant that takes a preparation
  function as this is a very common task.
- The task loop function can signal via its return value if it wants to
  be called again or not.
2020-03-15 13:17:26 +02:00
Sebastian Dröge
3ea465907d threadshare: Disable all elements for now 2020-03-15 13:17:26 +02:00
Mathieu Duponchelle
03fda100d4 threadshare/udpsink: pass correct defaults to v6 bind properties 2020-03-15 12:38:20 +02:00
Mathieu Duponchelle
bcbf862ded threadshare/udpsink: don't error out when socket can't be prepared for protocol
Instead, error out at chain time if a client with the unavailable
protocol (eg IPv6) has been added.
2020-03-15 12:38:20 +02:00
Sebastian Dröge
b8f8705c47 threadshare/udpsink: Add Element::send_event() impl and handle latency event
We need to add the latency to the running time we're waiting for, and
also should push all upstream events (apart from Step events) upstream.
2020-03-15 12:38:20 +02:00
Sebastian Dröge
160ae4d11c threadshare/udpsink: Port to latest API 2020-03-15 12:38:20 +02:00
Mathieu Duponchelle
382b9f118c threadshare: Initial version of a UDP sink 2020-03-15 12:38:20 +02:00
Sebastian Dröge
af56755aaa Revert "threadshare: Temporarily pin quote to 1.0.2"
This reverts commit 90b9499909.

It was fixed in the meantime.
2020-03-06 11:16:37 +02:00
Philippe Normand
90b9499909 threadshare: Temporarily pin quote to 1.0.2
See https://github.com/rust-lang-nursery/failure/issues/342

https://gitlab.freedesktop.org/gstreamer/gst-build/issues/83
2020-03-05 13:10:52 +00:00
Mathieu Duponchelle
9e665ae807 ts-jitterbuffer: fix request-pt-map emission
When a new payload type is encountered, we first check whether
it matches the caps received as an event before emitting the
request-pt-map signal if not, which means we shouldn't consider
errors from the first call to parse_caps as fatal.
2020-03-04 17:30:01 +01:00
Sebastian Dröge
e5e29b18d1 threadshare/rtpjitterbuffer: Use different GType names than used by the C rtpjitterbuffer
Otherwise there are conflicts when using them both in the same process.
2020-03-04 15:08:59 +00:00
Mathieu Duponchelle
1bfa20a656 ts-jitterbuffer: reset on unprepare
.. and reset earliest_pts in reset()
2020-03-04 15:13:41 +01:00
François Laignel
c60c6f0dc6 ts: use tag tokio-0.2.12-throttling 2020-02-28 16:05:48 +01:00
Sebastian Dröge
4dac77bb93 Fix some clippy warnings 2020-02-25 10:12:55 +02:00
Mathieu Duponchelle
49f73fbf61 proxy: fix items mistakenly discarded
When emptying the pending queue, we need to break as soon as
as we failed to push an item to the data queue, otherwise only
the last failed item is pushed back to the front of the pending
queue, and all the previously failed items in the loop get
discarded
2020-02-05 21:35:12 +01:00
Mathieu Duponchelle
bcae2423f5 proxy: signal the pending queue in ProxySrc.start()
If the proxy sink has already queued buffers in the shared
context pending queue and is waiting for space in the data
queue, we should signal that space is available when creating
it!
2020-02-05 21:35:12 +01:00
Mathieu Duponchelle
53e948b8da proxy: fix blocking upwards state change
ProxySink previously blocked on receiving the source pad
of ProxySrc in its ReadyToPaused transition, which meant
ProxySrc had to transition to Ready at the same time.

The usual use case is for the source and sink to reside in
two separate pipelines, and such an arrangement easily led
to deadlocks, as examplified by the new test case.

Instead we now maintain two more global hash maps holding
per-context sink pads and src pads weak references, and
forward events to those when needed.

As ProxySink may not have a source pad context to run
a future on when receiving FlushStart, gst::Element::call_async
is used instead, with a simple oneshot channel used to synchronize
flush start and flush stop handling.
2020-02-05 21:35:11 +01:00
Mathieu Duponchelle
4abb389269 socket based sources: close socket stream on unprepare
the socket was otherwise leaked
2020-02-04 20:09:27 +01:00
Sebastian Dröge
1e778e9827 Update for Seqnum/GroupId API changes 2020-01-25 01:21:22 +02:00