<p>sungtae kim has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.asterisk.org/c/asterisk/+/18966">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, 18 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/66/18966/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..f4f909a 100644</span><br><span>--- a/configs/samples/musiconhold.conf.sample</span><br><span>+++ b/configs/samples/musiconhold.conf.sample</span><br><span>@@ -10,6 +10,10 @@</span><br><span> ; over a class set by an application (e.g. a musicclass set on a queue).</span><br><span> ; Defaults to yes.</span><br><span> </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 style="color: hsl(120, 100%, 40%);">+</span><br><span> ; valid mode options:</span><br><span> ; files -- read files from a directory in any Asterisk supported</span><br><span> ; media format</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..01c9cf8 100644</span><br><span>--- a/res/res_musiconhold.c</span><br><span>+++ b/res/res_musiconhold.c</span><br><span>@@ -152,6 +152,7 @@</span><br><span> #define MOH_CACHERTCLASSES (1 << 5) /*!< Should we use a separate instance of MOH for each user or not */</span><br><span> #define MOH_ANNOUNCEMENT (1 << 6) /*!< Do we play announcement files between songs on this channel? */</span><br><span> #define MOH_PREFERCHANNELCLASS (1 << 7) /*!< Should queue moh override channel moh */</span><br><span style="color: hsl(120, 100%, 40%);">+#define MOH_ANSWEREDONLY (1 << 8) /*!< Play the moh if the channel answered */</span><br><span> </span><br><span> /* Custom astobj2 flag */</span><br><span> #define MOH_NOTDELETED (1 << 30) /*!< Find only records that aren't deleted? */</span><br><span>@@ -1659,6 +1660,13 @@</span><br><span> int warn_if_not_in_memory = !realtime_possible;</span><br><span> const char *classes[] = {NULL, NULL, interpclass, "default"};</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+ if (ast_test_flag(global_flags, MOH_ANSWEREDONLY)) {</span><br><span style="color: hsl(120, 100%, 40%);">+ if (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 style="color: hsl(120, 100%, 40%);">+</span><br><span> if (ast_test_flag(global_flags, MOH_PREFERCHANNELCLASS)) {</span><br><span> classes[0] = ast_channel_musicclass(chan);</span><br><span> classes[1] = mclass;</span><br><span>@@ -2013,6 +2021,8 @@</span><br><span> ast_set2_flag(global_flags, ast_true(var->value), MOH_CACHERTCLASSES);</span><br><span> } else if (!strcasecmp(var->name, "preferchannelclass")) {</span><br><span> ast_set2_flag(global_flags, ast_true(var->value), MOH_PREFERCHANNELCLASS);</span><br><span style="color: hsl(120, 100%, 40%);">+ } else if (!strcasecmp(var->name, "answeredonly")) {</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_set2_flag(global_flags, ast_true(var->value), MOH_ANSWEREDONLY);</span><br><span> } else {</span><br><span> ast_log(LOG_WARNING, "Unknown option '%s' in [general] section of musiconhold.conf\n", var->name);</span><br><span> }</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/c/asterisk/+/18966">change 18966</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/+/18966"/><meta itemprop="name" content="View Change"/></div></div>
<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-Change-Id: I1ab0defa43a29a26ae39f94c623596cf90fddc08 </div>
<div style="display:none"> Gerrit-Change-Number: 18966 </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>