mirror of
https://github.com/asterisk/asterisk.git
synced 2025-10-02 10:22:46 +00:00
res_agi: Respect "transmit_silence" option for "RECORD FILE".
The "RECORD FILE" command in res_agi has its own implementation for actually doing the recording. This has resulted in it not actually obeying the option "transmit_silence" when recording. This change causes it to now send silence if the option is enabled. ASTERISK-30314 Change-Id: Ib3a85601ff35d1b904f836691bad8a4b7e957174
This commit is contained in:
committed by
Joshua Colp
parent
1a72025c35
commit
e50b2bfad9
@@ -2908,6 +2908,7 @@ static int handle_recordfile(struct ast_channel *chan, AGI *agi, int argc, const
|
|||||||
int gotsilence = 0; /* did we timeout for silence? */
|
int gotsilence = 0; /* did we timeout for silence? */
|
||||||
char *silencestr = NULL;
|
char *silencestr = NULL;
|
||||||
RAII_VAR(struct ast_format *, rfmt, NULL, ao2_cleanup);
|
RAII_VAR(struct ast_format *, rfmt, NULL, ao2_cleanup);
|
||||||
|
struct ast_silence_generator *silgen = NULL;
|
||||||
|
|
||||||
/* XXX EAGI FIXME XXX */
|
/* XXX EAGI FIXME XXX */
|
||||||
|
|
||||||
@@ -2985,6 +2986,10 @@ static int handle_recordfile(struct ast_channel *chan, AGI *agi, int argc, const
|
|||||||
ast_seekstream(fs, sample_offset, SEEK_SET);
|
ast_seekstream(fs, sample_offset, SEEK_SET);
|
||||||
ast_truncstream(fs);
|
ast_truncstream(fs);
|
||||||
|
|
||||||
|
if (ast_opt_transmit_silence) {
|
||||||
|
silgen = ast_channel_start_silence_generator(chan);
|
||||||
|
}
|
||||||
|
|
||||||
start = ast_tvnow();
|
start = ast_tvnow();
|
||||||
while ((ms < 0) || ast_tvdiff_ms(ast_tvnow(), start) < ms) {
|
while ((ms < 0) || ast_tvdiff_ms(ast_tvnow(), start) < ms) {
|
||||||
res = ast_waitfor(chan, ms - ast_tvdiff_ms(ast_tvnow(), start));
|
res = ast_waitfor(chan, ms - ast_tvdiff_ms(ast_tvnow(), start));
|
||||||
@@ -2993,6 +2998,8 @@ static int handle_recordfile(struct ast_channel *chan, AGI *agi, int argc, const
|
|||||||
ast_agi_send(agi->fd, chan, "200 result=%d (waitfor) endpos=%ld\n", res,sample_offset);
|
ast_agi_send(agi->fd, chan, "200 result=%d (waitfor) endpos=%ld\n", res,sample_offset);
|
||||||
if (sildet)
|
if (sildet)
|
||||||
ast_dsp_free(sildet);
|
ast_dsp_free(sildet);
|
||||||
|
if (silgen)
|
||||||
|
ast_channel_stop_silence_generator(chan, silgen);
|
||||||
return RESULT_FAILURE;
|
return RESULT_FAILURE;
|
||||||
}
|
}
|
||||||
f = ast_read(chan);
|
f = ast_read(chan);
|
||||||
@@ -3001,6 +3008,8 @@ static int handle_recordfile(struct ast_channel *chan, AGI *agi, int argc, const
|
|||||||
ast_agi_send(agi->fd, chan, "200 result=%d (hangup) endpos=%ld\n", -1, sample_offset);
|
ast_agi_send(agi->fd, chan, "200 result=%d (hangup) endpos=%ld\n", -1, sample_offset);
|
||||||
if (sildet)
|
if (sildet)
|
||||||
ast_dsp_free(sildet);
|
ast_dsp_free(sildet);
|
||||||
|
if (silgen)
|
||||||
|
ast_channel_stop_silence_generator(chan, silgen);
|
||||||
return RESULT_FAILURE;
|
return RESULT_FAILURE;
|
||||||
}
|
}
|
||||||
switch(f->frametype) {
|
switch(f->frametype) {
|
||||||
@@ -3017,6 +3026,8 @@ static int handle_recordfile(struct ast_channel *chan, AGI *agi, int argc, const
|
|||||||
ast_frfree(f);
|
ast_frfree(f);
|
||||||
if (sildet)
|
if (sildet)
|
||||||
ast_dsp_free(sildet);
|
ast_dsp_free(sildet);
|
||||||
|
if (silgen)
|
||||||
|
ast_channel_stop_silence_generator(chan, silgen);
|
||||||
return RESULT_SUCCESS;
|
return RESULT_SUCCESS;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -3068,6 +3079,10 @@ static int handle_recordfile(struct ast_channel *chan, AGI *agi, int argc, const
|
|||||||
ast_dsp_free(sildet);
|
ast_dsp_free(sildet);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (silgen) {
|
||||||
|
ast_channel_stop_silence_generator(chan, silgen);
|
||||||
|
}
|
||||||
|
|
||||||
return RESULT_SUCCESS;
|
return RESULT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user