hang is a media-specific library built on top of moq-lite for streaming audio and video with WebCodecs compatibility.
Overview
Whilemoq-lite provides generic pub/sub transport, hang adds media-specific functionality:
- Catalog: JSON track containing codec info and track metadata
- Container: Timestamp + codec bitstream or fragmented MP4
- WebCodecs: Compatible with browser WebCodecs API
hang as similar to HLS/DASH, while moq-lite is like HTTP.
Installation
Add to yourCargo.toml:
Architecture
Catalog
The catalog is a special JSON track that describes available media tracks and their codecs.Catalog Structure
Eachhang broadcast includes a catalog track that contains:
- Track names and types (audio/video)
- Codec information
- Rendition details
- Live updates as tracks change
Producing a Catalog
Consuming a Catalog
Container
The container format defines how media frames are encoded within each track.Container Formats
hang supports two container formats:Legacy Format
A simple format: timestamp followed by codec payload:CMAF Format
Fragmented MP4 (moof + mdat pairs):Complete Example
Relationship with moq-mux
For importing existing media formats (fMP4, HLS, etc.) into hang broadcasts, use the moq-mux crate:WebCodecs Compatibility
The hang format is designed to work seamlessly with the browser WebCodecs API:Error Handling
All operations returnResult<T, hang::Error>:
Resources
- Full API Documentation - Complete reference on docs.rs
- Crates.io - Package page
- Source Code - GitHub repository
- Specification - hang protocol spec
- moq-mux - Import existing media formats
Next Steps
moq-mux
Import media from fMP4, HLS, and more
moq-cli
Publish media from command line
moq-lite
Learn about the transport layer
TypeScript SDK
Browser-side media handling