Commit 01394ff7 authored by Ghislain MARY's avatar Ghislain MARY
Browse files

Use unique_ptr for StunClient and IceAgent objects.

parent 5ec972c9
...@@ -74,7 +74,7 @@ public: ...@@ -74,7 +74,7 @@ public:
void setParams (MediaSessionParams *msp); void setParams (MediaSessionParams *msp);
void setRemoteParams (MediaSessionParams *msp); void setRemoteParams (MediaSessionParams *msp);
IceSession *getIceSession () const { return iceAgent->getIceSession(); } IceSession *getIceSession () const { return iceAgent ? iceAgent->getIceSession() : nullptr; }
SalMediaDescription *getLocalDesc () const { return localDesc; } SalMediaDescription *getLocalDesc () const { return localDesc; }
...@@ -284,8 +284,8 @@ private: ...@@ -284,8 +284,8 @@ private:
int mainTextStreamIndex = LINPHONE_CALL_STATS_TEXT; int mainTextStreamIndex = LINPHONE_CALL_STATS_TEXT;
LinphoneNatPolicy *natPolicy = nullptr; LinphoneNatPolicy *natPolicy = nullptr;
StunClient *stunClient = nullptr; std::unique_ptr<StunClient> stunClient;
IceAgent *iceAgent = nullptr; std::unique_ptr<IceAgent> iceAgent;
// The address family to prefer for RTP path, guessed from signaling path. // The address family to prefer for RTP path, guessed from signaling path.
int af; int af;
......
...@@ -1177,7 +1177,7 @@ string MediaSessionPrivate::getPublicIpForStream (int streamIndex) { ...@@ -1177,7 +1177,7 @@ string MediaSessionPrivate::getPublicIpForStream (int streamIndex) {
void MediaSessionPrivate::runStunTestsIfNeeded () { void MediaSessionPrivate::runStunTestsIfNeeded () {
L_Q(); L_Q();
if (linphone_nat_policy_stun_enabled(natPolicy) && !(linphone_nat_policy_ice_enabled(natPolicy) || linphone_nat_policy_turn_enabled(natPolicy))) { if (linphone_nat_policy_stun_enabled(natPolicy) && !(linphone_nat_policy_ice_enabled(natPolicy) || linphone_nat_policy_turn_enabled(natPolicy))) {
stunClient = new StunClient(q->getCore()); stunClient = makeUnique<StunClient>(q->getCore());
int ret = stunClient->run(mediaPorts[mainAudioStreamIndex].rtpPort, mediaPorts[mainVideoStreamIndex].rtpPort, mediaPorts[mainTextStreamIndex].rtpPort); int ret = stunClient->run(mediaPorts[mainAudioStreamIndex].rtpPort, mediaPorts[mainVideoStreamIndex].rtpPort, mediaPorts[mainTextStreamIndex].rtpPort);
if (ret >= 0) if (ret >= 0)
pingTime = ret; pingTime = ret;
...@@ -3939,7 +3939,7 @@ MediaSession::MediaSession (const shared_ptr<Core> &core, shared_ptr<Participant ...@@ -3939,7 +3939,7 @@ MediaSession::MediaSession (const shared_ptr<Core> &core, shared_ptr<Participant
d->setPortConfig(d->mainTextStreamIndex, make_pair(minPort, maxPort)); d->setPortConfig(d->mainTextStreamIndex, make_pair(minPort, maxPort));
memset(d->sessions, 0, sizeof(d->sessions)); memset(d->sessions, 0, sizeof(d->sessions));
d->iceAgent = new IceAgent(*this); d->iceAgent = makeUnique<IceAgent>(*this);
lInfo() << "New MediaSession [" << this << "] initialized (LinphoneCore version: " << linphone_core_get_version() << ")"; lInfo() << "New MediaSession [" << this << "] initialized (LinphoneCore version: " << linphone_core_get_version() << ")";
} }
...@@ -3957,9 +3957,6 @@ MediaSession::~MediaSession () { ...@@ -3957,9 +3957,6 @@ MediaSession::~MediaSession () {
linphone_call_stats_unref(d->textStats); linphone_call_stats_unref(d->textStats);
if (d->natPolicy) if (d->natPolicy)
linphone_nat_policy_unref(d->natPolicy); linphone_nat_policy_unref(d->natPolicy);
if (d->stunClient)
delete d->stunClient;
delete d->iceAgent;
if (d->localDesc) if (d->localDesc)
sal_media_description_unref(d->localDesc); sal_media_description_unref(d->localDesc);
if (d->biggestDesc) if (d->biggestDesc)
......
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