Commit graph

38 commits

Author SHA1 Message Date
Albert Sjolund
4d6c30cdb6 utils: streamproducer: wrap atomic operations
In order to support more platforms, especially MIPS,
add a small wrapper for necessary atomic(u64) instructions.
It exposes the necessary functions, and falls back to
mutex if needed.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/merge_requests/1471>
2024-08-12 14:54:29 +02:00
Guillaume Desmottes
3dab797c32 utils: streamproducer: fix set_forward_events() doc
The events are forwarded from the appsink to the appsrcs.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/merge_requests/1489>
2024-08-05 04:37:06 +00:00
Sebastian Dröge
a871f71515 gstreamer: Use obj = x instead of obj: x in debug log macros
And deprecate the old usage. This gives better tooling support, and
especially allows rustfmt to format the macro body correctly.

Fixes https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/issues/513

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/merge_requests/1477>
2024-07-06 14:08:03 +03:00
Sebastian Dröge
5ea912d702 Update to new clone macro syntax
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/merge_requests/1463>
2024-06-17 17:41:21 +03:00
Mathieu Duponchelle
0ef80c4fe7 streamproducer: expose set_forward_preroll() API
This is useful to decide whether the preroll sample should be forwarded
to consumers when prerolling or only once it is time to render it.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/merge_requests/1439>
2024-05-10 22:46:16 +00:00
Sebastian Dröge
193bcbf055 Switch from once_cell to std::sync::OnceLock where it makes sense
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/merge_requests/1379>
2024-01-31 14:59:54 +02:00
Sebastian Dröge
3b3c3baee5 Fix / work around a few new clippy 1.75 warnings
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/merge_requests/1370>
2023-12-22 16:33:41 +02:00
Guillaume Desmottes
a649e7dead gstreamer: move parse_* functions to their own module
Better namespacing so the API is more Rust-y.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/merge_requests/1355>
2023-12-04 16:15:51 +01:00
Sebastian Dröge
5ee8ee8545 utils: streamproducer: Don't use gst_element_send_event() in another place
It can cause deadlocks thanks to taking the state lock.
2023-11-10 09:45:09 +02:00
Sebastian Dröge
62f58620b7 gstreamer: Add accessors for PadProbeDatas on PadProbeInfo
And make use of it in examples and other code.

This allows to simplify usage a bit in most cases.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/merge_requests/1324>
2023-10-16 11:28:18 +03:00
Guillaume Desmottes
7bde0285ff gst-utils: prevent dead lock when requesting key unit
Sending the UpstreamForceKeyUnitEvent using gst_element_send_event()
internally takes the state lock. If appsink is pre-rolling we are also
holding the preroll lock.

This may result in a dead lock with the thread doing the state change as
this one takes the state lock and then the pre-roll lock.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/merge_requests/1316>
2023-10-03 11:45:51 +02:00
Guillaume Desmottes
63852b3b19 streamproducer: forward selected sticky events when adding consumers
The consumer pipeline may rely on some sticky events (Tag in my case)
which may have already been sent.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/merge_requests/1299>
2023-08-07 20:26:28 +00:00
Mathieu Duponchelle
88c21505d2 streamproducer: forward preroll sample from new_preroll callback
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/merge_requests/1280>
2023-07-07 17:06:54 +02:00
Mathieu Duponchelle
a4247d5199 streamproducer: extract process_sample function
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/merge_requests/1280>
2023-07-07 14:09:35 +02:00
Bilal Elmoussaoui
f9fa7f55fc Use re-exported once_cell
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/merge_requests/1293>
2023-07-06 16:50:35 +03:00
Jimmi Holst Christensen
85e427345e Forward tag events to consumers in StreamProducer
Fix #386

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/merge_requests/1045>
2023-04-04 07:31:58 +00:00
Guillaume Desmottes
32a02b51e1 utils: streamproducer: document forward_eos default value
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/merge_requests/1226>
2023-02-28 09:48:36 +01:00
Sebastian Dröge
f24b38470b Fix various new clippy warnings
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/merge_requests/1203>
2023-01-25 10:18:33 +02:00
Sebastian Dröge
c2e7abd128 utils: streamproducer: Persist ConsumptionLink state when changing producers
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/merge_requests/1189>
2023-01-16 16:16:15 +02:00
Sebastian Dröge
094d74e391 utils: streamproducer: Add ConsumptionLink::appsrc() getter
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/merge_requests/1189>
2023-01-16 14:41:06 +02:00
Sebastian Dröge
0a6ed3c717 utils: streamproducer: Add new ConsumptionLink::disconnected() constructor
This allows constructing a new consumption link from an `appsrc` without
having it connected from the very beginning.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/merge_requests/1189>
2023-01-16 14:41:06 +02:00
Sebastian Dröge
dd284a80ea utils: streamproducer: Add ConsumptionLink::set_discard() to stop forwarding buffers for a while
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/merge_requests/1189>
2023-01-16 14:41:06 +02:00
Sebastian Dröge
a68c37e4eb utils: streamproducer: Remove StreamProducer::forward()
Most applications forget to call `forward()` in the beginning and then
nothing works.

Fixes https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/issues/433

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/merge_requests/1189>
2023-01-16 14:41:06 +02:00
Sebastian Dröge
f8d17555c5 utils: streamproducer: Add #[must_use] attribute to add_consumer()
Simply discarding the result will immediately disconnect it again, which
was likely not intended and can easily lead to bugs.

Fixes https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/issues/432

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/merge_requests/1189>
2023-01-16 14:41:06 +02:00
Sebastian Dröge
f235dc987d Inline various trivial functions
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/merge_requests/1177>
2023-01-11 11:33:54 +02:00
Sebastian Dröge
567ce0a3bf Group and merge imports in all manual code
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/merge_requests/1182>
2023-01-04 13:25:17 +02:00
Guillaume Desmottes
fbceaab941 utils: streamproducer: add API to retrieve last sample from producer
This may be used for example to easily generate thumbnails from video
producers.
2022-07-11 11:32:06 +02:00
Guillaume Desmottes
0e17878bed utils: streamproducer: add API to retrieve pushed and dropped buffers
This may be used by applications to compute statistics about the overall
pipeline health, like the ratio of buffers dropped.
2022-07-11 09:10:52 +02:00
Thibault Saunier
8c69388eff utils: Re export AddConsumerError 2022-05-17 20:19:12 +03:00
Guillaume Desmottes
5349822962 utils/streamproducer: add ConsumptionLink
Having an explicit link object makes it much easier to build complex
producers/consumers dynamics graphs.
It provides helper to switch producers and prevent accidentally keeping
broken links around as they are disconnected on Drop.
2022-05-17 11:04:35 +03:00
Guillaume Desmottes
f68efd0cab utils/streamproducer: add API to not forward eos to consumers
User may want to plug another producer when one is eos, in such case we
don't want to propagate eos to consumers.
2022-05-17 11:04:35 +03:00
Guillaume Desmottes
351f070c8e utils/streamproducer: reset callbacks when removing consumer 2022-05-12 14:56:55 +02:00
Sebastian Dröge
98cc289bcc utils/streamproducer: Add StreamProducer::error() to signal an error message to all consumers 2022-05-12 10:51:56 +03:00
Sebastian Dröge
e263bd8945 utils/streamproducer: Request keyframes without a lock held and also after an appsrc has dropped some data 2022-05-12 10:44:59 +03:00
Sebastian Dröge
d6095900e9 utils/streamproducer: Improve debug output a bit 2022-05-12 10:37:14 +03:00
Sebastian Dröge
e82d388410 utils/streamproducer: Index hashmap by appsrc instance instead of pointer
This behaves the same but requires a little bit less code.
2022-05-12 10:34:11 +03:00
Sebastian Dröge
a51235048d utils/streamproducer: Add StreamProducer::configure_consumer()
This allows configuring an `appsrc` before actually adding it as
consumer at a later time, and can be useful if the pipeline with the
source should be started earlier than adding it to a consumer.

Also use strongly-typed property API for the `appsrc` properties.
2022-05-12 10:34:06 +03:00
Thibault Saunier
f3bba21faa Introduce StreamProducer
Introduce a new `gstreamer-utils` crate where we implement a
`StreamProducer` structure that allows "producing" pipeline (Producers)
pushing their data to 0 or several "consuming" pipelines. The Producer
needs to push their data to an `appsink` which the `StreamProducer` controls
and the "consumer" pipelines need to have an AppSrc which the same
StreamProducer controls.

It allows similare behavior as a `tee` element but with a simpler to
handle addition and removal of "consumers" as well as a total decoupling
of the various consumer, both between each others and the producer
pipeline.

This has simply been extracted from
[webrtcsink](https://github.com/centricular/webrtcsink/blob/main/plugins/src/webrtcsink/utils.rs)
2022-05-11 10:14:54 -04:00