Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 2 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,11 @@ env:

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v5
- run: sudo apt-get install -y protobuf-compiler clang nasm pkg-config
- name: Build
run: cargo build --verbose
- name: Run tests
run: cargo test --verbose
run: make test-all
- name: Run simulation tests
run: cargo test -p pulsebeam-simulator
run: make test-sim
17 changes: 14 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 2 additions & 8 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,8 @@ resolver = "2"
members = [
"pulsebeam",
"pulsebeam-agent",
"pulsebeam-cli",
"pulsebeam-cli",
"pulsebeam-core",
"pulsebeam-runtime",
"pulsebeam-simulator",
]

default-members = [
"pulsebeam",
"pulsebeam-agent",
"pulsebeam-cli",
"pulsebeam-runtime",
]
11 changes: 9 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,19 @@ dev:
$(CARGO_CMD) run -p pulsebeam -- --dev

build:
$(CARGO_CMD) build --profile profiling -p pulsebeam
$(CARGO_CMD) build

release:
$(CARGO_CMD) build --verbose --release -p pulsebeam

profile: build
profile:
$(CARGO_CMD) build --profile profiling -p pulsebeam

test-all:
cargo test --workspace --exclude pulsebeam-simulator

test-sim:
cargo test -p pulsebeam-simulator

flamegraph: profile
taskset -c 2-5 $(CARGO_CMD) flamegraph --profile profiling -p pulsebeam --bin pulsebeam
Expand Down
3 changes: 1 addition & 2 deletions pulsebeam-agent/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ authors.workspace = true

[features]
default = []
sim = ["dep:turmoil"]
# default = ["ffmpeg-static"]
#
# # Force static linking (default)
Expand All @@ -26,7 +25,6 @@ thiserror = { workspace = true }
tracing = { workspace = true }
str0m = { workspace = true }
bytes = { workspace = true }
turmoil = { workspace = true, optional = true }

tokio = { workspace = true }
metrics = "0.24.3"
Expand All @@ -35,6 +33,7 @@ maybe-async = "0.2.10"
http = "1.4.0"
tokio-stream = "0.1.17"
if-addrs = "0.14.0"
pulsebeam-core = { version = "0.1.0", path = "../pulsebeam-core" }

# FFmpeg integration
# ffmpeg-next = { version = "8.0.0", default-features = false, features = ["codec", "format", "filter", "software-resampling", "software-scaling"] }
13 changes: 3 additions & 10 deletions pulsebeam-agent/src/actor.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
use crate::signaling::{HttpSignalingClient, SignalingError};
use crate::{MediaFrame, TransceiverDirection};
use futures_lite::StreamExt;
use pulsebeam_core::net::UdpSocket;
use std::collections::HashMap;
use std::net::{IpAddr, SocketAddr};
use std::sync::Arc;
Expand All @@ -15,16 +18,6 @@ use tokio::time::Instant;
use tokio_stream::StreamMap;
use tokio_stream::wrappers::ReceiverStream;

use crate::signaling::{HttpSignalingClient, SignalingError};
use crate::{MediaFrame, TransceiverDirection};

#[cfg(not(feature = "sim"))]
use tokio::net as async_net;
#[cfg(feature = "sim")]
use turmoil::net as async_net;

use async_net::UdpSocket;

#[derive(Debug)]
pub struct TrackSender {
pub mid: Mid,
Expand Down
1 change: 1 addition & 0 deletions pulsebeam-cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@ tracing = { workspace = true }

pulsebeam-agent = { version = "0.1.0", path = "../pulsebeam-agent" }
tracing-subscriber = { version = "0.3", features = ["env-filter", "json"] }
pulsebeam-core = { version = "0.1.0", path = "../pulsebeam-core" }
2 changes: 1 addition & 1 deletion pulsebeam-cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ use pulsebeam_agent::{
media::H264Looper,
signaling::HttpSignalingClient,
};
use pulsebeam_core::net::UdpSocket;
use std::time::Duration;
use tokio::net::UdpSocket;

const RAW_H264: &[u8] = include_bytes!("video.h264");

Expand Down
18 changes: 18 additions & 0 deletions pulsebeam-core/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
[package]
name = "pulsebeam-core"
version.workspace = true
edition.workspace = true
homepage.workspace = true
documentation.workspace = true
repository.workspace = true
authors.workspace = true
license.workspace = true

[features]
default = []
sim = ["dep:turmoil", "dep:axum"]

[dependencies]
turmoil = { workspace = true, optional = true }
axum = { version = "^0.8", optional = true }
tokio = { workspace = true }
1 change: 1 addition & 0 deletions pulsebeam-core/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pub mod net;
49 changes: 49 additions & 0 deletions pulsebeam-core/src/net.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#[cfg(not(feature = "sim"))]
pub use tokio::net::UdpSocket;
#[cfg(feature = "sim")]
pub use turmoil::net::UdpSocket;

#[cfg(not(feature = "sim"))]
pub use tokio::net::{TcpListener, TcpStream};

#[cfg(feature = "sim")]
pub use sim::{TurmoilListener as TcpListener, TurmoilStream as TcpStream};

#[cfg(feature = "sim")]
mod sim {
use axum::serve::Listener;
use std::io;
use std::net::SocketAddr;
use turmoil::net::TcpListener as InnerListener;

pub type TurmoilStream = turmoil::net::TcpStream;
pub struct TurmoilListener(InnerListener);

impl TurmoilListener {
pub async fn bind(addr: SocketAddr) -> io::Result<Self> {
let inner = InnerListener::bind(addr).await?;
Ok(Self(inner))
}

pub async fn accept(&self) -> io::Result<(TurmoilStream, SocketAddr)> {
self.0.accept().await
}

pub fn local_addr(&self) -> io::Result<SocketAddr> {
self.0.local_addr()
}
}

impl Listener for TurmoilListener {
type Io = TurmoilStream;
type Addr = SocketAddr;

async fn accept(&mut self) -> (Self::Io, Self::Addr) {
self.0.accept().await.unwrap()
}

fn local_addr(&self) -> io::Result<Self::Addr> {
self.0.local_addr()
}
}
}
Empty file added pulsebeam-protocol/src/lib.rs
Empty file.
3 changes: 1 addition & 2 deletions pulsebeam-runtime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ harness = false
[features]
default = []
loom = ["dep:loom"]
sim = ["dep:turmoil"]

[dependencies]
thiserror = { workspace = true }
Expand All @@ -27,7 +26,6 @@ tracing = { workspace = true }
rand = { workspace = true }
bytes = { workspace = true }
futures-lite = { workspace = true }
turmoil = { workspace = true, optional = true }

quinn-udp = "0.5.14"
socket2 = "0.6.1"
Expand All @@ -42,6 +40,7 @@ dashmap = "6.1.0"
async-channel = "2.5.0"
tokio-util = "0.7.17"
systemstat = "0.2.5"
pulsebeam-core = { version = "0.1.0", path = "../pulsebeam-core" }

[dev-dependencies]
criterion = { version = "0.8.1", features = ["async", "async_tokio"] }
Expand Down
Loading