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
62struct codec_handle;
63typedef struct codec_handle *codec_handle_t;
64
78typedef struct _codec_context_t {
79 unsigned sample_rate;
80 unsigned channels;
81 wmem_map_t *fmtp_map;
82 void *priv;
84
85/*****************************************************************************/
86/* Interface which must be implemented by a codec */
87/* Codec decodes bytes to samples. Sample is 2 bytes! Codec writer must
88 * be careful when API refers bytes and when samples and its counts.
89 */
90/*****************************************************************************/
91
100typedef void *(*codec_init_fn)(codec_context_t *context);
101
107typedef void (*codec_release_fn)(codec_context_t *context);
108
115typedef unsigned (*codec_get_channels_fn)(codec_context_t *context);
116
123typedef unsigned (*codec_get_frequency_fn)(codec_context_t *context);
124
147typedef size_t (*codec_decode_fn)(codec_context_t *context,
148 const void *inputBytes, size_t inputBytesSize,
149 void *outputSamples, size_t *outputSamplesSize);
150
151/*****************************************************************************/
152/* Codec registering interface */
153/*****************************************************************************/
154
169WS_DLL_PUBLIC bool register_codec(const char *name, codec_init_fn init_fn,
170 codec_release_fn release_fn, codec_get_channels_fn channels_fn,
171 codec_get_frequency_fn frequency_fn, codec_decode_fn decode_fn);
172
181WS_DLL_PUBLIC bool deregister_codec(const char *name);
182
191WS_DLL_PUBLIC codec_handle_t find_codec(const char *name);
192
202WS_DLL_PUBLIC void *codec_init(codec_handle_t codec, codec_context_t *context);
203
212WS_DLL_PUBLIC void codec_release(codec_handle_t codec, codec_context_t *context);
213
223WS_DLL_PUBLIC unsigned codec_get_channels(codec_handle_t codec, codec_context_t *context);
224
234WS_DLL_PUBLIC unsigned codec_get_frequency(codec_handle_t codec, codec_context_t *context);
235
251WS_DLL_PUBLIC size_t codec_decode(codec_handle_t codec, codec_context_t *context,
252 const void *inputBytes, size_t inputBytesSize,
253 void *outputSamples, size_t *outputSamplesSize);
254
255#ifdef __cplusplus
256}
257#endif /* __cplusplus */
258
259#endif /* _CODECS_H_ */
260
261/*
262 * Editor modelines - https://www.wireshark.org/tools/modelines.html
263 *
264 * Local variables:
265 * c-basic-offset: 4
266 * tab-width: 8
267 * indent-tabs-mode: nil
268 * End:
269 *
270 * vi: set shiftwidth=4 tabstop=8 expandtab:
271 * :indentSize=4:tabSize=8:noTabs=true:
272 */
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:107
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:147
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:123
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:100
unsigned(* codec_get_channels_fn)(codec_context_t *context)
Get count of channels provided by the codec.
Definition codecs.h:115
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:78
Definition wmem_map.c:60
Context structure for audio codec configuration and state.
Definition codecs.c:75
Definition codecs.h:25