2021-12-14 18:40:27 +00:00
|
|
|
// Copyright (C) 2019-2021 François Laignel <fengalin@free.fr>
|
2019-11-24 20:35:46 +00:00
|
|
|
//
|
2021-12-14 18:40:27 +00:00
|
|
|
// Take a look at the license at the top of the repository in the LICENSE file.
|
2019-11-24 20:35:46 +00:00
|
|
|
|
2019-12-02 09:30:07 +00:00
|
|
|
//! A `runtime` for the `threadshare` GStreamer plugins framework.
|
|
|
|
//!
|
|
|
|
//! Many `GStreamer` `Element`s internally spawn OS `thread`s. For most applications, this is not an
|
|
|
|
//! issue. However, in applications which process many `Stream`s in parallel, the high number of
|
|
|
|
//! `threads` leads to reduced efficiency due to:
|
|
|
|
//!
|
|
|
|
//! * context switches,
|
|
|
|
//! * scheduler overhead,
|
|
|
|
//! * most of the threads waiting for some resources to be available.
|
|
|
|
//!
|
|
|
|
//! The `threadshare` `runtime` is a framework to build `Element`s for such applications. It
|
|
|
|
//! uses light-weight threading to allow multiple `Element`s share a reduced number of OS `thread`s.
|
|
|
|
//!
|
2019-11-30 18:51:31 +00:00
|
|
|
//! See this [talk] ([slides]) for a presentation of the motivations and principles,
|
|
|
|
//! and this [blog post].
|
2019-12-02 09:30:07 +00:00
|
|
|
//!
|
2021-12-14 18:40:27 +00:00
|
|
|
//! Current implementation uses a custom executor mostly based on the [`smol`] ecosystem.
|
2019-12-02 09:30:07 +00:00
|
|
|
//!
|
|
|
|
//! Most `Element`s implementations should use the high-level features provided by [`PadSrc`] &
|
|
|
|
//! [`PadSink`].
|
|
|
|
//!
|
|
|
|
//! [talk]: https://gstconf.ubicast.tv/videos/when-adding-more-threads-adds-more-problems-thread-sharing-between-elements-in-gstreamer/
|
|
|
|
//! [slides]: https://gstreamer.freedesktop.org/data/events/gstreamer-conference/2018/Sebastian%20Dr%C3%B6ge%20-%20When%20adding%20more%20threads%20adds%20more%20problems:%20Thread-sharing%20between%20elements%20in%20GStreamer.pdf
|
2019-11-30 18:51:31 +00:00
|
|
|
//! [blog post]: https://coaxion.net/blog/2018/04/improving-gstreamer-performance-on-a-high-number-of-network-streams-by-sharing-threads-between-elements-with-rusts-tokio-crate
|
2021-12-14 18:40:27 +00:00
|
|
|
//! [`smol`]: https://github.com/smol-rs/
|
2019-12-02 09:30:07 +00:00
|
|
|
//! [`PadSrc`]: pad/struct.PadSrc.html
|
|
|
|
//! [`PadSink`]: pad/struct.PadSink.html
|
|
|
|
|
2019-11-24 20:35:46 +00:00
|
|
|
pub mod executor;
|
2021-12-14 18:40:27 +00:00
|
|
|
pub use executor::{Async, Context, JoinHandle, SubTaskOutput, Timer};
|
2019-12-02 09:30:07 +00:00
|
|
|
|
|
|
|
pub mod pad;
|
2020-01-06 12:19:11 +00:00
|
|
|
pub use pad::{PadSink, PadSinkRef, PadSinkWeak, PadSrc, PadSrcRef, PadSrcWeak};
|
2019-12-02 09:30:07 +00:00
|
|
|
|
2020-03-05 15:59:13 +00:00
|
|
|
pub mod task;
|
2020-03-26 18:07:25 +00:00
|
|
|
pub use task::{Task, TaskState};
|
2019-12-02 09:30:07 +00:00
|
|
|
|
|
|
|
pub mod prelude {
|
|
|
|
pub use super::pad::{PadSinkHandler, PadSrcHandler};
|
2020-04-20 19:35:06 +00:00
|
|
|
pub use super::task::TaskImpl;
|
2019-12-02 09:30:07 +00:00
|
|
|
}
|
|
|
|
|
2020-01-02 21:32:52 +00:00
|
|
|
pub mod time;
|
2021-12-14 18:40:27 +00:00
|
|
|
pub use time::{delay_for, delay_for_at_least};
|
2020-01-02 21:32:52 +00:00
|
|
|
|
2020-11-22 14:24:55 +00:00
|
|
|
use once_cell::sync::Lazy;
|
2019-12-02 09:30:07 +00:00
|
|
|
|
2020-11-22 14:24:55 +00:00
|
|
|
static RUNTIME_CAT: Lazy<gst::DebugCategory> = Lazy::new(|| {
|
|
|
|
gst::DebugCategory::new(
|
2019-12-02 09:30:07 +00:00
|
|
|
"ts-runtime",
|
|
|
|
gst::DebugColorFlags::empty(),
|
|
|
|
Some("Thread-sharing Runtime"),
|
2020-11-22 14:24:55 +00:00
|
|
|
)
|
|
|
|
});
|