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)
|
||||
project(libdatachannel
|
||||
VERSION 0.10.4
|
||||
VERSION 0.10.5
|
||||
LANGUAGES CXX)
|
||||
set(PROJECT_DESCRIPTION "WebRTC Data Channels Library")
|
||||
|
||||
@ -33,6 +33,7 @@ endif()
|
||||
|
||||
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
|
||||
set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake/Modules)
|
||||
set(BUILD_SHARED_LIBS OFF) # to force usrsctp to be built static
|
||||
|
||||
if(WIN32)
|
||||
add_definitions(-DWIN32_LEAN_AND_MEAN)
|
||||
|
8
Jamfile
8
Jamfile
@ -15,9 +15,9 @@ lib libdatachannel
|
||||
: # requirements
|
||||
<cxxstd>17
|
||||
<include>./include/rtc
|
||||
<define>USE_NICE=0
|
||||
<define>RTC_ENABLE_MEDIA=0
|
||||
<define>RTC_ENABLE_WEBSOCKET=0
|
||||
<define>USE_NICE=0
|
||||
<toolset>msvc:<define>WIN32_LEAN_AND_MEAN
|
||||
<toolset>msvc:<define>NOMINMAX
|
||||
<toolset>msvc:<define>_CRT_SECURE_NO_WARNINGS
|
||||
@ -32,6 +32,8 @@ lib libdatachannel
|
||||
<link>static
|
||||
: # usage requirements
|
||||
<include>./include
|
||||
<define>RTC_ENABLE_MEDIA=0
|
||||
<define>RTC_ENABLE_WEBSOCKET=0
|
||||
<library>/libdatachannel//plog
|
||||
<toolset>gcc:<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
|
||||
{
|
||||
(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 $(<)
|
||||
}
|
||||
rule make_libusrsctp_msvc ( targets * : sources * : properties * )
|
||||
@ -109,7 +111,7 @@ actions make_libusrsctp_msvc
|
||||
cd $(CWD)/deps/usrsctp
|
||||
mkdir $(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)
|
||||
cd %OLDD%
|
||||
cp $(CWD)/deps/usrsctp/$(BUILD_DIR)/usrsctplib/Release/usrsctp.lib $(<)
|
||||
|
@ -117,9 +117,9 @@ void Candidate::parse(string candidate) {
|
||||
mTransportType = TransportType::Udp;
|
||||
} else if (transport == "TCP" || transport == "tcp") {
|
||||
// Peek tail to find TCP type
|
||||
std::istringstream iss(mTail);
|
||||
std::istringstream tiss(mTail);
|
||||
string tcptype_, tcptype;
|
||||
if (iss >> tcptype_ >> tcptype && tcptype_ == "tcptype") {
|
||||
if (tiss >> tcptype_ >> tcptype && tcptype_ == "tcptype") {
|
||||
if (auto it = TcpTypeMap.find(tcptype); it != TcpTypeMap.end())
|
||||
mTransportType = it->second;
|
||||
else
|
||||
|
@ -649,10 +649,10 @@ void PeerConnection::forwardMessage(message_ptr message) {
|
||||
stream % 2 == remoteParity) {
|
||||
|
||||
channel = std::make_shared<NegociatedDataChannel>(shared_from_this(), sctpTransport,
|
||||
message->stream);
|
||||
stream);
|
||||
channel->onOpen(weak_bind(&PeerConnection::triggerDataChannel, this,
|
||||
weak_ptr<DataChannel>{channel}));
|
||||
mDataChannels.emplace(message->stream, channel);
|
||||
mDataChannels.emplace(stream, channel);
|
||||
} else {
|
||||
// Invalid, close the DataChannel
|
||||
sctpTransport->closeStream(message->stream);
|
||||
@ -1137,7 +1137,7 @@ void PeerConnection::processRemoteCandidate(Candidate candidate) {
|
||||
} else {
|
||||
// We might need a lookup, do it asynchronously
|
||||
// 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};
|
||||
std::thread t([weakIceTransport, candidate = std::move(candidate)]() mutable {
|
||||
if (candidate.resolve(Candidate::ResolveMode::Lookup))
|
||||
|
@ -18,15 +18,26 @@
|
||||
|
||||
#include "threadpool.hpp"
|
||||
|
||||
#include <cstdlib>
|
||||
|
||||
namespace {
|
||||
void joinThreadPoolInstance() {
|
||||
rtc::ThreadPool::Instance().join();
|
||||
}
|
||||
}
|
||||
|
||||
namespace rtc {
|
||||
|
||||
ThreadPool &ThreadPool::Instance() {
|
||||
// Init handles joining on cleanup
|
||||
static ThreadPool *instance = new ThreadPool;
|
||||
return *instance;
|
||||
}
|
||||
|
||||
ThreadPool::~ThreadPool() { join(); }
|
||||
ThreadPool::ThreadPool() {
|
||||
std::atexit(joinThreadPoolInstance);
|
||||
}
|
||||
|
||||
ThreadPool::~ThreadPool() {}
|
||||
|
||||
int ThreadPool::count() const {
|
||||
std::unique_lock lock(mWorkersMutex);
|
||||
|
@ -56,7 +56,7 @@ public:
|
||||
auto enqueue(F &&f, Args &&... args) -> invoke_future_t<F, Args...>;
|
||||
|
||||
protected:
|
||||
ThreadPool() = default;
|
||||
ThreadPool();
|
||||
~ThreadPool();
|
||||
|
||||
std::function<void()> dequeue(); // returns null function if joining
|
||||
|
Reference in New Issue
Block a user