Asterisk - The Open Source Telephony Project GIT-master-f36a736
mixmonitor.c
Go to the documentation of this file.
1/*
2 * Asterisk -- An open source telephony toolkit.
3 *
4 * Copyright (C) 2013, Digium, Inc.
5 *
6 * Jonathan Rose <jrose@digium.com>
7 *
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.
13 *
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.
17 */
18
19/*! \file
20 *
21 * \brief loadable MixMonitor functionality
22 *
23 * \author Jonathan Rose <jrose@digium.com>
24 */
25
26/*** MODULEINFO
27 <support_level>core</support_level>
28 ***/
29
30#include "asterisk.h"
31
32#include "asterisk/lock.h"
33#include "asterisk/logger.h"
34#include "asterisk/mixmonitor.h"
35#include "asterisk/utils.h"
36#include "asterisk/channel.h"
37
39
41static int table_loaded = 0;
42
44{
46
47 if (table_loaded) {
48 /* If mixmonitor methods have already been provided, reject the new set */
49 ast_log(LOG_ERROR, "Tried to set mixmonitor methods, but something else has already provided them.\n");
50 return -1;
51 }
52
53 mixmonitor_methods = *method_table;
54
55 table_loaded = 1;
56 return 0;
57}
58
60{
62
63 if (!table_loaded) {
64 ast_log(LOG_ERROR, "Tried to clear mixmonitor methods, but none are currently loaded.\n");
65 return -1;
66 }
67
68 memset(&mixmonitor_methods, 0, sizeof(mixmonitor_methods));
69
70 table_loaded = 0;
71 return 0;
72}
73
74int ast_start_mixmonitor(struct ast_channel *chan, const char *filename, const char *options)
75{
77
79 ast_log(LOG_ERROR, "No loaded module currently provides MixMonitor starting functionality.\n");
80 return -1;
81 }
82
83 return mixmonitor_methods.start(chan, filename, options);
84}
85
86int ast_stop_mixmonitor(struct ast_channel *chan, const char *mixmon_id)
87{
89
91 ast_log(LOG_ERROR, "No loaded module currently provides MixMonitor stopping functionality.\n");
92 return -1;
93 }
94
95 return mixmonitor_methods.stop(chan, mixmon_id);
96}
ast_mutex_t lock
Definition: app_sla.c:331
Asterisk main include file. File version handling, generic pbx functions.
#define ast_log
Definition: astobj2.c:42
General Asterisk PBX channel definitions.
Support for logging to various files, console and syslog Configuration in file logger....
#define LOG_ERROR
Asterisk locking-related definitions:
#define AST_RWLOCK_DEFINE_STATIC(rwlock)
Definition: lock.h:543
#define SCOPED_WRLOCK(varname, lock)
scoped lock specialization for write locks
Definition: lock.h:599
#define SCOPED_RDLOCK(varname, lock)
scoped lock specialization for read locks
Definition: lock.h:594
int ast_set_mixmonitor_methods(struct ast_mixmonitor_methods *method_table)
Setup MixMonitor virtual methods table. Use this to provide the MixMonitor functionality from a loada...
Definition: mixmonitor.c:43
int ast_stop_mixmonitor(struct ast_channel *chan, const char *mixmon_id)
Stop a mixmonitor on a channel with the given parameters.
Definition: mixmonitor.c:86
static int table_loaded
Definition: mixmonitor.c:41
int ast_start_mixmonitor(struct ast_channel *chan, const char *filename, const char *options)
Start a mixmonitor on a channel with the given parameters.
Definition: mixmonitor.c:74
static ast_rwlock_t mixmonitor_lock
Definition: mixmonitor.c:38
int ast_clear_mixmonitor_methods(void)
Clear the MixMonitor virtual methods table. Use this to cleanup function pointers provided by a modul...
Definition: mixmonitor.c:59
static struct ast_mixmonitor_methods mixmonitor_methods
Definition: mixmonitor.c:40
loadable MixMonitor functionality
Main Channel structure associated with a channel.
MixMonitor virtual methods table definition.
Definition: mixmonitor.h:58
ast_mixmonitor_stop_fn stop
Definition: mixmonitor.h:60
ast_mixmonitor_start_fn start
Definition: mixmonitor.h:59
static struct test_options options
Utility functions.