Asterisk - The Open Source Telephony Project  21.4.1
Functions | Variables
mixmonitor.c File Reference

loadable MixMonitor functionality More...

#include "asterisk.h"
#include "asterisk/lock.h"
#include "asterisk/logger.h"
#include "asterisk/mixmonitor.h"
#include "asterisk/utils.h"
#include "asterisk/channel.h"

Go to the source code of this file.

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 *method_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...
 

Variables

static ast_rwlock_t mixmonitor_lock = { PTHREAD_RWLOCK_INITIALIZER , NULL, {1, 0} }
 
static struct ast_mixmonitor_methods mixmonitor_methods
 
static int table_loaded = 0
 

Detailed Description

loadable MixMonitor functionality

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

Definition in file mixmonitor.c.

Function Documentation

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 lock, and SCOPED_WRLOCK.

60 {
61  SCOPED_WRLOCK(lock, &mixmonitor_lock);
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:599
ast_mutex_t lock
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 lock, and SCOPED_WRLOCK.

44 {
45  SCOPED_WRLOCK(lock, &mixmonitor_lock);
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:599
ast_mutex_t lock
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 lock, and SCOPED_RDLOCK.

75 {
76  SCOPED_RDLOCK(lock, &mixmonitor_lock);
77 
78  if (!mixmonitor_methods.start) {
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 }
#define SCOPED_RDLOCK(varname, lock)
scoped lock specialization for read locks
Definition: lock.h:594
ast_mutex_t lock
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 lock, and SCOPED_RDLOCK.

87 {
88  SCOPED_RDLOCK(lock, &mixmonitor_lock);
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 }
#define SCOPED_RDLOCK(varname, lock)
scoped lock specialization for read locks
Definition: lock.h:594
ast_mutex_t lock