mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-05 12:16:00 +00:00
Merged revisions 7740 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.2 ........ r7740 | kpfleming | 2006-01-03 11:24:56 -0600 (Tue, 03 Jan 2006) | 4 lines revert incorrect fix for bug #6048 from revision 7709 put in correct (simpler) fix add doxygen docs for channel spy 'state' values ........ git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@7741 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -211,9 +211,9 @@ static int start_spying(struct ast_channel *chan, struct ast_channel *spychan, s
|
|||||||
|
|
||||||
static void stop_spying(struct ast_channel *chan, struct ast_channel_spy *spy)
|
static void stop_spying(struct ast_channel *chan, struct ast_channel_spy *spy)
|
||||||
{
|
{
|
||||||
/* If our status has changed, then the channel we're spying on is gone....
|
/* If our status has changed to DONE, then the channel we're spying on is gone....
|
||||||
DON'T TOUCH IT!!! RUN AWAY!!! */
|
DON'T TOUCH IT!!! RUN AWAY!!! */
|
||||||
if (spy->status != CHANSPY_RUNNING)
|
if (spy->status == CHANSPY_DONE)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!chan)
|
if (!chan)
|
||||||
|
@@ -86,7 +86,6 @@ LOCAL_USER_DECL;
|
|||||||
static const char *mixmonitor_spy_type = "MixMonitor";
|
static const char *mixmonitor_spy_type = "MixMonitor";
|
||||||
|
|
||||||
struct mixmonitor {
|
struct mixmonitor {
|
||||||
AST_LIST_ENTRY(mixmonitor) list;
|
|
||||||
struct ast_channel *chan;
|
struct ast_channel *chan;
|
||||||
char *filename;
|
char *filename;
|
||||||
char *post_process;
|
char *post_process;
|
||||||
@@ -95,15 +94,12 @@ struct mixmonitor {
|
|||||||
int writevol;
|
int writevol;
|
||||||
};
|
};
|
||||||
|
|
||||||
AST_LIST_HEAD_STATIC(monitors, mixmonitor);
|
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
MUXFLAG_APPEND = (1 << 1),
|
MUXFLAG_APPEND = (1 << 1),
|
||||||
MUXFLAG_BRIDGED = (1 << 2),
|
MUXFLAG_BRIDGED = (1 << 2),
|
||||||
MUXFLAG_VOLUME = (1 << 3),
|
MUXFLAG_VOLUME = (1 << 3),
|
||||||
MUXFLAG_READVOLUME = (1 << 4),
|
MUXFLAG_READVOLUME = (1 << 4),
|
||||||
MUXFLAG_WRITEVOLUME = (1 << 5),
|
MUXFLAG_WRITEVOLUME = (1 << 5),
|
||||||
FLAG_STOP = (1 << 6),
|
|
||||||
} mixmonitor_flags;
|
} mixmonitor_flags;
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
@@ -123,9 +119,9 @@ AST_APP_OPTIONS(mixmonitor_opts, {
|
|||||||
|
|
||||||
static void stopmon(struct ast_channel *chan, struct ast_channel_spy *spy)
|
static void stopmon(struct ast_channel *chan, struct ast_channel_spy *spy)
|
||||||
{
|
{
|
||||||
/* If our status has changed, then the channel we're spying on is gone....
|
/* If our status has changed to DONE, then the channel we're spying on is gone....
|
||||||
DON'T TOUCH IT!!! RUN AWAY!!! */
|
DON'T TOUCH IT!!! RUN AWAY!!! */
|
||||||
if (spy->status != CHANSPY_RUNNING)
|
if (spy->status == CHANSPY_DONE)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!chan)
|
if (!chan)
|
||||||
@@ -168,10 +164,6 @@ static void *mixmonitor_thread(void *obj)
|
|||||||
|
|
||||||
STANDARD_INCREMENT_USECOUNT;
|
STANDARD_INCREMENT_USECOUNT;
|
||||||
|
|
||||||
AST_LIST_LOCK(&monitors);
|
|
||||||
AST_LIST_INSERT_HEAD(&monitors, mixmonitor, list);
|
|
||||||
AST_LIST_UNLOCK(&monitors);
|
|
||||||
|
|
||||||
name = ast_strdupa(mixmonitor->chan->name);
|
name = ast_strdupa(mixmonitor->chan->name);
|
||||||
|
|
||||||
oflags = O_CREAT|O_WRONLY;
|
oflags = O_CREAT|O_WRONLY;
|
||||||
@@ -226,7 +218,7 @@ static void *mixmonitor_thread(void *obj)
|
|||||||
|
|
||||||
ast_channel_spy_trigger_wait(&spy);
|
ast_channel_spy_trigger_wait(&spy);
|
||||||
|
|
||||||
if (ast_check_hangup(mixmonitor->chan) || spy.status != CHANSPY_RUNNING || ast_test_flag(mixmonitor, FLAG_STOP)) {
|
if (ast_check_hangup(mixmonitor->chan) || spy.status != CHANSPY_RUNNING) {
|
||||||
ast_mutex_unlock(&spy.lock);
|
ast_mutex_unlock(&spy.lock);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -252,8 +244,6 @@ static void *mixmonitor_thread(void *obj)
|
|||||||
ast_mutex_unlock(&spy.lock);
|
ast_mutex_unlock(&spy.lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
stopmon(mixmonitor->chan, &spy);
|
|
||||||
|
|
||||||
if (mixmonitor->post_process) {
|
if (mixmonitor->post_process) {
|
||||||
char *p;
|
char *p;
|
||||||
|
|
||||||
@@ -265,6 +255,8 @@ static void *mixmonitor_thread(void *obj)
|
|||||||
pbx_substitute_variables_helper(mixmonitor->chan, mixmonitor->post_process, post_process, sizeof(post_process) - 1);
|
pbx_substitute_variables_helper(mixmonitor->chan, mixmonitor->post_process, post_process, sizeof(post_process) - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
stopmon(mixmonitor->chan, &spy);
|
||||||
|
|
||||||
if (option_verbose > 1)
|
if (option_verbose > 1)
|
||||||
ast_verbose(VERBOSE_PREFIX_2 "End MixMonitor Recording %s\n", name);
|
ast_verbose(VERBOSE_PREFIX_2 "End MixMonitor Recording %s\n", name);
|
||||||
|
|
||||||
@@ -281,10 +273,6 @@ out2:
|
|||||||
ast_closestream(fs);
|
ast_closestream(fs);
|
||||||
|
|
||||||
out:
|
out:
|
||||||
AST_LIST_LOCK(&monitors);
|
|
||||||
AST_LIST_REMOVE(&monitors, mixmonitor, list);
|
|
||||||
AST_LIST_UNLOCK(&monitors);
|
|
||||||
|
|
||||||
free(mixmonitor);
|
free(mixmonitor);
|
||||||
|
|
||||||
STANDARD_DECREMENT_USECOUNT;
|
STANDARD_DECREMENT_USECOUNT;
|
||||||
@@ -415,7 +403,6 @@ static int mixmonitor_exec(struct ast_channel *chan, void *data)
|
|||||||
static int mixmonitor_cli(int fd, int argc, char **argv)
|
static int mixmonitor_cli(int fd, int argc, char **argv)
|
||||||
{
|
{
|
||||||
struct ast_channel *chan;
|
struct ast_channel *chan;
|
||||||
struct mixmonitor *mon;
|
|
||||||
|
|
||||||
if (argc < 3)
|
if (argc < 3)
|
||||||
return RESULT_SHOWUSAGE;
|
return RESULT_SHOWUSAGE;
|
||||||
@@ -427,13 +414,8 @@ static int mixmonitor_cli(int fd, int argc, char **argv)
|
|||||||
|
|
||||||
if (!strcasecmp(argv[1], "start"))
|
if (!strcasecmp(argv[1], "start"))
|
||||||
mixmonitor_exec(chan, argv[3]);
|
mixmonitor_exec(chan, argv[3]);
|
||||||
else if (!strcasecmp(argv[1], "stop")) {
|
else if (!strcasecmp(argv[1], "stop"))
|
||||||
AST_LIST_TRAVERSE_SAFE_BEGIN(&monitors, mon, list) {
|
ast_channel_spy_stop_by_type(chan, mixmonitor_spy_type);
|
||||||
if (chan == mon->chan)
|
|
||||||
ast_set_flag(mon, FLAG_STOP);
|
|
||||||
}
|
|
||||||
AST_LIST_TRAVERSE_SAFE_END;
|
|
||||||
}
|
|
||||||
|
|
||||||
ast_mutex_unlock(&chan->lock);
|
ast_mutex_unlock(&chan->lock);
|
||||||
|
|
||||||
|
@@ -996,7 +996,7 @@ void ast_channel_spy_stop_by_type(struct ast_channel *chan, const char *type)
|
|||||||
AST_LIST_TRAVERSE(&chan->spies->list, spy, list) {
|
AST_LIST_TRAVERSE(&chan->spies->list, spy, list) {
|
||||||
ast_mutex_lock(&spy->lock);
|
ast_mutex_lock(&spy->lock);
|
||||||
if ((spy->type == type) && (spy->status == CHANSPY_RUNNING)) {
|
if ((spy->type == type) && (spy->status == CHANSPY_RUNNING)) {
|
||||||
spy->status = CHANSPY_DONE;
|
spy->status = CHANSPY_STOP;
|
||||||
if (ast_test_flag(spy, CHANSPY_TRIGGER_MODE) != CHANSPY_TRIGGER_NONE)
|
if (ast_test_flag(spy, CHANSPY_TRIGGER_MODE) != CHANSPY_TRIGGER_NONE)
|
||||||
ast_cond_signal(&spy->trigger);
|
ast_cond_signal(&spy->trigger);
|
||||||
}
|
}
|
||||||
|
@@ -30,9 +30,10 @@ extern "C" {
|
|||||||
#include "asterisk/linkedlists.h"
|
#include "asterisk/linkedlists.h"
|
||||||
|
|
||||||
enum chanspy_states {
|
enum chanspy_states {
|
||||||
CHANSPY_NEW = 0,
|
CHANSPY_NEW = 0, /*!< spy not yet operating */
|
||||||
CHANSPY_RUNNING = 1,
|
CHANSPY_RUNNING = 1, /*!< normal operation, spy is still operating */
|
||||||
CHANSPY_DONE = 2,
|
CHANSPY_DONE = 2, /*!< spy is stopped and already removed from channel */
|
||||||
|
CHANSPY_STOP = 3, /*!< spy requested to stop, still attached to channel */
|
||||||
};
|
};
|
||||||
|
|
||||||
enum chanspy_flags {
|
enum chanspy_flags {
|
||||||
|
Reference in New Issue
Block a user