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, DataChannel
and
PeerConnection
, that define all available callback methods. Note that all methods have
a default no-operation implementation.
Aforementioned traits are defined as follows:
Traits implementations are meant to be used through RtcPeerConnection
and
RtcDataChannel
structs.
The main struct, RtcPeerconnection
, takes a Config
(which defines ICE servers) and a
MakeDataChannel
instance (a factory used internally for on_data_channel
callback). Note that this factory trait is already implemented for FnMut
closures.
Here is the basic workflow:
use ;
;
;
let ice_servers = vec!;
let conf = new;
let mut pc = new?;
let dc = pc.create_data_channel?;
Complete implementation example can be found in the tests.
Packaging
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).
Note that CMake
is required to compile libdatachannel through
datachannel-sys.