Cargo layout (#36)

Combine moq-transport and moq-media into one crate again. 

I might regret this because moq is taken on crates.io.
This commit is contained in:
kixelated 2023-06-16 20:36:07 -07:00 committed by GitHub
parent 4c04fbf2b8
commit 3daa2f4812
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
18 changed files with 291 additions and 206 deletions

266
Cargo.lock generated
View File

@ -47,7 +47,7 @@ version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5ca11d4be1bab0c8bc8734a9aa7bf4ee8316d462a08c6ac5052f888fef5b494b" checksum = "5ca11d4be1bab0c8bc8734a9aa7bf4ee8316d462a08c6ac5052f888fef5b494b"
dependencies = [ dependencies = [
"windows-sys", "windows-sys 0.48.0",
] ]
[[package]] [[package]]
@ -57,7 +57,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "180abfa45703aebe0093f79badacc01b8fd4ea2e35118747e5811127f926e188" checksum = "180abfa45703aebe0093f79badacc01b8fd4ea2e35118747e5811127f926e188"
dependencies = [ dependencies = [
"anstyle", "anstyle",
"windows-sys", "windows-sys 0.48.0",
] ]
[[package]] [[package]]
@ -199,6 +199,22 @@ version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "acbf1af155f9b9ef647e42cdc158db4b64a1b61f743629225fde6f3e0be2a7c7" checksum = "acbf1af155f9b9ef647e42cdc158db4b64a1b61f743629225fde6f3e0be2a7c7"
[[package]]
name = "core-foundation"
version = "0.9.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "194a7a9e6de53fa55116934067c844d9d749312f75c6f6d0980e8c252f8c2146"
dependencies = [
"core-foundation-sys",
"libc",
]
[[package]]
name = "core-foundation-sys"
version = "0.8.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e496a50fda8aacccc86d7529e2c1e0892dbd0f898a6b5645b5561b89c3210efa"
[[package]] [[package]]
name = "cpufeatures" name = "cpufeatures"
version = "0.2.8" version = "0.2.8"
@ -258,7 +274,7 @@ checksum = "4bcfec3a70f97c962c307b2d2c56e358cf1d00b558d74262b5f929ee8cc7e73a"
dependencies = [ dependencies = [
"errno-dragonfly", "errno-dragonfly",
"libc", "libc",
"windows-sys", "windows-sys 0.48.0",
] ]
[[package]] [[package]]
@ -424,20 +440,6 @@ dependencies = [
"tracing", "tracing",
] ]
[[package]]
name = "h3"
version = "0.0.2"
source = "git+https://github.com/security-union/h3?branch=add-webtransport#fa956e0d44e66c04545741908fcb3690b0890be6"
dependencies = [
"bytes",
"fastrand",
"futures-util",
"http",
"pin-project-lite",
"tokio",
"tracing",
]
[[package]] [[package]]
name = "h3" name = "h3"
version = "0.0.2" version = "0.0.2"
@ -452,20 +454,6 @@ dependencies = [
"tracing", "tracing",
] ]
[[package]]
name = "h3-quinn"
version = "0.0.2"
source = "git+https://github.com/security-union/h3?branch=add-webtransport#fa956e0d44e66c04545741908fcb3690b0890be6"
dependencies = [
"bytes",
"futures",
"h3 0.0.2 (git+https://github.com/security-union/h3?branch=add-webtransport)",
"quinn",
"quinn-proto",
"tokio",
"tokio-util",
]
[[package]] [[package]]
name = "h3-quinn" name = "h3-quinn"
version = "0.0.3" version = "0.0.3"
@ -473,27 +461,13 @@ source = "git+https://github.com/hyperium/h3?branch=master#3ef7c1a37b635e8446322
dependencies = [ dependencies = [
"bytes", "bytes",
"futures", "futures",
"h3 0.0.2 (git+https://github.com/hyperium/h3?branch=master)", "h3",
"quinn", "quinn",
"quinn-proto", "quinn-proto",
"tokio", "tokio",
"tokio-util", "tokio-util",
] ]
[[package]]
name = "h3-webtransport"
version = "0.1.0"
source = "git+https://github.com/security-union/h3?branch=add-webtransport#fa956e0d44e66c04545741908fcb3690b0890be6"
dependencies = [
"bytes",
"futures-util",
"h3 0.0.2 (git+https://github.com/security-union/h3?branch=add-webtransport)",
"http",
"pin-project-lite",
"tokio",
"tracing",
]
[[package]] [[package]]
name = "h3-webtransport" name = "h3-webtransport"
version = "0.1.0" version = "0.1.0"
@ -501,7 +475,7 @@ source = "git+https://github.com/hyperium/h3?branch=master#3ef7c1a37b635e8446322
dependencies = [ dependencies = [
"bytes", "bytes",
"futures-util", "futures-util",
"h3 0.0.2 (git+https://github.com/hyperium/h3?branch=master)", "h3",
"http", "http",
"pin-project-lite", "pin-project-lite",
"tokio", "tokio",
@ -676,7 +650,7 @@ checksum = "eae7b9aee968036d54dce06cebaefd919e4472e753296daccd6d344e3e2df0c2"
dependencies = [ dependencies = [
"hermit-abi 0.3.1", "hermit-abi 0.3.1",
"libc", "libc",
"windows-sys", "windows-sys 0.48.0",
] ]
[[package]] [[package]]
@ -688,7 +662,7 @@ dependencies = [
"hermit-abi 0.3.1", "hermit-abi 0.3.1",
"io-lifetimes", "io-lifetimes",
"rustix", "rustix",
"windows-sys", "windows-sys 0.48.0",
] ]
[[package]] [[package]]
@ -764,7 +738,26 @@ checksum = "927a765cd3fc26206e66b296465fa9d3e5ab003e651c1b3c060e7956d96b19d2"
dependencies = [ dependencies = [
"libc", "libc",
"wasi", "wasi",
"windows-sys", "windows-sys 0.48.0",
]
[[package]]
name = "moq-demo"
version = "0.1.0"
dependencies = [
"anyhow",
"clap",
"env_logger",
"hex",
"log",
"moq-transport",
"moq-warp",
"quinn",
"ring",
"rustls 0.21.2",
"rustls-pemfile",
"tokio",
"warp",
] ]
[[package]] [[package]]
@ -774,19 +767,12 @@ dependencies = [
"anyhow", "anyhow",
"async-trait", "async-trait",
"bytes", "bytes",
"clap", "h3",
"env_logger", "h3-quinn",
"futures", "h3-webtransport",
"h3 0.0.2 (git+https://github.com/security-union/h3?branch=add-webtransport)",
"h3-quinn 0.0.2",
"h3-webtransport 0.1.0 (git+https://github.com/security-union/h3?branch=add-webtransport)",
"http", "http",
"log", "log",
"quinn", "quinn",
"quinn-proto",
"ring",
"rustls 0.21.2",
"rustls-pemfile",
"thiserror", "thiserror",
"tokio", "tokio",
] ]
@ -796,29 +782,9 @@ name = "moq-warp"
version = "0.1.0" version = "0.1.0"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"bytes",
"clap",
"env_logger",
"futures",
"h3 0.0.2 (git+https://github.com/hyperium/h3?branch=master)",
"h3-quinn 0.0.3",
"h3-webtransport 0.1.0 (git+https://github.com/hyperium/h3?branch=master)",
"hex",
"http",
"log",
"moq-transport", "moq-transport",
"mp4", "mp4",
"paste",
"quinn",
"quinn-proto",
"ring",
"rustls 0.21.2",
"rustls-pemfile",
"serde",
"serde_json",
"thiserror",
"tokio", "tokio",
"warp",
] ]
[[package]] [[package]]
@ -912,6 +878,12 @@ version = "1.18.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d" checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d"
[[package]]
name = "openssl-probe"
version = "0.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf"
[[package]] [[package]]
name = "parking_lot" name = "parking_lot"
version = "0.12.1" version = "0.12.1"
@ -935,12 +907,6 @@ dependencies = [
"windows-targets", "windows-targets",
] ]
[[package]]
name = "paste"
version = "1.0.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9f746c4065a8fa3fe23974dd82f15431cc8d40779821001404d10d2e79ca7d79"
[[package]] [[package]]
name = "percent-encoding" name = "percent-encoding"
version = "2.3.0" version = "2.3.0"
@ -1023,6 +989,7 @@ dependencies = [
"ring", "ring",
"rustc-hash", "rustc-hash",
"rustls 0.21.2", "rustls 0.21.2",
"rustls-native-certs",
"slab", "slab",
"thiserror", "thiserror",
"tinyvec", "tinyvec",
@ -1039,7 +1006,7 @@ dependencies = [
"libc", "libc",
"socket2 0.5.3", "socket2 0.5.3",
"tracing", "tracing",
"windows-sys", "windows-sys 0.48.0",
] ]
[[package]] [[package]]
@ -1139,7 +1106,7 @@ dependencies = [
"io-lifetimes", "io-lifetimes",
"libc", "libc",
"linux-raw-sys", "linux-raw-sys",
"windows-sys", "windows-sys 0.48.0",
] ]
[[package]] [[package]]
@ -1166,6 +1133,18 @@ dependencies = [
"sct", "sct",
] ]
[[package]]
name = "rustls-native-certs"
version = "0.6.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a9aace74cb666635c918e9c12bc0d348266037aa8eb599b5cba565709a8dff00"
dependencies = [
"openssl-probe",
"rustls-pemfile",
"schannel",
"security-framework",
]
[[package]] [[package]]
name = "rustls-pemfile" name = "rustls-pemfile"
version = "1.0.2" version = "1.0.2"
@ -1191,6 +1170,15 @@ version = "1.0.13"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f91339c0467de62360649f8d3e185ca8de4224ff281f66000de5eb2a77a79041" checksum = "f91339c0467de62360649f8d3e185ca8de4224ff281f66000de5eb2a77a79041"
[[package]]
name = "schannel"
version = "0.1.21"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "713cfb06c7059f3588fb8044c0fad1d09e3c01d225e25b9220dbfdcf16dbb1b3"
dependencies = [
"windows-sys 0.42.0",
]
[[package]] [[package]]
name = "scoped-tls" name = "scoped-tls"
version = "1.0.1" version = "1.0.1"
@ -1213,6 +1201,29 @@ dependencies = [
"untrusted", "untrusted",
] ]
[[package]]
name = "security-framework"
version = "2.9.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1fc758eb7bffce5b308734e9b0c1468893cae9ff70ebf13e7090be8dcbcc83a8"
dependencies = [
"bitflags",
"core-foundation",
"core-foundation-sys",
"libc",
"security-framework-sys",
]
[[package]]
name = "security-framework-sys"
version = "2.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f51d0c0d83bec45f16480d0ce0058397a69e48fcdc52d1dc8855fb68acbd31a7"
dependencies = [
"core-foundation-sys",
"libc",
]
[[package]] [[package]]
name = "serde" name = "serde"
version = "1.0.164" version = "1.0.164"
@ -1235,9 +1246,9 @@ dependencies = [
[[package]] [[package]]
name = "serde_json" name = "serde_json"
version = "1.0.96" version = "1.0.97"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "057d394a50403bcac12672b2b18fb387ab6d289d957dab67dd201875391e52f1" checksum = "bdf3bf93142acad5821c99197022e170842cdbc1c30482b98750c688c640842a"
dependencies = [ dependencies = [
"itoa", "itoa",
"ryu", "ryu",
@ -1308,7 +1319,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2538b18701741680e0322a2302176d3253a35388e2e62f172f64f4f16605f877" checksum = "2538b18701741680e0322a2302176d3253a35388e2e62f172f64f4f16605f877"
dependencies = [ dependencies = [
"libc", "libc",
"windows-sys", "windows-sys 0.48.0",
] ]
[[package]] [[package]]
@ -1400,7 +1411,7 @@ dependencies = [
"signal-hook-registry", "signal-hook-registry",
"socket2 0.4.9", "socket2 0.4.9",
"tokio-macros", "tokio-macros",
"windows-sys", "windows-sys 0.48.0",
] ]
[[package]] [[package]]
@ -1749,6 +1760,21 @@ version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
[[package]]
name = "windows-sys"
version = "0.42.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5a3e1820f08b8513f676f7ab6c1f99ff312fb97b553d30ff4dd86f9f15728aa7"
dependencies = [
"windows_aarch64_gnullvm 0.42.2",
"windows_aarch64_msvc 0.42.2",
"windows_i686_gnu 0.42.2",
"windows_i686_msvc 0.42.2",
"windows_x86_64_gnu 0.42.2",
"windows_x86_64_gnullvm 0.42.2",
"windows_x86_64_msvc 0.42.2",
]
[[package]] [[package]]
name = "windows-sys" name = "windows-sys"
version = "0.48.0" version = "0.48.0"
@ -1764,51 +1790,93 @@ version = "0.48.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7b1eb6f0cd7c80c79759c929114ef071b87354ce476d9d94271031c0497adfd5" checksum = "7b1eb6f0cd7c80c79759c929114ef071b87354ce476d9d94271031c0497adfd5"
dependencies = [ dependencies = [
"windows_aarch64_gnullvm", "windows_aarch64_gnullvm 0.48.0",
"windows_aarch64_msvc", "windows_aarch64_msvc 0.48.0",
"windows_i686_gnu", "windows_i686_gnu 0.48.0",
"windows_i686_msvc", "windows_i686_msvc 0.48.0",
"windows_x86_64_gnu", "windows_x86_64_gnu 0.48.0",
"windows_x86_64_gnullvm", "windows_x86_64_gnullvm 0.48.0",
"windows_x86_64_msvc", "windows_x86_64_msvc 0.48.0",
] ]
[[package]]
name = "windows_aarch64_gnullvm"
version = "0.42.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "597a5118570b68bc08d8d59125332c54f1ba9d9adeedeef5b99b02ba2b0698f8"
[[package]] [[package]]
name = "windows_aarch64_gnullvm" name = "windows_aarch64_gnullvm"
version = "0.48.0" version = "0.48.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "91ae572e1b79dba883e0d315474df7305d12f569b400fcf90581b06062f7e1bc" checksum = "91ae572e1b79dba883e0d315474df7305d12f569b400fcf90581b06062f7e1bc"
[[package]]
name = "windows_aarch64_msvc"
version = "0.42.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e08e8864a60f06ef0d0ff4ba04124db8b0fb3be5776a5cd47641e942e58c4d43"
[[package]] [[package]]
name = "windows_aarch64_msvc" name = "windows_aarch64_msvc"
version = "0.48.0" version = "0.48.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b2ef27e0d7bdfcfc7b868b317c1d32c641a6fe4629c171b8928c7b08d98d7cf3" checksum = "b2ef27e0d7bdfcfc7b868b317c1d32c641a6fe4629c171b8928c7b08d98d7cf3"
[[package]]
name = "windows_i686_gnu"
version = "0.42.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c61d927d8da41da96a81f029489353e68739737d3beca43145c8afec9a31a84f"
[[package]] [[package]]
name = "windows_i686_gnu" name = "windows_i686_gnu"
version = "0.48.0" version = "0.48.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "622a1962a7db830d6fd0a69683c80a18fda201879f0f447f065a3b7467daa241" checksum = "622a1962a7db830d6fd0a69683c80a18fda201879f0f447f065a3b7467daa241"
[[package]]
name = "windows_i686_msvc"
version = "0.42.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "44d840b6ec649f480a41c8d80f9c65108b92d89345dd94027bfe06ac444d1060"
[[package]] [[package]]
name = "windows_i686_msvc" name = "windows_i686_msvc"
version = "0.48.0" version = "0.48.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4542c6e364ce21bf45d69fdd2a8e455fa38d316158cfd43b3ac1c5b1b19f8e00" checksum = "4542c6e364ce21bf45d69fdd2a8e455fa38d316158cfd43b3ac1c5b1b19f8e00"
[[package]]
name = "windows_x86_64_gnu"
version = "0.42.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8de912b8b8feb55c064867cf047dda097f92d51efad5b491dfb98f6bbb70cb36"
[[package]] [[package]]
name = "windows_x86_64_gnu" name = "windows_x86_64_gnu"
version = "0.48.0" version = "0.48.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ca2b8a661f7628cbd23440e50b05d705db3686f894fc9580820623656af974b1" checksum = "ca2b8a661f7628cbd23440e50b05d705db3686f894fc9580820623656af974b1"
[[package]]
name = "windows_x86_64_gnullvm"
version = "0.42.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "26d41b46a36d453748aedef1486d5c7a85db22e56aff34643984ea85514e94a3"
[[package]] [[package]]
name = "windows_x86_64_gnullvm" name = "windows_x86_64_gnullvm"
version = "0.48.0" version = "0.48.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7896dbc1f41e08872e9d5e8f8baa8fdd2677f29468c4e156210174edc7f7b953" checksum = "7896dbc1f41e08872e9d5e8f8baa8fdd2677f29468c4e156210174edc7f7b953"
[[package]]
name = "windows_x86_64_msvc"
version = "0.42.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9aec5da331524158c6d1a4ac0ab1541149c0b9505fde06423b02f5ef0106b9f0"
[[package]] [[package]]
name = "windows_x86_64_msvc" name = "windows_x86_64_msvc"
version = "0.48.0" version = "0.48.0"

View File

@ -1,6 +1,6 @@
[workspace] [workspace]
members = [ members = [
"moq-transport", "moq-transport",
"moq-warp" "moq-demo",
"moq-warp",
] ]

40
moq-demo/Cargo.toml Normal file
View File

@ -0,0 +1,40 @@
[package]
name = "moq-demo"
description = "Media over QUIC"
authors = [ "Luke Curley" ]
repository = "https://github.com/kixelated/moq-rs"
license = "Apache-2.0"
version = "0.1.0"
edition = "2021"
keywords = [ "quic", "http3", "webtransport", "media", "live" ]
categories = [ "multimedia", "network-programming", "web-programming" ]
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
moq-transport = { path = "../moq-transport" }
moq-warp = { path = "../moq-warp" }
# QUIC
quinn = "0.10"
# Crypto
ring = "0.16.20"
rustls = "0.21.2"
rustls-pemfile = "1.0.2"
# Async stuff
tokio = { version = "1.27", features = ["full"] }
# Web server to serve the fingerprint
warp = { version = "0.3.3", features = ["tls"] }
hex = "0.4.3"
# Logging
clap = { version = "4.0", features = [ "derive" ] }
log = { version = "0.4", features = ["std"] }
env_logger = "0.9.3"
anyhow = "1.0.70"

View File

@ -1,4 +1,8 @@
use moq_warp::{app, media}; mod server;
mod session;
use server::*;
use std::{fs, io, net, path, sync}; use std::{fs, io, net, path, sync};
use std::collections::HashMap; use std::collections::HashMap;
@ -9,6 +13,8 @@ use clap::Parser;
use ring::digest::{digest, SHA256}; use ring::digest::{digest, SHA256};
use warp::Filter; use warp::Filter;
use moq_warp::Source;
/// Search for a pattern in a file and display the lines that contain it. /// Search for a pattern in a file and display the lines that contain it.
#[derive(Parser, Clone)] #[derive(Parser, Clone)]
struct Cli { struct Cli {
@ -39,20 +45,20 @@ async fn main() -> anyhow::Result<()> {
let serve = serve_http(args.clone()); let serve = serve_http(args.clone());
// Create a fake media source from disk. // Create a fake media source from disk.
let mut media = media::Source::new(args.media).context("failed to open fragmented.mp4")?; let mut media = Source::new(args.media).context("failed to open fragmented.mp4")?;
let mut broadcasts = HashMap::new(); let mut broadcasts = HashMap::new();
broadcasts.insert("demo".to_string(), media.broadcast()); broadcasts.insert("demo".to_string(), media.broadcast());
// Create a server to actually serve the media // Create a server to actually serve the media
let config = app::ServerConfig { let config = ServerConfig {
addr: args.addr, addr: args.addr,
cert: args.cert, cert: args.cert,
key: args.key, key: args.key,
broadcasts: Arc::new(broadcasts), broadcasts: Arc::new(broadcasts),
}; };
let mut server = app::Server::new(config).context("failed to create server")?; let mut server = Server::new(config).context("failed to create server")?;
// Run all of the above // Run all of the above
tokio::select! { tokio::select! {

View File

@ -1,19 +1,20 @@
use super::session::Session; use super::session::Session;
use crate::media;
use moq_transport::server::Endpoint;
use moq_warp::Broadcasts;
use std::{fs, io, net, path, sync, time}; use std::{fs, io, net, path, sync, time};
use anyhow::Context; use anyhow::Context;
use moq_transport::server;
use tokio::task::JoinSet; use tokio::task::JoinSet;
pub struct Server { pub struct Server {
// The MoQ transport server. // The MoQ transport server.
server: server::Endpoint, server: Endpoint,
// The media source. // The media source.
broadcasts: media::Broadcasts, broadcasts: Broadcasts,
// Sessions actively being run. // Sessions actively being run.
sessions: JoinSet<anyhow::Result<()>>, sessions: JoinSet<anyhow::Result<()>>,
@ -24,7 +25,7 @@ pub struct ServerConfig {
pub cert: path::PathBuf, pub cert: path::PathBuf,
pub key: path::PathBuf, pub key: path::PathBuf,
pub broadcasts: media::Broadcasts, pub broadcasts: Broadcasts,
} }
impl Server { impl Server {
@ -76,7 +77,7 @@ impl Server {
let server = quinn::Endpoint::server(server_config, config.addr)?; let server = quinn::Endpoint::server(server_config, config.addr)?;
let broadcasts = config.broadcasts; let broadcasts = config.broadcasts;
let server = server::Endpoint::new(server); let server = Endpoint::new(server);
let sessions = JoinSet::new(); let sessions = JoinSet::new();
Ok(Self { Ok(Self {

View File

@ -1,5 +1,3 @@
use crate::media;
use anyhow::Context; use anyhow::Context;
use tokio::io::AsyncWriteExt; use tokio::io::AsyncWriteExt;
@ -9,6 +7,7 @@ use std::sync::Arc;
use moq_transport::coding::VarInt; use moq_transport::coding::VarInt;
use moq_transport::{control, data, server, setup}; use moq_transport::{control, data, server, setup};
use moq_warp::{Broadcasts, Segment, Track};
pub struct Session { pub struct Session {
// Used to send/receive data streams. // Used to send/receive data streams.
@ -18,14 +17,14 @@ pub struct Session {
control: control::Stream, control: control::Stream,
// The list of available broadcasts for the session. // The list of available broadcasts for the session.
media: media::Broadcasts, media: Broadcasts,
// The list of active subscriptions. // The list of active subscriptions.
tasks: JoinSet<anyhow::Result<()>>, tasks: JoinSet<anyhow::Result<()>>,
} }
impl Session { impl Session {
pub async fn accept(session: server::Accept, media: media::Broadcasts) -> anyhow::Result<Session> { pub async fn accept(session: server::Accept, media: Broadcasts) -> anyhow::Result<Session> {
// Accep the WebTransport session. // Accep the WebTransport session.
// OPTIONAL validate the conn.uri() otherwise call conn.reject() // OPTIONAL validate the conn.uri() otherwise call conn.reject()
let session = session let session = session
@ -162,7 +161,7 @@ impl Session {
pub struct Subscription { pub struct Subscription {
transport: Arc<data::Transport>, transport: Arc<data::Transport>,
track_id: VarInt, track_id: VarInt,
track: media::Track, track: Track,
} }
impl Subscription { impl Subscription {
@ -201,12 +200,12 @@ impl Subscription {
struct Group { struct Group {
transport: Arc<data::Transport>, transport: Arc<data::Transport>,
track_id: VarInt, track_id: VarInt,
segment: media::Segment, segment: Segment,
} }
impl Group { impl Group {
pub async fn serve(mut self) -> anyhow::Result<()> { pub async fn serve(mut self) -> anyhow::Result<()> {
let header = moq_transport::data::Header { let header = data::Header {
track_id: self.track_id, track_id: self.track_id,
group_sequence: self.segment.sequence, group_sequence: self.segment.sequence,
object_sequence: VarInt::from_u32(0), // Always zero since we send an entire group as an object object_sequence: VarInt::from_u32(0), // Always zero since we send an entire group as an object

View File

@ -66,6 +66,17 @@ version = "1.0.71"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9c7d0618f0e0b7e8ff11427422b64564d5fb0be1940354bfe2e0529b18a9d9b8" checksum = "9c7d0618f0e0b7e8ff11427422b64564d5fb0be1940354bfe2e0529b18a9d9b8"
[[package]]
name = "async-trait"
version = "0.1.68"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b9ccdd8f2a161be9bd5c023df56f1b2a0bd1d83872ae53b71a84a12c9bf6e842"
dependencies = [
"proc-macro2",
"quote",
"syn",
]
[[package]] [[package]]
name = "atty" name = "atty"
version = "0.2.14" version = "0.2.14"
@ -416,7 +427,7 @@ dependencies = [
[[package]] [[package]]
name = "h3" name = "h3"
version = "0.0.2" version = "0.0.2"
source = "git+https://github.com/security-union/h3?branch=add-webtransport#db5c723f653911a476bfd8ffcfebf0f8f2eb980d" source = "git+https://github.com/hyperium/h3?branch=master#3ef7c1a37b635e8446322d8f8d3a68580a208ad8"
dependencies = [ dependencies = [
"bytes", "bytes",
"fastrand", "fastrand",
@ -429,8 +440,8 @@ dependencies = [
[[package]] [[package]]
name = "h3-quinn" name = "h3-quinn"
version = "0.0.2" version = "0.0.3"
source = "git+https://github.com/security-union/h3?branch=add-webtransport#db5c723f653911a476bfd8ffcfebf0f8f2eb980d" source = "git+https://github.com/hyperium/h3?branch=master#3ef7c1a37b635e8446322d8f8d3a68580a208ad8"
dependencies = [ dependencies = [
"bytes", "bytes",
"futures", "futures",
@ -444,7 +455,7 @@ dependencies = [
[[package]] [[package]]
name = "h3-webtransport" name = "h3-webtransport"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/security-union/h3?branch=add-webtransport#db5c723f653911a476bfd8ffcfebf0f8f2eb980d" source = "git+https://github.com/hyperium/h3?branch=master#3ef7c1a37b635e8446322d8f8d3a68580a208ad8"
dependencies = [ dependencies = [
"bytes", "bytes",
"futures-util", "futures-util",
@ -723,6 +734,7 @@ name = "moq"
version = "0.1.0" version = "0.1.0"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"async-trait",
"bytes", "bytes",
"clap", "clap",
"env_logger", "env_logger",

View File

@ -1,37 +1,31 @@
[package] [package]
name = "moq-transport" name = "moq-transport"
description = "Media over QUIC"
authors = [ "Luke Curley" ]
repository = "https://github.com/kixelated/moq-rs"
license = "Apache-2.0"
version = "0.1.0" version = "0.1.0"
edition = "2021" edition = "2021"
keywords = [ "quic", "http3", "webtransport", "media", "live" ]
categories = [ "multimedia", "network-programming", "web-programming" ]
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies] [dependencies]
# Fork of h3 with WebTransport support # WebTransport support: TODO pin a version when released
h3 = { git = "https://github.com/security-union/h3", branch = "add-webtransport" } h3 = { git = "https://github.com/hyperium/h3", branch = "master" }
h3-quinn = { git = "https://github.com/security-union/h3", branch = "add-webtransport" } h3-quinn = { git = "https://github.com/hyperium/h3", branch = "master" }
h3-webtransport = { git = "https://github.com/security-union/h3", branch = "add-webtransport" } h3-webtransport = { git = "https://github.com/hyperium/h3", branch = "master" }
quinn = { version = "0.10", default-features = false, features = ["runtime-tokio", "tls-rustls", "ring"] } quinn = "0.10"
quinn-proto = "0.10"
http = "0.2" http = "0.2"
# Crypto dependencies tokio = { version = "1.27", features = ["macros"] }
ring = "0.16"
rustls = { version = "0.21", features = ["dangerous_configuration"] }
rustls-pemfile = "1.0.2"
# Async stuff
tokio = { version = "1.27", features = ["full"] }
futures = "0.3"
# Encoding
bytes = "1" bytes = "1"
# Logging log = "0.4"
clap = { version = "4.0", features = [ "derive" ] }
log = { version = "0.4", features = ["std"] }
env_logger = "0.9.3"
# Utility
anyhow = "1.0.70" anyhow = "1.0.70"
thiserror = "1.0.21" thiserror = "1.0.21"
async-trait = "0.1" async-trait = "0.1"

View File

@ -1,6 +1,5 @@
use super::{Decode, Encode}; use crate::coding::{Decode, Encode, VarInt};
use crate::coding::VarInt;
use async_trait::async_trait; use async_trait::async_trait;
use tokio::io::{AsyncRead, AsyncWrite}; use tokio::io::{AsyncRead, AsyncWrite};

View File

@ -5,7 +5,7 @@
use std::convert::{TryFrom, TryInto}; use std::convert::{TryFrom, TryInto};
use std::fmt; use std::fmt;
use super::{Decode, Encode}; use crate::coding::{Decode, Encode};
use thiserror::Error; use thiserror::Error;

View File

@ -3,3 +3,5 @@ pub mod control;
pub mod data; pub mod data;
pub mod server; pub mod server;
pub mod setup; pub mod setup;
pub use coding::VarInt;

View File

@ -1,48 +1,22 @@
[package] [package]
name = "moq-warp" name = "moq-warp"
description = "Media over QUIC"
authors = [ "Luke Curley" ]
repository = "https://github.com/kixelated/moq-rs"
license = "Apache-2.0"
version = "0.1.0" version = "0.1.0"
edition = "2021" edition = "2021"
keywords = [ "quic", "http3", "webtransport", "media", "live" ]
categories = [ "multimedia", "network-programming", "web-programming" ]
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies] [dependencies]
# WebTransport support: TODO pin a version when released
h3 = { git = "https://github.com/hyperium/h3", branch = "master" }
h3-quinn = { git = "https://github.com/hyperium/h3", branch = "master" }
h3-webtransport = { git = "https://github.com/hyperium/h3", branch = "master" }
quinn = { version = "0.10", default-features = false, features = ["runtime-tokio", "tls-rustls", "ring"] }
quinn-proto = "0.10"
# Crypto dependencies
ring = "0.16"
rustls = { version = "0.21", features = ["dangerous_configuration"] }
rustls-pemfile = "1.0.2"
# Async stuff
tokio = { version = "1.27", features = ["full"] }
futures = "0.3"
# Media
mp4 = "0.13.0"
# Encoding
bytes = "1"
serde = "1.0.160"
serde_json = "1.0"
# Web server to serve the fingerprint
http = "0.2"
warp = { version = "0.3.3", features = ["tls"] }
hex = "0.4.3"
# Logging
clap = { version = "4.0", features = [ "derive" ] }
log = { version = "0.4", features = ["std"] }
env_logger = "0.9.3"
# Utility
anyhow = "1.0.70"
thiserror = "1.0.21"
paste = "1.0"
moq-transport = { path = "../moq-transport" } moq-transport = { path = "../moq-transport" }
tokio = "1.27"
mp4 = "0.13.0"
anyhow = "1.0.70"

View File

@ -1,5 +0,0 @@
mod server;
mod session;
pub use server::*;
pub use session::*;

View File

@ -1,2 +1,8 @@
pub mod app; mod source;
pub mod media; pub use source::Source;
mod model;
pub use model::*;
mod watch;
use watch::{Producer, Subscriber};

View File

@ -1,8 +0,0 @@
mod source;
pub use source::Source;
mod model;
pub use model::*;
mod watch;
use watch::{Producer, Subscriber};

View File

@ -3,7 +3,7 @@ use std::collections::HashMap;
use std::sync::Arc; use std::sync::Arc;
use std::time::Instant; use std::time::Instant;
use moq_transport::coding::VarInt; use moq_transport::VarInt;
// Map from track namespace to broadcast. // Map from track namespace to broadcast.
// TODO support updates // TODO support updates

View File

@ -2,16 +2,13 @@ use std::io::Read;
use std::{fs, io, path, time}; use std::{fs, io, path, time};
use anyhow;
use mp4;
use mp4::ReadBox; use mp4::ReadBox;
use anyhow::Context; use anyhow::Context;
use std::collections::HashMap; use std::collections::HashMap;
use std::sync::Arc; use std::sync::Arc;
use moq_transport::coding::VarInt; use moq_transport::VarInt;
use super::{Broadcast, Fragment, Producer, Segment, Track}; use super::{Broadcast, Fragment, Producer, Segment, Track};