- fixes for Android + ongoing migration to latest resiprocate

This commit is contained in:
2023-05-14 12:04:49 +03:00
parent 0eb5ad7cf7
commit dd6c01ca0d
8960 changed files with 133 additions and 2018592 deletions

View File

@@ -156,7 +156,7 @@ Account::Account(PVariantMap config, UserAgent& agent)
:mAgent(agent), mId(0), mConfig(config), mRegistrationState(RegistrationState::None),
mRegistration(NULL)
{
mProfile = resip::SharedPtr<resip::UserProfile>(new resip::UserProfile(agent.mProfile));
mProfile = std::make_shared<resip::UserProfile>(agent.mProfile);
mId = Account::generateId();
setup(*config);
}
@@ -201,7 +201,7 @@ void Account::setup(VariantMap &config)
}
// NAT decorator
mProfile->setOutboundDecorator(resip::SharedPtr<resip::MessageDecorator>(new NATDecorator(mAgent)));
mProfile->setOutboundDecorator(std::make_shared<NATDecorator>(mAgent));
// Rinstance
if (config.exists(CONFIG_INSTANCE_ID))
@@ -266,7 +266,7 @@ void Account::start()
// Create registration
mRegistration = new ResipSession(*mAgent.mDum);
resip::SharedPtr<resip::SipMessage> regmessage = mAgent.mDum->makeRegistration(mProfile->getDefaultFrom(), mProfile, mConfig->at(CONFIG_REGISTERDURATION).asInt(), mRegistration);
auto regmessage = mAgent.mDum->makeRegistration(mProfile->getDefaultFrom(), mProfile, mConfig->at(CONFIG_REGISTERDURATION).asInt(), mRegistration);
for (UserInfo::const_iterator iter = mUserInfo.begin(); iter != mUserInfo.end(); iter++)
regmessage->header(resip::ExtensionHeader(iter->first.c_str())).push_back(resip::StringCategory(iter->second.c_str()));
@@ -380,7 +380,7 @@ PClientObserver Account::observe(const std::string& target, const std::string& p
observer->mSessionId = observer->mSession->sessionId();
observer->mPeer = target;
resip::SharedPtr<resip::SipMessage> msg;
std::shared_ptr<resip::SipMessage> msg;
int expires = DEFAULT_SUBSCRIPTION_TIME, refresh = DEFAULT_SUBSCRIPTION_REFRESHTIME;
if (mConfig->exists(CONFIG_SUBSCRIPTION_TIME))
expires = CONFIG(CONFIG_SUBSCRIPTION_TIME).asInt();
@@ -498,7 +498,7 @@ void Account::prepareIceStack(Session *session, ice::AgentRole icerole)
//config.mDetectNetworkChange = true;
//config.mNetworkCheckInterval = 5000;
session->mIceStack = resip::SharedPtr<ice::Stack>(ice::Stack::makeICEBox(config));
session->mIceStack = std::shared_ptr<ice::Stack>(ice::Stack::makeICEBox(config));
session->mIceStack->setEventHandler(session, this);
session->mIceStack->setRole(icerole);
}
@@ -552,9 +552,8 @@ void Account::onSuccess(resip::ClientRegistrationHandle h, const resip::SipMessa
mAgent.mDum->addDomain(resip::Data(mExternalAddress.ip()));
}
const resip::Transport* transport = response.getReceivedTransport();
mUsedTransport = transport->transport();
bool streamTransport = transport->transport() == resip::TCP || transport->transport() == resip::TLS;
mUsedTransport = response.getReceivedTransportTuple().getType();
bool streamTransport = mUsedTransport == resip::TCP || mUsedTransport == resip::TLS;
// Retry registration for stream based transport too
if ( (hostChanged || portChanged) && mRegistrationState == RegistrationState::Registering /*&& !streamTransport*/ && mConfig->at(CONFIG_EXTERNALIP).asBool())
@@ -596,7 +595,7 @@ void Account::onRemoved(resip::ClientRegistrationHandle h, const resip::SipMessa
//mProfile->setDefaultFrom(from);
}
mProfile->setRegId(mConfig->at(CONFIG_REGID).asInt());
resip::SharedPtr<resip::SipMessage> regmessage = mAgent.mDum->makeRegistration(mProfile->getDefaultFrom(), mProfile, UA_REGISTRATION_TIME);
auto regmessage = mAgent.mDum->makeRegistration(mProfile->getDefaultFrom(), mProfile, UA_REGISTRATION_TIME);
for (UserInfo::const_iterator iter = mUserInfo.begin(); iter != mUserInfo.end(); iter++)
regmessage->header(resip::ExtensionHeader(iter->first.c_str())).push_back(resip::StringCategory(iter->second.c_str()));
@@ -740,8 +739,8 @@ Account::UserInfo Account::getUserInfo() const
return mUserInfo;
}
resip::AtomicCounter Account::IdGenerator;
std::atomic_int Account::IdGenerator;
int Account::generateId()
{
return IdGenerator.increment();
return ++IdGenerator;
}

View File

@@ -65,7 +65,7 @@ public:
void setup(VariantMap& config);
/* Returns corresponding resiprocate profile */
resip::SharedPtr<resip::UserProfile> getUserProfile() const { return mProfile; }
std::shared_ptr<resip::UserProfile> getUserProfile() const { return mProfile; }
typedef std::map<std::string, std::string> UserInfo;
void setUserInfo(const UserInfo& info);
@@ -83,7 +83,7 @@ protected:
RegistrationState mRegistrationState;
ice::NetworkAddress mExternalAddress;
resip::SharedPtr<resip::UserProfile> mProfile;
std::shared_ptr<resip::UserProfile> mProfile;
UserAgent& mAgent;
bool mPresenceOnline;
std::string mPresenceContent;

View File

@@ -10,7 +10,6 @@
#include <vector>
#include "resip/stack/SdpContents.hxx"
#include "rutil/SharedPtr.hxx"
#include "../helper/HL_InternetAddress.h"
#include "../helper/HL_NetworkSocket.h"

View File

@@ -54,7 +54,7 @@ UserAgent::UserAgent()
mConfig[CONFIG_RTCP_ATTR] = true;
// Create master profile
mProfile = resip::SharedPtr<resip::MasterProfile>(new resip::MasterProfile());
mProfile = std::make_shared<resip::MasterProfile>();
mProfile->clearSupportedMethods();
mProfile->addSupportedMethod(resip::INVITE);
mProfile->addSupportedMethod(resip::BYE);
@@ -146,8 +146,8 @@ void UserAgent::start()
mTransportList.clear();
resip::InternalTransport* t;
#define ADD_TRANSPORT4(X) if ((t = dynamic_cast<resip::InternalTransport*>(mStack->addTransport(X, 0, resip::V4)))) { t->setTransportLogger(this); mTransportList.push_back(t);}
#define ADD_TRANSPORT6(X) if ((t = dynamic_cast<resip::InternalTransport*>(mStack->addTransport(X, 0, resip::V6)))) { t->setTransportLogger(this); mTransportList.push_back(t);}
#define ADD_TRANSPORT4(X) if ((t = dynamic_cast<resip::InternalTransport*>(mStack->addTransport(X, 0, resip::V4)))) { /*t->setTransportLogger(this);*/ mTransportList.push_back(t);}
#define ADD_TRANSPORT6(X) if ((t = dynamic_cast<resip::InternalTransport*>(mStack->addTransport(X, 0, resip::V6)))) { /*t->setTransportLogger(this);*/ mTransportList.push_back(t);}
switch (mConfig[CONFIG_TRANSPORT].asInt())
{
@@ -315,7 +315,10 @@ void UserAgent::stop()
mTransportList.clear();
// Dump statistics here
ICELogInfo(<< "Remaining " << Session::InstanceCounter.value() << " session(s), " << ResipSession::InstanceCounter.value() << " resip DialogSet(s), " << resip::ClientRegistration::InstanceCounter.value() << " ClientRegistration(s)");
ICELogInfo(<< "Remaining "
<< Session::InstanceCounter << " session(s), "
<< ResipSession::InstanceCounter << " resip DialogSet(s), "
<< resip::ClientRegistration::InstanceCounter << " ClientRegistration(s)");
mDum->shutdown(this);
onDumCanBeDeleted();
@@ -585,7 +588,7 @@ void UserAgent::sendOffer(Session* session)
if (session->mOriginVersion == 1)
{
// Construct INVITE session
resip::SharedPtr<resip::SipMessage> msg = mDum->makeInviteSession(session->mRemotePeer, session->account()->mProfile, &sdp, session->mResipSession);
auto msg = mDum->makeInviteSession(session->mRemotePeer, session->account()->mProfile, &sdp, session->mResipSession);
// Include user headers
for (Session::UserHeaders::const_iterator iter = session->mUserHeaders.begin(); iter != session->mUserHeaders.end(); iter++)
@@ -655,8 +658,14 @@ void UserAgent::onFailure(resip::ClientRegistrationHandle h, const resip::SipMes
#pragma endregion
bool UserAgent::operator()(resip::Log::Level level, const resip::Subsystem& subsystem, const resip::Data& appName, const char* file,
int line, const resip::Data& message, const resip::Data& messageWithHeaders)
bool UserAgent::operator()(resip::Log::Level level,
const resip::Subsystem& subsystem,
const resip::Data& appName,
const char* file,
int line,
const resip::Data& message,
const resip::Data& messageWithHeaders,
const resip::Data& instanceName)
{
std::string filename = file;
std::stringstream ss;
@@ -990,7 +999,7 @@ void UserAgent::onAnswer(resip::InviteSessionHandle h, const resip::SipMessage&
s->mIceStack->clear();
}
UInt64 version = sdp.session().origin().getVersion();
uint64_t version = sdp.session().origin().getVersion();
s->mRemoteOriginVersion = version;
}
@@ -1017,10 +1026,10 @@ void UserAgent::onOffer(resip::InviteSessionHandle h, const resip::SipMessage& m
ice::Stack& ice = *s->mIceStack;
UInt64 version = sdp.session().origin().getVersion();
uint64_t version = sdp.session().origin().getVersion();
std::string remoteIp = sdp.session().connection().getAddress().c_str();
int code;
if ((UInt64)-1 == s->mRemoteOriginVersion)
if ((uint64_t)-1 == s->mRemoteOriginVersion)
{
code = s->processSdp(version, iceAvailable, icePwd, iceUfrag, remoteIp, sdp.session().media());
}
@@ -1564,7 +1573,7 @@ void UserAgent::onSipMessage(int flow, const char* msg, unsigned int length, con
ice::NetworkAddress address(*addr, addrlen);
std::string addressText = address.toStdString();
switch (flow)
/*switch (flow)
{
case resip::InternalTransport::TransportLogger::Flow_Received:
ICELogDebug(<< "Received from " << addressText << ":" << "\n"
@@ -1574,7 +1583,7 @@ void UserAgent::onSipMessage(int flow, const char* msg, unsigned int length, con
case resip::InternalTransport::TransportLogger::Flow_Sent:
ICELogDebug(<< "Sent to " << addressText << "\n" << strx::prefixLines(d, "<---"));
break;
}
}*/
}
PSession UserAgent::getUserSession(int sessionId)

View File

@@ -378,12 +378,13 @@ public:
#pragma region ExternalLogger implementation
/** return true to also do default logging, false to suppress default logging. */
virtual bool operator()(resip::Log::Level level,
const resip::Subsystem& subsystem,
const resip::Data& appName,
const char* file,
int line,
const resip::Data& message,
const resip::Data& messageWithHeaders) override;
const resip::Subsystem& subsystem,
const resip::Data& appName,
const char* file,
int line,
const resip::Data& message,
const resip::Data& messageWithHeaders,
const resip::Data& instanceName) override;
#pragma endregion
#pragma region DnsResultSink implementation
@@ -437,7 +438,7 @@ public:
#pragma region PagerHandler
void onSuccess(resip::ClientPagerMessageHandle, const resip::SipMessage& status) override;
void onFailure(resip::ClientPagerMessageHandle, const resip::SipMessage& status, std::unique_ptr<resip::Contents> contents);
void onFailure(resip::ClientPagerMessageHandle, const resip::SipMessage& status, std::unique_ptr<resip::Contents> contents) override;
void onMessageArrived(resip::ServerPagerMessageHandle, const resip::SipMessage& message) override;
#pragma endregion
@@ -447,7 +448,7 @@ protected:
Mutex mGuard;
// Smart pointer to resiprocate's master profile instance. The stack configuration holds here.
resip::SharedPtr<resip::MasterProfile> mProfile;
std::shared_ptr<resip::MasterProfile> mProfile;
// Resiprocate's SIP stack object pointer
resip::SipStack* mStack;

View File

@@ -85,7 +85,7 @@ void WatcherQueue::process()
if (i == mItemList.end())
return;
resip::SharedPtr<resip::SipMessage> msg;
std::shared_ptr<resip::SipMessage> msg;
int expires = DEFAULT_SUBSCRIPTION_TIME, refresh = DEFAULT_SUBSCRIPTION_REFRESHTIME;
switch (i->mState)

View File

@@ -37,12 +37,12 @@ ResipSessionAppDialog::~ResipSessionAppDialog()
#pragma region ResipSession
resip::AtomicCounter ResipSession::InstanceCounter;
std::atomic_int ResipSession::InstanceCounter;
ResipSession::ResipSession(resip::DialogUsageManager& dum)
: resip::AppDialogSet(dum), mUserAgent(NULL), mType(Type_None), mSessionId(0), mSession(0)
{
ResipSession::InstanceCounter.increment();
ResipSession::InstanceCounter++;
mTag = NULL;
mTerminated = false;
mOnWatchingStartSent = false;
@@ -62,7 +62,7 @@ ResipSession::~ResipSession()
{
}
ResipSession::InstanceCounter.decrement();
ResipSession::InstanceCounter--;
}
resip::AppDialog* ResipSession::createAppDialog(const resip::SipMessage& msg)
@@ -167,12 +167,12 @@ int ResipSession::sessionId()
return mSessionId;
}
void ResipSession::setUASProfile(std::shared_ptr<resip::UserProfile> profile)
void ResipSession::setUASProfile(const std::shared_ptr<resip::UserProfile>& profile)
{
mUASProfile = profile;
}
resip::SharedPtr<resip::UserProfile> ResipSession::selectUASUserProfile(const resip::SipMessage& msg)
std::shared_ptr<resip::UserProfile> ResipSession::selectUASUserProfile(const resip::SipMessage& msg)
{
assert(mUserAgent != nullptr);
@@ -184,7 +184,7 @@ resip::SharedPtr<resip::UserProfile> ResipSession::selectUASUserProfile(const re
else
return mUserAgent->mProfile;
}
return resip::SharedPtr<resip::UserProfile>();
return std::shared_ptr<resip::UserProfile>();
}
#pragma endregion
@@ -262,11 +262,11 @@ void Session::Stream::setRtcpMuxAttr(bool value)
#pragma endregion
#pragma region Session
resip::AtomicCounter Session::InstanceCounter;
std::atomic_int Session::InstanceCounter;
Session::Session(PAccount account)
{
InstanceCounter.increment();
InstanceCounter++;
mAccount = account;
mSessionId = Session::generateId();
mTag = NULL;
@@ -278,7 +278,7 @@ Session::Session(PAccount account)
mRole = Acceptor;
mGatheredCandidates = false;
mTerminated = false;
mRemoteOriginVersion = (UInt64)-1;
mRemoteOriginVersion = (uint64_t)-1;
mResipSession = NULL;
mRefCount = 1;
mOfferAnswerCounter = 0;
@@ -296,7 +296,7 @@ Session::~Session()
}
catch(...)
{}
InstanceCounter.decrement();
InstanceCounter--;
}
void Session::start(const std::string& peer)
@@ -829,10 +829,10 @@ int Session::sessionId()
return mSessionId;
}
resip::AtomicCounter Session::IdGenerator;
std::atomic_int Session::IdGenerator;
int Session::generateId()
{
return (int)IdGenerator.increment();
return ++IdGenerator;
}
std::string Session::remoteAddress() const
@@ -914,7 +914,7 @@ void Session::refreshMediaPath()
}
// Received offer with new SDP
int Session::processSdp(UInt64 version, bool iceAvailable, std::string icePwd, std::string iceUfrag,
int Session::processSdp(uint64_t version, bool iceAvailable, std::string icePwd, std::string iceUfrag,
std::string remoteIp, const resip::SdpContents::Session::MediumContainer& media)
{
bool iceRestart = false;

View File

@@ -213,7 +213,8 @@ public:
void refreshMediaPath();
// Processes new sdp from offer. Returns response code (200 is ok, 488 bad codec, 503 internal error).
int processSdp(UInt64 version, bool iceAvailable, std::string icePwd, std::string iceUfrag,
// There are passing string objects by value; this is correct; this values will modified on the stack.
int processSdp(uint64_t version, bool iceAvailable, std::string icePwd, const std::string iceUfrag,
std::string remoteIp, const resip::SdpContents::Session::MediumContainer& media);
// Session ID
@@ -223,7 +224,7 @@ public:
std::vector<Stream> mStreamList;
// Smart pointer to ICE stack. Actually stack is created in CreateICEStack() method
resip::SharedPtr<ice::Stack> mIceStack;
std::shared_ptr<ice::Stack> mIceStack;
// Pointer to owner user agent instance
UserAgent* mUserAgent;
@@ -236,7 +237,7 @@ public:
// SDP's origin version for sending
int mOriginVersion;
UInt64 mRemoteOriginVersion;
uint64_t mRemoteOriginVersion;
// SDP's session version
int mSessionVersion;
@@ -359,7 +360,7 @@ public:
ResipSession(resip::DialogUsageManager& dum);
virtual ~ResipSession();
virtual resip::AppDialog* createAppDialog(const resip::SipMessage& msg);
virtual resip::SharedPtr<resip::UserProfile> selectUASUserProfile(const resip::SipMessage& msg);
virtual std::shared_ptr<resip::UserProfile> selectUASUserProfile(const resip::SipMessage& msg);
void setType(Type type);
Type type();
@@ -383,7 +384,7 @@ public:
void runTerminatedEvent(Type type, int code = 0, int reason = 0);
void setUASProfile(std::shared_ptr<resip::UserProfile> profile);
void setUASProfile(const std::shared_ptr<resip::UserProfile>& profile);
protected:
bool mTerminated;