mirror of
https://github.com/mii443/libdatachannel.git
synced 2025-08-23 15:48:03 +00:00
Compare commits
8 Commits
Author | SHA1 | Date | |
---|---|---|---|
c37c88543d | |||
011bfbe46f | |||
de2ac6c0c2 | |||
75619babd7 | |||
fe9a34905b | |||
b88f1f5e72 | |||
ab7d7fefe0 | |||
e592fcf217 |
@ -1,6 +1,6 @@
|
||||
cmake_minimum_required(VERSION 3.7)
|
||||
project(libdatachannel
|
||||
VERSION 0.11.2
|
||||
VERSION 0.11.4
|
||||
LANGUAGES CXX)
|
||||
set(PROJECT_DESCRIPTION "WebRTC Data Channels Library")
|
||||
|
||||
|
2
deps/usrsctp
vendored
2
deps/usrsctp
vendored
Submodule deps/usrsctp updated: 2e754d5822...07f871bda2
@ -298,13 +298,16 @@ public:
|
||||
|
||||
private:
|
||||
uint8_t _length;
|
||||
char _text;
|
||||
char _text[1];
|
||||
|
||||
public:
|
||||
inline std::string text() const { return std::string(&_text, _length); }
|
||||
inline std::string text() const { return std::string(_text, _length); }
|
||||
inline void setText(std::string text) {
|
||||
_length = text.length();
|
||||
memcpy(&_text, text.data(), _length);
|
||||
if(text.size() > 0xFF)
|
||||
throw std::invalid_argument("text is too long");
|
||||
|
||||
_length = uint8_t(text.size());
|
||||
memcpy(_text, text.data(), text.size());
|
||||
}
|
||||
|
||||
inline uint8_t length() { return _length; }
|
||||
@ -334,12 +337,12 @@ public:
|
||||
return reinterpret_cast<RTCP_SDES_ITEM *>(base);
|
||||
}
|
||||
|
||||
long safelyCountChunkSize(unsigned int maxChunkSize) {
|
||||
long safelyCountChunkSize(size_t maxChunkSize) {
|
||||
if (maxChunkSize < RTCP_SDES_CHUNK::size({})) {
|
||||
// chunk is truncated
|
||||
return -1;
|
||||
} else {
|
||||
unsigned int size = sizeof(SSRC);
|
||||
size_t size = sizeof(SSRC);
|
||||
unsigned int i = 0;
|
||||
// We can always access first 4 bytes of first item (in case of no items there will be 4
|
||||
// null bytes)
|
||||
@ -407,7 +410,7 @@ public:
|
||||
auto chunk = getChunk(i);
|
||||
chunkSize += chunk->getSize();
|
||||
}
|
||||
uint16_t length = (sizeof(header) + chunkSize) / 4 - 1;
|
||||
uint16_t length = uint16_t((sizeof(header) + chunkSize) / 4 - 1);
|
||||
header.prepareHeader(202, chunkCount, length);
|
||||
}
|
||||
|
||||
@ -629,10 +632,10 @@ struct RTCP_NACK_PART {
|
||||
std::vector<uint16_t> getSequenceNumbers() {
|
||||
std::vector<uint16_t> result{};
|
||||
result.reserve(17);
|
||||
auto pid = getPID();
|
||||
uint16_t pid = getPID();
|
||||
result.push_back(pid);
|
||||
auto bitmask = getBLP();
|
||||
auto i = pid + 1;
|
||||
uint16_t bitmask = getBLP();
|
||||
uint16_t i = pid + 1;
|
||||
while (bitmask > 0) {
|
||||
if (bitmask & 0x1) {
|
||||
result.push_back(i);
|
||||
@ -673,9 +676,9 @@ public:
|
||||
(*fciCount)++;
|
||||
return true;
|
||||
} else {
|
||||
// TODO SPEEED!
|
||||
auto blp = parts[(*fciCount) - 1].getBLP();
|
||||
auto newBit = 1u << (unsigned int)(missingPacket - (1 + *fciPID));
|
||||
// TODO SPEED!
|
||||
uint16_t blp = parts[(*fciCount) - 1].getBLP();
|
||||
uint16_t newBit = uint16_t(1u << (missingPacket - (1 + *fciPID)));
|
||||
parts[(*fciCount) - 1].setBLP(blp | newBit);
|
||||
return false;
|
||||
}
|
||||
|
@ -667,6 +667,8 @@ void PeerConnection::forwardMessage(message_ptr message) {
|
||||
stream);
|
||||
channel->onOpen(weak_bind(&PeerConnection::triggerDataChannel, this,
|
||||
weak_ptr<DataChannel>{channel}));
|
||||
|
||||
std::unique_lock lock(mDataChannelsMutex); // we are going to emplace
|
||||
mDataChannels.emplace(stream, channel);
|
||||
} else {
|
||||
// Invalid, close the DataChannel
|
||||
|
@ -349,6 +349,10 @@ void SctpTransport::incoming(message_ptr message) {
|
||||
}
|
||||
|
||||
PLOG_VERBOSE << "Incoming size=" << message->size();
|
||||
|
||||
// TODO: There seems to be a possible data race between usrsctp_sendv() and usrsctp_conninput()
|
||||
// As a mitigation, lock the send mutex before calling usrsctp_conninput()
|
||||
std::lock_guard lock(mSendMutex);
|
||||
usrsctp_conninput(this, message->data(), message->size(), 0);
|
||||
}
|
||||
|
||||
|
@ -43,8 +43,7 @@ int ThreadPool::count() const {
|
||||
}
|
||||
|
||||
void ThreadPool::spawn(int count) {
|
||||
std::scoped_lock lock(mMutex, mWorkersMutex);
|
||||
mJoining = false;
|
||||
std::unique_lock lock(mWorkersMutex);
|
||||
while (count-- > 0)
|
||||
mWorkers.emplace_back(std::bind(&ThreadPool::run, this));
|
||||
}
|
||||
@ -62,6 +61,8 @@ void ThreadPool::join() {
|
||||
w.join();
|
||||
|
||||
mWorkers.clear();
|
||||
|
||||
mJoining = false;
|
||||
}
|
||||
|
||||
void ThreadPool::run() {
|
||||
|
@ -73,7 +73,7 @@ protected:
|
||||
|
||||
std::vector<std::thread> mWorkers;
|
||||
int mWaitingWorkers = 0;
|
||||
bool mJoining = false;
|
||||
std::atomic<bool> mJoining = false;
|
||||
|
||||
struct Task {
|
||||
clock::time_point time;
|
||||
|
Reference in New Issue
Block a user