Restore operation of the option that only writes when the channel is bridged.

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@87850 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
Joshua Colp
2007-10-31 17:56:21 +00:00
parent d13f7d94b1
commit f066bfc38a

View File

@@ -98,6 +98,7 @@ struct mixmonitor {
char *post_process; char *post_process;
char *name; char *name;
unsigned int flags; unsigned int flags;
struct ast_channel *chan;
}; };
enum { enum {
@@ -165,25 +166,27 @@ static void *mixmonitor_thread(void *obj)
if (!(fr = ast_audiohook_read_frame(&mixmonitor->audiohook, SAMPLES_PER_FRAME, AST_AUDIOHOOK_DIRECTION_BOTH, AST_FORMAT_SLINEAR))) if (!(fr = ast_audiohook_read_frame(&mixmonitor->audiohook, SAMPLES_PER_FRAME, AST_AUDIOHOOK_DIRECTION_BOTH, AST_FORMAT_SLINEAR)))
continue; continue;
/* Initialize the file if not already done so */ if (!ast_test_flag(mixmonitor, MUXFLAG_BRIDGED) || ast_bridged_channel(mixmonitor->chan)) {
if (!fs && !errflag) { /* Initialize the file if not already done so */
oflags = O_CREAT | O_WRONLY; if (!fs && !errflag) {
oflags |= ast_test_flag(mixmonitor, MUXFLAG_APPEND) ? O_APPEND : O_TRUNC; oflags = O_CREAT | O_WRONLY;
oflags |= ast_test_flag(mixmonitor, MUXFLAG_APPEND) ? O_APPEND : O_TRUNC;
if ((ext = strrchr(mixmonitor->filename, '.'))) if ((ext = strrchr(mixmonitor->filename, '.')))
*(ext++) = '\0'; *(ext++) = '\0';
else else
ext = "raw"; ext = "raw";
if (!(fs = ast_writefile(mixmonitor->filename, ext, NULL, oflags, 0, 0644))) { if (!(fs = ast_writefile(mixmonitor->filename, ext, NULL, oflags, 0, 0644))) {
ast_log(LOG_ERROR, "Cannot open %s.%s\n", mixmonitor->filename, ext); ast_log(LOG_ERROR, "Cannot open %s.%s\n", mixmonitor->filename, ext);
errflag = 1; errflag = 1;
}
} }
}
/* Write out frame */ /* Write out frame */
if (fs) if (fs)
ast_writestream(fs, fr); ast_writestream(fs, fr);
}
/* All done! free it. */ /* All done! free it. */
ast_frame_free(fr, 0); ast_frame_free(fr, 0);
@@ -245,6 +248,7 @@ static void launch_monitor_thread(struct ast_channel *chan, const char *filename
/* Copy over flags and channel name */ /* Copy over flags and channel name */
mixmonitor->flags = flags; mixmonitor->flags = flags;
mixmonitor->chan = chan;
mixmonitor->name = (char *) mixmonitor + sizeof(*mixmonitor); mixmonitor->name = (char *) mixmonitor + sizeof(*mixmonitor);
strcpy(mixmonitor->name, chan->name); strcpy(mixmonitor->name, chan->name);
if (!ast_strlen_zero(postprocess2)) { if (!ast_strlen_zero(postprocess2)) {