mirror of
https://github.com/signalwire/freeswitch.git
synced 2026-10-25 04:34:15 +00:00
add record_start and record_stop events
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@14591 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
1 parent
ee4674813f
commit
2c0eaac332
9 files changed
+70
-37
No files matched your search
@@ -1280,6 +1280,8 @@ typedef enum {
|
||||
SWITCH_EVENT_RECV_INFO,
|
||||
SWITCH_EVENT_CALL_SECURE,
|
||||
SWITCH_EVENT_NAT,
|
||||
SWITCH_EVENT_RECORD_START,
|
||||
SWITCH_EVENT_RECORD_STOP,
|
||||
SWITCH_EVENT_ALL
|
||||
} switch_event_types_t;
|
||||
|
||||
|
||||
@@ -1365,6 +1365,8 @@ SWITCH_DECLARE(void) switch_channel_event_set_extended_data(switch_channel_t *ch
|
||||
event->event_id == SWITCH_EVENT_CHANNEL_EXECUTE_COMPLETE ||
|
||||
event->event_id == SWITCH_EVENT_SESSION_HEARTBEAT ||
|
||||
event->event_id == SWITCH_EVENT_API ||
|
||||
event->event_id == SWITCH_EVENT_RECORD_START ||
|
||||
event->event_id == SWITCH_EVENT_RECORD_STOP ||
|
||||
event->event_id == SWITCH_EVENT_CUSTOM
|
||||
) {
|
||||
|
||||
|
||||
@@ -180,6 +180,8 @@ static char *EVENT_NAMES[] = {
|
||||
"RECV_INFO",
|
||||
"CALL_SECURE",
|
||||
"NAT",
|
||||
"RECORD_START",
|
||||
"RECORD_STOP",
|
||||
"ALL"
|
||||
};
|
||||
|
||||
|
||||
@@ -432,9 +432,16 @@ static switch_bool_t record_callback(switch_media_bug_t *bug, void *user_data, s
|
||||
switch_core_session_t *session = switch_core_media_bug_get_session(bug);
|
||||
switch_channel_t *channel = switch_core_session_get_channel(session);
|
||||
struct record_helper *rh = (struct record_helper *) user_data;
|
||||
switch_event_t *event;
|
||||
|
||||
|
||||
switch (type) {
|
||||
case SWITCH_ABC_TYPE_INIT:
|
||||
if (switch_event_create(&event, SWITCH_EVENT_RECORD_START) == SWITCH_STATUS_SUCCESS) {
|
||||
switch_channel_event_set_data(channel, event);
|
||||
switch_event_fire(&event);
|
||||
}
|
||||
|
||||
break;
|
||||
case SWITCH_ABC_TYPE_CLOSE:
|
||||
{
|
||||
@@ -444,6 +451,11 @@ static switch_bool_t record_callback(switch_media_bug_t *bug, void *user_data, s
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Stop recording file %s\n", rh->file);
|
||||
switch_channel_set_private(channel, rh->file, NULL);
|
||||
|
||||
if (switch_event_create(&event, SWITCH_EVENT_RECORD_STOP) == SWITCH_STATUS_SUCCESS) {
|
||||
switch_channel_event_set_data(channel, event);
|
||||
switch_event_fire(&event);
|
||||
}
|
||||
|
||||
if (rh->fh) {
|
||||
if (switch_channel_test_flag(channel, CF_ANSWERED) || !switch_core_media_bug_test_flag(bug, SMBF_RECORD_ANSWER_REQ)) {
|
||||
switch_size_t len;
|
||||
|
||||
@@ -393,7 +393,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_record_file(switch_core_session_t *se
|
||||
switch_codec_implementation_t read_impl = {0};
|
||||
switch_frame_t write_frame = { 0 };
|
||||
unsigned char write_buf[SWITCH_RECOMMENDED_BUFFER_SIZE] = { 0 };
|
||||
|
||||
switch_event_t *event;
|
||||
|
||||
switch_core_session_get_read_impl(session, &read_impl);
|
||||
|
||||
@@ -575,6 +575,12 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_record_file(switch_core_session_t *se
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (switch_event_create(&event, SWITCH_EVENT_RECORD_START) == SWITCH_STATUS_SUCCESS) {
|
||||
switch_channel_event_set_data(channel, event);
|
||||
switch_event_fire(&event);
|
||||
}
|
||||
|
||||
for (;;) {
|
||||
switch_size_t len;
|
||||
|
||||
@@ -685,6 +691,11 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_record_file(switch_core_session_t *se
|
||||
|
||||
}
|
||||
|
||||
if (switch_event_create(&event, SWITCH_EVENT_RECORD_STOP) == SWITCH_STATUS_SUCCESS) {
|
||||
switch_channel_event_set_data(channel, event);
|
||||
switch_event_fire(&event);
|
||||
}
|
||||
|
||||
if (waste_resources) {
|
||||
switch_core_codec_destroy(&write_codec);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user