<p>sungtae kim has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.asterisk.org/c/asterisk/+/19223">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">res_musiconhold: Add option to not play music on hold on unanswered channels<br><br>This change adds an option, answeredonly, that will prevent music on<br>hold on channels that are not answered.<br><br>ASTERISK-30135<br><br>Change-Id: I1ab0defa43a29a26ae39f94c623596cf90fddc08<br>---<br>M configs/samples/musiconhold.conf.sample<br>A doc/CHANGES-staging/res_musiconhold_answeredonly.txt<br>M res/res_musiconhold.c<br>3 files changed, 30 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/23/19223/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/configs/samples/musiconhold.conf.sample b/configs/samples/musiconhold.conf.sample</span><br><span>index 2f60108..1737c7a 100644</span><br><span>--- a/configs/samples/musiconhold.conf.sample</span><br><span>+++ b/configs/samples/musiconhold.conf.sample</span><br><span>@@ -82,6 +82,9 @@</span><br><span> ; ; in alphabetical order. If 'randstart', the files are sorted</span><br><span> ; ; in alphabetical order as well, but the first file is chosen</span><br><span> ; ; at random. If unspecified, the sort order is undefined.</span><br><span style="color: hsl(120, 100%, 40%);">+;answeredonly=yes ; Only allow answered channels to have music on hold.</span><br><span style="color: hsl(120, 100%, 40%);">+ ; Enabling this will prevent MOH on unanswered channels.</span><br><span style="color: hsl(120, 100%, 40%);">+ ; (default: "no")</span><br><span> </span><br><span> ;[native-alphabetical]</span><br><span> ;mode=files</span><br><span>diff --git a/doc/CHANGES-staging/res_musiconhold_answeredonly.txt b/doc/CHANGES-staging/res_musiconhold_answeredonly.txt</span><br><span>new file mode 100644</span><br><span>index 0000000..c335184</span><br><span>--- /dev/null</span><br><span>+++ b/doc/CHANGES-staging/res_musiconhold_answeredonly.txt</span><br><span>@@ -0,0 +1,4 @@</span><br><span style="color: hsl(120, 100%, 40%);">+Subject: res_musiconhold_answeredonly</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+This change adds an option, answeredonly, that will prevent music</span><br><span style="color: hsl(120, 100%, 40%);">+on hold on channels that are not answered.</span><br><span>diff --git a/res/res_musiconhold.c b/res/res_musiconhold.c</span><br><span>index 9844de0..6196211 100644</span><br><span>--- a/res/res_musiconhold.c</span><br><span>+++ b/res/res_musiconhold.c</span><br><span>@@ -193,6 +193,8 @@</span><br><span> unsigned int delete:1;</span><br><span> AST_LIST_HEAD_NOLOCK(, mohdata) members;</span><br><span> AST_LIST_ENTRY(mohclass) list;</span><br><span style="color: hsl(120, 100%, 40%);">+ /*!< Play the moh if the channel answered */</span><br><span style="color: hsl(120, 100%, 40%);">+ int answeredonly;</span><br><span> };</span><br><span> </span><br><span> struct mohdata {</span><br><span>@@ -1193,6 +1195,8 @@</span><br><span> ast_log(LOG_WARNING, "kill_method '%s' is invalid. Setting to 'process_group'\n", var->value);</span><br><span> mohclass->kill_method = KILL_METHOD_PROCESS_GROUP;</span><br><span> }</span><br><span style="color: hsl(120, 100%, 40%);">+ } else if (!strcasecmp(var->name, "answeredonly")) {</span><br><span style="color: hsl(120, 100%, 40%);">+ mohclass->answeredonly = ast_true(var->value) ? 1: 0;</span><br><span> }</span><br><span> }</span><br><span> </span><br><span>@@ -1835,6 +1839,11 @@</span><br><span> return -1;</span><br><span> }</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+ if (mohclass->answeredonly && (ast_channel_state(chan) != AST_STATE_UP)) {</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_verb(3, "The channel '%s' is not answered yet. Ignore the moh request.\n", ast_channel_name(chan));</span><br><span style="color: hsl(120, 100%, 40%);">+ return -1;</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> /* If we are using a cached realtime class with files, re-scan the files */</span><br><span> if (!var && ast_test_flag(global_flags, MOH_CACHERTCLASSES) && mohclass->realtime && !strcasecmp(mohclass->mode, "files")) {</span><br><span> /*</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/c/asterisk/+/19223">change 19223</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/+/19223"/><meta itemprop="name" content="View Change"/></div></div>
<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: 19 </div>
<div style="display:none"> Gerrit-Change-Id: I1ab0defa43a29a26ae39f94c623596cf90fddc08 </div>
<div style="display:none"> Gerrit-Change-Number: 19223 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: sungtae kim <pchero21@gmail.com> </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>