diff options
Diffstat (limited to 'codecs')
-rw-r--r-- | codecs/Makefile.am | 41 | ||||
-rw-r--r-- | codecs/Makefile.common | 41 | ||||
-rw-r--r-- | codecs/Makefile.nmake | 27 | ||||
-rw-r--r-- | codecs/codecs.c | 73 | ||||
-rw-r--r-- | codecs/codecs.h | 20 |
5 files changed, 167 insertions, 35 deletions
diff --git a/codecs/Makefile.am b/codecs/Makefile.am index 73f9612864..1ce407f129 100644 --- a/codecs/Makefile.am +++ b/codecs/Makefile.am @@ -1,10 +1,10 @@ # Makefile.am -# Automake file for the codecs for Wireshark +# Automake file for the libcodec library for Wireshark # # $Id$ # # Wireshark - Network traffic analyzer -# By Gerald Combs <gerald@xxxxxxxxxxxxx> +# By Gerald Combs <gerald@wireshark.org> # Copyright 1998 Gerald Combs # # This program is free software; you can redistribute it and/or @@ -21,6 +21,9 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +include Makefile.common +include ../Makefile.am.inc + if HAVE_WARNINGS_AS_ERRORS AM_CFLAGS = -Werror endif @@ -28,31 +31,27 @@ endif noinst_LIBRARIES = libcodec.a CLEANFILES = \ - libcodec.a \ - *~ + libcodec.a \ + *~ MAINTAINERCLEANFILES = \ - Makefile.in + Makefile.in +# All sources that should be put in the source distribution tarball libcodec_a_SOURCES = \ - codecs.c codecs.h \ - G711a/G711adecode.c G711a/G711adecode.h G711a/G711atable.h \ - G711u/G711udecode.c G711u/G711udecode.h G711u/G711utable.h \ - G722/G722decode.c G722/G722decode.h \ - G726/G726decode.c G726/G726decode.h \ - sbc/sbc.c sbc/sbc.h + $(LIBCODEC_SRC) \ + $(noinst_HEADERS) libcodec_a_DEPENDENCIES = -EXTRA_DIST = \ - Makefile.nmake \ - CMakeLists.txt +# Common headers +AM_CPPFLAGS = -I$(top_srcdir) -I$(top_srcdir)/wiretap -checkapi: +checkapi: $(PERL) ../tools/checkAPIs.pl -g abort -g termoutput -build \ - codecs.c \ - G711a/G711adecode.c \ - G711u/G711udecode.c \ - G722/G722decode.c \ - G726/G726decode.c \ - sbc/sbc.c + $(LIBCODEC_SRC) + +EXTRA_DIST = \ + CMakeLists.txt \ + Makefile.common \ + Makefile.nmake diff --git a/codecs/Makefile.common b/codecs/Makefile.common new file mode 100644 index 0000000000..42009472c0 --- /dev/null +++ b/codecs/Makefile.common @@ -0,0 +1,41 @@ +# Makefile.common +# Contains the stuff from Makefile.am and Makefile.nmake that is +# a) common to both files and +# b) portable between both files +# +# $Id$ +# +# Wireshark - Network traffic analyzer +# By Gerald Combs <gerald@wireshark.org> +# Copyright 1998 Gerald Combs +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + +LIBCODEC_SRC = \ + codecs.c \ + G711a/G711adecode.c \ + G711u/G711udecode.c \ + G722/G722decode.c \ + G726/G726decode.c \ + sbc/sbc.c + +noinst_HEADERS = \ + codecs.h \ + G711a/G711adecode.h G711a/G711atable.h \ + G711u/G711udecode.h G711u/G711utable.h \ + G722/G722decode.h \ + G726/G726decode.h \ + sbc/sbc.h + diff --git a/codecs/Makefile.nmake b/codecs/Makefile.nmake index 821cd5c00a..d2cbc4e35e 100644 --- a/codecs/Makefile.nmake +++ b/codecs/Makefile.nmake @@ -4,6 +4,7 @@ # $Id$ include ..\config.nmake +include ..\Makefile.nmake.inc ############### no need to modify below this line ######### @@ -11,9 +12,16 @@ CFLAGS=/I.. $(WARNINGS_ARE_ERRORS) $(STANDARD_CFLAGS) \ $(GLIB_CFLAGS) .c.obj:: - $(CC) $(CFLAGS) -Fd.\ -c $< + $(CC) $(CFLAGS) -Fd.\ -c $< -CODEC_OBJECTS= \ +include Makefile.common + +# if you add files here, be sure to include them also in Makefile.am EXTRA_DIST +# XXX - if the codec files weren't in subdirectories, we could just do +# LIBCODEC_OBJECTS = $(LIBCODEC_SRC:.c=.obj), and wouldn't need rules +# for each of the codecs below +# +LIBCODEC_OBJECTS= \ codecs.obj \ G711udecode.obj \ G711adecode.obj \ @@ -21,10 +29,8 @@ CODEC_OBJECTS= \ G726decode.obj \ sbc.obj - -codecs.lib : $(CODEC_OBJECTS) - link /lib /out:codecs.lib $(CODEC_OBJECTS) - +codecs.lib : $(LIBCODEC_OBJECTS) + link /lib /out:codecs.lib $(LIBCODEC_OBJECTS) codecs.obj: codecs.c codecs.h $(CC) $(CFLAGS) -Fd.\ -c codecs.c /Fo%|fF.obj @@ -45,7 +51,7 @@ sbc.obj: sbc\sbc.c sbc\sbc.h $(CC) $(CFLAGS) -Fd.\ -c sbc\sbc.c /Fo%|fF.obj clean: - rm -f $(CODEC_OBJECTS) codecs.lib *.pdb *.sbr + rm -f $(LIBCODEC_OBJECTS) codecs.lib *.pdb *.sbr distclean: clean @@ -53,9 +59,4 @@ maintainer-clean: distclean checkapi: $(PERL) ../tools/checkAPIs.pl -g abort -g termoutput -build \ - codecs.c \ - G711a/G711adecode.c \ - G711u/G711udecode.c \ - G722/G722decode.c \ - G726/G726decode.c \ - sbc/sbc.c + $(LIBCODEC_SRC) diff --git a/codecs/codecs.c b/codecs/codecs.c index 0cb397f99b..abe3eaa714 100644 --- a/codecs/codecs.c +++ b/codecs/codecs.c @@ -22,9 +22,82 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ +#include "config.h" + #include <glib.h> #include "codecs.h" +#ifdef HAVE_PLUGINS + +#include <gmodule.h> + +#include <wsutil/plugins.h> + +/* + * List of codec plugins. + */ +typedef struct { + void (*register_codec_module)(void); /* routine to call to register a codec */ +} codec_plugin; + +static GSList *codec_plugins = NULL; + +/* + * Callback for each plugin found. + */ +static gboolean +check_for_codec_plugin(GModule *handle) +{ + gpointer gp; + void (*register_codec_module)(void); + codec_plugin *plugin; + + /* + * Do we have a register_codec_module routine? + */ + if (!g_module_symbol(handle, "register_codec_module", &gp)) { + /* No, so this isn't a codec plugin. */ + return FALSE; + } + + /* + * Yes - this plugin includes one or more codecs. + */ + register_codec_module = (void (*)(void))gp; + + /* + * Add this one to the list of codec plugins. + */ + plugin = (codec_plugin *)g_malloc(sizeof (codec_plugin)); + plugin->register_codec_module = register_codec_module; + codec_plugins = g_slist_append(codec_plugins, plugin); + return TRUE; +} + +void +codec_register_plugin_types(void) +{ + add_plugin_type("codec", check_for_codec_plugin); +} + +static void +register_codec_plugin(gpointer data, gpointer user_data _U_) +{ + codec_plugin *plugin = (codec_plugin *)data; + + (plugin->register_codec_module)(); +} + +/* + * For all codec plugins, call their register routines. + */ +void +register_all_codecs(void) +{ + g_slist_foreach(codec_plugins, register_codec_plugin, NULL); +} +#endif /* HAVE_PLUGINS */ + struct codec_handle { const char *name; codec_init_fn init_fn; diff --git a/codecs/codecs.h b/codecs/codecs.h index 9231fe8455..f293e26f2d 100644 --- a/codecs/codecs.h +++ b/codecs/codecs.h @@ -25,6 +25,20 @@ #ifndef _CODECS_H_ #define _CODECS_H_ +#include "config.h" + +#include <epan/epan.h> +#include "ws_symbol_export.h" + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +#ifdef HAVE_PLUGINS +extern void codec_register_plugin_types(void); +extern void register_all_codecs(void); +#endif + struct codec_handle; typedef struct codec_handle *codec_handle_t; @@ -38,4 +52,8 @@ extern void *codec_init(codec_handle_t codec); extern void codec_release(codec_handle_t codec, void *context); extern int codec_decode(codec_handle_t codec, void *context, const void *input, int inputSizeBytes, void *output, int *outputSizeBytes); -#endif +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* _CODECS_H_ */ |