mirror of
https://git.jami.net/savoirfairelinux/jami-daemon.git
synced 2025-08-07 22:02:12 +08:00
[#2906] Update RTP remote ip address during this call_onb_media_update
Was previously updated during handle_reinvite
This commit is contained in:
@ -208,7 +208,7 @@ namespace sfl {
|
||||
|
||||
assert(_ca);
|
||||
|
||||
_debug ("Local audio port %i will be used\n", _ca->getLocalAudioPort());
|
||||
_debug ("Local audio port %i will be used", _ca->getLocalAudioPort());
|
||||
|
||||
//mic, we receive from soundcard in stereo, and we send encoded
|
||||
_audiolayer = _manager->getAudioDriver();
|
||||
@ -223,7 +223,7 @@ namespace sfl {
|
||||
template <typename D>
|
||||
AudioRtpSession<D>::~AudioRtpSession()
|
||||
{
|
||||
_debug ("Delete AudioRtpSession instance\n");
|
||||
_debug ("Delete AudioRtpSession instance");
|
||||
|
||||
try {
|
||||
terminate();
|
||||
@ -232,7 +232,7 @@ namespace sfl {
|
||||
throw;
|
||||
}
|
||||
|
||||
_debug("Unbind audio RTP stream for call id %s\n", _ca->getCallId().c_str());
|
||||
_debug("Unbind audio RTP stream for call id %s", _ca->getCallId().c_str());
|
||||
// _audiolayer->getMainBuffer()->unBindAll(_ca->getCallId());
|
||||
_manager->getAudioDriver()->getMainBuffer()->unBindAll(_ca->getCallId());
|
||||
|
||||
@ -243,7 +243,7 @@ namespace sfl {
|
||||
delete [] _spkrDataConverted;
|
||||
delete _time;
|
||||
delete _converter;
|
||||
_debug ("AudioRtpSession instance deleted\n");
|
||||
_debug ("AudioRtpSession instance deleted");
|
||||
}
|
||||
|
||||
template <typename D>
|
||||
@ -292,24 +292,24 @@ namespace sfl {
|
||||
_audiocodec = _manager->getCodecDescriptorMap().instantiateCodec(pl);
|
||||
|
||||
if (_audiocodec == NULL) {
|
||||
_debug ("No audiocodec, can't init RTP media\n");
|
||||
_debug ("No audiocodec, can't init RTP media");
|
||||
throw AudioRtpSessionException();
|
||||
}
|
||||
|
||||
_debug ("Init audio RTP session: codec payload %i\n", _audiocodec->getPayload());
|
||||
_debug ("Init audio RTP session: codec payload %i", _audiocodec->getPayload());
|
||||
|
||||
_codecSampleRate = _audiocodec->getClockRate();
|
||||
_codecFrameSize = _audiocodec->getFrameSize();
|
||||
|
||||
//TODO: figure out why this is necessary.
|
||||
if (_audiocodec->getPayload() == 9) {
|
||||
_debug ("Setting payload format to G722\n");
|
||||
_debug ("Setting payload format to G722");
|
||||
static_cast<D*>(this)->setPayloadFormat (ost::DynamicPayloadFormat ( (ost::PayloadType) _audiocodec->getPayload(), _audiocodec->getClockRate()));
|
||||
} else if (_audiocodec->hasDynamicPayload()) {
|
||||
_debug ("Setting a dynamic payload format\n");
|
||||
_debug ("Setting a dynamic payload format");
|
||||
static_cast<D*>(this)->setPayloadFormat (ost::DynamicPayloadFormat ( (ost::PayloadType) _audiocodec->getPayload(), _audiocodec->getClockRate()));
|
||||
} else if (!_audiocodec->hasDynamicPayload() && _audiocodec->getPayload() != 9) {
|
||||
_debug ("Setting a static payload format\n");
|
||||
_debug ("Setting a static payload format");
|
||||
static_cast<D*>(this)->setPayloadFormat (ost::StaticPayloadFormat ( (ost::StaticPayloadType) _audiocodec->getPayload()));
|
||||
}
|
||||
}
|
||||
@ -318,18 +318,18 @@ namespace sfl {
|
||||
void AudioRtpSession<D>::setDestinationIpAddress(void)
|
||||
{
|
||||
if (_ca == NULL) {
|
||||
_debug ("Sipcall is gone.\n");
|
||||
_debug ("Sipcall is gone.");
|
||||
throw AudioRtpSessionException();
|
||||
}
|
||||
|
||||
_debug ("Setting IP address for the RTP session\n");
|
||||
_debug ("Setting IP address for the RTP session");
|
||||
|
||||
// Store remote ip in case we would need to forget current destination
|
||||
_remote_ip = ost::InetHostAddress(_ca->getLocalSDP()->get_remote_ip().c_str());
|
||||
_debug ("Init audio RTP session: remote ip %s\n", _ca->getLocalSDP()->get_remote_ip().data());
|
||||
_debug ("Init audio RTP session: remote ip %s", _ca->getLocalSDP()->get_remote_ip().data());
|
||||
|
||||
if (!_remote_ip) {
|
||||
_debug ("Target IP address [%s] is not correct!\n", _ca->getLocalSDP()->get_remote_ip().data());
|
||||
_debug ("Target IP address [%s] is not correct!", _ca->getLocalSDP()->get_remote_ip().data());
|
||||
return;
|
||||
}
|
||||
|
||||
@ -337,7 +337,7 @@ namespace sfl {
|
||||
_remote_port = (unsigned short) _ca->getLocalSDP()->get_remote_audio_port();
|
||||
|
||||
if (! static_cast<D*>(this)->addDestination (_remote_ip, _remote_port)) {
|
||||
_debug ("Can't add destination to session!\n");
|
||||
_debug ("Can't add destination to session!");
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -347,6 +347,7 @@ namespace sfl {
|
||||
{
|
||||
// Destination address are stored in a list in ccrtp
|
||||
// This method clear off this entry
|
||||
_debug("updateDestinationIpAddress: remove destination %s", _ca->getLocalSDP()->get_remote_ip().c_str());
|
||||
static_cast<D*>(this)->forgetDestination(_remote_ip, _remote_port);
|
||||
|
||||
// new destination is stored in call
|
||||
@ -473,12 +474,12 @@ namespace sfl {
|
||||
_timestamp += _codecFrameSize;
|
||||
|
||||
if (!_audiolayer) {
|
||||
_debug ("No audiolayer available for MIC\n");
|
||||
_debug ("No audiolayer available for MIC");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!_audiocodec) {
|
||||
_debug ("No audiocodec available for MIC\n");
|
||||
_debug ("No audiocodec available for MIC");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -493,12 +494,12 @@ namespace sfl {
|
||||
void AudioRtpSession<D>::receiveSpeakerData ()
|
||||
{
|
||||
if (!_audiolayer) {
|
||||
_debug ("No audiolayer available for speaker\n");
|
||||
_debug ("No audiolayer available for speaker");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!_audiocodec) {
|
||||
_debug ("No audiocodec available for speaker\n");
|
||||
_debug ("No audiocodec available for speaker");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -524,7 +525,7 @@ namespace sfl {
|
||||
template <typename D>
|
||||
int AudioRtpSession<D>::startRtpThread ()
|
||||
{
|
||||
_debug("Starting main thread\n");
|
||||
_debug("Starting main thread");
|
||||
return start(_mainloopSemaphore);
|
||||
}
|
||||
|
||||
@ -553,7 +554,7 @@ namespace sfl {
|
||||
|
||||
if (_audiolayer == NULL) {
|
||||
_debug("For some unknown reason, audiolayer is null, just as \
|
||||
we were about to start the audio stream\n");
|
||||
we were about to start the audio stream");
|
||||
throw AudioRtpSessionException();
|
||||
}
|
||||
|
||||
@ -564,7 +565,7 @@ namespace sfl {
|
||||
static_cast<D*>(this)->startRunning();
|
||||
|
||||
|
||||
_debug ("Entering RTP mainloop for callid %s\n",_ca->getCallId().c_str());
|
||||
_debug ("Entering RTP mainloop for callid %s",_ca->getCallId().c_str());
|
||||
|
||||
while (!testCancel()) {
|
||||
|
||||
@ -600,7 +601,7 @@ namespace sfl {
|
||||
TimerPort::incTimer (threadSleep);
|
||||
}
|
||||
|
||||
_debug ("Left RTP main loop for callid %s\n",_ca->getCallId().c_str());
|
||||
_debug ("Left RTP main loop for callid %s",_ca->getCallId().c_str());
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -563,7 +563,7 @@ void MainBuffer::stateInfo()
|
||||
iter_call_id++;
|
||||
}
|
||||
|
||||
_debug ("%s\n", dbg_str.c_str());
|
||||
_debug ("%s", dbg_str.c_str());
|
||||
|
||||
iter_call++;
|
||||
}
|
||||
@ -597,7 +597,7 @@ void MainBuffer::stateInfo()
|
||||
}
|
||||
}
|
||||
|
||||
_debug ("%s\n", dbg_str.c_str());
|
||||
_debug ("%s", dbg_str.c_str());
|
||||
|
||||
iter_buffer++;
|
||||
}
|
||||
|
@ -494,8 +494,8 @@ void PulseLayer::writeToSpeaker (void)
|
||||
urgentAvailBytes = _urgentRingBuffer.AvailForGet();
|
||||
|
||||
|
||||
// available bytes to be written in pulseaudio internal buffer
|
||||
int writeableSize = pa_stream_writable_size (playback->pulseStream());
|
||||
// _debug("PulseLayer writablesize : %i", writeableSize);
|
||||
|
||||
if (writeableSize < 0)
|
||||
_debug ("PulseLayer playback error : %s", pa_strerror (writeableSize));
|
||||
@ -503,15 +503,10 @@ void PulseLayer::writeToSpeaker (void)
|
||||
|
||||
if (urgentAvailBytes > writeableSize) {
|
||||
|
||||
// _debug("urgentAvailBytes: %i", urgentAvailBytes);
|
||||
|
||||
// _debug("Play Urgent!");
|
||||
|
||||
out = (SFLDataFormat*) pa_xmalloc (writeableSize);
|
||||
_urgentRingBuffer.Get (out, writeableSize, 100);
|
||||
// pa_threaded_mainloop_lock (m);
|
||||
|
||||
pa_stream_write (playback->pulseStream(), out, writeableSize, NULL, 0, PA_SEEK_RELATIVE);
|
||||
// pa_threaded_mainloop_unlock (m);
|
||||
|
||||
pa_xfree (out);
|
||||
|
||||
@ -529,17 +524,16 @@ void PulseLayer::writeToSpeaker (void)
|
||||
|
||||
if (tone != 0) {
|
||||
|
||||
// _debug("PlayTone writeableSize: %i", writeableSize);
|
||||
|
||||
if (playback->getStreamState() == PA_STREAM_READY) {
|
||||
|
||||
// _debug("Play Sine Tone!");
|
||||
// _debug("writeableSize %d\n", writeableSize);
|
||||
|
||||
out = (SFLDataFormat*) pa_xmalloc (writeableSize);
|
||||
int copied = tone->getNext (out, writeableSize / sizeof (SFLDataFormat), 100);
|
||||
// pa_threaded_mainloop_lock (m);
|
||||
pa_stream_write (playback->pulseStream(), out, copied * sizeof (SFLDataFormat), NULL, 0, PA_SEEK_RELATIVE);
|
||||
// pa_threaded_mainloop_unlock (m);
|
||||
|
||||
int returnValue = pa_stream_write (playback->pulseStream(), out, copied * sizeof (SFLDataFormat), NULL, 0, PA_SEEK_RELATIVE);
|
||||
|
||||
// _debug("return value %d\n", returnValue);
|
||||
|
||||
pa_xfree (out);
|
||||
|
||||
@ -549,15 +543,13 @@ void PulseLayer::writeToSpeaker (void)
|
||||
else if (file_tone != 0) {
|
||||
|
||||
if (playback->getStreamState() == PA_STREAM_READY) {
|
||||
// _debug("Play File Tone!");
|
||||
|
||||
out = (SFLDataFormat*) pa_xmalloc (writeableSize);
|
||||
int copied = file_tone->getNext (out, writeableSize / sizeof (SFLDataFormat), 100);
|
||||
// pa_threaded_mainloop_lock (m);
|
||||
|
||||
pa_stream_write (playback->pulseStream(), out, copied * sizeof (SFLDataFormat), NULL, 0, PA_SEEK_RELATIVE);
|
||||
|
||||
pa_xfree (out);
|
||||
// pa_threaded_mainloop_unlock (m);
|
||||
|
||||
}
|
||||
|
||||
|
@ -197,7 +197,7 @@ class Sdp {
|
||||
* Set remote's IP addr. [not protected]
|
||||
* @param ip The remote IP address
|
||||
*/
|
||||
void set_remote_ip(const std::string& ip) { _remote_ip_addr = ip; }
|
||||
void set_remote_ip(const std::string& ip) { _remote_ip_addr = ip; }
|
||||
|
||||
/**
|
||||
* Return IP of destination [mutex protected]
|
||||
|
@ -248,7 +248,7 @@ SIPVoIPLink::SIPVoIPLink (const AccountID& accountID)
|
||||
|
||||
SIPVoIPLink::~SIPVoIPLink()
|
||||
{
|
||||
_debug("SIPVoIPLink destructor called");
|
||||
_debug("UserAgent: SIPVoIPLink destructor called");
|
||||
|
||||
terminate();
|
||||
}
|
||||
@ -257,7 +257,7 @@ SIPVoIPLink* SIPVoIPLink::instance (const AccountID& id)
|
||||
{
|
||||
|
||||
if (!_instance) {
|
||||
_debug ("Create new SIPVoIPLink instance");
|
||||
_debug ("UserAgent: Create new SIPVoIPLink instance");
|
||||
_instance = new SIPVoIPLink (id);
|
||||
}
|
||||
|
||||
@ -270,7 +270,7 @@ void SIPVoIPLink::decrementClients (void)
|
||||
|
||||
if (_clients == 0) {
|
||||
|
||||
_debug("No SIP account anymore, terminate SIPVoIPLink");
|
||||
_debug("UserAgent: No SIP account anymore, terminate SIPVoIPLink");
|
||||
terminate();
|
||||
SIPVoIPLink::_instance=NULL;
|
||||
}
|
||||
@ -299,10 +299,10 @@ bool SIPVoIPLink::init()
|
||||
void
|
||||
SIPVoIPLink::terminate()
|
||||
{
|
||||
_debug ("Terminating SIPVoIPLink");
|
||||
_debug ("UserAgent: Terminating SIPVoIPLink");
|
||||
|
||||
if (_evThread) {
|
||||
_debug ("Deleting sip eventThread");
|
||||
_debug ("UserAgent: Deleting sip eventThread");
|
||||
delete _evThread;
|
||||
_evThread = NULL;
|
||||
}
|
||||
@ -310,7 +310,7 @@ SIPVoIPLink::terminate()
|
||||
|
||||
/* Clean shutdown of pjsip library */
|
||||
if (initDone()) {
|
||||
_debug ("Shuting down PJSIP");
|
||||
_debug ("UserAgent: Shuting down PJSIP");
|
||||
pjsip_shutdown();
|
||||
}
|
||||
|
||||
@ -386,7 +386,7 @@ std::string SIPVoIPLink::getInterfaceAddrFromName(std::string ifaceName) {
|
||||
struct in_addr *addr_in;
|
||||
|
||||
if((fd = socket (AF_INET, SOCK_DGRAM,0)) < 0)
|
||||
_debug("getInterfaceAddrFromName error could not open socket\n");
|
||||
_debug("UserAgent: getInterfaceAddrFromName error could not open socket\n");
|
||||
|
||||
memset (&ifr, 0, sizeof (struct ifreq));
|
||||
|
||||
@ -394,7 +394,7 @@ std::string SIPVoIPLink::getInterfaceAddrFromName(std::string ifaceName) {
|
||||
ifr.ifr_addr.sa_family = AF_INET;
|
||||
|
||||
if((err = ioctl(fd, SIOCGIFADDR, &ifr)) < 0)
|
||||
_debug("getInterfaceAddrFromName use default interface (0.0.0.0)\n");
|
||||
_debug("UserAgent: getInterfaceAddrFromName use default interface (0.0.0.0)\n");
|
||||
|
||||
saddr_in = (struct sockaddr_in *)&ifr.ifr_addr;
|
||||
addr_in = &(saddr_in->sin_addr);
|
||||
@ -445,7 +445,7 @@ int SIPVoIPLink::sendRegister (AccountID id)
|
||||
account = dynamic_cast<SIPAccount *> (Manager::instance().getAccount (id));
|
||||
|
||||
if (account == NULL) {
|
||||
_debug ("In sendRegister: account is null");
|
||||
_debug ("UserAgent: In sendRegister: account is null");
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -1021,8 +1021,8 @@ int SIPVoIPLink::inv_session_reinvite (SIPCall *call, std::string direction)
|
||||
// TODO Restore Re-Invite
|
||||
// status = call->getLocalSDP()->create_initial_offer();
|
||||
|
||||
if (status != PJ_SUCCESS)
|
||||
return 1; // !PJ_SUCCESS
|
||||
// if (status != PJ_SUCCESS)
|
||||
// return 1; // !PJ_SUCCESS
|
||||
|
||||
pjmedia_sdp_media_remove_all_attr (local_sdp->media[0], "sendrecv");
|
||||
|
||||
@ -1802,7 +1802,6 @@ pj_status_t SIPVoIPLink::enable_dns_srv_resolver (pjsip_endpoint *endpt, pj_dns_
|
||||
bool SIPVoIPLink::pjsip_init()
|
||||
{
|
||||
pj_status_t status;
|
||||
int errPjsip = 0;
|
||||
pjsip_inv_callback inv_cb;
|
||||
pj_str_t accepted;
|
||||
std::string name_mod;
|
||||
@ -2221,7 +2220,7 @@ bool SIPVoIPLink::createSipTransport(AccountID id)
|
||||
int trns = remoteSipUri.find(";transport");
|
||||
std::string remoteAddr = remoteSipUri.substr(sips, trns-sips);
|
||||
|
||||
// Nothing to do, TLS listener already created at pjsip's startup and TLS connection\
|
||||
// Nothing to do, TLS listener already created at pjsip's startup and TLS connection
|
||||
// is automatically handled in pjsip when sending registration messages.
|
||||
if(createTlsTransport(id, remoteAddr) != PJ_SUCCESS)
|
||||
return false;
|
||||
@ -2749,9 +2748,7 @@ pj_status_t SIPVoIPLink::createAlternateUdpTransport (AccountID id)
|
||||
void SIPVoIPLink::shutdownSipTransport(const AccountID& accountID)
|
||||
{
|
||||
|
||||
_debug("Shutdown Sip Transport");
|
||||
|
||||
pj_status_t status = 0;
|
||||
_debug("UserAgent: Shutdown Sip Transport");
|
||||
|
||||
SIPAccount* account = dynamic_cast<SIPAccount *> (Manager::instance().getAccount (accountID));
|
||||
|
||||
@ -2915,23 +2912,9 @@ void set_voicemail_info (AccountID account, pjsip_msg_body *body)
|
||||
|
||||
void SIPVoIPLink::handle_reinvite (SIPCall *call)
|
||||
{
|
||||
/*
|
||||
// Close the previous RTP session
|
||||
call->getAudioRtp()->stop ();
|
||||
call->setAudioStart (false);
|
||||
|
||||
_debug ("Create new rtp session from handle_reinvite : %s:%i", call->getLocalIp().c_str(), call->getLocalAudioPort());
|
||||
_debug ("UserAgent: handle_reinvite");
|
||||
|
||||
try {
|
||||
call->getAudioRtp()->initAudioRtpSession (call);
|
||||
} catch (...) {
|
||||
_debug ("! SIP Failure: Unable to create RTP Session (%s:%d)", __FILE__, __LINE__);
|
||||
}
|
||||
*/
|
||||
|
||||
_debug("Handle reINVITE");
|
||||
|
||||
call->getAudioRtp()->updateDestinationIpAddress();
|
||||
}
|
||||
|
||||
// This callback is called when the invite session state has changed
|
||||
@ -3134,7 +3117,7 @@ void call_on_state_changed (pjsip_inv_session *inv, pjsip_event *e)
|
||||
// This callback is called after SDP offer/answer session has completed.
|
||||
void call_on_media_update (pjsip_inv_session *inv, pj_status_t status)
|
||||
{
|
||||
_debug ("call_on_media_update");
|
||||
_debug ("UserAgent: call_on_media_update");
|
||||
|
||||
const pjmedia_sdp_session *local_sdp;
|
||||
const pjmedia_sdp_session *remote_sdp;
|
||||
@ -3182,6 +3165,7 @@ void call_on_media_update (pjsip_inv_session *inv, pj_status_t status)
|
||||
|
||||
// Set remote ip / port
|
||||
call->getLocalSDP()->set_media_transport_info_from_remote_sdp (remote_sdp);
|
||||
call->getAudioRtp()->updateDestinationIpAddress();
|
||||
|
||||
// Get the crypto attribute containing srtp's cryptographic context (keys, cipher)
|
||||
CryptoOffer crypto_offer;
|
||||
|
Reference in New Issue
Block a user