[Home]

Summary:ASTERISK-23636: [patch]Filesystem based dynamic MoH classes
Reporter:Vitezslav Novy (vnovy)Labels:
Date Opened:2014-04-16 02:57:09Date Closed:2017-10-01 10:16:17
Priority:MinorRegression?No
Status:Closed/CompleteComponents:Resources/res_musiconhold
Versions:SVN Frequency of
Occurrence
Related
Issues:
Environment:Attachments:( 0) trunk-moh-20140415.patch
( 1) trunk-moh-20140422.patch
Description:This patch introduces another approach to dynamically controlled MoH.
Unlike realtime this way is file based.

As a switch between normal and alternative behavior, boolean variable
'dynamic' is used in MoH config file.

By setting

dynamic=yes

new behavior is switched on.



How dynamic behavior works

All static MoH classes in musiconhold.conf and realtime are ignored, except [default]
class. On the other hand dynamic class named 'default' is ignored too.

New variable 'dynamic_dir' defines directory, where dynamic classes are
defined. Each first level subdirectory of dynamic_dir defines one MoH class
with same name as directory name.
If class directory contains playlist file 'playlist.txt' content of
the file defines audiofiles in class and their order. Otherwise directory
is scanned same way as for standard MoH class with mode=files.

Playlist expects one file on line, without path and without extension.
Files must be placed in class directory.
If first line of playlist contains exactly one character '%', files will be
ordered randomly.

Comments:By: Rusty Newton (rnewton) 2014-04-17 11:49:30.489-0500

Interesting. You would also need to submit a patch to the musiconhold.conf.sample for the "dynamic" option, to explain it's use. Additionally submitting content for a wiki page would be helpful as well, though you might wait on that until after the code review process.

Please check out the [Code Review|https://wiki.asterisk.org/wiki/display/AST/Code+Review] process and follow that, especially the [check list|https://wiki.asterisk.org/wiki/display/AST/Code+Review+Checklist]. Once you get the reviewboard URL, you can edit this issue to add it for reference.

Thanks!



By: Matt Jordan (mjordan) 2014-04-17 16:28:40.024-0500

This does need to be put up for code review; however, I don't think I like the implementation approach. It's very complex. If we're going to define such things, why wouldn't we just define a class within musiconhold.conf and within that class explicitly order and define the path of a file to be used?

Having users create a separate playlist file that's referenced from some other directory doesn't seem to offer a simple or robust solution. The playlist should simply be part of musiconhold.conf, and if a particular play control is needed, put a particular method as an attribute of a class.


By: Vitezslav Novy (vnovy) 2014-04-18 01:54:15.852-0500

Thank you for your time spent on this.

This patch adds 2 independent features
- possibility to create dynamic class using filesystem, without DB and realtime
- playlist

When we'd define class in musiconhold.conf, as you suggest, it was not dynamic anymore. My approach allows create/delete/change MoH classes without module reload.

Also I do not understand your note about playlist referenced from other directory. Playlist is in class directory with all class audio files. Structure is same as for static MoH classes. Directory defined in dynamic_dir variable contains class directories which contain audio files.

On the other hand I agree with you that playlist feature can be implemented more generally - for static and RT classes too.



By: James Van Vleet (jvanvleet) 2014-04-18 08:05:32.468-0500

I should add some color here as well.   I asked Vitezslav to create this change and I use it today.    The issue we are working to solve is that while it is possible with the power of AMI and AGI to provide an almost totally custom experience to an individual caller, there are just a few things that remain out of reach.  One of the things I needed  was the ability to set the music on hold class for a call based on information gathered *at the time of the call*.    This patch allows us to build a MOH class and playlists "on the fly" that are then active when the caller puts calls on hold or if the AGI/AMI needs to play back MOH.   Without this patch all combinations of music files and all MOH classes would have to be defined in the configuration file or database before Asterisk is started.  In theory you could modify configuration "on the fly" however if I recall a reload of MOH kills other calls on hold or other nasty things happened.

While I understand the utility of such a feature to the average Asterisk user is pretty small, I have a strong desire to make sure mods we make to open source systems are available to everyone.    If there are alterations that preserve the requirement of "on the fly" MOH classes that help make this feature more widely available we are open to making them.   However we have to have the ability to set MOH dynamically per call.





By: Vitezslav Novy (vnovy) 2014-04-22 06:00:16.509-0500

New patch which is more code review friendly, I hope, and also contains documentation changes.

By: Vitezslav Novy (vnovy) 2014-04-22 09:04:33.583-0500

Code review request #3471

By: Vitezslav Novy (vnovy) 2017-10-01 10:16:18.224-0500

Patch not accepted. Closing