handling of RTP timeout improved

* rtp packet parse called in RtpStream, so rtp keepalive packets are not disregarded in respect to rtp timeout
 * rtp timeout made configurabe in sems.conf: dead_rtp_time




git-svn-id: http://svn.berlios.de/svnroot/repos/sems/trunk@281 8eb893ce-cfd4-0310-b710-fb5ebe64c474
sayer/1.4-spce2.6
Stefan Sayer 20 years ago
parent c07ba6ac52
commit 5eb2a7325a

@ -56,6 +56,7 @@ int AmConfig::LocalSIPPort = 5060;
string AmConfig::LocalSIPIP = "";
string AmConfig::Signature = "";
bool AmConfig::SingleCodecInOK = false;
unsigned int AmConfig::DeadRtpTime = DEAD_RTP_TIME;
AmSessionTimerConfig AmConfig::defaultSessionTimerConfig;
@ -129,6 +130,14 @@ int AmConfig::setMediaProcessorThreads(const string& th) {
return 1;
}
int AmConfig::setDeadRtpTime(const string& drt)
{
if(sscanf(drt.c_str(),"%u",&AmConfig::DeadRtpTime) != 1) {
return 0;
}
return 1;
}
int AmConfig::readConfiguration()
{
AmConfigReader cfg;
@ -243,6 +252,15 @@ int AmConfig::readConfiguration()
SingleCodecInOK = (cfg.getParameter("single_codec_in_ok") == "yes");
}
// dead_rtp_time
if(cfg.hasParameter("dead_rtp_time")){
if(!setDeadRtpTime(cfg.getParameter("dead_rtp_time"))){
ERROR("invalid dead_rtp_time value specified");
return -1;
}
}
return defaultSessionTimerConfig.readFromConfig(cfg);
}

@ -88,6 +88,9 @@ struct AmConfig
/** If 200 OK reply should be limited to preferred codec only */
static bool SingleCodecInOK;
/** Time of no RTP after which Session is regarded as dead, 0 for no Timeout */
static unsigned int DeadRtpTime;
/** Init function. Resolves SMTP server address. */
static int init();
@ -113,6 +116,8 @@ struct AmConfig
static int setStderr(const string& s);
/** Setter for parameter MediaProcessorThreads, returns 0 on invalid value */
static int setMediaProcessorThreads(const string& th);
/** Setter for parameter DeadRtpTime, returns 0 on invalid value */
static int setDeadRtpTime(const string& drt);
};
class AmConfigReader;

@ -91,11 +91,6 @@ void AmRtpReceiver::run()
if(p.recv(tmp_fds[i].fd) > 0){
if(p.parse() == -1){
DBG("error while parsing RTP packet.\n");
continue;
}
gettimeofday(&p.recv_time,NULL);
streams_mut.lock();

@ -423,7 +423,8 @@ int AmRtpStream::nextPacket(AmRtpPacket& p)
jitter_mut.lock();
timersub(&now,&last_recv_time,&diff);
if(diff.tv_sec > DEAD_RTP_TIME){
if(AmConfig::DeadRtpTime &&
(diff.tv_sec > AmConfig::DeadRtpTime)){
WARN("RTP Timeout detected. Last received packet is too old.\n");
DBG("diff.tv_sec = %i\n",(unsigned int)diff.tv_sec);
jitter_mut.unlock();

@ -44,8 +44,6 @@ using std::string;
using std::map;
using std::auto_ptr;
#define DEAD_RTP_TIME (5*60) /* 5 minutes */
// return values of AmRtpStream::receive
#define RTP_EMPTY 0 // no rtp packet available
#define RTP_PARSE_ERROR -1 // error while parsing rtp packet

@ -123,6 +123,20 @@ media_processor_threads=1
#
#sip_port=5060
# optional parameter: dead_rtp_time=<unsigned int>
#
# - if != 0, after this time (in seconds) of no RTP
# a session is considered dead and stopped. If set
# to 0 no check is done for rtp timeout.
#
# default=300 (5 minutes)
#
# Examples:
# # disable RTP timeout
# dead_rtp_time=0
# # RTP timeout after 10 seconds
# dead_rtp_time=10
# optional parameter: use_default_signature={yes|no}
#
# - use a Server/User-Agent header with the SEMS server

@ -49,6 +49,8 @@
#define DEFAULT_SIGNATURE "Sip Express Media Server " \
"(" VERSION " (" ARCH "/" OS"))"
// session considered dead after 5 minutes no RTP
#define DEAD_RTP_TIME 5*60
/* Session Timer defaul configuration: */
#define DEFAULT_ENABLE_SESSION_TIMER 1

Loading…
Cancel
Save