Skip to content

Commit

Permalink
restructure the code
Browse files Browse the repository at this point in the history
  • Loading branch information
yngrtc committed Jan 6, 2024
1 parent a88728a commit 12cca3f
Show file tree
Hide file tree
Showing 28 changed files with 216 additions and 420 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "rtc"]
path = rtc
url = https://github.com/webrtc-rs/rtc
10 changes: 10 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,16 @@ core_affinity = "0.8.1"
num_cpus = "1.16.0"
smol = "2.0.0"

# RTC protocol
shared = { path = "rtc/shared"}
stun = { path = "rtc/stun"}
rtp = { path = "rtc/rtp"}
rtcp = { path = "rtc/rtcp"}
srtp= { path = "rtc/srtp"}
dtls = { path = "rtc/dtls"}
sctp = { path = "rtc/sctp"}
data = { path = "rtc/data"}

[dev-dependencies]
futures = "0.3.30"
tokio = { version = "1.24.1", features = ["rt-multi-thread", "macros", "signal"] }
Expand Down
48 changes: 48 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,51 @@
<p align="center">
A pure Rust implementation of SFU
</p>

#

<details>
<summary><b>Table of Content</b></summary>

- [Building](#building)
- [Toolchain](#toolchain)
- [Monorepo Setup](#monorepo-setup)
- [Open Source License](#open-source-license)
- [Contributing](#contributing)
</details>

#

## Building

### Toolchain

webrtc-rs currently requires Rust 1.75.0 to build.

### Monorepo Setup

All webrtc dependent crates are added as [submodules](https://git-scm.com/book/en/v2/Git-Tools-Submodules) of this repository under /crates/.

```
git clone https://github.com/webrtc-rs/sfu
cd sfu
git submodule update --init --recursive
```

To build sfu crate:

```
cargo build [or clippy or test or fmt]
```

To build sfu-based chat example:

```
cargo run --package sfu --example chat
```

## Open Source License
Dual licensing under both MIT and Apache-2.0 is the currently accepted standard by the Rust language community and has been used for both the compiler and many public libraries since (see https://doc.rust-lang.org/1.6.0/complement-project-faq.html#why-dual-mitasl2-license). In order to match the community standards, webrtc-rs is using the dual MIT+Apache-2.0 license.

## Contributing
Contributors or Pull Requests are Welcome!!!
9 changes: 4 additions & 5 deletions examples/chat.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use async_broadcast::broadcast;
//use async_broadcast::broadcast;
use clap::Parser;
use log::info;
use std::collections::HashMap;
use std::io::Write;

mod signal;
Expand Down Expand Up @@ -76,11 +75,11 @@ fn main() -> anyhow::Result<()> {
cli.host, cli.signal_port, cli.media_port_min, cli.media_port_max
);

let media_ports: Vec<u16> = (cli.media_port_min..=cli.media_port_max).collect();
let (stop_tx, mut stop_rx) = broadcast::<()>(1);
let _media_ports: Vec<u16> = (cli.media_port_min..=cli.media_port_max).collect();
//let (_stop_tx, mut _stop_rx) = broadcast::<()>(1);
//let mut port2thread_map = HashMap::new();

let key_pair = rcgen::KeyPair::generate(&rcgen::PKCS_ECDSA_P256_SHA256)?;
//let key_pair = rcgen::KeyPair::generate(&rcgen::PKCS_ECDSA_P256_SHA256)?;
// let certificate = RTCCertificate::from_key_pair(key_pair)?;
// fingerprints = certificate.get_fingerprints();

Expand Down
1 change: 1 addition & 0 deletions rtc
Submodule rtc added at f8a963
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use async_trait::async_trait;
use std::sync::Arc;

use crate::rtc::server::ServerStates;
use crate::server::ServerStates;

use retty::channel::{Handler, InboundContext, InboundHandler, OutboundContext, OutboundHandler};
use retty::transport::TaggedBytesMut;
Expand Down
File renamed without changes.
6 changes: 6 additions & 0 deletions src/handlers/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
pub mod data;
//TODO: pub mod demuxer;
pub mod dtls;
pub mod rtcp;
pub mod rtp;
pub mod sctp;
File renamed without changes.
File renamed without changes.
1 change: 1 addition & 0 deletions src/handlers/sctp/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

5 changes: 3 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#![warn(rust_2018_idioms)]
#![allow(dead_code)]

//pub mod rtc;
//pub mod signal;
pub mod handlers;
pub mod server;
pub mod shared;
39 changes: 0 additions & 39 deletions src/rtc/endpoint/mod.rs

This file was deleted.

4 changes: 0 additions & 4 deletions src/rtc/mod.rs

This file was deleted.

80 changes: 0 additions & 80 deletions src/rtc/proto/ice/mod.rs

This file was deleted.

5 changes: 0 additions & 5 deletions src/rtc/proto/mod.rs

This file was deleted.

37 changes: 0 additions & 37 deletions src/rtc/room/mod.rs

This file was deleted.

Loading

0 comments on commit 12cca3f

Please sign in to comment.