mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-05 12:16:00 +00:00
res_musiconhold: Add option to not play music on hold on unanswered channels
This change adds an option, answeredonly, that will prevent music on hold on channels that are not answered. ASTERISK-30135 Change-Id: I1ab0defa43a29a26ae39f94c623596cf90fddc08
This commit is contained in:
committed by
Friendly Automation
parent
31b3addce7
commit
fc63688e3b
@@ -82,6 +82,9 @@ directory=moh
|
|||||||
; ; in alphabetical order. If 'randstart', the files are sorted
|
; ; in alphabetical order. If 'randstart', the files are sorted
|
||||||
; ; in alphabetical order as well, but the first file is chosen
|
; ; in alphabetical order as well, but the first file is chosen
|
||||||
; ; at random. If unspecified, the sort order is undefined.
|
; ; at random. If unspecified, the sort order is undefined.
|
||||||
|
;answeredonly=yes ; Only allow answered channels to have music on hold.
|
||||||
|
; Enabling this will prevent MOH on unanswered channels.
|
||||||
|
; (default: "no")
|
||||||
|
|
||||||
;[native-alphabetical]
|
;[native-alphabetical]
|
||||||
;mode=files
|
;mode=files
|
||||||
|
4
doc/CHANGES-staging/res_musiconhold_answeredonly.txt
Normal file
4
doc/CHANGES-staging/res_musiconhold_answeredonly.txt
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
Subject: res_musiconhold_answeredonly
|
||||||
|
|
||||||
|
This change adds an option, answeredonly, that will prevent music
|
||||||
|
on hold on channels that are not answered.
|
@@ -193,6 +193,8 @@ struct mohclass {
|
|||||||
unsigned int delete:1;
|
unsigned int delete:1;
|
||||||
AST_LIST_HEAD_NOLOCK(, mohdata) members;
|
AST_LIST_HEAD_NOLOCK(, mohdata) members;
|
||||||
AST_LIST_ENTRY(mohclass) list;
|
AST_LIST_ENTRY(mohclass) list;
|
||||||
|
/*!< Play the moh if the channel answered */
|
||||||
|
int answeredonly;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct mohdata {
|
struct mohdata {
|
||||||
@@ -1193,6 +1195,8 @@ static void moh_parse_options(struct ast_variable *var, struct mohclass *mohclas
|
|||||||
ast_log(LOG_WARNING, "kill_method '%s' is invalid. Setting to 'process_group'\n", var->value);
|
ast_log(LOG_WARNING, "kill_method '%s' is invalid. Setting to 'process_group'\n", var->value);
|
||||||
mohclass->kill_method = KILL_METHOD_PROCESS_GROUP;
|
mohclass->kill_method = KILL_METHOD_PROCESS_GROUP;
|
||||||
}
|
}
|
||||||
|
} else if (!strcasecmp(var->name, "answeredonly")) {
|
||||||
|
mohclass->answeredonly = ast_true(var->value) ? 1: 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1835,6 +1839,11 @@ static int local_ast_moh_start(struct ast_channel *chan, const char *mclass, con
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (mohclass->answeredonly && (ast_channel_state(chan) != AST_STATE_UP)) {
|
||||||
|
ast_verb(3, "The channel '%s' is not answered yet. Ignore the moh request.\n", ast_channel_name(chan));
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
/* If we are using a cached realtime class with files, re-scan the files */
|
/* If we are using a cached realtime class with files, re-scan the files */
|
||||||
if (!var && ast_test_flag(global_flags, MOH_CACHERTCLASSES) && mohclass->realtime && !strcasecmp(mohclass->mode, "files")) {
|
if (!var && ast_test_flag(global_flags, MOH_CACHERTCLASSES) && mohclass->realtime && !strcasecmp(mohclass->mode, "files")) {
|
||||||
/*
|
/*
|
||||||
|
Reference in New Issue
Block a user