Skip to main content

Crate g2g_core

Crate g2g_core 

Source
Expand description

Core types for the glass2glass multimedia framework.

This crate is no_std. It defines the data carriers (Frame, PipelinePacket), the memory domain model, capability negotiation types, the AsyncElement execution trait, the pipeline clock, the link backpressure policy, and the error enum. It contains no I/O and no executor.

The default build enables alloc. Building --no-default-features yields the heap-free MCU / safety subset: it links no allocator and carries only the data-plane types (Frame, Caps, System/Foreign memory, the const-generic StaticLendRing, the clock / time newtypes). The dynamic graph, caps solver, parse_launch, the dyn element traits, and the tooling (conformance, dot, copy plan, wire codec) all live behind the alloc feature.

See DESIGN.md for the full specification.

Re-exports§

pub use aggregator::InputAggregator;
pub use caps::pcm_formats;
pub use caps::pcm_from_gst_format;
pub use caps::pcm_gst_format;
pub use caps::AudioFormat;
pub use caps::ByteStreamEncoding;
pub use caps::Caps;
pub use caps::ClosedCaptionFormat;
pub use caps::Dim;
pub use caps::Interlace;
pub use caps::PassthroughFields;
pub use caps::Rate;
pub use caps::RawVideoFormat;
pub use caps::SubPictureFormat;
pub use caps::TensorDType;
pub use caps::TensorLayout;
pub use caps::TensorShape;
pub use caps::TextFormat;
pub use caps::VideoCodec;
pub use caps::ANY_CHANNELS;
pub use caps::ANY_SAMPLE_RATE;
pub use caps::PCM_FORMATS;
pub use channels::ChannelLayout;
pub use channels::ChannelPosition;
pub use caps::CapsSet;
pub use caps_transform::AudioShape;
pub use caps_transform::CapsTransform;
pub use caps_transform::FieldTransform;
pub use caps_transform::RawVideoShape;
pub use chapter::Chapter;
pub use clock::MonotonicClock;
pub use clock::elect_clock;
pub use clock::AsyncClock;
pub use clock::ClockCandidate;
pub use clock::ClockPriority;
pub use clock::ClockSync;
pub use clock::DynAsyncClock;
pub use clock::ElectedClock;
pub use clock::PipelineClock;
pub use clock::DriftClock;
pub use clock::DriftObservation;
pub use conformance::ConformanceDimension;
pub use conformance::ConformanceReport;
pub use conformance::Evidence;
pub use conformance::MaturityLevel;
pub use conformance::MaturityRecord;
pub use controller::ArmController;
pub use controller::ControlFault;
pub use controller::ControlProgram;
pub use controller::ControlReason;
pub use controller::ControlSource;
pub use controller::ControlTarget;
pub use copyplan::classify as classify_transfer;
pub use copyplan::CopyBudgetError;
pub use copyplan::CopyPlan;
pub use copyplan::CopyPolicy;
pub use copyplan::EdgeProfile;
pub use copyplan::Hop;
pub use copyplan::NodeProfile;
pub use copyplan::Transfer;
pub use copyplan::TransferKind;
pub use dot::DotAnnotations;
pub use element::AsyncElement;
pub use element::ConfigureOutcome;
pub use element::ElementBound;
pub use element::OutputSink;
pub use element::OutputSinkExt;
pub use element::PresentationStats;
pub use element::PushFuture;
pub use element::PushOutcome;
pub use element::QosMessage;
pub use element::Reconfigure;
pub use error::G2gError;
pub use error::HardwareError;
pub use format_element::legacy_sink_constraint;
pub use format_element::legacy_transform_constraint;
pub use format_element::CapsConstraint;
pub use format_element::CapsPreferences;
pub use format_element::FormatElement;
pub use frame::Frame;
pub use frame::FrameTiming;
pub use frame::PipelinePacket;
pub use graph::Bin;
pub use graph::BinInstance;
pub use graph::Demux;
pub use graph::Edge;
pub use graph::Graph;
pub use graph::GraphError;
pub use graph::Muxer;
pub use graph::NodeId;
pub use graph::NodeIdOffset;
pub use graph::NodeKind;
pub use graph::PadDir;
pub use graph::PadId;
pub use graph::Tee;
pub use graph::ValidatedGraph;
pub use link::LinkPolicy;
pub use mediaclock::MediaClock;
pub use meta::FrameMetaSet;
pub use meta::blob_decoder;
pub use meta::decode_blob;
pub use meta::AnalyticsMeta;
pub use meta::AnalyticsNode;
pub use meta::BBox;
pub use meta::Blob;
pub use meta::BlobDecoder;
pub use meta::BlobMeta;
pub use meta::CaptionMeta;
pub use meta::CaptionTriple;
pub use meta::Chromaticity;
pub use meta::Classification;
pub use meta::DecodedBlob;
pub use meta::FrameMeta;
pub use meta::HdrStaticMeta;
pub use meta::Mask;
pub use meta::MasteringDisplay;
pub use meta::NamedTensor;
pub use meta::ObjectDetection;
pub use meta::Propagation;
pub use meta::Relation;
pub use meta::RelationKind;
pub use meta::Roi;
pub use meta::Segmentation;
pub use meta::TensorMeta;
pub use meta::TimecodeMeta;
pub use meta::Tracking;
pub use meta::Transform;
pub use meta::BLOB_DECODERS;
pub use property::takes_undeclared_properties;
pub use property::ElementMetadata;
pub use property::PropError;
pub use property::PropFlags;
pub use property::PropKind;
pub use property::PropValue;
pub use property::PropertySpec;
pub use property::ValueError;
pub use property::UNDECLARED_PROPERTIES;
pub use ptp::ExchangeResult;
pub use ptp::PtpClock;
pub use ptp::PtpHeader;
pub use ptp::PtpMessageType;
pub use ptp::PtpServo;
pub use ptp::PtpSlave;
pub use ptp::PtpState;
pub use ptp::SlaveAction;
pub use memory::DomainSet;
pub use memory::MemoryDomain;
pub use memory::MemoryDomainKind;
pub use memory::SystemSlice;
pub use memory::CudaKeepAlive;
pub use memory::CvPixelBufferKeepAlive;
pub use memory::D3D11KeepAlive;
pub use memory::OwnedCudaBuffer;
pub use memory::OwnedCvPixelBuffer;
pub use memory::OwnedD3D11Texture;
pub use memory::OwnedDmaBuf;
pub use memory::OwnedVulkanTexture;
pub use memory::OwnedWebGPUBuffer;
pub use memory::OwnedWebGPUExternalTexture;
pub use memory::OwnedWgpuBuffer;
pub use memory::OwnedWgpuTexture;
pub use memory::SyncFd;
pub use memory::SystemView;
pub use memory::WebGPUKeepAlive;
pub use memory::WgpuBufferKeepAlive;
pub use memory::WgpuKeepAlive;
pub use metrics::LatencyHistogram;
pub use metrics::LatencySnapshot;
pub use query::AllocationParams;
pub use query::LatencyReport;
pub use rtp::RtpHeader;
pub use rtp::RtpParsed;
pub use rtp::RTP_HEADER_LEN;
pub use segment::Seek;
pub use segment::SeekFlags;
pub use segment::SeekType;
pub use segment::Segment;
pub use spsc::Overrun;
pub use spsc::SpscFrameRing;
pub use spsc::SpscCaptureSrc;
pub use state::PipelineState;
pub use state::StateChangeReturn;
pub use staticelem::drive_ready;
pub use staticelem::run_source_sink;
pub use staticelem::run_source_transform_sink;
pub use staticelem::run_sources_fanin_sink;
pub use staticelem::step_source_sink;
pub use staticelem::Chain;
pub use staticelem::SinkChain;
pub use staticelem::SourceChain;
pub use staticelem::StaticFanIn2;
pub use staticelem::StaticSink;
pub use staticelem::StaticSource;
pub use staticelem::StaticTransform;
pub use staticelem::Step;
pub use staticpool::RingSlot;
pub use staticpool::StaticAcquire;
pub use staticpool::StaticBufferPool;
pub use staticpool::StaticLendRing;
pub use staticpool::StaticPooled;
pub use stream::Stream;
pub use stream::StreamCollection;
pub use stream::StreamType;
pub use supervise::run_supervised;
pub use supervise::step_supervised;
pub use supervise::FaultPolicy;
pub use supervise::NoWatchdog;
pub use supervise::Recover;
pub use supervise::Recovery;
pub use supervise::RetryThenReset;
pub use supervise::RunOutcome;
pub use supervise::SkipBounded;
pub use supervise::Supervised;
pub use supervise::SupervisorReport;
pub use supervise::Watchdog;
pub use supervise::MAX_ATTEMPTS;
pub use tag::resolve_tags;
pub use tag::split_tags;
pub use tag::Tag;
pub use tag::TagList;
pub use tensor::TensorView;
pub use tensor::MAX_TENSOR_RANK;
pub use time::RefNs;
pub use time::RtpTs;
pub use time::TaiNs;
pub use wire::decode_packet;
pub use wire::encode_packet;
pub use wire::raw_format_from_u8;
pub use wire::raw_format_to_u8;
pub use wire::WireError;
pub use wire::WIRE_VERSION;
pub use pool::BufferPool;
pub use pool::PooledBuffer;
pub use bus::Bus;
pub use bus::BusHandle;
pub use bus::BusMessage;
pub use qos::QosTracker;
pub use pacing::Pace;
pub use pacing::PresentationPacer;
pub use pacing::MAX_LATENESS_PROPERTY;
pub use pacing::PACING_PROPERTIES;
pub use pacing::QOS_INTERVAL_PROPERTY;
pub use runtime::CapsConflict;
pub use runtime::LinkInterceptor;
pub use runtime::NegotiationFailure;
pub use runtime::ProbeAction;
pub use runtime::ProbeSlot;
pub use pad_template::PadCaps;
pub use pad_template::PadDirection;
pub use pad_template::PadTemplate;
pub use pad_template::PadTemplates;
pub use fanout::DuplexInbound;
pub use fanout::Gate;
pub use fanout::GateHandle;
pub use fanout::Merger;
pub use fanout::MergerHandle;
pub use fanout::MultiDuplexSession;
pub use fanout::MultiInputElement;
pub use fanout::MultiOutputElement;
pub use fanout::MultiOutputSink;
pub use fanout::MultiOutputSinkExt;
pub use fanout::MultiOutputSource;
pub use fanout::MultiSenderSink;
pub use fanout::PushToFuture;
pub use fanout::ReverseChannel;
pub use fanout::Router;
pub use fanout::RouterHandle;
pub use slot::ElementSlot;
pub use slot::SwapHandle;

Modules§

aggregator
Per-input collector for MultiInputElement aggregators (M199).
bus
Pipeline message bus (M11).
caps
caps_parse
gst-launch caps-string parsing: the inverse of Caps::to_gst_string.
caps_transform
M837: declarative forward derivation for caps transforms (DESIGN.md §4.13.1).
channels
Speaker channel positions and layouts for multichannel PCM. A ChannelLayout is a bitmask in the WAV / ffmpeg bit order, and that bit order (ascending) is also the interleave order of the samples, so a layout fully describes which speaker each interleaved channel index feeds.
chapter
Container chapters, the table of contents a file declares (the GStreamer GstToc analog).
clock
conformance
Conformance vocabulary + derived maturity (M614).
controller
Animated properties (M882), the gst-controller analog: a property’s value becomes a function of stream time instead of a constant set once at build time. A ControlSource is a keyframed curve, a ControlProgram binds curves to one node’s property names, and the runner samples the bindings at each frame’s PTS before handing that frame to the element.
copyplan
Copy / allocation plan (M613): a static, pre-run analysis of the memory-domain path a frame takes through a negotiated graph.
dot
Graphviz DOT rendering for a pipeline graph (developer tooling): the GST_DEBUG_DUMP_DOT_DIR analog. ValidatedGraph::to_dot turns a graph, plus the solver’s per-edge negotiated Caps and (when known) each link’s memory domain, into a digraph { .. } a developer can render with dot -Tsvg. Self-contained and no_std + alloc: it only formats Strings, no I/O, so it builds on every target the core does.
element
error
fanout
Fan-out primitives for the dynamic graph layer (DESIGN.md §4.8.4).
format_element
M16 step 2 (DESIGN.md §4.13.1): negotiation-time element surface.
frame
graph
DAG pipeline graph + validation (DESIGN_TODO “DAG runner” D1).
link
log
Element-granular logging facade (M179), the GST_DEBUG analog.
mediaclock
ST 2110-10 media clock: the mapping between a PTP/TAI time and an RTP timestamp, the piece that ties RTP media transport to the pipeline’s PTP clock (M595).
memory
meta
Per-frame metadata system: typed blobs that travel with a Frame (the GstMeta / GstAnalyticsRelationMeta analog), and the AnalyticsMeta relation graph for ML detection / classification / tracking results.
metrics
Lightweight metrics primitives for glass-to-glass observability.
pacing
Presentation pacing for synchronizing sinks: the PTS -> clock deadline, the play-edge / first-frame anchor, and the QoS late-drop verdict.
pad_template
Pad templates: declarative, pre-instantiation metadata describing the caps an element type can accept or produce.
pool
Buffer pools.
property
Runtime element properties (M104): a name/value bag layered over the compile-time with_* builders, the GObject-property analog.
ptp
PTP (IEEE 1588 / SMPTE ST 2059-2) clock servo, phase A of the PtpClock milestone.
qos
Sink-side QoS accounting: the late-frame drop rule and the BusMessage::Qos reports that follow from it.
query
Pipeline queries (M12).
rtp
RFC 3550 RTP fixed header (M643): the 12-byte wire header every RTP packetizer in the workspace emits, defined once. Pure const fn byte-building, part of the heap-free subset, so the MCU packet sink and the std packetizers in g2g-plugins (H.264, the ST 2110 essences) share one implementation instead of five hand-rolled copies.
runtime
Minimal async pipeline runtime (M1).
segment
Seek requests and the playback segment (M79).
slot
Lock-free atomic-swap container for dynamically replaceable elements.
spsc
Single-producer / single-consumer capture ring: the heap-free hand-off across the interrupt boundary a real MCU capture needs. A DMA-completion (or timer) ISR produces frames into the ring in interrupt context; the pipeline, in the main/task context, consumes them, concurrently and lock-free. This is the piece the synchronous StaticLendRing lend model (single cooperative context) does not cover: there the same task fills and drains; here the producer and consumer run in genuinely different execution contexts.
state
Pipeline lifecycle states (M76).
staticelem
Static (heap-free) element model for the no-alloc / MCU path (Phase 2 of the alloc-optional core): the generic twin of the object-safe AsyncElement / OutputSink, which box a future per frame (element.rs, the honest per-frame allocation boundary pinned by M616). Elements here are concrete types wired by direct calls and driven by a const-arity runner, so a whole pipeline monomorphizes to unboxed async state machines: no dyn, no Box, no allocation. This is the M620 concrete-chain pattern promoted to an API.
staticpool
Strict no-heap buffer pool for no_std RTOS targets that cannot tolerate alloc, the counterpart of crate::pool::BufferPool (which is Arc/Vec-backed). Sized at construction with a fixed [T; N]; acquiring moves a buffer out and the RAII handle returns it on drop. Pure core: no alloc, no Arc, no OS.
stream
Stream discovery: the available elementary streams of a container (the GStreamer GstStreamCollection analog, the data model playbin is built on).
supervise
Runtime fault recovery for the static heap-free MCU path: a supervisor that wraps a source -> sink chain and turns a returned fault (G2gError) into a bounded, deterministic recovery action instead of aborting the pipeline.
tag
Stream metadata tags (the GStreamer GstTagList analog).
tensor
Strided tensor view over a byte buffer: the zero-copy substrate for raw numeric media (M180). A TensorView describes how to read a flat [u8] backing as an n-dimensional array, by NumPy-style byte strides plus a byte offset, so a layout-preserving transform (flip, transpose, crop, channel reorder) is expressed as a new view over the same bytes rather than a copy. The bytes themselves live in a MemoryDomain, eg the shared-CPU SystemView; this type is pure metadata.
time
Boundary-scoped time newtypes (M618): distinct types at the clock / PTP / RTP seam, where three different “just an integer” times meet and are easy to mix up.
wire
Wire serialization of a PipelinePacket (M551, the distributed-graph primitive).

Macros§

g2g_debug
DEBUG-level log about a LogSource.
g2g_error
ERROR-level log about a LogSource.
g2g_fixme
FIXME-level log about a LogSource.
g2g_info
INFO-level log about a LogSource.
g2g_log
LOG-level (per-buffer) log about a LogSource.
g2g_log_at
Log at level about a LogSource, checking the category threshold before formatting the message. Prefer the level-specific macros.
g2g_log_fields
Log at level with structured fields plus the formatted message, so a sink can render or ship the values without re-parsing the line: g2g_log_fields!(LogLevel::Info, self, ["width" => w, "height" => h], "configured {w}x{h}"). Field values are anything convertible into a LogValue (strings, integers, floats, bools).
g2g_trace
TRACE-level (most verbose) log about a LogSource.
g2g_warn
WARN-level log about a LogSource.

Constants§

ABI_VERSION
The ABI compatibility tag for dynamically loaded (dlopened) plugins.