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:
|
public:
|
||||||
IceLock(pj_ice_strans* strans)
|
IceLock(pj_ice_strans* strans)
|
||||||
: lk_(pj_ice_strans_get_grp_lock(strans))
|
: lk_(pj_ice_strans_get_grp_lock(strans)) {
|
||||||
{
|
|
||||||
lock();
|
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
|
class IceTransport::Impl
|
||||||
@ -376,9 +381,6 @@ IceTransport::Impl::~Impl()
|
|||||||
}
|
}
|
||||||
|
|
||||||
JAMI_DBG("[ice:%p] done destroying", this);
|
JAMI_DBG("[ice:%p] done destroying", this);
|
||||||
|
|
||||||
if (scb)
|
|
||||||
scb();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -509,6 +511,8 @@ IceTransport::Impl::initIceInstance(const IceTransportOptions& options)
|
|||||||
std::lock_guard lk(tr->sendDataMutex_);
|
std::lock_guard lk(tr->sendDataMutex_);
|
||||||
tr->destroying_ = true;
|
tr->destroying_ = true;
|
||||||
tr->waitDataCv_.notify_all();
|
tr->waitDataCv_.notify_all();
|
||||||
|
if (tr->scb)
|
||||||
|
tr->scb();
|
||||||
} else {
|
} else {
|
||||||
JAMI_WARN("null IceTransport");
|
JAMI_WARN("null IceTransport");
|
||||||
}
|
}
|
||||||
@ -694,9 +698,9 @@ IceTransport::Impl::checkEventQueue(int maxEventToPoll)
|
|||||||
void
|
void
|
||||||
IceTransport::Impl::onComplete(pj_ice_strans*, pj_ice_strans_op op, pj_status_t status)
|
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"
|
const char* opname = op == PJ_ICE_STRANS_OP_INIT
|
||||||
: op == PJ_ICE_STRANS_OP_NEGOTIATION ? "negotiation"
|
? "initialization"
|
||||||
: "unknown_op";
|
: op == PJ_ICE_STRANS_OP_NEGOTIATION ? "negotiation" : "unknown_op";
|
||||||
|
|
||||||
const bool done = status == PJ_SUCCESS;
|
const bool done = status == PJ_SUCCESS;
|
||||||
if (done) {
|
if (done) {
|
||||||
@ -744,7 +748,7 @@ IceTransport::Impl::link() const
|
|||||||
std::ostringstream out;
|
std::ostringstream out;
|
||||||
for (unsigned strm = 1; strm <= streamsCount_ * compCountPerStream_; strm++) {
|
for (unsigned strm = 1; strm <= streamsCount_ * compCountPerStream_; strm++) {
|
||||||
auto absIdx = strm;
|
auto absIdx = strm;
|
||||||
auto comp = (strm + 1) / compCountPerStream_;
|
auto comp = (strm+1)/compCountPerStream_;
|
||||||
auto laddr = getLocalAddress(absIdx);
|
auto laddr = getLocalAddress(absIdx);
|
||||||
auto raddr = getRemoteAddress(absIdx);
|
auto raddr = getRemoteAddress(absIdx);
|
||||||
|
|
||||||
@ -766,6 +770,7 @@ IceTransport::Impl::setInitiatorSession()
|
|||||||
JAMI_DBG("[ice:%p] as master", this);
|
JAMI_DBG("[ice:%p] as master", this);
|
||||||
initiatorSession_ = true;
|
initiatorSession_ = true;
|
||||||
if (_isInitialized()) {
|
if (_isInitialized()) {
|
||||||
|
|
||||||
auto status = pj_ice_strans_change_role(icest_, PJ_ICE_SESS_ROLE_CONTROLLING);
|
auto status = pj_ice_strans_change_role(icest_, PJ_ICE_SESS_ROLE_CONTROLLING);
|
||||||
if (status != PJ_SUCCESS) {
|
if (status != PJ_SUCCESS) {
|
||||||
last_errmsg_ = sip_utils::sip_strerror(status);
|
last_errmsg_ = sip_utils::sip_strerror(status);
|
||||||
@ -783,6 +788,7 @@ IceTransport::Impl::setSlaveSession()
|
|||||||
JAMI_DBG("[ice:%p] as slave", this);
|
JAMI_DBG("[ice:%p] as slave", this);
|
||||||
initiatorSession_ = false;
|
initiatorSession_ = false;
|
||||||
if (_isInitialized()) {
|
if (_isInitialized()) {
|
||||||
|
|
||||||
auto status = pj_ice_strans_change_role(icest_, PJ_ICE_SESS_ROLE_CONTROLLED);
|
auto status = pj_ice_strans_change_role(icest_, PJ_ICE_SESS_ROLE_CONTROLLED);
|
||||||
if (status != PJ_SUCCESS) {
|
if (status != PJ_SUCCESS) {
|
||||||
last_errmsg_ = sip_utils::sip_strerror(status);
|
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,
|
jami_tracepoint_if_enabled(ice_transport_recv,
|
||||||
reinterpret_cast<uint64_t>(this),
|
reinterpret_cast<uint64_t>(this),
|
||||||
comp_id,
|
comp_id, size,
|
||||||
size,
|
|
||||||
getRemoteAddress(comp_id).toString().c_str());
|
getRemoteAddress(comp_id).toString().c_str());
|
||||||
if (size == 0)
|
if (size == 0)
|
||||||
return;
|
return;
|
||||||
@ -1125,8 +1130,8 @@ IceTransport::Impl::_waitForInitialization(std::chrono::milliseconds timeout)
|
|||||||
IceLock lk(icest_);
|
IceLock lk(icest_);
|
||||||
|
|
||||||
if (not iceCV_.wait_for(lk, timeout, [this] {
|
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);
|
JAMI_WARN("[ice:%p] waitForInitialization: timeout", this);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -1151,7 +1156,8 @@ IceTransport::initIceInstance(const IceTransportOptions& options)
|
|||||||
{
|
{
|
||||||
pimpl_->initIceInstance(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
|
bool
|
||||||
@ -1686,9 +1692,7 @@ IceTransport::send(unsigned compId, const unsigned char* buf, size_t len)
|
|||||||
|
|
||||||
jami_tracepoint(ice_transport_send,
|
jami_tracepoint(ice_transport_send,
|
||||||
reinterpret_cast<uint64_t>(this),
|
reinterpret_cast<uint64_t>(this),
|
||||||
compId,
|
compId, len, remote.toString().c_str());
|
||||||
len,
|
|
||||||
remote.toString().c_str());
|
|
||||||
|
|
||||||
auto status = pj_ice_strans_sendto2(pimpl_->icest_,
|
auto status = pj_ice_strans_sendto2(pimpl_->icest_,
|
||||||
compId,
|
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
|
// NOTE; because we are in TCP, the sent size will count the header (2
|
||||||
// bytes length).
|
// bytes length).
|
||||||
pimpl_->waitDataCv_.wait(dlk, [&] {
|
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;
|
pimpl_->lastSentLen_ = 0;
|
||||||
} else if (status != PJ_SUCCESS && status != PJ_EPENDING) {
|
} else if (status != PJ_SUCCESS && status != PJ_EPENDING) {
|
||||||
|
Reference in New Issue
Block a user