From 293f1ce249fd4c6f518c1105a43e653688eb4cd1 Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Wed, 2 May 2018 17:47:15 +0200 Subject: [PATCH] Coding style fixes. --- src/conference/session/media-session.cpp | 34 +++++++++++------------ src/nat/ice-agent.cpp | 35 ++++++++++-------------- src/nat/ice-agent.h | 2 +- 3 files changed, 32 insertions(+), 39 deletions(-) diff --git a/src/conference/session/media-session.cpp b/src/conference/session/media-session.cpp index b12047565..08535ea08 100644 --- a/src/conference/session/media-session.cpp +++ b/src/conference/session/media-session.cpp @@ -706,31 +706,29 @@ shared_ptr MediaSessionPrivate::getMe () const { void MediaSessionPrivate::setState (CallSession::State newState, const string &message) { L_Q(); - SalMediaDescription *rmd; - - lInfo()<<"MediaSessionPrivate::setState"; - - /* Take a ref on the session otherwise it might get destroyed during the call to setState */ + + // Take a ref on the session otherwise it might get destroyed during the call to setState shared_ptr sessionRef = q->getSharedFromThis(); if ((newState != state) && (newState != CallSession::State::StreamsRunning)) q->cancelDtmfs(); CallSessionPrivate::setState(newState, message); if (listener) listener->onCallSessionStateChangedForReporting(q->getSharedFromThis()); - switch(newState){ + SalMediaDescription *rmd = nullptr; + switch (newState) { case CallSession::State::UpdatedByRemote: - /*Handle specifically the case of an incoming ICE-concluded reINVITE*/ - lInfo()<<"Checking for ICE reINVITE"; + // Handle specifically the case of an incoming ICE-concluded reINVITE + lInfo() << "Checking for ICE reINVITE"; rmd = op->get_remote_media_description(); - if (iceAgent && rmd != nullptr && iceAgent->checkIceReinviteNeedsDeferedResponse(rmd)){ + if (iceAgent && rmd && iceAgent->checkIceReinviteNeedsDeferedResponse(rmd)) { deferUpdate = true; deferUpdateInternal = true; incomingIceReinvitePending = true; - lInfo()<<"CallSession [" << q << "]: ICE reinvite received, but one or more check-lists are not completed. Response will be sent later, when ICE has completed"; + lInfo() << "CallSession [" << q << "]: ICE reinvite received, but one or more check-lists are not completed. Response will be sent later, when ICE has completed"; } - break; + break; default: - break; + break; } } @@ -1177,7 +1175,7 @@ void MediaSessionPrivate::getLocalIp (const Address &remoteAddr) { hints.ai_family = AF_UNSPEC; hints.ai_socktype = SOCK_DGRAM; hints.ai_flags = AI_NUMERICHOST; - err = getaddrinfo(remoteAddr.getDomain().c_str(), NULL, &hints, &res); + err = getaddrinfo(remoteAddr.getDomain().c_str(), nullptr, &hints, &res); if (err == 0) dest = remoteAddr.getDomain().c_str(); if (res) freeaddrinfo(res); @@ -1251,9 +1249,9 @@ void MediaSessionPrivate::selectOutgoingIpVersion () { bool haveIpv6 = false; bool haveIpv4 = false; /* Check connectivity for IPv4 and IPv6 */ - if (linphone_core_get_local_ip_for(AF_INET6, NULL, ipv6) == 0) + if (linphone_core_get_local_ip_for(AF_INET6, nullptr, ipv6) == 0) haveIpv6 = true; - if (linphone_core_get_local_ip_for(AF_INET, NULL, ipv4) == 0) + if (linphone_core_get_local_ip_for(AF_INET, nullptr, ipv4) == 0) haveIpv4 = true; if (haveIpv6) { if (!haveIpv4) @@ -2388,8 +2386,10 @@ void MediaSessionPrivate::initializeAudioStream () { params.limeKeyTimeSpan = bctbx_time_string_to_sec(lp_config_get_string(linphone_core_get_config(q->getCore()->getCCore()), "sip", "lime_key_validity", "0")); setZrtpCryptoTypesParameters(¶ms); audio_stream_enable_zrtp(audioStream, ¶ms); - if (peerUri != NULL) ms_free(peerUri); - if (selfUri != NULL) ms_free(selfUri); + if (peerUri) + ms_free(peerUri); + if (selfUri) + ms_free(selfUri); } media_stream_reclaim_sessions(&audioStream->ms, &sessions[mainAudioStreamIndex]); diff --git a/src/nat/ice-agent.cpp b/src/nat/ice-agent.cpp index 167acc8b9..48f15b5f2 100644 --- a/src/nat/ice-agent.cpp +++ b/src/nat/ice-agent.cpp @@ -740,32 +740,25 @@ void IceAgent::updateIceStateInCallStatsForStream (LinphoneCallStats *stats, Ice } } -bool IceAgent::checkIceReinviteNeedsDeferedResponse(SalMediaDescription *md){ - int i,j; - IceCheckList *cl; - - if (!iceSession) return false; +bool IceAgent::checkIceReinviteNeedsDeferedResponse(SalMediaDescription *md) { + if (!iceSession || (ice_session_state(iceSession) != IS_Running)) + return false; - if (ice_session_state(iceSession) != IS_Running ) return false; - - for (i = 0; i < md->nb_streams; i++) { + for (int i = 0; i < md->nb_streams; i++) { SalStreamDescription *stream = &md->streams[i]; - cl = ice_session_check_list(iceSession, i); - - if (cl==NULL) continue; - if (stream->ice_mismatch == TRUE) { - return false; - } - if (stream->rtp_port == 0) { + IceCheckList *cl = ice_session_check_list(iceSession, i); + if (!cl) continue; - } - - if (ice_check_list_state(cl) != ICL_Running) continue; - for (j = 0; j < SAL_MEDIA_DESCRIPTION_MAX_ICE_REMOTE_CANDIDATES; j++) { + if (stream->ice_mismatch) + return false; + if ((stream->rtp_port == 0) || (ice_check_list_state(cl) != ICL_Running)) + continue; + + for (int j = 0; j < SAL_MEDIA_DESCRIPTION_MAX_ICE_REMOTE_CANDIDATES; j++) { const SalIceRemoteCandidate *remote_candidate = &stream->ice_remote_candidates[j]; - if (remote_candidate->addr[0] != '\0') return true; - + if (remote_candidate->addr[0] != '\0') + return true; } } return false; diff --git a/src/nat/ice-agent.h b/src/nat/ice-agent.h index 0e702010b..cb688f0af 100644 --- a/src/nat/ice-agent.h +++ b/src/nat/ice-agent.h @@ -70,7 +70,7 @@ public: * Checks if an incoming offer with ICE needs a delayed answer, because the ice session hasn't completed yet with * connecvity checks. */ - bool checkIceReinviteNeedsDeferedResponse(SalMediaDescription *md); + bool checkIceReinviteNeedsDeferedResponse (SalMediaDescription *md); private: void addLocalIceCandidates (int family, const char *addr, IceCheckList *audioCl, IceCheckList *videoCl, IceCheckList *textCl);