more
[metze/wireshark/wip.git] / codecs / codecs.h
1 /* codecs.h
2  * codecs interface   2007 Tomas Kukosa
3  *
4  * Wireshark - Network traffic analyzer
5  * By Gerald Combs <gerald@wireshark.org>
6  * Copyright 1998 Gerald Combs
7  *
8  * SPDX-License-Identifier: GPL-2.0-or-later
9  */
10
11 #ifndef _CODECS_H_
12 #define _CODECS_H_
13
14 #include <epan/epan.h>
15 #include "ws_symbol_export.h"
16 #include "ws_attributes.h"
17 #ifdef HAVE_PLUGINS
18 #include "wsutil/plugins.h"
19 #endif
20
21 #ifdef __cplusplus
22 extern "C" {
23 #endif /* __cplusplus */
24
25 #ifdef HAVE_PLUGINS
26 typedef struct {
27     void (*register_codec_module)(void);  /* routine to call to register a codec */
28 } codecs_plugin;
29
30 WS_DLL_PUBLIC void codecs_register_plugin(const codecs_plugin *plug);
31 #endif
32
33 /**
34  * For all built-in codecs and codec plugins, call their register routines.
35  */
36 WS_DLL_PUBLIC void codecs_init(void);
37
38 WS_DLL_PUBLIC void codecs_cleanup(void);
39
40 /**
41  * Get compile-time information for libraries used by libwscodecs.
42  */
43 WS_DLL_PUBLIC void codec_get_compiled_version_info(GString *str);
44
45 struct codec_handle;
46 typedef struct codec_handle *codec_handle_t;
47
48 typedef void *(*codec_init_fn)(void);
49 typedef void (*codec_release_fn)(void *context);
50 typedef unsigned (*codec_get_channels_fn)(void *context);
51 typedef unsigned (*codec_get_frequency_fn)(void *context);
52 typedef size_t (*codec_decode_fn)(void *context, const void *input, size_t inputSizeBytes,
53         void *output, size_t *outputSizeBytes);
54
55 WS_DLL_PUBLIC gboolean register_codec(const char *name, codec_init_fn init_fn,
56         codec_release_fn release_fn, codec_get_channels_fn channels_fn,
57         codec_get_frequency_fn frequency_fn, codec_decode_fn decode_fn);
58 WS_DLL_PUBLIC gboolean deregister_codec(const char *name);
59 WS_DLL_PUBLIC codec_handle_t find_codec(const char *name);
60 WS_DLL_PUBLIC void *codec_init(codec_handle_t codec);
61 WS_DLL_PUBLIC void codec_release(codec_handle_t codec, void *context);
62 WS_DLL_PUBLIC unsigned codec_get_channels(codec_handle_t codec, void *context);
63 WS_DLL_PUBLIC unsigned codec_get_frequency(codec_handle_t codec, void *context);
64 WS_DLL_PUBLIC size_t codec_decode(codec_handle_t codec, void *context, const void *input,
65         size_t inputSizeBytes, void *output, size_t *outputSizeBytes);
66
67 #ifdef __cplusplus
68 }
69 #endif /* __cplusplus */
70
71 #endif /* _CODECS_H_ */
72
73 /*
74  * Editor modelines  -  http://www.wireshark.org/tools/modelines.html
75  *
76  * Local variables:
77  * c-basic-offset: 4
78  * tab-width: 8
79  * indent-tabs-mode: nil
80  * End:
81  *
82  * vi: set shiftwidth=4 tabstop=8 expandtab:
83  * :indentSize=4:tabSize=8:noTabs=true:
84  */