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
......@@ -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;
}
......
......@@ -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)
{
......
......@@ -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 */
......
......@@ -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());
}
......@@ -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*
......
Supports Markdown
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