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

fix port problems

parent b61c3339
No related branches found
No related tags found
No related merge requests found
...@@ -196,7 +196,7 @@ AudioRtpRTX::initAudioRtpSession (void) ...@@ -196,7 +196,7 @@ AudioRtpRTX::initAudioRtpSession (void)
_codecSampleRate = _audiocodec->getClockRate(); _codecSampleRate = _audiocodec->getClockRate();
remoteIP = _ca->getRemoteIp(); remoteIP = _ca->getLocalSDP()->get_remote_ip();
_debug("Init audio RTP session - remote IP = %s\n", remoteIP.c_str()); _debug("Init audio RTP session - remote IP = %s\n", remoteIP.c_str());
ost::InetHostAddress remote_ip(remoteIP.c_str()); ost::InetHostAddress remote_ip(remoteIP.c_str());
if (!remote_ip) { if (!remote_ip) {
......
...@@ -165,6 +165,10 @@ int Sdp::receiving_initial_offer( pjmedia_sdp_session* remote ){ ...@@ -165,6 +165,10 @@ int Sdp::receiving_initial_offer( pjmedia_sdp_session* remote ){
// Build the local offer to respond // Build the local offer to respond
create_local_offer( ); create_local_offer( );
// Retrieve some useful remote information
this->fetch_remote_ip_from_sdp (remote);
//this->fetch_remote_audio_port_from_sdp ();
status = pjmedia_sdp_neg_create_w_remote_offer( _pool, status = pjmedia_sdp_neg_create_w_remote_offer( _pool,
get_local_sdp_session(), remote, &_negociator ); get_local_sdp_session(), remote, &_negociator );
state = pjmedia_sdp_neg_get_state( _negociator ); state = pjmedia_sdp_neg_get_state( _negociator );
...@@ -347,7 +351,7 @@ void Sdp::set_local_media_capabilities () { ...@@ -347,7 +351,7 @@ void Sdp::set_local_media_capabilities () {
/* Only one audio media used right now */ /* Only one audio media used right now */
audio = new sdpMedia(MIME_TYPE_AUDIO); audio = new sdpMedia(MIME_TYPE_AUDIO);
audio->set_port (_localAudioPort); audio->set_port (getocalAudioPort);
/* We retrieve the codecs selected by the user */ /* We retrieve the codecs selected by the user */
selected_codecs = Manager::instance().getCodecDescriptorMap().getActiveCodecs(); selected_codecs = Manager::instance().getCodecDescriptorMap().getActiveCodecs();
...@@ -367,6 +371,8 @@ void Sdp::attribute_port_to_all_media (int port) { ...@@ -367,6 +371,8 @@ void Sdp::attribute_port_to_all_media (int port) {
std::vector<sdpMedia*> medias; std::vector<sdpMedia*> medias;
int i, size; int i, size;
set_local_extern_audio_port (port);
medias = get_local_media_cap (); medias = get_local_media_cap ();
size = medias.size(); size = medias.size();
...@@ -381,3 +387,12 @@ std::string Sdp::convert_int_to_string (int value) { ...@@ -381,3 +387,12 @@ std::string Sdp::convert_int_to_string (int value) {
result << value; result << value;
return result.str(); return result.str();
} }
void Sdp::fetch_remote_ip_from_sdp (pjmedia_sdp_session *r_sdp) {
std::string remote_ip;
remote_ip = r_sdp->conn->addr.ptr;
_debug(" Remote Audio IP: %s\n", remote_ip.c_str());
set_remote_ip(remote_ip);
}
...@@ -149,10 +149,10 @@ class Sdp { ...@@ -149,10 +149,10 @@ class Sdp {
*/ */
void attribute_port_to_all_media (int port); void attribute_port_to_all_media (int port);
///////////////////////////////////////////////////////////////////////////33 void set_local_extern_audio_port(int port){ _local_extern_audio_port = port; }
void setLocalExternAudioPort(int port){ _localAudioPort = port; }
int getLocalExternAudioPort (void){ return _localAudioPort; } int get_local_extern_audio_port (void){ return _local_extern_audio_port; }
///////////////////////////////////////////////////////////////////////////33
void toString (void); void toString (void);
...@@ -160,25 +160,25 @@ class Sdp { ...@@ -160,25 +160,25 @@ class Sdp {
* Set remote's IP addr. [not protected] * Set remote's IP addr. [not protected]
* @param ip The remote IP address * @param ip The remote IP address
*/ */
void setRemoteIP(const std::string& ip) { _remoteIPAddress = ip; } void set_remote_ip(const std::string& ip) { _remoteIPAddress = ip; }
/** /**
* Set remote's audio port. [not protected] * Set remote's audio port. [not protected]
* @param port The remote audio port * @param port The remote audio port
*/ */
void setRemoteAudioPort(unsigned int port) { _remoteAudioPort = port; } void set_remote_audio_port(unsigned int port) { _remote_audio_port = port; }
/** /**
* Return audio port at destination [mutex protected] * Return audio port at destination [mutex protected]
* @return unsigned int The remote audio port * @return unsigned int The remote audio port
*/ */
unsigned int getRemoteAudioPort() { return _remoteAudioPort; } unsigned int get_remote_audio_port() { return _remote_audio_port; }
/** /**
* Return IP of destination [mutex protected] * Return IP of destination [mutex protected]
* @return const std:string The remote IP address * @return const std:string The remote IP address
*/ */
const std::string& getRemoteIp() { return _remoteIPAddress; } const std::string& get_remote_ip() { return _remoteIPAddress; }
///////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////
...@@ -288,7 +288,11 @@ class Sdp { ...@@ -288,7 +288,11 @@ class Sdp {
std::string convert_int_to_string (int value); std::string convert_int_to_string (int value);
int _localAudioPort; void fetch_remote_ip_from_sdp (pjmedia_sdp_session *r_sdp);
void fetch_remote_audio_port_from_sdp (pjmedia_sdp_media *r_sdp);
int _local_extern_audio_port;
//////////////////////////////////////////////////////////////////3 //////////////////////////////////////////////////////////////////3
/** Remote's IP address */ /** Remote's IP address */
......
...@@ -477,6 +477,8 @@ SIPVoIPLink::answer(const CallID& id) ...@@ -477,6 +477,8 @@ SIPVoIPLink::answer(const CallID& id)
SIPCall *call; SIPCall *call;
pj_status_t status; pj_status_t status;
pjsip_tx_data *tdata; pjsip_tx_data *tdata;
Sdp *local_sdp;
pjsip_inv_session *inv_session;
_debug("SIPVoIPLink::answer: start answering \n"); _debug("SIPVoIPLink::answer: start answering \n");
...@@ -487,15 +489,19 @@ SIPVoIPLink::answer(const CallID& id) ...@@ -487,15 +489,19 @@ SIPVoIPLink::answer(const CallID& id)
return false; return false;
} }
// User answered the incoming call, tell peer this news local_sdp = call->getLocalSDP();
if (call->getLocalSDP()->start_negociation()) { inv_session = call->getInvSession();
// Create and send a 200(OK) response status = local_sdp->start_negociation ();
if (status == PJ_SUCCESS) {
_debug("SIPVoIPLink::answer:UserAgent: Negociation success! : call %s \n", call->getCallId().c_str()); _debug("SIPVoIPLink::answer:UserAgent: Negociation success! : call %s \n", call->getCallId().c_str());
status = pjsip_inv_answer(call->getInvSession(), PJSIP_SC_OK, NULL, NULL, &tdata); // Create and send a 200(OK) response
status = pjsip_inv_answer(inv_session, PJSIP_SC_OK, NULL, NULL, &tdata);
PJ_ASSERT_RETURN(status == PJ_SUCCESS, 1); PJ_ASSERT_RETURN(status == PJ_SUCCESS, 1);
status = pjsip_inv_send_msg(call->getInvSession(), tdata); status = pjsip_inv_send_msg(inv_session, tdata);
PJ_ASSERT_RETURN(status == PJ_SUCCESS, 1); PJ_ASSERT_RETURN(status == PJ_SUCCESS, 1);
// Start the RTP sessions
_debug("SIPVoIPLink::answer: Starting AudioRTP when answering : call %s \n", call->getCallId().c_str()); _debug("SIPVoIPLink::answer: Starting AudioRTP when answering : call %s \n", call->getCallId().c_str());
if (_audiortp->createNewSession(call) >= 0) { if (_audiortp->createNewSession(call) >= 0) {
call->setAudioStart(true); call->setAudioStart(true);
...@@ -506,11 +512,22 @@ SIPVoIPLink::answer(const CallID& id) ...@@ -506,11 +512,22 @@ SIPVoIPLink::answer(const CallID& id)
_debug("SIPVoIPLink::answer: Unable to start sound when answering %s/%d\n", __FILE__, __LINE__); _debug("SIPVoIPLink::answer: Unable to start sound when answering %s/%d\n", __FILE__, __LINE__);
} }
} }
else {
// Create and send a 488/Not acceptable here
// because the SDP negociation failed
status = pjsip_inv_answer( inv_session, PJSIP_SC_NOT_ACCEPTABLE_HERE, NULL, NULL,
&tdata );
PJ_ASSERT_RETURN( status == PJ_SUCCESS, 1 );
status = pjsip_inv_send_msg( inv_session, tdata );
PJ_ASSERT_RETURN( status == PJ_SUCCESS, 1 );
// Terminate the call
_debug("SIPVoIPLink::answer: fail terminate call %s \n",call->getCallId().c_str()); _debug("SIPVoIPLink::answer: fail terminate call %s \n",call->getCallId().c_str());
terminateOneCall(call->getCallId()); terminateOneCall(call->getCallId());
removeCall(call->getCallId()); removeCall(call->getCallId());
return false; return false;
} }
}
bool bool
SIPVoIPLink::hangup(const CallID& id) SIPVoIPLink::hangup(const CallID& id)
......
...@@ -112,7 +112,7 @@ class SIPVoIPLink : public VoIPLink ...@@ -112,7 +112,7 @@ class SIPVoIPLink : public VoIPLink
/** /**
* Answer the call * Answer the call
* @param id The call identifier * @param id The call identifier
* @return bool True on success * @return int True on success
*/ */
bool answer(const CallID& id); bool answer(const CallID& id);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment