mirror of
https://github.com/signalwire/freeswitch.git
synced 2025-04-23 03:33:48 +00:00
add timetable
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@669 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
parent
5492b17e94
commit
d8146aa7c7
@ -44,6 +44,12 @@ extern "C" {
|
|||||||
|
|
||||||
#include <switch.h>
|
#include <switch.h>
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
switch_time_t created;
|
||||||
|
switch_time_t answered;
|
||||||
|
switch_time_t hungup;
|
||||||
|
} switch_channel_timetable_t;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @defgroup switch_channel Channel Functions
|
* @defgroup switch_channel Channel Functions
|
||||||
* @ingroup FREESWITCH
|
* @ingroup FREESWITCH
|
||||||
@ -67,6 +73,13 @@ SWITCH_DECLARE(switch_channel_state) switch_channel_get_state(switch_channel *ch
|
|||||||
*/
|
*/
|
||||||
SWITCH_DECLARE(switch_channel_state) switch_channel_set_state(switch_channel *channel, switch_channel_state state);
|
SWITCH_DECLARE(switch_channel_state) switch_channel_set_state(switch_channel *channel, switch_channel_state state);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\brief View the timetable of a channel
|
||||||
|
\param channel channel to retrieve timetable from
|
||||||
|
\returns a pointer to the channel's timetable (created, answered, etc..)
|
||||||
|
*/
|
||||||
|
SWITCH_DECLARE(switch_channel_timetable_t *) switch_channel_get_timetable(switch_channel *channel);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\brief Allocate a new channel
|
\brief Allocate a new channel
|
||||||
\param channel NULL pointer to allocate channel to
|
\param channel NULL pointer to allocate channel to
|
||||||
|
@ -32,7 +32,6 @@
|
|||||||
#include <switch_channel.h>
|
#include <switch_channel.h>
|
||||||
|
|
||||||
struct switch_channel {
|
struct switch_channel {
|
||||||
time_t initiated;
|
|
||||||
char *name;
|
char *name;
|
||||||
switch_buffer *dtmf_buffer;
|
switch_buffer *dtmf_buffer;
|
||||||
switch_mutex_t *dtmf_mutex;
|
switch_mutex_t *dtmf_mutex;
|
||||||
@ -46,6 +45,7 @@ struct switch_channel {
|
|||||||
const struct switch_state_handler_table *state_handlers[SWITCH_MAX_STATE_HANDLERS];
|
const struct switch_state_handler_table *state_handlers[SWITCH_MAX_STATE_HANDLERS];
|
||||||
int state_handler_index;
|
int state_handler_index;
|
||||||
switch_hash *variables;
|
switch_hash *variables;
|
||||||
|
switch_channel_timetable_t times;
|
||||||
void *private;
|
void *private;
|
||||||
int freq;
|
int freq;
|
||||||
int bits;
|
int bits;
|
||||||
@ -54,7 +54,10 @@ struct switch_channel {
|
|||||||
int kbps;
|
int kbps;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
SWITCH_DECLARE(switch_channel_timetable_t *) switch_channel_get_timetable(switch_channel *channel)
|
||||||
|
{
|
||||||
|
return &channel->times;
|
||||||
|
}
|
||||||
|
|
||||||
SWITCH_DECLARE(switch_status) switch_channel_alloc(switch_channel **channel, switch_memory_pool *pool)
|
SWITCH_DECLARE(switch_status) switch_channel_alloc(switch_channel **channel, switch_memory_pool *pool)
|
||||||
{
|
{
|
||||||
@ -67,7 +70,7 @@ SWITCH_DECLARE(switch_status) switch_channel_alloc(switch_channel **channel, swi
|
|||||||
switch_core_hash_init(&(*channel)->variables, pool);
|
switch_core_hash_init(&(*channel)->variables, pool);
|
||||||
switch_buffer_create(pool, &(*channel)->dtmf_buffer, 128);
|
switch_buffer_create(pool, &(*channel)->dtmf_buffer, 128);
|
||||||
switch_mutex_init(&(*channel)->dtmf_mutex, SWITCH_MUTEX_NESTED, pool);
|
switch_mutex_init(&(*channel)->dtmf_mutex, SWITCH_MUTEX_NESTED, pool);
|
||||||
|
(*channel)->times.created = switch_time_now();
|
||||||
|
|
||||||
return SWITCH_STATUS_SUCCESS;
|
return SWITCH_STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
@ -549,6 +552,7 @@ SWITCH_DECLARE(switch_status) switch_channel_hangup(switch_channel *channel)
|
|||||||
{
|
{
|
||||||
assert(channel != NULL);
|
assert(channel != NULL);
|
||||||
if (channel->state < CS_HANGUP) {
|
if (channel->state < CS_HANGUP) {
|
||||||
|
channel->times.hungup = switch_time_now();
|
||||||
channel->state = CS_HANGUP;
|
channel->state = CS_HANGUP;
|
||||||
switch_core_session_signal_state_change(channel->session);
|
switch_core_session_signal_state_change(channel->session);
|
||||||
}
|
}
|
||||||
@ -563,6 +567,7 @@ SWITCH_DECLARE(switch_status) switch_channel_answer(switch_channel *channel)
|
|||||||
if (switch_core_session_answer_channel(channel->session) == SWITCH_STATUS_SUCCESS) {
|
if (switch_core_session_answer_channel(channel->session) == SWITCH_STATUS_SUCCESS) {
|
||||||
switch_event *event;
|
switch_event *event;
|
||||||
|
|
||||||
|
channel->times.answered = switch_time_now();
|
||||||
switch_channel_set_flag(channel, CF_ANSWERED);
|
switch_channel_set_flag(channel, CF_ANSWERED);
|
||||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Answer %s!\n", channel->name);
|
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Answer %s!\n", channel->name);
|
||||||
if (switch_event_create(&event, SWITCH_EVENT_CHANNEL_ANSWER) == SWITCH_STATUS_SUCCESS) {
|
if (switch_event_create(&event, SWITCH_EVENT_CHANNEL_ANSWER) == SWITCH_STATUS_SUCCESS) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user