From 25369192ac7f861a101efa084c213b4077c984d4 Mon Sep 17 00:00:00 2001 From: Alexandre Savard <alexandresavard@alexandresavard-desktop.(none)> Date: Mon, 1 Mar 2010 16:54:43 -0500 Subject: [PATCH] [#2926] Code Cleanup --- .../src/audio/audiortp/AudioRtpFactory.cpp | 28 ++++++------- .../src/audio/audiortp/AudioRtpFactory.h | 42 +++++++++---------- .../src/audio/audiortp/AudioZrtpSession.cpp | 1 - .../src/audio/audiortp/AudioZrtpSession.h | 4 +- .../audio/audiortp/ZrtpSessionCallback.cpp | 7 ++-- sflphone-common/src/sip/sdp.cpp | 11 ++--- 6 files changed, 44 insertions(+), 49 deletions(-) diff --git a/sflphone-common/src/audio/audiortp/AudioRtpFactory.cpp b/sflphone-common/src/audio/audiortp/AudioRtpFactory.cpp index e532515d60..646aa89b95 100644 --- a/sflphone-common/src/audio/audiortp/AudioRtpFactory.cpp +++ b/sflphone-common/src/audio/audiortp/AudioRtpFactory.cpp @@ -125,14 +125,14 @@ void AudioRtpFactory::initAudioRtpSession (SIPCall * ca) void AudioRtpFactory::start (void) { if (_rtpSession == NULL) { - throw AudioRtpFactoryException ("_rtpSession was null when trying to start audio thread"); + throw AudioRtpFactoryException ("RTP: Error: _rtpSession was null when trying to start audio thread"); } switch (_rtpSessionType) { case Sdes: if (static_cast<AudioSrtpSession *> (_rtpSession)->startRtpThread() != 0) { - throw AudioRtpFactoryException ("Failed to start AudioSRtpSession thread"); + throw AudioRtpFactoryException ("RTP: Error: Failed to start AudioSRtpSession thread"); } break; @@ -140,7 +140,7 @@ void AudioRtpFactory::start (void) _debug ("Starting symmetric rtp thread"); if (static_cast<AudioSymmetricRtpSession *> (_rtpSession)->startRtpThread() != 0) { - throw AudioRtpFactoryException ("Failed to start AudioSymmetricRtpSession thread"); + throw AudioRtpFactoryException ("RTP: Error: Failed to start AudioSymmetricRtpSession thread"); } break; @@ -148,9 +148,8 @@ void AudioRtpFactory::start (void) case Zrtp: if (static_cast<AudioZrtpSession *> (_rtpSession)->startRtpThread() != 0) { - throw AudioRtpFactoryException ("Failed to start AudioZrtpSession thread"); + throw AudioRtpFactoryException ("RTP: Error: Failed to start AudioZrtpSession thread"); } - break; } } @@ -158,10 +157,10 @@ void AudioRtpFactory::start (void) void AudioRtpFactory::stop (void) { ost::MutexLock mutex (_audioRtpThreadMutex); - _debug ("Stopping audio rtp session"); + _info("RTP: Stopping audio rtp session"); if (_rtpSession == NULL) { - _debugException ("_rtpSession is null when trying to stop. Returning."); + _debugException ("RTP: Error: _rtpSession is null when trying to stop. Returning."); return; } @@ -183,16 +182,16 @@ void AudioRtpFactory::stop (void) _rtpSession = NULL; } catch (...) { - _debugException ("Exception caught when stopping the audio rtp session"); - throw AudioRtpFactoryException("caught exception in AudioRtpFactory::stop"); + _debugException ("RTP: Error: Exception caught when stopping the audio rtp session"); + throw AudioRtpFactoryException("RTP: Error: caught exception in AudioRtpFactory::stop"); } } void AudioRtpFactory::updateDestinationIpAddress (void) { - _debug ("Updating IP address"); + _info ("RTP: Updating IP address"); if (_rtpSession == NULL) { - throw AudioRtpFactoryException ("_rtpSession was null when trying to update IP address"); + throw AudioRtpFactoryException ("RTP: Error: _rtpSession was null when trying to update IP address"); } switch (_rtpSessionType) { @@ -216,19 +215,20 @@ sfl::AudioZrtpSession * AudioRtpFactory::getAudioZrtpSession() if ( (_rtpSessionType == Zrtp) && (_rtpSessionType != NULL)) { return static_cast<AudioZrtpSession *> (_rtpSession); } else { - throw AudioRtpFactoryException("_rtpSession is NULL in getAudioZrtpSession"); + throw AudioRtpFactoryException("RTP: Error: _rtpSession is NULL in getAudioZrtpSession"); } } - void AudioRtpFactory::setRemoteCryptoInfo(sfl::SdesNegotiator& nego) +void AudioRtpFactory::setRemoteCryptoInfo(sfl::SdesNegotiator& nego) { if ( _rtpSession && _rtpSessionType && (_rtpSessionType == Sdes)) { static_cast<AudioSrtpSession *> (_rtpSession)->setRemoteCryptoInfo(nego); } else { - throw AudioRtpFactoryException("_rtpSession is NULL in setRemoteCryptoInfo"); + throw AudioRtpFactoryException("RTP: Error: _rtpSession is NULL in setRemoteCryptoInfo"); } } + } diff --git a/sflphone-common/src/audio/audiortp/AudioRtpFactory.h b/sflphone-common/src/audio/audiortp/AudioRtpFactory.h index cfa14165f1..0076c968c8 100644 --- a/sflphone-common/src/audio/audiortp/AudioRtpFactory.h +++ b/sflphone-common/src/audio/audiortp/AudioRtpFactory.h @@ -63,27 +63,27 @@ namespace sfl { void initAudioRtpConfig(SIPCall *ca); - /** - * Lazy instantiation method. Create a new RTP session of a given - * type according to the content of the configuration file. - * @param ca A pointer on a SIP call - * @return A new AudioRtpSession object - */ - void initAudioRtpSession(SIPCall *ca); - - /** - * Start the audio rtp thread of the type specified in the configuration - * file. initAudioRtpSession must have been called prior to that. - * @param None - */ - void start(); - - /** - * Stop the audio rtp thread of the type specified in the configuration - * file. initAudioRtpSession must have been called prior to that. - * @param None - */ - void stop(); + /** + * Lazy instantiation method. Create a new RTP session of a given + * type according to the content of the configuration file. + * @param ca A pointer on a SIP call + * @return A new AudioRtpSession object + */ + void initAudioRtpSession(SIPCall *ca); + + /** + * Start the audio rtp thread of the type specified in the configuration + * file. initAudioRtpSession must have been called prior to that. + * @param None + */ + void start(); + + /** + * Stop the audio rtp thread of the type specified in the configuration + * file. initAudioRtpSession must have been called prior to that. + * @param None + */ + void stop(); /** * Update current RTP destination address with one stored in call diff --git a/sflphone-common/src/audio/audiortp/AudioZrtpSession.cpp b/sflphone-common/src/audio/audiortp/AudioZrtpSession.cpp index 5b6b67101f..cb82fe29e2 100644 --- a/sflphone-common/src/audio/audiortp/AudioZrtpSession.cpp +++ b/sflphone-common/src/audio/audiortp/AudioZrtpSession.cpp @@ -38,7 +38,6 @@ AudioZrtpSession::AudioZrtpSession (ManagerImpl * manager, SIPCall * sipcall, co { _debug ("AudioZrtpSession initialized"); initializeZid(); - // startZrtp(); } void AudioZrtpSession::initializeZid (void) diff --git a/sflphone-common/src/audio/audiortp/AudioZrtpSession.h b/sflphone-common/src/audio/audiortp/AudioZrtpSession.h index 2e41e04b45..138bd26847 100644 --- a/sflphone-common/src/audio/audiortp/AudioZrtpSession.h +++ b/sflphone-common/src/audio/audiortp/AudioZrtpSession.h @@ -38,8 +38,8 @@ namespace sfl { class AudioZrtpSession : public ost::SymmetricZRTPSession, public AudioRtpSession<AudioZrtpSession> { public: - AudioZrtpSession(ManagerImpl * manager, SIPCall * sipcall, const std::string& zidFilename); - + AudioZrtpSession(ManagerImpl * manager, SIPCall * sipcall, const std::string& zidFilename); + private: void initializeZid(void); std::string _zidFilename; diff --git a/sflphone-common/src/audio/audiortp/ZrtpSessionCallback.cpp b/sflphone-common/src/audio/audiortp/ZrtpSessionCallback.cpp index f866b39e00..145792e0bc 100644 --- a/sflphone-common/src/audio/audiortp/ZrtpSessionCallback.cpp +++ b/sflphone-common/src/audio/audiortp/ZrtpSessionCallback.cpp @@ -150,7 +150,6 @@ ZrtpSessionCallback::showMessage (GnuZrtpCodes::MessageSeverity sev, int32_t sub msg = _infoMap[subCode]; if (msg != NULL) { - _debug ("ZRTP Debug:"); } } @@ -158,7 +157,6 @@ ZrtpSessionCallback::showMessage (GnuZrtpCodes::MessageSeverity sev, int32_t sub msg = _warningMap[subCode]; if (msg != NULL) { - _debug ("ZRTP Debug:"); } } @@ -166,10 +164,11 @@ ZrtpSessionCallback::showMessage (GnuZrtpCodes::MessageSeverity sev, int32_t sub msg = _severeMap[subCode]; if (msg != NULL) { - _debug ("ZRTP Debug:"); } } + + if (sev == ZrtpError) { if (subCode < 0) { // received an error packet from peer subCode *= -1; @@ -181,7 +180,7 @@ ZrtpSessionCallback::showMessage (GnuZrtpCodes::MessageSeverity sev, int32_t sub msg = _zrtpMap[subCode]; if (msg != NULL) { - _debug ("ZRTP Debug: %s", msg->c_str()); + } } } diff --git a/sflphone-common/src/sip/sdp.cpp b/sflphone-common/src/sip/sdp.cpp index ba4e856b30..886dc1430f 100644 --- a/sflphone-common/src/sip/sdp.cpp +++ b/sflphone-common/src/sip/sdp.cpp @@ -489,9 +489,6 @@ void Sdp::set_negotiated_sdp (const pjmedia_sdp_session *sdp) pjmedia_sdp_attr_to_rtpmap (_pool, attribute, &rtpmap); - // _debug("================== set_negociated_offer ===================== %i", pj_strtoul(&rtpmap->pt)); - // _debug("================== set_negociated_offer ===================== %s", current->desc.fmt[j].ptr); - // _debug("================== set_negociated_offer ===================== %i", atoi(current->desc.fmt[j].ptr)); iter = codecs_list.find ( (AudioCodecType) pj_strtoul (&rtpmap->pt)); if (iter==codecs_list.end()) @@ -627,7 +624,7 @@ void Sdp::set_remote_ip_from_sdp (const pjmedia_sdp_session *r_sdp) { std::string remote_ip (r_sdp->conn->addr.ptr, r_sdp->conn->addr.slen); - _debug (" Remote IP from fetching SDP: %s", remote_ip.c_str()); + _info ("SDP: Remote IP from fetching SDP: %s", remote_ip.c_str()); this->set_remote_ip (remote_ip); } @@ -637,21 +634,21 @@ void Sdp::set_remote_audio_port_from_sdp (pjmedia_sdp_media *r_media) int remote_port; remote_port = r_media->desc.port; - _debug (" Remote Audio Port from fetching SDP: %d", remote_port); + _info ("SDP: Remote Audio Port from fetching SDP: %d", remote_port); this->set_remote_audio_port (remote_port); } void Sdp::set_media_transport_info_from_remote_sdp (const pjmedia_sdp_session *remote_sdp) { - _debug ("Fetching media from sdp"); + _info ("SDP: Fetching media from sdp"); pjmedia_sdp_media *r_media; this->get_remote_sdp_media_from_offer (remote_sdp, &r_media); if (r_media==NULL) { - _debug ("SDP Failure: no remote sdp media found in the remote offer"); + _warn ("SDP: Error: no remote sdp media found in the remote offer"); return; } -- GitLab