Commit graph

138 commits

Author SHA1 Message Date
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
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
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
François Laignel
e2add3f2c8 ts-jitterbuffer: add dedicated functions for state transitions + tests
fixes https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/issues/95
2020-01-23 19:10:21 +01:00
Mathieu Duponchelle
c50aa09034 threadshare: fix latency query handlers
Returning 0 as the max latency in those sources is incorrect,
and may lead to sinks incorrectly complaining about insufficient
buffering elements.

Reproduce with:

gst-launch-1.0 ts-udpsrc port=50000 address=127.0.0.1 \
  caps="application/x-rtp, media=(string)audio, clock-rate=(int)8000, encoding-name=(string)PCMA, payload=(int)8" ! \
  rtppcmadepay ! alawdec ! autoaudiosink

gst-launch-1.0 audiotestsrc do-timestamp=true samplesperbuffer=400 ! \
  alawenc ! rtppcmapay max-ptime=50000000 min-ptime=50000000 ! \
  udpsink host=127.0.0.1 port=50000

Logs:

Not enough buffering available for  the processing deadline of 0:00:00.020000000,
add enough queues to buffer  0:00:00.020000000 additional data.
Shortening processing latency to 0:00:00.000000000.

This then causes glitches, there are many other ways for the problems
to manifest.
2020-01-23 15:36:22 +00:00
Mathieu Duponchelle
decc1e2029 threadshare: make live sources return NoPreroll from PlayingToPaused
Not returning NoPreroll in that transition causes downstream sinks
to wait for preroll forever.

Reproduce with:

gst-launch-1.0 audiotestsrc ! udpsink host=127.0.0.1 port=50000
gst-launch-1.0 ts-udpsrc address=127.0.0.1 port=50000 ! fakesink

ctrl + C in the receiver pipeline -> hangs forever
2020-01-23 15:56:11 +01:00
François Laignel
d1cc8eaec8 ts: don't panic when operating on a Context without a valid PadContext
Fixes https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/issues/94
2020-01-22 06:16:17 +00:00
Mathieu Duponchelle
0aa5b15564 jitterbuffer: return NoPreroll when going from READY to PAUSED
This is useful when upstream is not a live source

Fixes potential issue discussed in:

https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/issues/93#note_388528
2020-01-21 22:14:33 +01:00
Mathieu Duponchelle
1823ca525e jitterbuffer: don't try to lock in query handlers
Instead, add position and latency fields to the PadSrcHandler

Fixes #93
2020-01-21 22:14:06 +01:00
François Laignel
676ae87aed ts: queue & proxy: spawn on src_pad in PadSinkHandlers...
... instead of copying the src_pad's Context
2020-01-17 15:37:54 +01:00
François Laignel
7a4fea8669 ts-udpsrc: prepare socket immediately
Now that we can `Context::enter`, it is no longer necessary to spawn
a `Future` to prepare the `UdpSocket` and beneficiate from the
`Context`'s IO driver.
2020-01-16 00:44:48 +01:00
François Laignel
a15d60105b ts: fix FlushStart / FlushStop events handling 2020-01-16 00:44:45 +01:00
François Laignel
3eed2f69d9 ts: have block_on panic if running on a Context thread 2020-01-16 00:18:16 +01:00
Guillaume Desmottes
db8b2ad08b threadshare: fix coding style
Just ran 'gst-indent'.
2020-01-02 11:49:39 +05:30
Sebastian Dröge
9772adbfbf Fix various new clippy warnings from 1.40 2019-12-22 11:35:01 +02:00
François Laignel
688357a474 Update jitterbuffer.rs + clippy pass 2019-12-21 10:58:14 +01:00
François Laignel
dfbc0d3975 Move jitterbuffer to its own directory module 2019-12-21 10:45:43 +01:00
François Laignel
0221524a10 Update to tokio release 0.2.5 + throttling 2019-12-21 08:56:43 +01:00
François Laignel
e8f5191ee7 ts: Pad wrapper for async processing
See https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/merge_requests/170#note_276334
and https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/merge_requests/204
2019-12-21 08:56:43 +01:00
François Laignel
ff470e9799 ts: move iocontext.rs to runtime/executor.rs
Part of: https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/merge_requests/170
2019-12-19 20:44:00 +01:00
François Laignel
8eec141517 threadsharing: migrate to async/await and tokio 0.2.0-alpha.6
See https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/merge_requests/164
2019-12-19 20:44:00 +01:00
Sebastian Dröge
1ae57967ae Move debug categories from an instance member to lazy_static
Simplifies the code a bit and less state to carry around.
2019-10-31 23:35:11 +01:00
Sebastian Dröge
04bc1a6b65 ts-udpsrc: Remove redundant semicolons 2019-10-04 12:06:47 +03:00
Mathieu Duponchelle
9897336896 jitterbuffer: flush RTPJitterBuffer when going to NULL
and cancel our timer
2019-10-03 15:56:07 +00:00
Mathieu Duponchelle
8a4d517dec jitterbuffer: fix tear down
- Release pending future id in READY -> NULL
- Verify that we still have an io_context in the timeout's closure
2019-10-03 15:56:07 +00:00
Sebastian Dröge
b84388b0f3 threadshare: Fix shutdown race condition
We might've already handled the shutdown unparking while doing the
previous turn(s), so we have to check the atomic bool afterwards again
and before waiting (potentially) forever.

Fixes https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/issues/75
2019-10-02 12:02:09 +03:00
Mathieu Duponchelle
5976c9c1e4 jitterbuffer: timeouts may be called context_wait / 2 too early
Take this into account to determine what packets need sending out.
2019-09-24 15:17:27 +02:00
Mathieu Duponchelle
c5d5cdcd9d jitterbuffer: discard packets with invalid pts
When RTPJitterBuffer resets itself in caluclate_pts(), it returns
GST_CLOCK_TIME_NONE and the packet should be discarded, according
to the behaviour of the standard jitterbuffer.
2019-09-24 15:17:22 +02:00
Mathieu Duponchelle
ec56fee368 jitterbuffer: fix packet_spacing calculation
When encountering an unexpected gap in received seqnums, ips_pts
and ips_rtptime must be reset to avoid calculating a potentially
invalid packet spacing the next time sequential packets are
received.
2019-09-12 15:29:18 +02:00
Sebastian Dröge
e7053bc046 threadshare: Don't keep timers locked while waiting for IO 2019-09-09 13:55:56 +03:00
Sebastian Dröge
5f9d649021 threadshare: Handle context-wait==0 by waiting on IO 2019-09-09 12:37:18 +03:00
Sebastian Dröge
1084178e95 jitterbuffer: Minor code cleanup 2019-09-07 10:53:11 +03:00