mirror of
https://github.com/mii443/libdatachannel.git
synced 2025-08-23 15:48:03 +00:00
Compare commits
7 Commits
Author | SHA1 | Date | |
---|---|---|---|
679ecfc066 | |||
4e3ea69073 | |||
b79c886480 | |||
08da691911 | |||
754568506a | |||
7ac351d1b9 | |||
6d5cecbca1 |
@ -1,6 +1,6 @@
|
|||||||
cmake_minimum_required(VERSION 3.7)
|
cmake_minimum_required(VERSION 3.7)
|
||||||
project(libdatachannel
|
project(libdatachannel
|
||||||
VERSION 0.10.4
|
VERSION 0.10.5
|
||||||
LANGUAGES CXX)
|
LANGUAGES CXX)
|
||||||
set(PROJECT_DESCRIPTION "WebRTC Data Channels Library")
|
set(PROJECT_DESCRIPTION "WebRTC Data Channels Library")
|
||||||
|
|
||||||
@ -33,6 +33,7 @@ endif()
|
|||||||
|
|
||||||
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
|
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
|
||||||
set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake/Modules)
|
set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake/Modules)
|
||||||
|
set(BUILD_SHARED_LIBS OFF) # to force usrsctp to be built static
|
||||||
|
|
||||||
if(WIN32)
|
if(WIN32)
|
||||||
add_definitions(-DWIN32_LEAN_AND_MEAN)
|
add_definitions(-DWIN32_LEAN_AND_MEAN)
|
||||||
|
8
Jamfile
8
Jamfile
@ -15,9 +15,9 @@ lib libdatachannel
|
|||||||
: # requirements
|
: # requirements
|
||||||
<cxxstd>17
|
<cxxstd>17
|
||||||
<include>./include/rtc
|
<include>./include/rtc
|
||||||
<define>USE_NICE=0
|
|
||||||
<define>RTC_ENABLE_MEDIA=0
|
<define>RTC_ENABLE_MEDIA=0
|
||||||
<define>RTC_ENABLE_WEBSOCKET=0
|
<define>RTC_ENABLE_WEBSOCKET=0
|
||||||
|
<define>USE_NICE=0
|
||||||
<toolset>msvc:<define>WIN32_LEAN_AND_MEAN
|
<toolset>msvc:<define>WIN32_LEAN_AND_MEAN
|
||||||
<toolset>msvc:<define>NOMINMAX
|
<toolset>msvc:<define>NOMINMAX
|
||||||
<toolset>msvc:<define>_CRT_SECURE_NO_WARNINGS
|
<toolset>msvc:<define>_CRT_SECURE_NO_WARNINGS
|
||||||
@ -32,6 +32,8 @@ lib libdatachannel
|
|||||||
<link>static
|
<link>static
|
||||||
: # usage requirements
|
: # usage requirements
|
||||||
<include>./include
|
<include>./include
|
||||||
|
<define>RTC_ENABLE_MEDIA=0
|
||||||
|
<define>RTC_ENABLE_WEBSOCKET=0
|
||||||
<library>/libdatachannel//plog
|
<library>/libdatachannel//plog
|
||||||
<toolset>gcc:<cxxflags>"-pthread -Wno-pedantic -Wno-unused-parameter -Wno-unused-variable"
|
<toolset>gcc:<cxxflags>"-pthread -Wno-pedantic -Wno-unused-parameter -Wno-unused-variable"
|
||||||
<toolset>clang:<cxxflags>"-pthread -Wno-pedantic -Wno-unused-parameter -Wno-unused-variable"
|
<toolset>clang:<cxxflags>"-pthread -Wno-pedantic -Wno-unused-parameter -Wno-unused-variable"
|
||||||
@ -94,7 +96,7 @@ rule make_libusrsctp ( targets * : sources * : properties * )
|
|||||||
}
|
}
|
||||||
actions make_libusrsctp
|
actions make_libusrsctp
|
||||||
{
|
{
|
||||||
(cd $(CWD)/deps/usrsctp && mkdir -p $(BUILD_DIR) && cd $(BUILD_DIR) && cmake -DCMAKE_BUILD_TYPE=$(VARIANT) -DCMAKE_C_FLAGS="-fPIC -Wno-unknown-warning-option -Wno-format-truncation" .. && make -j2 usrsctp-static)
|
(cd $(CWD)/deps/usrsctp && mkdir -p $(BUILD_DIR) && cd $(BUILD_DIR) && cmake -DCMAKE_BUILD_TYPE=$(VARIANT) -DCMAKE_C_FLAGS="-fPIC -Wno-unknown-warning-option -Wno-format-truncation" -Dsctp_build_shared_lib=0 -Dsctp_build_programs=0 .. && make -j2 usrsctp)
|
||||||
cp $(CWD)/deps/usrsctp/$(BUILD_DIR)/usrsctplib/libusrsctp.a $(<)
|
cp $(CWD)/deps/usrsctp/$(BUILD_DIR)/usrsctplib/libusrsctp.a $(<)
|
||||||
}
|
}
|
||||||
rule make_libusrsctp_msvc ( targets * : sources * : properties * )
|
rule make_libusrsctp_msvc ( targets * : sources * : properties * )
|
||||||
@ -109,7 +111,7 @@ actions make_libusrsctp_msvc
|
|||||||
cd $(CWD)/deps/usrsctp
|
cd $(CWD)/deps/usrsctp
|
||||||
mkdir $(BUILD_DIR)
|
mkdir $(BUILD_DIR)
|
||||||
cd $(BUILD_DIR)
|
cd $(BUILD_DIR)
|
||||||
cmake -G "Visual Studio 16 2019" ..
|
cmake -G "Visual Studio 16 2019" -Dsctp_build_shared_lib=0 -Dsctp_build_programs=0 ..
|
||||||
msbuild usrsctplib.sln /property:Configuration=$(VARIANT)
|
msbuild usrsctplib.sln /property:Configuration=$(VARIANT)
|
||||||
cd %OLDD%
|
cd %OLDD%
|
||||||
cp $(CWD)/deps/usrsctp/$(BUILD_DIR)/usrsctplib/Release/usrsctp.lib $(<)
|
cp $(CWD)/deps/usrsctp/$(BUILD_DIR)/usrsctplib/Release/usrsctp.lib $(<)
|
||||||
|
@ -117,9 +117,9 @@ void Candidate::parse(string candidate) {
|
|||||||
mTransportType = TransportType::Udp;
|
mTransportType = TransportType::Udp;
|
||||||
} else if (transport == "TCP" || transport == "tcp") {
|
} else if (transport == "TCP" || transport == "tcp") {
|
||||||
// Peek tail to find TCP type
|
// Peek tail to find TCP type
|
||||||
std::istringstream iss(mTail);
|
std::istringstream tiss(mTail);
|
||||||
string tcptype_, tcptype;
|
string tcptype_, tcptype;
|
||||||
if (iss >> tcptype_ >> tcptype && tcptype_ == "tcptype") {
|
if (tiss >> tcptype_ >> tcptype && tcptype_ == "tcptype") {
|
||||||
if (auto it = TcpTypeMap.find(tcptype); it != TcpTypeMap.end())
|
if (auto it = TcpTypeMap.find(tcptype); it != TcpTypeMap.end())
|
||||||
mTransportType = it->second;
|
mTransportType = it->second;
|
||||||
else
|
else
|
||||||
|
@ -649,10 +649,10 @@ void PeerConnection::forwardMessage(message_ptr message) {
|
|||||||
stream % 2 == remoteParity) {
|
stream % 2 == remoteParity) {
|
||||||
|
|
||||||
channel = std::make_shared<NegociatedDataChannel>(shared_from_this(), sctpTransport,
|
channel = std::make_shared<NegociatedDataChannel>(shared_from_this(), sctpTransport,
|
||||||
message->stream);
|
stream);
|
||||||
channel->onOpen(weak_bind(&PeerConnection::triggerDataChannel, this,
|
channel->onOpen(weak_bind(&PeerConnection::triggerDataChannel, this,
|
||||||
weak_ptr<DataChannel>{channel}));
|
weak_ptr<DataChannel>{channel}));
|
||||||
mDataChannels.emplace(message->stream, channel);
|
mDataChannels.emplace(stream, channel);
|
||||||
} else {
|
} else {
|
||||||
// Invalid, close the DataChannel
|
// Invalid, close the DataChannel
|
||||||
sctpTransport->closeStream(message->stream);
|
sctpTransport->closeStream(message->stream);
|
||||||
@ -1137,7 +1137,7 @@ void PeerConnection::processRemoteCandidate(Candidate candidate) {
|
|||||||
} else {
|
} else {
|
||||||
// We might need a lookup, do it asynchronously
|
// We might need a lookup, do it asynchronously
|
||||||
// We don't use the thread pool because we have no control on the timeout
|
// We don't use the thread pool because we have no control on the timeout
|
||||||
if (auto iceTransport = std::atomic_load(&mIceTransport)) {
|
if ((iceTransport = std::atomic_load(&mIceTransport))) {
|
||||||
weak_ptr<IceTransport> weakIceTransport{iceTransport};
|
weak_ptr<IceTransport> weakIceTransport{iceTransport};
|
||||||
std::thread t([weakIceTransport, candidate = std::move(candidate)]() mutable {
|
std::thread t([weakIceTransport, candidate = std::move(candidate)]() mutable {
|
||||||
if (candidate.resolve(Candidate::ResolveMode::Lookup))
|
if (candidate.resolve(Candidate::ResolveMode::Lookup))
|
||||||
|
@ -18,15 +18,26 @@
|
|||||||
|
|
||||||
#include "threadpool.hpp"
|
#include "threadpool.hpp"
|
||||||
|
|
||||||
|
#include <cstdlib>
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
void joinThreadPoolInstance() {
|
||||||
|
rtc::ThreadPool::Instance().join();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
namespace rtc {
|
namespace rtc {
|
||||||
|
|
||||||
ThreadPool &ThreadPool::Instance() {
|
ThreadPool &ThreadPool::Instance() {
|
||||||
// Init handles joining on cleanup
|
|
||||||
static ThreadPool *instance = new ThreadPool;
|
static ThreadPool *instance = new ThreadPool;
|
||||||
return *instance;
|
return *instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
ThreadPool::~ThreadPool() { join(); }
|
ThreadPool::ThreadPool() {
|
||||||
|
std::atexit(joinThreadPoolInstance);
|
||||||
|
}
|
||||||
|
|
||||||
|
ThreadPool::~ThreadPool() {}
|
||||||
|
|
||||||
int ThreadPool::count() const {
|
int ThreadPool::count() const {
|
||||||
std::unique_lock lock(mWorkersMutex);
|
std::unique_lock lock(mWorkersMutex);
|
||||||
|
@ -56,7 +56,7 @@ public:
|
|||||||
auto enqueue(F &&f, Args &&... args) -> invoke_future_t<F, Args...>;
|
auto enqueue(F &&f, Args &&... args) -> invoke_future_t<F, Args...>;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
ThreadPool() = default;
|
ThreadPool();
|
||||||
~ThreadPool();
|
~ThreadPool();
|
||||||
|
|
||||||
std::function<void()> dequeue(); // returns null function if joining
|
std::function<void()> dequeue(); // returns null function if joining
|
||||||
|
Reference in New Issue
Block a user