| Wireshark 4.7.3 The Wireshark network protocol analyzer

Loading...
Searching...
No Matches
codecs.h
Go to the documentation of this file.
1
10
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
28 typedef struct {
29 void (*register_codec_module)(void);
30} codecs_plugin;
31
42WS_DLL_PUBLIC void codecs_register_plugin(const codecs_plugin *plug);
43
54WS_DLL_PUBLIC void codecs_init(const char* app_env_var_prefix);
55
63WS_DLL_PUBLIC void codecs_cleanup(void);
64
65 struct codec_handle;
66 typedef struct codec_handle *codec_handle_t;
67
75 typedef struct _codec_context_t {
76 unsigned sample_rate;
77 unsigned channels;
78 wmem_map_t *fmtp_map;
79 void *priv;
80} codec_context_t;
81
82/*****************************************************************************/
83/* Interface which must be implemented by a codec */
84/* Codec decodes bytes to samples. Sample is 2 bytes! Codec writer must
85 * be careful when API refers bytes and when samples and its counts.
86 */
87/*****************************************************************************/
88
97 typedef void *(*codec_init_fn)(codec_context_t *context);
98
104 typedef void (*codec_release_fn)(codec_context_t *context);
105
112 typedef unsigned (*codec_get_channels_fn)(codec_context_t *context);
113
120 typedef unsigned (*codec_get_frequency_fn)(codec_context_t *context);
121
144 typedef size_t (*codec_decode_fn)(codec_context_t *context,
145 const void *inputBytes, size_t inputBytesSize,
146 void *outputSamples, size_t *outputSamplesSize);
147
148/*****************************************************************************/
149/* Codec registering interface */
150/*****************************************************************************/
151
166WS_DLL_PUBLIC bool register_codec(const char *name, codec_init_fn init_fn,
167 codec_release_fn release_fn, codec_get_channels_fn channels_fn,
168 codec_get_frequency_fn frequency_fn, codec_decode_fn decode_fn);
169
178WS_DLL_PUBLIC bool deregister_codec(const char *name);
179
188WS_DLL_PUBLIC codec_handle_t find_codec(const char *name);
189
199WS_DLL_PUBLIC void *codec_init(codec_handle_t codec, codec_context_t *context);
200
209WS_DLL_PUBLIC void codec_release(codec_handle_t codec, codec_context_t *context);
210
220WS_DLL_PUBLIC unsigned codec_get_channels(codec_handle_t codec, codec_context_t *context);
221
231WS_DLL_PUBLIC unsigned codec_get_frequency(codec_handle_t codec, codec_context_t *context);
232
248WS_DLL_PUBLIC size_t codec_decode(codec_handle_t codec, codec_context_t *context,
249 const void *inputBytes, size_t inputBytesSize,
250 void *outputSamples, size_t *outputSamplesSize);
251
252#ifdef __cplusplus
253}
254#endif /* __cplusplus */
255
256#endif /* _CODECS_H_ */
257
258/*
259 * Editor modelines - https://www.wireshark.org/tools/modelines.html
260 *
261 * Local variables:
262 * c-basic-offset: 4
263 * tab-width: 8
264 * indent-tabs-mode: nil
265 * End:
266 *
267 * vi: set shiftwidth=4 tabstop=8 expandtab:
268 * :indentSize=4:tabSize=8:noTabs=true:
269 */
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:104
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_context_t
struct _codec_context_t codec_context_t
Context structure for audio codec configuration and state.
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:144
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:120
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:97
codec_get_channels_fn
unsigned(* codec_get_channels_fn)(codec_context_t *context)
Get count of channels provided by the codec.
Definition codecs.h:112
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
wmem_map_t
struct _wmem_map_t wmem_map_t
Opaque type representing a wmem-managed hash map.
Definition wmem_map.h:46
_codec_context_t
Context structure for audio codec configuration and state.
Definition codecs.h:75
_codec_context_t::channels
unsigned channels
Definition codecs.h:77
_codec_context_t::sample_rate
unsigned sample_rate
Definition codecs.h:76
_codec_context_t::fmtp_map
wmem_map_t * fmtp_map
Definition codecs.h:78
_codec_context_t::priv
void * priv
Definition codecs.h:79
codec_handle
Definition codecs.c:75
codecs_plugin
Plugin descriptor for a codec module, providing the registration entry point.
Definition codecs.h:28
codecs_plugin::register_codec_module
void(* register_codec_module)(void)
Definition codecs.h:29
wmem_map.h