Skip to content
Snippets Groups Projects
Commit ab3df1e1 authored by Emmanuel Milou's avatar Emmanuel Milou
Browse files

Build RTP session with right remote IP and remote audio port

parent a6edb365
No related branches found
No related tags found
No related merge requests found
...@@ -185,19 +185,22 @@ AudioRtpRTX::initBuffers() ...@@ -185,19 +185,22 @@ AudioRtpRTX::initBuffers()
void void
AudioRtpRTX::initAudioRtpSession (void) AudioRtpRTX::initAudioRtpSession (void)
{ {
std::string remoteIP;
unsigned int remotePort;
try { try {
if (_ca == 0) { return; } if (_ca == 0) { return; }
_audiocodec = Manager::instance().getCodecDescriptorMap().getCodec( _ca->getLocalSDP()->getAudioCodec() ); _audiocodec = Manager::instance().getCodecDescriptorMap().getCodec( _ca->getLocalSDP()->getAudioCodec() );
_codecSampleRate = _audiocodec->getClockRate(); _codecSampleRate = _audiocodec->getClockRate();
_debug("Init audio RTP session\n"); remoteIP = _ca->getLocalSDP()->getRemoteIp();
ost::InetHostAddress remote_ip(_ca->getRemoteIp().c_str()); _debug("Init audio RTP session - remote IP = %s\n", remoteIP.c_str());
ost::InetHostAddress remote_ip(remoteIP.c_str());
if (!remote_ip) { 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; return;
} }
if (!_sym) { if (!_sym) {
_sessionRecv->setSchedulingTimeout (10000); _sessionRecv->setSchedulingTimeout (10000);
_sessionRecv->setExpireTimeout(1000000); _sessionRecv->setExpireTimeout(1000000);
...@@ -210,12 +213,13 @@ AudioRtpRTX::initAudioRtpSession (void) ...@@ -210,12 +213,13 @@ AudioRtpRTX::initAudioRtpSession (void)
} }
if (!_sym) { if (!_sym) {
if ( !_sessionRecv->addDestination(remote_ip, (unsigned short) _ca->getRemoteAudioPort()) ) { remotePort = _ca->getLocalSDP()->getRemoteAudioPort();
_debug("AudioRTP Thread Error: could not connect to port %d\n", _ca->getRemoteAudioPort()); if ( !_sessionRecv->addDestination(remote_ip, (unsigned short) remotePort) ) {
_debug("AudioRTP Thread Error: could not connect to port %d\n", remotePort);
return; return;
} }
if (!_sessionSend->addDestination (remote_ip, (unsigned short) _ca->getRemoteAudioPort())) { if (!_sessionSend->addDestination (remote_ip, (unsigned short) remotePort)) {
_debug("! ARTP Thread Error: could not connect to port %d\n", _ca->getRemoteAudioPort()); _debug("! ARTP Thread Error: could not connect to port %d\n", remotePort);
return; return;
} }
...@@ -233,7 +237,7 @@ AudioRtpRTX::initAudioRtpSession (void) ...@@ -233,7 +237,7 @@ AudioRtpRTX::initAudioRtpSession (void)
//_debug("AudioRTP Thread: Added session destination %s\n", remote_ip.getHostname() ); //_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; return;
} }
......
...@@ -26,8 +26,6 @@ Call::Call(const CallID& id, Call::CallType type) ...@@ -26,8 +26,6 @@ Call::Call(const CallID& id, Call::CallType type)
, _localIPAddress("") , _localIPAddress("")
, _localAudioPort(0) , _localAudioPort(0)
, _localExternalAudioPort(0) , _localExternalAudioPort(0)
, _remoteIPAddress("")
, _remoteAudioPort(0)
, _id(id) , _id(id)
, _type(type) , _type(type)
, _connectionState(Call::Disconnected) , _connectionState(Call::Disconnected)
...@@ -97,20 +95,6 @@ Call::getLocalAudioPort() ...@@ -97,20 +95,6 @@ Call::getLocalAudioPort()
return _localAudioPort; return _localAudioPort;
} }
unsigned int
Call::getRemoteAudioPort()
{
ost::MutexLock m(_callMutex);
return _remoteAudioPort;
}
const std::string&
Call::getRemoteIp()
{
ost::MutexLock m(_callMutex);
return _remoteIPAddress;
}
void void
Call::setAudioStart(bool start) Call::setAudioStart(bool start)
{ {
......
...@@ -180,18 +180,6 @@ class Call{ ...@@ -180,18 +180,6 @@ class Call{
*/ */
unsigned int getLocalAudioPort(); 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 * @return Return the file name for this call
*/ */
...@@ -226,18 +214,6 @@ class Call{ ...@@ -226,18 +214,6 @@ class Call{
/** Protect every attribute that can be changed by two threads */ /** Protect every attribute that can be changed by two threads */
ost::Mutex _callMutex; 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; bool _audioStarted;
// Informations about call socket / audio // Informations about call socket / audio
...@@ -251,12 +227,6 @@ class Call{ ...@@ -251,12 +227,6 @@ class Call{
/** Port assigned to my machine by the NAT, as seen by remote peer (he connects there) */ /** Port assigned to my machine by the NAT, as seen by remote peer (he connects there) */
unsigned int _localExternalAudioPort; unsigned int _localExternalAudioPort;
/** Remote's IP address */
std::string _remoteIPAddress;
/** Remote's audio port */
unsigned int _remoteAudioPort;
private: private:
......
...@@ -147,10 +147,10 @@ Sdp::setRemoteAudioFromSDP(pjmedia_sdp_session* remote_sdp, pjmedia_sdp_media *r ...@@ -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); std::string remoteIP(remote_sdp->conn->addr.ptr, remote_sdp->conn->addr.slen);
_debug(" Remote Audio IP: %s\n", remoteIP.data()); _debug(" Remote Audio IP: %s\n", remoteIP.data());
//setRemoteIP(remoteIP); setRemoteIP(remoteIP);
int remotePort = remote_med->desc.port; int remotePort = remote_med->desc.port;
_debug(" Remote Audio Port: %d\n", remotePort); _debug(" Remote Audio Port: %d\n", remotePort);
//setRemoteAudioPort(remotePort); setRemoteAudioPort(remotePort);
return true; return true;
} }
...@@ -382,6 +382,6 @@ void Sdp::toString (void) { ...@@ -382,6 +382,6 @@ void Sdp::toString (void) {
sdp << "fmt_count=" << _localSDP->media[0]->desc.fmt_count << "\n"; sdp << "fmt_count=" << _localSDP->media[0]->desc.fmt_count << "\n";
sdp << "fmt=" << _localSDP->media[0]->desc.fmt[0].ptr << "\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());
} }
...@@ -101,6 +101,31 @@ class Sdp { ...@@ -101,6 +101,31 @@ class Sdp {
AudioCodecType getAudioCodec (void) { return _audioCodec; } 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: private:
/** /**
* Set the audio codec used. [not protected] * Set the audio codec used. [not protected]
...@@ -116,6 +141,13 @@ class Sdp { ...@@ -116,6 +141,13 @@ class Sdp {
int _localPort; int _localPort;
/** Remote's IP address */
std::string _remoteIPAddress;
/** Remote's audio port */
unsigned int _remoteAudioPort;
/** /**
* Get a valid remote media * Get a valid remote media
* @param remote_sdp pjmedia_sdp_session* * @param remote_sdp pjmedia_sdp_session*
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment