streamkit_core/lib.rs
1// SPDX-FileCopyrightText: © 2025 StreamKit Contributors
2//
3// SPDX-License-Identifier: MPL-2.0
4
5//! StreamKit Core - Fundamental traits and data structures for real-time media processing.
6//!
7//! This crate defines the core abstractions for building StreamKit pipelines:
8//!
9//! ## Core Modules
10//!
11//! - [`types`]: Core data types (Packet, AudioFrame, PacketType, etc.)
12//! - [`node`]: ProcessorNode trait and execution context
13//! - [`registry`]: Node factory and discovery system
14//! - [`pins`]: Pin system for graph validation and type checking
15//! - [`state`]: Node state machine and lifecycle tracking
16//! - [`stats`]: Node statistics collection and reporting
17//! - [`telemetry`]: Telemetry event emission for observability
18//! - [`control`]: Control messages for node and engine management
19//! - [`error`]: Error types and handling
20//! - [`resource_manager`]: Shared resource management (ML models, GPU contexts)
21//! - [`packet_meta`]: Packet type metadata and compatibility checking
22//! - [`moq_gateway`]: MoQ WebTransport routing infrastructure
23//! - [`helpers`]: Utility functions for configuration and packet processing
24//!
25//! ## Quick Start
26//!
27//! ```ignore
28//! use streamkit_core::node::{ProcessorNode, NodeContext};
29//! use streamkit_core::types::{Packet, AudioFrame};
30//! use streamkit_core::pins::{InputPin, OutputPin};
31//! use streamkit_core::registry::NodeRegistry;
32//!
33//! // Define a custom node
34//! struct GainNode { gain: f32 }
35//!
36//! #[async_trait]
37//! impl ProcessorNode for GainNode {
38//! fn input_pins(&self) -> Vec<InputPin> { /* ... */ }
39//! fn output_pins(&self) -> Vec<OutputPin> { /* ... */ }
40//! async fn run(self: Box<Self>, ctx: NodeContext) { /* ... */ }
41//! }
42//!
43//! // Register with the factory
44//! let mut registry = NodeRegistry::new();
45//! registry.register_static(/* ... */);
46//! ```
47
48// Re-export async_trait for use in node implementations
49pub use async_trait::async_trait;
50
51// Module declarations
52pub mod control;
53pub mod error;
54pub mod frame_pool;
55pub mod helpers;
56pub mod moq_gateway;
57pub mod node;
58pub mod node_config;
59pub mod packet_meta;
60pub mod pins;
61pub mod registry;
62pub mod resource_manager;
63pub mod state;
64pub mod stats;
65pub mod telemetry;
66pub mod types;
67
68// Convenience re-exports for commonly used types
69// These are the most frequently used types in node implementations
70
71// Error handling
72pub use error::StreamKitError;
73
74// Core node abstractions
75pub use node::{
76 InitContext, NodeContext, OutputSendError, OutputSender, ProcessorNode, RoutedPacketMessage,
77};
78
79// Registry and factory
80pub use registry::{NodeDefinition, NodeRegistry};
81
82// Resource management
83pub use resource_manager::{Resource, ResourceError, ResourceKey, ResourceManager, ResourcePolicy};
84
85// State tracking
86pub use state::{NodeState, NodeStateUpdate, StopReason};
87
88// Statistics
89pub use stats::{NodeStats, NodeStatsUpdate};
90
91// Telemetry
92pub use telemetry::{TelemetryConfig, TelemetryEmitter, TelemetryEvent};
93
94// Pin definitions
95pub use pins::{InputPin, OutputPin, PinCardinality};
96
97// Helper modules (for convenience, maintaining backward compatibility)
98pub use helpers::{config_helpers, packet_helpers};
99pub use state::state_helpers;
100pub use telemetry::telemetry_helpers;
101
102// Frame pooling (optional hot-path optimization)
103pub use frame_pool::{AudioFramePool, FramePool, PooledFrameData, PooledSamples};
104
105// Node buffer configuration
106pub use node_config::{
107 get_codec_channel_capacity, get_demuxer_buffer_size, get_moq_peer_channel_capacity,
108 get_stream_channel_capacity, set_node_buffer_config, NodeBufferConfig,
109};