Skip to content

Latest commit

 

History

History
65 lines (48 loc) · 2.36 KB

File metadata and controls

65 lines (48 loc) · 2.36 KB

Rust WebRTC Client-Server example

About

An example with WebRTC-client and WebRTC-server. Network model is Client-Server-Client.

WebRTC-client works in two modes: sender or receiver. In sender mode, it sends text and video data to the server. The WebRTC server forwards data from one sender client to a receiver client.

The client side of this example uses async rust and web-sys including the use of WebRTC. The server side of this example uses async rust, WebSocket using tokio-tungstenite and WebRTC using webrtc-rs.

In order to simplify the code, all the errors are unwrapped.

State

  • Signaling protocol,
  • Signaling server,
  • Multiple clients per server,
  • Sender-Client-To-Server WebRTC-connection,
  • Sender-Client-To-Server text,
  • Sender-Client-To-Server video,
  • Sender-Client-To-Server audio,
  • Sender-Client-To-Server video and audio as a single stream,
  • Server-To-Receiver-Client WebRTC-connection,
  • Server-To-Receiver-Client text,
  • Server-To-Receiver-Client video,
  • Server-To-Receiver-Client audio,
  • Server-To-Receiver-Client video and audio as a single stream,
  • Each Sender-Client paired with the Receiver-Client,
  • Data transfer from Sender-Client to Receiver-Client via server,
  • Media transfer from Sender-Client to Receiver-Client via server.

Setup

  • Run bash setup.sh

Usage

  • Run bash watch.sh
  • Open localhost:8080 in browser
  • Edit the server address if necessary and click button Start sender or Start receiver.
  • Type in sender TextArea, the message will be displayed on the receiver TextArea.
  • If the receiver is started before the sender, you will see the video as soon as the sender is started.
  • If the sender starts before the receiver, the video will start after the sender sends keyframes.
  • A separate HtmlVideoElement is used for audio playback on the Client-Receiver side.

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.