Asterisk - The Open Source Telephony Project  18.5.0
Data Structures | Typedefs | Functions
mixmonitor.h File Reference

loadable MixMonitor functionality More...

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  ast_mixmonitor_methods
 MixMonitor virtual methods table definition. More...
 

Typedefs

typedef int(* ast_mixmonitor_start_fn) (struct ast_channel *chan, const char *filename, const char *options)
 Start a mixmonitor on a channel. More...
 
typedef int(* ast_mixmonitor_stop_fn) (struct ast_channel *chan, const char *mixmon_id)
 Stop a mixmonitor on a channel. More...
 

Functions

int ast_clear_mixmonitor_methods (void)
 Clear the MixMonitor virtual methods table. Use this to cleanup function pointers provided by a module that set. More...
 
int ast_set_mixmonitor_methods (struct ast_mixmonitor_methods *vmethod_table)
 Setup MixMonitor virtual methods table. Use this to provide the MixMonitor functionality from a loadable module. More...
 
int ast_start_mixmonitor (struct ast_channel *chan, const char *filename, const char *options)
 Start a mixmonitor on a channel with the given parameters. More...
 
int ast_stop_mixmonitor (struct ast_channel *chan, const char *mixmon_id)
 Stop a mixmonitor on a channel with the given parameters. More...
 

Detailed Description

loadable MixMonitor functionality

Author
Jonathan Rose jrose.nosp@m.@dig.nosp@m.ium.c.nosp@m.om

Definition in file mixmonitor.h.

Typedef Documentation

◆ ast_mixmonitor_start_fn

typedef int(* ast_mixmonitor_start_fn) (struct ast_channel *chan, const char *filename, const char *options)

Start a mixmonitor on a channel.

Since
12.0.0
Parameters
chanWhich channel to put the MixMonitor on
filenameWhat the name of the file should be
optionsWhat options should be used for the mixmonitor
Return values
0on success
non-zeroon failure

Definition at line 40 of file mixmonitor.h.

◆ ast_mixmonitor_stop_fn

typedef int(* ast_mixmonitor_stop_fn) (struct ast_channel *chan, const char *mixmon_id)

Stop a mixmonitor on a channel.

Since
12.0.0
Parameters
chanWhich channel to stop a MixMonitor on
mixmon_idStop the MixMonitor with this mixmonid if it is on the channel (may be NULL)
Return values
0on success
non-zeroon failure

Definition at line 52 of file mixmonitor.h.

Function Documentation

◆ ast_clear_mixmonitor_methods()

int ast_clear_mixmonitor_methods ( void  )

Clear the MixMonitor virtual methods table. Use this to cleanup function pointers provided by a module that set.

Since
12.0.0
Return values
0if successful
non-zeroon failure (occurs when methods aren't loaded)

Definition at line 59 of file mixmonitor.c.

References ast_log, lock, LOG_ERROR, mixmonitor_lock, mixmonitor_methods, SCOPED_WRLOCK, and table_loaded.

Referenced by clear_mixmonitor_methods().

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 }
#define SCOPED_WRLOCK(varname, lock)
scoped lock specialization for write locks
Definition: lock.h:597
static ast_rwlock_t mixmonitor_lock
Definition: mixmonitor.c:38
#define ast_log
Definition: astobj2.c:42
ast_mutex_t lock
Definition: app_meetme.c:1091
#define LOG_ERROR
Definition: logger.h:285
static struct ast_mixmonitor_methods mixmonitor_methods
Definition: mixmonitor.c:40
static int table_loaded
Definition: mixmonitor.c:41

◆ ast_set_mixmonitor_methods()

int ast_set_mixmonitor_methods ( struct ast_mixmonitor_methods vmethod_table)

Setup MixMonitor virtual methods table. Use this to provide the MixMonitor functionality from a loadable module.

Since
12.0.0
Parameters
vmethod_tablepointer to vmethod table providing mixmonitor functions
Return values
0if successful
non-zeroon failure

Definition at line 43 of file mixmonitor.c.

References ast_log, lock, LOG_ERROR, mixmonitor_lock, mixmonitor_methods, SCOPED_WRLOCK, and table_loaded.

Referenced by set_mixmonitor_methods().

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 }
#define SCOPED_WRLOCK(varname, lock)
scoped lock specialization for write locks
Definition: lock.h:597
static ast_rwlock_t mixmonitor_lock
Definition: mixmonitor.c:38
#define ast_log
Definition: astobj2.c:42
ast_mutex_t lock
Definition: app_meetme.c:1091
#define LOG_ERROR
Definition: logger.h:285
static struct ast_mixmonitor_methods mixmonitor_methods
Definition: mixmonitor.c:40
static int table_loaded
Definition: mixmonitor.c:41

◆ ast_start_mixmonitor()

int ast_start_mixmonitor ( struct ast_channel chan,
const char *  filename,
const char *  options 
)

Start a mixmonitor on a channel with the given parameters.

Since
12.0.0
Parameters
chanWhich channel to apply the MixMonitor to
filenamefilename to use for the recording
optionsOptional arguments to be interpreted by the MixMonitor start function
Return values
0if successful
non-zeroon failure
Note
This function will always fail is nothing has set the mixmonitor methods

Definition at line 74 of file mixmonitor.c.

References ast_log, lock, LOG_ERROR, mixmonitor_lock, mixmonitor_methods, SCOPED_RDLOCK, and ast_mixmonitor_methods::start.

Referenced by setup_mixmonitor(), and start_automixmonitor().

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 }
static ast_rwlock_t mixmonitor_lock
Definition: mixmonitor.c:38
#define SCOPED_RDLOCK(varname, lock)
scoped lock specialization for read locks
Definition: lock.h:592
#define ast_log
Definition: astobj2.c:42
ast_mutex_t lock
Definition: app_meetme.c:1091
#define LOG_ERROR
Definition: logger.h:285
static struct ast_mixmonitor_methods mixmonitor_methods
Definition: mixmonitor.c:40
static struct test_options options
ast_mixmonitor_start_fn start
Definition: mixmonitor.h:59

◆ ast_stop_mixmonitor()

int ast_stop_mixmonitor ( struct ast_channel chan,
const char *  mixmon_id 
)

Stop a mixmonitor on a channel with the given parameters.

Since
12.0.0
Parameters
chanWhich channel to stop a MixMonitor on (may be NULL if mixmon_id is provided)
mixmon_idWhich mixmon_id should be stopped (may be NULL if chan is provided)
Return values
0if successful
non-zeroon failure

Definition at line 86 of file mixmonitor.c.

References ast_log, lock, LOG_ERROR, mixmonitor_lock, mixmonitor_methods, SCOPED_RDLOCK, and ast_mixmonitor_methods::stop.

Referenced by stop_automixmonitor().

87 {
89 
90  if (!mixmonitor_methods.stop) {
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 }
static ast_rwlock_t mixmonitor_lock
Definition: mixmonitor.c:38
#define SCOPED_RDLOCK(varname, lock)
scoped lock specialization for read locks
Definition: lock.h:592
#define ast_log
Definition: astobj2.c:42
ast_mutex_t lock
Definition: app_meetme.c:1091
#define LOG_ERROR
Definition: logger.h:285
static struct ast_mixmonitor_methods mixmonitor_methods
Definition: mixmonitor.c:40
ast_mixmonitor_stop_fn stop
Definition: mixmonitor.h:60