Module: sems Branch: master Commit: 0390e6799fb151cb2ee5b54e63f461ad9a8722c7 URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sems/?a=commit;h=0390e6799fb151cb2ee5b54e63f461ad9a8722c7
Author: Stefan Sayer <[email protected]> Committer: Stefan Sayer <[email protected]> Date: Wed Nov 6 13:03:43 2013 +0100 webconference: add lonely_user_timer option --- apps/webconference/WebConference.cpp | 9 ++++++ apps/webconference/WebConference.h | 2 + apps/webconference/WebConferenceDialog.cpp | 38 ++++++++++++++++++++++++++- apps/webconference/WebConferenceDialog.h | 3 ++ apps/webconference/etc/webconference.conf | 6 ++++ 5 files changed, 56 insertions(+), 2 deletions(-) diff --git a/apps/webconference/WebConference.cpp b/apps/webconference/WebConference.cpp index 726909e..2197a0b 100644 --- a/apps/webconference/WebConference.cpp +++ b/apps/webconference/WebConference.cpp @@ -74,6 +74,8 @@ bool WebConferenceFactory::PrivateRoomsMode = false; bool WebConferenceFactory::LoopFirstParticipantPrompt = false; +unsigned int WebConferenceFactory::LonelyUserTimer = 0; + string WebConferenceFactory::participant_id_paramname; // default: param not used string WebConferenceFactory::participant_id_hdr = "X-ParticipantID"; // default header @@ -227,6 +229,13 @@ int WebConferenceFactory::load() LoopFirstParticipantPrompt = cfg.getParameter("loop_first_participant_prompt") == "yes"; + LonelyUserTimer = cfg.getParameterInt("lonely_user_timer", 0); + if (!LonelyUserTimer) { + DBG("'lonely user' timer not used\n"); + } else { + DBG("Timer for 'lonely user' used: %u seconds\n", LonelyUserTimer); + } + DBG("Looping first participant prompt: %s\n", LoopFirstParticipantPrompt ? "yes":"no"); if (cfg.getParameter("support_rooms_timeout") == "yes") { diff --git a/apps/webconference/WebConference.h b/apps/webconference/WebConference.h index 2502832..daa72df 100644 --- a/apps/webconference/WebConference.h +++ b/apps/webconference/WebConference.h @@ -138,6 +138,8 @@ public: static bool PrivateRoomsMode; static bool LoopFirstParticipantPrompt; + static unsigned int LonelyUserTimer; + // P-App-Param parameter to get participant ID from static string participant_id_paramname; // if participant_id_paramname not configured: diff --git a/apps/webconference/WebConferenceDialog.cpp b/apps/webconference/WebConferenceDialog.cpp index 64344df..9cc29c0 100644 --- a/apps/webconference/WebConferenceDialog.cpp +++ b/apps/webconference/WebConferenceDialog.cpp @@ -28,6 +28,8 @@ #include "AmUtils.h" #include "AmMediaProcessor.h" +#define LONELY_USER_TIMER_ID 50 + // room name unknown WebConferenceDialog::WebConferenceDialog(AmPromptCollection& prompts, WebConferenceFactory* my_f, @@ -51,7 +53,8 @@ WebConferenceDialog::WebConferenceDialog(AmPromptCollection& prompts, : play_list(this), separator(this, 0), prompts(prompts), state(None), factory(my_f), muted(false), connect_ts(-1), disconnect_ts(-1), - local_input(NULL), cred(NULL) + local_input(NULL), cred(NULL), + lonely_user(true) { conf_id = room; DBG("set conf_id to %s\n", conf_id.c_str()); @@ -109,7 +112,6 @@ void WebConferenceDialog::connectConference(const string& room) { setInOut(NULL, &play_list); else setInOut(&play_list, &play_list); - } void WebConferenceDialog::onInvite(const AmSipRequest& req) { @@ -301,7 +303,17 @@ void WebConferenceDialog::process(AmEvent* ev) if(ce->participants == 1){ prompts.addToPlaylist(FIRST_PARTICIPANT, (long)this, play_list, true, WebConferenceFactory::LoopFirstParticipantPrompt); + + if (WebConferenceFactory::LonelyUserTimer) { + DBG("only person in the room - setting LonelyUserTimer %u sec\n", + WebConferenceFactory::LonelyUserTimer); + setTimer(LONELY_USER_TIMER_ID, WebConferenceFactory::LonelyUserTimer); + lonely_user = true; + } + } else { + // someone else joined + lonely_user = false; if (WebConferenceFactory::LoopFirstParticipantPrompt) { // -- reset the channel (flush playlist) @@ -323,6 +335,16 @@ void WebConferenceDialog::process(AmEvent* ev) case ConfParticipantLeft: { DBG("########## participant left ########\n"); prompts.addToPlaylist(DROP_SOUND, (long)this, play_list, true); + + if(ce->participants == 1) { + if (WebConferenceFactory::LonelyUserTimer) { + DBG("only person in the room - setting LonelyUserTimer %u sec\n", + WebConferenceFactory::LonelyUserTimer); + setTimer(LONELY_USER_TIMER_ID, WebConferenceFactory::LonelyUserTimer); + lonely_user = true; + } + } + } break; default: @@ -380,6 +402,18 @@ void WebConferenceDialog::process(AmEvent* ev) } break; } } + + + AmPluginEvent* plugin_event = dynamic_cast<AmPluginEvent*>(ev); + if(plugin_event && plugin_event->name == "timer_timeout") { + int timer_id = plugin_event->data.get(0).asInt(); + if (timer_id == LONELY_USER_TIMER_ID && lonely_user) { + DBG("LonelyUserTimer of %u sec expired - kicking lonely user\n", + WebConferenceFactory::LonelyUserTimer); + onKicked(); + return; + } + } AmSession::process(ev); } diff --git a/apps/webconference/WebConferenceDialog.h b/apps/webconference/WebConferenceDialog.h index e5c1140..69bbfd2 100644 --- a/apps/webconference/WebConferenceDialog.h +++ b/apps/webconference/WebConferenceDialog.h @@ -89,6 +89,9 @@ private: AmAudio *local_input; void setLocalInput(AmAudio* in); + /** flag to indicate whether user was joined by anyone in the room */ + bool lonely_user; + public: WebConferenceDialog(AmPromptCollection& prompts, WebConferenceFactory* my_f, diff --git a/apps/webconference/etc/webconference.conf b/apps/webconference/etc/webconference.conf index 419fb04..ad49bea 100644 --- a/apps/webconference/etc/webconference.conf +++ b/apps/webconference/etc/webconference.conf @@ -36,6 +36,12 @@ direct_room_re=000777.* # e.g. direct_room_strip=5, called 000777123 => room 123 direct_room_strip=6 +# lonely_user_timer - a caller that is that many seconds in a room alone will be kicked +# +# Default: disabled (0) +# +#lonely_user_timer=120 + # # master_password sets optionally a master password which can be used to # retreive a room's password with the getRoomPassword function _______________________________________________ Semsdev mailing list [email protected] http://lists.iptel.org/mailman/listinfo/semsdev
