1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
//! Host gst-python-ml elements as first-class glass2glass elements (M198).
//!
//! Experimental (Tier 3 in `STABILITY.md`): no stability promise.
//!
//! gst-python-ml factored its ML logic away from GStreamer: the inference
//! `tasks/`, the engine `MLEngineMixin`, and the per-frame work all run with no
//! framework types, behind three seams selected by the `PYML_BACKEND` env var:
//! `FrameIO` (read/write/append-blob a buffer), `AnalyticsBackend` (attach
//! detection metadata), and the element base classes. Today only a `gst`
//! backend exists. This crate is the g2g host those seams target: it embeds
//! CPython in the g2g process, exposes a native `g2g` module that backs
//! `FrameIO` / `AnalyticsBackend` against the live Rust [`Frame`], and wraps a
//! hosted element instance in a g2g [`AsyncElement`] so it negotiates caps and
//! flows frames like any other node.
//!
//! Build layers:
//! - **default (`std`)**: the [`PyTransform`] shell and the pixel-format
//! mapping ([`format`]) compile. Caps negotiation works; the per-frame Python
//! call returns [`G2gError::UnsupportedDomain`] because there is no
//! interpreter. This keeps the crate in `cargo check --workspace` without
//! libpython.
//! - **`python`**: pulls pyo3 + numpy, embeds CPython, and runs the hosted
//! element for real. OS-coupled, off the no_std / RTOS baseline.
//!
//! Two zero-copy frame paths reach the hosted element: System memory over the
//! Python buffer protocol (`g2g_process`), and a GPU-resident CUDA frame over
//! `__cuda_array_interface__` / `__dlpack__`, one `g2g.CudaPlane` per NV12 plane
//! handed to `g2g_process_cuda` (or its batch and produce siblings). The `host`
//! and `cuda_plane` modules carry the contracts, the plane layout, and the
//! CUDA-context caveat.
//!
//! This crate links `std` unconditionally (embedding CPython is the most
//! OS-coupled thing in the tree). The `std` feature only forwards to
//! `g2g-core/std`; it is not a no_std gate on this crate.
pub use PyAggregator;
pub use PyTransform;
pub use PySource;
/// Register the hosted Python elements as `gst-launch` / autoplug factories on
/// `registry`, so they are instantiable by name like any built-in:
/// - `pyelement module=... class=... draw-label=...` — a transform;
/// - `pysrc module=... class=... format=... width=... height=... framerate=...
/// num-buffers=...` — a source;
/// - `pyaggregator module=... class=... draw-label=...` — an N-in/1-out batching
/// muxer (its input count comes from link degree).
///
/// The parser default-constructs each and applies its `key=value` properties via
/// the property system, then negotiation + `configure_pipeline` spawn the worker.
/// Call after [`g2g_plugins::default_registry`] (or any `Registry`). Building the
/// per-frame path still needs the `python` feature.
pub use init_host;