Source

Target

Commits (1)
Showing with 104 additions and 3 deletions
......@@ -2042,6 +2042,7 @@ static void rtp_config_read(LinphoneCore *lc) {
int min_port, max_port;
int jitt_comp;
int nortp_timeout;
int nortp_onhold_timeout;
bool_t rtp_no_xmit_on_audio_mute;
bool_t adaptive_jitt_comp_enabled;
const char *tmp;
......@@ -2081,6 +2082,8 @@ static void rtp_config_read(LinphoneCore *lc) {
linphone_core_set_video_jittcomp(lc, jitt_comp);
nortp_timeout = linphone_config_get_int(lc->config, "rtp", "nortp_timeout", 30);
linphone_core_set_nortp_timeout(lc, nortp_timeout);
nortp_onhold_timeout = linphone_config_get_int(lc->config, "rtp", "nortp_onhold_timeout", 3600);
linphone_core_set_nortp_onhold_timeout(lc, nortp_onhold_timeout);
rtp_no_xmit_on_audio_mute = !!linphone_config_get_int(lc->config, "rtp", "rtp_no_xmit_on_audio_mute", FALSE);
linphone_core_set_rtp_no_xmit_on_audio_mute(lc, rtp_no_xmit_on_audio_mute);
adaptive_jitt_comp_enabled = !!linphone_config_get_int(lc->config, "rtp", "audio_adaptive_jitt_comp_enabled", TRUE);
......@@ -3951,6 +3954,10 @@ int linphone_core_get_nortp_timeout(const LinphoneCore *lc) {
return lc->rtp_conf.nortp_timeout;
}
int linphone_core_get_nortp_onhold_timeout(const LinphoneCore *lc) {
return lc->rtp_conf.nortp_onhold_timeout;
}
bool_t linphone_core_get_rtp_no_xmit_on_audio_mute(const LinphoneCore *lc) {
return lc->rtp_conf.rtp_no_xmit_on_audio_mute;
}
......@@ -4020,6 +4027,10 @@ void linphone_core_set_nortp_timeout(LinphoneCore *lc, int nortp_timeout) {
lc->rtp_conf.nortp_timeout = nortp_timeout;
}
void linphone_core_set_nortp_onhold_timeout(LinphoneCore *lc, int nortp_onhold_timeout) {
lc->rtp_conf.nortp_onhold_timeout = nortp_onhold_timeout;
}
bool_t linphone_core_get_use_info_for_dtmf(LinphoneCore *lc) {
return !!linphone_config_get_int(lc->config, "sip", "use_info", 0);
}
......@@ -7392,6 +7403,7 @@ void rtp_config_uninit(LinphoneCore *lc) {
linphone_config_set_int(lc->config, "rtp", "audio_jitt_comp", config->audio_jitt_comp);
linphone_config_set_int(lc->config, "rtp", "video_jitt_comp", config->video_jitt_comp);
linphone_config_set_int(lc->config, "rtp", "nortp_timeout", config->nortp_timeout);
linphone_config_set_int(lc->config, "rtp", "nortp_onhold_timeout", config->nortp_onhold_timeout);
linphone_config_set_int(lc->config, "rtp", "audio_adaptive_jitt_comp_enabled",
config->audio_adaptive_jitt_comp_enabled);
linphone_config_set_int(lc->config, "rtp", "video_adaptive_jitt_comp_enabled",
......
......@@ -98,6 +98,7 @@ struct rtp_config {
int audio_jitt_comp; /*jitter compensation*/
int video_jitt_comp; /*jitter compensation*/
int nortp_timeout;
int nortp_onhold_timeout;
int disable_upnp;
MSCryptoSuite *srtp_suites;
LinphoneAVPFMode avpf_mode;
......
......@@ -2788,6 +2788,19 @@ LINPHONE_PUBLIC LinphoneRange *linphone_core_get_text_ports_range(const Linphone
**/
LINPHONE_PUBLIC int linphone_core_get_nortp_timeout(const LinphoneCore *core);
/**
* Gets the value of the no-rtp timeout when the call is on hold.
*
* When no RTP or RTCP packets have been received for a while when the call is on hold
* #LinphoneCore will consider the call is broken (remote end crashed or
* disconnected from the network), and thus will terminate the call.
* The no-rtp timeout is the duration above which the call is considered broken.
* @param core #LinphoneCore object @notnil
* @return The value of the no-rtp timeout in seconds when the call is on hold
* @ingroup media_parameters
**/
LINPHONE_PUBLIC int linphone_core_get_nortp_onhold_timeout(const LinphoneCore *core);
/**
* Sets the UDP port used for audio streaming.
* A value of -1 will request the system to allocate the local port randomly.
......@@ -2854,6 +2867,15 @@ LINPHONE_PUBLIC void linphone_core_set_text_port_range(LinphoneCore *core, int m
**/
LINPHONE_PUBLIC void linphone_core_set_nortp_timeout(LinphoneCore *core, int seconds);
/**
* Sets the no-rtp timeout value in seconds when the call is on hold.
* @param core #LinphoneCore object @notnil
* @param seconds The no-rtp timeout value to use in seconds when the call is on hold
* @ingroup media_parameters
* @see linphone_core_get_nortp_on_hold_timeout() for details.
**/
LINPHONE_PUBLIC void linphone_core_set_nortp_onhold_timeout(LinphoneCore *core, int seconds);
/**
* Sets whether SIP INFO is to be used to send digits.
* @param core #LinphoneCore object @notnil
......
......@@ -276,8 +276,11 @@ MediaStream *MS2AudioStream::getMediaStream() const {
return mStream ? &mStream->ms : nullptr;
}
void MS2AudioStream::setupMediaLossCheck() {
void MS2AudioStream::setupMediaLossCheck(bool_t isPaused) {
int disconnectTimeout = linphone_core_get_nortp_timeout(getCCore());
if (isPaused) {
disconnectTimeout = linphone_core_get_nortp_onhold_timeout(getCCore());
}
if (disconnectTimeout == 0) {
lInfo() << "No RTP timeout disabled";
return;
......@@ -673,7 +676,7 @@ void MS2AudioStream::render(const OfferAnswerContext &params, CallSession::State
});
}
setupMediaLossCheck();
setupMediaLossCheck(targetState == CallSession::State::Paused);
return;
}
......
......@@ -246,7 +246,7 @@ protected:
private:
virtual void handleEvent(const OrtpEvent *ev) override;
void setupMediaLossCheck();
void setupMediaLossCheck(bool_t isPaused);
void setPlaybackGainDb(float gain);
void setZrtpCryptoTypesParameters(MSZrtpParams *params, bool localIsOffer);
void startZrtpPrimaryChannel(const OfferAnswerContext &params);
......
......@@ -25,6 +25,7 @@
#include "belle-sip/sipstack.h"
#include "linphone/api/c-types.h"
#include "mediastreamer2/msutils.h"
#include "mediastreamer2/msvolume.h"
......@@ -2274,6 +2275,66 @@ static void call_terminated_by_caller(void) {
linphone_core_manager_destroy(pauline);
}
static void call_terminated_by_nortp_timeout_base(bool_t on_hold) {
LinphoneCoreManager *marie = linphone_core_manager_new("marie_rc");
LinphoneCoreManager *pauline =
linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc");
LinphoneCallParams *pauline_params = NULL;
bctbx_list_t *lcs = NULL;
bool_t call_ok;
lcs = bctbx_list_append(lcs, marie->lc);
lcs = bctbx_list_append(lcs, pauline->lc);
int nortp_timeout = 5;
int nortp_on_hold_timeout = 8;
int test_timeout = (nortp_timeout + 1) * 1000;
if (on_hold) {
test_timeout = (nortp_on_hold_timeout + 1) * 1000;
linphone_core_set_nortp_onhold_timeout(marie->lc, nortp_on_hold_timeout);
} else {
linphone_core_set_nortp_timeout(marie->lc, nortp_timeout);
}
BC_ASSERT_TRUE((call_ok = call_with_params(pauline, marie, pauline_params, NULL)));
if (!call_ok) goto end;
LinphoneCall *marie_call = NULL;
marie_call = linphone_core_get_current_call(marie->lc);
wait_for_until(marie->lc, pauline->lc, NULL, 0, 2000);
if (on_hold) {
/*marie in pause*/
linphone_call_pause(marie_call);
BC_ASSERT_TRUE(wait_for_list(lcs, &marie->stat.number_of_LinphoneCallPaused, 1, 10000));
}
/*marie looses the network and pauline terminates the call, no rtp sent*/
linphone_core_set_network_reachable(marie->lc, FALSE);
linphone_call_terminate(linphone_core_get_current_call(pauline->lc));
/*call terminates after nortp timeout has been reached */
wait_for_list(lcs, NULL, 0, test_timeout);
BC_ASSERT_TRUE(wait_for(marie->lc, pauline->lc, &marie->stat.number_of_LinphoneCallEnd, 1));
BC_ASSERT_EQUAL(linphone_call_get_reason(marie_call), LinphoneReasonIOError, int, "%d");
end:
if (pauline_params) {
linphone_call_params_unref(pauline_params);
}
bctbx_list_free(lcs);
linphone_core_manager_destroy(marie);
linphone_core_manager_destroy(pauline);
}
static void call_terminated_by_nortp_timeout(void) {
call_terminated_by_nortp_timeout_base(FALSE);
}
static void call_terminated_by_nortp_timeout_on_hold(void) {
call_terminated_by_nortp_timeout_base(TRUE);
}
static void call_with_no_sdp(void) {
LinphoneCoreManager *marie = linphone_core_manager_new("marie_rc");
LinphoneCoreManager *pauline =
......@@ -7803,6 +7864,8 @@ static test_t call_tests[] = {
TEST_NO_TAG("Call with early update failed", call_with_early_update_failed),
TEST_NO_TAG("Early-media call with updated codec", early_media_call_with_codec_update),
TEST_NO_TAG("Call terminated by caller", call_terminated_by_caller),
TEST_NO_TAG("Call terminated by no rtp timeout", call_terminated_by_nortp_timeout),
TEST_NO_TAG("Call terminated by no rtp timeout on hold", call_terminated_by_nortp_timeout_on_hold),
TEST_NO_TAG("Call without SDP", call_with_no_sdp),
TEST_ONE_TAG("Call without SDP to a lime X3DH enabled device", call_with_no_sdp_lime, "LimeX3DH"),
TEST_NO_TAG("Call without SDP and ACK without SDP", call_with_no_sdp_ack_without_sdp),
......