diff --git a/src/audio/audiortp.cpp b/src/audio/audiortp.cpp index d60367ad916e196d027c1d270a3455290a624935..7810bc9c5c8da2eca21cafe98a460ad787029d4d 100644 --- a/src/audio/audiortp.cpp +++ b/src/audio/audiortp.cpp @@ -185,19 +185,22 @@ AudioRtpRTX::initBuffers() void AudioRtpRTX::initAudioRtpSession (void) { + std::string remoteIP; + unsigned int remotePort; + try { if (_ca == 0) { return; } _audiocodec = Manager::instance().getCodecDescriptorMap().getCodec( _ca->getLocalSDP()->getAudioCodec() ); _codecSampleRate = _audiocodec->getClockRate(); - _debug("Init audio RTP session\n"); - ost::InetHostAddress remote_ip(_ca->getRemoteIp().c_str()); + remoteIP = _ca->getLocalSDP()->getRemoteIp(); + _debug("Init audio RTP session - remote IP = %s\n", remoteIP.c_str()); + ost::InetHostAddress remote_ip(remoteIP.c_str()); if (!remote_ip) { - _debug("! ARTP Thread Error: Target IP address [%s] is not correct!\n", _ca->getRemoteIp().data()); + _debug("! ARTP Thread Error: Target IP address [%s] is not correct!\n", remoteIP.data()); return; } - if (!_sym) { _sessionRecv->setSchedulingTimeout (10000); _sessionRecv->setExpireTimeout(1000000); @@ -210,12 +213,13 @@ AudioRtpRTX::initAudioRtpSession (void) } if (!_sym) { - if ( !_sessionRecv->addDestination(remote_ip, (unsigned short) _ca->getRemoteAudioPort()) ) { - _debug("AudioRTP Thread Error: could not connect to port %d\n", _ca->getRemoteAudioPort()); + remotePort = _ca->getLocalSDP()->getRemoteAudioPort(); + if ( !_sessionRecv->addDestination(remote_ip, (unsigned short) remotePort) ) { + _debug("AudioRTP Thread Error: could not connect to port %d\n", remotePort); return; } - if (!_sessionSend->addDestination (remote_ip, (unsigned short) _ca->getRemoteAudioPort())) { - _debug("! ARTP Thread Error: could not connect to port %d\n", _ca->getRemoteAudioPort()); + if (!_sessionSend->addDestination (remote_ip, (unsigned short) remotePort)) { + _debug("! ARTP Thread Error: could not connect to port %d\n", remotePort); return; } @@ -233,7 +237,7 @@ AudioRtpRTX::initAudioRtpSession (void) //_debug("AudioRTP Thread: Added session destination %s\n", remote_ip.getHostname() ); - if (!_session->addDestination (remote_ip, (unsigned short) _ca->getRemoteAudioPort())) { + if (!_session->addDestination (remote_ip, (unsigned short) remotePort)) { return; } diff --git a/src/call.cpp b/src/call.cpp index 36496be7da189a5945233c3b8f5877b344f36703..b1625d346e3bc726bb6c48c66cf91a49e1323ad5 100644 --- a/src/call.cpp +++ b/src/call.cpp @@ -26,8 +26,6 @@ Call::Call(const CallID& id, Call::CallType type) , _localIPAddress("") , _localAudioPort(0) , _localExternalAudioPort(0) - , _remoteIPAddress("") - , _remoteAudioPort(0) , _id(id) , _type(type) , _connectionState(Call::Disconnected) @@ -97,20 +95,6 @@ Call::getLocalAudioPort() return _localAudioPort; } -unsigned int -Call::getRemoteAudioPort() -{ - ost::MutexLock m(_callMutex); - return _remoteAudioPort; -} - -const std::string& -Call::getRemoteIp() -{ - ost::MutexLock m(_callMutex); - return _remoteIPAddress; -} - void Call::setAudioStart(bool start) { diff --git a/src/call.h b/src/call.h index 5fac0b23a790d46608f979cc6f61785272e3af77..d82ff7ba583c2253571532ddcd7f80561cf3aad2 100644 --- a/src/call.h +++ b/src/call.h @@ -180,18 +180,6 @@ class Call{ */ unsigned int getLocalAudioPort(); - /** - * Return audio port at destination [mutex protected] - * @return unsigned int The remote audio port - */ - unsigned int getRemoteAudioPort(); - - /** - * Return IP of destination [mutex protected] - * @return const std:string The remote IP address - */ - const std::string& getRemoteIp(); - /** * @return Return the file name for this call */ @@ -226,18 +214,6 @@ class Call{ /** Protect every attribute that can be changed by two threads */ ost::Mutex _callMutex; - /** - * Set remote's IP addr. [not protected] - * @param ip The remote IP address - */ - void setRemoteIP(const std::string& ip) { _remoteIPAddress = ip; } - - /** - * Set remote's audio port. [not protected] - * @param port The remote audio port - */ - void setRemoteAudioPort(unsigned int port) { _remoteAudioPort = port; } - bool _audioStarted; // Informations about call socket / audio @@ -251,13 +227,7 @@ class Call{ /** Port assigned to my machine by the NAT, as seen by remote peer (he connects there) */ unsigned int _localExternalAudioPort; - /** Remote's IP address */ - std::string _remoteIPAddress; - - /** Remote's audio port */ - unsigned int _remoteAudioPort; - - + private: /** Unique ID of the call */ diff --git a/src/sdp.cpp b/src/sdp.cpp index b7dc1d1f6d1327f4d4496b3d8c74974ba38f98af..f89dd5b540cd059ce35b3e6d8bc451e32fa1075a 100644 --- a/src/sdp.cpp +++ b/src/sdp.cpp @@ -147,10 +147,10 @@ Sdp::setRemoteAudioFromSDP(pjmedia_sdp_session* remote_sdp, pjmedia_sdp_media *r { std::string remoteIP(remote_sdp->conn->addr.ptr, remote_sdp->conn->addr.slen); _debug(" Remote Audio IP: %s\n", remoteIP.data()); - //setRemoteIP(remoteIP); + setRemoteIP(remoteIP); int remotePort = remote_med->desc.port; _debug(" Remote Audio Port: %d\n", remotePort); - //setRemoteAudioPort(remotePort); + setRemoteAudioPort(remotePort); return true; } @@ -382,6 +382,6 @@ void Sdp::toString (void) { sdp << "fmt_count=" << _localSDP->media[0]->desc.fmt_count << "\n"; sdp << "fmt=" << _localSDP->media[0]->desc.fmt[0].ptr << "\n"; - _debug ("LOCAL SDP: \n%s\n", sdp.str().c_str()); + //_debug ("LOCAL SDP: \n%s\n", sdp.str().c_str()); } diff --git a/src/sdp.h b/src/sdp.h index 9ddc0ebcc506e361dce860e3927002adf5b9be04..99d96ba7ac058e135ba1925d074970ad9edeed8e 100644 --- a/src/sdp.h +++ b/src/sdp.h @@ -90,9 +90,9 @@ class Sdp { * @return CodecDescriptor The codec map */ CodecDescriptor& getCodecMap(){ return _codecMap; } - + void setLocalExternAudioPort(int port){ _localPort = port; } - + int getLocalExternAudioPort (void){ return _localPort; } int receiving_initial_offer( pjmedia_sdp_session* remote ); @@ -100,7 +100,32 @@ class Sdp { void toString (void); AudioCodecType getAudioCodec (void) { return _audioCodec; } - + + /** + * Set remote's IP addr. [not protected] + * @param ip The remote IP address + */ + void setRemoteIP(const std::string& ip) { _remoteIPAddress = ip; } + + /** + * Set remote's audio port. [not protected] + * @param port The remote audio port + */ + void setRemoteAudioPort(unsigned int port) { _remoteAudioPort = port; } + + /** + * Return audio port at destination [mutex protected] + * @return unsigned int The remote audio port + */ + unsigned int getRemoteAudioPort() { return _remoteAudioPort; } + + /** + * Return IP of destination [mutex protected] + * @return const std:string The remote IP address + */ + const std::string& getRemoteIp() { return _remoteIPAddress; } + + private: /** * Set the audio codec used. [not protected] @@ -116,6 +141,13 @@ class Sdp { int _localPort; + /** Remote's IP address */ + std::string _remoteIPAddress; + + /** Remote's audio port */ + unsigned int _remoteAudioPort; + + /** * Get a valid remote media * @param remote_sdp pjmedia_sdp_session*