Wireshark  4.3.0
The Wireshark network protocol analyzer
codecs.h
Go to the documentation of this file.
1 
11 #ifndef _CODECS_H_
12 #define _CODECS_H_
13 
14 #include <wireshark.h>
15 
16 #ifdef __cplusplus
17 extern "C" {
18 #endif /* __cplusplus */
19 
20 /*
21  * IMPORTANT: This header is the public plugin API for codecs.
22  *
23  * When this API changes the API level must be bumped in ws_version.h.in.
24  * If the change is backward-compatible only the maximum (codec) API level is increased by one.
25  * If the change is backward-incompatible, meaning a plugin that does not use
26  * new functionaly may not compile anymore, both the maximum (codec) API level is increased by one
27  * and the minimum (codec) API level is bumped to the new maximum (codec) API level.
28  *
29  * API functionality above level one should be annotated with a comment indicating
30  * the API level required (when it was first introduced).
31  */
32 
33 typedef struct {
34  void (*register_codec_module)(void); /* routine to call to register a codec */
36 
37 WS_DLL_PUBLIC void codecs_register_plugin(const codecs_plugin *plug);
38 
39 typedef struct _codec_context_t {
40  unsigned sample_rate;
41  unsigned channels;
42  wmem_map_t *fmtp_map;
43  void *priv; /* Private state set by the decoder */
45 
46 /*****************************************************************************/
47 /* Interface which must be implemented by a codec */
48 /* Codec decodes bytes to samples. Sample is 2 bytes! Codec writer must
49  * be careful when API refers bytes and when samples and its counts.
50  */
51 /*****************************************************************************/
52 
60 typedef void *(*codec_init_fn)(codec_context_t *context);
61 
66 typedef void (*codec_release_fn)(codec_context_t *context);
67 
74 typedef unsigned (*codec_get_channels_fn)(codec_context_t *context);
75 
82 typedef unsigned (*codec_get_frequency_fn)(codec_context_t *context);
83 
104 typedef size_t (*codec_decode_fn)(codec_context_t *context,
105  const void *inputBytes, size_t inputBytesSize,
106  void *outputSamples, size_t *outputSamplesSize);
107 
108 /*****************************************************************************/
109 /* Codec registering interface */
110 /*****************************************************************************/
111 
112 WS_DLL_PUBLIC bool register_codec(const char *name, codec_init_fn init_fn,
113  codec_release_fn release_fn, codec_get_channels_fn channels_fn,
114  codec_get_frequency_fn frequency_fn, codec_decode_fn decode_fn);
115 
116 #ifdef __cplusplus
117 }
118 #endif /* __cplusplus */
119 
120 #endif /* _CODECS_H_ */
121 
122 /*
123  * Editor modelines - https://www.wireshark.org/tools/modelines.html
124  *
125  * Local variables:
126  * c-basic-offset: 4
127  * tab-width: 8
128  * indent-tabs-mode: nil
129  * End:
130  *
131  * vi: set shiftwidth=4 tabstop=8 expandtab:
132  * :indentSize=4:tabSize=8:noTabs=true:
133  */
void(* codec_release_fn)(codec_context_t *context)
Definition: codecs.h:66
size_t(* codec_decode_fn)(codec_context_t *context, const void *inputBytes, size_t inputBytesSize, void *outputSamples, size_t *outputSamplesSize)
Definition: codecs.h:104
unsigned(* codec_get_frequency_fn)(codec_context_t *context)
Definition: codecs.h:82
void *(* codec_init_fn)(codec_context_t *context)
Definition: codecs.h:60
unsigned(* codec_get_channels_fn)(codec_context_t *context)
Definition: codecs.h:74
Definition: codecs.h:39
Definition: wmem_map.c:44
Definition: codecs.h:33