mirror of
https://git.jami.net/savoirfairelinux/jami-daemon.git
synced 2025-08-12 22:09:25 +08:00
ice_transport: revert last change
Change-Id: Ie810524fa960832154be0319d1c4e2383e87eb90
This commit is contained in:
@ -82,16 +82,21 @@ class IceLock
|
||||
|
||||
public:
|
||||
IceLock(pj_ice_strans* strans)
|
||||
: lk_(pj_ice_strans_get_grp_lock(strans))
|
||||
{
|
||||
: lk_(pj_ice_strans_get_grp_lock(strans)) {
|
||||
lock();
|
||||
}
|
||||
|
||||
~IceLock() { unlock(); }
|
||||
~IceLock() {
|
||||
unlock();
|
||||
}
|
||||
|
||||
void lock() { pj_grp_lock_acquire(lk_); }
|
||||
void lock() {
|
||||
pj_grp_lock_acquire(lk_);
|
||||
}
|
||||
|
||||
void unlock() { pj_grp_lock_release(lk_); }
|
||||
void unlock() {
|
||||
pj_grp_lock_release(lk_);
|
||||
}
|
||||
};
|
||||
|
||||
class IceTransport::Impl
|
||||
@ -376,9 +381,6 @@ IceTransport::Impl::~Impl()
|
||||
}
|
||||
|
||||
JAMI_DBG("[ice:%p] done destroying", this);
|
||||
|
||||
if (scb)
|
||||
scb();
|
||||
}
|
||||
|
||||
void
|
||||
@ -509,6 +511,8 @@ IceTransport::Impl::initIceInstance(const IceTransportOptions& options)
|
||||
std::lock_guard lk(tr->sendDataMutex_);
|
||||
tr->destroying_ = true;
|
||||
tr->waitDataCv_.notify_all();
|
||||
if (tr->scb)
|
||||
tr->scb();
|
||||
} else {
|
||||
JAMI_WARN("null IceTransport");
|
||||
}
|
||||
@ -694,9 +698,9 @@ IceTransport::Impl::checkEventQueue(int maxEventToPoll)
|
||||
void
|
||||
IceTransport::Impl::onComplete(pj_ice_strans*, pj_ice_strans_op op, pj_status_t status)
|
||||
{
|
||||
const char* opname = op == PJ_ICE_STRANS_OP_INIT ? "initialization"
|
||||
: op == PJ_ICE_STRANS_OP_NEGOTIATION ? "negotiation"
|
||||
: "unknown_op";
|
||||
const char* opname = op == PJ_ICE_STRANS_OP_INIT
|
||||
? "initialization"
|
||||
: op == PJ_ICE_STRANS_OP_NEGOTIATION ? "negotiation" : "unknown_op";
|
||||
|
||||
const bool done = status == PJ_SUCCESS;
|
||||
if (done) {
|
||||
@ -744,7 +748,7 @@ IceTransport::Impl::link() const
|
||||
std::ostringstream out;
|
||||
for (unsigned strm = 1; strm <= streamsCount_ * compCountPerStream_; strm++) {
|
||||
auto absIdx = strm;
|
||||
auto comp = (strm + 1) / compCountPerStream_;
|
||||
auto comp = (strm+1)/compCountPerStream_;
|
||||
auto laddr = getLocalAddress(absIdx);
|
||||
auto raddr = getRemoteAddress(absIdx);
|
||||
|
||||
@ -766,6 +770,7 @@ IceTransport::Impl::setInitiatorSession()
|
||||
JAMI_DBG("[ice:%p] as master", this);
|
||||
initiatorSession_ = true;
|
||||
if (_isInitialized()) {
|
||||
|
||||
auto status = pj_ice_strans_change_role(icest_, PJ_ICE_SESS_ROLE_CONTROLLING);
|
||||
if (status != PJ_SUCCESS) {
|
||||
last_errmsg_ = sip_utils::sip_strerror(status);
|
||||
@ -783,6 +788,7 @@ IceTransport::Impl::setSlaveSession()
|
||||
JAMI_DBG("[ice:%p] as slave", this);
|
||||
initiatorSession_ = false;
|
||||
if (_isInitialized()) {
|
||||
|
||||
auto status = pj_ice_strans_change_role(icest_, PJ_ICE_SESS_ROLE_CONTROLLED);
|
||||
if (status != PJ_SUCCESS) {
|
||||
last_errmsg_ = sip_utils::sip_strerror(status);
|
||||
@ -1096,8 +1102,7 @@ IceTransport::Impl::onReceiveData(unsigned comp_id, void* pkt, pj_size_t size)
|
||||
|
||||
jami_tracepoint_if_enabled(ice_transport_recv,
|
||||
reinterpret_cast<uint64_t>(this),
|
||||
comp_id,
|
||||
size,
|
||||
comp_id, size,
|
||||
getRemoteAddress(comp_id).toString().c_str());
|
||||
if (size == 0)
|
||||
return;
|
||||
@ -1125,8 +1130,8 @@ IceTransport::Impl::_waitForInitialization(std::chrono::milliseconds timeout)
|
||||
IceLock lk(icest_);
|
||||
|
||||
if (not iceCV_.wait_for(lk, timeout, [this] {
|
||||
return threadTerminateFlags_ or _isInitialized() or _isFailed();
|
||||
})) {
|
||||
return threadTerminateFlags_ or _isInitialized() or _isFailed();
|
||||
})) {
|
||||
JAMI_WARN("[ice:%p] waitForInitialization: timeout", this);
|
||||
return false;
|
||||
}
|
||||
@ -1151,7 +1156,8 @@ IceTransport::initIceInstance(const IceTransportOptions& options)
|
||||
{
|
||||
pimpl_->initIceInstance(options);
|
||||
|
||||
jami_tracepoint(ice_transport_context, reinterpret_cast<uint64_t>(this));
|
||||
jami_tracepoint(ice_transport_context,
|
||||
reinterpret_cast<uint64_t>(this));
|
||||
}
|
||||
|
||||
bool
|
||||
@ -1686,9 +1692,7 @@ IceTransport::send(unsigned compId, const unsigned char* buf, size_t len)
|
||||
|
||||
jami_tracepoint(ice_transport_send,
|
||||
reinterpret_cast<uint64_t>(this),
|
||||
compId,
|
||||
len,
|
||||
remote.toString().c_str());
|
||||
compId, len, remote.toString().c_str());
|
||||
|
||||
auto status = pj_ice_strans_sendto2(pimpl_->icest_,
|
||||
compId,
|
||||
@ -1703,7 +1707,8 @@ IceTransport::send(unsigned compId, const unsigned char* buf, size_t len)
|
||||
// NOTE; because we are in TCP, the sent size will count the header (2
|
||||
// bytes length).
|
||||
pimpl_->waitDataCv_.wait(dlk, [&] {
|
||||
return pimpl_->lastSentLen_ >= static_cast<pj_size_t>(len) or pimpl_->destroying_;
|
||||
return pimpl_->lastSentLen_ >= static_cast<pj_size_t>(len)
|
||||
or pimpl_->destroying_;
|
||||
});
|
||||
pimpl_->lastSentLen_ = 0;
|
||||
} else if (status != PJ_SUCCESS && status != PJ_EPENDING) {
|
||||
|
Reference in New Issue
Block a user