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 "ws_symbol_export.h"
15 #include "ws_attributes.h"
16 
17 #include <stdbool.h>
18 
19 #include "wsutil/wmem/wmem_map.h"
20 
21 #ifdef __cplusplus
22 extern "C" {
23 #endif /* __cplusplus */
24 
25 typedef struct {
26  void (*register_codec_module)(void); /* routine to call to register a codec */
28 
29 WS_DLL_PUBLIC void codecs_register_plugin(const codecs_plugin *plug);
30 
34 WS_DLL_PUBLIC void codecs_init(void);
35 
36 WS_DLL_PUBLIC void codecs_cleanup(void);
37 
41 WS_DLL_PUBLIC void codec_get_compiled_version_info(GString *str);
42 
43 struct codec_handle;
44 typedef struct codec_handle *codec_handle_t;
45 
46 typedef struct _codec_context_t {
47  unsigned sample_rate;
48  unsigned channels;
49  wmem_map_t *fmtp_map;
50  void *priv; /* Private state set by the decoder */
52 
53 /*****************************************************************************/
54 /* Interface which must be implemented by a codec */
55 /* Codec decodes bytes to samples. Sample is 2 bytes! Codec writer must
56  * be careful when API refers bytes and when samples and its counts.
57  */
58 /*****************************************************************************/
59 
67 typedef void *(*codec_init_fn)(codec_context_t *context);
68 
73 typedef void (*codec_release_fn)(codec_context_t *context);
74 
81 typedef unsigned (*codec_get_channels_fn)(codec_context_t *context);
82 
89 typedef unsigned (*codec_get_frequency_fn)(codec_context_t *context);
90 
111 typedef size_t (*codec_decode_fn)(codec_context_t *context,
112  const void *inputBytes, size_t inputBytesSize,
113  void *outputSamples, size_t *outputSamplesSize);
114 
115 /*****************************************************************************/
116 /* Codec registering interface */
117 /*****************************************************************************/
118 
119 WS_DLL_PUBLIC bool register_codec(const char *name, codec_init_fn init_fn,
120  codec_release_fn release_fn, codec_get_channels_fn channels_fn,
121  codec_get_frequency_fn frequency_fn, codec_decode_fn decode_fn);
122 WS_DLL_PUBLIC bool deregister_codec(const char *name);
123 WS_DLL_PUBLIC codec_handle_t find_codec(const char *name);
124 WS_DLL_PUBLIC void *codec_init(codec_handle_t codec, codec_context_t *context);
125 WS_DLL_PUBLIC void codec_release(codec_handle_t codec, codec_context_t *context);
126 WS_DLL_PUBLIC unsigned codec_get_channels(codec_handle_t codec, codec_context_t *context);
127 WS_DLL_PUBLIC unsigned codec_get_frequency(codec_handle_t codec, codec_context_t *context);
128 WS_DLL_PUBLIC size_t codec_decode(codec_handle_t codec, codec_context_t *context,
129  const void *inputBytes, size_t inputBytesSize,
130  void *outputSamples, size_t *outputSamplesSize);
131 
132 #ifdef __cplusplus
133 }
134 #endif /* __cplusplus */
135 
136 #endif /* _CODECS_H_ */
137 
138 /*
139  * Editor modelines - https://www.wireshark.org/tools/modelines.html
140  *
141  * Local variables:
142  * c-basic-offset: 4
143  * tab-width: 8
144  * indent-tabs-mode: nil
145  * End:
146  *
147  * vi: set shiftwidth=4 tabstop=8 expandtab:
148  * :indentSize=4:tabSize=8:noTabs=true:
149  */
WS_DLL_PUBLIC void codecs_init(void)
Definition: codecs.c:55
void(* codec_release_fn)(codec_context_t *context)
Definition: codecs.h:73
size_t(* codec_decode_fn)(codec_context_t *context, const void *inputBytes, size_t inputBytesSize, void *outputSamples, size_t *outputSamplesSize)
Definition: codecs.h:111
unsigned(* codec_get_frequency_fn)(codec_context_t *context)
Definition: codecs.h:89
void *(* codec_init_fn)(codec_context_t *context)
Definition: codecs.h:67
unsigned(* codec_get_channels_fn)(codec_context_t *context)
Definition: codecs.h:81
WS_DLL_PUBLIC void codec_get_compiled_version_info(GString *str)
Definition: codecs.h:46
Definition: wmem_map.c:44
Definition: codecs.c:75
Definition: codecs.h:25