2 * Asterisk -- An open source telephony toolkit.
4 * Copyright (C) 2013, Digium, Inc.
6 * Jonathan Rose <jrose@digium.com>
8 * See http://www.asterisk.org for more information about
9 * the Asterisk project. Please do not directly contact
10 * any of the maintainers of this project for assistance;
11 * the project provides a web site, mailing lists and IRC
12 * channels for your use.
14 * This program is free software, distributed under the terms of
15 * the GNU General Public License Version 2. See the LICENSE file
16 * at the top of the source tree.
21 * \brief loadable MixMonitor functionality
23 * \author Jonathan Rose <jrose@digium.com>
27 <support_level>core</support_level>
32 ASTERISK_FILE_VERSION(__FILE__, "$Revision: 390830 $")
34 #include "asterisk/lock.h"
35 #include "asterisk/logger.h"
36 #include "asterisk/mixmonitor.h"
37 #include "asterisk/utils.h"
38 #include "asterisk/channel.h"
40 AST_RWLOCK_DEFINE_STATIC(mixmonitor_lock);
42 static struct ast_mixmonitor_methods mixmonitor_methods;
43 static int table_loaded = 0;
45 int ast_set_mixmonitor_methods(struct ast_mixmonitor_methods *method_table)
47 SCOPED_WRLOCK(lock, &mixmonitor_lock);
50 /* If mixmonitor methods have already been provided, reject the new set */
51 ast_log(LOG_ERROR, "Tried to set mixmonitor methods, but something else has already provided them.\n");
55 mixmonitor_methods = *method_table;
61 int ast_clear_mixmonitor_methods(void)
63 SCOPED_WRLOCK(lock, &mixmonitor_lock);
66 ast_log(LOG_ERROR, "Tried to clear mixmonitor methods, but none are currently loaded.\n");
70 memset(&mixmonitor_methods, 0, sizeof(mixmonitor_methods));
76 int ast_start_mixmonitor(struct ast_channel *chan, const char *filename, const char *options)
78 SCOPED_RDLOCK(lock, &mixmonitor_lock);
80 if (!mixmonitor_methods.start) {
81 ast_log(LOG_ERROR, "No loaded module currently provides MixMonitor starting functionality.\n");
85 return mixmonitor_methods.start(chan, filename, options);
88 int ast_stop_mixmonitor(struct ast_channel *chan, const char *mixmon_id)
90 SCOPED_RDLOCK(lock, &mixmonitor_lock);
92 if (!mixmonitor_methods.stop) {
93 ast_log(LOG_ERROR, "No loaded module currently provides MixMonitor stopping functionality.\n");
97 return mixmonitor_methods.stop(chan, mixmon_id);