Skip to main content

animacamos_core/
lib.rs

1//! # animacamos-core
2//!
3//! Platform-neutral core primitives for real-time video / camera applications.
4//!
5//! This crate defines the **fundamental contract** shared by any application
6//! that captures, transports, or outputs video frames in real time:
7//!
8//! - [`Session`] — a logical video session with a lifecycle.
9//! - [`Device`] — a source or sink device descriptor.
10//! - [`VideoFormat`] — width / height / pixel format / frame rate.
11//! - [`VideoFrame`] — a single decoded frame + timing + sequence.
12//! - [`FrameHub`] — a low-latency, latest-frame-wins fan-out for frames.
13//! - [`CameraOutput`] — the trait a platform backend implements.
14//! - [`CoreEvent`] / [`EventBus`] — a tiny event system.
15//! - [`CoreError`] — the public error type.
16//!
17//! The core is **deliberately agnostic**: it has no dependency on WebRTC,
18//! signaling, Tauri, a UI framework, a specific OS, or any concrete virtual
19//! camera implementation. It only defines the contract.
20//!
21//! ## Example
22//!
23//! ```rust
24//! use animacamos_core::{Session, VideoFormat, PixelFormat, FrameHub, VideoFrame};
25//!
26//! let mut session = Session::new();
27//! session.connect().unwrap();
28//! assert_eq!(session.state(), animacamos_core::SessionState::Connecting);
29//!
30//! let hub = FrameHub::new();
31//! let fmt = VideoFormat::new(1920, 1080, PixelFormat::I420, 30).unwrap();
32//! let frame = VideoFrame::new(fmt, vec![0u8; 1920 * 1080 * 3 / 2], 0).unwrap();
33//! hub.publish(frame);
34//! ```
35
36#![forbid(unsafe_code)]
37#![warn(missing_docs, missing_debug_implementations, rust_2018_idioms)]
38
39pub mod device;
40pub mod error;
41pub mod events;
42pub mod format;
43pub mod frame;
44pub mod hub;
45pub mod output;
46pub mod session;
47
48pub use device::{Device, DeviceKind, DeviceMetadata};
49pub use error::{CoreError, Result};
50pub use events::{CoreEvent, EventBus, EventSubscription};
51pub use format::{PixelFormat, VideoFormat};
52pub use frame::VideoFrame;
53pub use hub::{FrameHub, FrameHubStats};
54pub use output::{CameraCapabilities, CameraOutput, CameraOutputStatus, FrameCounters};
55pub use session::{Session, SessionId, SessionState};
56
57/// Library version as a static string.
58pub const VERSION: &str = env!("CARGO_PKG_VERSION");