Compare commits

...

6 Commits

10 changed files with 12 additions and 46 deletions

View File

@ -1,6 +1,6 @@
cmake_minimum_required(VERSION 3.7)
project(libdatachannel
VERSION 0.11.8
VERSION 0.11.10
LANGUAGES CXX)
set(PROJECT_DESCRIPTION "WebRTC Data Channels Library")

View File

@ -37,17 +37,6 @@
#include <set>
#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,
"Number of RTP packets truncated over past second");
static rtc::LogCounter
@ -701,7 +690,7 @@ void PeerConnection::forwardMedia(message_ptr message) {
std::set<uint32_t> ssrcs;
size_t offset = 0;
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) {
COUNTER_MEDIA_TRUNCATED++;
break;
@ -923,12 +912,13 @@ void PeerConnection::incomingTrack(Description::Media description) {
void PeerConnection::openTracks() {
#if RTC_ENABLE_MEDIA
if (auto transport = std::atomic_load(&mDtlsTransport)) {
auto srtpTransport = reinterpret_pointer_cast<DtlsSrtpTransport>(transport);
std::shared_lock lock(mTracksMutex); // read-only
for (auto it = mTracks.begin(); it != mTracks.end(); ++it)
if (auto track = it->second.lock())
if (!track->isOpen())
track->open(srtpTransport);
if (auto srtpTransport = std::dynamic_pointer_cast<DtlsSrtpTransport>(transport)) {
std::shared_lock lock(mTracksMutex); // read-only
for (auto it = mTracks.begin(); it != mTracks.end(); ++it)
if (auto track = it->second.lock())
if (!track->isOpen())
track->open(srtpTransport);
}
}
#endif
}

View File

@ -67,7 +67,7 @@ void ThreadPool::join() {
void ThreadPool::run() {
++mBusyWorkers;
scope_guard([&]() { --mBusyWorkers; });
scope_guard guard([&]() { --mBusyWorkers; });
while (runOne()) {
}
}
@ -94,7 +94,7 @@ std::function<void()> ThreadPool::dequeue() {
}
--mBusyWorkers;
scope_guard([&]() { ++mBusyWorkers; });
scope_guard guard([&]() { ++mBusyWorkers; });
mWaitingCondition.notify_all();
if(time)
mTasksCondition.wait_until(lock, *time);

View File

@ -72,7 +72,7 @@ protected:
std::function<void()> dequeue(); // returns null function if joining
std::vector<std::thread> mWorkers;
int mBusyWorkers = 0;
std::atomic<int> mBusyWorkers = 0;
std::atomic<bool> mJoining = false;
struct Task {

View File

@ -326,10 +326,6 @@ int test_capi_connectivity_main() {
deletePeer(peer2);
sleep(1);
// You may call rtcCleanup() when finished to free static resources
rtcCleanup();
sleep(1);
printf("Success\n");
return 0;

View File

@ -177,10 +177,6 @@ int test_capi_track_main() {
deletePeer(peer2);
sleep(1);
// You may call rtcCleanup() when finished to free static resources
rtcCleanup();
sleep(1);
printf("Success\n");
return 0;

View File

@ -251,9 +251,5 @@ void test_connectivity() {
pc2->close();
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;
}

View File

@ -143,9 +143,5 @@ void test_track() {
pc2->close();
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;
}

View File

@ -258,9 +258,5 @@ void test_turn_connectivity() {
pc2->close();
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;
}

View File

@ -78,10 +78,6 @@ void test_websocket() {
ws->close();
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;
}