Tsahi is right that building a SFU for most applications isn't the right
choice. It is like building your own HTTP server to server static
HTML. It is pretty unlikely that you will do better then nginx or
Apache. I do recommend building an SFU for fun/learning though!
Building a MVP SFU isn't that hard and it is a great learning experience.
I would go even lower then libwebrtc though. Most WebRTC implementations
(client and server) are running the same code. OpenSSL, libsrtp,
usrsctp. The software gets different in the RTP/RTCP layer.
If you are ok with media only just do SDP, ICE, DTLS and SRTP. I
would recommend going with C/C++, Java, Go, Typescript, C# or Rust. All
these languages have the libraries you need today.
Think of your SFU as just 'RTP packet fanout' for your MVP. It is *way
more* complicated then this in a production application. But for your
MVP this is enough. These are the high level programming tasks.
* Create a 'PeerConnection' on your server.
- It consumes and distributes RTP packets.
- Each 'room' will be an array of 'PeerConnections' in your server.
* Implement the PeerConnection
- Generate a self-signed DTLS certificate
- Start a ICE-lite listener
- Generate a Offer that contains those details and two media sections
- Respond to STUN packets from remote ICE Agent
- Do DTLS Handshake
- Extract keying material that is used to encrypt/decrypt S(RTP)
packets
* Distribute your RTP packets
- On each incoming packets decrypt
- Then distribute to each 'PeerConnection'
- You will encrypt via SRTP
- Then send via ICE-lite socket
I glossed over lots of details. I think this is enough info to go
learn. Check out the book
https://webrtcforthecurious.com/ it is an Open
Source book that teaches the protocols and might be helpful.
If you do decide to build your own server I would be careful about using
libwebrtc. I have helped some companies that went that route. They had
performance issues that made them end up switching. You also have to keep
up with API changes.
On Sat, Feb 27, 2021 at 06:12:15AM -0800, Tsahi Levent-Levi wrote:
> Hi,
>
> The best recommendation is simply not to do it.
> Use Janus, Jitsi or madiasoup.
> If you're really after a C++ implementation then take Janus.
>
> This would reduce your need to deal with writing an SFU altogether and let
> you focus on the actual use case you are after.
>
> The challenge with your question, is that in most cases, I wouldn't be
> suggesting developing an SFU to someone who is asking it because... well...
> it requires too much knowledge and experience with VoIP and WebRTC. And
> having that much of experience usually means the question wouldn't be asked
> at all.
>
> --
> Regards,
> *Tsahi Levent-Levi*
> Analyst & Consultant
> BlogGeek.me <
https://bloggeek.me>
>
> Want to get more of your WebRTC sessions effectively connected? Enroll to
> my free video course:
http://bit.ly/32Y3qZK
>
> On Friday, February 26, 2021 at 11:39:04 AM UTC+2
tengz...@gmail.com wrote:
>
> > Dear all,
> > I want to know which is the recommended way to implement a SFU server
> > using webrtc.
> > The SFU server need to be high performance, so I want to implement in C++
> > using the webrtc c++ library.
> > After going through the source code, I think I can implment a class like
> > VideoReceiveStream2 to implment the packet receive, nack send, fec resolve
> > and so on...
> > and after receiving the packet, using the RTPSender to forward the packet
> > to other peers.
> > Is that right?
> >
> > Any sugguestions will be greatly appreciated.
> >
>
> --
>
> ---
> You received this message because you are subscribed to the Google Groups "discuss-webrtc" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to
discuss-webrt...@googlegroups.com.
> To view this discussion on the web visit
https://groups.google.com/d/msgid/discuss-webrtc/aaf03dc4-b2fb-4388-8ef9-4053dfa08077n%40googlegroups.com.