mirror of
https://github.com/mii443/libdatachannel.git
synced 2025-08-23 15:48:03 +00:00
Compare commits
6 Commits
Author | SHA1 | Date | |
---|---|---|---|
38db6d7365 | |||
781d864b9f | |||
8cbcb35bf4 | |||
b63ec9cead | |||
aa6f87f467 | |||
eec7a761e8 |
@ -1,6 +1,6 @@
|
|||||||
cmake_minimum_required(VERSION 3.7)
|
cmake_minimum_required(VERSION 3.7)
|
||||||
project(libdatachannel
|
project(libdatachannel
|
||||||
VERSION 0.11.8
|
VERSION 0.11.10
|
||||||
LANGUAGES CXX)
|
LANGUAGES CXX)
|
||||||
set(PROJECT_DESCRIPTION "WebRTC Data Channels Library")
|
set(PROJECT_DESCRIPTION "WebRTC Data Channels Library")
|
||||||
|
|
||||||
|
@ -37,17 +37,6 @@
|
|||||||
#include <set>
|
#include <set>
|
||||||
#include <thread>
|
#include <thread>
|
||||||
|
|
||||||
#if __clang__ && defined(__APPLE__)
|
|
||||||
namespace {
|
|
||||||
template <typename To, typename From>
|
|
||||||
inline std::shared_ptr<To> reinterpret_pointer_cast(std::shared_ptr<From> const &ptr) noexcept {
|
|
||||||
return std::shared_ptr<To>(ptr, reinterpret_cast<To *>(ptr.get()));
|
|
||||||
}
|
|
||||||
} // namespace
|
|
||||||
#else
|
|
||||||
using std::reinterpret_pointer_cast;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static rtc::LogCounter COUNTER_MEDIA_TRUNCATED(plog::warning,
|
static rtc::LogCounter COUNTER_MEDIA_TRUNCATED(plog::warning,
|
||||||
"Number of RTP packets truncated over past second");
|
"Number of RTP packets truncated over past second");
|
||||||
static rtc::LogCounter
|
static rtc::LogCounter
|
||||||
@ -701,7 +690,7 @@ void PeerConnection::forwardMedia(message_ptr message) {
|
|||||||
std::set<uint32_t> ssrcs;
|
std::set<uint32_t> ssrcs;
|
||||||
size_t offset = 0;
|
size_t offset = 0;
|
||||||
while ((sizeof(rtc::RTCP_HEADER) + offset) <= message->size()) {
|
while ((sizeof(rtc::RTCP_HEADER) + offset) <= message->size()) {
|
||||||
auto header = reinterpret_cast<rtc::RTCP_HEADER *>(message->data() + offset);
|
auto header = reinterpret_cast<RTCP_HEADER *>(message->data() + offset);
|
||||||
if (header->lengthInBytes() > message->size() - offset) {
|
if (header->lengthInBytes() > message->size() - offset) {
|
||||||
COUNTER_MEDIA_TRUNCATED++;
|
COUNTER_MEDIA_TRUNCATED++;
|
||||||
break;
|
break;
|
||||||
@ -923,13 +912,14 @@ void PeerConnection::incomingTrack(Description::Media description) {
|
|||||||
void PeerConnection::openTracks() {
|
void PeerConnection::openTracks() {
|
||||||
#if RTC_ENABLE_MEDIA
|
#if RTC_ENABLE_MEDIA
|
||||||
if (auto transport = std::atomic_load(&mDtlsTransport)) {
|
if (auto transport = std::atomic_load(&mDtlsTransport)) {
|
||||||
auto srtpTransport = reinterpret_pointer_cast<DtlsSrtpTransport>(transport);
|
if (auto srtpTransport = std::dynamic_pointer_cast<DtlsSrtpTransport>(transport)) {
|
||||||
std::shared_lock lock(mTracksMutex); // read-only
|
std::shared_lock lock(mTracksMutex); // read-only
|
||||||
for (auto it = mTracks.begin(); it != mTracks.end(); ++it)
|
for (auto it = mTracks.begin(); it != mTracks.end(); ++it)
|
||||||
if (auto track = it->second.lock())
|
if (auto track = it->second.lock())
|
||||||
if (!track->isOpen())
|
if (!track->isOpen())
|
||||||
track->open(srtpTransport);
|
track->open(srtpTransport);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -67,7 +67,7 @@ void ThreadPool::join() {
|
|||||||
|
|
||||||
void ThreadPool::run() {
|
void ThreadPool::run() {
|
||||||
++mBusyWorkers;
|
++mBusyWorkers;
|
||||||
scope_guard([&]() { --mBusyWorkers; });
|
scope_guard guard([&]() { --mBusyWorkers; });
|
||||||
while (runOne()) {
|
while (runOne()) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -94,7 +94,7 @@ std::function<void()> ThreadPool::dequeue() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
--mBusyWorkers;
|
--mBusyWorkers;
|
||||||
scope_guard([&]() { ++mBusyWorkers; });
|
scope_guard guard([&]() { ++mBusyWorkers; });
|
||||||
mWaitingCondition.notify_all();
|
mWaitingCondition.notify_all();
|
||||||
if(time)
|
if(time)
|
||||||
mTasksCondition.wait_until(lock, *time);
|
mTasksCondition.wait_until(lock, *time);
|
||||||
|
@ -72,7 +72,7 @@ protected:
|
|||||||
std::function<void()> dequeue(); // returns null function if joining
|
std::function<void()> dequeue(); // returns null function if joining
|
||||||
|
|
||||||
std::vector<std::thread> mWorkers;
|
std::vector<std::thread> mWorkers;
|
||||||
int mBusyWorkers = 0;
|
std::atomic<int> mBusyWorkers = 0;
|
||||||
std::atomic<bool> mJoining = false;
|
std::atomic<bool> mJoining = false;
|
||||||
|
|
||||||
struct Task {
|
struct Task {
|
||||||
|
@ -326,10 +326,6 @@ int test_capi_connectivity_main() {
|
|||||||
deletePeer(peer2);
|
deletePeer(peer2);
|
||||||
sleep(1);
|
sleep(1);
|
||||||
|
|
||||||
// You may call rtcCleanup() when finished to free static resources
|
|
||||||
rtcCleanup();
|
|
||||||
sleep(1);
|
|
||||||
|
|
||||||
printf("Success\n");
|
printf("Success\n");
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
@ -177,10 +177,6 @@ int test_capi_track_main() {
|
|||||||
deletePeer(peer2);
|
deletePeer(peer2);
|
||||||
sleep(1);
|
sleep(1);
|
||||||
|
|
||||||
// You may call rtcCleanup() when finished to free static resources
|
|
||||||
rtcCleanup();
|
|
||||||
sleep(1);
|
|
||||||
|
|
||||||
printf("Success\n");
|
printf("Success\n");
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
@ -251,9 +251,5 @@ void test_connectivity() {
|
|||||||
pc2->close();
|
pc2->close();
|
||||||
this_thread::sleep_for(1s);
|
this_thread::sleep_for(1s);
|
||||||
|
|
||||||
// You may call rtc::Cleanup() when finished to free static resources
|
|
||||||
rtc::Cleanup();
|
|
||||||
this_thread::sleep_for(1s);
|
|
||||||
|
|
||||||
cout << "Success" << endl;
|
cout << "Success" << endl;
|
||||||
}
|
}
|
||||||
|
@ -143,9 +143,5 @@ void test_track() {
|
|||||||
pc2->close();
|
pc2->close();
|
||||||
this_thread::sleep_for(1s);
|
this_thread::sleep_for(1s);
|
||||||
|
|
||||||
// You may call rtc::Cleanup() when finished to free static resources
|
|
||||||
rtc::Cleanup();
|
|
||||||
this_thread::sleep_for(1s);
|
|
||||||
|
|
||||||
cout << "Success" << endl;
|
cout << "Success" << endl;
|
||||||
}
|
}
|
||||||
|
@ -258,9 +258,5 @@ void test_turn_connectivity() {
|
|||||||
pc2->close();
|
pc2->close();
|
||||||
this_thread::sleep_for(1s);
|
this_thread::sleep_for(1s);
|
||||||
|
|
||||||
// You may call rtc::Cleanup() when finished to free static resources
|
|
||||||
rtc::Cleanup();
|
|
||||||
this_thread::sleep_for(1s);
|
|
||||||
|
|
||||||
cout << "Success" << endl;
|
cout << "Success" << endl;
|
||||||
}
|
}
|
||||||
|
@ -78,10 +78,6 @@ void test_websocket() {
|
|||||||
ws->close();
|
ws->close();
|
||||||
this_thread::sleep_for(1s);
|
this_thread::sleep_for(1s);
|
||||||
|
|
||||||
// You may call rtc::Cleanup() when finished to free static resources
|
|
||||||
rtc::Cleanup();
|
|
||||||
this_thread::sleep_for(1s);
|
|
||||||
|
|
||||||
cout << "Success" << endl;
|
cout << "Success" << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user