| 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
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 */
27} codecs_plugin;
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
62 struct codec_handle;
63 typedef struct codec_handle *codec_handle_t;
64
78 typedef struct _codec_context_t {
79 unsigned sample_rate;
80 unsigned channels;
81 wmem_map_t *fmtp_map;
82 void *priv;
83} codec_context_t;
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
100 typedef void *(*codec_init_fn)(codec_context_t *context);
101
107 typedef void (*codec_release_fn)(codec_context_t *context);
108
115 typedef unsigned (*codec_get_channels_fn)(codec_context_t *context);
116
123 typedef unsigned (*codec_get_frequency_fn)(codec_context_t *context);
124
147 typedef 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 */
codec_decode
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
codec_release_fn
void(* codec_release_fn)(codec_context_t *context)
Destroy context of codec.
Definition codecs.h:107
register_codec
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
codecs_cleanup
WS_DLL_PUBLIC void codecs_cleanup(void)
Clean up all registered codecs.
Definition codecs.c:64
codec_get_channels
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
codec_get_frequency
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
find_codec
WS_DLL_PUBLIC codec_handle_t find_codec(const char *name)
Find a registered codec by name.
Definition codecs.c:92
codec_decode_fn
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
codecs_init
WS_DLL_PUBLIC void codecs_init(const char *app_env_var_prefix)
Initialize all built-in and plugin-based codecs.
codec_get_frequency_fn
unsigned(* codec_get_frequency_fn)(codec_context_t *context)
Get frequency/rate provided by the codec.
Definition codecs.h:123
codecs_register_plugin
WS_DLL_PUBLIC void codecs_register_plugin(const codecs_plugin *plug)
Register a codec plugin with the system.
codec_init_fn
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
codec_get_channels_fn
unsigned(* codec_get_channels_fn)(codec_context_t *context)
Get count of channels provided by the codec.
Definition codecs.h:115
codec_init
WS_DLL_PUBLIC void * codec_init(codec_handle_t codec, codec_context_t *context)
Initialize codec-specific state.
Definition codecs.c:153
deregister_codec
WS_DLL_PUBLIC bool deregister_codec(const char *name)
Deregister a previously registered codec.
Definition codecs.c:141
codec_release
WS_DLL_PUBLIC void codec_release(codec_handle_t codec, codec_context_t *context)
Release codec-specific resources.
Definition codecs.c:159
_codec_context_t
Definition codecs.h:78
_wmem_map_t
Definition wmem_map.c:60
codec_context_t
Context structure for audio codec configuration and state.
codec_handle
Definition codecs.c:75
codecs_plugin
Definition codecs.h:25
wmem_map.h