mirror of
https://github.com/signalwire/freeswitch.git
synced 2025-08-13 17:38:59 +00:00
add session heartbeat feature
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@9882 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
@@ -106,6 +106,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_read_frame(switch_core_sessi
|
||||
switch_status_t status;
|
||||
int need_codec, perfect, do_bugs = 0, do_resample = 0, is_cng = 0;
|
||||
unsigned int flag = 0;
|
||||
switch_event_header_t *hi;
|
||||
|
||||
switch_assert(session != NULL);
|
||||
|
||||
@@ -122,6 +123,41 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_read_frame(switch_core_sessi
|
||||
|
||||
*frame = NULL;
|
||||
|
||||
if (session->read_codec && session->track_duration) {
|
||||
if (session->read_frame_count == 0) {
|
||||
switch_event_t *event;
|
||||
session->read_frame_count = (session->read_codec->implementation->samples_per_second /
|
||||
session->read_codec->implementation->samples_per_frame) * session->track_duration;
|
||||
|
||||
switch_event_create(&event, SWITCH_EVENT_SESSION_HEARTBEAT);
|
||||
switch_channel_event_set_data(session->channel, event);
|
||||
if (!switch_channel_test_flag(session->channel, CF_VERBOSE_EVENTS)) {
|
||||
if ((hi = switch_channel_variable_first(session->channel))) {
|
||||
for (; hi; hi = hi->next) {
|
||||
char buf[1024] = "";
|
||||
char *vvar = NULL, *vval = NULL;
|
||||
|
||||
if (strncasecmp(hi->name, "hb_", 3)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
vvar = (char *) hi->name;
|
||||
vval = (char *) hi->value;
|
||||
|
||||
switch_assert(vvar && vval);
|
||||
switch_snprintf(buf, sizeof(buf), "variable_%s", vvar);
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, buf, vval);
|
||||
}
|
||||
switch_channel_variable_last(session->channel);
|
||||
}
|
||||
}
|
||||
switch_event_fire(&event);
|
||||
} else {
|
||||
session->read_frame_count--;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (switch_channel_test_flag(session->channel, CF_HOLD)) {
|
||||
status = SWITCH_STATUS_BREAK;
|
||||
goto even_more_done;
|
||||
|
Reference in New Issue
Block a user