forked from Mirrors/freeswitch
add event system
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@128 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
parent
611e80432e
commit
40824bc41a
|
@ -45,7 +45,8 @@ src/switch_console.c \
|
|||
src/switch_core.c \
|
||||
src/switch_loadable_module.c \
|
||||
src/switch_mutex.c \
|
||||
src/switch_utils.c
|
||||
src/switch_utils.c \
|
||||
src/switch_event.c
|
||||
|
||||
#bindir = $(PREFIX)/bin
|
||||
#libdir = $(PREFIX)/lib
|
||||
|
@ -62,7 +63,8 @@ library_include_HEADERS = src/include/switch.h \
|
|||
src/include/switch_types.h \
|
||||
src/include/switch_utils.h \
|
||||
src/include/switch_caller.h \
|
||||
src/include/switch_buffer.h
|
||||
src/include/switch_buffer.h \
|
||||
src/include/switch_event.h
|
||||
|
||||
lib_LTLIBRARIES = libfreeswitch.la
|
||||
libfreeswitch_la_CFLAGS = $(AM_CFLAGS) -Wall -Werror -Wstrict-prototypes -Wmissing-prototypes -g
|
||||
|
|
17
Makefile.in
17
Makefile.in
|
@ -75,7 +75,8 @@ am_libfreeswitch_la_OBJECTS = libfreeswitch_la-switch_buffer.lo \
|
|||
libfreeswitch_la-switch_core.lo \
|
||||
libfreeswitch_la-switch_loadable_module.lo \
|
||||
libfreeswitch_la-switch_mutex.lo \
|
||||
libfreeswitch_la-switch_utils.lo
|
||||
libfreeswitch_la-switch_utils.lo \
|
||||
libfreeswitch_la-switch_event.lo
|
||||
libfreeswitch_la_OBJECTS = $(am_libfreeswitch_la_OBJECTS)
|
||||
binPROGRAMS_INSTALL = $(INSTALL_PROGRAM)
|
||||
PROGRAMS = $(bin_PROGRAMS)
|
||||
|
@ -252,7 +253,8 @@ src/switch_console.c \
|
|||
src/switch_core.c \
|
||||
src/switch_loadable_module.c \
|
||||
src/switch_mutex.c \
|
||||
src/switch_utils.c
|
||||
src/switch_utils.c \
|
||||
src/switch_event.c
|
||||
|
||||
|
||||
#bindir = $(PREFIX)/bin
|
||||
|
@ -270,7 +272,8 @@ library_include_HEADERS = src/include/switch.h \
|
|||
src/include/switch_types.h \
|
||||
src/include/switch_utils.h \
|
||||
src/include/switch_caller.h \
|
||||
src/include/switch_buffer.h
|
||||
src/include/switch_buffer.h \
|
||||
src/include/switch_event.h
|
||||
|
||||
lib_LTLIBRARIES = libfreeswitch.la
|
||||
libfreeswitch_la_CFLAGS = $(AM_CFLAGS) -Wall -Werror -Wstrict-prototypes -Wmissing-prototypes -g
|
||||
|
@ -406,6 +409,7 @@ distclean-compile:
|
|||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libfreeswitch_la-switch_config.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libfreeswitch_la-switch_console.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libfreeswitch_la-switch_core.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libfreeswitch_la-switch_event.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libfreeswitch_la-switch_loadable_module.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libfreeswitch_la-switch_mutex.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libfreeswitch_la-switch_utils.Plo@am__quote@
|
||||
|
@ -494,6 +498,13 @@ libfreeswitch_la-switch_utils.lo: src/switch_utils.c
|
|||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
|
||||
@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libfreeswitch_la_CFLAGS) $(CFLAGS) -c -o libfreeswitch_la-switch_utils.lo `test -f 'src/switch_utils.c' || echo '$(srcdir)/'`src/switch_utils.c
|
||||
|
||||
libfreeswitch_la-switch_event.lo: src/switch_event.c
|
||||
@am__fastdepCC_TRUE@ if $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libfreeswitch_la_CFLAGS) $(CFLAGS) -MT libfreeswitch_la-switch_event.lo -MD -MP -MF "$(DEPDIR)/libfreeswitch_la-switch_event.Tpo" -c -o libfreeswitch_la-switch_event.lo `test -f 'src/switch_event.c' || echo '$(srcdir)/'`src/switch_event.c; \
|
||||
@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libfreeswitch_la-switch_event.Tpo" "$(DEPDIR)/libfreeswitch_la-switch_event.Plo"; else rm -f "$(DEPDIR)/libfreeswitch_la-switch_event.Tpo"; exit 1; fi
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='src/switch_event.c' object='libfreeswitch_la-switch_event.lo' libtool=yes @AMDEPBACKSLASH@
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
|
||||
@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libfreeswitch_la_CFLAGS) $(CFLAGS) -c -o libfreeswitch_la-switch_event.lo `test -f 'src/switch_event.c' || echo '$(srcdir)/'`src/switch_event.c
|
||||
|
||||
freeswitch-switch.o: src/switch.c
|
||||
@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(freeswitch_CFLAGS) $(CFLAGS) -MT freeswitch-switch.o -MD -MP -MF "$(DEPDIR)/freeswitch-switch.Tpo" -c -o freeswitch-switch.o `test -f 'src/switch.c' || echo '$(srcdir)/'`src/switch.c; \
|
||||
@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/freeswitch-switch.Tpo" "$(DEPDIR)/freeswitch-switch.Po"; else rm -f "$(DEPDIR)/freeswitch-switch.Tpo"; exit 1; fi
|
||||
|
|
|
@ -12,3 +12,4 @@ mod_rawaudio
|
|||
mod_iaxchan
|
||||
#mod_opalchan
|
||||
mod_codec_g729
|
||||
mod_event_test
|
||||
|
|
|
@ -1,7 +1,4 @@
|
|||
/* config.h.in. Generated from configure.in by autoheader. */
|
||||
|
||||
/* Define to 1 if you have the <arpa/inet.h> header file. */
|
||||
#undef HAVE_ARPA_INET_H
|
||||
/* src/include/config.h.in. Generated from configure.in by autoheader. */
|
||||
|
||||
/* Define to 1 if you have the <dirent.h> header file, and it defines `DIR'.
|
||||
*/
|
||||
|
@ -10,61 +7,28 @@
|
|||
/* Define to 1 if you have the <dlfcn.h> header file. */
|
||||
#undef HAVE_DLFCN_H
|
||||
|
||||
/* Define to 1 if you have the <fcntl.h> header file. */
|
||||
#undef HAVE_FCNTL_H
|
||||
|
||||
/* Define to 1 if you have the `gethostname' function. */
|
||||
#undef HAVE_GETHOSTNAME
|
||||
|
||||
/* Define to 1 if you have the `gettimeofday' function. */
|
||||
#undef HAVE_GETTIMEOFDAY
|
||||
|
||||
/* Define to 1 if you have the <inttypes.h> header file. */
|
||||
#undef HAVE_INTTYPES_H
|
||||
|
||||
/* Define to 1 if you have the `localtime_r' function. */
|
||||
#undef HAVE_LOCALTIME_R
|
||||
|
||||
/* Define to 1 if your system has a GNU libc compatible `malloc' function, and
|
||||
to 0 otherwise. */
|
||||
#undef HAVE_MALLOC
|
||||
|
||||
/* Define to 1 if you have the `memmove' function. */
|
||||
#undef HAVE_MEMMOVE
|
||||
|
||||
/* Define to 1 if you have the <memory.h> header file. */
|
||||
#undef HAVE_MEMORY_H
|
||||
|
||||
/* Define to 1 if you have the `memset' function. */
|
||||
#undef HAVE_MEMSET
|
||||
|
||||
/* Define to 1 if you have the <ndir.h> header file, and it defines `DIR'. */
|
||||
#undef HAVE_NDIR_H
|
||||
|
||||
/* Define to 1 if you have the <netdb.h> header file. */
|
||||
#undef HAVE_NETDB_H
|
||||
|
||||
/* Define to 1 if you have the <netinet/in.h> header file. */
|
||||
#undef HAVE_NETINET_IN_H
|
||||
|
||||
/* Define to 1 if you have the `socket' function. */
|
||||
#undef HAVE_SOCKET
|
||||
|
||||
/* Define to 1 if you have the <stdint.h> header file. */
|
||||
#undef HAVE_STDINT_H
|
||||
|
||||
/* Define to 1 if you have the <stdlib.h> header file. */
|
||||
#undef HAVE_STDLIB_H
|
||||
|
||||
/* Define to 1 if you have the `strcasecmp' function. */
|
||||
#undef HAVE_STRCASECMP
|
||||
|
||||
/* Define to 1 if you have the `strchr' function. */
|
||||
#undef HAVE_STRCHR
|
||||
|
||||
/* Define to 1 if you have the `strdup' function. */
|
||||
#undef HAVE_STRDUP
|
||||
|
||||
/* Define to 1 if you have the `strftime' function. */
|
||||
#undef HAVE_STRFTIME
|
||||
|
||||
|
@ -74,32 +38,17 @@
|
|||
/* Define to 1 if you have the <string.h> header file. */
|
||||
#undef HAVE_STRING_H
|
||||
|
||||
/* Define to 1 if you have the `strncasecmp' function. */
|
||||
#undef HAVE_STRNCASECMP
|
||||
|
||||
/* Define to 1 if you have the `strstr' function. */
|
||||
#undef HAVE_STRSTR
|
||||
|
||||
/* Define to 1 if you have the <sys/dir.h> header file, and it defines `DIR'.
|
||||
*/
|
||||
#undef HAVE_SYS_DIR_H
|
||||
|
||||
/* Define to 1 if you have the <sys/ioctl.h> header file. */
|
||||
#undef HAVE_SYS_IOCTL_H
|
||||
|
||||
/* Define to 1 if you have the <sys/ndir.h> header file, and it defines `DIR'.
|
||||
*/
|
||||
#undef HAVE_SYS_NDIR_H
|
||||
|
||||
/* Define to 1 if you have the <sys/socket.h> header file. */
|
||||
#undef HAVE_SYS_SOCKET_H
|
||||
|
||||
/* Define to 1 if you have the <sys/stat.h> header file. */
|
||||
#undef HAVE_SYS_STAT_H
|
||||
|
||||
/* Define to 1 if you have the <sys/time.h> header file. */
|
||||
#undef HAVE_SYS_TIME_H
|
||||
|
||||
/* Define to 1 if you have the <sys/types.h> header file. */
|
||||
#undef HAVE_SYS_TYPES_H
|
||||
|
||||
|
|
|
@ -116,7 +116,7 @@ extern "C" {
|
|||
#include <switch_module_interfaces.h>
|
||||
#include <switch_channel.h>
|
||||
#include <switch_buffer.h>
|
||||
|
||||
#include <switch_event.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -119,6 +119,7 @@ SWITCH_DECLARE(switch_status) switch_core_session_set_read_codec(switch_core_ses
|
|||
SWITCH_DECLARE(switch_status) switch_core_session_set_write_codec(switch_core_session *session, switch_codec *codec);
|
||||
SWITCH_DECLARE(switch_memory_pool *) switch_core_session_get_pool(switch_core_session *session);
|
||||
SWITCH_DECLARE(void) pbx_core_session_signal_state_change(switch_core_session *session);
|
||||
SWITCH_DECLARE(char *) switch_core_strdup(switch_memory_pool *pool, char *todup);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -122,6 +122,21 @@ typedef enum {
|
|||
SWITCH_IO_FLAG_NOOP = 0,
|
||||
} switch_io_flag;
|
||||
|
||||
/* make sure this is synced with the EVENT_NAMES array in switch_event.c
|
||||
also never put any new ones before EVENT_ALL
|
||||
*/
|
||||
typedef enum {
|
||||
SWITCH_EVENT_CUSTOM,
|
||||
SWITCH_EVENT_INBOUND_CHAN,
|
||||
SWITCH_EVENT_OUTBOUND_CHAN,
|
||||
SWITCH_EVENT_ANSWER_CHAN,
|
||||
SWITCH_EVENT_HANGUP_CHAN,
|
||||
SWITCH_EVENT_STARTUP,
|
||||
SWITCH_EVENT_ALL
|
||||
} switch_event_t;
|
||||
|
||||
typedef struct switch_event_node switch_event_node;
|
||||
typedef void (*switch_event_callback_t)(switch_event_t, int, char *);
|
||||
typedef struct switch_loadable_module switch_loadable_module;
|
||||
typedef struct switch_frame switch_frame;
|
||||
typedef struct switch_channel switch_channel;
|
||||
|
|
|
@ -51,6 +51,7 @@ int main(int argc, char *argv[]) {
|
|||
exit(-1);
|
||||
}
|
||||
|
||||
switch_event_fire(SWITCH_EVENT_STARTUP, "Ready");
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "freeswitch Version %s Started\n\n", SWITCH_GLOBAL_VERSION);
|
||||
|
||||
/* wait for console input */
|
||||
|
|
|
@ -422,6 +422,20 @@ SWITCH_DECLARE(char *) switch_core_session_strdup(switch_core_session *session,
|
|||
return duped;
|
||||
}
|
||||
|
||||
|
||||
SWITCH_DECLARE(char *) switch_core_strdup(switch_memory_pool *pool, char *todup)
|
||||
{
|
||||
char *duped = NULL;
|
||||
|
||||
assert(pool != NULL);
|
||||
assert(todup != NULL);
|
||||
|
||||
if (todup && (duped = apr_palloc(pool, strlen(todup)+1))) {
|
||||
strcpy(duped, todup);
|
||||
}
|
||||
return duped;
|
||||
}
|
||||
|
||||
SWITCH_DECLARE(void *) switch_core_session_get_private(switch_core_session *session)
|
||||
{
|
||||
assert(session != NULL);
|
||||
|
@ -1500,6 +1514,7 @@ SWITCH_DECLARE(switch_status) switch_core_init(void)
|
|||
return SWITCH_STATUS_MEMERR;
|
||||
}
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Allocated memory pool.\n");
|
||||
switch_event_init(runtime.memory_pool);
|
||||
|
||||
#ifdef EMBED_PERL
|
||||
if (! (my_perl = perl_alloc())) {
|
||||
|
|
Loading…
Reference in New Issue