datachannel-rs

Rust wrappers for libdatachannel, a WebRTC Data Channels standalone implementation in C++.
Usage
This crate provides two traits that end user must implement, DataChannelHandler and
PeerConnectionHandler, which defined all callbacks for RtcPeerConnection and
RtcDataChannel structs respectively.
Aforementioned traits are defined as follows:
Note that all on_* methods have a default no-operation implementation.
The main struct, RtcPeerconnection, takes a RtcConfig (which defines ICE servers)
and a instance of PeerConnectionHandler.
Here is the basic workflow:
use ;
;
;
let ice_servers = vec!;
let conf = new;
let mut pc = new?;
let mut dc = pc.create_data_channel?;
// TODO: exchange `SessionDescription` and `IceCandidate` with remote peer
// TODO: wait for `dc` to be opened (should be signaled through `on_open`)
// ...
// Then send a message
dc.send?;
Complete implementation example can be found in the tests.
See also async-datachannel for an async-based implementation.
Cargo features
logDefault Enables logging provided by thelogcrate (mutually exclusive withtracing).tracingEnables logging provided by thetracingcrate (mutally exclusive withlog).staticBuild and link statically (with all dependencies, includingOpenSSL).mediaEnables media support throughlibdatachannel.
Building
Note that CMake is required to compile libdatachannel through
datachannel-sys.
Clone the repo recursively:
Static build
By default libdatachannel will be built and linked dynamically. However there is a
static Cargo feature that will build and link it statically (with all its
dependencies, including OpenSSL).
Apple macOS
You probably need to set the following environment variables if your build fails with an
OpenSSL related error.
With the paths of your local OpenSSL installation.
Ubuntu
Required dependencies:
# Needed to compile libdatachannel