[Asterisk-code-review] res_parking: Add music on hold override option. (asterisk[16])

Friendly Automation asteriskteam at digium.com
Thu Jun 9 04:42:45 CDT 2022


Friendly Automation has submitted this change. ( https://gerrit.asterisk.org/c/asterisk/+/18620 )

Change subject: res_parking: Add music on hold override option.
......................................................................

res_parking: Add music on hold override option.

An m option to Park and ParkAndAnnounce now allows
specifying a music on hold class override.

ASTERISK-30087

Change-Id: I03de8d97b100e451b2611b5a621d48750f5d6a9e
---
A doc/CHANGES-staging/res_parking_moh.txt
M res/parking/parking_applications.c
2 files changed, 29 insertions(+), 5 deletions(-)

Approvals:
  Joshua Colp: Looks good to me, but someone else must approve
  Kevin Harwell: Looks good to me, approved
  Friendly Automation: Approved for Submit



diff --git a/doc/CHANGES-staging/res_parking_moh.txt b/doc/CHANGES-staging/res_parking_moh.txt
new file mode 100644
index 0000000..50f589c
--- /dev/null
+++ b/doc/CHANGES-staging/res_parking_moh.txt
@@ -0,0 +1,4 @@
+Subject: res_parking
+
+An m option to Park and ParkAndAnnounce now allows
+specifying a music on hold class override.
diff --git a/res/parking/parking_applications.c b/res/parking/parking_applications.c
index 29878f8..531db88 100644
--- a/res/parking/parking_applications.c
+++ b/res/parking/parking_applications.c
@@ -241,6 +241,7 @@
 enum park_args {
 	OPT_ARG_COMEBACK,
 	OPT_ARG_TIMEOUT,
+	OPT_ARG_MUSICONHOLD,
 	OPT_ARG_ARRAY_SIZE /* Always the last element of the enum */
 };
 
@@ -250,6 +251,7 @@
 	MUXFLAG_NOANNOUNCE = (1 << 2),
 	MUXFLAG_COMEBACK_OVERRIDE = (1 << 3),
 	MUXFLAG_TIMEOUT_OVERRIDE = (1 << 4),
+	MUXFLAG_MUSICONHOLD = (1 << 5),
 };
 
 AST_APP_OPTIONS(park_opts, {
@@ -258,6 +260,7 @@
 	AST_APP_OPTION('s', MUXFLAG_NOANNOUNCE),
 	AST_APP_OPTION_ARG('c', MUXFLAG_COMEBACK_OVERRIDE, OPT_ARG_COMEBACK),
 	AST_APP_OPTION_ARG('t', MUXFLAG_TIMEOUT_OVERRIDE, OPT_ARG_TIMEOUT),
+	AST_APP_OPTION_ARG('m', MUXFLAG_MUSICONHOLD, OPT_ARG_MUSICONHOLD),
 });
 
 static int apply_option_timeout (int *var, char *timeout_arg)
@@ -275,7 +278,8 @@
 	return 0;
 }
 
-static int park_app_parse_data(const char *data, int *disable_announce, int *use_ringing, int *randomize, int *time_limit, char **comeback_override, char **lot_name)
+static int park_app_parse_data(const char *data, int *disable_announce, int *use_ringing, int *randomize, int *time_limit,
+	char **comeback_override, char **lot_name, char **musicclass)
 {
 	char *parse;
 	struct ast_flags flags = { 0 };
@@ -308,6 +312,10 @@
 			}
 		}
 
+		if (ast_test_flag(&flags, MUXFLAG_MUSICONHOLD)) {
+			*musicclass = ast_strdup(opts[OPT_ARG_MUSICONHOLD]);
+		}
+
 		if (ast_test_flag(&flags, MUXFLAG_RINGING)) {
 			*use_ringing = 1;
 		}
@@ -481,8 +489,8 @@
 	return data_copy;
 }
 
-struct ast_bridge *park_common_setup(struct ast_channel *parkee, struct ast_channel *parker,
-		const char *lot_name, const char *comeback_override,
+static struct ast_bridge *park_common_setup2(struct ast_channel *parkee, struct ast_channel *parker,
+		const char *lot_name, const char *comeback_override, const char *musicclass,
 		int use_ringing, int randomize, int time_limit, int silence_announcements)
 {
 	struct ast_bridge *parking_bridge;
@@ -518,11 +526,22 @@
 
 	/* Apply relevant bridge roles and such to the parking channel */
 	parking_channel_set_roles(parkee, lot, use_ringing);
+	/* If requested, override the MOH class */
+	if (!ast_strlen_zero(musicclass)) {
+		ast_channel_set_bridge_role_option(parkee, "holding_participant", "moh_class", musicclass);
+	}
 	setup_park_common_datastore(parkee, ast_channel_uniqueid(parker), comeback_override, randomize, time_limit,
 		silence_announcements);
 	return parking_bridge;
 }
 
+struct ast_bridge *park_common_setup(struct ast_channel *parkee, struct ast_channel *parker,
+		const char *lot_name, const char *comeback_override,
+		int use_ringing, int randomize, int time_limit, int silence_announcements)
+{
+	return park_common_setup2(parkee, parker, lot_name, comeback_override, NULL, use_ringing, randomize, time_limit, silence_announcements);
+}
+
 struct ast_bridge *park_application_setup(struct ast_channel *parkee, struct ast_channel *parker, const char *app_data,
 		int *silence_announcements)
 {
@@ -532,12 +551,13 @@
 
 	RAII_VAR(char *, comeback_override, NULL, ast_free);
 	RAII_VAR(char *, lot_name_app_arg, NULL, ast_free);
+	RAII_VAR(char *, musicclass, NULL, ast_free);
 
 	if (app_data) {
-		park_app_parse_data(app_data, silence_announcements, &use_ringing, &randomize, &time_limit, &comeback_override, &lot_name_app_arg);
+		park_app_parse_data(app_data, silence_announcements, &use_ringing, &randomize, &time_limit, &comeback_override, &lot_name_app_arg, &musicclass);
 	}
 
-	return park_common_setup(parkee, parker, lot_name_app_arg, comeback_override, use_ringing,
+	return park_common_setup2(parkee, parker, lot_name_app_arg, comeback_override, musicclass, use_ringing,
 		randomize, time_limit, silence_announcements ? *silence_announcements : 0);
 
 }

-- 
To view, visit https://gerrit.asterisk.org/c/asterisk/+/18620
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings

Gerrit-Project: asterisk
Gerrit-Branch: 16
Gerrit-Change-Id: I03de8d97b100e451b2611b5a621d48750f5d6a9e
Gerrit-Change-Number: 18620
Gerrit-PatchSet: 2
Gerrit-Owner: N A <mail at interlinked.x10host.com>
Gerrit-Reviewer: Friendly Automation
Gerrit-Reviewer: Joshua Colp <jcolp at sangoma.com>
Gerrit-Reviewer: Kevin Harwell <kharwell at digium.com>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20220609/360de56e/attachment-0001.html>


More information about the asterisk-code-review mailing list