mirror of
https://github.com/mii443/libdatachannel.git
synced 2025-08-23 15:48:03 +00:00
Compare commits
8 Commits
Author | SHA1 | Date | |
---|---|---|---|
e4ab5273fc | |||
bf0b3ce1b9 | |||
655175d21e | |||
c85943e916 | |||
1cc7910bf1 | |||
62b435a4aa | |||
9da756bd12 | |||
f5b584f536 |
@ -1,6 +1,6 @@
|
|||||||
cmake_minimum_required(VERSION 3.7)
|
cmake_minimum_required(VERSION 3.7)
|
||||||
project(libdatachannel
|
project(libdatachannel
|
||||||
VERSION 0.12.1
|
VERSION 0.12.3
|
||||||
LANGUAGES CXX)
|
LANGUAGES CXX)
|
||||||
set(PROJECT_DESCRIPTION "WebRTC Data Channels Library")
|
set(PROJECT_DESCRIPTION "WebRTC Data Channels Library")
|
||||||
|
|
||||||
|
9
Jamfile
9
Jamfile
@ -12,9 +12,12 @@ feature.compose <gnutls>on
|
|||||||
lib libdatachannel
|
lib libdatachannel
|
||||||
: # sources
|
: # sources
|
||||||
[ glob ./src/*.cpp ]
|
[ glob ./src/*.cpp ]
|
||||||
|
[ glob ./src/impl/*.cpp ]
|
||||||
: # requirements
|
: # requirements
|
||||||
<cxxstd>17
|
<cxxstd>17
|
||||||
|
<include>./include
|
||||||
<include>./include/rtc
|
<include>./include/rtc
|
||||||
|
<include>./src
|
||||||
<define>RTC_ENABLE_MEDIA=0
|
<define>RTC_ENABLE_MEDIA=0
|
||||||
<define>RTC_ENABLE_WEBSOCKET=0
|
<define>RTC_ENABLE_WEBSOCKET=0
|
||||||
<define>USE_NICE=0
|
<define>USE_NICE=0
|
||||||
@ -143,7 +146,7 @@ rule make_libjuice_openssl ( targets * : sources * : properties * )
|
|||||||
{
|
{
|
||||||
# on macOS, default to pick up openssl from the homebrew installation
|
# on macOS, default to pick up openssl from the homebrew installation
|
||||||
# brew install openssl
|
# brew install openssl
|
||||||
OPENSSL_INCLUDE = /usr/local/opt/openssl/include ;
|
OPENSSL_INCLUDE = /opt/homebrew/opt/openssl /usr/local/opt/openssl/include ;
|
||||||
}
|
}
|
||||||
|
|
||||||
if $(OPENSSL_INCLUDE) != ""
|
if $(OPENSSL_INCLUDE) != ""
|
||||||
@ -191,7 +194,7 @@ rule openssl-lib-path ( properties * )
|
|||||||
{
|
{
|
||||||
# on macOS, default to pick up openssl from the homebrew installation
|
# on macOS, default to pick up openssl from the homebrew installation
|
||||||
# brew install openssl
|
# brew install openssl
|
||||||
OPENSSL_LIB = /usr/local/opt/openssl/lib ;
|
OPENSSL_LIB = /opt/homebrew/opt/openssl/lib /usr/local/opt/openssl/lib ;
|
||||||
}
|
}
|
||||||
else if <target-os>windows in $(properties) && $(OPENSSL_LIB) = ""
|
else if <target-os>windows in $(properties) && $(OPENSSL_LIB) = ""
|
||||||
{
|
{
|
||||||
@ -217,7 +220,7 @@ rule openssl-include-path ( properties * )
|
|||||||
{
|
{
|
||||||
# on macOS, default to pick up openssl from the homebrew installation
|
# on macOS, default to pick up openssl from the homebrew installation
|
||||||
# brew install openssl
|
# brew install openssl
|
||||||
OPENSSL_INCLUDE = /usr/local/opt/openssl/include ;
|
OPENSSL_INCLUDE = /opt/homebrew/opt/openssl/include /usr/local/opt/openssl/include ;
|
||||||
}
|
}
|
||||||
else if <target-os>windows in $(properties) && $(OPENSSL_INCLUDE) = ""
|
else if <target-os>windows in $(properties) && $(OPENSSL_INCLUDE) = ""
|
||||||
{
|
{
|
||||||
|
@ -118,7 +118,7 @@ function createPeerConnection(ws, id) {
|
|||||||
pc.onconnectionstatechange = () => console.log(`Connection state: ${pc.connectionState}`);
|
pc.onconnectionstatechange = () => console.log(`Connection state: ${pc.connectionState}`);
|
||||||
pc.onicegatheringstatechange = () => console.log(`Gathering state: ${pc.iceGatheringState}`);
|
pc.onicegatheringstatechange = () => console.log(`Gathering state: ${pc.iceGatheringState}`);
|
||||||
pc.onicecandidate = (e) => {
|
pc.onicecandidate = (e) => {
|
||||||
if (e.candidate) {
|
if (e.candidate && e.candidate.candidate) {
|
||||||
// Send candidate
|
// Send candidate
|
||||||
sendLocalCandidate(ws, id, e.candidate);
|
sendLocalCandidate(ws, id, e.candidate);
|
||||||
}
|
}
|
||||||
|
@ -22,6 +22,7 @@
|
|||||||
#include <functional>
|
#include <functional>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
|
#include <utility>
|
||||||
|
|
||||||
namespace rtc {
|
namespace rtc {
|
||||||
|
|
||||||
@ -32,11 +33,10 @@ template <class... Ts> overloaded(Ts...) -> overloaded<Ts...>;
|
|||||||
// weak_ptr bind helper
|
// weak_ptr bind helper
|
||||||
template <typename F, typename T, typename... Args> auto weak_bind(F &&f, T *t, Args &&..._args) {
|
template <typename F, typename T, typename... Args> auto weak_bind(F &&f, T *t, Args &&..._args) {
|
||||||
return [bound = std::bind(f, t, _args...), weak_this = t->weak_from_this()](auto &&...args) {
|
return [bound = std::bind(f, t, _args...), weak_this = t->weak_from_this()](auto &&...args) {
|
||||||
using result_type = typename decltype(bound)::result_type;
|
|
||||||
if (auto shared_this = weak_this.lock())
|
if (auto shared_this = weak_this.lock())
|
||||||
return bound(args...);
|
return bound(args...);
|
||||||
else
|
else
|
||||||
return static_cast<result_type>(false);
|
return static_cast<decltype(bound(args...))>(false);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -36,7 +36,7 @@ struct PeerConnection;
|
|||||||
struct DataChannel : Channel, std::enable_shared_from_this<DataChannel> {
|
struct DataChannel : Channel, std::enable_shared_from_this<DataChannel> {
|
||||||
DataChannel(weak_ptr<PeerConnection> pc, uint16_t stream, string label, string protocol,
|
DataChannel(weak_ptr<PeerConnection> pc, uint16_t stream, string label, string protocol,
|
||||||
Reliability reliability);
|
Reliability reliability);
|
||||||
~DataChannel();
|
virtual ~DataChannel();
|
||||||
|
|
||||||
void close();
|
void close();
|
||||||
void remoteClose();
|
void remoteClose();
|
||||||
|
@ -189,7 +189,7 @@ shared_ptr<DtlsTransport> PeerConnection::initDtlsTransport() {
|
|||||||
auto certificate = mCertificate.get();
|
auto certificate = mCertificate.get();
|
||||||
auto lower = std::atomic_load(&mIceTransport);
|
auto lower = std::atomic_load(&mIceTransport);
|
||||||
auto verifierCallback = weak_bind(&PeerConnection::checkFingerprint, this, _1);
|
auto verifierCallback = weak_bind(&PeerConnection::checkFingerprint, this, _1);
|
||||||
auto stateChangeCallback =
|
auto dtlsStateChangeCallback =
|
||||||
[this, weak_this = weak_from_this()](DtlsTransport::State transportState) {
|
[this, weak_this = weak_from_this()](DtlsTransport::State transportState) {
|
||||||
auto shared_this = weak_this.lock();
|
auto shared_this = weak_this.lock();
|
||||||
if (!shared_this)
|
if (!shared_this)
|
||||||
@ -224,7 +224,7 @@ shared_ptr<DtlsTransport> PeerConnection::initDtlsTransport() {
|
|||||||
// DTLS-SRTP
|
// DTLS-SRTP
|
||||||
transport = std::make_shared<DtlsSrtpTransport>(
|
transport = std::make_shared<DtlsSrtpTransport>(
|
||||||
lower, certificate, config.mtu, verifierCallback,
|
lower, certificate, config.mtu, verifierCallback,
|
||||||
weak_bind(&PeerConnection::forwardMedia, this, _1), stateChangeCallback);
|
weak_bind(&PeerConnection::forwardMedia, this, _1), dtlsStateChangeCallback);
|
||||||
#else
|
#else
|
||||||
PLOG_WARNING << "Ignoring media support (not compiled with media support)";
|
PLOG_WARNING << "Ignoring media support (not compiled with media support)";
|
||||||
#endif
|
#endif
|
||||||
@ -233,7 +233,7 @@ shared_ptr<DtlsTransport> PeerConnection::initDtlsTransport() {
|
|||||||
if (!transport) {
|
if (!transport) {
|
||||||
// DTLS only
|
// DTLS only
|
||||||
transport = std::make_shared<DtlsTransport>(lower, certificate, config.mtu,
|
transport = std::make_shared<DtlsTransport>(lower, certificate, config.mtu,
|
||||||
verifierCallback, stateChangeCallback);
|
verifierCallback, dtlsStateChangeCallback);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::atomic_store(&mDtlsTransport, transport);
|
std::atomic_store(&mDtlsTransport, transport);
|
||||||
@ -738,7 +738,7 @@ void PeerConnection::validateRemoteDescription(const Description &description) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void PeerConnection::processLocalDescription(Description description) {
|
void PeerConnection::processLocalDescription(Description description) {
|
||||||
const size_t localSctpPort = DEFAULT_SCTP_PORT;
|
const uint16_t localSctpPort = DEFAULT_SCTP_PORT;
|
||||||
const size_t localMaxMessageSize =
|
const size_t localMaxMessageSize =
|
||||||
config.maxMessageSize.value_or(DEFAULT_LOCAL_MAX_MESSAGE_SIZE);
|
config.maxMessageSize.value_or(DEFAULT_LOCAL_MAX_MESSAGE_SIZE);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user