diff --git a/core/AmConfig.cpp b/core/AmConfig.cpp index 9504d342..0547bf47 100644 --- a/core/AmConfig.cpp +++ b/core/AmConfig.cpp @@ -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); } diff --git a/core/AmConfig.h b/core/AmConfig.h index 4c4a7570..0ca74cf5 100644 --- a/core/AmConfig.h +++ b/core/AmConfig.h @@ -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; diff --git a/core/AmRtpReceiver.cpp b/core/AmRtpReceiver.cpp index 1d91becb..31947796 100644 --- a/core/AmRtpReceiver.cpp +++ b/core/AmRtpReceiver.cpp @@ -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(); diff --git a/core/AmRtpStream.cpp b/core/AmRtpStream.cpp index 548add2b..95fb7ccf 100644 --- a/core/AmRtpStream.cpp +++ b/core/AmRtpStream.cpp @@ -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(); diff --git a/core/AmRtpStream.h b/core/AmRtpStream.h index 094c8fc4..472b63be 100644 --- a/core/AmRtpStream.h +++ b/core/AmRtpStream.h @@ -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 diff --git a/core/sems.conf.sample b/core/sems.conf.sample index 8d7ae433..3cbd1447 100644 --- a/core/sems.conf.sample +++ b/core/sems.conf.sample @@ -123,6 +123,20 @@ media_processor_threads=1 # #sip_port=5060 +# optional parameter: dead_rtp_time= +# +# - 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 diff --git a/core/sems.h b/core/sems.h index cf02601b..357bed25 100644 --- a/core/sems.h +++ b/core/sems.h @@ -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