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
51WS_DLL_PUBLIC void codecs_init(const char* app_env_var_prefix);
52
60WS_DLL_PUBLIC void codecs_cleanup(void);
61
70WS_DLL_PUBLIC void codec_get_compiled_version_info(GString *str);
71
72struct codec_handle;
73typedef struct codec_handle *codec_handle_t;
74
88typedef struct _codec_context_t {
89 unsigned sample_rate;
90 unsigned channels;
91 wmem_map_t *fmtp_map;
92 void *priv;
94
95/*****************************************************************************/
96/* Interface which must be implemented by a codec */
97/* Codec decodes bytes to samples. Sample is 2 bytes! Codec writer must
98 * be careful when API refers bytes and when samples and its counts.
99 */
100/*****************************************************************************/
101
110typedef void *(*codec_init_fn)(codec_context_t *context);
111
117typedef void (*codec_release_fn)(codec_context_t *context);
118
125typedef unsigned (*codec_get_channels_fn)(codec_context_t *context);
126
133typedef unsigned (*codec_get_frequency_fn)(codec_context_t *context);
134
157typedef size_t (*codec_decode_fn)(codec_context_t *context,
158 const void *inputBytes, size_t inputBytesSize,
159 void *outputSamples, size_t *outputSamplesSize);
160
161/*****************************************************************************/
162/* Codec registering interface */
163/*****************************************************************************/
164
179WS_DLL_PUBLIC bool register_codec(const char *name, codec_init_fn init_fn,
180 codec_release_fn release_fn, codec_get_channels_fn channels_fn,
181 codec_get_frequency_fn frequency_fn, codec_decode_fn decode_fn);
182
191WS_DLL_PUBLIC bool deregister_codec(const char *name);
192
201WS_DLL_PUBLIC codec_handle_t find_codec(const char *name);
202
212WS_DLL_PUBLIC void *codec_init(codec_handle_t codec, codec_context_t *context);
213
222WS_DLL_PUBLIC void codec_release(codec_handle_t codec, codec_context_t *context);
223
233WS_DLL_PUBLIC unsigned codec_get_channels(codec_handle_t codec, codec_context_t *context);
234
244WS_DLL_PUBLIC unsigned codec_get_frequency(codec_handle_t codec, codec_context_t *context);
245
261WS_DLL_PUBLIC size_t codec_decode(codec_handle_t codec, codec_context_t *context,
262 const void *inputBytes, size_t inputBytesSize,
263 void *outputSamples, size_t *outputSamplesSize);
264
265#ifdef __cplusplus
266}
267#endif /* __cplusplus */
268
269#endif /* _CODECS_H_ */
270
271/*
272 * Editor modelines - https://www.wireshark.org/tools/modelines.html
273 *
274 * Local variables:
275 * c-basic-offset: 4
276 * tab-width: 8
277 * indent-tabs-mode: nil
278 * End:
279 *
280 * vi: set shiftwidth=4 tabstop=8 expandtab:
281 * :indentSize=4:tabSize=8:noTabs=true:
282 */
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
void(* codec_release_fn)(codec_context_t *context)
Destroy context of codec.
Definition codecs.h:117
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:157
WS_DLL_PUBLIC void codecs_init(const char *app_env_var_prefix)
Initialize all built-in and plugin-based codecs.
unsigned(* codec_get_frequency_fn)(codec_context_t *context)
Get frequency/rate provided by the codec.
Definition codecs.h:133
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:110
unsigned(* codec_get_channels_fn)(codec_context_t *context)
Get count of channels provided by the codec.
Definition codecs.h:125
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:88
Definition wmem_map.c:60
Context structure for audio codec configuration and state.
Definition codecs.c:75
Definition codecs.h:25