moq-lite

Crates.iomoq-lite
lib.rsmoq-lite
version0.7.1
created_at2025-03-23 19:15:44.36672+00
updated_at2025-09-22 21:32:33.439742+00
descriptionMedia over QUIC - Transport (Lite)
homepage
repositoryhttps://github.com/kixelated/moq
max_upload_size
id1602974
size183,464
(kixelated)

documentation

README

Documentation Crates.io License: MIT

moq-lite

A Rust implementation of the Media over QUIC transport.

This crate provides the core networking layer, implementing the moq-lite specification. Live media is built on top of this layer using something like hang.

  • Broadcasts: Discoverable collections of tracks.
  • Tracks: Named streams of data, split into groups.
  • Groups: A sequential collection of frames, usually starting with a keyframe.
  • Frame: A timed chunk of data.

Example - Chat track

	// Optional: Use moq_native to make a QUIC client.
    let config = moq_native::ClientConfig::default(); // See documentation
	let client = moq_native::Client::new(config);

	// For local development, use: http://localhost:4443/anon
	// The "anon" path is usually configured to bypass authentication; be careful!
	let url = url::Url::parse("https://relay.moq.dev/anon").unwrap();

	// Establish a WebTransport/QUIC connection.
	let connection = client.connect(url).await?;

	// Perform the MoQ handshake.
	let mut session = moq_lite::Session::connect(connection).await?;

	// Create a broadcast.
	// A broadcast is a collection of tracks, but in this example there's just one.
	let broadcast = moq_lite::BroadcastProducer::new();

	// Create a track that we'll insert into the broadcast.
	// A track is a series of groups representing a live stream.
	let track = broadcast.create(moq_lite::Track {
		name: "chat".to_string(),
		priority: 0,
	});

	// Create a group.
	// Each group is independent and the newest group(s) will be prioritized.
	let group = track.append();

	// Write frames to the group.
	// Each frame is dependent on the previous frame, so older frames are prioritized.
	group.append(b"Hello");
	group.append(b"World");

	// Finally, publish the broadcast to the session.
	// You can provide a broadcast path which gets appended to the URL.
	session.publish("my-broadcast", broadcast.consume());

	// NOTE: You can create multiple consumer instances of any `XxxProducer`
	// Each which will receive a (ref-counted) copy of the data.
	let _broadcast = broadcast.consume();
	let _track = track.consume();
	let _group = group.consume();
Commit count: 645

cargo fmt