<p>Michael Bradeen has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.asterisk.org/c/asterisk/+/19318">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">audiohook: add directional awareness<br><br>Add enum to allow setting optional direction. If set to only one<br>direction, only feed matching-direction frames to the associated<br>slin factory.<br><br>This prevents mangling the transcoder on non-mixed frames when the<br>READ and WRITE frames would have otherwise required it. Also<br>removes the need to mute or discard the un-wanted frames as they<br>are no longer added in the first place.<br><br>res_stasis_snoop is changed to use this addition to set direction<br>on audiohook based on spy direction.<br><br>If no direction is set, the ast_audiohook_init will init this enum<br>to BOTH which maintains existing functionality.<br><br>ASTERISK-30252<br><br>Change-Id: If8716bad334562a5d812be4eeb2a92e4f3be28eb<br>---<br>M include/asterisk/audiohook.h<br>M main/audiohook.c<br>M res/res_stasis_snoop.c<br>3 files changed, 40 insertions(+), 0 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/18/19318/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/include/asterisk/audiohook.h b/include/asterisk/audiohook.h</span><br><span>index 8e93d56..e9941ac 100644</span><br><span>--- a/include/asterisk/audiohook.h</span><br><span>+++ b/include/asterisk/audiohook.h</span><br><span>@@ -119,6 +119,7 @@</span><br><span> struct ast_audiohook_options options; /*!< Applicable options */</span><br><span> unsigned int hook_internal_samp_rate; /*!< internal read/write sample rate on the audiohook.*/</span><br><span> AST_LIST_ENTRY(ast_audiohook) list; /*!< Linked list information */</span><br><span style="color: hsl(120, 100%, 40%);">+ enum ast_audiohook_direction direction; /*!< Intended audiohook direction, BOTH by default on init */</span><br><span> };</span><br><span> </span><br><span> struct ast_audiohook_list;</span><br><span>diff --git a/main/audiohook.c b/main/audiohook.c</span><br><span>index 966d5f2..c671f37 100644</span><br><span>--- a/main/audiohook.c</span><br><span>+++ b/main/audiohook.c</span><br><span>@@ -109,6 +109,9 @@</span><br><span> </span><br><span> audiohook->init_flags = init_flags;</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+ /* Set direction to BOTH so that we feed frames in both directions */</span><br><span style="color: hsl(120, 100%, 40%);">+ audiohook->direction = AST_AUDIOHOOK_DIRECTION_BOTH;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> /* initialize internal rate at 8khz, this will adjust if necessary */</span><br><span> audiohook_set_internal_rate(audiohook, DEFAULT_INTERNAL_SAMPLE_RATE, 0);</span><br><span> </span><br><span>@@ -159,6 +162,13 @@</span><br><span> int other_factory_samples;</span><br><span> int other_factory_ms;</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+ /* Don't feed the frame if we are set to read and this is a write frame or if set to</span><br><span style="color: hsl(120, 100%, 40%);">+ write and this is a read frame as we don't want it. Plus, it can cause mis-resampling</span><br><span style="color: hsl(120, 100%, 40%);">+ if the READ and WRITE frames have different bitrates */</span><br><span style="color: hsl(120, 100%, 40%);">+ if(audiohook->direction!= AST_AUDIOHOOK_DIRECTION_BOTH && audiohook->direction!=direction){</span><br><span style="color: hsl(120, 100%, 40%);">+ return 0;</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> /* Update last feeding time to be current */</span><br><span> *rwtime = ast_tvnow();</span><br><span> </span><br><span>diff --git a/res/res_stasis_snoop.c b/res/res_stasis_snoop.c</span><br><span>index 8d0c6eb..6490a90 100644</span><br><span>--- a/res/res_stasis_snoop.c</span><br><span>+++ b/res/res_stasis_snoop.c</span><br><span>@@ -287,6 +287,9 @@</span><br><span> return -1;</span><br><span> }</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+ /* Set the direction so we don't write unused frames */</span><br><span style="color: hsl(120, 100%, 40%);">+ audiohook->direction = *direction;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> return ast_audiohook_attach(chan, audiohook);</span><br><span> }</span><br><span> </span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/c/asterisk/+/19318">change 19318</a>. To unsubscribe, or for help writing mail filters, visit <a href="https://gerrit.asterisk.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.asterisk.org/c/asterisk/+/19318"/><meta itemprop="name" content="View Change"/></div></div>
<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: 18 </div>
<div style="display:none"> Gerrit-Change-Id: If8716bad334562a5d812be4eeb2a92e4f3be28eb </div>
<div style="display:none"> Gerrit-Change-Number: 19318 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Michael Bradeen <mbradeen@sangoma.com> </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>