Module: sems Branch: master Commit: 8484835df58273466de3cd107eae86b49fc1b5c1 URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sems/?a=commit;h=8484835df58273466de3cd107eae86b49fc1b5c1
Author: Stefan Sayer <[email protected]> Committer: Stefan Sayer <[email protected]> Date: Wed Jun 22 15:12:50 2011 +0200 call_timer: start timer with early session --- apps/examples/call_gen/CallGen.cpp | 37 +++++++++++++++++++++++++---------- apps/examples/call_gen/CallGen.h | 4 +++ 2 files changed, 30 insertions(+), 11 deletions(-) diff --git a/apps/examples/call_gen/CallGen.cpp b/apps/examples/call_gen/CallGen.cpp index e849376..1e6b8b0 100644 --- a/apps/examples/call_gen/CallGen.cpp +++ b/apps/examples/call_gen/CallGen.cpp @@ -371,7 +371,8 @@ CallGenDialog::CallGenDialog(AmPromptCollection& prompts, play_rand_digits(play_rand_digits), call_time_base(call_time_base), call_time_rand(call_time_rand), - play_file(&CallGenFactory::play_file) + play_file(&CallGenFactory::play_file), + timer_started(false) { } @@ -394,6 +395,29 @@ void CallGenDialog::report(CallGenEvent what) { disconnect_ts); } +void CallGenDialog::setCallTimer() { + if (timer_started) + return; + timer_started = true; + + int call_timer = call_time_base; + if (call_time_rand>0) + call_timer+=rand()%call_time_rand; + + if (call_timer > 0) { + DBG("setting timer %d %d\n", CALL_TIMER, call_timer); + if (!setTimer(CALL_TIMER, call_timer)) { + ERROR("could not load user_timer from session_timer plug-in\n"); + return; + } + } + +} + +void CallGenDialog::onEarlySessionStart() { + setCallTimer(); +} + void CallGenDialog::onSessionStart() { time(&connect_ts); @@ -412,17 +436,8 @@ void CallGenDialog::onSessionStart() { // prompts.addToPlaylist(PLAY_FILE, (long)this, play_list); setInOut(&play_list, &play_list); - int call_timer = call_time_base; - if (call_time_rand>0) - call_timer+=rand()%call_time_rand; - if (call_timer > 0) { - DBG("setting timer %d %d\n", CALL_TIMER, call_timer); - if (!setTimer(CALL_TIMER, call_timer)) { - ERROR("could not load user_timer from session_timer plug-in\n"); - return; - } - } + setCallTimer(); } void CallGenDialog::process(AmEvent* event) diff --git a/apps/examples/call_gen/CallGen.h b/apps/examples/call_gen/CallGen.h index 2906a89..d2ac1cb 100644 --- a/apps/examples/call_gen/CallGen.h +++ b/apps/examples/call_gen/CallGen.h @@ -138,7 +138,10 @@ private: int call_time_base; int call_time_rand; + bool timer_started; + void report(CallGenEvent what); + void setCallTimer(); public: CallGenDialog(AmPromptCollection& prompts, @@ -146,6 +149,7 @@ public: ~CallGenDialog(); void onInvite(const AmSipRequest& r); + void onEarlySessionStart(); void onSessionStart(); void onBye(const AmSipRequest& req); void process(AmEvent* event); _______________________________________________ Semsdev mailing list [email protected] http://lists.iptel.org/mailman/listinfo/semsdev
