Skip to content
This repository has been archived by the owner on Aug 23, 2022. It is now read-only.

Add main parts of SFU example #15

Closed
wants to merge 1 commit into from

Conversation

srcrip
Copy link

@srcrip srcrip commented Jun 22, 2022

This branch adds a simple example of a Selective Forwarding Unit.

There's a little bit of cleanup I'll add shortly, but the big elephant in the room is this branch only works on the main branch of webrtc-rs. I've set it as such here so that people can try it out by just pulling this branch, but ultimately we can't merge this until there's a new release, at which point we can tag the whole examples version to 0.5.

while let Ok(signal) = socket_rx.recv_async().await {
match signal {
SocketMessage { event, uuid: id, data: sdp } if event == "offer" => {
println!("\nReceiving offer: {:?}, for uuid: {:?}\n", sdp, id);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should use log::info or so for these, no printlns

uuid: id.to_owned(),
tx: socket_tx.clone(),
sdp
}).unwrap();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

expect instead of unwrap if we don't think this can happen. Alternatively if the receiver is gone should this task halt?

for (_k, p) in &peers {
match p.local_video_tracks.get(&uuid) {
Some(track) => {
if let Err(err) = track.write_rtp(&packet).await {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These futures can be created, collected into a Vec and then ran concurrently with futures::join_all


async fn simple_file_send(filename: &str) -> Result<Response<Body>, anyhow::Error> {
// Serve a file by asynchronously reading it by chunks using tokio-util crate.
if let Ok(file) = tokio::fs::File::open(filename).await {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If filename is user controlled this can trigger a path traversal vulnerability.

@k0nserv
Copy link
Member

k0nserv commented Aug 23, 2022

We have migrated this crate to the monorepo(webrtc-rs/webrtc) please re-open this pull request over there or perhaps for this case in the SFU repo?

@k0nserv k0nserv closed this Aug 23, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants