Wireshark 4.7.0
The Wireshark network protocol analyzer
Loading...
Searching...
No Matches
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
20
21#ifdef __cplusplus
22extern "C" {
23#endif /* __cplusplus */
24
25typedef struct {
26 void (*register_codec_module)(void); /* routine to call to register a codec */
28
39WS_DLL_PUBLIC void codecs_register_plugin(const codecs_plugin *plug);
40
49WS_DLL_PUBLIC void codecs_init(void);
50
58WS_DLL_PUBLIC void codecs_cleanup(void);
59
68WS_DLL_PUBLIC void codec_get_compiled_version_info(GString *str);
69
70struct codec_handle;
71typedef struct codec_handle *codec_handle_t;
72
86typedef struct _codec_context_t {
87 unsigned sample_rate;
88 unsigned channels;
89 wmem_map_t *fmtp_map;
90 void *priv;
92
93/*****************************************************************************/
94/* Interface which must be implemented by a codec */
95/* Codec decodes bytes to samples. Sample is 2 bytes! Codec writer must
96 * be careful when API refers bytes and when samples and its counts.
97 */
98/*****************************************************************************/
99
108typedef void *(*codec_init_fn)(codec_context_t *context);
109
115typedef void (*codec_release_fn)(codec_context_t *context);
116
123typedef unsigned (*codec_get_channels_fn)(codec_context_t *context);
124
131typedef unsigned (*codec_get_frequency_fn)(codec_context_t *context);
132
155typedef size_t (*codec_decode_fn)(codec_context_t *context,
156 const void *inputBytes, size_t inputBytesSize,
157 void *outputSamples, size_t *outputSamplesSize);
158
159/*****************************************************************************/
160/* Codec registering interface */
161/*****************************************************************************/
162
177WS_DLL_PUBLIC bool register_codec(const char *name, codec_init_fn init_fn,
178 codec_release_fn release_fn, codec_get_channels_fn channels_fn,
179 codec_get_frequency_fn frequency_fn, codec_decode_fn decode_fn);
180
189WS_DLL_PUBLIC bool deregister_codec(const char *name);
190
199WS_DLL_PUBLIC codec_handle_t find_codec(const char *name);
200
210WS_DLL_PUBLIC void *codec_init(codec_handle_t codec, codec_context_t *context);
211
220WS_DLL_PUBLIC void codec_release(codec_handle_t codec, codec_context_t *context);
221
231WS_DLL_PUBLIC unsigned codec_get_channels(codec_handle_t codec, codec_context_t *context);
232
242WS_DLL_PUBLIC unsigned codec_get_frequency(codec_handle_t codec, codec_context_t *context);
243
259WS_DLL_PUBLIC size_t codec_decode(codec_handle_t codec, codec_context_t *context,
260 const void *inputBytes, size_t inputBytesSize,
261 void *outputSamples, size_t *outputSamplesSize);
262
263#ifdef __cplusplus
264}
265#endif /* __cplusplus */
266
267#endif /* _CODECS_H_ */
268
269/*
270 * Editor modelines - https://www.wireshark.org/tools/modelines.html
271 *
272 * Local variables:
273 * c-basic-offset: 4
274 * tab-width: 8
275 * indent-tabs-mode: nil
276 * End:
277 *
278 * vi: set shiftwidth=4 tabstop=8 expandtab:
279 * :indentSize=4:tabSize=8:noTabs=true:
280 */
WS_DLL_PUBLIC size_t codec_decode(codec_handle_t codec, codec_context_t *context, const void *inputBytes, size_t inputBytesSize, void *outputSamples, size_t *outputSamplesSize)
Decode input bytes into audio samples.
Definition codecs.c:177
WS_DLL_PUBLIC void codecs_init(void)
Initialize all built-in and plugin-based codecs.
Definition codecs.c:55
void(* codec_release_fn)(codec_context_t *context)
Destroy context of codec.
Definition codecs.h:115
WS_DLL_PUBLIC bool register_codec(const char *name, codec_init_fn init_fn, codec_release_fn release_fn, codec_get_channels_fn channels_fn, codec_get_frequency_fn frequency_fn, codec_decode_fn decode_fn)
Register a new codec implementation.
Definition codecs.c:104
WS_DLL_PUBLIC void codecs_cleanup(void)
Clean up all registered codecs.
Definition codecs.c:64
WS_DLL_PUBLIC unsigned codec_get_channels(codec_handle_t codec, codec_context_t *context)
Query the number of audio channels for a codec.
Definition codecs.c:165
WS_DLL_PUBLIC unsigned codec_get_frequency(codec_handle_t codec, codec_context_t *context)
Query the sample rate for a codec.
Definition codecs.c:171
WS_DLL_PUBLIC codec_handle_t find_codec(const char *name)
Find a registered codec by name.
Definition codecs.c:92
size_t(* codec_decode_fn)(codec_context_t *context, const void *inputBytes, size_t inputBytesSize, void *outputSamples, size_t *outputSamplesSize)
Decode one frame of payload.
Definition codecs.h:155
unsigned(* codec_get_frequency_fn)(codec_context_t *context)
Get frequency/rate provided by the codec.
Definition codecs.h:131
WS_DLL_PUBLIC void codecs_register_plugin(const codecs_plugin *plug)
Register a codec plugin with the system.
void *(* codec_init_fn)(codec_context_t *context)
Initialize context of codec. Context can contain any information required by codec to pass between ca...
Definition codecs.h:108
unsigned(* codec_get_channels_fn)(codec_context_t *context)
Get count of channels provided by the codec.
Definition codecs.h:123
WS_DLL_PUBLIC void codec_get_compiled_version_info(GString *str)
Retrieve compile-time version information for codec-related libraries.
WS_DLL_PUBLIC void * codec_init(codec_handle_t codec, codec_context_t *context)
Initialize codec-specific state.
Definition codecs.c:153
WS_DLL_PUBLIC bool deregister_codec(const char *name)
Deregister a previously registered codec.
Definition codecs.c:141
WS_DLL_PUBLIC void codec_release(codec_handle_t codec, codec_context_t *context)
Release codec-specific resources.
Definition codecs.c:159
Definition codecs.h:86
Definition wmem_map.c:60
Context structure for audio codec configuration and state.
Definition codecs.c:75
Definition codecs.h:25