Commit graph

150 commits

Author SHA1 Message Date
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
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
ccfb8246be Fix compilation after gstreamer-rs!383 2019-12-18 08:17:42 +02: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
b05fb902f9 Remove usage of subclassing feature, it's the default now 2019-09-09 10:45:06 +03:00
Sebastian Dröge
1084178e95 jitterbuffer: Minor code cleanup 2019-09-07 10:53:11 +03:00
Sebastian Dröge
83cc8104a1 Fix or silence all remaining clippy warnings
Also ignore common errors we don't care about when running clippy and
make clippy errors fail the CI.
2019-09-07 10:42:07 +03:00
Mathieu Duponchelle
2c7775125a tests/appsrc: remove unrelated jitterbuffer "tests"
This was mistakenly staged during development for !161
2019-09-06 21:13:37 +02:00
Mathieu Duponchelle
9d7e304fc6 threadshare: address clippy errors 2019-09-06 19:21:07 +02:00
Mathieu Duponchelle
202ff408e7 jitterbuffer: share context downstream
.. and execute pending futures after pushing buffers
2019-09-06 14:33:39 +00:00
Mathieu Duponchelle
5496067925 jitterbuffer: initial thread sharing support 2019-09-06 14:33:39 +00:00
Sebastian Dröge
33cb599464 threadshare/iocontext: Add custom interval timer implementation
This knows about our throttled event loop and ensures that timers are
triggered at most 1 throttle time later instead of 2.
2019-09-06 14:33:39 +00:00
Mathieu Duponchelle
b7e55836c1 WIP: thread-sharing jitterbuffer
Actual thread-sharing will follow!
2019-09-06 14:33:39 +00:00
François Laignel
0e11ac87d3 Update for new {Value, StructureRef}::get signature
See https://github.com/gtk-rs/glib/pull/513
and https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/merge_requests/310
2019-08-13 15:29:28 +02:00
Mathieu Duponchelle
da2332d814 ts-queue: Make PendingQueue a proper struct 2019-08-09 11:44:47 +00:00
Mathieu Duponchelle
892c812669 ts-queue: split up enqueue_item
This is far from a full refactoring, but it makes the current
implementation slightly easier to understand
2019-08-09 11:44:47 +00:00
Ray Tiley
ccd607707d threadsharing/udpsrc: Fix build on Windows 2019-08-08 10:32:19 -04:00