smol-rs / async-broadcast

Async broadcast channels

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

can async-broadcast be used to broadcast audio/video

pylearndl opened this issue · comments

Hi,

I'm new to rust was searching how to broadcast to all other users on google and came across to async-broadcast.
Can async-broadcast be used to broadcast audio/video to all other users except the sender? I was also looking for example regarding it but found none. I though I might ask here! Cheers

Can async-broadcast be used to broadcast audio/video to all other users except the sender

Don't see why not. Like most channels API in Rust (and other modern languages), there is a clear split between sender and receiver. When you create a channel, you immediately get a sender and receiver (both of which you can clone to create multiple senders and/or receivers).

So I'm not exactly sure what your question is. 🤔

diagram
I’m trying to code SFU (relay) server in Rust with JavaScript web client. I have used ws-audio-api to encode getUserMedia audio, encode audio using OpusEncoder and chunk into buffer packets. I send those buffer packets to WebTransport server connected on https://127.0.0.1:4435/ in loop as audio gets encoded and chunked in to buffer.

for (var i = 0; i < packets.length; i++) { await _this.webtranserve.write(packets[i]); }

On server WebTransport receives packets via datagram and send it to web client B via datagram.

dgram = connection.receive_datagram() => { let dgram = dgram?; connection.send_datagram(dgram.to_vec())?; }

Above implementation works for one to one (Client A -> Server Room <- Client B). Above implementation stating to lag while sending packets from server to more than one client. If 5 or more clients connects to same room on server then I have to loop to send packets through all clients in the room and it creates lag in audio.

I want to code SFU implement as below diagram. For example, Room A on server has 10 client connections. Let say, when encoded audio packet received from client 1, server broadcast to all rest clients (2 to 10) sends packets without any lag (latency). Will async-broadcast can be useful in this scenario (without any lag, low latency)?
maxresdefault2

@pylearndl Seems you need a consultant to come up with a solution to your problem rather than help on async-broadcast API. Please don't comment here anymore.