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:
parent
620508cc80
commit
6481a0d11b
|
@ -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);
|
||||
|
||||
/*!
|
||||
\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
|
||||
\param bug the bug to set the frame on
|
||||
|
|
|
@ -783,6 +783,8 @@ SMBF_READ_STREAM - Include the Read Stream
|
|||
SMBF_WRITE_STREAM - Include the Write Stream
|
||||
SMBF_WRITE_REPLACE - Replace the Write 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>
|
||||
*/
|
||||
typedef enum {
|
||||
|
@ -791,7 +793,8 @@ typedef enum {
|
|||
SMBF_WRITE_STREAM = (1 << 1),
|
||||
SMBF_WRITE_REPLACE = (1 << 2),
|
||||
SMBF_READ_REPLACE = (1 << 3),
|
||||
SMBF_STEREO = (1 << 4)
|
||||
SMBF_STEREO = (1 << 4),
|
||||
SMBF_RECORD_ANSWER_REQ = (1 << 5)
|
||||
} switch_media_bug_flag_t;
|
||||
|
||||
/*!
|
||||
|
|
|
@ -40,6 +40,15 @@ static void switch_core_media_bug_destroy(switch_media_bug_t *bug)
|
|||
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)
|
||||
{
|
||||
|
|
|
@ -262,10 +262,24 @@ static switch_bool_t record_callback(switch_media_bug_t *bug, void *user_data, s
|
|||
case SWITCH_ABC_TYPE_READ:
|
||||
if (fh) {
|
||||
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) {
|
||||
len = (switch_size_t) frame.datalen / 2;
|
||||
switch_core_file_write(fh, frame.data, &len);
|
||||
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;
|
||||
switch_core_file_write(fh, frame.data, &len);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -327,6 +341,10 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_record_session(switch_core_session_t
|
|||
flags |= SMBF_STEREO;
|
||||
channels = 2;
|
||||
}
|
||||
|
||||
if ((p = switch_channel_get_variable(channel, "RECORD_ANSWER_REQ")) && switch_true(p)) {
|
||||
flags |= SMBF_RECORD_ANSWER_REQ;
|
||||
}
|
||||
|
||||
fh->channels = channels;
|
||||
fh->samplerate = read_codec->implementation->actual_samples_per_second;
|
||||
|
|
Loading…
Reference in New Issue