241241enum park_args {
242242 OPT_ARG_COMEBACK ,
243243 OPT_ARG_TIMEOUT ,
244+ OPT_ARG_MUSICONHOLD ,
244245 OPT_ARG_ARRAY_SIZE /* Always the last element of the enum */
245246};
246247
@@ -250,6 +251,7 @@ enum park_flags {
250251 MUXFLAG_NOANNOUNCE = (1 << 2 ),
251252 MUXFLAG_COMEBACK_OVERRIDE = (1 << 3 ),
252253 MUXFLAG_TIMEOUT_OVERRIDE = (1 << 4 ),
254+ MUXFLAG_MUSICONHOLD = (1 << 5 ),
253255};
254256
255257AST_APP_OPTIONS (park_opts , {
@@ -258,6 +260,7 @@ AST_APP_OPTIONS(park_opts, {
258260 AST_APP_OPTION ('s' , MUXFLAG_NOANNOUNCE ),
259261 AST_APP_OPTION_ARG ('c' , MUXFLAG_COMEBACK_OVERRIDE , OPT_ARG_COMEBACK ),
260262 AST_APP_OPTION_ARG ('t' , MUXFLAG_TIMEOUT_OVERRIDE , OPT_ARG_TIMEOUT ),
263+ AST_APP_OPTION_ARG ('m' , MUXFLAG_MUSICONHOLD , OPT_ARG_MUSICONHOLD ),
261264});
262265
263266static int apply_option_timeout (int * var , char * timeout_arg )
@@ -275,7 +278,8 @@ static int apply_option_timeout (int *var, char *timeout_arg)
275278 return 0 ;
276279}
277280
278- 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 )
281+ static int park_app_parse_data (const char * data , int * disable_announce , int * use_ringing , int * randomize , int * time_limit ,
282+ char * * comeback_override , char * * lot_name , char * * musicclass )
279283{
280284 char * parse ;
281285 struct ast_flags flags = { 0 };
@@ -308,6 +312,10 @@ static int park_app_parse_data(const char *data, int *disable_announce, int *use
308312 }
309313 }
310314
315+ if (ast_test_flag (& flags , MUXFLAG_MUSICONHOLD )) {
316+ * musicclass = ast_strdup (opts [OPT_ARG_MUSICONHOLD ]);
317+ }
318+
311319 if (ast_test_flag (& flags , MUXFLAG_RINGING )) {
312320 * use_ringing = 1 ;
313321 }
@@ -481,8 +489,8 @@ struct park_common_datastore *get_park_common_datastore_copy(struct ast_channel
481489 return data_copy ;
482490}
483491
484- struct ast_bridge * park_common_setup (struct ast_channel * parkee , struct ast_channel * parker ,
485- const char * lot_name , const char * comeback_override ,
492+ static struct ast_bridge * park_common_setup2 (struct ast_channel * parkee , struct ast_channel * parker ,
493+ const char * lot_name , const char * comeback_override , const char * musicclass ,
486494 int use_ringing , int randomize , int time_limit , int silence_announcements )
487495{
488496 struct ast_bridge * parking_bridge ;
@@ -518,11 +526,22 @@ struct ast_bridge *park_common_setup(struct ast_channel *parkee, struct ast_chan
518526
519527 /* Apply relevant bridge roles and such to the parking channel */
520528 parking_channel_set_roles (parkee , lot , use_ringing );
529+ /* If requested, override the MOH class */
530+ if (!ast_strlen_zero (musicclass )) {
531+ ast_channel_set_bridge_role_option (parkee , "holding_participant" , "moh_class" , musicclass );
532+ }
521533 setup_park_common_datastore (parkee , ast_channel_uniqueid (parker ), comeback_override , randomize , time_limit ,
522534 silence_announcements );
523535 return parking_bridge ;
524536}
525537
538+ struct ast_bridge * park_common_setup (struct ast_channel * parkee , struct ast_channel * parker ,
539+ const char * lot_name , const char * comeback_override ,
540+ int use_ringing , int randomize , int time_limit , int silence_announcements )
541+ {
542+ return park_common_setup2 (parkee , parker , lot_name , comeback_override , NULL , use_ringing , randomize , time_limit , silence_announcements );
543+ }
544+
526545struct ast_bridge * park_application_setup (struct ast_channel * parkee , struct ast_channel * parker , const char * app_data ,
527546 int * silence_announcements )
528547{
@@ -532,12 +551,13 @@ struct ast_bridge *park_application_setup(struct ast_channel *parkee, struct ast
532551
533552 RAII_VAR (char * , comeback_override , NULL , ast_free );
534553 RAII_VAR (char * , lot_name_app_arg , NULL , ast_free );
554+ RAII_VAR (char * , musicclass , NULL , ast_free );
535555
536556 if (app_data ) {
537- park_app_parse_data (app_data , silence_announcements , & use_ringing , & randomize , & time_limit , & comeback_override , & lot_name_app_arg );
557+ park_app_parse_data (app_data , silence_announcements , & use_ringing , & randomize , & time_limit , & comeback_override , & lot_name_app_arg , & musicclass );
538558 }
539559
540- return park_common_setup (parkee , parker , lot_name_app_arg , comeback_override , use_ringing ,
560+ return park_common_setup2 (parkee , parker , lot_name_app_arg , comeback_override , musicclass , use_ringing ,
541561 randomize , time_limit , silence_announcements ? * silence_announcements : 0 );
542562
543563}
0 commit comments