mirror of
https://github.com/mii443/libdatachannel.git
synced 2025-08-22 15:15:28 +00:00
Added some Readme info
This commit is contained in:
43
README.md
43
README.md
@ -1,6 +1,6 @@
|
||||
# libdatachannel - C/C++ WebRTC Data Channels
|
||||
|
||||
libdatachannel is a standalone implementation of WebRTC Data Channels and WebSockets in C++17 with C bindings for POSIX platforms (including Linux and Apple macOS) and Microsoft Windows. It enables direct connectivity between native applications and web browsers without the pain of importing the entire WebRTC stack. Its API is modelled as a simplified version of the JavaScript WebRTC and WebSocket API, in order to ease the design of cross-environment applications.
|
||||
libdatachannel is a standalone implementation of WebRTC Data Channels and WebSockets in C++17 with C bindings for POSIX platforms (including Linux and Apple macOS) and Microsoft Windows. It enables direct connectivity between native applications and web browsers without the pain of importing the entire WebRTC stack. Its API is modelled as a simplified version of the JavaScript WebRTC and WebSocket browser API, in order to ease the design of cross-environment applications.
|
||||
|
||||
It can be compiled with multiple backends:
|
||||
- The security layer can be provided through [GnuTLS](https://www.gnutls.org/) or [OpenSSL](https://www.openssl.org/).
|
||||
@ -16,31 +16,31 @@ The library aims at implementing the following communication protocols:
|
||||
|
||||
### WebRTC Data Channel
|
||||
|
||||
The WebRTC stack has been tested to be compatible with Firefox and Chromium.
|
||||
|
||||
Protocol stack:
|
||||
- SCTP-based Data Channels ([draft-ietf-rtcweb-data-channel-13](https://tools.ietf.org/html/draft-ietf-rtcweb-data-channel-13))
|
||||
- DTLS/UDP ([RFC7350](https://tools.ietf.org/html/rfc7350) and [RFC8261](https://tools.ietf.org/html/rfc8261))
|
||||
- ICE ([RFC8445](https://tools.ietf.org/html/rfc8445)) with STUN [RFC5389](https://tools.ietf.org/html/rfc5389)
|
||||
|
||||
Features:
|
||||
- IPv6 support
|
||||
- Full IPv6 support
|
||||
- Trickle ICE [draft-ietf-ice-trickle-21](https://tools.ietf.org/html/draft-ietf-ice-trickle-21)
|
||||
- Multicast DNS candidates resolution ([draft-ietf-rtcweb-mdns-ice-candidates-03](https://tools.ietf.org/html/draft-ietf-rtcweb-mdns-ice-candidates-03)) provided the operating system has mDNS support
|
||||
- Multicast DNS candidates ([draft-ietf-rtcweb-mdns-ice-candidates-04](https://tools.ietf.org/html/draft-ietf-rtcweb-mdns-ice-candidates-04))
|
||||
- TURN relaying [RFC5766](https://tools.ietf.org/html/rfc5766) with [libnice](https://github.com/libnice/libnice) as ICE backend.
|
||||
|
||||
It has been tested to be compatible with Firefox and Chromium.
|
||||
### WebSocket
|
||||
|
||||
### WebSocket (optional)
|
||||
WebSocket is the protocol of choice for WebRTC signaling. The support is optional and can be disabled at compile time.
|
||||
|
||||
Protocol stack:
|
||||
- WebSocket protocol ([RFC6455](https://tools.ietf.org/html/rfc6455)), client-side only
|
||||
- HTTP over TLS ([RFC2818](https://tools.ietf.org/html/rfc2818))
|
||||
|
||||
Features:
|
||||
- IPv6 support
|
||||
- IPv6 and IPv4/IPv6 dual-stack support
|
||||
- Keepalive with ping/pong
|
||||
|
||||
WebSocket is the protocol of choice for WebRTC signaling.
|
||||
|
||||
## Dependencies
|
||||
|
||||
- GnuTLS: https://www.gnutls.org/ or OpenSSL: https://www.openssl.org/
|
||||
@ -49,8 +49,8 @@ Optional:
|
||||
- libnice: https://nice.freedesktop.org/ (substituable with libjuice)
|
||||
|
||||
Submodules:
|
||||
- usrsctp: https://github.com/sctplab/usrsctp
|
||||
- libjuice: https://github.com/paullouisageneau/libjuice
|
||||
- usrsctp: https://github.com/sctplab/usrsctp
|
||||
|
||||
## Building
|
||||
### Building with CMake (preferred)
|
||||
@ -70,10 +70,12 @@ $ git submodule update --init --recursive
|
||||
$ make USE_JUICE=1 USE_GNUTLS=1
|
||||
```
|
||||
|
||||
## Example
|
||||
## Examples
|
||||
|
||||
See [examples](https://github.com/paullouisageneau/libdatachannel/blob/master/examples/) for a complete usage example with signaling server (under GPLv2).
|
||||
|
||||
Additionnaly, you might want to have a look at the [C API](https://github.com/paullouisageneau/libdatachannel/blob/dev/include/rtc/rtc.h).
|
||||
|
||||
### Signal a PeerConnection
|
||||
|
||||
```cpp
|
||||
@ -122,9 +124,11 @@ pc->onGatheringStateChange([](PeerConnection::GatheringState state) {
|
||||
|
||||
```cpp
|
||||
auto dc = pc->createDataChannel("test");
|
||||
|
||||
dc->onOpen([]() {
|
||||
cout << "Open" << endl;
|
||||
});
|
||||
|
||||
dc->onMessage([](const variant<binary, string> &message) {
|
||||
if (holds_alternative<string>(message)) {
|
||||
cout << "Received: " << get<string>(message) << endl;
|
||||
@ -143,3 +147,22 @@ pc->onDataChannel([&dc](shared_ptr<rtc::DataChannel> incoming) {
|
||||
|
||||
```
|
||||
|
||||
### Open a WebSocket
|
||||
|
||||
```cpp
|
||||
auto ws = make_shared<rtc::WebSocket>();
|
||||
|
||||
ws->onOpen([]() {
|
||||
cout << "WebSocket open" << endl;
|
||||
});
|
||||
|
||||
ws->onMessage([](const variant<binary, string> &message) {
|
||||
if (holds_alternative<string>(message)) {
|
||||
cout << "WebSocket received: " << get<string>(message) << endl;
|
||||
}
|
||||
});
|
||||
|
||||
ws->open("wss://my.websocket/service");
|
||||
|
||||
```
|
||||
|
||||
|
12
examples/README.md
Normal file
12
examples/README.md
Normal file
@ -0,0 +1,12 @@
|
||||
# Examples for libdatachannel
|
||||
|
||||
This directory contains different WebRTC clients and WebSocket + JSON signaling servers.
|
||||
|
||||
- [client](client) uses libdatachannel to implement WebRTC Data Channels with WebSocket signaling
|
||||
- [web](web) contains an equivalent implementation for web browsers and a node.js signaling server
|
||||
- [signaling-server-python](signaling-server-python) contains a similar signaling server in Python
|
||||
|
||||
Additionally, it contains two debugging tools for libdatachannel with copy-pasting as signaling:
|
||||
- [copy-paste](copy-paste) using the C++ API
|
||||
- [copy-paste-capi](copy-paste-capi) using the C API
|
||||
|
Reference in New Issue
Block a user