[Asterisk-code-review] res/res stasis snoop: generate silence when audiohook return... (asterisk[14])
Torrey Searle
asteriskteam at digium.com
Tue Jul 11 10:00:56 CDT 2017
Torrey Searle has uploaded this change for review. ( https://gerrit.asterisk.org/5989
Change subject: res/res_stasis_snoop: generate silence when audiohook returns null
......................................................................
res/res_stasis_snoop: generate silence when audiohook returns null
Currently when rtp is paused, no packets are written to the
recorded audio file, causing the silence to be skipped and recording
not properly time aligned. The read handler as been adapted to
return a silence frame of the correct size.
ASTERISK-27128 #close
Change-Id: I2d7f60650457860b9c70907b14426756b058a844
---
M res/res_stasis_snoop.c
1 file changed, 17 insertions(+), 1 deletion(-)
git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/89/5989/1
diff --git a/res/res_stasis_snoop.c b/res/res_stasis_snoop.c
index e5b5bf6..56d15cf 100644
--- a/res/res_stasis_snoop.c
+++ b/res/res_stasis_snoop.c
@@ -74,6 +74,8 @@
unsigned int whisper_active:1;
/*! \brief Uniqueid of the channel this snoop is snooping on */
char uniqueid[AST_MAX_UNIQUEID];
+ /*! \brief A frame of silence to use when the audiohook returns null */
+ struct ast_frame silence;
};
/*! \brief Destructor for snoop structure */
@@ -91,6 +93,11 @@
if (snoop->whisper_active) {
ast_audiohook_destroy(&snoop->whisper);
+ }
+
+ if (snoop->silence.data.ptr) {
+ ast_free(snoop->silence.data.ptr);
+ snoop->silence.data.ptr = NULL;
}
ast_free(snoop->app);
@@ -199,7 +206,7 @@
frame = ast_audiohook_read_frame(&snoop->spy, snoop->spy_samples, snoop->spy_direction, snoop->spy_format);
ast_audiohook_unlock(&snoop->spy);
- return frame ? frame : &ast_null_frame;
+ return frame ? frame : &snoop->silence;
}
/*! \brief Callback function for hanging up a Snoop channel */
@@ -385,6 +392,15 @@
snoop->spy_samples = ast_format_get_sample_rate(snoop->spy_format) / (1000 / SNOOP_INTERVAL);
snoop->spy_active = 1;
+
+ snoop->silence.frametype = AST_FRAME_VOICE,
+ snoop->silence.datalen = snoop->spy_samples * sizeof(uint16_t),
+ snoop->silence.samples = snoop->spy_samples,
+ snoop->silence.mallocd = 0,
+ snoop->silence.offset = 0,
+ snoop->silence.src = __PRETTY_FUNCTION__,
+ snoop->silence.subclass.format = snoop->spy_format,
+ snoop->silence.data.ptr = ast_calloc(snoop->spy_samples, sizeof(uint16_t));
}
/* If whispering is enabled set up the audiohook */
--
To view, visit https://gerrit.asterisk.org/5989
To unsubscribe, visit https://gerrit.asterisk.org/settings
Gerrit-Project: asterisk
Gerrit-Branch: 14
Gerrit-MessageType: newchange
Gerrit-Change-Id: I2d7f60650457860b9c70907b14426756b058a844
Gerrit-Change-Number: 5989
Gerrit-PatchSet: 1
Gerrit-Owner: Torrey Searle <tsearle at gmail.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20170711/a251e4e5/attachment.html>
More information about the asterisk-code-review
mailing list