add RECORD_ANSWER_REQ var

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@6389 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
Anthony Minessale 2007-11-23 18:35:38 +00:00
parent 620508cc80
commit 6481a0d11b
4 changed files with 42 additions and 4 deletions

View File

@ -157,6 +157,14 @@ SWITCH_DECLARE(void) switch_core_media_bug_set_write_replace_frame(switch_media_
*/ */
SWITCH_DECLARE(switch_frame_t *) switch_core_media_bug_get_read_replace_frame(switch_media_bug_t *bug); SWITCH_DECLARE(switch_frame_t *) switch_core_media_bug_get_read_replace_frame(switch_media_bug_t *bug);
/*!
\brief Obtain the session from a media bug
\param bug the bug to get the data from
*/
SWITCH_DECLARE(switch_core_session_t *) switch_core_media_bug_get_session(switch_media_bug_t *bug);
SWITCH_DECLARE(uint32_t) switch_core_media_bug_test_flag(switch_media_bug_t *bug, uint32_t flag);
/*! /*!
\brief Set a return replace frame \brief Set a return replace frame
\param bug the bug to set the frame on \param bug the bug to set the frame on

View File

@ -783,6 +783,8 @@ SMBF_READ_STREAM - Include the Read Stream
SMBF_WRITE_STREAM - Include the Write Stream SMBF_WRITE_STREAM - Include the Write Stream
SMBF_WRITE_REPLACE - Replace the Write Stream SMBF_WRITE_REPLACE - Replace the Write Stream
SMBF_READ_REPLACE - Replace the Read Stream SMBF_READ_REPLACE - Replace the Read Stream
SMBF_STEREO - Record in stereo
SMBF_ANSWER_RECORD_REQ - Don't record until the channel is answered
</pre> </pre>
*/ */
typedef enum { typedef enum {
@ -791,7 +793,8 @@ typedef enum {
SMBF_WRITE_STREAM = (1 << 1), SMBF_WRITE_STREAM = (1 << 1),
SMBF_WRITE_REPLACE = (1 << 2), SMBF_WRITE_REPLACE = (1 << 2),
SMBF_READ_REPLACE = (1 << 3), SMBF_READ_REPLACE = (1 << 3),
SMBF_STEREO = (1 << 4) SMBF_STEREO = (1 << 4),
SMBF_RECORD_ANSWER_REQ = (1 << 5)
} switch_media_bug_flag_t; } switch_media_bug_flag_t;
/*! /*!

View File

@ -40,6 +40,15 @@ static void switch_core_media_bug_destroy(switch_media_bug_t *bug)
switch_buffer_destroy(&bug->raw_write_buffer); switch_buffer_destroy(&bug->raw_write_buffer);
} }
SWITCH_DECLARE(uint32_t) switch_core_media_bug_test_flag(switch_media_bug_t *bug, uint32_t flag)
{
return switch_test_flag(bug, flag);
}
SWITCH_DECLARE(switch_core_session_t *) switch_core_media_bug_get_session(switch_media_bug_t *bug)
{
return bug->session;
}
SWITCH_DECLARE(switch_frame_t *) switch_core_media_bug_get_write_replace_frame(switch_media_bug_t *bug) SWITCH_DECLARE(switch_frame_t *) switch_core_media_bug_get_write_replace_frame(switch_media_bug_t *bug)
{ {

View File

@ -262,12 +262,26 @@ static switch_bool_t record_callback(switch_media_bug_t *bug, void *user_data, s
case SWITCH_ABC_TYPE_READ: case SWITCH_ABC_TYPE_READ:
if (fh) { if (fh) {
switch_size_t len; switch_size_t len;
switch_core_session_t *session;
switch_channel_t *channel;
session = switch_core_media_bug_get_session(bug);
assert(session != NULL);
channel = switch_core_session_get_channel(session);
assert(channel != NULL);
if (switch_core_media_bug_read(bug, &frame) == SWITCH_STATUS_SUCCESS) { if (switch_core_media_bug_read(bug, &frame) == SWITCH_STATUS_SUCCESS) {
int doit = 1;
if (!switch_channel_test_flag(channel, CF_ANSWERED) && switch_core_media_bug_test_flag(bug, SMBF_RECORD_ANSWER_REQ)) {
doit = 0;
}
if (doit) {
len = (switch_size_t) frame.datalen / 2; len = (switch_size_t) frame.datalen / 2;
switch_core_file_write(fh, frame.data, &len); switch_core_file_write(fh, frame.data, &len);
} }
} }
}
break; break;
case SWITCH_ABC_TYPE_WRITE: case SWITCH_ABC_TYPE_WRITE:
default: default:
@ -328,6 +342,10 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_record_session(switch_core_session_t
channels = 2; channels = 2;
} }
if ((p = switch_channel_get_variable(channel, "RECORD_ANSWER_REQ")) && switch_true(p)) {
flags |= SMBF_RECORD_ANSWER_REQ;
}
fh->channels = channels; fh->channels = channels;
fh->samplerate = read_codec->implementation->actual_samples_per_second; fh->samplerate = read_codec->implementation->actual_samples_per_second;