mirror of
https://github.com/signalwire/freeswitch.git
synced 2026-07-24 05:02:10 +00:00
Addition of scheduler engine and a few applications to use it.
This patch adds a scheduler thread to the core and moves the heartbeat event to use the new scheduler as an example. Also The following features are implemented that use this scheduler: sched_hangup dialplan application: <action application="sched_hangup" data="+10 normal_clearing bleg"/> ** The cause code is optional and the optional bleg keyword will only hangup the channel the current channel is bridged to if the call is in a bridge. sched_transfer dialplan application: <action application="sched_transfer" data="+10 1000 XML default"/> ** The last 2 args (dialplan and context) are optional sched_broadcast dialplan application: <action application="sched_broadcast" data="+10 playback:/tmp/foo.wav"/> <action application="sched_broadcast" data="+10 playback!normal_clearing:/tmp/foo.wav"/> ** The optional !<cause_code> can be added to make the channel hangup after broadcasting the file. sched_hangup api function: sched_hangup +10 <uuid_string> normal_clearing ** The cause code is optional sched_transfer api function: sched_transfer +10 <uuid_string> 1000 XML default ** The last 2 args (dialplan and context) are optional sched_broadcast api function: sched_broadcast +10 <uuid_str> playback:/tmp/foo.wav sched_broadcast +10 <uuid_str> playback!normal_clearing:/tmp/foo.wav ** The optional !<cause_code> can be added to make the channel hangup after broadcasting the file. The new C functions in the core are documented in the doxeygen. *NOTE* This commit should satisfy at least 2 bounties on the wiki git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@4785 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
@@ -104,17 +104,68 @@ struct switch_core_session;
|
||||
struct switch_core_runtime;
|
||||
struct switch_core_port_allocator;
|
||||
|
||||
struct switch_core_scheduler_task {
|
||||
time_t created;
|
||||
time_t runtime;
|
||||
uint32_t cmd_id;
|
||||
char *group;
|
||||
void *cmd_arg;
|
||||
uint32_t task_id;
|
||||
};
|
||||
|
||||
|
||||
/*!
|
||||
\defgroup core1 Core Library
|
||||
\ingroup FREESWITCH
|
||||
\{
|
||||
*/
|
||||
|
||||
|
||||
///\defgroup mb1 Media Bugs
|
||||
///\ingroup core1
|
||||
///\{
|
||||
|
||||
|
||||
///\defgroup sched1 Scheduler
|
||||
///\ingroup core1
|
||||
///\{
|
||||
|
||||
|
||||
/*!
|
||||
\brief Schedule a task in the future
|
||||
\param runtime the time in epoch seconds to execute the task.
|
||||
\param func the callback function to execute when the task is executed.
|
||||
\param desc an arbitrary description of the task.
|
||||
\param group a group id tag to link multiple tasks to a single entity.
|
||||
\param cmd_id an arbitrary index number be used in the callback.
|
||||
\param cmd_arg user data to be passed to the callback.
|
||||
\param flags flags to alter behaviour
|
||||
\return the id of the task
|
||||
*/
|
||||
SWITCH_DECLARE(uint32_t) switch_core_scheduler_add_task(time_t task_runtime,
|
||||
switch_core_scheduler_func_t func,
|
||||
char *desc,
|
||||
char *group,
|
||||
uint32_t cmd_id,
|
||||
void *cmd_arg,
|
||||
switch_scheduler_flag_t flags);
|
||||
|
||||
/*!
|
||||
\brief Delete a scheduled task
|
||||
\param task_id the id of the task
|
||||
\return SWITCH_STATUS_SUCCESS if the task was deleted.
|
||||
*/
|
||||
SWITCH_DECLARE(switch_status_t) switch_core_scheduler_del_task_id(uint32_t task_id);
|
||||
|
||||
/*!
|
||||
\brief Delete a scheduled task based on the group name
|
||||
\param group the group name
|
||||
\return SWITCH_STATUS_SUCCESS if any tasks were deleted
|
||||
*/
|
||||
SWITCH_DECLARE(switch_status_t) switch_core_scheduler_del_task_group(char *group);
|
||||
|
||||
|
||||
///\}
|
||||
|
||||
/*!
|
||||
\brief Add a media bug to the session
|
||||
\param session the session to add the bug to
|
||||
|
||||
Reference in New Issue
Block a user