Compare commits

...

5 Commits

3 changed files with 28 additions and 7 deletions

View File

@ -1,7 +1,7 @@
cmake_minimum_required(VERSION 3.7) cmake_minimum_required(VERSION 3.7)
project(libdatachannel project(libdatachannel
DESCRIPTION "WebRTC Data Channels Library" DESCRIPTION "WebRTC Data Channels Library"
VERSION 0.7.1 VERSION 0.7.2
LANGUAGES CXX) LANGUAGES CXX)
# Options # Options

View File

@ -82,6 +82,11 @@ std::optional<Description> PeerConnection::remoteDescription() const {
} }
void PeerConnection::setLocalDescription(std::optional<Description> description) { void PeerConnection::setLocalDescription(std::optional<Description> description) {
if (description)
PLOG_VERBOSE << "Setting local description: " << string(*description);
else
PLOG_VERBOSE << "Setting default local description";
if (auto iceTransport = std::atomic_load(&mIceTransport)) { if (auto iceTransport = std::atomic_load(&mIceTransport)) {
throw std::logic_error("Local description is already set"); throw std::logic_error("Local description is already set");
} else { } else {
@ -98,6 +103,8 @@ void PeerConnection::setLocalDescription(std::optional<Description> description)
} }
void PeerConnection::setRemoteDescription(Description description) { void PeerConnection::setRemoteDescription(Description description) {
PLOG_VERBOSE << "Setting remote description: " << string(description);
description.hintType(localDescription() ? Description::Type::Answer : Description::Type::Offer); description.hintType(localDescription() ? Description::Type::Answer : Description::Type::Offer);
auto type = description.type(); auto type = description.type();
auto remoteCandidates = description.extractCandidates(); // Candidates will be added at the end auto remoteCandidates = description.extractCandidates(); // Candidates will be added at the end
@ -143,6 +150,7 @@ void PeerConnection::setRemoteDescription(Description description) {
} }
void PeerConnection::addRemoteCandidate(Candidate candidate) { void PeerConnection::addRemoteCandidate(Candidate candidate) {
PLOG_VERBOSE << "Adding remote candidate: " << string(candidate);
auto iceTransport = std::atomic_load(&mIceTransport); auto iceTransport = std::atomic_load(&mIceTransport);
if (!mRemoteDescription || !iceTransport) if (!mRemoteDescription || !iceTransport)

View File

@ -676,8 +676,16 @@ std::optional<milliseconds> SctpTransport::rtt() {
int SctpTransport::RecvCallback(struct socket *sock, union sctp_sockstore addr, void *data, int SctpTransport::RecvCallback(struct socket *sock, union sctp_sockstore addr, void *data,
size_t len, struct sctp_rcvinfo recv_info, int flags, void *ptr) { size_t len, struct sctp_rcvinfo recv_info, int flags, void *ptr) {
int ret = static_cast<SctpTransport *>(ptr)->handleRecv( auto *transport = static_cast<SctpTransport *>(ptr);
sock, addr, static_cast<const byte *>(data), len, recv_info, flags);
std::shared_lock lock(InstancesMutex);
if (Instances.find(transport) == Instances.end()) {
free(data);
return -1;
}
int ret =
transport->handleRecv(sock, addr, static_cast<const byte *>(data), len, recv_info, flags);
free(data); free(data);
return ret; return ret;
} }
@ -692,8 +700,6 @@ int SctpTransport::SendCallback(struct socket *sock, uint32_t sb_free) {
void *ptr = sconn->sconn_addr; void *ptr = sconn->sconn_addr;
auto *transport = static_cast<SctpTransport *>(ptr); auto *transport = static_cast<SctpTransport *>(ptr);
// Workaround for sctplab/usrsctp#405: Send callback is invoked on already closed socket
// https://github.com/sctplab/usrsctp/issues/405
std::shared_lock lock(InstancesMutex); std::shared_lock lock(InstancesMutex);
if (Instances.find(transport) == Instances.end()) if (Instances.find(transport) == Instances.end())
return -1; return -1;
@ -702,8 +708,15 @@ int SctpTransport::SendCallback(struct socket *sock, uint32_t sb_free) {
} }
int SctpTransport::WriteCallback(void *ptr, void *data, size_t len, uint8_t tos, uint8_t set_df) { int SctpTransport::WriteCallback(void *ptr, void *data, size_t len, uint8_t tos, uint8_t set_df) {
return static_cast<SctpTransport *>(ptr)->handleWrite(static_cast<byte *>(data), len, tos, auto *transport = static_cast<SctpTransport *>(ptr);
set_df);
// Workaround for sctplab/usrsctp#405: Send callback is invoked on already closed socket
// https://github.com/sctplab/usrsctp/issues/405
std::shared_lock lock(InstancesMutex);
if (Instances.find(transport) == Instances.end())
return -1;
return transport->handleWrite(static_cast<byte *>(data), len, tos, set_df);
} }
} // namespace rtc } // namespace rtc