Commit 2a20afcf authored by Philippe Gorley's avatar Philippe Gorley Committed by Adrien Béraud

sipcall: add peer uri

For SIP accounts, peer uri contains a well formed sip uri. For Ring
accounts, contains "ring:username" if a registered name is found, else
"ring:ringid".

Change-Id: I55bc46e905adf4cf8fe8ea955a2f9cb13438de7e
parent 8d913236
......@@ -390,14 +390,17 @@ RingAccount::startOutgoingCall(const std::shared_ptr<SIPCall>& call, const std::
setCertificateStatus(toUri, tls::TrustStore::PermissionStatus::ALLOWED);
call->setPeerNumber(toUri + "@ring.dht");
call->setPeerUri(RING_URI_PREFIX + toUri);
call->setState(Call::ConnectionState::TRYING);
std::weak_ptr<SIPCall> wCall = call;
#if HAVE_RINGNS
nameDir_.get().lookupAddress(toUri, [wCall](const std::string& result, const NameDirectory::Response& response){
if (response == NameDirectory::Response::found)
if (auto call = wCall.lock())
if (auto call = wCall.lock()) {
call->setPeerRegistredName(result);
call->setPeerUri(RING_URI_PREFIX + result);
}
});
#endif
......@@ -2456,12 +2459,15 @@ RingAccount::replyToIncomingIceMsg(const std::shared_ptr<SIPCall>& call,
const dht::InfoHash& from_id)
{
auto from = from_id.toString();
call->setPeerUri(RING_URI_PREFIX + from);
std::weak_ptr<SIPCall> wcall = call;
#if HAVE_RINGNS
nameDir_.get().lookupAddress(from, [wcall](const std::string& result, const NameDirectory::Response& response){
if (response == NameDirectory::Response::found)
if (auto call = wcall.lock())
if (auto call = wcall.lock()) {
call->setPeerRegistredName(result);
call->setPeerUri(RING_URI_PREFIX + result);
}
});
#endif
......
......@@ -214,6 +214,7 @@ SIPAccount::newOutgoingCall(const std::string& toUrl,
call->initIceMediaTransport(true);
call->setIPToIP(isIP2IP());
call->setPeerNumber(toUri);
call->setPeerUri(toUri);
call->initRecFilename(to);
const auto localAddress = ip_utils::getInterfaceAddr(getLocalInterface(), family);
......
......@@ -1155,8 +1155,7 @@ SIPCall::toggleRecording()
const bool startRecording = Call::toggleRecording();
if (startRecording) {
std::stringstream ss;
ss << "Ring call between " << getSIPAccount().getUserUri() << " and "
<< (!peerRegistredName_.empty() ? peerRegistredName_ : getPeerNumber());
ss << "Ring call between " << getSIPAccount().getUserUri() << " and " << peerUri_;
recorder_->setMetadata(ss.str(), ""); // use default description
if (avformatrtp_)
avformatrtp_->startRecorder(recorder_);
......
......@@ -209,6 +209,8 @@ public: // NOT SIP RELATED (good candidates to be moved elsewhere)
peerRegistredName_ = name;
}
void setPeerUri(const std::string peerUri) { peerUri_ = peerUri; }
bool initIceMediaTransport(bool master, unsigned channel_num=4);
bool isIceRunning() const;
......@@ -294,6 +296,8 @@ private:
///< Temporary transport for media. Replace mediaTransport_ when connected with success
std::shared_ptr<IceTransport> tmpMediaTransport_;
std::string peerUri_{};
};
// Helpers
......
......@@ -331,9 +331,10 @@ transaction_request_cb(pjsip_rx_data *rdata)
}
}
call->setState(Call::ConnectionState::PROGRESSING);
call->setPeerNumber(peerNumber);
call->setPeerUri(account->getToUri(peerNumber));
call->setPeerDisplayName(peerDisplayName);
call->setState(Call::ConnectionState::PROGRESSING);
call->initRecFilename(peerNumber);
call->getSDP().setPublishedIP(addrSdp);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment